From 5e10fe06e80c7d146cbb5eb8f7b3e1e447a80b88 Mon Sep 17 00:00:00 2001
From: haoyahui <2032914783@qq.com>
Date: 星期五, 17 十一月 2023 17:07:53 +0800
Subject: [PATCH] 部门物品:物品分发,物品报废静态。调拨管理联调,price由元改为分,仓库管理库管员

---
 admin-web/src/views/foundation/store/person.vue |   62 +++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/admin-web/src/views/foundation/store/person.vue b/admin-web/src/views/foundation/store/person.vue
index 040a042..1a4e5dc 100644
--- a/admin-web/src/views/foundation/store/person.vue
+++ b/admin-web/src/views/foundation/store/person.vue
@@ -7,7 +7,7 @@
           <el-tree ref="tree" :data="treeData" node-key="id" :props="defaultProps" default-expand-all>
             <template slot-scope="{ node, data }">
               <div v-if="data.type != 'user'">{{ data.name }}</div>
-              <div v-else class="leaf-node" :class="data.checked ? 'checked' : ''" @click="handleCheckItem(node, data)">
+              <div v-else class="leaf-node" :class="data.checked ? 'checked' : ''" @click="handleCheckItem(data)">
                 {{ data.name }}
               </div>
             </template>
@@ -59,10 +59,15 @@
         children: 'children',
         label: 'name',
       },
+      key: Math.random(),
     };
   },
   computed: {
     checkedKeys() {
+      console.log(
+        1111,
+        this.selectdSections.map((v) => v.id),
+      );
       return this.selectdSections.map((v) => v.id);
     },
   },
@@ -71,18 +76,38 @@
     if (this.setting.info) {
       this.formData = Object.assign({}, JSON.parse(this.setting.info));
     }
-    this.initTree();
+    this.init();
     warehouseManagerList({ warehouseId: this.formData.id }).then((res) => {
-      console.log(res);
+      this.selectdSections = res.map((item) => {
+        item.name = item.managerName;
+        item.id = item.managerId;
+        return item;
+      });
+      this.key = Math.random();
     });
   },
   methods: {
-    initTree() {
-      userSelectDepartment({ agencyId: this.formData.agencyId }).then((res) => {
-        this.treeData = [res];
+    async init() {
+      let managerRes = await warehouseManagerList({ warehouseId: this.formData.id });
+      this.managerListStr = JSON.stringify(managerRes);
+      const res = await userSelectDepartment({ agencyId: this.formData.agencyId });
+      this.treeData = this.deepList([res]);
+    },
+    deepList(list) {
+      return list.map((item) => {
+        if (item.children && item.children.length) {
+          this.deepList(item.children);
+        } else {
+          if (this.managerListStr.includes(item.id)) {
+            item.checked = true;
+          } else {
+            item.checked = false;
+          }
+        }
+        return item;
       });
     },
-    handleCheckItem(node, data) {
+    handleCheckItem(data) {
       this.selectdSections = [];
       this.treeData[0].children.forEach((item, index) => {
         if (item.children) {
@@ -96,14 +121,13 @@
           });
         }
       });
-      console.log(this.treeData);
     },
     handleDel(item) {
-      this.handleCheckItem({}, item);
+      this.handleCheckItem(item);
     },
     handleClear() {
       this.selectdSections.forEach((item) => {
-        this.handleCheckItem({}, item);
+        this.handleCheckItem(item);
       });
       this.selectdSections = [];
     },
@@ -111,23 +135,21 @@
       this.$emit('close');
     },
     save() {
-      let params = [];
+      let params = {
+        warehouseId: this.setting.id,
+        warehouseManagerInfoList: [],
+      };
       this.selectdSections.forEach((item) => {
-        params.push({
+        params.warehouseManagerInfoList.push({
           managerId: item.id,
           managerName: item.name,
-          baseWarehouseId: this.setting.id,
         });
       });
       debugger;
       warehouseManagerAdd(params).then((res) => {
-        if (res) {
-          this.$message.success('淇濆瓨鎴愬姛锛�');
-          this.close();
-          this.$emit('search');
-        } else {
-          this.$message.error('淇濆瓨澶辫触');
-        }
+        this.$message.success('淇濆瓨鎴愬姛锛�');
+        this.close();
+        this.$emit('search');
       });
     },
   },

--
Gitblit v1.9.1