Browse Source

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

zhujindu 6 months ago
parent
commit
27d705746b
1 changed files with 127 additions and 74 deletions
  1. 127 74
      src/views/deviceWithin/addStoreVisit.vue

+ 127 - 74
src/views/deviceWithin/addStoreVisit.vue

@@ -97,13 +97,6 @@
         class="table-headermd"
         style="width: 100%"
         v-if="productTitles">
-        <el-table-column label="产品名称" prop="collectionName">
-          <template slot-scope="scope">
-            <span class="tipTitle" @click="tipTitle(scope.row.collectionName)">
-              {{ scope.row.collectionName }}
-            </span>
-          </template>
-        </el-table-column>
         <el-table-column label="品类" prop="level1" />
         <el-table-column label="档次" prop="grade" />
         <el-table-column label="品牌" prop="brandName" />
@@ -125,6 +118,47 @@
           /></template>
         </el-table-column>
       </el-table>
+      <el-table :data="tableData1" border class="table-headermd" style="width: 100%">
+        <el-table-column label="产品名称" prop="collectionName">
+          <template slot-scope="scope">
+            <span class="tipTitle" @click="tipTitle(scope.row.collectionName)">
+              {{ scope.row.collectionName }}
+            </span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="name">
+          <template slot="header"> <span>进货原价</span><span class="xing">*</span> </template>
+          <template slot-scope="scope"
+            ><van-field
+              v-model="scope.row.xdjhyj"
+              placeholder="请输入"
+              type="number"
+              @blur="inputblur(scope.row.xdjhyj, scope.$index, '0')"
+          /></template>
+        </el-table-column>
+        <el-table-column class="t-center" prop="address">
+          <template slot="header"> <span>促后净价</span><span class="xing">*</span> </template>
+          <template slot-scope="scope">
+            <van-field
+              v-model="scope.row.xdjhchjj"
+              placeholder="请输入"
+              type="number"
+              @blur="inputblurs(scope.row.xdjhchjj, scope.$index, '1')" />
+          </template>
+        </el-table-column>
+        <el-table-column class="t-center" prop="address">
+          <template slot="header" class="t-center">
+            <span>油工拿货价</span><span class="xing">*</span>
+          </template>
+          <template slot-scope="scope"
+            ><van-field
+              v-model="scope.row.ygnhj"
+              placeholder="请输入"
+              type="number"
+              @blur="inputblur(scope.row.ygnhj, scope.$index, '2')"
+          /></template>
+        </el-table-column>
+      </el-table>
       <div v-if="unManage == 0" style="margin: 10px">
         <van-checkbox v-model="checked" shape="square">全部不经营</van-checkbox>
       </div>
@@ -2795,7 +2829,7 @@ export default {
       photoIdentifyType: null, //图片识别类型
       pictureSource: '0',
       stillDistribute: false,
-      productTitles: [],
+      productTitles: null,
       inspectionType: '',
       competitortableData: [],
     };
@@ -3318,7 +3352,7 @@ export default {
       console.log(params.id);
       getCollectionInfos(params).then((res) => {
         loading1.clear();
-        this.productTitles = res.data.productTitles || []; //产品类型表头数据
+        this.productTitles = res.data.productTitles; //产品类型表头数据
         var checkUnManage = res.data;
         var collectionItemLists = res.data.collectionItemList;
         if (checkUnManage.checkUnManage != null && checkUnManage.checkUnManage != 'N') {
@@ -3714,44 +3748,46 @@ export default {
             }
           }
           this.collectionItemList = collectionItemLists;
-        } else if (this.$route.query.taskType == 2) {
-          for (var f = 0; f < collectionItemLists.length; f++) {
-            var collectionOptionListarr = collectionItemLists[f].collectionOptionList;
-            for (let p = 0; p < this.productTitles.length; p++) {
-              for (var ff = 0; ff < collectionOptionListarr.length; ff++) {
-                if (
-                  this.productTitles[p].titleValue == collectionOptionListarr[ff].collectionOption
-                ) {
-                  collectionItemLists[f][this.productTitles[p].titleValue] =
-                    collectionOptionListarr[ff].answerValue;
+        } else {
+          if (this.$route.query.taskType == 2 && this.productTitles) {
+            for (var f = 0; f < collectionItemLists.length; f++) {
+              var collectionOptionListarr = collectionItemLists[f].collectionOptionList;
+              for (let p = 0; p < this.productTitles.length; p++) {
+                for (var ff = 0; ff < collectionOptionListarr.length; ff++) {
+                  if (
+                    this.productTitles[p].titleValue == collectionOptionListarr[ff].collectionOption
+                  ) {
+                    collectionItemLists[f][this.productTitles[p].titleValue] =
+                      collectionOptionListarr[ff].answerValue;
+                  }
                 }
               }
             }
-          }
-          this.competitortableData = collectionItemLists;
-        } else {
-          for (var f = 0; f < collectionItemLists.length; f++) {
-            var collectionOptionListarr = collectionItemLists[f].collectionOptionList;
-            for (var ff = 0; ff < collectionOptionListarr.length; ff++) {
-              if (ff == '0') {
-                collectionItemLists[f].xdjhyj = collectionOptionListarr[ff].answerValue;
-                collectionItemLists[f].value = collectionOptionListarr[ff].answerValue;
-                collectionItemLists[f].contrastValue = collectionOptionListarr[ff].answerValue;
-              }
-              if (ff == '1') {
-                collectionItemLists[f].xdjhchjj = collectionOptionListarr[ff].answerValue;
-                if (collectionOptionListarr[ff].answerValue == null) {
-                  collectionItemLists[f].answerVal = 'T';
-                } else {
-                  collectionItemLists[f].answerVal = '';
+            this.competitortableData = collectionItemLists;
+          } else {
+            for (var f = 0; f < collectionItemLists.length; f++) {
+              var collectionOptionListarr = collectionItemLists[f].collectionOptionList;
+              for (var ff = 0; ff < collectionOptionListarr.length; ff++) {
+                if (ff == '0') {
+                  collectionItemLists[f].xdjhyj = collectionOptionListarr[ff].answerValue;
+                  collectionItemLists[f].value = collectionOptionListarr[ff].answerValue;
+                  collectionItemLists[f].contrastValue = collectionOptionListarr[ff].answerValue;
+                }
+                if (ff == '1') {
+                  collectionItemLists[f].xdjhchjj = collectionOptionListarr[ff].answerValue;
+                  if (collectionOptionListarr[ff].answerValue == null) {
+                    collectionItemLists[f].answerVal = 'T';
+                  } else {
+                    collectionItemLists[f].answerVal = '';
+                  }
+                }
+                if (ff == '2') {
+                  collectionItemLists[f].ygnhj = collectionOptionListarr[ff].answerValue;
                 }
-              }
-              if (ff == '2') {
-                collectionItemLists[f].ygnhj = collectionOptionListarr[ff].answerValue;
               }
             }
+            this.tableData1 = collectionItemLists;
           }
-          this.tableData1 = collectionItemLists;
         }
       });
     },
@@ -3759,6 +3795,7 @@ export default {
       this.$toast(val);
     },
     inputblurs(val, index, num) {
+      if (!val) return;
       if ((val + '').trim() == '') {
         this.tableData1[index].xdjhchjj = '';
       } else {
@@ -3783,34 +3820,48 @@ export default {
         }
       }
     },
-    inputblur(itemVal, index) {
-      let value = this.competitortableData[index][itemVal];
-      if (value.split('.')[1] == '' || (value + '').trim() == '') {
+    inputblur(val, index, num) {
+      if (val.split('.')[1] == '' || (val + '').trim() == '') {
         this.$toast('请输入正确格式数字');
-        this.competitortableData[index][itemVal] = '';
+        if (num == '0') {
+          this.tableData1[index].xdjhyj = '';
+        }
+        if (num == '1') {
+          this.tableData1[index].xdjhchjj = '';
+        }
+        if (num == '2') {
+          this.tableData1[index].ygnhj = '';
+        }
       } else {
-        if (!/^\d+(\.\d{1,2})?$/.test(value) || Number(value) > 10000 || Number(value) <= 0) {
+        if (!/^\d+(\.\d{1,2})?$/.test(val) || Number(val) > 10000 || Number(val) <= 0) {
           this.$toast('请输入大于0并且小于10000的两位小数');
-          this.competitortableData[index][itemVal] = '';
-          ff;
+          if (num == '0') {
+            this.tableData1[index].xdjhyj = '';
+          }
+          if (num == '1') {
+            this.tableData1[index].xdjhchjj = '';
+          }
+          if (num == '2') {
+            this.tableData1[index].ygnhj = '';
+          }
         } else {
-          // if (num == '0') {
-          //   if (this.tableData1[index].xdjhyj < this.tableData1[index].xdjhchjj) {
-          //     this.tableData1[index].xdjhyj = '';
-          //     this.$toast('请输入大于等于促后净价的数字');
-          //   }
-          // }
-          // if (num == '1') {
-          //   if (this.tableData1[index].xdjhyj == '') {
-          //     this.tableData1[index].xdjhchjj = '';
-          //     this.$toast('请输入进货原价');
-          //   } else {
-          //     if (Number(val) > Number(this.tableData1[index].xdjhyj)) {
-          //       this.$toast('请输入小于等于进货原价的数字');
-          //       this.tableData1[index].xdjhchjj = '';
-          //     }
-          //   }
-          // }
+          if (num == '0') {
+            if (this.tableData1[index].xdjhyj < this.tableData1[index].xdjhchjj) {
+              this.tableData1[index].xdjhyj = '';
+              this.$toast('请输入大于等于促后净价的数字');
+            }
+          }
+          if (num == '1') {
+            if (this.tableData1[index].xdjhyj == '') {
+              this.tableData1[index].xdjhchjj = '';
+              this.$toast('请输入进货原价');
+            } else {
+              if (Number(val) > Number(this.tableData1[index].xdjhyj)) {
+                this.$toast('请输入小于等于进货原价的数字');
+                this.tableData1[index].xdjhchjj = '';
+              }
+            }
+          }
         }
       }
     },
@@ -4672,16 +4723,18 @@ export default {
           // }
         }
         for (var d = 0; d < this.competitortableData.length; d++) {
-          for (let p = 0; p < this.productTitles.length; p++) {
-            formData.collectionAnswers.push({
-              collectionId: this.competitortableData[d].collectionId,
-              itemName: this.competitortableData[d].collectionName,
-              collectionType: 'chanpin',
-              collectionOptionId:
-                this.competitortableData[d].collectionOptionList[p].collectionOptionId,
-              answerType: 'sz',
-              answerValue: this.competitortableData[d][this.productTitles[p].titleValue],
-            });
+          if (this.productTitles) {
+            for (let p = 0; p < this.productTitles.length; p++) {
+              formData.collectionAnswers.push({
+                collectionId: this.competitortableData[d].collectionId,
+                itemName: this.competitortableData[d].collectionName,
+                collectionType: 'chanpin',
+                collectionOptionId:
+                  this.competitortableData[d].collectionOptionList[p].collectionOptionId,
+                answerType: 'sz',
+                answerValue: this.competitortableData[d][this.productTitles[p].titleValue],
+              });
+            }
           }
           // for (var dd = 0; dd < this.tableData1[d].collectionOptionList.length; dd++) {
           // if (dd == 0) {