From 2abe52eae99702b41d315410b3c826dc20b47949 Mon Sep 17 00:00:00 2001
From: Z <zhouheqiang@chfatech.com>
Date: Tue, 4 Feb 2020 10:33:44 +0800
Subject: [PATCH] Z: Dot: store's del done.

---
 ybf_admin/src/api/in/store.js            |  5 +-
 ybf_admin/src/pages/in/contact/store.vue | 91 +++++++++++++++++-------
 2 files changed, 67 insertions(+), 29 deletions(-)

diff --git a/ybf_admin/src/api/in/store.js b/ybf_admin/src/api/in/store.js
index d00c4be..2e0e566 100644
--- a/ybf_admin/src/api/in/store.js
+++ b/ybf_admin/src/api/in/store.js
@@ -27,8 +27,9 @@ export function ApiStoreAddStore(inData) {
 
 export function ApiStoreDelStore(inData) {
   return request({
-    url: `/admin/auth/stall/delete?stallId=${inData}`,
-    method: 'delete',
+    url: `/admin/auth/stall/delete`,
+    method: 'post',
+    data: qs.stringify(inData, {arrayFormat: 'repeat'})
   })
 }
 
diff --git a/ybf_admin/src/pages/in/contact/store.vue b/ybf_admin/src/pages/in/contact/store.vue
index aea7b8f..3a74ea4 100644
--- a/ybf_admin/src/pages/in/contact/store.vue
+++ b/ybf_admin/src/pages/in/contact/store.vue
@@ -4,7 +4,7 @@
     <div class="searchs">
       <div class="buttons">
         <el-button class="button buttonlight" size="small" @click="addStore">添加门店</el-button>
-        <el-button class="button buttondark" size="small">批量删除</el-button>
+        <el-button class="button buttondark" size="small" @click="storeDelStoreArr">批量删除</el-button>
       </div>
 
       <!-- 搜索区 -->
@@ -146,7 +146,7 @@
               <el-col :span="24">
                 <el-form-item label="店员:">
                   <el-table class="list" :data="zdata.see.storeManList" tooltip-effect="dark">
-                    <el-table-column type="index" width="50"  align="center"></el-table-column>
+                    <el-table-column type="index" width="50" align="center"></el-table-column>
                     <el-table-column prop="userName" label="门店名称" align="center"></el-table-column>
                     <el-table-column prop="userId" label="门店类型" align="center"></el-table-column>
                     <el-table-column prop="mobile" label="门店类型" align="center"></el-table-column>
@@ -209,6 +209,9 @@ export default {
           ]
         }
       },
+      zlist: {
+        listPick: []
+      },
       page: {
         currentPage: 1,
         size: 20,
@@ -296,7 +299,8 @@ export default {
               name: "测试"
             }
           ]
-        }
+        },
+        listPick: []
       },
       tableHeight: window.innerHeight * 0.5,
       data: {
@@ -336,25 +340,32 @@ export default {
 
       for (let i = 0; i < this.list.man.length; i++) {
         let item = manList[i];
-        if (item.id == inId) {
-          manName = item.userName;
+        if (item != null && item.id != null) {
+          if (item.id == inId) {
+            manName = item.userName;
+          }
         }
       }
       return manName;
     },
-
     transManIdToManName() {
       let mainList = this.list.main;
       let id = "";
       let name = "";
 
       for (let i = 0; i < mainList.length; i++) {
-        id = this.list.main[i].principal;
-        name = this.matchManIdAndManName(id);
-        this.list.main[i].principal = name;
+        if (
+          this.list.main[i].principal &&
+          this.list.main[i].principal != null
+        ) {
+          id = this.list.main[i].principal;
+          name = this.matchManIdAndManName(id);
+          this.list.main[i].principal = name;
+        } else {
+          this.list.main[i].principal = "未知";
+        }
       }
     },
-
     storeGetMainList() {
       // zlog("--->In Get API!");
       let postData = {
@@ -381,32 +392,57 @@ export default {
           this.zdata.see.storeBossName = res.data.principal.userName;
           this.zdata.see.storeDoorId = res.data.adminStall.signNum;
           this.zdata.see.storeAddress = res.data.adminStall.location;
-          this.zdata.see.storeManList = res.data.clerks_unselected
+          this.zdata.see.storeManList = res.data.clerks_unselected;
         })
         .catch(err => {});
 
       this.zcache.status.seeDialog = true;
-
-      // let postData = {
-      //   isDetail: true,
-      //   stallId: inData
-      // };
-
-      // this.msgId = id;
-      // this.detailDialog = true;
-      // this.$refs.storeDetail.detailDialog = true;
-
-      // ApiStoreGetStoreDetail(postData).then(res => {
-      // });
     },
     storeDelStore(inData) {
+      let delArr = [];
+      delArr.push(String(inData));
+
+      let postData = {
+        stallIds: delArr
+      };
+      
+      ApiStoreDelStore(postData)
+        .then(res => {
+          if (res.result == "success") {
+            this.$message({
+              message: "删除成功",
+              type: "success"
+            });
+            this.storeGetMainList();
+          } else {
+            this.$message({
+              message: "删除失败!",
+              type: "error"
+            });
+          }
+        })
+        .catch(err => {
+          this.$message({
+            message: "删除失败!",
+            type: "error"
+          });
+        });
+    },
+    listPick(inData) {
+      this.zlist.listPick = inData;
+    },
+    storeDelStoreArr() {
+      let delArr = this.zlist.listPick;
+      let delIdsArr = [];
+      for (let i = 0; i < delArr.length; i++) {
+        delIdsArr.push(String(delArr[i].id));
+      }
       let postData = {
-        stallId: 123456
+        stallIds: delIdsArr
       };
 
-      ApiStoreDelStore(inData)
+      ApiStoreDelStore(postData)
         .then(res => {
-          console.log("--->delRes =", res);
           if (res.result == "success") {
             this.$message({
               message: "删除成功",
@@ -428,7 +464,8 @@ export default {
         });
     },
 
-    listPick() {},
+
+
     testButtonClick() {},
     pagesSizeChange() {},
     pagesNowPageChange() {},
-- 
2.18.1