Browse Source

检测器管理新增/编辑时,设备型号放到设备名称前,并且设备型号输入框的值带入到设备名称中

like 6 months ago
parent
commit
883dafcc61
1 changed files with 20 additions and 5 deletions
  1. 20 5
      snowy-admin-web/src/views/biz/monitor/mem/form.vue

+ 20 - 5
snowy-admin-web/src/views/biz/monitor/mem/form.vue

@@ -1,6 +1,6 @@
 <template>
 	<xn-form-container
-		:title="formData.id ? '编辑采集器' : '新增采集器'"
+		:title="formData.id ? '编辑监测器' : '新增监测器'"
 		:width="'800px'"
 		:visible="visible"
 		:destroy-on-close="true"
@@ -26,15 +26,22 @@
 					</a-form-item>
 				</a-col>
 				<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-					<a-form-item label="设备名称" name="deviceName">
-						<a-input v-model:value="formData.deviceName" placeholder="请输入设备名称" allow-clear />
+					<a-form-item label="设备编号" name="deviceCode">
+						<a-input
+							v-model:value="formData.deviceCode"
+							placeholder="请输入设备编号"
+							allow-clear
+							:maxlength="10"
+							@change="deviceCodeChange(formData.deviceCode)"
+						/>
 					</a-form-item>
 				</a-col>
 				<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-					<a-form-item label="设备编号" name="deviceCode">
-						<a-input v-model:value="formData.deviceCode" placeholder="请输入设备编号" allow-clear :maxlength="10" />
+					<a-form-item label="设备名称" name="deviceName">
+						<a-input v-model:value="formData.deviceName" 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="sensorCount">
 						<a-input-number
@@ -220,6 +227,14 @@
 			formData.value = { sortCode: 99 }
 		}
 	}
+
+	// 设备名称同步设备编号
+	const deviceCodeChange = (e) => {
+		if (!formData.value.id) {
+			formData.value.deviceName = e
+		}
+	}
+
 	// 关闭抽屉
 	const onClose = () => {
 		formRef.value.resetFields()