|
|
@@ -50,7 +50,6 @@ const alarmColumns = ref([]);
|
|
|
|
|
|
const deviceOptions = ref<any>([]);
|
|
|
const deviceList = ref<DeviceType[]>([]);
|
|
|
-// 设备名称选项:用 ref 保证响应式
|
|
|
const deviceNameOptions = ref<any>([]);
|
|
|
|
|
|
const strtype = ref('');
|
|
|
@@ -60,7 +59,6 @@ const scroll = reactive({ y: 180 });
|
|
|
const activeKey = ref('1');
|
|
|
const deviceActive = ref('');
|
|
|
|
|
|
-// 设备类型下拉(计算属性)
|
|
|
const deviceTypeSelectOptions = computed(() => {
|
|
|
return deviceList.value.map((item) => ({
|
|
|
label: item.deviceName,
|
|
|
@@ -68,9 +66,33 @@ const deviceTypeSelectOptions = computed(() => {
|
|
|
}));
|
|
|
});
|
|
|
|
|
|
-function tabChange(activeKeyVal) {
|
|
|
+async function tabChange(activeKeyVal) {
|
|
|
activeKey.value = activeKeyVal;
|
|
|
- activeKey.value === '1' ? reload() : reloadOperate();
|
|
|
+ await nextTick();
|
|
|
+
|
|
|
+ if (activeKey.value === '2') {
|
|
|
+ const form = getForm();
|
|
|
+ const values = form.getFieldsValue();
|
|
|
+ const operateForm = operateTableContext[1].getForm?.();
|
|
|
+ if (operateForm) {
|
|
|
+ operateForm.setFieldsValue(values);
|
|
|
+ }
|
|
|
+ loadOperateColumns();
|
|
|
+ reloadOperate();
|
|
|
+ } else if (activeKey.value === '3') {
|
|
|
+ const form = getForm();
|
|
|
+ const values = form.getFieldsValue();
|
|
|
+ const alarmForm = AlarmTableContext[1].getForm?.();
|
|
|
+ if (alarmForm) {
|
|
|
+ alarmForm.setFieldsValue(values);
|
|
|
+ }
|
|
|
+ loadAlarmColumns();
|
|
|
+ reloadAlarm();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (activeKey.value === '1') {
|
|
|
+ reload();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async function fetchDeviceHistory() {
|
|
|
@@ -84,6 +106,7 @@ async function fetchDeviceHistory() {
|
|
|
ttime_end: formData.ttime_end,
|
|
|
gdeviceids: formData.gdeviceids,
|
|
|
strtype: strtype.value,
|
|
|
+ skip: formData.skip,
|
|
|
};
|
|
|
const res = await getDeviceHistoryApi(p);
|
|
|
return {
|
|
|
@@ -91,7 +114,7 @@ async function fetchDeviceHistory() {
|
|
|
records: res?.datalist?.records?.map((item) => ({ ...item, ...item.readData })) || [],
|
|
|
};
|
|
|
}
|
|
|
-// 获取操作历史
|
|
|
+
|
|
|
async function fetchOperateHistory() {
|
|
|
const formData = getForm().getFieldsValue();
|
|
|
const pagination = getPaginationRef();
|
|
|
@@ -101,11 +124,11 @@ async function fetchOperateHistory() {
|
|
|
createTime_begin: formData.ttime_begin,
|
|
|
createTime_end: formData.ttime_end,
|
|
|
devicetype: strtype.value ? strtype.value + '*' : '',
|
|
|
+ skip: formData.skip,
|
|
|
};
|
|
|
const res = await getDevicesetLog(p);
|
|
|
return { total: res?.total || 0, records: res?.records || [] };
|
|
|
}
|
|
|
-// 获取预警历史
|
|
|
|
|
|
async function fetchAlarmHistory() {
|
|
|
const formData = getForm().getFieldsValue();
|
|
|
@@ -117,6 +140,7 @@ async function fetchAlarmHistory() {
|
|
|
createTime_end: formData.ttime_end,
|
|
|
devicetype: strtype.value ? strtype.value + '*' : '',
|
|
|
gdeviceids: formData.gdeviceids,
|
|
|
+ skip: formData.skip,
|
|
|
};
|
|
|
const res = await getAlarmList(p);
|
|
|
return { total: res?.total || 0, records: res?.records || [] };
|
|
|
@@ -138,7 +162,6 @@ async function getDeviceList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 查询表单
|
|
|
const getSchemas = () => [
|
|
|
{
|
|
|
field: 'ttime_begin',
|
|
|
@@ -186,16 +209,13 @@ const getSchemas = () => [
|
|
|
onChange: async (value) => {
|
|
|
const selectedType = deviceList.value.find((item) => item.deviceType === value);
|
|
|
if (selectedType) {
|
|
|
- // 1. 先更新设备名称选项
|
|
|
deviceNameOptions.value = selectedType.datalist.map((item) => ({
|
|
|
label: item.strname,
|
|
|
value: item.deviceID,
|
|
|
deviceKind: item.deviceType,
|
|
|
}));
|
|
|
deviceNameOptions.value = [...deviceNameOptions.value];
|
|
|
- console.log(deviceNameOptions.value, '=============');
|
|
|
await nextTick();
|
|
|
- // 4. 设置表单值
|
|
|
if (deviceNameOptions.value.length) {
|
|
|
getForm().setFieldsValue({
|
|
|
gdeviceids: deviceNameOptions.value[0].value,
|
|
|
@@ -207,11 +227,8 @@ const getSchemas = () => [
|
|
|
strtype.value = selectedType.deviceType;
|
|
|
historyType.value = selectedType.deviceType;
|
|
|
|
|
|
- if (activeKey.value === '2') {
|
|
|
- await loadOperateColumns();
|
|
|
- } else if (activeKey.value === '3') {
|
|
|
- await loadAlarmColumns();
|
|
|
- }
|
|
|
+ if (activeKey.value === '2') loadOperateColumns();
|
|
|
+ if (activeKey.value === '3') loadAlarmColumns();
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
@@ -229,11 +246,9 @@ const getSchemas = () => [
|
|
|
onChange: (_, option) => {
|
|
|
historyType.value = option.deviceKind;
|
|
|
strtype.value = option.deviceKind;
|
|
|
- if (activeKey.value === '2') {
|
|
|
- loadOperateColumns();
|
|
|
- } else if (activeKey.value === '3') {
|
|
|
- loadAlarmColumns();
|
|
|
- }
|
|
|
+
|
|
|
+ if (activeKey.value === '2') loadOperateColumns();
|
|
|
+ if (activeKey.value === '3') loadAlarmColumns();
|
|
|
},
|
|
|
},
|
|
|
required: true,
|
|
|
@@ -266,7 +281,6 @@ function loadOperateColumns() {
|
|
|
setOperateColumns(cols);
|
|
|
}
|
|
|
|
|
|
-// 历史数据表格
|
|
|
const { tableContext } = useListPage({
|
|
|
tableProps: {
|
|
|
api: fetchDeviceHistory,
|
|
|
@@ -287,7 +301,6 @@ const { tableContext } = useListPage({
|
|
|
});
|
|
|
const [registerTable, { getForm, setColumns, getPaginationRef, reload }] = tableContext;
|
|
|
|
|
|
-// 操作历史表格
|
|
|
const { tableContext: operateTableContext } = useListPage({
|
|
|
tableProps: {
|
|
|
api: fetchOperateHistory,
|
|
|
@@ -308,7 +321,6 @@ const { tableContext: operateTableContext } = useListPage({
|
|
|
});
|
|
|
const [registerOperateTable, { setColumns: setOperateColumns, reload: reloadOperate }] = operateTableContext;
|
|
|
|
|
|
-// 获取设备类型列表
|
|
|
async function getDeviceTypeList(value) {
|
|
|
const res = await systemList({ devicetype: 'sys', systemID: value });
|
|
|
const result = res.msgTxt;
|
|
|
@@ -347,16 +359,16 @@ async function getDeviceTypeList(value) {
|
|
|
columns.value = getTableHeaderColumns(columnKey);
|
|
|
if (columns.value && columns.value.length) {
|
|
|
setColumns(columns.value);
|
|
|
- reload();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
function loadAlarmColumns() {
|
|
|
const cols = getTableHeaderColumns('alarm_history');
|
|
|
alarmColumns.value = cols;
|
|
|
setAlarmColumns(cols);
|
|
|
}
|
|
|
-// 预警历史表格
|
|
|
+
|
|
|
const { tableContext: AlarmTableContext } = useListPage({
|
|
|
tableProps: {
|
|
|
api: fetchAlarmHistory,
|