|
|
@@ -235,38 +235,69 @@ export default {
|
|
|
this.taskPhotoRecognitionResult = item.taskPhotoRecognitionResult;
|
|
|
});
|
|
|
},
|
|
|
- onSubmit() {
|
|
|
- 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: true,
|
|
|
- collectionAnswers: [],
|
|
|
- checkUnManage: 'N',
|
|
|
- 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: [],
|
|
|
- isH5: this.userInfo.photoMethod == '1' ? true : false, // 是否H5拍照 1:是;0:否
|
|
|
- };
|
|
|
- // 0=企业微信,1=H5相机
|
|
|
- if (this.userInfo.photoMethod == '1') {
|
|
|
- formData.mediaInfos = [];
|
|
|
- } else {
|
|
|
- formData.mediaInfos = this.$refs.taskPhoto[0].imgArr;
|
|
|
+ waitUploadReady(timeout = 60000, interval = 300) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const start = Date.now();
|
|
|
+ const check = () => {
|
|
|
+ const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
|
|
|
+ if (taskPhoto && taskPhoto.isUploadImg) {
|
|
|
+ resolve();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (Date.now() - start >= timeout) {
|
|
|
+ reject(new Error('图片上传超时,请稍后再试'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ setTimeout(check, interval);
|
|
|
+ };
|
|
|
+ check();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async onSubmit() {
|
|
|
+ this.toastLoading(0, '提交中,请稍候...', true);
|
|
|
+ try {
|
|
|
+ const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
|
|
|
+ if (taskPhoto && !taskPhoto.isUploadImg) {
|
|
|
+ await this.waitUploadReady(120000, 400);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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: true,
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ await this.addCollection(formData);
|
|
|
+ } catch (err) {
|
|
|
+ this.$toast(err.message || '提交失败,请稍后再试');
|
|
|
+ } finally {
|
|
|
+ this.toastLoading().clear();
|
|
|
}
|
|
|
- this.addCollection(formData);
|
|
|
},
|
|
|
addCollection(formData) {
|
|
|
- addCollectionAnswerBatch(formData).then((res) => {
|
|
|
+ return addCollectionAnswerBatch(formData).then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
localStorage.setItem('getRequestFlage', 'true');
|
|
|
this.$router.go(-1);
|
|
|
+ } else {
|
|
|
+ this.$toast('提交失败,请重试');
|
|
|
}
|
|
|
});
|
|
|
},
|