Browse Source

Merge branch 'feature_20260330_拜访连拍速度优化' into uat(dev)

zhujindu 2 weeks ago
parent
commit
4e453a7e87

+ 39 - 10
src/components/deleteUploadImgTaskPhoto.vue

@@ -19,10 +19,10 @@
             ref="uploadVNormal" />
         </div>
       </van-col>
-      <van-col span="6" v-for="(id, index) in imgArr" :key="index">
+      <van-col span="6" v-for="(urls, index) in imgArr" :key="index">
         <div class="imgview">
           <van-icon v-if="insert == '1'" name="close" size="16" v-on:click="deleteImg(index)" />
-          <img :src="id" width="100px" height="100px" @click="previewsImg(index)" />
+          <img :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)" />
           <!-- <img
             v-else
             :src="urls.fileUrl"
@@ -96,7 +96,7 @@ export default {
   watch: {
     imgs: {
       handler(val) {
-        this.imgArr = val || [];
+        if (val) this.imgArr = val;
       },
       deep: true,
       immediate: true,
@@ -106,6 +106,8 @@ export default {
     return {
       url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
       imgArr: [],
+      mediaIds: [],
+      locationRemark: '',
     };
   },
   methods: {
@@ -113,21 +115,48 @@ export default {
       this.imgArr.splice(index, 1);
     },
     previewsImg(index) {
+      let urls = this.imgArr.map((item) => item.serverId);
       ImagePreview({
-        images: this.imgArr,
+        images: urls,
         startPosition: index,
       });
     },
-    newimgarr(localIds) {
-      if (this.isIOS()) {
-        this.imgArr = this.imgArr.concat([...localIds]);
-        // 解决ios微信localId无法直接使用的问题,获取base64后再上传
-        // this.setIosImg(localIds);
+    newimgarr(data) {
+      const { localIds, locationRemark, source } = data;
+      this.locationRemark = locationRemark;
+      if (source == 'weixin') {
+        this.syncUpload(localIds);
       } else {
-        this.imgArr = this.imgArr.concat([...localIds]);
+        this.$emit('upDataDetail');
       }
+      // if (this.isIOS()) {
+      //   this.imgArr = this.imgArr.concat([...localIds]);
+      //   // 解决ios微信localId无法直接使用的问题,获取base64后再上传
+      //   // this.setIosImg(localIds);
+      // } else {
+      //   this.imgArr = this.imgArr.concat([...localIds]);
+      // }
       // this.$emit('upDataDetail');
     },
+    syncUpload(localIds, callback) {
+      if (!localIds.length) {
+        callback && callback();
+        return;
+      } else {
+        var localId = localIds.pop();
+        wx.uploadImage({
+          localId: localId,
+          isShowProgressTips: 1, // 默认为1,显示进度提示
+          success: (res) => {
+            this.imgArr.push({
+              mediaId: res.serverId,
+              fileUrl: localId,
+            });
+            this.syncUpload(localIds, callback);
+          },
+        });
+      }
+    },
     isIOS() {
       return /iPhone|iPad|iPod/i.test(navigator.userAgent);
     },

+ 7 - 1
src/components/uploadVNormalTaskPhoto.vue

@@ -219,7 +219,12 @@ export default {
                 success: function (res) {
                   let localIds = res.localIds;
                   that.localIdsArr = [];
-                  that.$emit('newimgarr', localIds);
+                  that.$emit('newimgarr', {
+                    localIds: localIds,
+                    locationRemark: that.addressesRemark,
+                    collectionItemId: that.collectionItemId,
+                    source: 'weixin',
+                  });
                   // that.syncUpload(localIds);
                 },
               });
@@ -336,6 +341,7 @@ export default {
       this.$emit('newimgarr', {
         fileInfoList: fileInfoList,
         photoIdentifyType: this.photoIdentifyType,
+        source: 'H5',
       });
     },
     // 照片是否入库,1.照片识别三次不通过仍要上传,2.照片识别通过

+ 14 - 8
src/views/deviceWithin/taskPhotoTaking.vue

@@ -144,6 +144,7 @@ export default {
       taskPhotoRecognitionResult: null,
       spanArr: [],
       pos: 0,
+      mediaIds: [],
     };
   },
   activated() {
@@ -240,15 +241,20 @@ export default {
         deviceCode: '',
         putInCode: '',
         equipmentCode: '',
+        collectionItemId: this.$refs.taskPhoto[0].collectionItemId, //	是	string	采集项id
+        objectType: this.$route.query.photoType, //	是	string	照片类型,取任务上的照片类型,如果没有则取手动选择的照片类型
+        locationRemark: this.$refs.taskPhoto[0].locationRemark, //	是	String	当前地址信息
+        mediaInfos: this.$refs.taskPhoto[0].imgArr,
       };
-      console.log(this.$refs.taskPhoto);
-      console.log(this.$refs.taskPhoto.imgArr);
-      // addCollectionAnswerBatch(formData).then((res) => {
-      //   if (res.code == 200) {
-      //     localStorage.setItem('getRequestFlage', 'true');
-      //     this.$router.go(-1);
-      //   }
-      // });
+      this.addCollection(formData);
+    },
+    addCollection(formData) {
+      addCollectionAnswerBatch(formData).then((res) => {
+        if (res.code == 200) {
+          localStorage.setItem('getRequestFlage', 'true');
+          this.$router.go(-1);
+        }
+      });
     },
     onClickLeft() {
       this.$router.go(-1);