소스 검색

监测点配置 新增样式重新调整

like 6 달 전
부모
커밋
d6fb286410

+ 193 - 103
snowy-admin-web/src/views/biz/monitor/point/form.vue

@@ -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;

+ 2 - 2
snowy-admin-web/src/views/biz/monitor/point/index.vue

@@ -43,7 +43,7 @@
 				<!-- 其他操作区域 -->
 				<div class="table-head-btn">
 					<div class="btn-left">
-						<a-button type="primary" @click="formRef.onOpen({ monitorTargetId: queryId })">
+						<a-button type="primary" @click="formRef.onOpen('add', { monitorTargetId: queryId })">
 							<template #icon><plus-outlined /></template>新增
 						</a-button>
 					</div>
@@ -56,7 +56,7 @@
 					{{ $TOOL.dictTypeData('SENSORTYPE', record.sensorType) }}
 				</template>
 				<template v-if="column.dataIndex === 'action'">
-					<a-button type="link" size="small" @click="formRef.onOpen(record)">编辑</a-button>
+					<a-button type="link" size="small" @click="formRef.onOpen('edit', record)">编辑</a-button>
 					<a-popconfirm title="确定要删除吗?" @confirm="deleteData(record)">
 						<a-button type="link" danger size="small">删除</a-button>
 					</a-popconfirm>

+ 0 - 434
snowy-admin-web/src/views/motoring/location/form.vue

@@ -1,434 +0,0 @@
-<template>
-	<xn-form-container
-		:title="formData.id ? '编辑点位' : '新增点位'"
-		:width="'800px'"
-		:visible="visible"
-		:destroy-on-close="true"
-		@close="onClose"
-	>
-		<a-form
-			ref="formRef"
-			:model="formData"
-			:rules="formRules"
-			layout="inline"
-			:label-col="{ style: { width: '110px', justifyContent: 'end' } }"
-		>
-			<a-row :gutter="10">
-				<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-					<a-form-item label="监控对象" name="monitorTargetId">
-						<a-select
-							ref="select"
-							v-model:value="formData.monitorTargetId"
-							:options="monitorTargetOptions"
-							placeholder="请选择监控对象"
-							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 v-model:value="formData.name" placeholder="请输入点位名称" allow-clear />
-					</a-form-item>
-				</a-col>
-				<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-					<a-form-item label="传感器类型" name="sensorType">
-						<a-select
-							ref="select"
-							v-model:value="formData.sensorType"
-							:options="sensorOptions"
-							placeholder="请选择传感器类型"
-							@change="sensorTypeChange"
-						/>
-					</a-form-item>
-				</a-col>
-
-				<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-					<a-form-item label="监控设备" name="monitorDeviceId">
-						<a-select
-							ref="select"
-							v-model:value="formData.monitorDeviceId"
-							:options="memListOptions"
-							placeholder="请选择监控设备"
-							@change="monitorDeviceIdChange"
-						/>
-					</a-form-item>
-				</a-col>
-
-				<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" v-if="formData.monitorDeviceId">
-					<a-form-item label="传感器编号" name="sensorCode">
-						<a-input v-model:value="formData.sensorCode" disabled placeholder="请输入传感器编号" allow-clear />
-					</a-form-item>
-				</a-col>
-
-				<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" v-if="formData.monitorDeviceId">
-					<a-form-item label="传感器路数" name="sensorRoute">
-						<a-radio-group v-model:value="formData.sensorRoute">
-							<a-radio-button v-for="i in sensorRouteMax" :key="i" :value="i" :disabled="isRouteDisabled(i)">
-								{{ i }}路
-							</a-radio-button>
-						</a-radio-group>
-					</a-form-item>
-				</a-col>
-
-				<!-- 报警接收人 -->
-				<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-form-item>
-				</a-col>
-
-				<div
-					class="form_item"
-					v-if="formData.sensorType == 'W' || formData.sensorType == 'WS' || formData.sensorType == 'WSC'"
-				>
-					<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-						<a-form-item label="温度上限" name="temperatureUp">
-							<a-input-number
-								id="inputNumber"
-								v-model:value="formData.temperatureUp"
-								placeholder="请输入温度上限"
-								allow-clear
-								:min="temperatureMax.downMax"
-								:max="temperatureMax.upMax"
-								style="width: 100%"
-								:disabled="temperatureMax.upMax == null || temperatureMax.upMax == undefined"
-							/>
-						</a-form-item>
-					</a-col>
-					<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-						<a-form-item label="温度下限" name="temperatureDown">
-							<a-input-number
-								id="inputNumber"
-								v-model:value="formData.temperatureDown"
-								placeholder="请输入温度下限"
-								allow-clear
-								:min="temperatureMax.downMax"
-								:max="temperatureMax.upMax"
-								style="width: 100%"
-								:disabled="!temperatureMax.downMax == null || temperatureMax.downMax == undefined"
-							/>
-						</a-form-item>
-					</a-col>
-				</div>
-
-				<div class="form_item" v-if="formData.sensorType == 'WS' || formData.sensorType == 'WSC'">
-					<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-						<a-form-item label="湿度上限" name="humidityUp">
-							<a-input-number
-								id="inputNumber"
-								v-model:value="formData.humidityUp"
-								placeholder="请输入湿度上限"
-								allow-clear
-								:min="humidityMax.downMax"
-								:max="humidityMax.upMax"
-								style="width: 100%"
-								:disabled="!humidityMax.upMax"
-							/>
-						</a-form-item>
-					</a-col>
-					<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-						<a-form-item label="湿度下限" name="humidityDown">
-							<a-input-number
-								id="inputNumber"
-								v-model:value="formData.humidityDown"
-								placeholder="请输入湿度下限"
-								allow-clear
-								:min="humidityMax.downMax"
-								:max="humidityMax.upMax"
-								style="width: 100%"
-								:disabled="!humidityMax.downMax"
-							/>
-						</a-form-item>
-					</a-col>
-				</div>
-
-				<div class="form_item" v-if="formData.sensorType == 'WSC'">
-					<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-						<a-form-item label="CO2上限" name="co2Up">
-							<a-input-number
-								id="inputNumber"
-								v-model:value="formData.co2Up"
-								placeholder="请输入CO2上限"
-								allow-clear
-								:max="co2Max.upMax"
-								style="width: 100%"
-							/>
-						</a-form-item>
-					</a-col>
-					<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-						<a-form-item label="CO2下限" name="co2Down">
-							<a-input-number
-								id="inputNumber"
-								v-model:value="formData.co2Down"
-								placeholder="请输入CO2下限"
-								allow-clear
-								:max="co2Max.downMax"
-								style="width: 100%"
-							/>
-						</a-form-item>
-					</a-col>
-				</div>
-			</a-row>
-		</a-form>
-
-		<template #footer>
-			<a-button class="xn-mr8" @click="onClose">取消</a-button>
-			<a-button type="primary" @click="onSubmit">保存</a-button>
-		</template>
-	</xn-form-container>
-</template>
-
-<script setup>
-	import tool from '@/utils/tool'
-	import { required } from '@/utils/formRules'
-	import locationApi from '@/api/basicset/locationApi.js'
-	import setupApi from '@/api/basicset/setupApi'
-	import memApi from '@/api/basicset/memApi'
-	const emit = defineEmits({ successful: null })
-	const visible = ref(false) // 默认是关闭状态
-	const formRef = ref()
-	const formData = ref({ alarmUsers: [] }) // 表单数据
-	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 sensorRouteMax = ref(1) //传感器最大值默认1
-
-	// 默认要校验的
-	const formRules = {
-		name: [required('请输入区域名称')],
-		monitorTargetId: [required('请选择监控对象')],
-		monitorDeviceId: [required('请选择监控设备')],
-		sensorType: [required('请选择传感器类型')],
-		sensorRoute: [required('请输入传感器路数')],
-		alarmUsers: [required('请选择报警接收人')],
-		temperatureUp: [{ validator: validateTemperature, trigger: ['change', 'blur'] }],
-		temperatureDown: [{ validator: validateTemperature, trigger: ['change', 'blur'] }],
-		humidityUp: [{ validator: validateHumidity, trigger: ['change', 'blur'] }],
-		humidityDown: [{ validator: validateHumidity, trigger: ['change', 'blur'] }],
-		co2Up: [{ validator: validateCo2, trigger: ['change', 'blur'] }],
-		co2Down: [{ validator: validateCo2, trigger: ['change', 'blur'] }]
-	}
-
-	// 温度上下限校验
-	function validateTemperature(rule, value, callback) {
-		if (rule.field == 'temperatureDown') {
-			if (formData.value.temperatureUp !== null && value >= formData.value.temperatureUp) {
-				callback(new Error('温度下限不能大于或等于温度上限'))
-			} else {
-				callback()
-			}
-		} else if (rule.field == 'temperatureUp') {
-			if (formData.value.temperatureDown !== null && value <= formData.value.temperatureDown) {
-				callback(new Error('温度上限不能小于或等于温度下限'))
-			} else {
-				callback()
-			}
-		}
-	}
-
-	// 湿度上下限校验
-	function validateHumidity(rule, value, callback) {
-		if (rule.field == 'humidityDown') {
-			if (formData.value.humidityUp !== null && value >= formData.value.humidityUp) {
-				callback(new Error('湿度下限不能大于或等于湿度上限'))
-			} else {
-				callback()
-			}
-		} else if (rule.field == 'humidityUp') {
-			if (formData.value.humidityDown !== null && value <= formData.value.humidityDown) {
-				callback(new Error('湿度上限不能小于或等于湿度下限'))
-			} else {
-				callback()
-			}
-		}
-	}
-
-	// CO2上下限校验
-	function validateCo2(rule, value, callback) {
-		if (rule.field == 'co2Down') {
-			if (formData.value.co2Up !== null && value >= formData.value.co2Up) {
-				callback(new Error('CO2下限不能大于或等于CO2上限'))
-			} else {
-				callback()
-			}
-		} else if (rule.field == 'co2Up') {
-			if (formData.value.co2Down !== null && value <= formData.value.co2Down) {
-				callback(new Error('CO2上限不能小于或等于CO2下限'))
-			} else {
-				callback()
-			}
-		}
-	}
-
-	// 打开抽屉
-	const onOpen = (record) => {
-		setupListData()
-		visible.value = true
-		if (record) {
-			formData.value = Object.assign({}, record)
-
-			// 报警接收人回显
-			if (formData.value.alarmUsers && formData.value.alarmUsers.length > 0) {
-				formData.value.alarmUsers = formData.value.alarmUsers.map((item) => item.openId)
-			}
-			sensorType.value = formData.value.sensorType
-
-			memListData(sensorType.value)
-		} else {
-			formData.value = { alarmUsers: [] }
-			memListData()
-		}
-	}
-	// 获取监控对象 以及获取报警接收人的数据
-	const setupListData = () => {
-		setupApi.setupList({ isAll: false }).then((res) => {
-			monitorTargetOptions.value = (res || []).map((item) => {
-				return {
-					...item,
-					value: item['id'],
-					label: item['name']
-				}
-			})
-			const list = monitorTargetOptions.value.find((item) => item.value === formData.value.monitorTargetId)
-			alarmUsersOptions.value = list.alarmUsers || []
-		})
-	}
-
-	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)
-		}
-	}
-
-	// 选中监控设备
-	const monitorDeviceIdChange = (value) => {
-		if (value) {
-			askRegionByDeviceIdData(value)
-			const data = memListOptions.value.find((item) => item.value === value)
-			formData.value = {
-				...formData.value,
-				sensorCode: data.deviceCode, //传感器编号
-				modelName: data.modelName, //监控设备型号
-				deviceCode: data.deviceCode, //冷链编号
-				temperatureUp: data.temperatureUp, //温度上限
-				temperatureDown: data.temperatureDown, //温度下限
-				humidityUp: data.humidityUp, //湿度上限
-				humidityDown: data.humidityDown, //湿度下限
-				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
-			}
-			co2Max.value = {
-				upMax: data.co2Up,
-				downMax: data.co2Down
-			}
-		}
-	}
-
-	const useSensorRoute = ref([]) //已使用的传感器路数
-	// 根据检测设备id获取已使用的路数
-	const askRegionByDeviceIdData = (value) => {
-		if (value) {
-			memApi.getRegionByDeviceIdData({ deviceId: value }).then((res) => {
-				useSensorRoute.value = res
-			})
-		}
-	}
-
-	// 检查该路是否已被禁用
-	const isRouteDisabled = (route) => {
-		// 通过遍历useSensorRoute中的数据,判断该路是否已被占用
-		return useSensorRoute.value.some((item) => item.sensorRoute === route)
-	}
-
-	// 验证并提交数据
-	const onSubmit = () => {
-		formRef.value
-			.validate()
-			.then(() => {
-				const parameter = {
-					...formData.value,
-					alarmUsers: alarmUsersOptions.value.filter((user) => formData.value.alarmUsers.includes(user.openId))
-				}
-				locationApi.submitForm(parameter, formData.value.id).then(() => {
-					onClose()
-					emit('successful')
-				})
-			})
-			.catch((error) => {
-				console.log(error)
-			})
-	}
-
-	// 关闭抽屉
-	const onClose = () => {
-		memListOptions.value = []
-
-		formRef.value.resetFields()
-		visible.value = false
-	}
-
-	// 调用这个函数将子组件的一些数据和方法暴露出去
-	defineExpose({
-		onOpen
-	})
-</script>
-
-<style lang="less" scoped>
-	:deep(.ant-form-item) {
-		width: 100%;
-		margin-bottom: 10px;
-	}
-
-	.form_item {
-		width: 100%;
-		display: flex;
-		align-items: center;
-		justify-content: center;
-		flex-wrap: wrap;
-	}
-</style>

+ 0 - 184
snowy-admin-web/src/views/motoring/location/index.vue

@@ -1,184 +0,0 @@
-<template>
-	<div class="table_item">
-		<a-page-header title="返回" sub-title="监测点配置" @back="goBack" style="padding: 20px 0" />
-		<s-table
-			ref="tableRef"
-			:columns="columns"
-			:data="loadData"
-			:row-key="(record) => record.id"
-			bordered
-			@resizeColumn="handleResizeColumn"
-		>
-			<template #operator>
-				<!-- 搜索区域 -->
-				<div class="table-search">
-					<div class="table-search-form">
-						<a-row :gutter="10">
-							<a-form
-								ref="searchFormRef"
-								name="advanced_search"
-								layout="inline"
-								:label-col="{ style: { width: '70px', justifyContent: 'end' } }"
-								:model="searchFormState"
-								class="ant-advanced-search-form"
-							>
-								<a-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8"
-									><a-form-item label="点位名称" name="name">
-										<a-input v-model:value="searchFormState.name" placeholder="请输入点位名称" /> </a-form-item
-								></a-col>
-							</a-form>
-						</a-row>
-					</div>
-					<div class="table-search-buttons">
-						<a-button type="primary" @click="tableRef.refresh(true)">查询</a-button>
-						<a-button class="xn-mg08" @click="reset">重置</a-button>
-					</div>
-				</div>
-
-				<!-- 其他操作区域 -->
-				<div class="table-head-btn">
-					<div class="btn-left">
-						<a-button type="primary" @click="formRef.onOpen({ monitorTargetId: queryId })">
-							<template #icon><plus-outlined /></template>新增
-						</a-button>
-					</div>
-				</div>
-			</template>
-			<template #bodyCell="{ column, record, index }">
-				<!-- 序号 -->
-				<template v-if="column.dataIndex === 'index'">{{ index + 1 }} </template>
-				<template v-if="column.dataIndex === 'action'">
-					<a-button type="link" size="small" @click="formRef.onOpen(record)">编辑</a-button>
-					<a-popconfirm title="确定要删除吗?" @confirm="deleteData(record)">
-						<a-button type="link" danger size="small">删除</a-button>
-					</a-popconfirm>
-				</template>
-			</template>
-		</s-table>
-		<Form ref="formRef" @successful="tableRef.refresh(true)" />
-	</div>
-</template>
-
-<script setup>
-	import locationApi from '@/api/basicset/locationApi.js'
-	import { useRoute } from 'vue-router'
-	import router from '@/router'
-	import Form from './form.vue'
-	const formRef = ref()
-	const searchFormRef = ref()
-	const searchFormState = ref({})
-	const tableRef = ref()
-	const Route = useRoute()
-
-	const columns = [
-		{
-			title: '序号',
-			dataIndex: 'index',
-			align: 'center',
-			width: 50
-		},
-		{
-			title: '区域名称',
-			dataIndex: 'name',
-			align: 'center',
-			ellipsis: true,
-			resizable: true
-		},
-
-		{
-			title: '监控对象',
-			dataIndex: 'targetName',
-			align: 'center',
-			ellipsis: true,
-			resizable: true
-		},
-		{
-			title: '监控设备',
-			dataIndex: 'deviceName',
-			align: 'center',
-			ellipsis: true,
-			resizable: true
-		},
-		{
-			title: '传感器编号',
-			dataIndex: 'sensorCode',
-			align: 'center',
-			ellipsis: true,
-			resizable: true
-		},
-		{
-			title: '传感器类型',
-			dataIndex: 'sensorType',
-			align: 'center',
-			ellipsis: true,
-			resizable: true
-		},
-		{
-			title: '传感器路数',
-			dataIndex: 'sensorRoute',
-			align: 'center',
-			ellipsis: true,
-			resizable: true
-		},
-
-		{
-			title: '操作',
-			dataIndex: 'action',
-			align: 'center',
-			width: 150
-		}
-	]
-	// 可伸缩列
-	const handleResizeColumn = (w, col) => {
-		col.width = w
-	}
-
-	const queryId = ref() //监控对象的id
-	onBeforeMount(() => {
-		if (Route.query.id) {
-			queryId.value = Route.query.id
-		}
-	})
-
-	// 返回上一页
-	const goBack = () => {
-		router.go(-1)
-	}
-
-	const loadData = (parameter) => {
-		if (queryId.value) {
-			parameter.monitorTargetId = queryId.value
-			return locationApi.locationPage(Object.assign(parameter, searchFormState.value)).then((res) => {
-				return res
-			})
-		}
-	}
-	// 重置
-	const reset = () => {
-		searchFormRef.value.resetFields()
-		tableRef.value.refresh(true)
-	}
-	// 删除
-	const deleteData = (record) => {
-		let params = [
-			{
-				id: record.id
-			}
-		]
-		locationApi.locationDelete(params).then(() => {
-			tableRef.value.refresh(true)
-			reset()
-		})
-	}
-</script>
-
-<style lang="less" scoped>
-	.table_item {
-		padding: 15px 20px;
-		background-color: #ffffff;
-
-		:deep(.ant-table-pagination-right) {
-			justify-content: center !important;
-		}
-	}
-</style>