Kaynağa Gözat

门店拜访任务列表访问速度优化

zhujindu 5 ay önce
ebeveyn
işleme
5163d58854

+ 16 - 0
src/api/agentList.js

@@ -24,6 +24,22 @@ export function getChainsGroupTask(data) {
     data,
   });
 }
+// 通过经销商ID获取对应经销商任务组信息
+export function getVisitTasks(data) {
+  return request({
+    url: '/mobile/chainsGroup/getVisitTasks',
+    method: 'post',
+    data,
+  });
+}
+// 门店拜访获取采集项信息接口
+export function getCollectionInfos(data) {
+  return request({
+    url: '/mobile/chainsGroup/getCollectionInfos',
+    method: 'post',
+    data,
+  });
+}
 
 export function checkChainsAddressByChainCode(query) {
   return request({

+ 2 - 0
src/router/index.js

@@ -61,6 +61,7 @@ const router = new VueRouter({
           component: () => import('@/views/agentList/visitPage.vue'),
           meta: {
             title: '拜访详情',
+            keepAlive: true,
           },
         },
         {
@@ -69,6 +70,7 @@ const router = new VueRouter({
           component: () => import('@/views/agentList/visitTask.vue'),
           meta: {
             title: '拜访任务',
+            keepAlive: true,
           },
         },
         {

+ 1 - 0
src/store/modules/user.js

@@ -40,6 +40,7 @@ const user = {
             localStorage.setItem('userId', res.data.userId);
             localStorage.setItem('deptIds', JSON.stringify(res.data.deptIds));
             localStorage.setItem('chainUser', res.data.chainUser); //是否经销商用户 true
+            localStorage.setItem('getRequestFlage', 'true');
             // 经销商类型
             getDictOption({}, 'sfa_chains_type').then((res) => {
               commit('SET_CHAINS_TYPE', res.data);

+ 31 - 7
src/views/agentList/visitPage.vue

@@ -92,7 +92,13 @@
 </template>
 
 <script>
-import { getChainsGroupTask, endVisits, stopVisit, editDwellTime } from '@/api/agentList';
+import {
+  getChainsGroupTask,
+  endVisits,
+  stopVisit,
+  editDwellTime,
+  getVisitTasks,
+} from '@/api/agentList';
 import store from '@/store';
 export default {
   name: 'visitPage',
@@ -143,7 +149,12 @@ export default {
       timeN: null,
     };
   },
-  created() {
+  created() {},
+  mounted() {},
+  activated() {
+    // 是否请求任务列表接口
+    let getRequestFlage = localStorage.getItem('getRequestFlage');
+    if (getRequestFlage != 'true') return;
     this.urlParameter = this.$route.query;
     this.chainId = this.$route.query.chainId + '';
     this.visitId = this.$route.query.visitId || localStorage.getItem('visitId');
@@ -157,9 +168,16 @@ export default {
     this.lon = this.$route.query.lon + '';
     this.visitModel = this.$route.query.visitModel + '';
     this.uType = localStorage.getItem('uType');
-  },
-  mounted() {
-    this.addVisits();
+    if (localStorage.getItem('visitId') != null) {
+      this.visitId = localStorage.getItem('visitId');
+      setTimeout(() => {
+        this.addVisits();
+      });
+    } else {
+      setTimeout(() => {
+        this.addVisits();
+      });
+    }
   },
   methods: {
     animation() {
@@ -314,7 +332,7 @@ export default {
             message: '加载中...',
             forbidClick: true,
           });
-          getChainsGroupTask(params).then((res) => {
+          getVisitTasks(params).then((res) => {
             loading2.clear();
             if (res.code == 200) {
               localStorage.setItem('visitId', res.data.visitId);
@@ -357,7 +375,7 @@ export default {
             message: '加载中...',
             forbidClick: true,
           });
-          getChainsGroupTask(params).then((res) => {
+          getVisitTasks(params).then((res) => {
             loading2.clear();
             if (res.code == 200) {
               localStorage.setItem('visitId', res.data.visitId);
@@ -377,6 +395,7 @@ export default {
       );
     },
     visitTask(val, index) {
+      localStorage.setItem('getRequestFlage', 'false');
       this.$router.push({
         path: '/visitTask',
         query: {
@@ -396,10 +415,15 @@ export default {
           locationRemark: this.address,
           locationAccuracy: this.locationAccuracy,
           photoIdentifyType: val.photoIdentifyType,
+          inspectionType: val.inspectionType,
+          deviceCode: val.deviceCode,
+          putInCode: val.putInCode,
+          equipmentCode: val.equipmentCode,
         },
       });
     },
     onClickLeft() {
+      localStorage.setItem('getRequestFlage', 'true');
       if (this.$route.query.urltype == 1) {
         window.location.replace(window.location.origin + '/mobile/home');
       } else {

+ 59 - 50
src/views/agentList/visitTask.vue

@@ -2754,7 +2754,7 @@ import jianjie from '@/assets/icon/jianjie.jpg';
 import { ImagePreview } from 'vant';
 import taskTips from '@/components/taskTips';
 import store from '@/store';
-import { getChainsGroupTask } from '@/api/agentList';
+import { getChainsGroupTask, getCollectionInfos } from '@/api/agentList';
 export default {
   name: 'visitTask',
   components: { zRadio, zCheckbox, uploadImg, storeCode, deleteUploadImg, taskTips },
@@ -2842,6 +2842,8 @@ export default {
       examplePhotoImg: '', //示例-操作说明图标地址
       photoIdentifyType: null, //图片识别类型
       pictureSource: '0',
+      inspectionType: '',
+      competitortableData: [],
     };
   },
   watch: {
@@ -2852,7 +2854,7 @@ export default {
       }
     },
   },
-  created() {
+  activated() {
     this.flag = false;
     this.link = '3';
     this.wuliaoMust = true;
@@ -2862,9 +2864,13 @@ export default {
     this.visitId = this.$route.query.visitId + '';
     this.taskId = this.$route.query.taskId + '';
     this.chainId = this.$route.query.chainId + '';
-    this.isMust == this.$route.query.isMust + '';
+    this.isMust = this.$route.query.isMust + '';
     this.photoIdentifyType = this.$route.query.photoIdentifyType;
+    this.inspectionType = this.$route.query.inspectionType;
     this.storeGroupId = this.$route.query.storeGroupId + '';
+    this.deviceCode = this.$route.query.deviceCode;
+    this.putInCode = this.$route.query.putInCode;
+    this.equipmentCode = this.$route.query.equipmentCode;
     if (this.$route.query.photoType != null) {
       this.indexselect = 0;
     } else {
@@ -3189,6 +3195,7 @@ export default {
             taskId: that.$route.query.taskId,
           }).then((res) => {
             if (res.code == 200) {
+              localStorage.setItem('getRequestFlage', 'true');
               that.$dialog
                 .alert({
                   title: '系统提示',
@@ -3273,77 +3280,78 @@ export default {
         insert = true;
       }
       this.insert = insert;
+      let params = {
+        chainCode: this.$route.query.chainCode, //	string	门店编码
+        insert: insert, //	boolean	是否为拜访时进入,true-拜访时进入,false-编辑时进入
+        id: '', //	Long	拜访id
+        taskId: this.$route.query.taskId, //	Long	任务id
+      };
       if (this.$route.query.type == 'edit') {
-        var params = {
-          chainId: this.$route.query.chainId,
-          chainCode: this.$route.query.chainCode,
-          visitEntry: '0',
-          lat: '',
-          lon: '',
-          visitModel: this.visitModel,
-          routeDetailsId: '',
-          storeGroupId: this.$route.query.storeGroupId,
-          visitSource: '1',
-          insert: insert,
-          locationCity: '',
-          locationRemark: '',
-          locationAccuracy: '',
-        };
+        // var params = {
+        //   chainId: this.$route.query.chainId,
+        //   chainCode: this.$route.query.chainCode,
+        //   visitEntry: '0',
+        //   lat: '',
+        //   lon: '',
+        //   visitModel: this.visitModel,
+        //   routeDetailsId: '',
+        //   storeGroupId: this.$route.query.storeGroupId,
+        //   visitSource: '1',
+        //   insert: insert,
+        //   locationCity: '',
+        //   locationRemark: '',
+        //   locationAccuracy: '',
+        // };
       } else {
-        var params = {
-          chainId: this.chainId,
-          chainCode: this.$route.query.chainCode,
-          visitEntry: '0',
-          lat: this.$route.query.lat,
-          lon: this.$route.query.lon,
-          visitModel: this.$route.query.visitModel,
-          routeDetailsId: this.$route.query.taskId,
-          locationCity: this.$route.query.locationCity,
-          insert: insert,
-          locationRemark: this.$route.query.locationRemark,
-          locationAccuracy: this.$route.query.locationAccuracy,
-          visitSource: this.$route.query.visitSource,
-        };
+        // var params = {
+        //   chainId: this.chainId,
+        //   chainCode: this.$route.query.chainCode,
+        //   visitEntry: '0',
+        //   lat: this.$route.query.lat,
+        //   lon: this.$route.query.lon,
+        //   visitModel: this.$route.query.visitModel,
+        //   routeDetailsId: this.$route.query.taskId,
+        //   locationCity: this.$route.query.locationCity,
+        //   insert: insert,
+        //   locationRemark: this.$route.query.locationRemark,
+        //   locationAccuracy: this.$route.query.locationAccuracy,
+        //   visitSource: this.$route.query.visitSource,
+        // };
+        params.taskId = this.$route.query.taskId; //	Long	任务id
       }
       if (this.$route.query.visitId != null) {
         params.id = this.$route.query.visitId;
       }
-      getChainsGroupTask(params).then((res) => {
+      getCollectionInfos(params).then((res) => {
         loading1.clear();
-        this.deviceCode = '';
-        this.putInCode = '';
         // 竞品调查-table动态化数据
-        this.productTitles = res.data.sfaTaskList[this.$route.query.ids].productTitles; //产品类型表头数据
+        this.productTitles = res.data.productTitles; //产品类型表头数据
         // this.equipmentCode = res.data.equipmentCode;
-        var checkUnManage = res.data.sfaTaskList[this.$route.query.ids];
-        var collectionItemLists = res.data.sfaTaskList[this.$route.query.ids].collectionItemList;
+        var checkUnManage = res.data;
+        var collectionItemLists = res.data.collectionItemList;
         if (checkUnManage.checkUnManage != null && checkUnManage.checkUnManage != 'N') {
           this.checked = true;
         } else {
           this.checked = false;
         }
-        this.unManage = res.data.sfaTaskList[this.$route.query.ids].unManage;
-        this.deviceCode = res.data.sfaTaskList[this.$route.query.ids].deviceCode || ''; // 设备编号
-        this.putInCode = res.data.sfaTaskList[this.$route.query.ids].putInCode || ''; // 投放编号
+        this.unManage = res.data.unManage;
         // 调色机类型:buy-购买类调色机,place-放置类调色机 不显示设备编号和投放编号
-        let inspectionType = res.data.sfaTaskList[this.$route.query.ids].inspectionType;
-        if (inspectionType == 'buy') {
-          this.equipmentCode = res.data.sfaTaskList[this.$route.query.ids].putInCode || '';
+        if (this.inspectionType == 'buy') {
+          this.equipmentCode = this.putInCode || '';
           this.showCode = true;
-        } else if (inspectionType == 'place') {
-          this.equipmentCode = res.data.sfaTaskList[this.$route.query.ids].equipmentCode || '';
+        } else if (this.inspectionType == 'place') {
+          this.equipmentCode = this.equipmentCode || '';
           this.showCode = false;
         }
         if (
-          (res.data.sfaTaskList[this.$route.query.ids].processStatus == 3 &&
-            this.$route.query.types == 'edit') ||
-          res.data.sfaTaskList[this.$route.query.ids].processStatus == undefined
+          (res.data.processStatus == 3 && this.$route.query.types == 'edit') ||
+          res.data.processStatus == undefined
         ) {
           this.processKey = true;
         } else {
           this.processKey = false;
         }
-        this.infoShow = res.data.sfaTaskList[this.$route.query.ids].isMust;
+        this.infoShow = res.data.isMust;
         if (this.$route.query.taskType == 1) {
           for (var q = 0; q < collectionItemLists.length; q++) {
             if (
@@ -4661,6 +4669,7 @@ export default {
           }
           addCollectionAnswer(formData).then((res) => {
             if (res.code == 200) {
+              localStorage.setItem('getRequestFlage', 'true');
               this.$router.go(-1);
             } else {
               this.$dialog.alert({