Ver código fonte

优化请求参数设备ID变更为设备KEY

microrain 1 ano atrás
pai
commit
56a880a72a

+ 5 - 5
src/views/iot/device/instance/component/list.vue

@@ -25,7 +25,7 @@
 		</el-dialog>
 	</div>
 </template>
- 
+
 <script lang="ts">
 import { reactive, toRefs, defineComponent, ref, unref } from 'vue';
 import { Close } from '@element-plus/icons-vue';
@@ -54,7 +54,7 @@ interface TableDataState {
 		param: {
 			pageNum: number;
 			pageSize: number;
-			id: number;
+      deviceKey: string;
 		};
 	};
 }
@@ -73,16 +73,16 @@ export default defineComponent({
 				param: {
 					pageNum: 1,
 					pageSize: 10,
-					id: 0,
+          deviceKey: '',
 					propertyKey: '',
 				},
 			},
 		});
 		// 打开弹窗
-		const openDialog = (row: RuleFormState | null, devid) => {
+		const openDialog = (row: RuleFormState | null, deviceKey) => {
 			resetForm();
 			if (row) {
-				state.tableData.param.id = devid;
+				state.tableData.param.deviceKey = deviceKey;
 				state.tableData.param.propertyKey = row.key
 				typeList();
 

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

@@ -54,7 +54,7 @@
 
                   {{getValueText(item.key,item.value)}}
                   <!-- {{ item.value }}{{ item.unit }} -->
-                  
+
                 </div>
                 <div v-else>
                   <div class="oblist" v-for="(vare, name) in item.value">
@@ -375,7 +375,7 @@
           </el-form>
         </el-tab-pane>
 
-  
+
 
       </el-tabs>
     </div>
@@ -543,7 +543,7 @@ export default defineComponent({
     });
 
     function initData() {
-      
+
       const ids = route.params && route.params.id;
       api.instance.detail(ids).then((res: any) => {
         state.detail = res.data;
@@ -811,7 +811,7 @@ export default defineComponent({
         getrunData();
       }
     };
- 
+
     const getValueText=(key, value)=>{
       let data =array_list.value;
       for (let i = 0; i < data.length; i++) {
@@ -867,15 +867,15 @@ export default defineComponent({
     }
 
     const getrunData = () => {
-      
-      api.instance.getrun_status({ id: state.detail.id }).then((res: any) => {
+
+      api.instance.getrun_status({ deviceKey: state.detail.key }).then((res: any) => {
         state.areaData = res
         let properties = state.areaData.properties || [];
 
         var temp = new Array();
 
         properties.forEach(function (item, index) {
-          
+
           let datalist = item.list || [];
           temp[index] = [];
           var temps = new Array();

+ 3 - 3
src/views/iot/device/template/detail.vue

@@ -578,7 +578,7 @@ export default defineComponent({
 		};
 
 		const getrunData = () => {
-			api.instance.getrun_status({ id: state.detail.id }).then((res: any) => {
+			api.instance.getrun_status({ deviceKey: state.detail.key }).then((res: any) => {
 				state.areaData = res;
 				let properties = state.areaData.properties || [];
 
@@ -621,12 +621,12 @@ export default defineComponent({
 
 		const CkOption = () => {
 			if (state.developer_status == 2) {
-				api.instance.devoffline({ id: state.detail.id }).then((res: any) => {
+				api.instance.devoffline({ deviceKey: state.detail.key }).then((res: any) => {
 					ElMessage.success('操作成功');
 					state.developer_status = 1;
 				});
 			} else {
-				api.instance.devonline({ id: state.detail.id }).then((res: any) => {
+				api.instance.devonline({ deviceKey: state.detail.key }).then((res: any) => {
 					ElMessage.success('操作成功');
 					state.developer_status = 2;
 				});