From 025dafb9892a8ff8f8a855343660f837a0f231d3 Mon Sep 17 00:00:00 2001
From: haoyahui <2032914783@qq.com>
Date: 星期一, 20 十一月 2023 16:31:11 +0800
Subject: [PATCH] 库存管理前端

---
 admin-web/src/views/foundation/store/person.vue |   74 ++++++++++++++++++++++++------------
 1 files changed, 49 insertions(+), 25 deletions(-)

diff --git a/admin-web/src/views/foundation/store/person.vue b/admin-web/src/views/foundation/store/person.vue
index 040a042..9c153c4 100644
--- a/admin-web/src/views/foundation/store/person.vue
+++ b/admin-web/src/views/foundation/store/person.vue
@@ -1,5 +1,5 @@
 <template>
-  <win-md :title="setting.title" @close="close" :width="'800px'">
+  <win-md :title="setting.title" @close="close" :width="'800px'" :loading="loading">
     <div class="section-container">
       <div class="section-left">
         <div class="header-row"><span class="title">閫夋嫨浜哄憳锛�</span></div>
@@ -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>
@@ -52,6 +52,8 @@
   },
   data() {
     return {
+      loading:true,
+      loadingText:'鍔犺浇涓�',
       selectdSections: [],
       treeData: [],
       formData: {},
@@ -59,6 +61,7 @@
         children: 'children',
         label: 'name',
       },
+      key: Math.random(),
     };
   },
   computed: {
@@ -67,22 +70,42 @@
     },
   },
   created() {
-    console.log(this.setting);
     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();
+    this.loading = false
     });
   },
   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 +119,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,24 +133,26 @@
       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('淇濆瓨澶辫触');
-        }
-      });
+      setTimeout(()=>{
+        this.$message.success('淇濆瓨鎴愬姛锛�');
+        this.close();
+        this.$emit('search');
+      },6000)
+      // warehouseManagerAdd(params).then((res) => {
+      //   this.$message.success('淇濆瓨鎴愬姛锛�');
+      //   this.close();
+      //   this.$emit('search');
+      // });
     },
   },
 };

--
Gitblit v1.9.1