diff --git a/src/views/run/instant/index.vue b/src/views/run/instant/index.vue index e483859..f8d35ea 100644 --- a/src/views/run/instant/index.vue +++ b/src/views/run/instant/index.vue @@ -31,6 +31,18 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] rowKey: 'mpId', immediate: true, columns, + afterFetch: async (data) => { + // data 就是表格当前页的数据数组 + for (const row of data) { + // 解析获取点号 + const pointCode = (JSON.parse(row.instantInfo)).model_state + //读取实时值 + const realValue = await getExaNow(pointCode); + // 更新当前行 + updateTableDataRecord(row.mpId, Object.assign(row, { pointSte: realValue })) + + } + }, formConfig: { labelWidth: 80, schemas: searchSchema.value, @@ -100,10 +112,6 @@ interface countObj { const countData = ref() onMounted(async () => { countData.value = await getInstantCount() - console.log(countData.value) - const { setFieldsValue } = getForm() - await setFieldsValue({ system: null }) - getNow() }) async function getTableData(type) { const { getFieldsValue, setFieldsValue } = getForm() @@ -129,21 +137,6 @@ async function getTableData(type) { } reload() } -async function getNow() { - const params = getDataSource() - params.forEach((item: any) => { - const pointCode = (JSON.parse(item.instantInfo)).model_state - // 对数组中的每个元素执行异步操作 - getExaNow(pointCode).then((result) => { - updateTableDataRecord(item.id, Object.assign(item, { pointSte: result })) - }) - .catch((error) => { - console.error('Error:', error) - updateTableDataRecord(item.id, Object.assign(item, { pointSte: pointCode })) - }) - }) -} - function handleWarnConfig(record: Recordable) { router.push(`/run/instant/warn/config?mpId=${record.mpId}`) } @@ -168,9 +161,9 @@ function handleWarnConfig(record: Recordable) {