|
@@ -182,6 +182,7 @@
|
|
disFlag: true, // 启用动态获取处理单位则设置为false
|
|
disFlag: true, // 启用动态获取处理单位则设置为false
|
|
showFlag: false,
|
|
showFlag: false,
|
|
isProcessing: false, // 遮罩层
|
|
isProcessing: false, // 遮罩层
|
|
|
|
+ uploadFlag: true, // 上传判定值
|
|
processingUnits: [],
|
|
processingUnits: [],
|
|
fileList1: [],
|
|
fileList1: [],
|
|
fileList2: [],
|
|
fileList2: [],
|
|
@@ -281,7 +282,6 @@
|
|
watch: {
|
|
watch: {
|
|
},
|
|
},
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
- console.log('options',options)
|
|
|
|
// 从 options 中获取 id 参数
|
|
// 从 options 中获取 id 参数
|
|
this.showFlag = options.showFlag;
|
|
this.showFlag = options.showFlag;
|
|
this.id = options.id;
|
|
this.id = options.id;
|
|
@@ -411,6 +411,10 @@
|
|
|
|
|
|
let errors = [];
|
|
let errors = [];
|
|
|
|
|
|
|
|
+ if(!this.uploadFlag){
|
|
|
|
+ errors.push("图片未上传完成,请等待上传完后在提交")
|
|
|
|
+ }
|
|
|
|
+
|
|
if (this.fileList1 && this.fileList1.length > 0) {
|
|
if (this.fileList1 && this.fileList1.length > 0) {
|
|
// 将 fileList1 中的每个文件对象的属性名调整为新的属性名
|
|
// 将 fileList1 中的每个文件对象的属性名调整为新的属性名
|
|
this.inputForm.fileList1 = this.fileList1.map(file => {
|
|
this.inputForm.fileList1 = this.fileList1.map(file => {
|
|
@@ -433,6 +437,7 @@
|
|
duration: 2000
|
|
duration: 2000
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+ this.isProcessing = false;
|
|
reject('Form validation failed');
|
|
reject('Form validation failed');
|
|
} else {
|
|
} else {
|
|
// 所有验证通过,执行保存操作
|
|
// 所有验证通过,执行保存操作
|
|
@@ -468,6 +473,13 @@
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
+ let errors = [];
|
|
|
|
+
|
|
|
|
+ if(!this.uploadFlag){
|
|
|
|
+ errors.push("图片未上传完成,请等待上传完后在提交")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
if (this.fileList2 && this.fileList2.length > 0) {
|
|
if (this.fileList2 && this.fileList2.length > 0) {
|
|
// 将 fileList1 中的每个文件对象的属性名调整为新的属性名
|
|
// 将 fileList1 中的每个文件对象的属性名调整为新的属性名
|
|
this.inputForm.fileList2 = this.fileList2.map(file => {
|
|
this.inputForm.fileList2 = this.fileList2.map(file => {
|
|
@@ -493,32 +505,46 @@
|
|
};
|
|
};
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- //数据保存
|
|
|
|
- this.$refs.inputForm.validate().then(() => {
|
|
|
|
- uni.showLoading();
|
|
|
|
|
|
|
|
- overService.savePhoto(this.inputForm).then(data => {
|
|
|
|
- EventBus.$emit('refreshPhoto');
|
|
|
|
|
|
+ if (errors.length > 0) {
|
|
|
|
+ // 存在错误,显示提示信息
|
|
|
|
+ errors.forEach(error => {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title: "提交成功",
|
|
|
|
- icon: "success",
|
|
|
|
- duration: 1000 // 提示持续时间为1秒(1000毫秒)
|
|
|
|
|
|
+ title: error,
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
});
|
|
});
|
|
|
|
+ });
|
|
|
|
+ this.isProcessing = false;
|
|
|
|
+ reject('Form validation failed');
|
|
|
|
+ } else {
|
|
|
|
+ //数据保存
|
|
|
|
+ this.$refs.inputForm.validate().then(() => {
|
|
|
|
+ uni.showLoading();
|
|
|
|
|
|
- // 延迟1秒后再跳转到上一页
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.isProcessing = false; // 显示遮罩层
|
|
|
|
- resolve('Form saved successfully');
|
|
|
|
- uni.navigateBack({
|
|
|
|
- delta: 1
|
|
|
|
|
|
+ overService.savePhoto(this.inputForm).then(data => {
|
|
|
|
+ EventBus.$emit('refreshPhoto');
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "提交成功",
|
|
|
|
+ icon: "success",
|
|
|
|
+ duration: 1000 // 提示持续时间为1秒(1000毫秒)
|
|
});
|
|
});
|
|
- }, 1000);
|
|
|
|
- }).catch(error => {
|
|
|
|
- reject('Save operation failed');
|
|
|
|
|
|
+
|
|
|
|
+ // 延迟1秒后再跳转到上一页
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.isProcessing = false; // 显示遮罩层
|
|
|
|
+ resolve('Form saved successfully');
|
|
|
|
+ uni.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ });
|
|
|
|
+ }, 1000);
|
|
|
|
+ }).catch(error => {
|
|
|
|
+ reject('Save operation failed');
|
|
|
|
+ });
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ reject('Form validation failed');
|
|
});
|
|
});
|
|
- }).catch(() => {
|
|
|
|
- reject('Form validation failed');
|
|
|
|
- });
|
|
|
|
|
|
+ }
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
@@ -528,29 +554,36 @@
|
|
},
|
|
},
|
|
// 新增图片
|
|
// 新增图片
|
|
async afterRead(event) {
|
|
async afterRead(event) {
|
|
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
|
- let lists = [].concat(event.file)
|
|
|
|
- let fileListLen = this[`fileList${event.name}`].length
|
|
|
|
- lists.map((item) => {
|
|
|
|
- this[`fileList${event.name}`].push({
|
|
|
|
- ...item,
|
|
|
|
- status: 'uploading',
|
|
|
|
- message: '上传中'
|
|
|
|
|
|
+ try {
|
|
|
|
+ this.uploadFlag = false
|
|
|
|
+ // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
|
+ let lists = [].concat(event.file)
|
|
|
|
+ let fileListLen = this[`fileList${event.name}`].length
|
|
|
|
+ lists.map((item) => {
|
|
|
|
+ this[`fileList${event.name}`].push({
|
|
|
|
+ ...item,
|
|
|
|
+ status: 'uploading',
|
|
|
|
+ message: '上传中'
|
|
|
|
+ })
|
|
})
|
|
})
|
|
- })
|
|
|
|
- for (let i = 0; i < lists.length; i++) {
|
|
|
|
- const result = await this.uploadFilePromise(lists[i].url, fileListLen)
|
|
|
|
- let item = this[`fileList${event.name}`][fileListLen]
|
|
|
|
- this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
|
|
|
|
- status: 'success',
|
|
|
|
- message: '',
|
|
|
|
- url: result
|
|
|
|
- }))
|
|
|
|
- fileListLen++
|
|
|
|
|
|
+ for (let i = 0; i < lists.length; i++) {
|
|
|
|
+ const result = await this.uploadFilePromise(lists[i].url, fileListLen)
|
|
|
|
+ let item = this[`fileList${event.name}`][fileListLen]
|
|
|
|
+ this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
|
|
|
|
+ status: 'success',
|
|
|
|
+ message: '',
|
|
|
|
+ url: result
|
|
|
|
+ }))
|
|
|
|
+ fileListLen++
|
|
|
|
+ }
|
|
|
|
+ this.uploadFlag = true
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('上传失败:', error);
|
|
|
|
+ } finally {
|
|
|
|
+ this.uploadFlag = true
|
|
}
|
|
}
|
|
},
|
|
},
|
|
uploadFilePromise(url, index) {
|
|
uploadFilePromise(url, index) {
|
|
- console.log($auth.getUserToken())
|
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
let a = uni.uploadFile({
|
|
let a = uni.uploadFile({
|
|
url: 'http://localhost:8000/app/file/webUpload/fileUpload', // 仅为示例,非真实的接口地址
|
|
url: 'http://localhost:8000/app/file/webUpload/fileUpload', // 仅为示例,非真实的接口地址
|
|
@@ -579,7 +612,6 @@
|
|
})
|
|
})
|
|
},
|
|
},
|
|
getOfficeOnHamlet(value){
|
|
getOfficeOnHamlet(value){
|
|
- console.log('getOfficeOnHamlet:',value)
|
|
|
|
// 根据组织ID 获取 该村的 村支书
|
|
// 根据组织ID 获取 该村的 村支书
|
|
overService.getUserInfoByOffId(value)
|
|
overService.getUserInfoByOffId(value)
|
|
.then(data => {
|
|
.then(data => {
|