Browse Source

优化修改位置下拉树

LinWuTai 1 year ago
parent
commit
0c3ff37da5

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/service/impl/TbLocationServiceImpl.java

@@ -93,6 +93,7 @@ public class TbLocationServiceImpl implements ITbLocationService
             TbLocation location = selectTbLocationById(id);
             TreeSelect treeSelect = new TreeSelect();
             treeSelect.setId(location.getId());
+            treeSelect.setNumber(location.getNumber());
             treeSelect.setLabel(location.getName());
             treeSelects.add(treeSelect);
         } else {
@@ -102,6 +103,7 @@ public class TbLocationServiceImpl implements ITbLocationService
             for (TbLocation tbLocation : locations) {
                 TreeSelect treeSelect = new TreeSelect();
                 treeSelect.setId(tbLocation.getId());
+                treeSelect.setNumber(tbLocation.getNumber());
                 treeSelect.setLabel(tbLocation.getName());
                 treeSelects.add(treeSelect);
             }
@@ -122,6 +124,7 @@ public class TbLocationServiceImpl implements ITbLocationService
             for (TbLocation tbLocation : locations) {
                 TreeSelect childrenTreeSelect = new TreeSelect();
                 childrenTreeSelect.setId(tbLocation.getId());
+                childrenTreeSelect.setNumber(tbLocation.getNumber());
                 childrenTreeSelect.setLabel(tbLocation.getName());
                 List<TreeSelect> treeSelectList = buildChildrenSelect(childrenTreeSelect);
                 childrenTreeSelect.setChildren(treeSelectList);

+ 10 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java

@@ -19,6 +19,8 @@ public class TreeSelect implements Serializable
     /** 节点ID */
     private Long id;
 
+    private String number;
+
     /** 节点名称 */
     private String label;
 
@@ -55,6 +57,14 @@ public class TreeSelect implements Serializable
         this.id = id;
     }
 
+    public String getNumber() {
+        return number;
+    }
+
+    public void setNumber(String number) {
+        this.number = number;
+    }
+
     public String getLabel()
     {
         return label;

+ 9 - 2
ruoyi-ui/src/views/inventory/inventory/index.vue

@@ -26,7 +26,7 @@
           />
       </el-form-item>
       <el-form-item label="盘点地点" prop="inventoryLocation">
-        <treeselect v-model="queryParams.inventoryLocation" :options="locationOption" placeholder="选择位置" @keyup.enter.native="handleQuery" />
+        <treeselect v-model="queryParams.inventoryLocation" :options="locationOption" :normalizer="tenantIdnormalizer" placeholder="选择位置" @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item label="盘点人" prop="inventoryBy">
         <el-input
@@ -232,7 +232,7 @@
               :value="item.number"
             ></el-option>
           </el-select> -->
-          <treeselect v-model="form.inventoryLocation" :options="locationOption" placeholder="选择位置" />
+          <treeselect v-model="form.inventoryLocation" :options="locationOption" :normalizer="tenantIdnormalizer" placeholder="选择位置" />
         </el-form-item>
         <el-form-item label="备注" prop="remark">
           <el-input v-model="form.remark" placeholder="请输入备注" />
@@ -350,6 +350,13 @@ export default {
       console.log('获取用户:', info)
       this.form.inventoryBy = info.userName
     },
+    tenantIdnormalizer(node) {
+      return {
+        id: node.number,
+        label: node.label,
+        children: node.children
+      }
+    },
     /** 查询资产盘点记录列表 */
     getList() {
       this.loading = true;