Sfoglia il codice sorgente

物模型中,,功能,事件中涉及到的参数管理 新增编辑

yukai 2 anni fa
parent
commit
1b0b77f32d

+ 14 - 5
src/views/iot/device/product/component/editAttr.vue

@@ -67,10 +67,11 @@
 				<el-form-item label="JSON对象" prop="maxLength" v-if="type == 'object'">
 					<div v-for="(item, index) in jsondata" :key="index" class="jslist">
 						<div class="jsonlist">
-							<div>参数名称:</div>
-							<div style="width: 60%">{{ item.name }}</div>
+							<div>参数标识:{{ item.key }}</div>
+							<div>参数名称:{{ item.name }}</div>
+							<div>数据类型:{{ item.valueType.type }}</div>
 							<div class="jsonoption">
-								<!-- <el-link type="primary">编辑</el-link> -->
+								<el-link type="primary"  @click="editjson(index)">编辑</el-link>
 								<el-link type="primary" @click="deljson(index)">删除</el-link>
 							</div>
 						</div>
@@ -145,9 +146,11 @@
 				<el-form-item label="JSON对象" prop="maxLength" v-if="types == 'object'">
 					<div v-for="(item, index) in jsondata" :key="index" class="jslist">
 						<div class="jsonlist">
-							<div>参数名称:</div>
-							<div style="width: 60%">{{ item.name }}</div>
+							<div>参数标识:{{ item.key }}</div>
+							<div>参数名称:{{ item.name }}</div>
+							<div>数据类型:{{ item.valueType.type }}</div>
 							<div class="jsonoption">
+								<el-link type="primary"  @click="editjson(index)">编辑</el-link>
 								<el-link type="primary" @click="deljson(index)">删除</el-link>
 							</div>
 						</div>
@@ -360,6 +363,11 @@ export default defineComponent({
 			state.enumdata.splice(index, 1);
 		};
 
+		const editjson=(index)=>{
+
+			editOptionRef.value.openDialog(state.jsondata[index]);
+			
+		}
 		const deljson = (index) => {
 			state.jsondata.splice(index, 1);
 		}
@@ -463,6 +471,7 @@ export default defineComponent({
 			getOptionData,
 			openDialog,
 			deljson,
+			editjson,
 			addEnum,
 			delEnum,
 			addJson,

+ 10 - 0
src/views/iot/device/product/component/editEvent.vue

@@ -24,6 +24,7 @@
 							<div>参数名称:{{ item.name }}</div>
 							<div>数据类型:{{ item.valueType.type }}</div>
 							<div class="jsonoption">
+								<el-link type="primary"  @click="editjson(index, 'fun')">编辑</el-link>
 								<el-link type="primary" @click="deljson(index, 'fun')">删除</el-link>
 							</div>
 						</div>
@@ -183,6 +184,14 @@ export default defineComponent({
 				state.jsondata.splice(index, 1);
 			}
 		};
+		const editjson=(index,type)=>{
+			if (type == 'fun') {
+				editOptionRef.value.openDialog(state.outputsdata[index]);
+			} else {
+				editOptionRef.value.openDialog(state.jsondata[index]);
+
+			}
+		}
 
 		const addJson = (type) => {
 			editOptionRef.value.openDialog({ product_id: 0, id: 0, type_data: type });
@@ -230,6 +239,7 @@ export default defineComponent({
 			getOptionData,
 			openDialog,
 			deljson,
+			editjson,
 			addEnum,
 			delEnum,
 			addJson,

+ 17 - 2
src/views/iot/device/product/component/editFun.vue

@@ -16,7 +16,7 @@
 							<div>参数名称:{{ item.name }}</div>
 							<div>数据类型:{{ item.valueType.type }}</div>
 							<div class="jsonoption">
-								<!-- <el-link type="primary">编辑</el-link> -->
+								<el-link type="primary"  @click="editjson(index, 'fun')">编辑</el-link>
 								<el-link type="primary" @click="deljson(index, 'fun')">删除</el-link>
 							</div>
 						</div>
@@ -39,7 +39,7 @@
 							<div>参数名称:{{ item.name }}</div>
 							<div>数据类型:{{ item.valueType.type }}</div>
 							<div class="jsonoption">
-								<!-- <el-link type="primary">编辑</el-link> -->
+								<el-link type="primary" @click="editjsonOut(index, 'fun')">编辑</el-link>
 								<el-link type="primary" @click="deljsonOut(index, 'fun')">删除</el-link>
 							</div>
 						</div>
@@ -203,6 +203,15 @@ export default defineComponent({
 			state.enumdata.splice(index, 1);
 		};
 
+		const editjson=(index,type)=>{
+			if (type == 'fun') {
+				editOptionRef.value.openDialog(state.inputsdata[index]);
+			} else {
+				editOptionRef.value.openDialog(state.jsondata[index]);
+
+			}
+		}
+
 		const deljson = (index, type) => {
 			if (type == 'fun') {
 				state.inputsdata.splice(index, 1);
@@ -219,6 +228,10 @@ export default defineComponent({
 			}
 		};
 
+		const editjsonOut=(index,type)=>{
+			editOptionOutRef.value.openDialog(state.outputsdata[index]);
+		}
+
 		const addJson = (type) => {
 			editOptionRef.value.openDialog({ product_id: 0, id: 0, type_data: type });
 		};
@@ -282,6 +295,8 @@ export default defineComponent({
 			getOptionData,
 			getOptionDataOut,
 			openDialog,
+			editjson,
+			editjsonOut,
 			deljson,
 			deljsonOut,
 			addEnum,

+ 11 - 2
src/views/iot/device/product/component/editOption.vue

@@ -131,7 +131,7 @@ export default defineComponent({
 		});
 
 		// 打开弹窗
-		const openDialog = (row: RuleFormState | null) => {
+		const openDialog = (row: RuleFormState | null,type='add') => {
 			resetForm();
 
 			api.product.getDataType({ status: -1 }).then((res: any) => {
@@ -152,6 +152,16 @@ export default defineComponent({
 				// api.dict.getType(row.dictId).then((res:any)=>{
 				//   state.ruleForm = res.data.dictType
 				// }
+
+				if (typeof row.valueType !== 'undefined') {
+					state.type=row.valueType.type;
+					state.elementType=row.valueType.elementType;
+					state.enumdata=row.valueType.elements;
+					state.properties=row.valueType.properties;
+					state.valueType=row.valueType;
+				}
+
+
 				state.ruleForm = row;
 			}
 			state.isShowDialog = true;
@@ -216,7 +226,6 @@ export default defineComponent({
 							state.valueType.elementType = state.elementType;
 						}
 
-						console.log(state)
 						state.ruleForm.valueType = state.valueType;
 						ElMessage.success('参数类型添加成功');
 						closeDialog(); // 关闭弹窗