소스 검색

fix: 新增属性定义接口参数bug处理

vera_min 1 개월 전
부모
커밋
0652c9d3dd
1개의 변경된 파일8개의 추가작업 그리고 7개의 파일을 삭제
  1. 8 7
      src/views/iot/device/product/component/editAttr.vue

+ 8 - 7
src/views/iot/device/product/component/editAttr.vue

@@ -45,7 +45,7 @@
 				<!-- 精度 -->
 				<el-form-item :label="$t('message.device.formI18nLabel.precision')" prop="decimals" v-if="type == 'float' || type == 'double'">
 					<!-- 请输入精度 -->
-					<el-input v-model="valueType.decimals" :placeholder="$t('message.device.formI18nPlaceholder.precision')" />
+					<el-input v-model="valueType.decimals" :placeholder="$t('message.device.formI18nPlaceholder.inputPrecision')" />
 				</el-form-item>
 
 				<!-- 单位 -->
@@ -410,13 +410,13 @@ const resetForm = () => {
 		transportProtocol: '',
 		accessMode: 1,
 		status: 1,
-		valueType: JSON.parse(JSON.stringify(valueType)),
+		valueType: JSON.parse(JSON.stringify(valueType.value)),
 		desc: '',
 	}
 	type.value = ''
 	types.value = ''
-	valueType.value = JSON.parse(JSON.stringify(valueType))
-	elementType.value = JSON.parse(JSON.stringify(valueType))
+	valueType.value = JSON.parse(JSON.stringify(valueType.value))
+	elementType.value = JSON.parse(JSON.stringify(valueType.value))
 	jsondata.value = []
 	enumdata.value = [
 		{
@@ -533,9 +533,10 @@ const onSubmit = () => {
 						}
 					}
 				}
-
-				ruleForm.value.valueType = valueType.value
-				api.model.propertyadd(ruleForm.value).then(() => {
+				Object.assign(ruleForm.value.valueType, valueType.value)
+				// 深拷贝确保响应式对象正确序列化
+				const submitData = JSON.parse(JSON.stringify(ruleForm.value))
+				api.model.propertyadd(submitData).then(() => {
 					ElMessage.success(t('message.tableI18nConfirm.addSuccess'))
 					closeDialog() // 关闭弹窗
 					emit('typeList')