Răsfoiți Sursa

1.去掉产品、设备所属部门字段:新增、编辑、详情、列表
2.产品详情,表格中增加产品标识展示,去除产品名称

yukai 2 ani în urmă
părinte
comite
63aa7c65a3

+ 74 - 76
src/views/iot/device/category/index.vue

@@ -6,7 +6,6 @@
           <el-form-item label="分类名称">
             <el-input size="default" v-model="tableData.param.name" placeholder="请输入分类名称" class="w-50" clearable />
           </el-form-item>
-         
           <el-form-item>
             <el-button size="default" type="primary" class="ml10" @click="getCateList">
               <el-icon>
@@ -25,8 +24,7 @@
       </div>
       <el-table :data="tableData.data" style="width: 100%" row-key="id" default-expand-all :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" v-loading="tableData.loading">
         <el-table-column prop="name" label="分类名称" v-col="'name'" show-overflow-tooltip> </el-table-column>
-        
-       
+
         <el-table-column prop="desc" label="描述" align="center" min-width="180" v-col="'desc'"></el-table-column>
         <el-table-column label="操作" align="center" width="140" fixed="right">
           <template #default="scope">
@@ -49,83 +47,83 @@ import api from '/@/api/device';
 
 // 定义接口来定义对象的类型
 interface TableDataRow {
-	id: number;
-	parentId: number;
-	name: string;
-	status: number;
-	orderNum: number;
-	leader: string;
-	children?: TableDataRow[];
+  id: number;
+  parentId: number;
+  name: string;
+  status: number;
+  orderNum: number;
+  leader: string;
+  children?: TableDataRow[];
 }
 interface TableDataState {
-	tableData: {
-		data: Array<TableDataRow>;
-		loading: boolean;
-		param: {
-			name: string;
-			status: number;
-		};
-	};
+  tableData: {
+    data: Array<TableDataRow>;
+    loading: boolean;
+    param: {
+      name: string;
+      status: number;
+    };
+  };
 }
 
 export default defineComponent({
-	name: 'deviceCate',
-	components: { EditCate },
-	setup() {
-		const editDeptRef = ref();
-		const state = reactive<TableDataState>({
-			tableData: {
-				data: [],
-				loading: false,
-				param: {
-					name: '',
-					status: -1,
-				},
-			},
-		});
-		// 初始化表格数据
-		const initTableData = () => {
-			getCateList();
-		};
-		const getCateList = () => {
-			state.tableData.loading = true;
-			api.category.getList(state.tableData.param).then((res: any) => {
-				state.tableData.data = res.category;
-			}).finally(() => (state.tableData.loading = false));
-		};
-		// 打开新增菜单弹窗
-		const onOpenAdd = (row?: TableDataRow) => {
-			editDeptRef.value.openDialog(row?.id);
-		};
-		// 打开编辑菜单弹窗
-		const onOpenEdit = (row: TableDataRow) => {
-			editDeptRef.value.openDialog(row);
-		};
-		// 删除当前行
-		const onTabelRowDel = (row: TableDataRow) => {
-			ElMessageBox.confirm(`此操作将永久删除分类:${row.name}, 是否继续?`, '提示', {
-				confirmButtonText: '删除',
-				cancelButtonText: '取消',
-				type: 'warning',
-			}).then(() => {
-				api.category.del(row.id).then(() => {
-					ElMessage.success('删除成功');
-					getCateList();
-				});
-			});
-		};
-		// 页面加载时
-		onMounted(() => {
-			initTableData();
-		});
-		return {
-			editDeptRef,
-			getCateList,
-			onOpenAdd,
-			onOpenEdit,
-			onTabelRowDel,
-			...toRefs(state),
-		};
-	},
+  name: 'deviceCate',
+  components: { EditCate },
+  setup() {
+    const editDeptRef = ref();
+    const state = reactive<TableDataState>({
+      tableData: {
+        data: [],
+        loading: false,
+        param: {
+          name: '',
+          status: -1,
+        },
+      },
+    });
+    // 初始化表格数据
+    const initTableData = () => {
+      getCateList();
+    };
+    const getCateList = () => {
+      state.tableData.loading = true;
+      api.category.getList(state.tableData.param).then((res: any) => {
+        state.tableData.data = res.category;
+      }).finally(() => (state.tableData.loading = false));
+    };
+    // 打开新增菜单弹窗
+    const onOpenAdd = (row?: TableDataRow) => {
+      editDeptRef.value.openDialog(row?.id);
+    };
+    // 打开编辑菜单弹窗
+    const onOpenEdit = (row: TableDataRow) => {
+      editDeptRef.value.openDialog({ ...row });
+    };
+    // 删除当前行
+    const onTabelRowDel = (row: TableDataRow) => {
+      ElMessageBox.confirm(`此操作将永久删除分类:${row.name}, 是否继续?`, '提示', {
+        confirmButtonText: '删除',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(() => {
+        api.category.del(row.id).then(() => {
+          ElMessage.success('删除成功');
+          getCateList();
+        });
+      });
+    };
+    // 页面加载时
+    onMounted(() => {
+      initTableData();
+    });
+    return {
+      editDeptRef,
+      getCateList,
+      onOpenAdd,
+      onOpenEdit,
+      onTabelRowDel,
+      ...toRefs(state),
+    };
+  },
 });
 </script>

Fișier diff suprimat deoarece este prea mare
+ 479 - 494
src/views/iot/device/instance/detail.vue


+ 142 - 143
src/views/iot/device/instance/index.vue

@@ -6,7 +6,7 @@
           <el-form-item label="设备名称" prop="name">
             <el-input v-model="tableData.param.name" placeholder="请输入产品名称" clearable size="default" style="width: 240px" @keyup.enter.native="typeList" />
           </el-form-item>
-		  <el-form-item label="设备标识" prop="key">
+          <el-form-item label="设备标识" prop="key">
             <el-input v-model="tableData.param.key" placeholder="请输入产品名称" clearable size="default" style="width: 240px" @keyup.enter.native="typeList" />
           </el-form-item>
 
@@ -57,7 +57,6 @@
         <el-table-column label="产品名称" prop="productName" :show-overflow-tooltip="true" v-col="'productName'"/>
         <!-- <el-table-column label="部门" prop="deptName" :show-overflow-tooltip="true" v-col="'deptName'"/> -->
 
-
         <el-table-column prop="status" label="状态" width="100" align="center" v-col="'status'">
           <template #default="scope">
             <el-tag type="info" size="small" v-if="scope.row.status==1">离线</el-tag>
@@ -65,13 +64,13 @@
             <el-tag type="info" size="small" v-if="scope.row.status==0">未启用</el-tag>
           </template>
         </el-table-column>
-         <el-table-column prop="registryTime" label="激活时间" align="center" width="150" v-col="'registryTime'"></el-table-column>
-         <el-table-column prop="lastOnlineTime" label="最后上线时间" align="center" width="150" v-col="'lastOnlineTime'"></el-table-column>
+        <el-table-column prop="registryTime" label="激活时间" align="center" width="150" v-col="'registryTime'"></el-table-column>
+        <el-table-column prop="lastOnlineTime" label="最后上线时间" align="center" width="150" v-col="'lastOnlineTime'"></el-table-column>
         <el-table-column label="操作" width="200" align="center" fixed="right">
           <template #default="scope">
 
-			 <!-- <el-button size="small" text type="primary" @click="onOpenDetail(scope.row)">详情</el-button> -->
-			 <router-link :to="'/device/instance/detail/' + scope.row.id" class="link-type" style="padding-right: 12px;
+            <!-- <el-button size="small" text type="primary" @click="onOpenDetail(scope.row)">详情</el-button> -->
+            <router-link :to="'/device/instance/detail/' + scope.row.id" class="link-type" style="padding-right: 12px;
     font-size: 12px;color: #409eff;" v-auth="'detail'">
               <span>详情</span>
             </router-link>
@@ -96,148 +95,148 @@ import api from '/@/api/device';
 
 // 定义接口来定义对象的类型
 interface TableDataRow {
-	id: number;
-	name: string;
-	key: string;
-	status: number;
-	desc: string;
-	createBy: string;
+  id: number;
+  name: string;
+  key: string;
+  status: number;
+  desc: string;
+  createBy: string;
 }
 interface TableDataState {
-	ids: number[];
-	tableData: {
-		data: Array<TableDataRow>;
-		total: number;
-		loading: boolean;
-		param: {
-			pageNum: number;
-			pageSize: number;
-			name: string;
-			key: string;
-			status: string;
-			dateRange: string[];
-		};
-	};
+  ids: number[];
+  tableData: {
+    data: Array<TableDataRow>;
+    total: number;
+    loading: boolean;
+    param: {
+      pageNum: number;
+      pageSize: number;
+      name: string;
+      key: string;
+      status: string;
+      dateRange: string[];
+    };
+  };
 }
 
 export default defineComponent({
-	name: 'deviceInstance',
-	components: { EditDic },
-	setup() {
-		const addDicRef = ref();
-		const editDicRef = ref();
-		const detailRef=ref();
-		const queryRef = ref();
-		const state = reactive<TableDataState>({
-			ids: [],
-			tableData: {
-				data: [],
-				total: 0,
-				loading: false,
-				param: {
-					pageNum: 1,
-					pageSize: 10,
-					name: '',
-					key: '',
-					status: '',
-					dateRange: [],
-				},
-			},
-		});
-		// 初始化表格数据
-		const initTableData = () => {
-			typeList();
-		};
-		const typeList = () => {
-			state.tableData.loading = true;
-			api.instance.getList(state.tableData.param).then((res: any) => {
-				console.log(res);
-				state.tableData.data = res.device;
-				state.tableData.total = res.total;
-			}).finally(() => (state.tableData.loading = false));
-		};
+  name: 'deviceInstance',
+  components: { EditDic },
+  setup() {
+    const addDicRef = ref();
+    const editDicRef = ref();
+    const detailRef = ref();
+    const queryRef = ref();
+    const state = reactive<TableDataState>({
+      ids: [],
+      tableData: {
+        data: [],
+        total: 0,
+        loading: false,
+        param: {
+          pageNum: 1,
+          pageSize: 10,
+          name: '',
+          key: '',
+          status: '',
+          dateRange: [],
+        },
+      },
+    });
+    // 初始化表格数据
+    const initTableData = () => {
+      typeList();
+    };
+    const typeList = () => {
+      state.tableData.loading = true;
+      api.instance.getList(state.tableData.param).then((res: any) => {
+        console.log(res);
+        state.tableData.data = res.device;
+        state.tableData.total = res.total;
+      }).finally(() => (state.tableData.loading = false));
+    };
 
-		//查看详情
-		const onOpenDetail=(row: TableDataRow)=>{
-			detailRef.value.openDialog(row);
-		}
-		// 打开新增产品弹窗
-		const onOpenAddDic = () => {
-			editDicRef.value.openDialog();
-		};
-		// 打开修改产品弹窗
-		const onOpenEditDic = (row: TableDataRow) => {
-			editDicRef.value.openDialog(row);
-		};
-		// 删除产品
-		const onRowDel = (row: TableDataRow) => {
-			let msg = '你确定要删除所选数据?';
-			let ids: number[] = [];
-			if (row) {
-				msg = `此操作将永久删除设备:“${row.name}”,是否继续?`;
-				ids = [row.id];
-			} else {
-				ids = state.ids;
-			}
-			if (ids.length === 0) {
-				ElMessage.error('请选择要删除的数据。');
-				return;
-			}
-			ElMessageBox.confirm(msg, '提示', {
-				confirmButtonText: '确认',
-				cancelButtonText: '取消',
-				type: 'warning',
-			})
-				.then(() => {
-					api.instance.del(ids).then(() => {
-						ElMessage.success('删除成功');
-						typeList();
-					});
-				})
-				.catch(() => {});
-		};
-		// 页面加载时
-		onMounted(() => {
-			initTableData();
-		});
-		/** 重置按钮操作 */
-		const resetQuery = (formEl: FormInstance | undefined) => {
-			if (!formEl) return;
-			formEl.resetFields();
-			typeList();
-		};
-		// 多选框选中数据
-		const handleSelectionChange = (selection: TableDataRow[]) => {
-			state.ids = selection.map((item) => item.id);
-		};
-		const onActionStatus=(item:TableDataRow[])=>{
-			if(item.status==0){
-				api.instance.devdeploy({id:item.id}).then((res: any) => {
-						typeList();
-						ElMessage.success(res.message || '操作成功');
-				});
-			}else{
-				api.instance.devundeploy({id:item.id}).then((res: any) => {
-						typeList();
-						ElMessage.success(res.message || '操作成功');
-				});
-			}
-		}
-		return {
-			addDicRef,
-			editDicRef,
-			detailRef,
-			queryRef,
-			onActionStatus,
-			onOpenDetail,
-			onOpenAddDic,
-			onOpenEditDic,
-			onRowDel,
-			typeList,
-			resetQuery,
-			handleSelectionChange,
-			...toRefs(state),
-		};
-	},
+    //查看详情
+    const onOpenDetail = (row: TableDataRow) => {
+      detailRef.value.openDialog(row);
+    }
+    // 打开新增产品弹窗
+    const onOpenAddDic = () => {
+      editDicRef.value.openDialog();
+    };
+    // 打开修改产品弹窗
+    const onOpenEditDic = (row: TableDataRow) => {
+      editDicRef.value.openDialog(row);
+    };
+    // 删除产品
+    const onRowDel = (row: TableDataRow) => {
+      let msg = '你确定要删除所选数据?';
+      let ids: number[] = [];
+      if (row) {
+        msg = `此操作将永久删除设备:“${row.name}”,是否继续?`;
+        ids = [row.id];
+      } else {
+        ids = state.ids;
+      }
+      if (ids.length === 0) {
+        ElMessage.error('请选择要删除的数据。');
+        return;
+      }
+      ElMessageBox.confirm(msg, '提示', {
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning',
+      })
+        .then(() => {
+          api.instance.del(ids).then(() => {
+            ElMessage.success('删除成功');
+            typeList();
+          });
+        })
+        .catch(() => { });
+    };
+    // 页面加载时
+    onMounted(() => {
+      initTableData();
+    });
+    /** 重置按钮操作 */
+    const resetQuery = (formEl: FormInstance | undefined) => {
+      if (!formEl) return;
+      formEl.resetFields();
+      typeList();
+    };
+    // 多选框选中数据
+    const handleSelectionChange = (selection: TableDataRow[]) => {
+      state.ids = selection.map((item) => item.id);
+    };
+    const onActionStatus = (item: TableDataRow[]) => {
+      if (item.status == 0) {
+        api.instance.devdeploy({ id: item.id }).then((res: any) => {
+          typeList();
+          ElMessage.success(res.message || '操作成功');
+        });
+      } else {
+        api.instance.devundeploy({ id: item.id }).then((res: any) => {
+          typeList();
+          ElMessage.success(res.message || '操作成功');
+        });
+      }
+    }
+    return {
+      addDicRef,
+      editDicRef,
+      detailRef,
+      queryRef,
+      onActionStatus,
+      onOpenDetail,
+      onOpenAddDic,
+      onOpenEditDic,
+      onRowDel,
+      typeList,
+      resetQuery,
+      handleSelectionChange,
+      ...toRefs(state),
+    };
+  },
 });
 </script>

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff