diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index 544e231f..b6efdf8b 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -222,13 +222,21 @@ link :type="isRowConnected(scope.row) ? 'warning' : 'success'" :formatter="dateFormatter" width="180px" /> - - - + + +
-
+
{ const loadRuleAttributeOptions = async (deviceId: number) => { try { - const res = await DeviceApi.getDeviceAttributePage({ pageNo: 1, pageSize: 1000, deviceId }) - const data = Array.isArray((res as any)?.list) ? (res as any).list : (Array.isArray(res) ? res : []) + const res = await request.get({ url: '/iot/device-contact-model/list', params: { id: deviceId } }) + const data = Array.isArray(res) ? res : (res as any)?.list ?? [] ruleAttributeOptions.value = data as any[] } catch { ruleAttributeOptions.value = [] @@ -638,7 +646,7 @@ watch( return } ruleQueryParams.pageNo = 1 - await Promise.all([getRuleList(), loadRuleAttributeOptions(val)]) + await getRuleList() } ) @@ -704,7 +712,15 @@ const isRunningIdentifier = computed(() => { return (ruleForm.identifier || '').toString().toUpperCase() === 'RUNNING' }) -const openRuleForm = (row: DevicePointRuleVO & { pointRulesVOList?: any[] }) => { +const openRuleForm = async (row: DevicePointRuleVO & { pointRulesVOList?: any[] }) => { + const deviceId = row.deviceId || attributeDeviceId.value + if (!deviceId) { + message.error('设备信息缺失,无法加载点位规则') + return + } + + await loadRuleAttributeOptions(deviceId) + ruleForm.id = row.id ruleForm.identifier = row.identifier ruleForm.fieldName = row.fieldName @@ -785,6 +801,16 @@ const handleRuleSubmit = async () => { } } +const handleRuleDelete = async (id: number) => { + if (!id) return + try { + await message.delConfirm() + await request.delete({ url: '/iot/device-point-rules/delete?id=' + id }) + message.success(t('common.delSuccess')) + await getRuleList() + } catch { } +} + const handleAddPointRule = () => { if (!isRunningIdentifier.value) return const allOptions = currentRuleOptions.value || []