From 4392c41e1a268e551aaf90b48c1f1c82ff6fe846 Mon Sep 17 00:00:00 2001 From: hwj Date: Thu, 22 Jan 2026 09:57:21 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E9=87=87=E9=9B=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=A8=A1=E5=9E=8B-=E7=82=B9=E4=BD=8D=E8=A7=84?= =?UTF-8?q?=E5=88=99-=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=A2=9E=E5=BC=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/iot/devicemodel/index.vue | 71 +++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/views/iot/devicemodel/index.vue b/src/views/iot/devicemodel/index.vue index 1b8cf46c..f844aa4d 100644 --- a/src/views/iot/devicemodel/index.vue +++ b/src/views/iot/devicemodel/index.vue @@ -149,6 +149,12 @@ link type="primary" @click="openForm('update', scope.row.id)" +
+ + 新增告警规则 + +
+ + + + + + + + + + + + + + + + @@ -546,6 +574,15 @@ const ruleForm = reactive>({ ruleValue: undefined, }) +const createRuleDialogVisible = ref(false) +const createRuleFormLoading = ref(false) +const createRuleFormRef = ref() +const createRuleForm = reactive({ + identifier: 'ALARM', + fieldName: '', + defaultValue: '报警', +}) + const extraPointRules = ref< Array<{ id?: number @@ -601,6 +638,17 @@ const isRunningIdentifier = computed(() => { return (ruleForm.identifier || '').toString().toUpperCase() === 'RUNNING' }) +const openCreateRuleForm = () => { + if (!attributeModelId.value) { + message.error('请先选择模型') + return + } + createRuleForm.identifier = 'ALARM' + createRuleForm.fieldName = '报警' + createRuleForm.defaultValue = '报警' + createRuleDialogVisible.value = true +} + const openRuleForm = (row: DeviceModelRuleVO & { pointRulesVOList?: any[] }) => { ruleForm.id = row.id ruleForm.identifier = row.identifier @@ -703,6 +751,29 @@ const handleAddPointRule = () => { }) } +const handleCreateRuleSubmit = async () => { + if (!attributeModelId.value) return + if (!createRuleForm.fieldName) { + message.warning('请输入名称') + return + } + try { + createRuleFormLoading.value = true + const payload = { + identifier: createRuleForm.identifier, + fieldName: createRuleForm.fieldName, + defaultValue: createRuleForm.defaultValue, + modelId: attributeModelId.value, + } + await request.post({ url: '/iot/device-model-rules/create', data: payload }) + message.success('新增成功') + createRuleDialogVisible.value = false + await getRuleList() + } finally { + createRuleFormLoading.value = false + } +} + const handleRemovePointRule = (index: number) => { if (index < 0 || index >= extraPointRules.value.length) return extraPointRules.value.splice(index, 1)