style:采集设备-点位规则-规则下拉接口修改,添加删除按钮

main
黄伟杰 2 months ago
parent c7bd47b73b
commit 706edf7dad

@ -222,13 +222,21 @@ link :type="isRowConnected(scope.row) ? 'warning' : 'success'"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center" width="120px">
<template #default="scope">
<el-button link type="primary" @click="openRuleForm(scope.row)">
编辑
</el-button>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160px">
<template #default="scope">
<el-button link type="primary" @click="openRuleForm(scope.row)">
编辑
</el-button>
<el-button
v-if="(scope.row.identifier || '').toString().toUpperCase() === 'ALARM'"
link
type="danger"
@click="handleRuleDelete(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<Pagination
:total="ruleTotal"
@ -250,7 +258,7 @@ link :type="isRowConnected(scope.row) ? 'warning' : 'success'"
</el-form-item>
<div class="flex flex-col w-full">
<div class="border border-gray-200 dark:border-gray-600 rounded-md px-16px py-12px">
<div class="border border-gray-200 dark:border-gray-600 rounded-md py-12px">
<el-form-item label="点位规则">
<el-select
v-model="ruleForm.fieldRule"
@ -619,8 +627,8 @@ const resetRuleQuery = () => {
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 || []

Loading…
Cancel
Save