zhujindu il y a 1 an
Parent
commit
c72c654c90
1 fichiers modifiés avec 249 ajouts et 153 suppressions
  1. 249 153
      src/views/deviceWithin/addStoreVisit.vue

+ 249 - 153
src/views/deviceWithin/addStoreVisit.vue

@@ -91,15 +91,40 @@
       <p v-if="unManage == 0" class="isTableMust">
         <van-icon name="info-o" />&nbsp;请根据本店实际经营的竞品产品,反馈价格信息!
       </p>
-      <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">
+      <el-table
+        :data="competitortableData"
+        border
+        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" />
+        <el-table-column label="规格" prop="spec" />
+        <el-table-column
+          v-for="(item, index) in productTitles"
+          :key="index"
+          :prop="item.titleValue">
+          <template slot="header">
+            <span>{{ item.titleName }}</span
+            ><span class="xing">*</span>
+          </template>
+          <template slot-scope="scope"
+            ><van-field
+              v-model="scope.row[item.titleValue]"
+              placeholder="请输入"
+              type="number"
+              @blur="inputblur(item.titleValue, scope.$index, '0')"
+          /></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
@@ -130,7 +155,7 @@
               type="number"
               @blur="inputblur(scope.row.ygnhj, scope.$index, '2')"
           /></template>
-        </el-table-column>
+        </el-table-column> -->
       </el-table>
       <div v-if="unManage == 0" style="margin: 10px">
         <van-checkbox v-model="checked" shape="square">全部不经营</van-checkbox>
@@ -3224,6 +3249,7 @@ export default {
       var insert = '';
       this.collectionItemList = [];
       this.tableData1 = [];
+      this.competitortableData = [];
       this.collectionAnswerlisd = [];
       if (this.$route.query.type == 'edit') {
         insert = false;
@@ -3270,6 +3296,8 @@ export default {
         loading1.clear();
         this.deviceCode = '';
         this.putInCode = '';
+        // 竞品调查-table动态化数据
+        this.productTitles = res.data.sfaTaskList[this.$route.query.ids].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;
@@ -3669,6 +3697,21 @@ 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;
+                }
+              }
+            }
+          }
+          this.competitortableData = collectionItemLists;
         } else {
           for (var f = 0; f < collectionItemLists.length; f++) {
             var collectionOptionListarr = collectionItemLists[f].collectionOptionList;
@@ -3723,48 +3766,34 @@ export default {
         }
       }
     },
-    inputblur(val, index, num) {
-      if (val.split('.')[1] == '' || (val + '').trim() == '') {
+    inputblur(itemVal, index) {
+      let value = this.competitortableData[index][itemVal];
+      if (value.split('.')[1] == '' || (value + '').trim() == '') {
         this.$toast('请输入正确格式数字');
-        if (num == '0') {
-          this.tableData1[index].xdjhyj = '';
-        }
-        if (num == '1') {
-          this.tableData1[index].xdjhchjj = '';
-        }
-        if (num == '2') {
-          this.tableData1[index].ygnhj = '';
-        }
+        this.competitortableData[index][itemVal] = '';
       } else {
-        if (!/^\d+(\.\d{1,2})?$/.test(val) || Number(val) > 10000 || Number(val) <= 0) {
+        if (!/^\d+(\.\d{1,2})?$/.test(value) || Number(value) > 10000 || Number(value) <= 0) {
           this.$toast('请输入大于0并且小于10000的两位小数');
-          if (num == '0') {
-            this.tableData1[index].xdjhyj = '';
-          }
-          if (num == '1') {
-            this.tableData1[index].xdjhchjj = '';
-          }
-          if (num == '2') {
-            this.tableData1[index].ygnhj = '';
-          }
+          this.competitortableData[index][itemVal] = '';
+          ff;
         } 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 = '';
+          //     }
+          //   }
+          // }
         }
       }
     },
@@ -3821,45 +3850,77 @@ export default {
       this.show = true;
     },
     newimgarr1(val) {
-      console.log(JSON.stringify(val));
-      console.log('pType=' + this.pType);
-      this.show = false;
       //是否开启图匠识别,(1:店招内容识别,2:门店代码识别,3:调色机识别,4:更换店招)
       //  拍摄店招时只允许上传一张
       let photoIdentifyType = val.photoIdentifyType;
+      this.show = false;
       if (this.pType == 'D') {
-        let fileInfoList =
+        if (
           this.collectionItemList[this.indeximg].collectionOptionList[this.childIndex1]
             .collectionItems[this.childIndex].collectionOptionList[this.childIndex2]
             .collectionItems[this.childIndex3].collectionOptionList[this.childIndex4]
-            .collectionItems[this.childIndex5].fileInfoList;
-        if (fileInfoList == null) {
-          fileInfoList = [];
+            .collectionItems[this.childIndex5].fileInfoList == null
+        ) {
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].collectionOptionList[this.childIndex4].collectionItems[this.childIndex5].fileInfoList =
+            [];
         }
         if (photoIdentifyType == 1) {
-          fileInfoList = [val];
-          // this.$set(fileInfoList, 0, val);
-          console.log('fileInfoList=' + fileInfoList);
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].collectionOptionList[this.childIndex4].collectionItems[this.childIndex5].fileInfoList =
+            [val];
         } else {
-          fileInfoList.push(val);
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].collectionOptionList[this.childIndex4].collectionItems[
+            this.childIndex5
+          ].fileInfoList.push(val);
         }
       }
       if (this.pType == 'E') {
-        let fileInfoList =
+        if (
           this.collectionItemList[this.indeximg].collectionOptionList[this.childIndex1]
             .collectionItems[this.childIndex].collectionOptionList[this.childIndex2]
             .collectionItems[this.childIndex3].collectionOptionList[this.childIndex4]
             .collectionItems[this.childIndex5].collectionOptionList[this.childIndex6]
-            .collectionItems[this.childIndex7].fileInfoList;
-        if (fileInfoList == null) {
-          fileInfoList = [];
+            .collectionItems[this.childIndex7].fileInfoList == null
+        ) {
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].collectionOptionList[this.childIndex4].collectionItems[
+            this.childIndex5
+          ].collectionOptionList[this.childIndex6].collectionItems[this.childIndex7].fileInfoList =
+            [];
         }
         if (photoIdentifyType == 1) {
-          fileInfoList = [val];
-          // this.$set(fileInfoList, 0, val);
-          console.log('fileInfoList=' + fileInfoList);
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].collectionOptionList[this.childIndex4].collectionItems[
+            this.childIndex5
+          ].collectionOptionList[this.childIndex6].collectionItems[this.childIndex7].fileInfoList =
+            [val];
         } else {
-          fileInfoList.push(val);
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].collectionOptionList[this.childIndex4].collectionItems[
+            this.childIndex5
+          ].collectionOptionList[this.childIndex6].collectionItems[
+            this.childIndex7
+          ].fileInfoList.push(val);
         }
       }
       if (this.pType == 'A' || this.pType == 'B') {
@@ -3879,59 +3940,74 @@ export default {
           }
         }
         if (child) {
-          let fileInfoList =
-            this.collectionItemList[this.indeximg].collectionOptionList[childi].collectionItems[
-              this.childIndex
-            ].fileInfoList;
           for (
             let childi = 0;
             childi < this.collectionItemList[this.indeximg].collectionOptionList.length;
             childi++
           ) {
-            if (fileInfoList == null || fileInfoList == undefined) {
-              fileInfoList = [];
+            if (
+              this.collectionItemList[this.indeximg].collectionOptionList[childi].collectionItems[
+                this.childIndex
+              ].fileInfoList == null ||
+              this.collectionItemList[this.indeximg].collectionOptionList[childi].collectionItems[
+                this.childIndex
+              ].fileInfoList == undefined
+            ) {
+              this.collectionItemList[this.indeximg].collectionOptionList[childi].collectionItems[
+                this.childIndex
+              ].fileInfoList = [];
             }
             if (photoIdentifyType == 1) {
-              fileInfoList = [val];
-              // this.$set(fileInfoList, 0, val);
+              this.collectionItemList[this.indeximg].collectionOptionList[childi].collectionItems[
+                this.childIndex
+              ].fileInfoList = [val];
             } else {
-              fileInfoList.push(val);
+              this.collectionItemList[this.indeximg].collectionOptionList[childi].collectionItems[
+                this.childIndex
+              ].fileInfoList.push(val);
             }
           }
         } else {
-          let fileInfoList = this.collectionItemList[this.indeximg].fileInfoList;
-          if (fileInfoList == null || fileInfoList == undefined) {
-            fileInfoList = [];
+          if (
+            this.collectionItemList[this.indeximg].fileInfoList == null ||
+            this.collectionItemList[this.indeximg].fileInfoList == undefined
+          ) {
+            this.collectionItemList[this.indeximg].fileInfoList = [];
           }
           if (photoIdentifyType == 1) {
-            fileInfoList.splice(0, 1, val);
-            // fileInfoList = [val];
-            // this.$set(fileInfoList, 0, val);
-            console.log('fileInfoList111=' + JSON.stringify(fileInfoList));
+            this.collectionItemList[this.indeximg].fileInfoList = [val];
             console.log(
-              'fileInfoList222=' +
-                JSON.stringify(this.collectionItemList[this.indeximg].fileInfoList)
+              JSON.stringify('fileInfoList111=' + this.collectionItemList[this.indeximg])
             );
-            this.$forceUpdate();
           } else {
-            fileInfoList.push(val);
+            this.collectionItemList[this.indeximg].fileInfoList.push(val);
           }
         }
       }
       if (this.pType == 'C') {
-        let fileInfoList =
+        if (
           this.collectionItemList[this.indeximg].collectionOptionList[this.childIndex1]
             .collectionItems[this.childIndex].collectionOptionList[this.childIndex2]
-            .collectionItems[this.childIndex3].fileInfoList;
-        if (fileInfoList == null) {
-          fileInfoList = [];
+            .collectionItems[this.childIndex3].fileInfoList == null
+        ) {
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].fileInfoList = [];
         }
         if (photoIdentifyType == 1) {
-          fileInfoList = [val];
-          // this.$set(fileInfoList, 0, val);
-          console.log('fileInfoList=' + fileInfoList);
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].fileInfoList = [val];
         } else {
-          fileInfoList.push(val);
+          this.collectionItemList[this.indeximg].collectionOptionList[
+            this.childIndex1
+          ].collectionItems[this.childIndex].collectionOptionList[this.childIndex2].collectionItems[
+            this.childIndex3
+          ].fileInfoList.push(val);
         }
       }
       this.$forceUpdate();
@@ -4532,72 +4608,92 @@ export default {
           }
         }
       } else if (this.$route.query.taskType == 2) {
-        for (let dy = 0; dy < this.tableData1.length; dy++) {
-          if (this.tableData1[dy].xdjhchjj != '') {
-            if (
-              this.tableData1[dy].xdjhyj == '' ||
-              this.tableData1[dy].ygnhj == '' ||
-              this.tableData1[dy].xdjhchjj.split('.')[1] == ''
-            ) {
+        for (let dy = 0; dy < this.competitortableData.length; dy++) {
+          for (let p = 0; p < this.productTitles.length; p++) {
+            if (this.competitortableData[dy][this.productTitles[p].titleValue] == '') {
               this.$dialog.alert({
                 title: '系统提示',
-                message: '请完善' + this.tableData1[dy].collectionName + '信息或促后竞价格式不正确',
-              });
-              return false;
-            }
-          }
-          if (this.tableData1[dy].xdjhyj != '') {
-            if (this.tableData1[dy].xdjhchjj == '' || this.tableData1[dy].ygnhj == '') {
-              this.$dialog.alert({
-                title: '系统提示',
-                message: '请完善' + this.tableData1[dy].collectionName + '信息',
-              });
-              return false;
-            }
-          }
-          if (this.tableData1[dy].ygnhj != '') {
-            if (this.tableData1[dy].xdjhchjj == '' || this.tableData1[dy].xdjhyj == '') {
-              this.$dialog.alert({
-                title: '系统提示',
-                message: '请完善' + this.tableData1[dy].collectionName + '信息',
+                message: '请完善' + this.competitortableData[dy].collectionName + '信息',
               });
               return false;
             }
           }
+          // if (this.tableData1[dy].xdjhchjj != '') {
+          //   if (
+          //     this.tableData1[dy].xdjhyj == '' ||
+          //     this.tableData1[dy].ygnhj == '' ||
+          //     this.tableData1[dy].xdjhchjj.split('.')[1] == ''
+          //   ) {
+          //     this.$dialog.alert({
+          //       title: '系统提示',
+          //       message: '请完善' + this.tableData1[dy].collectionName + '信息或促后竞价格式不正确',
+          //     });
+          //     return false;
+          //   }
+          // }
+          // if (this.tableData1[dy].xdjhyj != '') {
+          //   if (this.tableData1[dy].xdjhchjj == '' || this.tableData1[dy].ygnhj == '') {
+          //     this.$dialog.alert({
+          //       title: '系统提示',
+          //       message: '请完善' + this.tableData1[dy].collectionName + '信息',
+          //     });
+          //     return false;
+          //   }
+          // }
+          // if (this.tableData1[dy].ygnhj != '') {
+          //   if (this.tableData1[dy].xdjhchjj == '' || this.tableData1[dy].xdjhyj == '') {
+          //     this.$dialog.alert({
+          //       title: '系统提示',
+          //       message: '请完善' + this.tableData1[dy].collectionName + '信息',
+          //     });
+          //     return false;
+          //   }
+          // }
         }
-        for (var d = 0; d < this.tableData1.length; d++) {
-          for (var dd = 0; dd < this.tableData1[d].collectionOptionList.length; dd++) {
-            if (dd == 0) {
-              formData.collectionAnswers.push({
-                collectionId: this.tableData1[d].collectionId,
-                itemName: this.tableData1[d].collectionName,
-                collectionType: 'chanpin',
-                collectionOptionId: this.tableData1[d].collectionOptionList[dd].collectionOptionId,
-                answerType: 'sz',
-                answerValue: this.tableData1[d].xdjhyj,
-              });
-            }
-            if (dd == 1) {
-              formData.collectionAnswers.push({
-                collectionId: this.tableData1[d].collectionId,
-                itemName: this.tableData1[d].collectionName,
-                collectionType: 'chanpin',
-                collectionOptionId: this.tableData1[d].collectionOptionList[dd].collectionOptionId,
-                answerType: 'sz',
-                answerValue: this.tableData1[d].xdjhchjj,
-              });
-            }
-            if (dd == 2) {
-              formData.collectionAnswers.push({
-                collectionId: this.tableData1[d].collectionId,
-                itemName: this.tableData1[d].collectionName,
-                collectionType: 'chanpin',
-                collectionOptionId: this.tableData1[d].collectionOptionList[dd].collectionOptionId,
-                answerType: 'sz',
-                answerValue: this.tableData1[d].ygnhj,
-              });
-            }
+        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],
+            });
           }
+          // for (var dd = 0; dd < this.tableData1[d].collectionOptionList.length; dd++) {
+          // if (dd == 0) {
+          //   formData.collectionAnswers.push({
+          //     collectionId: this.tableData1[d].collectionId,
+          //     itemName: this.tableData1[d].collectionName,
+          //     collectionType: 'chanpin',
+          //     collectionOptionId: this.tableData1[d].collectionOptionList[dd].collectionOptionId,
+          //     answerType: 'sz',
+          //     answerValue: this.tableData1[d].xdjhyj,
+          //   });
+          // }
+          // if (dd == 1) {
+          //   formData.collectionAnswers.push({
+          //     collectionId: this.tableData1[d].collectionId,
+          //     itemName: this.tableData1[d].collectionName,
+          //     collectionType: 'chanpin',
+          //     collectionOptionId: this.tableData1[d].collectionOptionList[dd].collectionOptionId,
+          //     answerType: 'sz',
+          //     answerValue: this.tableData1[d].xdjhchjj,
+          //   });
+          // }
+          // if (dd == 2) {
+          //   formData.collectionAnswers.push({
+          //     collectionId: this.tableData1[d].collectionId,
+          //     itemName: this.tableData1[d].collectionName,
+          //     collectionType: 'chanpin',
+          //     collectionOptionId: this.tableData1[d].collectionOptionList[dd].collectionOptionId,
+          //     answerType: 'sz',
+          //     answerValue: this.tableData1[d].ygnhj,
+          //   });
+          // }
+          // }
         }
       } else {
         for (var d = 0; d < this.tableData1.length; d++) {