Bläddra i källkod

wip 完成新增设备model二级树

YaolongHan 4 år sedan
förälder
incheckning
274b30d42e
1 ändrade filer med 78 tillägg och 11 borttagningar
  1. 78 11
      src/components/editview/leftToolBar/addItemModel.vue

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

@@ -53,15 +53,16 @@
             :height="tableHeight"
             @selection-change="handleSelectionChange"
           >
-            <el-table-column type="localName" width="55">
-              <template slot-scope="scope">{{ scope.row }}</template>
-            </el-table-column>
-            <el-table-column label="本地名称" width="300">
+            <el-table-column type="selection" width="55"> </el-table-column>
+            <el-table-column type="localName" label="本地名称" width="300">
               <template slot-scope="scope">{{
-                scope.row.date ? scope.row.date : ""
+                scope.row.localName ? scope.row.localName : "--"
               }}</template>
             </el-table-column>
             <el-table-column prop="localId" label="本地编码" width="300">
+              <template slot-scope="scope">{{
+                scope.row.localId ? scope.row.localId : "--"
+              }}</template>
             </el-table-column>
             <el-table-column
               prop="bimLocation"
@@ -69,6 +70,17 @@
               show-overflow-tooltip
               width="300"
             >
+              <template slot-scope="scope">{{
+                scope.row.building || scope.row.floor
+                  ? scope.row.building && scope.row.floor
+                    ? scope.row.building.localName +
+                      "-" +
+                      scope.row.floor.localName
+                    : scope.row.building
+                    ? scope.row.building.localName
+                    : scope.row.floor.localName
+                  : "--"
+              }}</template>
             </el-table-column>
             <el-table-column
               prop="codeName"
@@ -171,7 +183,7 @@ export default {
   },
   methods: {
     ...mapMutations(["SETEQUIPLIST"]),
-    // 筛选item
+    // 筛选设备
     changeEquip(list) {
       const classCode = []; // 设备类型
       list.forEach((val) => {
@@ -204,11 +216,13 @@ export default {
         this.tableTotal = res.total;
       });
     },
+    // 筛选楼层
     changeFloor(list) {
       let buildIdList = []; // 设备类型
       let floorIdList = [];
       let isfloornull = "";
       let isbuildnull = "";
+      // 遍历获取对应得楼层id、建筑id
       list.forEach((val) => {
         if (val.index == 1) {
           if (val.id == "bisnull") {
@@ -225,14 +239,24 @@ export default {
           }
         }
       });
-
+      // 对id数组和or isnull 进行拼接
+      if (buildIdList.length) {
+        if (isbuildnull) {
+          isbuildnull = "or " + isbuildnull;
+        }
+      }
       this.buildIdString = buildIdList.length
-        ? ";buildingId in " + JSON.stringify(buildIdList) + " " + isbuildnull
+        ? ";buildingId in " + JSON.stringify(buildIdList) + isbuildnull
         : isbuildnull
         ? ";" + isbuildnull
         : "";
+      if (floorIdList.length) {
+        if (isfloornull) {
+          isfloornull = "or " + isfloornull;
+        }
+      }
       this.floorIdString = floorIdList.length
-        ? ";floorId in " + JSON.stringify(floorIdList) + " or " + isfloornull
+        ? ";floorId in " + JSON.stringify(floorIdList) + isfloornull
         : isfloornull
         ? ";" + isfloornull
         : "";
@@ -275,6 +299,7 @@ export default {
       this.SETEQUIPLIST(list);
       this.modalClose();
     },
+    // 搜索回车
     pressEnter() {},
     // /是否下拉折叠
     collapse(item) {
@@ -285,7 +310,13 @@ export default {
       items.children.splice(key, 1);
       items.number = items.children.length;
     },
-    // 构建树list
+    /**
+     * 构建树list
+     * list 需要递归得数组
+     * arr  需要返回得结果
+     * nameList 要递归得判断条件
+     * index 树得层
+     */
     mapList(
       list,
       arr = [],
@@ -321,7 +352,43 @@ export default {
       }
       return arr;
     },
-    handleSelectionChange() {},
+    // 选中table回调
+    handleSelectionChange(list) {
+      let arr = [];
+      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.number++;
+              console.log("aItem", aItem);
+            }
+          });
+          if (!index) {
+            let obj = {
+              id: item.classCode,
+              title: item.codeName,
+              children: [],
+              number: 0,
+            };
+            arr.push(obj);
+          }
+        } else {
+          let obj = {
+            id: item.classCode,
+            title: item.codeName,
+            children: [],
+            number: 0,
+          };
+          arr.push(obj);
+        }
+      });
+      console.log("afasdfdsa", arr);
+      // let arr = this.mapList(list, [], ["classCode", "codeName", "children"]);
+    },
     currentChangeHandle(pageMsg) {
       console.log(pageMsg);
     },