|
|
|
|
@ -149,6 +149,12 @@ link type="primary" @click="openForm('update', scope.row.id)"
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<div class="mb-10px text-right">
|
|
|
|
|
<el-button type="primary" @click="openCreateRuleForm">
|
|
|
|
|
新增告警规则
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
v-loading="ruleLoading"
|
|
|
|
|
:data="ruleList"
|
|
|
|
|
@ -313,6 +319,28 @@ link type="primary" @click="openForm('update', scope.row.id)"
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<el-dialog v-model="createRuleDialogVisible" title="新增告警规则" width="520px" draggable>
|
|
|
|
|
<el-form :model="createRuleForm" ref="createRuleFormRef" label-width="90px">
|
|
|
|
|
<el-form-item label="标识符">
|
|
|
|
|
<el-input v-model="createRuleForm.identifier" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="名称">
|
|
|
|
|
<el-input v-model="createRuleForm.fieldName" placeholder="请输入名称" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="默认值">
|
|
|
|
|
<el-input v-model="createRuleForm.defaultValue" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
<el-button @click="createRuleDialogVisible = false">取 消</el-button>
|
|
|
|
|
<el-button type="primary" :loading="createRuleFormLoading" @click="handleCreateRuleSubmit">
|
|
|
|
|
保 存
|
|
|
|
|
</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
</el-tabs>
|
|
|
|
|
</template>
|
|
|
|
|
@ -546,6 +574,15 @@ const ruleForm = reactive<Partial<DeviceModelRuleVO>>({
|
|
|
|
|
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)
|
|
|
|
|
|