|
@@ -14,20 +14,33 @@
|
|
|
:label-col="{ style: { width: '110px', justifyContent: 'end' } }"
|
|
|
>
|
|
|
<a-row :gutter="10">
|
|
|
+ <!-- 选择点位 -->
|
|
|
+ <div class="dict">
|
|
|
+ <span>点位标签:</span>
|
|
|
+ <a-radio-group
|
|
|
+ v-model:value="pointName"
|
|
|
+ :options="pointOptions"
|
|
|
+ option-type="button"
|
|
|
+ @change="pointNameChange(pointName)"
|
|
|
+ >
|
|
|
+ </a-radio-group>
|
|
|
+ </div>
|
|
|
+
|
|
|
<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
|
- <a-form-item label="监控对象" name="monitorTargetId">
|
|
|
+ <a-form-item label="监测对象" name="monitorTargetId">
|
|
|
<a-select
|
|
|
ref="select"
|
|
|
v-model:value="formData.monitorTargetId"
|
|
|
:options="monitorTargetOptions"
|
|
|
- placeholder="请选择监控对象"
|
|
|
+ placeholder="请选择监测对象"
|
|
|
+ :field-names="{ label: 'name', value: 'id' }"
|
|
|
disabled
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
|
<a-form-item label="点位名称" name="name">
|
|
|
- <a-input :value="formData.name" placeholder="请输入点位名称" allow-clear @input="nameInput" />
|
|
|
+ <a-input :value="formData.name" placeholder="请输入点位名称" allow-clear @input="nameInput" :max="20" />
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
@@ -49,6 +62,7 @@
|
|
|
v-model:value="formData.monitorDeviceId"
|
|
|
:options="memListOptions"
|
|
|
placeholder="请选择监测设备"
|
|
|
+ :field-names="{ label: 'deviceName', value: 'id' }"
|
|
|
@change="monitorDeviceIdChange"
|
|
|
/>
|
|
|
</a-form-item>
|
|
@@ -73,17 +87,35 @@
|
|
|
<!-- 报警接收人 -->
|
|
|
<a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
<a-form-item label="报警接收人" name="alarmUsers">
|
|
|
- <a-select
|
|
|
- v-model:value="formData.alarmUsers"
|
|
|
- mode="multiple"
|
|
|
- style="width: 100%"
|
|
|
- placeholder="请选择报警接收人"
|
|
|
- :options="alarmUsersOptions"
|
|
|
- :field-names="{ label: 'nickName', value: 'openId' }"
|
|
|
- ></a-select>
|
|
|
+ <a-checkbox-group v-model:value="formData.alarmUsers" name="checkboxgroup">
|
|
|
+ <a-checkbox
|
|
|
+ v-for="option in alarmUsersOptions"
|
|
|
+ :key="option.openId"
|
|
|
+ :value="option.openId"
|
|
|
+ :label="option.nickName"
|
|
|
+ >
|
|
|
+ {{ option.nickName }}
|
|
|
+ </a-checkbox>
|
|
|
+ </a-checkbox-group>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
|
|
|
+ <!-- 选择冰箱型号 -->
|
|
|
+ <div class="dict" v-if="!formData.id && formData.sensorType && formData.monitorDeviceId">
|
|
|
+ <span>冰箱型号:</span>
|
|
|
+ <a-radio-group v-model:value="fridgeName" option-type="button" @change="fridgeNameChange(fridgeName)">
|
|
|
+ <a-radio-button
|
|
|
+ v-for="e in filteredFridges"
|
|
|
+ :key="e.value"
|
|
|
+ :value="e.value"
|
|
|
+ :label="e.label"
|
|
|
+ :disabled="e.disabled"
|
|
|
+ >
|
|
|
+ <database-outlined /> {{ e.label }}</a-radio-button
|
|
|
+ >
|
|
|
+ </a-radio-group>
|
|
|
+ </div>
|
|
|
+
|
|
|
<div
|
|
|
class="form_item"
|
|
|
v-if="formData.sensorType == 'W' || formData.sensorType == 'WS' || formData.sensorType == 'WSC'"
|
|
@@ -95,10 +127,10 @@
|
|
|
v-model:value="formData.temperatureUp"
|
|
|
placeholder="请输入温度上限"
|
|
|
allow-clear
|
|
|
- :min="temperatureMax.downMax"
|
|
|
- :max="temperatureMax.upMax"
|
|
|
+ :min="currentMonitorDevice.temperatureDown"
|
|
|
+ :max="currentMonitorDevice.temperatureUp"
|
|
|
style="width: 100%"
|
|
|
- :disabled="temperatureMax.upMax == null || temperatureMax.upMax == undefined"
|
|
|
+ :disabled="!currentMonitorDevice.temperatureUp"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
@@ -109,10 +141,10 @@
|
|
|
v-model:value="formData.temperatureDown"
|
|
|
placeholder="请输入温度下限"
|
|
|
allow-clear
|
|
|
- :min="temperatureMax.downMax"
|
|
|
- :max="temperatureMax.upMax"
|
|
|
+ :min="currentMonitorDevice.temperatureDown"
|
|
|
+ :max="currentMonitorDevice.temperatureUp"
|
|
|
style="width: 100%"
|
|
|
- :disabled="!temperatureMax.downMax == null || temperatureMax.downMax == undefined"
|
|
|
+ :disabled="!currentMonitorDevice.temperatureDown"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
@@ -126,10 +158,10 @@
|
|
|
v-model:value="formData.humidityUp"
|
|
|
placeholder="请输入湿度上限"
|
|
|
allow-clear
|
|
|
- :min="humidityMax.downMax"
|
|
|
- :max="humidityMax.upMax"
|
|
|
+ :min="currentMonitorDevice.humidityDown"
|
|
|
+ :max="currentMonitorDevice.humidityUp"
|
|
|
style="width: 100%"
|
|
|
- :disabled="!humidityMax.upMax"
|
|
|
+ :disabled="!currentMonitorDevice.humidityUp"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
@@ -140,10 +172,10 @@
|
|
|
v-model:value="formData.humidityDown"
|
|
|
placeholder="请输入湿度下限"
|
|
|
allow-clear
|
|
|
- :min="humidityMax.downMax"
|
|
|
- :max="humidityMax.upMax"
|
|
|
+ :min="currentMonitorDevice.humidityDown"
|
|
|
+ :max="currentMonitorDevice.humidityUp"
|
|
|
style="width: 100%"
|
|
|
- :disabled="!humidityMax.downMax"
|
|
|
+ :disabled="!currentMonitorDevice.humidityDown"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
@@ -157,9 +189,10 @@
|
|
|
v-model:value="formData.co2Up"
|
|
|
placeholder="请输入CO2上限"
|
|
|
allow-clear
|
|
|
- :max="co2Max.upMax"
|
|
|
- :min="co2Max.downMax"
|
|
|
+ :max="currentMonitorDevice.co2Up"
|
|
|
+ :min="currentMonitorDevice.co2Down"
|
|
|
style="width: 100%"
|
|
|
+ :disabled="!currentMonitorDevice.co2Up"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
@@ -170,13 +203,20 @@
|
|
|
v-model:value="formData.co2Down"
|
|
|
placeholder="请输入CO2下限"
|
|
|
allow-clear
|
|
|
- :max="co2Max.upMax"
|
|
|
- :min="co2Max.downMax"
|
|
|
+ :max="currentMonitorDevice.co2Up"
|
|
|
+ :min="currentMonitorDevice.co2Down"
|
|
|
style="width: 100%"
|
|
|
+ :disabled="!currentMonitorDevice.co2Down"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
</div>
|
|
|
+
|
|
|
+ <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
+ <a-form-item label="勿扰设置">
|
|
|
+ <a-time-range-picker v-model:value="formData.time" value-format="HH:mm:ss" style="width: 80%" show-time />
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
</a-row>
|
|
|
</a-form>
|
|
|
|
|
@@ -199,22 +239,23 @@
|
|
|
const emit = defineEmits({ successful: null })
|
|
|
const visible = ref(false) // 默认是关闭状态
|
|
|
const formRef = ref()
|
|
|
- const formData = ref({ alarmUsers: [] }) // 表单数据
|
|
|
+ const formData = ref({ alarmUsers: [], time: [] }) // 表单数据
|
|
|
+ const pointOptions = tool.dictList('MONITORPOINT') // 点位名称
|
|
|
+ const pointName = ref('上层')
|
|
|
+ const currentMonitorObj = ref({}) //当前的监测对象
|
|
|
const sensorOptions = tool.dictList('SENSORTYPE') // 传感器类型
|
|
|
- const monitorTargetOptions = ref([]) // 监控对象
|
|
|
- const memListOptions = ref([]) // 监测设备数据
|
|
|
const alarmUsersOptions = ref([]) // 报警接收人数据
|
|
|
-
|
|
|
- const temperatureMax = ref({ upMax: Infinity, downMax: Infinity }) // 温度最大值
|
|
|
- const humidityMax = ref({ upMax: Infinity, downMax: Infinity }) // 湿度最大值
|
|
|
- const co2Max = ref({ upMax: Infinity, downMax: Infinity }) // CO2最大值
|
|
|
+ const fridgeOptions = tool.dictList('REFRIGERATORSMODEL') // 冰箱型号
|
|
|
+ const monitorTargetOptions = ref([]) // 监测对象
|
|
|
+ const memListOptions = ref([]) // 监测设备
|
|
|
+ const currentMonitorDevice = ref({}) //当前的监测设备
|
|
|
|
|
|
const sensorRouteMax = ref(1) //传感器最大值默认1
|
|
|
|
|
|
// 默认要校验的
|
|
|
const formRules = {
|
|
|
- name: [required('请输入区域名称')],
|
|
|
- monitorTargetId: [required('请选择监控对象')],
|
|
|
+ name: [required('请输入点位名称')],
|
|
|
+ monitorTargetId: [required('请选择监测对象')],
|
|
|
monitorDeviceId: [required('请选择监测设备')],
|
|
|
sensorType: [required('请选择传感器类型')],
|
|
|
sensorRoute: [required('请输入传感器路数')],
|
|
@@ -279,53 +320,68 @@
|
|
|
}
|
|
|
|
|
|
// 打开抽屉
|
|
|
- const onOpen = (record) => {
|
|
|
- setupListData()
|
|
|
+ const onOpen = (type, record) => {
|
|
|
+ setupListData(type, record)
|
|
|
+ memListData()
|
|
|
visible.value = true
|
|
|
- if (record) {
|
|
|
- formData.value = Object.assign({}, record)
|
|
|
+ if (!record) {
|
|
|
+ formData.value = ref({ alarmUsers: [], time: [] })
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 报警接收人回显
|
|
|
- if (formData.value.alarmUsers && formData.value.alarmUsers.length > 0) {
|
|
|
- formData.value.alarmUsers = formData.value.alarmUsers.map((item) => item.openId)
|
|
|
- }
|
|
|
+ // 选中的点位标签
|
|
|
+ const pointNameChange = (val) => {
|
|
|
+ pointName.value = val
|
|
|
+ formData.value.name = currentMonitorObj.value.name + '-' + pointName.value
|
|
|
+ }
|
|
|
|
|
|
- sensorType.value = formData.value.sensorType
|
|
|
+ // 选中的冰箱标签
|
|
|
+ const fridgeNameChange = (val) => {
|
|
|
+ const data = fridgeRanges.value[val]
|
|
|
|
|
|
- memListData(sensorType.value)
|
|
|
- } else {
|
|
|
- formData.value = { alarmUsers: [] }
|
|
|
- memListData()
|
|
|
+ formData.value = {
|
|
|
+ ...formData.value,
|
|
|
+
|
|
|
+ temperatureUp: data.up, //温度上限
|
|
|
+ temperatureDown: data.down //温度下限
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 获取监控对象 以及获取报警接收人的数据
|
|
|
- const setupListData = () => {
|
|
|
- setupApi.setupList({ isAll: false }).then((res) => {
|
|
|
- monitorTargetOptions.value = (res || []).map((item) => {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- value: item['id'],
|
|
|
- label: item['name']
|
|
|
+ // 获取监测对象
|
|
|
+ const setupListData = (type, record) => {
|
|
|
+ setupApi
|
|
|
+ .setupList({ isAll: false })
|
|
|
+ .then((res) => {
|
|
|
+ monitorTargetOptions.value = res || []
|
|
|
+ currentMonitorObj.value = monitorTargetOptions.value.find((item) => item.id === record.monitorTargetId) //当前的监测对象
|
|
|
+ alarmUsersOptions.value = currentMonitorObj.value.alarmUsers || [] //报警接收人
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ formData.value = Object.assign({}, record)
|
|
|
+
|
|
|
+ if (type == 'add') {
|
|
|
+ formData.value.name = currentMonitorObj.value.name + '-' + pointName.value
|
|
|
+ } else {
|
|
|
+ formData.value.time = [
|
|
|
+ formData.value.ignoreStartTime ? formData.value.ignoreStartTime : null,
|
|
|
+ formData.value.ignoreEndTime ? formData.value.ignoreEndTime : null
|
|
|
+ ]
|
|
|
+
|
|
|
+ if (formData.value.alarmUsers && formData.value.alarmUsers.length > 0) {
|
|
|
+ formData.value.alarmUsers = formData.value.alarmUsers.map((item) => item.openId)
|
|
|
+ }
|
|
|
+ memListData(formData.value.sensorType)
|
|
|
}
|
|
|
})
|
|
|
- const list = monitorTargetOptions.value.find((item) => item.value === formData.value.monitorTargetId)
|
|
|
-
|
|
|
- if (!formData.value.id) {
|
|
|
- formData.value.name = list.label
|
|
|
- }
|
|
|
- formData.value._name = list.label
|
|
|
- alarmUsersOptions.value = list.alarmUsers || []
|
|
|
- })
|
|
|
}
|
|
|
|
|
|
// 名称输入
|
|
|
const nameInput = (e) => {
|
|
|
const val = e.target.value
|
|
|
- if (!val.startsWith(formData.value._name)) {
|
|
|
+ if (!val.startsWith(formData.value.name)) {
|
|
|
formData.value.name = formData.value._name
|
|
|
message.warning({
|
|
|
- content: '名称必须以监控对象名称:' + formData.value._name + ' 开头',
|
|
|
+ content: '名称必须以 "监测对象名称" + ' + pointName.value + ' 开头',
|
|
|
key: 'name'
|
|
|
})
|
|
|
} else {
|
|
@@ -333,39 +389,28 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const sensorType = ref() //选中的传感器类型
|
|
|
- // 监测设备通过传感器类型来获取, sensorType可为空
|
|
|
- const memListData = (value) => {
|
|
|
- memApi.memList({ isAll: false, sensorType: value }).then((res) => {
|
|
|
- memListOptions.value = (res || []).map((item) => {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- value: item['id'],
|
|
|
- label: item['deviceName'],
|
|
|
- modelName: item['modelName'],
|
|
|
- deviceCode: item['deviceCode'],
|
|
|
- sensorCount: item['sensorCount']
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
// 选中传感器类型
|
|
|
const sensorTypeChange = (value) => {
|
|
|
if (value) {
|
|
|
- formData.value.monitorDeviceId = null
|
|
|
- formData.value.sensorRoute = null
|
|
|
- sensorRouteMax.value = 1
|
|
|
- sensorType.value = value
|
|
|
memListData(value)
|
|
|
+ monitorDeviceIdChange()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 监测设备通过传感器类型来获取, sensorType可为空
|
|
|
+ const memListData = (value) => {
|
|
|
+ memApi.memList({ isAll: false, sensorType: value }).then((res) => {
|
|
|
+ memListOptions.value = res || []
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
// 选中监测设备
|
|
|
const monitorDeviceIdChange = (value) => {
|
|
|
+ fridgeName.value = null
|
|
|
if (value) {
|
|
|
askRegionByDeviceIdData(value)
|
|
|
- const data = memListOptions.value.find((item) => item.value === value)
|
|
|
+ const data = memListOptions.value.find((item) => item.id === value)
|
|
|
+ currentMonitorDevice.value = data //选中的监测设备
|
|
|
formData.value = {
|
|
|
...formData.value,
|
|
|
sensorCode: data.deviceCode, //传感器编号
|
|
@@ -378,23 +423,51 @@
|
|
|
co2Up: data.co2Up, //CO2上限
|
|
|
co2Down: data.co2Down //CO2下限
|
|
|
}
|
|
|
- sensorRouteMax.value = data.sensorCount //传感器路数的最大值
|
|
|
-
|
|
|
- temperatureMax.value = {
|
|
|
- upMax: data.temperatureUp,
|
|
|
- downMax: data.temperatureDown
|
|
|
- }
|
|
|
|
|
|
- humidityMax.value = {
|
|
|
- upMax: data.humidityUp,
|
|
|
- downMax: data.humidityDown
|
|
|
+ sensorRouteMax.value = data.sensorCount //传感器路数的最大值
|
|
|
+ isFridgeDisabled()
|
|
|
+ } else {
|
|
|
+ // 清理掉监测设备的一些信息
|
|
|
+ currentMonitorDevice.value = {}
|
|
|
+ sensorRouteMax.value = 1
|
|
|
+ formData.value = {
|
|
|
+ ...formData.value,
|
|
|
+ monitorDeviceId: null, //监测设备
|
|
|
+ sensorRoute: null, //传感器路数
|
|
|
+ sensorCode: null, //传感器编号
|
|
|
+ modelName: null, //监测设备型号
|
|
|
+ deviceCode: null, //冷链编号
|
|
|
+ temperatureUp: null, //温度上限
|
|
|
+ temperatureDown: null, //温度下限
|
|
|
+ humidityUp: null, //湿度上限
|
|
|
+ humidityDown: null, //湿度下限
|
|
|
+ co2Up: null, //CO2上限
|
|
|
+ co2Down: null //CO2下限
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- co2Max.value = {
|
|
|
- upMax: data.co2Up,
|
|
|
- downMax: data.co2Down
|
|
|
+ const fridgeName = ref() //选择的冰箱型号
|
|
|
+ const fridgeRanges = ref({
|
|
|
+ '-80': { up: -70, down: -80 },
|
|
|
+ '-40': { up: -30, down: -40 },
|
|
|
+ 4: { up: 14, down: 4 },
|
|
|
+ '-196': { up: -186, down: -196 }
|
|
|
+ })
|
|
|
+ const filteredFridges = ref([])
|
|
|
+ // 判断 当前的监测设备 的温度范围是否在该冰箱的温度范围内
|
|
|
+ const isFridgeDisabled = () => {
|
|
|
+ console.log(currentMonitorDevice.value.temperatureUp, currentMonitorDevice.value.temperatureDown)
|
|
|
+ filteredFridges.value = fridgeOptions.map((fridge) => {
|
|
|
+ const { up, down } = fridgeRanges.value[fridge.value]
|
|
|
+ const isDisabled =
|
|
|
+ up < currentMonitorDevice.value.temperatureDown || down > currentMonitorDevice.value.temperatureUp
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...fridge,
|
|
|
+ disabled: isDisabled
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const useSensorRoute = ref([]) //已使用的传感器路数
|
|
@@ -420,8 +493,11 @@
|
|
|
.then(() => {
|
|
|
const parameter = {
|
|
|
...formData.value,
|
|
|
- alarmUsers: alarmUsersOptions.value.filter((user) => formData.value.alarmUsers.includes(user.openId))
|
|
|
+ alarmUsers: alarmUsersOptions.value.filter((user) => formData.value.alarmUsers.includes(user.openId)),
|
|
|
+ ignoreStartTime: formData.value.time && formData.value.time.length ? formData.value.time[0] : null,
|
|
|
+ ignoreEndTime: formData.value.time && formData.value.time.length ? formData.value.time[1] : null
|
|
|
}
|
|
|
+ delete parameter.time
|
|
|
locationApi.submitForm(parameter, formData.value.id).then(() => {
|
|
|
onClose()
|
|
|
emit('successful')
|
|
@@ -435,6 +511,9 @@
|
|
|
// 关闭抽屉
|
|
|
const onClose = () => {
|
|
|
memListOptions.value = []
|
|
|
+ currentMonitorObj.value = {}
|
|
|
+ pointName.value = '上层'
|
|
|
+ fridgeName.value = null
|
|
|
|
|
|
formRef.value.resetFields()
|
|
|
visible.value = false
|
|
@@ -447,6 +526,17 @@
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
+ .dict {
|
|
|
+ width: 100%;
|
|
|
+ padding: 0 10px 0px 45px;
|
|
|
+ :deep(.ant-radio-button-wrapper) {
|
|
|
+ margin: 5px 5px 10px 0px;
|
|
|
+ }
|
|
|
+ :deep(.ant-radio-button-wrapper-checked) {
|
|
|
+ color: #2b61ff;
|
|
|
+ background-color: #e6f3ff;
|
|
|
+ }
|
|
|
+ }
|
|
|
:deep(.ant-form-item) {
|
|
|
width: 100%;
|
|
|
margin-bottom: 10px;
|