|
|
|
@ -333,7 +333,10 @@
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="mb-10px text-right">
|
|
|
|
<div class="mb-10px flex justify-end gap-8px">
|
|
|
|
|
|
|
|
<el-button type="primary" plain @click="openCreateCountRuleForm">
|
|
|
|
|
|
|
|
新增产量
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
<el-button type="primary" @click="openCreateRuleForm">
|
|
|
|
<el-button type="primary" @click="openCreateRuleForm">
|
|
|
|
{{ t('DataCollection.DeviceModel.ruleCreateButton') }}
|
|
|
|
{{ t('DataCollection.DeviceModel.ruleCreateButton') }}
|
|
|
|
</el-button>
|
|
|
|
</el-button>
|
|
|
|
@ -364,7 +367,7 @@
|
|
|
|
{{ t('DataCollection.DeviceModel.ruleEditRuleButton') }}
|
|
|
|
{{ t('DataCollection.DeviceModel.ruleEditRuleButton') }}
|
|
|
|
</el-button>
|
|
|
|
</el-button>
|
|
|
|
<el-button
|
|
|
|
<el-button
|
|
|
|
v-if="(scope.row.identifier || '').toString().toUpperCase() === 'ALARM'"
|
|
|
|
v-if="scope.row.identifier === 'ALARM' || scope.row.identifier === 'COUNT'"
|
|
|
|
link
|
|
|
|
link
|
|
|
|
type="danger"
|
|
|
|
type="danger"
|
|
|
|
@click="handleRuleDelete(scope.row.id)"
|
|
|
|
@click="handleRuleDelete(scope.row.id)"
|
|
|
|
@ -411,7 +414,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-col w-full">
|
|
|
|
<div class="flex flex-col w-full">
|
|
|
|
<div class="border border-gray-200 dark:border-gray-600 rounded-md py-12px">
|
|
|
|
<div class="border border-gray-200 dark:border-gray-600 rounded-md py-12px">
|
|
|
|
<el-form-item :label="t('DataCollection.DeviceModel.ruleDialogFieldRule')">
|
|
|
|
<el-form-item
|
|
|
|
|
|
|
|
v-if="!isCountIdentifier"
|
|
|
|
|
|
|
|
:label="t('DataCollection.DeviceModel.ruleDialogFieldRule')"
|
|
|
|
|
|
|
|
>
|
|
|
|
<el-select
|
|
|
|
<el-select
|
|
|
|
v-model="ruleForm.fieldRule"
|
|
|
|
v-model="ruleForm.fieldRule"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogFieldRulePlaceholder')"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogFieldRulePlaceholder')"
|
|
|
|
@ -427,7 +433,7 @@
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('DataCollection.DeviceModel.ruleDialogRule')">
|
|
|
|
<el-form-item :label="isCountIdentifier ? '四则运算规则' : t('DataCollection.DeviceModel.ruleDialogRule')">
|
|
|
|
<div class="flex items-center gap-8px">
|
|
|
|
<div class="flex items-center gap-8px">
|
|
|
|
<el-select
|
|
|
|
<el-select
|
|
|
|
v-model="ruleForm.ruleAttributeId"
|
|
|
|
v-model="ruleForm.ruleAttributeId"
|
|
|
|
@ -447,14 +453,14 @@
|
|
|
|
class="!w-160px"
|
|
|
|
class="!w-160px"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<el-option
|
|
|
|
<el-option
|
|
|
|
v-for="item in ruleOperatorOptions"
|
|
|
|
v-for="item in currentRuleOperatorOptions"
|
|
|
|
:key="item.value"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-select>
|
|
|
|
<el-input
|
|
|
|
<el-input
|
|
|
|
v-if="ruleForm.ruleOperator !== 'TRUE' && ruleForm.ruleOperator !== 'FALSE'"
|
|
|
|
v-if="isCountIdentifier || (ruleForm.ruleOperator !== 'TRUE' && ruleForm.ruleOperator !== 'FALSE')"
|
|
|
|
v-model="ruleForm.ruleValue"
|
|
|
|
v-model="ruleForm.ruleValue"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogRuleValuePlaceholder')"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogRuleValuePlaceholder')"
|
|
|
|
class="!w-200px"
|
|
|
|
class="!w-200px"
|
|
|
|
@ -463,6 +469,7 @@
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template v-if="isRunningIdentifier">
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
v-for="(item, index) in extraPointRules"
|
|
|
|
v-for="(item, index) in extraPointRules"
|
|
|
|
:key="index"
|
|
|
|
:key="index"
|
|
|
|
@ -510,7 +517,7 @@
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-select>
|
|
|
|
<el-input
|
|
|
|
<el-input
|
|
|
|
v-if="item.operator !== 'TRUE' && item.operator !== 'FALSE'"
|
|
|
|
v-if="isCountIdentifier || (item.operator !== 'TRUE' && item.operator !== 'FALSE')"
|
|
|
|
v-model="item.operatorRule"
|
|
|
|
v-model="item.operatorRule"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogRuleValuePlaceholder')"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogRuleValuePlaceholder')"
|
|
|
|
class="!w-200px"
|
|
|
|
class="!w-200px"
|
|
|
|
@ -521,6 +528,7 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item v-if="isRunningIdentifier" label=" ">
|
|
|
|
<el-form-item v-if="isRunningIdentifier" label=" ">
|
|
|
|
<el-button type="primary" link @click="handleAddPointRule">
|
|
|
|
<el-button type="primary" link @click="handleAddPointRule">
|
|
|
|
@ -537,7 +545,7 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
|
|
<el-dialog v-model="createRuleDialogVisible" :title="t('DataCollection.DeviceModel.ruleCreateButton')" width="520px" draggable>
|
|
|
|
<el-dialog v-model="createRuleDialogVisible" :title="createRuleDialogTitle" width="520px" draggable>
|
|
|
|
<el-form :model="createRuleForm" ref="createRuleFormRef" label-width="120px">
|
|
|
|
<el-form :model="createRuleForm" ref="createRuleFormRef" label-width="120px">
|
|
|
|
<el-form-item :label="t('DataCollection.DeviceModel.ruleDialogIdentifier')">
|
|
|
|
<el-form-item :label="t('DataCollection.DeviceModel.ruleDialogIdentifier')">
|
|
|
|
<el-input v-model="createRuleForm.identifier" disabled />
|
|
|
|
<el-input v-model="createRuleForm.identifier" disabled />
|
|
|
|
@ -551,7 +559,7 @@
|
|
|
|
<el-form-item :label="t('DataCollection.DeviceModel.ruleDialogDefaultValue')">
|
|
|
|
<el-form-item :label="t('DataCollection.DeviceModel.ruleDialogDefaultValue')">
|
|
|
|
<el-input v-model="createRuleForm.defaultValue" disabled />
|
|
|
|
<el-input v-model="createRuleForm.defaultValue" disabled />
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('DataCollection.DeviceModel.ruleDialogAlarmLevel')">
|
|
|
|
<el-form-item v-if="!isCreateCountRule" :label="t('DataCollection.DeviceModel.ruleDialogAlarmLevel')">
|
|
|
|
<el-select
|
|
|
|
<el-select
|
|
|
|
v-model="createRuleForm.alarmLevel"
|
|
|
|
v-model="createRuleForm.alarmLevel"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogAlarmLevelPlaceholder')"
|
|
|
|
:placeholder="t('DataCollection.DeviceModel.ruleDialogAlarmLevelPlaceholder')"
|
|
|
|
@ -1089,6 +1097,12 @@ const runningRuleOptions = [
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
const alarmRuleOptions = [{ value: '5', label: '报警' }]
|
|
|
|
const alarmRuleOptions = [{ value: '5', label: '报警' }]
|
|
|
|
|
|
|
|
const countOperatorOptions = [
|
|
|
|
|
|
|
|
{ value: '+', label: '加' },
|
|
|
|
|
|
|
|
{ value: '-', label: '减' },
|
|
|
|
|
|
|
|
{ value: '*', label: '乘' },
|
|
|
|
|
|
|
|
{ value: '/', label: '除' },
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
const currentRuleOptions = computed(() => {
|
|
|
|
const currentRuleOptions = computed(() => {
|
|
|
|
const id = (ruleForm.identifier || '').toString().toUpperCase()
|
|
|
|
const id = (ruleForm.identifier || '').toString().toUpperCase()
|
|
|
|
@ -1114,6 +1128,13 @@ const isRuleDisabled = (value: string, selfRule?: string | number) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ruleOperatorOptions = computed(() => getStrDictOptions('czsb_rules_conditions'))
|
|
|
|
const ruleOperatorOptions = computed(() => getStrDictOptions('czsb_rules_conditions'))
|
|
|
|
|
|
|
|
const isCountIdentifier = computed(() => {
|
|
|
|
|
|
|
|
return (ruleForm.identifier || '').toString().toUpperCase() === 'COUNT'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const currentRuleOperatorOptions = computed(() => {
|
|
|
|
|
|
|
|
if (isCountIdentifier.value) return countOperatorOptions
|
|
|
|
|
|
|
|
return ruleOperatorOptions.value
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const isRunningIdentifier = computed(() => {
|
|
|
|
const isRunningIdentifier = computed(() => {
|
|
|
|
return (ruleForm.identifier || '').toString().toUpperCase() === 'RUNNING'
|
|
|
|
return (ruleForm.identifier || '').toString().toUpperCase() === 'RUNNING'
|
|
|
|
@ -1224,8 +1245,10 @@ const handleRuleSubmit = async () => {
|
|
|
|
fieldRule: ruleForm.fieldRule,
|
|
|
|
fieldRule: ruleForm.fieldRule,
|
|
|
|
defaultValue: ruleForm.defaultValue,
|
|
|
|
defaultValue: ruleForm.defaultValue,
|
|
|
|
deviceId: ruleForm.deviceId ?? attributeDeviceId.value,
|
|
|
|
deviceId: ruleForm.deviceId ?? attributeDeviceId.value,
|
|
|
|
alarmLevel: ruleForm.alarmLevel,
|
|
|
|
|
|
|
|
pointRulesVOList,
|
|
|
|
pointRulesVOList,
|
|
|
|
|
|
|
|
} as any
|
|
|
|
|
|
|
|
if (!isCountIdentifier.value) {
|
|
|
|
|
|
|
|
payload.alarmLevel = ruleForm.alarmLevel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await request.put({ url: '/iot/device-point-rules/update', data: payload })
|
|
|
|
await request.put({ url: '/iot/device-point-rules/update', data: payload })
|
|
|
|
@ -1282,6 +1305,13 @@ const createRuleForm = reactive({
|
|
|
|
defaultValue: '报警',
|
|
|
|
defaultValue: '报警',
|
|
|
|
alarmLevel: '',
|
|
|
|
alarmLevel: '',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const isCreateCountRule = computed(() => {
|
|
|
|
|
|
|
|
return createRuleForm.identifier.toString().toUpperCase() === 'COUNT'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const createRuleDialogTitle = computed(() => {
|
|
|
|
|
|
|
|
if (isCreateCountRule.value) return '新增产量'
|
|
|
|
|
|
|
|
return t('DataCollection.DeviceModel.ruleCreateButton')
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const openCreateRuleForm = () => {
|
|
|
|
const openCreateRuleForm = () => {
|
|
|
|
if (!attributeDeviceId.value) {
|
|
|
|
if (!attributeDeviceId.value) {
|
|
|
|
@ -1294,6 +1324,17 @@ const openCreateRuleForm = () => {
|
|
|
|
createRuleForm.alarmLevel = ''
|
|
|
|
createRuleForm.alarmLevel = ''
|
|
|
|
createRuleDialogVisible.value = true
|
|
|
|
createRuleDialogVisible.value = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const openCreateCountRuleForm = () => {
|
|
|
|
|
|
|
|
if (!attributeDeviceId.value) {
|
|
|
|
|
|
|
|
message.error('请先选择设备')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
createRuleForm.identifier = 'COUNT'
|
|
|
|
|
|
|
|
createRuleForm.fieldName = '产能'
|
|
|
|
|
|
|
|
createRuleForm.defaultValue = '产能'
|
|
|
|
|
|
|
|
createRuleForm.alarmLevel = ''
|
|
|
|
|
|
|
|
createRuleDialogVisible.value = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleCreateRuleSubmit = async () => {
|
|
|
|
const handleCreateRuleSubmit = async () => {
|
|
|
|
if (!attributeDeviceId.value) return
|
|
|
|
if (!attributeDeviceId.value) return
|
|
|
|
@ -1307,8 +1348,10 @@ const handleCreateRuleSubmit = async () => {
|
|
|
|
identifier: createRuleForm.identifier,
|
|
|
|
identifier: createRuleForm.identifier,
|
|
|
|
fieldName: createRuleForm.fieldName,
|
|
|
|
fieldName: createRuleForm.fieldName,
|
|
|
|
defaultValue: createRuleForm.defaultValue,
|
|
|
|
defaultValue: createRuleForm.defaultValue,
|
|
|
|
alarmLevel: createRuleForm.alarmLevel,
|
|
|
|
|
|
|
|
deviceId: attributeDeviceId.value,
|
|
|
|
deviceId: attributeDeviceId.value,
|
|
|
|
|
|
|
|
} as any
|
|
|
|
|
|
|
|
if (!isCreateCountRule.value) {
|
|
|
|
|
|
|
|
payload.alarmLevel = createRuleForm.alarmLevel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await request.post({ url: '/iot/device-point-rules/create', data: payload })
|
|
|
|
await request.post({ url: '/iot/device-point-rules/create', data: payload })
|
|
|
|
message.success('新增成功')
|
|
|
|
message.success('新增成功')
|
|
|
|
|