Browse Source

edit:feat> 调试二级树

YaolongHan 4 years ago
parent
commit
38e36ab496
1 changed files with 24 additions and 11 deletions
  1. 24 11
      src/components/editview/leftToolBar/addItemModel.vue

+ 24 - 11
src/components/editview/leftToolBar/addItemModel.vue

@@ -102,7 +102,7 @@
           <div class="top">
             <div class="top-l">
               <span class="equip-title">已选实例</span>
-              <span class="equip-num">341</span>
+              <span class="equip-num">{{ choiceEquipList.length }}</span>
             </div>
             <div class="top-r">清空</div>
           </div>
@@ -120,7 +120,7 @@
                       'el-icon-caret-bottom',
                     ]"
                   ></i>
-                  <span class="equip-title">{{ items.name }}</span>
+                  <span class="equip-title">{{ items.title }}</span>
                   <span class="equip-num">{{ items.number }}</span>
                 </div>
                 <el-collapse-transition>
@@ -130,7 +130,7 @@
                       v-for="(item, key) in items.children"
                       :key="key"
                     >
-                      <div class="item-title">{{ item.name }}</div>
+                      <div class="item-title">{{ item.localName }}</div>
                       <i
                         class="el-icon-error"
                         @click="deleteItem(items, key)"
@@ -174,11 +174,12 @@ export default {
       floorIdString: "", // 楼层id 类型string
       tableTotal: 0, //搜索获取得设备总数
       equiptable: [], //table数据
-      equipData: EquipmentList,
+      equipData: [], //选中得设备数组
       buildFloorList: [], // 建筑查询数据
       categoryList: [], //设备类型
       currentPage2: 5,
       tableHeight: 0, //table的高度
+      choiceEquipList: [], // 选中得设备数组//非树机构
     };
   },
   methods: {
@@ -307,8 +308,19 @@ export default {
     },
     // 删除item
     deleteItem(items, key) {
-      items.children.splice(key, 1);
+      let deleteItem = items.children.splice(key, 1);
       items.number = items.children.length;
+      console.log("deleteItem");
+      let index = -1;
+      this.choiceEquipList.forEach((item, i) => {
+        if (item.id == deleteItem[0].id) {
+          index = i;
+        }
+      });
+      if(index>=0){
+         this.choiceEquipList.splice(key,1)
+      }
+      this.handleSelectionChange(this.choiceEquipList)
     },
     /**
      * 构建树list
@@ -355,24 +367,24 @@ export default {
     // 选中table回调
     handleSelectionChange(list) {
       let arr = [];
+      this.choiceEquipList = list;
       list.forEach((item) => {
         if (arr.length) {
           let index = -1;
           arr.forEach((aItem) => {
             if (aItem.id == item.classCode) {
-                console.log("aItem", aItem);
               index = 1;
-              aitem.children.push(item);
+              aItem.children.push(item);
               aItem.number++;
-              console.log("aItem", aItem);
             }
           });
-          if (!index) {
+          if (index == -1) {
             let obj = {
               id: item.classCode,
               title: item.codeName,
               children: [],
               number: 0,
+              showChildren: true,
             };
             arr.push(obj);
           }
@@ -382,12 +394,12 @@ export default {
             title: item.codeName,
             children: [],
             number: 0,
+            showChildren: true,
           };
           arr.push(obj);
         }
       });
-      console.log("afasdfdsa", arr);
-      // let arr = this.mapList(list, [], ["classCode", "codeName", "children"]);
+      this.equipData = arr;
     },
     currentChangeHandle(pageMsg) {
       console.log(pageMsg);
@@ -452,6 +464,7 @@ li {
   .right {
     width: 420px;
     height: 100%;
+    overflow-y: scroll;
     border-left: 1px solid #eff0f1;
     .top {
       height: 58px;