|
|
|
|
@ -202,9 +202,10 @@ import { listRfidReadRecord, getRfidReadRecord, delRfidReadRecord, addRfidReadRe
|
|
|
|
|
import { RfidReadRecordVO, RfidReadRecordQuery, RfidReadRecordForm } from '@/api/rfid/rfidReadRecord/types';
|
|
|
|
|
import { getRfidDeviceList } from "@/api/rfid/rfidDevice";
|
|
|
|
|
import type { RfidDeviceVO } from '@/api/rfid/rfidDevice/types';
|
|
|
|
|
import { useDict } from '@/utils/dict';
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const { read_status, alarm_level, alarm_flag } = toRefs<any>(proxy?.useDict('read_status', 'alarm_level', 'alarm_flag'));
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const { read_status, alarm_level, alarm_flag } = toRefs(useDict('read_status', 'alarm_level', 'alarm_flag'));
|
|
|
|
|
|
|
|
|
|
const rfidReadRecordList = ref<RfidReadRecordVO[]>([]);
|
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
|
@ -213,6 +214,7 @@ const showSearch = ref(true);
|
|
|
|
|
const ids = ref<Array<string | number>>([]);
|
|
|
|
|
// 当前选中行的记录时间(用于分表定位)
|
|
|
|
|
const selectedRecordTimes = ref<string[]>([]);
|
|
|
|
|
const selectedRecords = ref<RfidReadRecordVO[]>([]);
|
|
|
|
|
const single = ref(true);
|
|
|
|
|
const multiple = ref(true);
|
|
|
|
|
const total = ref(0);
|
|
|
|
|
@ -318,7 +320,7 @@ const getList = async () => {
|
|
|
|
|
|
|
|
|
|
/** 加载设备下拉(设备名称),使用 getRfidDeviceList 获取全量数据 */
|
|
|
|
|
const loadDeviceOptions = async () => {
|
|
|
|
|
const res: any = await getRfidDeviceList({ isMarked: "1" } as any);
|
|
|
|
|
const res = await getRfidDeviceList({ isMarked: "1" });
|
|
|
|
|
deviceOptions.value = res.data || [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -351,12 +353,29 @@ const resetQuery = () => {
|
|
|
|
|
/** 多选框选中数据 */
|
|
|
|
|
const handleSelectionChange = (selection: RfidReadRecordVO[]) => {
|
|
|
|
|
ids.value = selection.map(item => item.id);
|
|
|
|
|
selectedRecords.value = selection;
|
|
|
|
|
// 保存选中行的记录时间,用于分表定位
|
|
|
|
|
selectedRecordTimes.value = selection.map(item => item.recordTime?.substring(0, 10) || '');
|
|
|
|
|
single.value = selection.length != 1;
|
|
|
|
|
multiple.value = !selection.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 按记录日期分组删除,避免跨天批量删除时只打到第一张分表 */
|
|
|
|
|
const buildDeleteGroups = (row?: RfidReadRecordVO): Map<string, Array<string | number>> => {
|
|
|
|
|
const records = row ? [row] : selectedRecords.value;
|
|
|
|
|
const deleteGroups = new Map<string, Array<string | number>>();
|
|
|
|
|
records.forEach((record) => {
|
|
|
|
|
const queryDate = record.recordTime?.substring(0, 10);
|
|
|
|
|
if (!queryDate) {
|
|
|
|
|
throw new Error("读取记录缺少记录时间,无法定位分表");
|
|
|
|
|
}
|
|
|
|
|
const groupIds = deleteGroups.get(queryDate) || [];
|
|
|
|
|
groupIds.push(record.id);
|
|
|
|
|
deleteGroups.set(queryDate, groupIds);
|
|
|
|
|
});
|
|
|
|
|
return deleteGroups;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
|
const handleAdd = () => {
|
|
|
|
|
reset();
|
|
|
|
|
@ -396,12 +415,13 @@ const submitForm = () => {
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
const handleDelete = async (row?: RfidReadRecordVO) => {
|
|
|
|
|
const _ids = row?.id || ids.value;
|
|
|
|
|
// 获取查询日期(用于分表定位)
|
|
|
|
|
const queryDate = row?.recordTime?.substring(0, 10) || selectedRecordTimes.value[0];
|
|
|
|
|
const deleteGroups = buildDeleteGroups(row);
|
|
|
|
|
try {
|
|
|
|
|
await proxy?.$modal.confirm('是否确认删除读取记录编号为"' + _ids + '"的数据项?');
|
|
|
|
|
loading.value = true;
|
|
|
|
|
await delRfidReadRecord(_ids, queryDate);
|
|
|
|
|
for (const [queryDate, groupIds] of deleteGroups) {
|
|
|
|
|
await delRfidReadRecord(groupIds, queryDate);
|
|
|
|
|
}
|
|
|
|
|
proxy?.$modal.msgSuccess("删除成功");
|
|
|
|
|
await getList();
|
|
|
|
|
} finally {
|
|
|
|
|
|