Browse Source

Merge branch 'feature_20241219_提示类-色卡开放大区及以上级别权限'

zhujindu 11 months ago
parent
commit
fac7d0e6be

+ 6 - 3
src/api/index.js

@@ -859,11 +859,12 @@ export function approvalStore(data) {
 }
 
 // 各部门未拜访门店数量
-export function selectNoVisitsInfo(query) {
+export function selectNoVisitsInfo(query, signal) {
   return request({
     url: '/mobile/storeStatistics/selectNoVisitsInfo',
     method: 'get',
     params: query,
+    signal: signal,
   });
 }
 
@@ -877,11 +878,12 @@ export function getReportMaterial(query) {
 }
 
 // 提示类页签-查询下属业务员色卡指标接口
-export function getReportMaterialType(data) {
+export function getReportMaterialType(data, signal) {
   return request({
     url: '/mobile/reportMobile/getReportMaterialType',
     method: 'post',
     data: data,
+    signal: signal,
   });
 }
 
@@ -940,11 +942,12 @@ export function selectUserStoreNoVisits(data) {
 }
 
 // 提示类建店详情接口
-export function selectPendingCasesInfo(query) {
+export function selectPendingCasesInfo(query, signal) {
   return request({
     url: '/mobile/storeStatistics/selectPendingCasesInfo',
     method: 'get',
     params: query,
+    signal: signal,
   });
 }
 

+ 5 - 1
src/utils/request.js

@@ -60,7 +60,11 @@ service.interceptors.response.use(
     } else if (message.includes('Request failed with status code')) {
       message = '系统接口' + message.substr(message.length - 3) + '异常';
     }
-    Toast(message);
+    if (error.message === 'canceled') {
+      console.log('请求被取消:', error.message);
+    } else {
+      Toast(message);
+    }
     return Promise.reject(error);
   }
 );

+ 31 - 21
src/views/home/hintTabPage/hintDetail.vue

@@ -246,6 +246,7 @@ export default {
       ],
       materialCode: null, //色卡物料来源
       maskShow: true,
+      controller: null, //取消请求
     };
   },
   watch: {
@@ -272,11 +273,16 @@ export default {
     this.deptId = this.userInfo.deptId; // 当前用户部门id
     this.activaPantoneName = this.$route.query.pantoneName; //当前色卡
     this.materialCode = this.$route.query.materialCode; // 色卡code
+    this.controller = new AbortController(); //取消请求
     this.initData();
   },
   methods: {
     rowKey(row) {
-      return this.fromType == 'pantone' ? row['id'] : row['onlyId'];
+      if (this.fromType == 'noVisit' || this.fromType == 'createStore') {
+        return row['onlyId'];
+      } else if (this.fromType == 'pantone') {
+        return row['warehouseCode'];
+      }
     },
     setTabsItem() {
       this.tabsItem = [
@@ -289,8 +295,8 @@ export default {
           name: 'createStore',
         },
       ];
-      // 2销售部主管显示色卡
-      if (this.userInfo.empLevel == '2') {
+      // 业务员不显示色卡
+      if (this.userInfo.empLevel != '3') {
         this.tabsItem.push({
           title: '色卡',
           name: 'pantone',
@@ -306,8 +312,8 @@ export default {
       // 请求子级数据时不需要loading
       if (!resolve && !tree) {
         this.toggleIndex = this.toggleIndex++;
-        this.maskShow = true;
       }
+      this.maskShow = true;
       if (this.fromType == 'noVisit') {
         // 未拜访
         this.deptId = tree ? tree.onlyId : this.userInfo.deptId;
@@ -321,14 +327,18 @@ export default {
       } else if (this.fromType == 'pantone') {
         // 色卡
         this.firstProp = 'warehouseName';
-        let empLevel = tree ? tree.empLevel : null;
-        this.getPantoneData(resolve, empLevel);
+        let deptId = tree ? tree.deptId : null;
+        this.getPantoneData(resolve, deptId);
       }
     },
     tabChange(val) {
       this.tableList = []; // 清楚tab数
       this.tabsItemPantone = {}; // 清楚色卡tab数据
       this.fromType = val;
+      if (this.controller) {
+        this.controller.abort();
+      }
+      this.controller = new AbortController(); //取消请求
       this.initData();
     },
     tabChangePantone(val) {
@@ -346,7 +356,8 @@ export default {
     },
     // 未拜访
     selectNoVisitsInfoFun(resolve) {
-      selectNoVisitsInfo({ deptId: this.deptId }).then((res) => {
+      selectNoVisitsInfo({ deptId: this.deptId }, this.controller.signal).then((res) => {
+        this.maskShow = false;
         if (res.code == 200) {
           res.data.forEach((val) => {
             if (val.empLevel < 3) val.hasChildren = true;
@@ -355,11 +366,9 @@ export default {
           if (resolve) {
             resolve && resolve(res.data);
           } else {
-            this.maskShow = false;
             this.tableList = res.data;
           }
         } else {
-          this.maskShow = false;
           this.Toast({
             message: res.msg,
             duration: 5000,
@@ -369,20 +378,20 @@ export default {
     },
     // 建店
     selectPendingCasesInfoFun(resolve) {
-      selectPendingCasesInfo({ deptId: this.deptId }).then((res) => {
+      selectPendingCasesInfo({ deptId: this.deptId }, this.controller.signal).then((res) => {
+        this.maskShow = false;
         if (res.code == 200) {
           res.data.forEach((val) => {
+            // 是否还有子级
             if (val.empLevel < 3) val.hasChildren = true;
           });
           // 是否是子级
           if (resolve) {
             resolve && resolve(res.data);
           } else {
-            this.maskShow = false;
             this.tableList = res.data;
           }
         } else {
-          this.maskShow = false;
           this.Toast({
             message: res.msg,
             duration: 5000,
@@ -391,10 +400,9 @@ export default {
       });
     },
     // 色卡tab
-    getPantoneData(resolve, empLevel) {
+    getPantoneData(resolve, deptId) {
       if (JSON.stringify(this.tabsItemPantone) != '{}') {
-        // this.tabsItemPantone != {} 不是初次获取tab数据不需要在赋值
-        this.getReportMaterialTypeFun(resolve, empLevel);
+        this.getReportMaterialTypeFun(resolve, deptId);
       } else {
         getReportMaterial().then((res) => {
           this.tabsItemPantone = res.data;
@@ -410,22 +418,24 @@ export default {
       }
     },
     // 色卡详情
-    getReportMaterialTypeFun(resolve, empLevel) {
-      // empLevel 第一次传 null
-      getReportMaterialType({ materialCode: this.materialCode, empLevel: empLevel }).then((res) => {
+    getReportMaterialTypeFun(resolve, deptId) {
+      // deptId 第一次传 null 获取当前等级下的数据(不需要当前层级)
+      getReportMaterialType(
+        { materialCode: this.materialCode, deptId: deptId },
+        this.controller.signal
+      ).then((res) => {
+        this.maskShow = false;
         if (res.code == 200) {
           res.data.colorCardList.forEach((val) => {
-            if (val.empLevel < 3) val.hasChildren = true;
+            if (val.isChildren && val.isChildren == 'true') val.hasChildren = true;
           });
           // 是否是子级
           if (resolve) {
             resolve && resolve(res.data.colorCardList);
           } else {
-            this.maskShow = false;
             this.tableList = res.data.colorCardList;
           }
         } else {
-          this.maskShow = false;
           this.Toast({
             message: res.msg,
             duration: 5000,

+ 7 - 7
src/views/home/hintTabPage/index.vue

@@ -111,8 +111,8 @@
             </div>
           </div>
         </van-collapse-item>
-        <!-- 色卡 销售员和销售部主管显示-->
-        <van-collapse-item name="4" v-if="empLevel == '2' || empLevel == '3'">
+        <!-- 色卡 -->
+        <van-collapse-item name="4">
           <template #title>
             <div class="itemHeader" @click.stop>
               <span class="itemTitle">{{ pantone.title }}</span>
@@ -156,7 +156,7 @@
                 </div>
               </div>
             </template>
-            <template v-if="empLevel == '2'">
+            <template v-else>
               <div v-for="(val, key, index) in pantone.pantoneData" :key="index">
                 <div class="title">{{ key }}</div>
                 <div class="pantoneItem">
@@ -487,7 +487,7 @@ export default {
       });
     },
     getPantoneData() {
-      if (this.empLevel == 2 || this.empLevel == 3) {
+      if (this.empLevel !== 4) {
         this.pantone.pantoneLosding = true;
         getReportMaterial().then((res) => {
           this.pantone.pantoneLosding = false;
@@ -522,14 +522,14 @@ export default {
         systemModel: '提示类',
         buryingPointType: 7,
         buryingPointValue: value,
-        buryingPointName: key + '-门店未签收:',
+        buryingPointName: key + '门店未签收:',
         buryingPointPosition: '色卡',
       });
       // 业务员进入未拜访列表
       if (this.empLevel == '3') {
         this.$router.push({ path: '/pantoneNoGet', query: { storeId: val.storeId } });
-      } else if (this.empLevel == '2') {
-        // 销售部主管
+      } else {
+        // 销售部,大区,公司,总部
         this.$router.push({
           path: '/hintDetail',
           query: { fromType: 'pantone', materialCode: val.materialCode, pantoneName: key }, // materialCode物料来源

+ 1 - 1
src/views/home/hintTabPage/noVisit.vue

@@ -11,7 +11,7 @@
             <div class="num">{{ val.storeNum }}家</div>
           </template>
           <div class="itemContent">
-            <template v-if="val.storeList.length">
+            <template v-if="val.storeList && val.storeList.length">
               <div class="item" v-for="(item, index) in val.storeList" :key="index">
                 <div class="itemLeft">
                   <div class="storeName">{{ item.storeName }}</div>