Przeglądaj źródła

Merge branch 'feature_20250708_主管任务照片批量上传' into release

zhujindu 4 miesięcy temu
rodzic
commit
ce262784b3

+ 63 - 34
src/components/uploadVTask.vue

@@ -56,11 +56,17 @@ export default {
       type: Boolean,
       default: false,
     },
+    item: {
+      type: Object,
+      default: {},
+    },
   },
   data() {
     return {
       shows: false,
       url: '',
+      addressesRemark: '',
+      localIdsArr: [],
     };
   },
   methods: {
@@ -72,7 +78,7 @@ export default {
       let that = this;
       let wx = this.wx;
       let qiyeData;
-      let addressesRemark = '';
+      this.addressesRemark = '';
       var map = new TMap.Map('allmap', {
         zoom: 14,
         center: new TMap.LatLng(39.986785, 116.301012),
@@ -119,10 +125,10 @@ export default {
                   geocoder.getAddress({ location: location }).then(
                     function (result) {
                       var addresses = result.result.formatted_addresses;
-                      addressesRemark = addresses.recommend;
+                      that.addressesRemark = addresses.recommend;
                     },
                     function (err) {
-                      addressesRemark = '';
+                      that.addressesRemark = '';
                     }
                   );
                 },
@@ -133,42 +139,53 @@ export default {
                 },
               });
               wx.chooseImage({
-                count: 1,
+                count: 5,
                 sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
                 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
                 defaultCameraMode: 'normal', //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
                 isSaveToAlbum: 0,
                 success: function (res) {
-                  var localIds = '';
-                  if (res.localIds != undefined) {
-                    localIds = res.localIds[0];
-                  } else {
-                    localIds = res.localId;
-                  }
+                  let localIds = res.localIds;
                   // andriod中localId可以作为img标签的src属性显示图片;
                   // iOS应当使用 getLocalImgData 获取图片base64数据,从而用于img标签的显示(在img标签内使用 wx.chooseImage 的 localid 显示可能会不成功)
-                  wx.uploadImage({
-                    localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
-                    isShowProgressTips: 1, // 默认为1,显示进度提示
-                    success: function (res) {
-                      that.uploadImagev(res.serverId, addressesRemark);
-                    },
-                  });
+                  that.localIdsArr = [];
+                  that.syncUpload(localIds);
+                  // wx.uploadImage({
+                  //   localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
+                  //   isShowProgressTips: 1, // 默认为1,显示进度提示
+                  //   success: function (res) {
+                  //     that.uploadImagev(res.serverId, addressesRemark);
+                  //   },
+                  // });
                 },
               });
             });
           }
         });
     },
-    uploadImagev(meidaId, addressesRemark) {
-      var that = this;
+    syncUpload(localIds) {
+      if (!localIds.length) {
+        this.uploadImagev(this.localIdsArr);
+      } else {
+        var localId = localIds.pop();
+        wx.uploadImage({
+          localId: localId,
+          isShowProgressTips: 1, // 默认为1,显示进度提示
+          success: (res) => {
+            this.localIdsArr.push(res.serverId);
+            this.syncUpload(localIds);
+          },
+        });
+      }
+    },
+    uploadImagev(meidaIds) {
       var form = {
-        mediaId: meidaId,
-        customId: that.customId,
-        summaryId: that.summaryId,
-        locationRemark: addressesRemark,
+        mediaIds: meidaIds,
+        customId: this.customId,
+        summaryId: this.summaryId,
+        locationRemark: this.addressesRemark,
       };
-      var loind1 = that.$toast.loading({
+      var loind1 = this.$toast.loading({
         duration: 0,
         message: '上传中...',
         forbidClick: true,
@@ -179,19 +196,31 @@ export default {
       }
       addPhotov(form).then((res) => {
         if (res.code == 200) {
-          that.imgArr = res.data.url;
+          // that.imgArr = res.data.url;
           loind1.clear();
-          that.$toast('上传成功!');
-          that.$emit('newimgarr', {
-            fileUrl: res.data.url,
-            id: res.data.fileId,
-            fileType: res.fileType,
-            fileName: res.fileName,
-            type: that.type,
-            index: that.indexImg,
+          this.$toast('上传成功!');
+          let urlArr = [];
+          let idArr = [];
+          res.data.forEach((val) => {
+            urlArr.push({
+              fileUrl: val.url,
+              id: val.fileId,
+              // fileType: val.fileType,
+              // fileName: val.fileName,
+              type: this.type,
+              index: this.indexImg,
+            });
+            idArr.push(val.fileId);
           });
+          if (this.item.fileInfoList == null || this.item.fileInfoList == undefined) {
+            this.item.fileInfoList = [];
+            this.item.fileIdList = [];
+          }
+          this.item.fileInfoList = this.item.fileInfoList.concat(urlArr);
+          this.item.fileIdList = this.item.fileIdList.concat(idArr);
+          this.$emit('newimgarr');
         } else {
-          that.$toast('上传失败!');
+          this.$toast('上传失败!');
         }
       });
     },

+ 3 - 10
src/views/week/SUPTaskApproval/detailItem.vue

@@ -59,6 +59,7 @@
               :customId="item.customId"
               :summaryId="item.summaryId"
               :allowWriteAgain="false"
+              :item="item"
               @click="imgClick(item, index)"></upload-img>
           </van-row>
         </div>
@@ -370,16 +371,8 @@ export default {
       this.indeximg = index;
       this.show = true;
     },
-    newimgarr1(val) {
-      if (
-        this.collectionItemList[val.index].fileInfoList == null ||
-        this.collectionItemList[val.index].fileInfoList == undefined
-      ) {
-        this.collectionItemList[val.index].fileInfoList = [];
-        this.collectionItemList[val.index].fileIdList = [];
-      }
-      this.collectionItemList[val.index].fileInfoList.push(val);
-      this.collectionItemList[val.index].fileIdList.push(val.id);
+    newimgarr1() {
+      this.$forceUpdate();
     },
     dateFn(val) {
       return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);

+ 12 - 10
src/views/week/VisitSummaryAdd.vue

@@ -66,6 +66,7 @@
                 :indexImg="index"
                 :customId="item.customId"
                 :summaryId="item.summaryId"
+                :item="item"
                 @click="imgClick(item, index)"></upload-img>
             </van-row>
           </div>
@@ -449,16 +450,17 @@ export default {
       this.indeximg = index;
       this.show = true;
     },
-    newimgarr1(val) {
-      if (
-        this.collectionItemList[val.index].fileInfoList == null ||
-        this.collectionItemList[val.index].fileInfoList == undefined
-      ) {
-        this.collectionItemList[val.index].fileInfoList = [];
-        this.collectionItemList[val.index].fileIdList = [];
-      }
-      this.collectionItemList[val.index].fileInfoList.push(val);
-      this.collectionItemList[val.index].fileIdList.push(val.id);
+    newimgarr1() {
+      this.$forceUpdate();
+      // if (
+      //   this.collectionItemList[val.index].fileInfoList == null ||
+      //   this.collectionItemList[val.index].fileInfoList == undefined
+      // ) {
+      //   this.collectionItemList[val.index].fileInfoList = [];
+      //   this.collectionItemList[val.index].fileIdList = [];
+      // }
+      // this.collectionItemList[val.index].fileInfoList.push(val);
+      // this.collectionItemList[val.index].fileIdList.push(val.id);
     },
     dateFn(val) {
       return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);

+ 3 - 10
src/views/week/allowWriteAgainSummary.vue

@@ -64,6 +64,7 @@
               :customId="item.customId"
               :summaryId="item.summaryId"
               :allowWriteAgain="item.allowWriteAgain"
+              :item="item"
               @click="imgClick(item, index)"></upload-img>
           </van-row>
         </div>
@@ -416,16 +417,8 @@ export default {
       this.indeximg = index;
       this.show = true;
     },
-    newimgarr1(val) {
-      if (
-        this.collectionItemList[val.index].fileInfoList == null ||
-        this.collectionItemList[val.index].fileInfoList == undefined
-      ) {
-        this.collectionItemList[val.index].fileInfoList = [];
-        this.collectionItemList[val.index].fileIdList = [];
-      }
-      this.collectionItemList[val.index].fileInfoList.push(val);
-      this.collectionItemList[val.index].fileIdList.push(val.id);
+    newimgarr1() {
+      this.$forceUpdate();
     },
     dateFn(val) {
       return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);

+ 3 - 10
src/views/week/componVisitSummary.vue

@@ -52,6 +52,7 @@
               :indexImg="index"
               :customId="item.customId"
               :summaryId="item.summaryId"
+              :item="item"
               @click="imgClick(item, index)"></upload-img>
           </van-row>
         </div>
@@ -437,16 +438,8 @@ export default {
       this.indeximg = index;
       this.show = true;
     },
-    newimgarr1(val) {
-      if (
-        this.collectionItemList[val.index].fileInfoList == null ||
-        this.collectionItemList[val.index].fileInfoList == undefined
-      ) {
-        this.collectionItemList[val.index].fileInfoList = [];
-        this.collectionItemList[val.index].fileIdList = [];
-      }
-      this.collectionItemList[val.index].fileInfoList.push(val);
-      this.collectionItemList[val.index].fileIdList.push(val.id);
+    newimgarr1() {
+      this.$forceUpdate();
     },
     dateFn(val) {
       return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);