From b2429057ae17e9f5b357435b0bff5f6cc0040b69 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期五, 05 一月 2024 10:09:22 +0800
Subject: [PATCH] 1、分页查询问题修复 2、库管员选择问题修复

---
 admin-web/src/views/foundation/store/person.vue |   97 ++++++++++++++++++++++++++----------------------
 1 files changed, 52 insertions(+), 45 deletions(-)

diff --git a/admin-web/src/views/foundation/store/person.vue b/admin-web/src/views/foundation/store/person.vue
index 92b0ed7..d86ae94 100644
--- a/admin-web/src/views/foundation/store/person.vue
+++ b/admin-web/src/views/foundation/store/person.vue
@@ -8,7 +8,9 @@
             <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(data)">
-                {{ data.name }}
+                <div>{{ data.name }}</div>
+                <i style="font-size: 18px;font-weight: bold;color: #0d997c;margin-right: 10px"
+                   class="el-icon-check"></i>
               </div>
             </template>
           </el-tree>
@@ -28,8 +30,8 @@
       </div>
     </div>
     <div slot="footer" align="center" class="dialog-footer">
-      <my-button name="鍙栨秷" site="form" @click="close" />
-      <my-button name="淇濆瓨" site="form" @click="save" />
+      <my-button name="鍙栨秷" site="form" @click="close"/>
+      <my-button name="淇濆瓨" site="form" @click="save"/>
     </div>
   </win-md>
 </template>
@@ -41,17 +43,18 @@
 
 export default {
   name: 'person',
-  components: { winMd, myButton },
+  components: {winMd, myButton},
   props: {
     setting: {
       type: Object,
-      default: () => {},
+      default: () => {
+      },
     },
   },
   data() {
     return {
-      loading:true,
-      loadingText:'鍔犺浇涓�',
+      loading: true,
+      loadingText: '鍔犺浇涓�',
       selectdSections: [],
       treeData: [],
       formData: {},
@@ -72,47 +75,45 @@
       this.formData = Object.assign({}, JSON.parse(this.setting.info));
     }
     this.init();
-    warehouseManagerList({ warehouseId: this.formData.id }).then((res) => {
-      this.selectdSections = res.map((item) => {
-        item.name = item.managerName;
-        item.id = item.managerId;
-        return item;
-      });
-      this.key = Math.random();
-    this.loading = false
-    });
   },
   methods: {
     async init() {
-      let managerRes = await warehouseManagerList({ warehouseId: this.formData.id });
-      this.managerListStr = JSON.stringify(managerRes);
-      const res = await userSelectDepartment({ agencyId: this.formData.agencyId });
+      let managerRes = await warehouseManagerList({warehouseId: this.formData.id});
+      this.selectdSections = managerRes.map((item) => {
+        item.name = item.managerName;
+        item.id = item.managerId;
+        item.checked = true
+        return item;
+      });
+      const res = await userSelectDepartment({agencyId: this.formData.agencyId});
       this.treeData = this.deepList([res]);
+      this.key = Math.random();
+      this.loading = false
     },
     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;
-          }
+          item.checked = this.selectdSections.some(s=>item.id===s.id)
         }
         return item;
       });
     },
     handleCheckItem(data) {
-      this.selectdSections = [];
+      if (!data.checked) {
+        this.selectdSections.push(data);
+      } else {
+        let idx = this.selectdSections.findIndex(item => item.id === data.id)
+        if (idx !== -1) {
+          this.selectdSections.splice(idx, 1)
+        }
+      }
       this.treeData[0].children.forEach((item, index) => {
         if (item.children) {
           item.children.forEach((child, childIndex) => {
             if (child.id == data.id) {
               this.$set(this.treeData[0].children[index].children[childIndex], 'checked', !child.checked);
-            }
-            if (child.checked) {
-              this.selectdSections.push(child);
             }
           });
         }
@@ -131,6 +132,10 @@
       this.$emit('close');
     },
     save() {
+      if(this.selectdSections.length===0){
+        this.$message.error('璇烽�夋嫨搴撶鍛橈紒');
+        return
+      }
       let params = {
         warehouseId: this.setting.id,
         warehouseManagerInfoList: [],
@@ -141,16 +146,6 @@
           managerName: item.name,
         });
       });
-      // setTimeout(()=>{
-      //   warehouseManagerAdd(params).then((res) => {
-      //     this.$message.success('淇濆瓨鎴愬姛锛�');
-      //     this.close();
-      //     this.$emit('search');
-      //   });
-      //   this.$message.success('淇濆瓨鎴愬姛锛�');
-      //   this.close();
-      //   this.$emit('search');
-      // },6000)
       warehouseManagerAdd(params).then((res) => {
         this.$message.success('淇濆瓨鎴愬姛锛�');
         this.close();
@@ -165,12 +160,14 @@
   height: 400px;
   display: flex;
   justify-content: space-between;
+
   ::v-deep {
     .el-tree-node__expand-icon.is-leaf {
       display: none;
     }
   }
 }
+
 .section-left,
 .section-right {
   width: calc((100% - 20px) / 2);
@@ -181,10 +178,12 @@
   border-radius: 4px;
   overflow-y: auto;
 }
+
 .header-row {
   display: flex;
   align-items: center;
   justify-content: space-between;
+
   .title {
     color: #3d3d3d;
     font-size: 14px;
@@ -192,9 +191,11 @@
     font-weight: 400;
   }
 }
+
 .section-body {
   margin-top: 20px;
 }
+
 .section-right {
   .btn {
     display: inline-block;
@@ -209,11 +210,13 @@
     background: rgba($color: #0d997c, $alpha: 0.1);
     cursor: pointer;
   }
+
   .del-btn {
     color: #f9675b;
     border: 1px solid #f9675b;
     background: rgba($color: #f9675b, $alpha: 0.1);
   }
+
   .section-item {
     width: 44%;
     margin: 0 auto;
@@ -223,20 +226,24 @@
     margin-bottom: 10px;
   }
 }
+
 .leaf-node {
   width: 100%;
   height: 26px;
   line-height: 26px;
   padding-left: 10px;
-  &:hover {
-    background: #f5f7fa;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+
+  i {
+    display: none;
   }
 }
+
 .checked {
-  width: 100%;
-  background: #f5f7fa;
-  height: 26px;
-  line-height: 26px;
-  box-sizing: border-box;
+  i {
+    display: inline-flex;
+  }
 }
 </style>

--
Gitblit v1.9.1