|
@@ -152,6 +152,7 @@ export default {
|
|
|
spanArr: [],
|
|
spanArr: [],
|
|
|
pos: 0,
|
|
pos: 0,
|
|
|
mediaIds: [],
|
|
mediaIds: [],
|
|
|
|
|
+ mediaInfos: [],
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
activated() {
|
|
activated() {
|
|
@@ -255,40 +256,53 @@ export default {
|
|
|
},
|
|
},
|
|
|
async onSubmit() {
|
|
async onSubmit() {
|
|
|
this.toastLoading(0, '提交中,请稍候...', true);
|
|
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: 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();
|
|
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ this.mediaInfos = [];
|
|
|
|
|
+ this.syncUpload(taskPhoto.imgArr, () => {
|
|
|
|
|
+ this.toastLoading().clear();
|
|
|
|
|
+ formData.mediaInfos = this.mediaInfos;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ await this.addCollection(formData);
|
|
|
|
|
+ },
|
|
|
|
|
+ syncUpload(imgArr, callback) {
|
|
|
|
|
+ if (!imgArr.length) {
|
|
|
|
|
+ this.isUploadImg = true;
|
|
|
|
|
+ callback && callback();
|
|
|
|
|
+ return;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var item = imgArr.pop();
|
|
|
|
|
+ wx.uploadImage({
|
|
|
|
|
+ localId: item.mediaFileUrl,
|
|
|
|
|
+ isShowProgressTips: 0, // 默认为1,显示进度提示
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ this.mediaInfos.push({
|
|
|
|
|
+ mediaId: res.serverId,
|
|
|
|
|
+ mediaFileUrl: item.mediaFileUrl,
|
|
|
|
|
+ });
|
|
|
|
|
+ this.syncUpload(localIds, callback);
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
addCollection(formData) {
|
|
addCollection(formData) {
|