Browse Source

Merge branch 'feature_20260425_完美门店陈列奖励案图片上传方式修改' into uat(dev)

zhujindu 7 giờ trước cách đây
mục cha
commit
b6ca80b7cf

+ 29 - 124
src/components/deleteUploadImgTaskPhoto.vue

@@ -7,6 +7,7 @@
         v-if="formData.processStatus != 1 || formData.displayRewardTaskEditable">
         <div class="addImg">
           <uploadVNormalTaskPhoto
+            :imgArr="imgs"
             :formData="formData"
             :shouws="true"
             :storeGroupId="storeGroupId"
@@ -23,18 +24,14 @@
             ref="uploadVNormal" />
         </div>
       </van-col>
-      <van-col span="6" v-for="(urls, index) in imgArr" :key="index">
+      <van-col span="6" v-for="(urls, index) in imgs" :key="index">
         <div class="imgview">
           <van-icon
             v-if="formData.processStatus != 1 || formData.displayRewardTaskEditable"
             name="close"
             size="20"
-            v-on:click="deleteImg(index, urls)" />
-          <img
-            :src="urls.fileUrl || urls.mediaFileUrl"
-            width="100px"
-            height="100px"
-            @click="previewsImg(index)" />
+            v-on:click="deleteImg(index, urls.fileIdSplicing)" />
+          <img :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)" />
           <!-- <img
             v-else
             :src="urls.fileUrl"
@@ -117,24 +114,16 @@ export default {
         return [];
       },
     },
+    imgs: {
+      type: Array,
+      default() {
+        return [];
+      },
+    },
   },
   watch: {
-    formData: {
-      handler(val) {
-        // <!-- 0=企业微信,1=H5相机 -->
-        if (this.userInfo.photoMethod == '1') {
-          this.imgArr = this.fileInfoList || [];
-        } else {
-          this.imgArr = val.mediaInfos || [];
-          // if (this.formData.mediaInfos) {
-          //   getTicketFun(['downloadImage']).then(() => {
-          //     this.toastLoading(0, '加载中,请稍候...', true);
-          //     let mediaInfosCopy = JSON.parse(JSON.stringify(this.formData.mediaInfos));
-          //     this.downloadImage(mediaInfosCopy);
-          //   });
-          // }
-        }
-      },
+    imgs: {
+      handler(val) {},
       deep: true,
       immediate: true,
     },
@@ -142,119 +131,35 @@ export default {
   data() {
     return {
       url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
-      imgArr: [],
-      mediaIds: [],
-      locationRemark: '',
-      isUploadImg: true,
     };
   },
   methods: {
-    downloadImage(mediaInfos) {
-      if (!mediaInfos.length) {
-        this.toastLoading().clear();
-        return;
-      } else {
-        let mediaitem = mediaInfos.pop();
-        if (mediaitem.fileUrl) {
-          this.imgArr.push(mediaitem);
-          this.downloadImage(mediaInfos);
+    deleteImg(index, fileIdList) {
+      this.toastLoading(0, '请稍候...', true);
+      removePhotoBatch({ fileIdList: fileIdList.split(',') }).then((res) => {
+        if (res.code == 200) {
+          this.$emit('upDataDetail');
         } else {
-          wx.downloadImage({
-            serverId: mediaitem.mediaId,
-            isShowProgressTips: 0, // 默认为1,显示进度提示
-            success: (res) => {
-              wx.getLocalImgData({
-                localId: res.localId,
-                success: (res2) => {
-                  this.imgArr.push({
-                    mediaId: mediaitem.mediaId,
-                    mediaFileUrl: res2.localData,
-                  });
-                  this.downloadImage(mediaInfos);
-                },
-                fail: (err) => {
-                  console.error('获取本地图片数据失败:', err);
-                  this.$toast('获取图片数据失败');
-                  this.toastLoading().clear();
-                  this.downloadImage(mediaInfos);
-                },
-              });
-            },
-            fail: (err) => {
-              console.error('下载图片失败:', err);
-              this.$toast('下载图片失败,请重试');
-              // 可以选择继续下载其他图片或停止
-              this.downloadImage(mediaInfos);
-            },
-          });
+          this.$toast('删除失败!');
         }
-      }
-    },
-    deleteImg(index, urls) {
-      // <!-- 0=企业微信,1=H5相机 -->
-      if (this.userInfo.photoMethod == '1') {
-        removePhotoBatch({ fileIdList: urls.fileIdSplicing.split(',') }).then((res) => {
-          if (res.code == 200) {
-            this.$toast('删除成功!');
-            this.$emit('upDataDetail');
-          } else {
-            this.$toast('删除失败!');
-          }
-        });
-      } else {
-        this.imgArr.splice(index, 1);
-      }
+      });
     },
     previewsImg(index) {
-      let urls = this.imgArr.map((item) => item.fileUrl || item.mediaFileUrl);
+      var arrimg = [];
+      for (var imgi = 0; imgi < this.imgs.length; imgi++) {
+        arrimg.push(this.imgs[imgi].fileUrl);
+      }
       ImagePreview({
-        images: urls,
+        images: arrimg,
         startPosition: index,
+        onClose() {
+          // do something
+        },
       });
     },
-    newimgarr(data) {
-      const { localIds, locationRemark, source } = data;
-      this.locationRemark = locationRemark;
-      console.log(source);
-      // 0=企业微信,1=H5相机
-      if (this.userInfo.photoMethod == '0') {
-        this.isUploadImg = false;
-        const startIndex = this.imgArr.length;
-        this.imgArr = this.imgArr.concat(
-          localIds.map((item) => {
-            return {
-              mediaId: '',
-              mediaFileUrl: item,
-            };
-          }),
-        );
-        // this.$nextTick(() => {
-        //   this.syncUpload(localIds, startIndex);
-        // });
-      } else {
-        this.$emit('upDataDetail');
-      }
+    newimgarr() {
+      this.$emit('upDataDetail');
     },
-    // syncUpload(localIds, baseIndex = 0, callback) {
-    //   if (!localIds.length) {
-    //     this.isUploadImg = true;
-    //     callback && callback();
-    //     return;
-    //   } else {
-    //     var localId = localIds.pop();
-    //     wx.uploadImage({
-    //       localId: localId,
-    //       isShowProgressTips: 0, // 默认为1,显示进度提示
-    //       success: (res) => {
-    //         const index = baseIndex + localIds.length;
-    //         if (this.imgArr[index]) {
-    //           this.imgArr[index].mediaId = res.serverId;
-    //         }
-    //         this.syncUpload(localIds, baseIndex, callback);
-    //       },
-    //     });
-    //   }
-    // },
   },
 };
 </script>

+ 9 - 9
src/components/uploadVNormalTaskPhoto.vue

@@ -213,7 +213,7 @@ export default {
               let count = 1;
               // 1:店招内容识别(不能连拍和多选),3:调色机识别(不能连拍和多选) 需要实时识别的不支持连拍和多选
               if (that.photoIdentifyType != 1 && that.photoIdentifyType != 3) {
-                count = that.continuousShoot == '1' ? 20 : 1; //是否允许连拍/相册多选 最多5张
+                count = that.continuousShoot == '1' ? 5 : 1; //是否允许连拍/相册多选 最多5张
               }
               wx.chooseImage({
                 count: count,
@@ -225,13 +225,13 @@ export default {
                 success: function (res) {
                   let localIds = res.localIds;
                   that.localIdsArr = [];
-                  that.$emit('newimgarr', {
-                    localIds: localIds,
-                    locationRemark: that.addressesRemark,
-                    collectionItemId: that.collectionItemId,
-                    source: 'weixin',
-                  });
-                  // that.syncUpload(localIds);
+                  // that.$emit('newimgarr', {
+                  //   localIds: localIds,
+                  //   locationRemark: that.addressesRemark,
+                  //   collectionItemId: that.collectionItemId,
+                  //   source: 'weixin',
+                  // });
+                  that.syncUpload(localIds);
                 },
               });
             });
@@ -248,7 +248,7 @@ export default {
           isShowProgressTips: 1, // 默认为1,显示进度提示
           success: (res) => {
             this.localIdsArr.push(res.serverId);
-            // this.syncUpload(localIds);
+            this.syncUpload(localIds);
           },
         });
       }

+ 17 - 17
src/views/deviceOutside/suishenbangOutstoreVisit.vue

@@ -630,24 +630,24 @@ export default {
       localStorage.setItem('getRequestFlage', 'false');
       console.log(this.visitId);
       if (val.taskType == '5') {
-        getCljlaToDBLabel({ visitsId: this.visitId }).then((res) => {
-          if (res.code == 200) {
-            this.$router.push({
-              path: '/taskPhotoTaking',
-              query: {
-                storeCode: this.urlParameter.storeCode,
-                visitsId: this.visitId,
-                taskIds: val.taskIds.join(','),
-                storeGroupId: this.storeGroupId,
-                photoType: val.photoType,
-                insert: true,
-                storeId: this.storeId,
-              },
-            });
-          } else {
-            this.$toast(res.msg);
-          }
+        // getCljlaToDBLabel({ visitsId: this.visitId }).then((res) => {
+        //   if (res.code == 200) {
+        this.$router.push({
+          path: '/taskPhotoTaking',
+          query: {
+            storeCode: this.urlParameter.storeCode,
+            visitsId: this.visitId,
+            taskIds: val.taskIds.join(','),
+            storeGroupId: this.storeGroupId,
+            photoType: val.photoType,
+            insert: true,
+            storeId: this.storeId,
+          },
         });
+        //   } else {
+        //     this.$toast(res.msg);
+        //   }
+        // });
       } else {
         this.$router.push({
           path: '/addStoreVisit',

+ 17 - 17
src/views/deviceWithin/storeVisit.vue

@@ -791,24 +791,24 @@ export default {
         }, 2000);
         localStorage.setItem('getRequestFlage', 'false');
         if (val.taskType == '5') {
-          getCljlaToDBLabel({ visitsId: this.visitId }).then((res) => {
-            if (res.code == 200) {
-              this.$router.push({
-                path: '/taskPhotoTaking',
-                query: {
-                  storeCode: this.urlParameter.storeCode,
-                  visitsId: this.visitId,
-                  taskIds: val.taskIds.join(','),
-                  storeGroupId: this.storeGroupId,
-                  photoType: val.photoType,
-                  insert: this.insert,
-                  storeId: this.storeId,
-                },
-              });
-            } else {
-              this.$toast(res.msg);
-            }
+          // getCljlaToDBLabel({ visitsId: this.visitId }).then((res) => {
+          //   if (res.code == 200) {
+          this.$router.push({
+            path: '/taskPhotoTaking',
+            query: {
+              storeCode: this.urlParameter.storeCode,
+              visitsId: this.visitId,
+              taskIds: val.taskIds.join(','),
+              storeGroupId: this.storeGroupId,
+              photoType: val.photoType,
+              insert: this.insert,
+              storeId: this.storeId,
+            },
           });
+          //   } else {
+          //     this.$toast(res.msg);
+          //   }
+          // });
         } else {
           this.$router.push({
             path: '/addStoreVisit',

+ 4 - 19
src/views/deviceWithin/taskPhotoTaking.vue

@@ -42,6 +42,7 @@
                 </template>
               </van-cell>
               <deleteUploadImgTaskPhoto
+                :imgs="item.fileInfoList"
                 ref="taskPhoto"
                 :formData="formData"
                 :storeGroupId="storeGroupId"
@@ -292,7 +293,6 @@ export default {
     },
     onSubmit() {
       this.toastLoading(0, '提交中,请稍候...', true);
-      const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
       let formData = {
         storeId: this.$route.query.storeId,
         storeCode: this.$route.query.storeCode,
@@ -305,24 +305,8 @@ export default {
         deviceCode: '',
         putInCode: '',
         equipmentCode: '',
-        collectionItemId: taskPhoto ? taskPhoto.collectionItemId : '',
-        objectType: this.$route.query.photoType,
-        locationRemark: taskPhoto ? taskPhoto.locationRemark : '',
-        mediaInfos: [],
-        isH5: this.userInfo.photoMethod == '1',
       };
-      if (this.userInfo.photoMethod == '1') {
-        formData.mediaInfos = [];
-        this.addCollection(formData);
-      } else {
-        this.mediaInfos = [];
-        let imgArr = JSON.parse(JSON.stringify(taskPhoto.imgArr));
-        this.syncUpload(imgArr, () => {
-          this.toastLoading().clear();
-          formData.mediaInfos = this.mediaInfos;
-          this.addCollection(formData);
-        });
-      }
+      this.addCollection(formData);
     },
     syncUpload(imgArr, callback) {
       if (!imgArr.length) {
@@ -349,7 +333,8 @@ export default {
       }
     },
     addCollection(formData) {
-      return addCollectionAnswerBatch(formData).then((res) => {
+      addCollectionAnswerBatch(formData).then((res) => {
+        this.toastLoading().clear();
         if (res.code == 200) {
           localStorage.setItem('getRequestFlage', 'true');
           this.$router.go(-1);