소스 검색

no message

zhujindu 4 시간 전
부모
커밋
9b27398319
2개의 변경된 파일31개의 추가작업 그리고 120개의 파일을 삭제
  1. 28 103
      src/components/deleteUploadImgTaskPhoto.vue
  2. 3 17
      src/views/deviceWithin/taskPhotoTaking.vue

+ 28 - 103
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,99 +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) {
+      removePhotoBatch({ fileIdList: fileIdList.split(',') }).then((res) => {
+        if (res.code == 200) {
+          this.$toast('删除成功!');
+          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) {
+    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>

+ 3 - 17
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,
@@ -307,22 +307,8 @@ export default {
         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 +335,7 @@ export default {
       }
     },
     addCollection(formData) {
-      return addCollectionAnswerBatch(formData).then((res) => {
+      addCollectionAnswerBatch(formData).then((res) => {
         if (res.code == 200) {
           localStorage.setItem('getRequestFlage', 'true');
           this.$router.go(-1);