瀏覽代碼

fix: 修改设备中的productKey字段等

yanglzh 1 年之前
父節點
當前提交
0c2fa04bf4

+ 9 - 9
src/views/iot/device/instance/component/edit.vue

@@ -8,9 +8,9 @@
         <el-form-item label="设备名称" prop="name">
           <el-input v-model="ruleForm.name" placeholder="请输入设备名称" />
         </el-form-item>
-        <el-form-item label="所属产品" prop="productId">
-          <el-select v-model="ruleForm.productId" @change="productIdChange" :disabled="ruleForm.id" placeholder="请选择所属产品" class="w100">
-            <el-option v-for="item in productData" :key="item.id" :label="item.name" :value="item.id" />
+        <el-form-item label="所属产品" prop="productKey">
+          <el-select v-model="ruleForm.productKey" @change="productIdChange" :disabled="ruleForm.id" placeholder="请选择所属产品" class="w100">
+            <el-option v-for="item in productData" :key="item.id" :label="item.name" :value="item.key" />
           </el-select>
         </el-form-item>
         <el-form-item label="设备坐标" prop="lng">
@@ -99,7 +99,7 @@ interface RuleFormState {
   key: string;
   name: string;
   version: string;
-  productId: number | string;
+  productKey: string | string;
   tags: Tag[];
   lng: string;
   lat: string;
@@ -117,7 +117,7 @@ const form: RuleFormState = {
   id: 0,
   key: '',
   name: '',
-  productId: '',
+  productKey: '',
   tags: [],
   lng: '',
   lat: '',
@@ -176,7 +176,7 @@ export default defineComponent({
         key: [
           { required: true, message: "设备标识不能为空", trigger: "blur" }
         ],
-        productId: [{ required: true, message: '所属产品不能为空', trigger: 'blur' }],
+        productKey: [{ required: true, message: '所属产品不能为空', trigger: 'blur' }],
       },
       deviceImgLimit: 0,
       certificateLimit: 0,
@@ -216,7 +216,7 @@ export default defineComponent({
         state.phone = row.extensionInfo ? JSON.parse(row.extensionInfo).phone : [];
         state.certificate = row.extensionInfo ? JSON.parse(row.extensionInfo).certificate : [];
         state.intro = row.extensionInfo ? JSON.parse(row.extensionInfo).intro : "";
-        productIdChange(row.productId as number)
+        productKeyChange(row.productKey as string)
       }
       state.isShowDialog = true;
     };
@@ -293,8 +293,8 @@ export default defineComponent({
     }
 
     // 所属产品变化的时候,更新产品详情
-    const productIdChange = (productId: number) => {
-      api.product.detail(productId).then((res: any) => {
+    const productIdChange = (productKey: string) => {
+      api.product.detail(productKey).then((res: any) => {
         const { authType, authUser, authPasswd, accessToken, certificateId } = res.data
         state.product = res.data
         state.ruleForm.authType = authType

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

@@ -54,7 +54,7 @@ getData()
 
 function getData() {
 	loading.value = true
-	api.tabDeviceFucntion.getList({ key: props.productKey }).then((res: IListItem[]) => {
+	api.tabDeviceFucntion.getList({ productKey: props.productKey }).then((res: IListItem[]) => {
 		if (!res) return
 		res.forEach((item) => (item.result = ''))
 		list.value = res

+ 18 - 18
src/views/iot/device/instance/component/subDevice.vue

@@ -402,7 +402,7 @@ export default defineComponent({
 			activetab: 'attr', // 分类数据
 			detail: [],
 			prodetail: [],
-			product_id: 0,
+			productKey: '',
 			developer_status: 0,
 			deviceTableData: {
 				data: [],
@@ -421,7 +421,7 @@ export default defineComponent({
 				loading: false,
 				param: {
 					pageNum: 1,
-					productId: 0,
+					productKey: '',
 					pageSize: 10,
 					status: '',
 					dateRange: [],
@@ -433,7 +433,7 @@ export default defineComponent({
 				loading: false,
 				param: {
 					pageNum: 1,
-					productId: 0,
+					productKey: '',
 					pageSize: 10,
 					status: '',
 					dateRange: [],
@@ -460,10 +460,10 @@ export default defineComponent({
                 api.instance.detail(ids).then((res: any) => {
                     state.detail = res.data;
                     state.developer_status = res.data.status;
-                    state.tableData.param.productId = res.data.product.id;
-                    state.product_id = res.data.product.id;
+                    state.tableData.param.productKey = res.data.product.key;
+                    state.productKey = res.data.product.key;
                     getrunData();
-                    api.product.detail(res.data.product.id).then((productRes: any) => {
+                    api.product.detail(res.data.product.key).then((productRes: any) => {
                         state.prodetail = productRes.data;
                     });
                     //第一次加载
@@ -484,41 +484,41 @@ export default defineComponent({
 
 		//编辑属性
 		const onEditAttr = (row: TableDataRow) => {
-			editAttrRef.value.openDialog(row, state.product_id)
+			editAttrRef.value.openDialog(row, state.productKey)
 		}
 
 		//编辑功能
 		const onEditFun = (row: TableDataRow) => {
-			editFunRef.value.openDialog(row, state.product_id)
+			editFunRef.value.openDialog(row, state.productKey)
 		}
 
 		//编辑事件
 		const onEditEvent = (row: TableDataRow) => {
-			editEventRef.value.openDialog(row, state.product_id)
+			editEventRef.value.openDialog(row, state.productKey)
 		}
 
 		//编辑标签
 		const onEditTag = (row: TableDataRow) => {
-			editTabRef.value.openDialog(row, state.product_id)
+			editTabRef.value.openDialog(row, state.productKey)
 		}
 
 		//打开添加属性弹窗
 		const onOpenEditAttr = () => {
-			editAttrRef.value.openDialog({ product_id: state.product_id, id: 0, accessMode: 0 })
+			editAttrRef.value.openDialog({ productKey: state.productKey, id: 0, accessMode: 0 })
 		}
 
 		//打开添加功能弹窗
 		const onOpenEditFun = () => {
-			editFunRef.value.openDialog({ product_id: state.product_id, id: 0 })
+			editFunRef.value.openDialog({ productKey: state.productKey, id: 0 })
 		}
 		//打开添加事件弹窗
 		const onOpenEditEvent = () => {
-			editEventRef.value.openDialog({ product_id: state.product_id, id: 0, level: 0 })
+			editEventRef.value.openDialog({ productKey: state.productKey, id: 0, level: 0 })
 		}
 
 		//打开添加事件弹窗
 		const onOpenEditTab = () => {
-			editTabRef.value.openDialog({ product_id: state.product_id, id: 0, accessMode: 0 })
+			editTabRef.value.openDialog({ productKey: state.productKey, id: 0, accessMode: 0 })
 		}
 
 		//查看日志列表
@@ -546,25 +546,25 @@ export default defineComponent({
 			})
 				.then(() => {
 					if (type == 'attr') {
-						api.model.propertydel(state.product_id, key).then(() => {
+						api.model.propertydel(state.productKey, key).then(() => {
 							ElMessage.success('删除成功')
 							getproperty()
 						})
 					}
 					if (type == 'fun') {
-						api.model.functiondel(state.product_id, key).then(() => {
+						api.model.functiondel(state.productKey, key).then(() => {
 							ElMessage.success('删除成功')
 							getfunction()
 						})
 					}
 					if (type == 'event') {
-						api.model.eventdel(state.product_id, key).then(() => {
+						api.model.eventdel(state.productKey, key).then(() => {
 							ElMessage.success('删除成功')
 							getevent()
 						})
 					}
 					if (type == 'tab') {
-						api.model.tagdel(state.product_id, key).then(() => {
+						api.model.tagdel(state.productKey, key).then(() => {
 							ElMessage.success('删除成功')
 							tagdel()
 						})

+ 19 - 19
src/views/iot/device/instance/detail.vue

@@ -509,7 +509,7 @@ export default defineComponent({
       activetab: 'attr', // 分类数据
       detail: {},
       prodetail: [],
-      product_id: 0,
+      productKey: '',
       developer_status: 0,
       deviceTableData: {
         data: [],
@@ -528,7 +528,7 @@ export default defineComponent({
         loading: false,
         param: {
           pageNum: 1,
-          productId: 0,
+          productKey: '',
           pageSize: 10,
           status: '',
           dateRange: [],
@@ -540,7 +540,7 @@ export default defineComponent({
         loading: false,
         param: {
           pageNum: 1,
-          productId: 0,
+          productKey: '',
           pageSize: 10,
           status: '',
           dateRange: [],
@@ -558,9 +558,9 @@ export default defineComponent({
       api.instance.detail(ids).then((res: any) => {
         state.detail = res.data;
         state.developer_status = res.data.status;
-        state.tableData.param.productId = res.data.product.id;
-        state.product_id = res.data.product.id;
-        api.product.detail(res.data.product.id).then((res: any) => {
+        state.tableData.param.productKey = res.data.product.key;
+        state.productKey = res.data.product.key;
+        api.product.detail(res.data.product.key).then((res: any) => {
           state.prodetail = res.data;
         });
 
@@ -570,7 +570,7 @@ export default defineComponent({
         state.intro = intro
 
         //加载全部属性
-        datahub.node.getpropertyList({ key: state.detail.product.key }).then((re: any) => {
+        datahub.node.getpropertyList({ productKey: state.detail.product.key }).then((re: any) => {
           array_list.value = re;
           re.forEach((item: any) => propertyMap.set(item.key, item?.valueType));
         });
@@ -684,41 +684,41 @@ export default defineComponent({
 
     //编辑属性
     const onEditAttr = (row: TableDataRow) => {
-      editAttrRef.value.openDialog(row, state.product_id);
+      editAttrRef.value.openDialog(row, state.productKey);
     };
 
     //编辑功能
     const onEditFun = (row: TableDataRow) => {
-      editFunRef.value.openDialog(row, state.product_id);
+      editFunRef.value.openDialog(row, state.productKey);
     };
 
     //编辑事件
     const onEditEvent = (row: TableDataRow) => {
-      editEventRef.value.openDialog(row, state.product_id);
+      editEventRef.value.openDialog(row, state.productKey);
     };
 
     //编辑标签
     const onEditTag = (row: TableDataRow) => {
-      editTabRef.value.openDialog(row, state.product_id);
+      editTabRef.value.openDialog(row, state.productKey);
     };
 
     //打开添加属性弹窗
     const onOpenEditAttr = () => {
-      editAttrRef.value.openDialog({ product_id: state.product_id, id: 0, accessMode: 0 });
+      editAttrRef.value.openDialog({ productKey: state.productKey, id: 0, accessMode: 0 });
     };
 
     //打开添加功能弹窗
     const onOpenEditFun = () => {
-      editFunRef.value.openDialog({ product_id: state.product_id, id: 0 });
+      editFunRef.value.openDialog({ productKey: state.productKey, id: 0 });
     };
     //打开添加事件弹窗
     const onOpenEditEvent = () => {
-      editEventRef.value.openDialog({ product_id: state.product_id, id: 0, level: 0 });
+      editEventRef.value.openDialog({ productKey: state.productKey, id: 0, level: 0 });
     };
 
     //打开添加事件弹窗
     const onOpenEditTab = () => {
-      editTabRef.value.openDialog({ product_id: state.product_id, id: 0, accessMode: 0 });
+      editTabRef.value.openDialog({ productKey: state.productKey, id: 0, accessMode: 0 });
     };
 
     //查看日志列表
@@ -751,25 +751,25 @@ export default defineComponent({
       })
         .then(() => {
           if (type == 'attr') {
-            api.model.propertydel(state.product_id, key).then(() => {
+            api.model.propertydel(state.productKey, key).then(() => {
               ElMessage.success('删除成功');
               getproperty();
             });
           }
           if (type == 'fun') {
-            api.model.functiondel(state.product_id, key).then(() => {
+            api.model.functiondel(state.productKey, key).then(() => {
               ElMessage.success('删除成功');
               getfunction();
             });
           }
           if (type == 'event') {
-            api.model.eventdel(state.product_id, key).then(() => {
+            api.model.eventdel(state.productKey, key).then(() => {
               ElMessage.success('删除成功');
               getevent();
             });
           }
           if (type == 'tab') {
-            api.model.tagdel(state.product_id, key).then(() => {
+            api.model.tagdel(state.productKey, key).then(() => {
               ElMessage.success('删除成功');
               tagdel();
             });

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

@@ -377,7 +377,7 @@ export default defineComponent({
 		}
 
 		const addJson = () => {
-			editOptionRef.value.openDialog({ productKey: 0, id: 0 });
+			editOptionRef.value.openDialog({ productKey: '', id: 0 });
 		};
 		const getOptionData = (data) => {
 			state.jsondata.push(data);

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

@@ -197,7 +197,7 @@ export default defineComponent({
 		}
 
 		const addJson = (type) => {
-			editOptionRef.value.openDialog({ productKey: 0, id: 0, type_data: type });
+			editOptionRef.value.openDialog({ productKey: '', id: 0, type_data: type });
 		};
 		const getOptionData = (data, type_data) => {
 			if (type_data == 'fun') {

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

@@ -158,7 +158,7 @@ export default defineComponent({
 		});
 
 		// 打开弹窗
-		const openDialog = (row: RuleFormState | null, productKey: number | null) => {
+		const openDialog = (row: RuleFormState | null, productKey: string | null) => {
 			resetForm();
 			state.ruleForm = row;
 			state.productKey = productKey;
@@ -236,11 +236,11 @@ export default defineComponent({
 		}
 
 		const addJson = (type) => {
-			editOptionRef.value.openDialog({ productKey: 0, id: 0, type_data: type });
+			editOptionRef.value.openDialog({ productKey: '', id: 0, type_data: type });
 		};
 
 		const addJsonOut = (type) => {
-			editOptionOutRef.value.openDialog({ productKey: 0, id: 0, type_data: type });
+			editOptionOutRef.value.openDialog({ productKey: '', id: 0, type_data: type });
 		};
 
 		const getOptionData = (data, type_data) => {

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

@@ -371,7 +371,7 @@ export default defineComponent({
 		};
 
 		const addJson = () => {
-			editOptionRef.value.openDialog({ productKey: 0, id: 0 });
+			editOptionRef.value.openDialog({ productKey: '', id: 0 });
 		};
 		const getOptionData = (data) => {
 			state.jsondata.push(data);