zhujindu 1 тиждень тому
батько
коміт
9e79e0074a
1 змінених файлів з 73 додано та 66 видалено
  1. 73 66
      src/views/deviceWithin/taskPhotoTaking.vue

+ 73 - 66
src/views/deviceWithin/taskPhotoTaking.vue

@@ -3,7 +3,7 @@
     <van-nav-bar class="navBar" left-arrow title="生动化陈列" @click-left="onClickLeft">
       <template #right v-if="formData">
         <span
-          v-if="formData.processStatus != 1 || formData.displayRewardTaskEditable"
+          v-if="formData.processStatus != 1"
           @click="onSubmit"
           style="
             color: white;
@@ -42,6 +42,7 @@
                 </template>
               </van-cell>
               <deleteUploadImgTaskPhoto
+                :imgs="item.fileInfoList"
                 ref="taskPhoto"
                 :formData="formData"
                 :storeGroupId="storeGroupId"
@@ -75,14 +76,28 @@
             <div class="itemHtml" v-html="item.displayInstructions"></div>
           </div>
           <div class="itemBottom" v-if="insert == 'false'">
-            <img
+            <van-button
+              round
+              type="primary"
+              @click="openDialog(item)"
+              v-if="item.taskPhotoConditionPassed == 1"
+              >通过</van-button
+            >
+            <van-button
+              round
+              type="danger"
+              @click="openDialog(item)"
+              v-if="item.taskPhotoConditionPassed == 0"
+              >不通过</van-button
+            >
+            <!-- <img
               v-if="item.taskPhotoConditionPassed == 1"
               @click="openDialog(item)"
               :src="require('@/assets/taskPhotoSu.png')" />
             <img
               v-if="item.taskPhotoConditionPassed == 0"
               @click="openDialog(item)"
-              :src="require('@/assets/taskPhotoErr.png')" />
+              :src="require('@/assets/taskPhotoErr.png')" /> -->
           </div>
         </div>
       </div>
@@ -159,14 +174,21 @@ export default {
       pos: 0,
       mediaIds: [],
       editFlag: true,
+      mediaInfos: [],
     };
   },
   activated() {
+    if (this.formData && this.formData.collectionItemList && this.formData.collectionItemList[0]) {
+      this.formData.collectionItemList[0].fileInfoList = [];
+    }
     this.taskIds = this.$route.query.taskIds || [];
     this.visitsId = this.$route.query.visitsId || '';
     this.storeGroupId = this.$route.query.storeGroupId || '';
     this.objectType = this.$route.query.photoType || '';
     this.insert = this.$route.query.insert;
+    // 授权
+    // getTicketFun(['uploadImage']).then(() => {});
+    this.toastLoading(0, '加载中...', true);
     if (this.$route.query.source == 'historicalDetails') {
       this.getVisitsDetailFun();
     } else {
@@ -246,7 +268,6 @@ export default {
       }
     },
     getVisitsDetailFun() {
-      this.toastLoading(0, '加载中...', true);
       getVisitsDetail({ visitsId: this.visitsId }).then((res) => {
         this.toastLoading().clear();
         if (res.data.sfaTaskList) {
@@ -266,6 +287,7 @@ export default {
         id: this.visitsId,
         taskIds: this.taskIds.split(','),
       }).then((res) => {
+        this.toastLoading().clear();
         if (res.data && res.data.length) {
           this.dataList = res.data;
           this.formData = res.data[0];
@@ -276,13 +298,7 @@ export default {
       });
     },
     isEditFun() {
-      // processStatus 是否有权限编辑,displayRewardTaskEditable 只能编辑一次,
-      if (
-        (this.insert == 'false' && this.formData.processStatus != 1) ||
-        this.formData.displayRewardTaskEditable
-      ) {
-        this.getTicketFunfun();
-      }
+      // this.getTicketFunfun();
     },
     openDialog(item) {
       this.vanPopup = true;
@@ -293,57 +309,50 @@ export default {
         this.taskPhotoRecognitionResult = item.taskPhotoRecognitionResult;
       });
     },
-    waitUploadReady(interval = 1000) {
-      return new Promise((resolve) => {
-        const intervalId = setInterval(() => {
-          const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
-          if (taskPhoto && taskPhoto.isUploadImg) {
-            clearInterval(intervalId);
-            resolve();
-          }
-        }, interval);
-      });
-    },
-    async onSubmit() {
+    onSubmit() {
       this.toastLoading(0, '提交中,请稍候...', true);
-      try {
-        const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
-        if (taskPhoto && !taskPhoto.isUploadImg) {
-          await this.waitUploadReady(1000);
-        }
-
-        let formData = {
-          storeId: this.$route.query.storeId,
-          storeCode: this.$route.query.storeCode,
-          storeGroupId: this.$route.query.storeGroupId,
-          visitsId: this.visitsId,
-          taskList: this.taskIds.split(',').map((val) => Number(val)),
-          insert: this.insert,
-          collectionAnswers: [],
-          checkUnManage: 'N',
-          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 = [];
-        } else if (taskPhoto) {
-          formData.mediaInfos = taskPhoto.imgArr;
+      let formData = {
+        storeId: this.$route.query.storeId,
+        storeCode: this.$route.query.storeCode,
+        storeGroupId: this.$route.query.storeGroupId,
+        visitsId: this.visitsId,
+        taskList: this.taskIds.split(',').map((val) => Number(val)),
+        insert: this.insert,
+        collectionAnswers: [],
+        checkUnManage: 'N',
+        deviceCode: '',
+        putInCode: '',
+        equipmentCode: '',
+      };
+      this.addCollection(formData);
+    },
+    syncUpload(imgArr, callback) {
+      if (!imgArr.length) {
+        callback && callback();
+        return;
+      } else {
+        var item = imgArr.pop();
+        if (!item.mediaId) {
+          wx.uploadImage({
+            localId: item.mediaFileUrl,
+            isShowProgressTips: 0, // 默认为1,显示进度提示
+            success: (res) => {
+              this.mediaInfos.push({
+                mediaId: res.serverId,
+                mediaFileUrl: item.mediaFileUrl,
+              });
+              this.syncUpload(imgArr, callback);
+            },
+          });
+        } else {
+          this.mediaInfos.push(item);
+          this.syncUpload(imgArr, callback);
         }
-        await this.addCollection(formData);
-      } catch (err) {
-        this.$toast(err.message || '提交失败,请稍后再试');
-      } finally {
-        this.toastLoading().clear();
       }
     },
     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);
@@ -474,7 +483,7 @@ export default {
       }
       .itemBottom {
         align-items: center;
-        width: 35px;
+        width: 60px;
         margin-left: 5px;
         img {
           width: 100%;
@@ -492,14 +501,12 @@ export default {
 }
 </style>
 <style lang="scss">
-// .taskPhotoTaking {
-//   .itenHtml {
-//     overflow: hidden;
-//     img {
-//       width: 100%;
-//     }
-//   }
-// }
+.taskPhotoTaking {
+  .van-button--danger {
+    background-color: #ee0a24 !important;
+    border: 1px solid #ee0a24 !important;
+  }
+}
 .identifyResultdialog {
   width: vw(690) !important;
   margin-top: 1vh !important;