Explorar o código

设备功能第一参数回显key值,功能执行页面增加枚举输入类型的下拉选,修复文字错误

yanglzh %!s(int64=2) %!d(string=hai) anos
pai
achega
0fc039e637

+ 11 - 1
src/views/iot/device/instance/component/function.vue

@@ -8,7 +8,10 @@
 						<el-table-column prop="valueType.type" label="输入类型" />
 						<el-table-column prop="name" label="值" min-width="200">
 							<template #default="{ row }">
-								<el-input v-model="row.value" clearable>
+								<el-select v-model="row.value" clearable v-if="row.valueType.type === 'enum'" style="wdith: 100% !important;">
+									<el-option v-for="item in row.valueType.elements" :key="item.value" :value="item.value" :label="item.text"></el-option>
+								</el-select>
+								<el-input v-model="row.value" clearable v-else>
 									<template v-if="row.valueType.unit" #append>{{ row.valueType.unit }}</template>
 								</el-input>
 							</template>
@@ -85,14 +88,21 @@ function clear(row: IListItem) {
 	align-items: stretch;
 	justify-content: space-between;
 	gap: 20px;
+
 	.el-table {
 		flex: 3;
 	}
+
 	.result {
 		flex: 2;
 	}
+
 	::v-deep(.el-textarea__inner) {
 		height: 100%;
 	}
+
+	::v-deep(.el-select) {
+		width: 100%;
+	}
 }
 </style>

+ 64 - 46
src/views/iot/device/product/component/editAttr.vue

@@ -3,14 +3,14 @@
 		<el-dialog :title="(ruleForm.id !== 0 ? '修改' : '添加') + '属性定义'" v-model="isShowDialog" width="769px">
 			<el-form :model="ruleForm" ref="formRef" :rules="rules" size="default" label-width="120px">
 				<el-form-item label="属性定义标识" prop="key">
-					<el-input v-model="ruleForm.key" placeholder="请输入属性定义标识" :disabled="ruleForm.id!== 0 ?true : false" />
+					<el-input v-model="ruleForm.key" placeholder="请输入属性定义标识" :disabled="ruleForm.id !== 0 ? true : false" />
 				</el-form-item>
 				<el-form-item label="属性定义名称" prop="name">
 					<el-input v-model="ruleForm.name" placeholder="请输入属性定义名称" />
 				</el-form-item>
 
-				<el-form-item label="数据类型" prop="type" >
-					<el-select v-model="valueType.type" placeholder="请选择数据类型" @change="seletChange" :disabled="ruleForm.id!== 0 ?true : false">
+				<el-form-item label="数据类型" prop="type">
+					<el-select v-model="valueType.type" placeholder="请选择数据类型" @change="seletChange" :disabled="ruleForm.id !== 0 ? true : false">
 						<el-option-group v-for="group in typeData" :key="group.label" :label="group.label">
 							<el-option v-for="item in group.options" :key="item.type" :label="item.title" :value="item.type" />
 						</el-option-group>
@@ -49,13 +49,17 @@
 
 				<el-form-item label="枚举项" prop="maxLength" v-if="type == 'enum'">
 					<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-						<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"
-							><el-icon><Right /></el-icon
-						></span>
+						<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"><el-icon>
+								<Right />
+							</el-icon></span>
 						<el-input v-model="item.value" placeholder="请输入枚举文本" />
 						<div class="input-option">
-							<el-icon @click="addEnum" v-if="index == 0"><Plus /></el-icon>
-							<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+							<el-icon @click="addEnum" v-if="index == 0">
+								<Plus />
+							</el-icon>
+							<el-icon @click="delEnum(index)" v-if="index != 0">
+								<Minus />
+							</el-icon>
 						</div>
 					</div>
 				</el-form-item>
@@ -74,7 +78,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -119,19 +125,23 @@
 
 					<el-form-item label="枚举项" prop="maxLength" v-if="types == 'enum'">
 						<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-							<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"
-								><el-icon><Right /></el-icon
-							></span>
+							<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"><el-icon>
+									<Right />
+								</el-icon></span>
 							<el-input v-model="item.value" placeholder="请输入枚举文本" />
 							<div class="input-option">
-								<el-icon @click="addEnum" v-if="index == 0"><Plus /></el-icon>
-								<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+								<el-icon @click="addEnum" v-if="index == 0">
+									<Plus />
+								</el-icon>
+								<el-icon @click="delEnum(index)" v-if="index != 0">
+									<Minus />
+								</el-icon>
 							</div>
 						</div>
 					</el-form-item>
 				</div>
 
-				
+
 				<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">
@@ -146,7 +156,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -155,7 +167,7 @@
 				<!--根据数据类型输出不同表单-->
 
 				<el-form-item label="是否只读" prop="accessMode">
-					<el-radio-group v-model="ruleForm.accessMode" >
+					<el-radio-group v-model="ruleForm.accessMode">
 						<el-radio :label="0">读写</el-radio>
 						<el-radio :label="1">只读</el-radio>
 					</el-radio-group>
@@ -211,14 +223,14 @@ export default defineComponent({
 			typeData: [], //
 			type: '',
 			types: '',
-			productId:0,
+			productId: 0,
 			valueType: {
 				type: '',
 				maxLength: '',
-				trueText:'是',
-				trueValue:'true',
-				falseText:'否',
-				falseValue:'false',
+				trueText: '是',
+				trueValue: 'true',
+				falseText: '否',
+				falseValue: 'false',
 			},
 			elementType: {
 				type: '',
@@ -234,8 +246,8 @@ export default defineComponent({
 			jsondata: [],
 
 			ruleForm: {
-				id:0,
-				productId:0,
+				id: 0,
+				productId: 0,
 				name: '',
 				key: '',
 				transportProtocol: '',
@@ -253,12 +265,12 @@ export default defineComponent({
 				key: [{ required: true, message: '属性定义标识不能为空', trigger: 'blur' }],
 				accessMode: [{ required: true, message: '请选择是否只读', trigger: 'blur' }],
 				type: [{ required: true, message: '请选择数据类型', trigger: 'blur' }],
-				
+
 			},
 		});
 
 		// 打开弹窗
-		const openDialog = (row: RuleFormState | null,productId:number | null) => {
+		const openDialog = (row: RuleFormState | null, productId: number | null) => {
 			resetForm();
 
 			api.product.getDataType({ status: -1 }).then((res: any) => {
@@ -277,14 +289,14 @@ export default defineComponent({
 				state.typeData = datat || [];
 			});
 			state.ruleForm = row;
-			if (row.valueType) {	
+			if (row.valueType) {
 				state.ruleForm = row;
 
-				state.productId=productId;
+				state.productId = productId;
 				state.valueType = row.valueType;
 				state.ruleForm.valueType.type = row.valueType.type;
 				state.ruleForm.type = row.valueType.type;
-				state.type = row.valueType.type ;
+				state.type = row.valueType.type;
 				state.ruleForm.accessMode = row.accessMode;
 				if (row.valueType.elementType) {
 					state.elementType = row.valueType.elementType;
@@ -299,15 +311,15 @@ export default defineComponent({
 					state.jsondata = row.valueType.properties;
 				}
 
-				if(row.type == 'array' && state.types=='enum'){
-					state.enumdata=row.valueType.elementType.elements
+				if (row.type == 'array' && state.types == 'enum') {
+					state.enumdata = row.valueType.elementType.elements
 				}
-				if(row.type == 'array' && state.types=='object'){
-					state.jsondata=row.valueType.elementType.properties
+				if (row.type == 'array' && state.types == 'object') {
+					state.jsondata = row.valueType.elementType.properties
 				}
 			}
 
-			
+
 			state.isShowDialog = true;
 		};
 		const resetForm = () => {
@@ -323,7 +335,7 @@ export default defineComponent({
 				},
 
 				desc: '',
-				
+
 			};
 			state.type = '';
 			state.types = '';
@@ -331,16 +343,16 @@ export default defineComponent({
 			state.elementType = {};
 			state.jsondata = [];
 			state.enumdata = [{
-					text: '',
-					value: '',
-				},];
+				text: '',
+				value: '',
+			},];
 		};
 
 		const seletChange = (val) => {
 			state.type = val;
 			state.ruleForm.type = val;
-		
-			
+
+
 			console.log(val);
 		};
 		const seletChanges = (val) => {
@@ -398,14 +410,14 @@ export default defineComponent({
 						if (state.type == 'array') {
 							state.valueType.elementType = state.elementType;
 							//如果是选中数组,并选择了枚举
-							if(state.types=='enum'){
+							if (state.types == 'enum') {
 								state.valueType.elementType = {
 									elements: state.enumdata,
 									type: 'enum'
 								}
 							}
 							//如果是选中数组,并选择了object
-							if(state.types=='object'){
+							if (state.types == 'object') {
 								state.valueType.elementType = {
 									properties: state.jsondata,
 									type: 'object'
@@ -433,14 +445,14 @@ export default defineComponent({
 						if (state.type == 'array') {
 							state.valueType.elementType = state.elementType;
 							//如果是选中数组,并选择了枚举
-							if(state.types=='enum'){
+							if (state.types == 'enum') {
 								state.valueType.elementType = {
 									elements: state.enumdata,
 									type: 'enum'
 								}
 							}
 							//如果是选中数组,并选择了object
-							if(state.types=='object'){
+							if (state.types == 'object') {
 								state.valueType.elementType = {
 									properties: state.jsondata,
 									type: 'object'
@@ -485,35 +497,41 @@ export default defineComponent({
 	justify-content: space-between;
 	margin-top: 10px;
 }
+
 .input-option {
 	line-height: 30px;
 	padding-top: 5px;
 	width: 140px;
 }
+
 .input-option i {
 	margin: 0px 5px;
 	border: 1px solid #c3c3c3;
 	font-size: 16px;
 }
+
 .input-options {
 	display: flex;
 	align-items: center;
 	color: #409eff;
 	cursor: pointer;
 }
+
 .jslist {
 	width: 100%;
 	border: 1px solid #e8e8e8;
 	padding: 10px;
 	margin-bottom: 10px;
 }
+
 .jsonlist {
 	display: flex;
 	flex-direction: row;
 	justify-content: space-between;
 }
-.jsonoption {
-}
+
+.jsonoption {}
+
 .jsonoption a {
 	margin: 0px 10px;
 }

+ 37 - 18
src/views/iot/device/product/component/editEvent copy.vue

@@ -31,7 +31,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson('fun')">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -77,13 +79,17 @@
 
 				<el-form-item label="枚举项" prop="maxLength" v-if="type == 'enum'">
 					<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-						<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"
-							><el-icon><Right /></el-icon
-						></span>
-						<el-input v-model="item.value" placeholder="请输入枚举文本" />
+						<el-input v-model="item.text" placeholder="请输入枚举文本" /><span style="margin: 0px 10px"><el-icon>
+								<Right />
+							</el-icon></span>
+						<el-input v-model="item.value" placeholder="请输入枚举" />
 						<div class="input-option">
-							<el-icon @click="addEnum" v-if="index == 0"><Plus /></el-icon>
-							<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+							<el-icon @click="addEnum" v-if="index == 0">
+								<Plus />
+							</el-icon>
+							<el-icon @click="delEnum(index)" v-if="index != 0">
+								<Minus />
+							</el-icon>
 						</div>
 					</div>
 				</el-form-item>
@@ -102,7 +108,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -147,13 +155,17 @@
 
 					<el-form-item label="枚举项" prop="maxLength" v-if="types == 'enum'">
 						<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-							<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"
-								><el-icon><Right /></el-icon
-							></span>
+							<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"><el-icon>
+									<Right />
+								</el-icon></span>
 							<el-input v-model="item.value" placeholder="请输入枚举文本" />
 							<div class="input-option">
-								<el-icon @click="addEnum" v-if="index == 0"><Plus /></el-icon>
-								<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+								<el-icon @click="addEnum" v-if="index == 0">
+									<Plus />
+								</el-icon>
+								<el-icon @click="delEnum(index)" v-if="index != 0">
+									<Minus />
+								</el-icon>
 							</div>
 						</div>
 					</el-form-item>
@@ -173,7 +185,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -504,36 +518,41 @@ export default defineComponent({
 	justify-content: space-between;
 	margin-top: 10px;
 }
+
 .input-option {
 	line-height: 30px;
 	padding-top: 5px;
 	width: 140px;
 }
+
 .input-option i {
 	margin: 0px 5px;
 	border: 1px solid #c3c3c3;
 	font-size: 16px;
 }
+
 .input-options {
 	display: flex;
 	align-items: center;
 	color: #409eff;
 	cursor: pointer;
 }
+
 .jslist {
 	width: 100%;
 	border: 1px solid #e8e8e8;
 	padding: 10px;
 	margin-bottom: 10px;
 }
+
 .jsonlist {
 	display: flex;
 	flex-direction: row;
 	justify-content: space-between;
 }
-.jsonoption {
-}
+
+.jsonoption {}
+
 .jsonoption a {
 	margin: 0px 10px;
-}
-</style>
+}</style>

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

@@ -13,7 +13,7 @@
 					<div v-for="(item, index) in inputsdata" :key="index" class="jslist">
 						<div class="jsonlist">
 							<div>参数名称:</div>
-							<div style="width: 60%">{{ item.name }}</div>
+							<div style="width: 60%">{{ item.name }} ({{ item.key }})</div>
 							<div class="jsonoption">
 								<!-- <el-link type="primary">编辑</el-link> -->
 								<el-link type="primary" @click="deljson(index, 'fun')">删除</el-link>
@@ -23,7 +23,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson('fun')">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -33,7 +35,7 @@
 					<div v-for="(item, index) in outputsdata" :key="index" class="jslist">
 						<div class="jsonlist">
 							<div>参数名称:</div>
-							<div style="width: 60%">{{ item.name }}</div>
+							<div style="width: 60%">{{ item.name }} ({{ item.key }})</div>
 							<div class="jsonoption">
 								<!-- <el-link type="primary">编辑</el-link> -->
 								<el-link type="primary" @click="deljsonOut(index, 'fun')">删除</el-link>
@@ -43,7 +45,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJsonOut('fun')">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -157,7 +161,7 @@ export default defineComponent({
 			state.inputsdata = row.inputs || [];
 			state.outputsdata = row.outputs || [];
 			state.isShowDialog = true;
-			
+
 		};
 		const resetForm = () => {
 			state.ruleForm = {
@@ -309,35 +313,41 @@ export default defineComponent({
 	justify-content: space-between;
 	margin-top: 10px;
 }
+
 .input-option {
 	line-height: 30px;
 	padding-top: 5px;
 	width: 140px;
 }
+
 .input-option i {
 	margin: 0px 5px;
 	border: 1px solid #c3c3c3;
 	font-size: 16px;
 }
+
 .input-options {
 	display: flex;
 	align-items: center;
 	color: #409eff;
 	cursor: pointer;
 }
+
 .jslist {
 	width: 100%;
 	border: 1px solid #e8e8e8;
 	padding: 10px;
 	margin-bottom: 10px;
 }
+
 .jsonlist {
 	display: flex;
 	flex-direction: row;
 	justify-content: space-between;
 }
-.jsonoption {
-}
+
+.jsonoption {}
+
 .jsonoption a {
 	margin: 0px 10px;
 }

+ 95 - 80
src/views/iot/device/product/component/editOption.vue

@@ -3,7 +3,7 @@
 		<el-dialog :title="(ruleForm.id !== 0 ? '修改' : '添加') + '参数'" v-model="isShowDialog" width="769px">
 			<el-form :model="ruleForm" ref="formRef" :rules="rules" size="default" label-width="120px">
 				<el-form-item label="参数标识" prop="key">
-					<el-input v-model="ruleForm.key" placeholder="请输入参数标识" :disabled="ruleForm.id!== 0 ?true : false" />
+					<el-input v-model="ruleForm.key" placeholder="请输入参数标识" :disabled="ruleForm.id !== 0 ? true : false" />
 				</el-form-item>
 				<el-form-item label="参数名称" prop="name">
 					<el-input v-model="ruleForm.name" placeholder="请输入参数名称" />
@@ -12,7 +12,7 @@
 				<el-form-item label="数据类型" prop="type">
 					<el-select v-model="valueType.type" placeholder="请选择数据类型" @change="seletChange">
 						<el-option-group v-for="group in typeData" :key="group.label" :label="group.label">
-							<el-option v-for="item in group.options" :key="item.type" :label="item.title" :value="item.type"  :disabled="item.type=='object'" />
+							<el-option v-for="item in group.options" :key="item.type" :label="item.title" :value="item.type" :disabled="item.type == 'object'" />
 						</el-option-group>
 					</el-select>
 				</el-form-item>
@@ -38,90 +38,104 @@
 				<el-form-item label="布尔值" prop="maxLength" v-if="type == 'boolean'">
 					<div class="input-box">
 						<el-input v-model="valueType.trueText" placeholder="请输入布尔值" value="是" /><span style="margin: 0px 10px">~</span>
-						<el-input v-model="valueType.trueValue" placeholder="请输入布尔值"  value="true"/>
+						<el-input v-model="valueType.trueValue" placeholder="请输入布尔值" value="true" />
 					</div>
 
 					<div class="input-box">
-						<el-input v-model="valueType.falseText" placeholder="请输入布尔值"  value="否" /> <span style="margin: 0px 10px">~</span>
-						<el-input v-model="valueType.falseValue" placeholder="请输入布尔值"  value="false"/>
+						<el-input v-model="valueType.falseText" placeholder="请输入布尔值" value="否" /> <span style="margin: 0px 10px">~</span>
+						<el-input v-model="valueType.falseValue" placeholder="请输入布尔值" value="false" />
 					</div>
 				</el-form-item>
 
 				<el-form-item label="枚举项" prop="maxLength" v-if="type == 'enum'">
 					<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-						<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"><el-icon><Right /></el-icon></span>
-						<el-input v-model="item.value" placeholder="请输入枚举文本" />
+						<el-input v-model="item.text" placeholder="请输入枚举文本" /><span style="margin: 0px 10px"><el-icon>
+								<Right />
+							</el-icon></span>
+						<el-input v-model="item.value" placeholder="请输入枚举值" />
 						<div class="input-option">
-							<el-icon @click="addEnum"  v-if="index == 0"><Plus /></el-icon>
-							<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+							<el-icon @click="addEnum" v-if="index == 0">
+								<Plus />
+							</el-icon>
+							<el-icon @click="delEnum(index)" v-if="index != 0">
+								<Minus />
+							</el-icon>
 						</div>
 					</div>
 				</el-form-item>
 
 				<el-form-item label="JSON对象" prop="maxLength" v-if="type == 'object'">
 					<div class="input-options" @click="addJson">
-							<el-icon   ><Plus /></el-icon>
-							<div>添加参数</div>
-						</div>
+						<el-icon>
+							<Plus />
+						</el-icon>
+						<div>添加参数</div>
+					</div>
 				</el-form-item>
 
 
-			<div v-if="type == 'array'">
-				<el-form-item label="元素类型" prop="type" >
-					<el-select v-model="elementType.type" placeholder="请选择元素类型" @change="seletChanges">
-						<el-option-group v-for="group in typeData" :key="group.label" :label="group.label">
-							<el-option v-for="item in group.options" :key="item.type" :label="item.title" :value="item.type" :disabled="item.type=='array'" />
-						</el-option-group>
-					</el-select>
-				</el-form-item>
-
+				<div v-if="type == 'array'">
+					<el-form-item label="元素类型" prop="type">
+						<el-select v-model="elementType.type" placeholder="请选择元素类型" @change="seletChanges">
+							<el-option-group v-for="group in typeData" :key="group.label" :label="group.label">
+								<el-option v-for="item in group.options" :key="item.type" :label="item.title" :value="item.type" :disabled="item.type == 'array'" />
+							</el-option-group>
+						</el-select>
+					</el-form-item>
 
-				<el-form-item label="精度" prop="decimals" v-if="types == 'float' || types == 'double'">
-					<el-input v-model="elementType.decimals" placeholder="请输入精度" />
-				</el-form-item>
 
-				<el-form-item label="单位" prop="unit" v-if="types == 'int' || types == 'long' || types == 'float' || types == 'double'">
-					<el-input v-model="elementType.unit" placeholder="请输入单位" />
-				</el-form-item>
+					<el-form-item label="精度" prop="decimals" v-if="types == 'float' || types == 'double'">
+						<el-input v-model="elementType.decimals" placeholder="请输入精度" />
+					</el-form-item>
 
-				<el-form-item label="最大长度" prop="maxLength" v-if="types == 'string'">
-					<el-input v-model="elementType.maxLength" placeholder="请输入最大长度" />
-				</el-form-item>
+					<el-form-item label="单位" prop="unit" v-if="types == 'int' || types == 'long' || types == 'float' || types == 'double'">
+						<el-input v-model="elementType.unit" placeholder="请输入单位" />
+					</el-form-item>
 
-				<el-form-item label="时间格式" prop="maxLength" v-if="types == 'date'">
-					<el-input v-model="elementType.maxLength" placeholder="请输入时间格式" />
-				</el-form-item>
+					<el-form-item label="最大长度" prop="maxLength" v-if="types == 'string'">
+						<el-input v-model="elementType.maxLength" placeholder="请输入最大长度" />
+					</el-form-item>
 
-				<el-form-item label="布尔值" prop="maxLength" v-if="types == 'boolean'">
-					<div class="input-box">
-						<el-input v-model="elementType.trueText" placeholder="请输入布尔值" value="是" /><span style="margin: 0px 10px">~</span>
-						<el-input v-model="elementType.trueValue" placeholder="请输入布尔值"  value="true"/>
-					</div>
+					<el-form-item label="时间格式" prop="maxLength" v-if="types == 'date'">
+						<el-input v-model="elementType.maxLength" placeholder="请输入时间格式" />
+					</el-form-item>
 
-					<div class="input-box">
-						<el-input v-model="elementType.falseText" placeholder="请输入布尔值"  value="否" /> <span style="margin: 0px 10px">~</span>
-						<el-input v-model="elementType.falseValue" placeholder="请输入布尔值"  value="false"/>
-					</div>
-				</el-form-item>
+					<el-form-item label="布尔值" prop="maxLength" v-if="types == 'boolean'">
+						<div class="input-box">
+							<el-input v-model="elementType.trueText" placeholder="请输入布尔值" value="是" /><span style="margin: 0px 10px">~</span>
+							<el-input v-model="elementType.trueValue" placeholder="请输入布尔值" value="true" />
+						</div>
 
-				<el-form-item label="枚举项" prop="maxLength" v-if="types == 'enum'">
-					<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-						<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"><el-icon><Right /></el-icon></span>
-						<el-input v-model="item.value" placeholder="请输入枚举文本" />
-						<div class="input-option">
-							<el-icon @click="addEnum"  v-if="index == 0"><Plus /></el-icon>
-							<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+						<div class="input-box">
+							<el-input v-model="elementType.falseText" placeholder="请输入布尔值" value="否" /> <span style="margin: 0px 10px">~</span>
+							<el-input v-model="elementType.falseValue" placeholder="请输入布尔值" value="false" />
 						</div>
-					</div>
-				</el-form-item>
+					</el-form-item>
+
+					<el-form-item label="枚举项" prop="maxLength" v-if="types == 'enum'">
+						<div class="input-box" v-for="(item, index) in enumdata" :key="index">
+							<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"><el-icon>
+									<Right />
+								</el-icon></span>
+							<el-input v-model="item.value" placeholder="请输入枚举文本" />
+							<div class="input-option">
+								<el-icon @click="addEnum" v-if="index == 0">
+									<Plus />
+								</el-icon>
+								<el-icon @click="delEnum(index)" v-if="index != 0">
+									<Minus />
+								</el-icon>
+							</div>
+						</div>
+					</el-form-item>
 
 
 
-			</div>
+				</div>
 
 				<!--根据数据类型输出不同表单-->
 
-			
+
 				<el-form-item label="参数描述	" prop="desc">
 					<el-input v-model="ruleForm.desc" type="textarea" placeholder="请输入参数描述"></el-input>
 				</el-form-item>
@@ -140,7 +154,7 @@
 import { reactive, toRefs, defineComponent, ref, unref } from 'vue';
 import api from '/@/api/device';
 import uploadVue from '/@/components/upload/index.vue';
-import { Plus, Minus,Right } from '@element-plus/icons-vue';
+import { Plus, Minus, Right } from '@element-plus/icons-vue';
 
 import { ElMessage, UploadProps } from 'element-plus';
 
@@ -158,7 +172,7 @@ interface DicState {
 
 export default defineComponent({
 	name: 'deviceEditPro',
-	components: { Plus, Minus,Right },
+	components: { Plus, Minus, Right },
 	setup(prop, { emit }) {
 		const formRef = ref<HTMLElement | null>(null);
 
@@ -166,7 +180,7 @@ export default defineComponent({
 			isShowDialog: false,
 			typeData: [], //
 			type: '',
-			types:'',
+			types: '',
 			valueType: {
 				type: '',
 				maxLength: '',
@@ -183,7 +197,7 @@ export default defineComponent({
 			],
 
 			ruleForm: {
-				id:0,
+				id: 0,
 				name: '',
 				key: '',
 				transportProtocol: '',
@@ -236,12 +250,12 @@ export default defineComponent({
 				name: '',
 				desc: '',
 			};
-			state.valueType={};
-			state.enumdata=[{
-					'text': '',
-					'value': '',
-				}];
-			state.elementType={};
+			state.valueType = {};
+			state.enumdata = [{
+				'text': '',
+				'value': '',
+			}];
+			state.elementType = {};
 		};
 
 		const seletChange = (val) => {
@@ -256,16 +270,16 @@ export default defineComponent({
 
 		const addEnum = () => {
 			state.enumdata.push({
-					'text': '',
-					'value': '',
-					
-				});
+				'text': '',
+				'value': '',
+
+			});
 		};
-		const delEnum=(index)=>{
+		const delEnum = (index) => {
 			state.enumdata.splice(index, 1);
 		}
 
-		const addJson=()=>{
+		const addJson = () => {
 
 		}
 		// 关闭弹窗
@@ -291,14 +305,14 @@ export default defineComponent({
 						});
 					} else {
 						//添加
-						if(state.type=='enum'){
-							state.valueType.elements=state.enumdata;
+						if (state.type == 'enum') {
+							state.valueType.elements = state.enumdata;
 						}
 
 						state.ruleForm.valueType = state.valueType;
 						ElMessage.success('参数类型添加成功');
-							closeDialog(); // 关闭弹窗
-							emit('typeList',state.ruleForm,state.ruleForm.type_data);
+						closeDialog(); // 关闭弹窗
+						emit('typeList', state.ruleForm, state.ruleForm.type_data);
 					}
 				}
 			});
@@ -327,21 +341,22 @@ export default defineComponent({
 	justify-content: space-between;
 	margin-top: 10px;
 }
+
 .input-option {
 	line-height: 30px;
 	padding-top: 5px;
 	width: 140px;
 }
+
 .input-option i {
 	margin: 0px 5px;
 	border: 1px solid #c3c3c3;
 	font-size: 16px;
 }
+
 .input-options {
 	display: flex;
-	    align-items: center;
-    color: #409eff;
-	cursor:pointer
-}
-
-</style>
+	align-items: center;
+	color: #409eff;
+	cursor: pointer
+}</style>

+ 46 - 29
src/views/iot/device/product/component/editTab.vue

@@ -3,7 +3,7 @@
 		<el-dialog :title="(ruleForm.id !== 0 ? '修改' : '添加') + '标签定义'" v-model="isShowDialog" width="769px">
 			<el-form :model="ruleForm" ref="formRef" :rules="rules" size="default" label-width="120px">
 				<el-form-item label="标签定义标识" prop="key">
-					<el-input v-model="ruleForm.key" placeholder="请输入标签定义标识" :disabled="ruleForm.id!== 0 ?true : false" />
+					<el-input v-model="ruleForm.key" placeholder="请输入标签定义标识" :disabled="ruleForm.id !== 0 ? true : false" />
 				</el-form-item>
 				<el-form-item label="标签定义名称" prop="name">
 					<el-input v-model="ruleForm.name" placeholder="请输入标签定义名称" />
@@ -49,13 +49,17 @@
 
 				<el-form-item label="枚举项" prop="maxLength" v-if="type == 'enum'">
 					<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-						<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"
-							><el-icon><Right /></el-icon
-						></span>
-						<el-input v-model="item.value" placeholder="请输入枚举文本" />
+						<el-input v-model="item.text" placeholder="请输入枚举文本" /><span style="margin: 0px 10px"><el-icon>
+								<Right />
+							</el-icon></span>
+						<el-input v-model="item.value" placeholder="请输入枚举" />
 						<div class="input-option">
-							<el-icon @click="addEnum" v-if="index == 0"><Plus /></el-icon>
-							<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+							<el-icon @click="addEnum" v-if="index == 0">
+								<Plus />
+							</el-icon>
+							<el-icon @click="delEnum(index)" v-if="index != 0">
+								<Minus />
+							</el-icon>
 						</div>
 					</div>
 				</el-form-item>
@@ -74,7 +78,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -119,13 +125,17 @@
 
 					<el-form-item label="枚举项" prop="maxLength" v-if="types == 'enum'">
 						<div class="input-box" v-for="(item, index) in enumdata" :key="index">
-							<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"
-								><el-icon><Right /></el-icon
-							></span>
+							<el-input v-model="item.text" placeholder="请输入枚举值" /><span style="margin: 0px 10px"><el-icon>
+									<Right />
+								</el-icon></span>
 							<el-input v-model="item.value" placeholder="请输入枚举文本" />
 							<div class="input-option">
-								<el-icon @click="addEnum" v-if="index == 0"><Plus /></el-icon>
-								<el-icon @click="delEnum(index)" v-if="index != 0"><Minus /></el-icon>
+								<el-icon @click="addEnum" v-if="index == 0">
+									<Plus />
+								</el-icon>
+								<el-icon @click="delEnum(index)" v-if="index != 0">
+									<Minus />
+								</el-icon>
 							</div>
 						</div>
 					</el-form-item>
@@ -145,7 +155,9 @@
 
 					<div style="display: block; width: 100%">
 						<div class="input-options" @click="addJson">
-							<el-icon><Plus /></el-icon>
+							<el-icon>
+								<Plus />
+							</el-icon>
 							<div>添加参数</div>
 						</div>
 					</div>
@@ -299,11 +311,11 @@ export default defineComponent({
 					state.jsondata = row.valueType.properties;
 				}
 
-				if(row.type == 'array' && state.types=='enum'){
-					state.enumdata=row.valueType.elementType.elements
+				if (row.type == 'array' && state.types == 'enum') {
+					state.enumdata = row.valueType.elementType.elements
 				}
-				if(row.type == 'array' && state.types=='object'){
-					state.jsondata=row.valueType.elementType.properties
+				if (row.type == 'array' && state.types == 'object') {
+					state.jsondata = row.valueType.elementType.properties
 				}
 			}
 
@@ -330,9 +342,9 @@ export default defineComponent({
 			state.elementType = {};
 			state.jsondata = [];
 			state.enumdata = [{
-					text: '',
-					value: '',
-				},];
+				text: '',
+				value: '',
+			},];
 		};
 
 		const seletChange = (val) => {
@@ -396,14 +408,14 @@ export default defineComponent({
 						if (state.type == 'array') {
 							state.valueType.elementType = state.elementType;
 							//如果是选中数组,并选择了枚举
-							if(state.types=='enum'){
+							if (state.types == 'enum') {
 								state.valueType.elementType = {
 									elements: state.enumdata,
 									type: 'enum'
 								}
 							}
 							//如果是选中数组,并选择了object
-							if(state.types=='object'){
+							if (state.types == 'object') {
 								state.valueType.elementType = {
 									properties: state.jsondata,
 									type: 'object'
@@ -432,13 +444,13 @@ export default defineComponent({
 						if (state.type == 'array') {
 							state.valueType.elementType = state.elementType;
 							//如果是选中数组,并选择了枚举
-							if(state.types=='enum'){
+							if (state.types == 'enum') {
 								state.valueType.elementType = {
 									elements: state.enumdata
 								}
 							}
 							//如果是选中数组,并选择了object
-							if(state.types=='object'){
+							if (state.types == 'object') {
 								state.valueType.elementType = {
 									properties: state.jsondata,
 									type: 'object'
@@ -483,36 +495,41 @@ export default defineComponent({
 	justify-content: space-between;
 	margin-top: 10px;
 }
+
 .input-option {
 	line-height: 30px;
 	padding-top: 5px;
 	width: 140px;
 }
+
 .input-option i {
 	margin: 0px 5px;
 	border: 1px solid #c3c3c3;
 	font-size: 16px;
 }
+
 .input-options {
 	display: flex;
 	align-items: center;
 	color: #409eff;
 	cursor: pointer;
 }
+
 .jslist {
 	width: 100%;
 	border: 1px solid #e8e8e8;
 	padding: 10px;
 	margin-bottom: 10px;
 }
+
 .jsonlist {
 	display: flex;
 	flex-direction: row;
 	justify-content: space-between;
 }
-.jsonoption {
-}
+
+.jsonoption {}
+
 .jsonoption a {
 	margin: 0px 10px;
-}
-</style>
+}</style>