Przeglądaj źródła

优化了些设备类型的页面

linan 5 lat temu
rodzic
commit
a29980cf26

+ 1 - 1
src/store/index.js

@@ -7,7 +7,7 @@ Vue.use(Vuex)
 export default new Vuex.Store({
 	strict: true,
 	state: {
-		token: localStorage.getItem("token"),
+		token: localStorage.getItem("token")
 	},
 	getters: {
 		token: state => state.token,

+ 1 - 1
src/views/Home/Home.vue

@@ -109,7 +109,7 @@ export default {
         ];
         this.menuCollapse = JSON.parse(localStorage.getItem("menuCollapse"));
     },
-    mounted() {},
+    mounted() {console.log(this)},
     methods: {
         // 收取菜单按钮
         onMenuCollapse() {

+ 30 - 16
src/views/deviceManagement/DeviceInfo.vue

@@ -29,12 +29,12 @@
                 </el-input>
             </el-col>
             <el-col :span="8">
-                <el-button @click="handleNewBtn" type="primary" icon="el-icon-document-add">新建</el-button>
+                <el-button @click="add" type="primary" icon="el-icon-document-add">新建</el-button>
             </el-col>
         </el-row>
         <el-row>
             <el-table :data="deviceList">
-                <el-table-column prop="id" label="#" width="120px"></el-table-column>
+                <el-table-column prop="id" label="序号" width="120px"></el-table-column>
                 <el-table-column prop="name" label="名称"></el-table-column>
                 <el-table-column prop="deviceNo" label="MAC/SN"></el-table-column>
                 <el-table-column prop="sVer" label="软件版本"></el-table-column>
@@ -54,9 +54,8 @@
                             type="text"
                             v-if="isCamera(scope.row.hardTypeId)"
                         >播放</el-button>
-                        <el-button @click="handleEdit(scope.row)" type="text" size="small">编辑</el-button>
-                        <!-- <el-button @click="handleDel(scope.row)" type="text" size="small">删除</el-button> -->
-                        <el-popconfirm title="是否删除此设备的信息?" @onConfirm="handleDel(scope.row)">
+                        <el-button @click="edit(scope.row)" type="text" size="small">编辑</el-button>
+                        <el-popconfirm title="是否删除此设备的信息?" @onConfirm="del(scope.row)">
                             <el-button slot="reference" type="text" size="small">删除</el-button>
                         </el-popconfirm>
                         <el-button @click="subDeviceAdmin(scope.row)" type="text" size="small">子设备管理</el-button>
@@ -64,8 +63,9 @@
                 </el-table-column>
             </el-table>
         </el-row>
+
         <!-- 设备信息新建、编辑 -->
-        <el-dialog title="新建/编辑设备信息" :visible.sync="isShowDialog" append-to-body>
+        <el-dialog :title="isAdd?'新建设备信息':'编辑设备信息'" :visible.sync="isShowDialog" append-to-body>
             <el-form :model="formData" label-width="100px">
                 <el-form-item label="名称:">
                     <el-input v-model="formData.name" placeholder="请输入名称"></el-input>
@@ -112,7 +112,7 @@
             </el-form>
             <div slot="footer">
                 <el-button @click="isShowDialog=false">取 消</el-button>
-                <el-button type="primary" @click="handleSave">保 存</el-button>
+                <el-button type="primary" @click="save">保 存</el-button>
             </div>
         </el-dialog>
         <!-- 摄像头播放 -->
@@ -142,7 +142,6 @@ export default {
                 keywords: ""
             },
             formData: {
-                orgId: 1,
                 name: "",
                 hardTypeId: null,
                 deviceNo: "",
@@ -154,7 +153,8 @@ export default {
                 title: null,
                 rtsp: null,
                 ws: null
-            }
+            },
+            isAdd: true
         };
     },
     created() {
@@ -196,7 +196,16 @@ export default {
             //获取下一级列表
             this.loadTypeList(item);
         },
-        handleNewBtn() {
+        add() {
+            this.isAdd = true
+            this.formData = {
+                orgId: 1,
+                name: "",
+                hardTypeId: null,
+                deviceNo: "",
+                description: "",
+                meta: ""
+            }
             if (this.formData.id) delete this.formData.id;
             this.isShowDialog = true;
         },
@@ -245,12 +254,19 @@ export default {
             this.isShowVideo = true;
         },
         // 编辑
-        handleEdit(row) {
+        edit(row) {
             console.log(row);
+            this.isAdd = false
             // 判断是为了重复点击不会重复格式化
             if(typeof row.meta == "object"){
                 row.meta = JSON.stringify(row.meta, null, 4);
             }
+                // orgId: 1,
+                // name: "",
+                // hardTypeId: null,
+                // deviceNo: "",
+                // description: "",
+                // meta: ""
             
             if (this.formData.id) {
                 delete this.formData.id;
@@ -264,9 +280,8 @@ export default {
             this.isShowDialog = true;
         },
         // 删除
-        handleDel(row) {
+        del(row) {
             console.log(row);
-            this.isShowVideo = true;
         },
         // 子设备管理
         subDeviceAdmin(row) {
@@ -276,12 +291,11 @@ export default {
             });
         },
         // 编辑的保存按钮
-        handleSave() {
-            let isNew = this.formData.id ? false : true;
+        save() {
             this.formData.hardTypeId = this.selectArr[
                 this.selectArr.length - 1
             ];
-            let api = isNew
+            let api = this.isAdd
                 ? "/device/device-communication/add"
                 : "/device/device/device-communication/update";
             this.formData.meta = JSON.parse(this.formData.meta);

+ 1 - 1
src/views/template/Af.vue

@@ -30,7 +30,7 @@ export default {
                     else this.$message.error("服务器发生异常");
                 }
             });
-        }
+        },
     }
 };
 </script>