Ver código fonte

传感器模型左侧列表当前项展示优化

zhangliang2 3 anos atrás
pai
commit
f9d7c60467

+ 2 - 2
src/views/modelLibrary/components/formCamera.vue

@@ -227,7 +227,7 @@ export default {
                     this.$refs.form.clearValidate();
                     this.form = res.info;
                     // 传回当前展示form的share,从而改变按钮的展示
-                    this.$emit("changeShare", this.form.share);
+                    this.$emit("changeShare", this.form);
                     // 数据加载完毕,可展示canvas
                     this.$emit("showDone");
                 } else {
@@ -255,7 +255,7 @@ export default {
                             this.form.share = res.info.share;
                             this.$message.success("保存成功");
                             // this.$parent.$refs.modelList.getList();
-                            this.$emit("changeShare", this.form.share);
+                            this.$emit("changeShare", this.form);
                             this.$emit("getList");
                         } else {
                             this.$message.error(res.message || "保存失败");

+ 2 - 2
src/views/modelLibrary/components/formGps.vue

@@ -165,7 +165,7 @@ export default {
                     this.$refs.form.clearValidate();
                     this.form = res.info;
                     // 传回当前展示form的share,从而改变按钮的展示
-                    this.$emit("changeShare", this.form.share);
+                    this.$emit("changeShare", this.form);
                 } else {
                     this.$message.error(res.message || "获取失败");
                 }
@@ -190,7 +190,7 @@ export default {
                             this.form.id = res.info.id;
                             this.form.share = res.info.share;
                             this.$message.success("保存成功");
-                            this.$emit("changeShare", this.form.share);
+                            this.$emit("changeShare", this.form);
                             this.$emit("getList");
                         } else {
                             this.$message.error(res.message || "保存失败");

+ 2 - 2
src/views/modelLibrary/components/formLaserRadar.vue

@@ -276,7 +276,7 @@ export default {
                     this.$refs.form.clearValidate();
                     this.form = res.info;
                     // 传回当前展示form的share,从而改变按钮的展示
-                    this.$emit("changeShare", this.form.share);
+                    this.$emit("changeShare", this.form);
                     // 数据加载完毕,可展示canvas
                     this.$emit("showDone");
                 } else {
@@ -303,7 +303,7 @@ export default {
                             this.form.id = res.info.id;
                             this.form.share = res.info.share;
                             this.$message.success("保存成功");
-                            this.$emit("changeShare", this.form.share);
+                            this.$emit("changeShare", this.form);
                             this.$emit("getList");
                         } else {
                             this.$message.error(res.message || "保存失败");

+ 2 - 2
src/views/modelLibrary/components/formPerfectSensor.vue

@@ -318,7 +318,7 @@ export default {
                     this.form = res.info;
                     this.form.targetFilter = res.info.targetFilter.split(",");
                     // 传回当前展示form的share,从而改变按钮的展示
-                    this.$emit("changeShare", this.form.share);
+                    this.$emit("changeShare", this.form);
                     // 数据加载完毕,可展示canvas
                     this.$emit("showDone");
                 } else {
@@ -348,7 +348,7 @@ export default {
                             this.form.id = res.info.id;
                             this.form.share = res.info.share;
                             this.$message.success("保存成功");
-                            this.$emit("changeShare", this.form.share);
+                            this.$emit("changeShare", this.form);
                             this.$emit("getList");
                         } else {
                             this.$message.error(res.message || "保存失败");

+ 25 - 2
src/views/modelLibrary/components/modelList.vue

@@ -23,7 +23,13 @@
             <div class="title">公有</div>
             <ul class="list listPub">
                 <li v-for="item in listPub" :key="item.id">
-                    <span @click="showInfo(item.id)">
+                    <span
+                        @click="showInfo(item.id)"
+                        v-bind:class="{
+                            isCur:
+                                curOne.share === '1' && curOne.id === item.id,
+                        }"
+                    >
                         {{ item[showName] }}
                     </span>
                 </li>
@@ -31,7 +37,13 @@
             <div class="title">私有</div>
             <ul class="list listPri">
                 <li v-for="item in listPri" :key="item.id">
-                    <span @click="showInfo(item.id)">
+                    <span
+                        @click="showInfo(item.id)"
+                        v-bind:class="{
+                            isCur:
+                                curOne.share === '0' && curOne.id === item.id,
+                        }"
+                    >
                         {{ item[showName] }}
                     </span>
                     <i class="el-icon-delete" @click="delOne(item.id)"></i>
@@ -65,6 +77,13 @@ export default {
             type: String,
             default: "",
         },
+        curOne: {
+            default: {
+                share: "",
+                id: "",
+            },
+            type: Object,
+        },
     },
 
     methods: {
@@ -170,6 +189,10 @@ export default {
                 i {
                     cursor: pointer;
                 }
+
+                .isCur {
+                    color: @themeColor;
+                }
             }
         }
 

+ 33 - 2
src/views/modelLibrary/sensorModel.vue

@@ -8,6 +8,7 @@
             @showInfo="showInfo"
             @addOne="addOne"
             @delOne="delOne"
+            :curOne="curOne"
         ></model-list>
         <div class="contentPanel">
             <toolbarTab
@@ -131,6 +132,11 @@ export default {
             currentShare: "",
             coordinate: { r: 0, h: 0, n: 0 }, // 存放传递给canvas的值
             coordinateA: { r: 0, n: 0, hl: 0, hr: 0 }, // 存放传递给完美传感器canvas的值
+            // 用于当前选中项的展示
+            curOne: {
+                share: "",
+                id: "",
+            },
         };
     },
 
@@ -186,11 +192,18 @@ export default {
             this.addOne();
             this.getListApi = item.api;
             this.subPageActiveName = item.fromId;
+
             this.$nextTick(() => {
                 this.getList();
             });
+
             this.$refs.canvasSensor.clear();
             this.$refs.canvasSensorA.clear();
+
+            this.curOne = {
+                share: "",
+                id: "",
+            };
         },
         showInfo(id) {
             this.$refs[`form${this.subPageActiveName}`].showInfo(id);
@@ -209,9 +222,15 @@ export default {
             this.$refs.canvasSensor.clear();
             this.$refs.canvasSensorA.clear();
         },
-        changeShare(share) {
+        changeShare(form) {
             // 根据form传回的share进行按钮展示
-            this.currentShare = share;
+            this.currentShare = form.share;
+
+            // 确定当前展示哪条数据
+            this.curOne = {
+                share: form.share,
+                id: form.id,
+            };
         },
         showDone() {
             this.$refs[`form${this.subPageActiveName}`].inputChange();
@@ -220,12 +239,19 @@ export default {
             this.$refs[
                 `form${this.subPageActiveName}`
             ].$refs.form.resetFields();
+
             this.$refs[`form${this.subPageActiveName}`].form.sensorCode = "";
             this.$refs[`form${this.subPageActiveName}`].form.share = "";
             this.$refs[`form${this.subPageActiveName}`].form.id = "";
+
             this.currentShare = "";
             this.$refs.canvasSensor.clear();
             this.$refs.canvasSensorA.clear();
+
+            this.curOne = {
+                share: "",
+                id: "",
+            };
         },
         delOne(id) {
             const delApis = [
@@ -251,6 +277,11 @@ export default {
                     ) {
                         this.addOne();
                     }
+
+                    this.curOne = {
+                        share: "",
+                        id: "",
+                    };
                 } else {
                     this.$message.error(res.message || "删除失败");
                 }