commit
This commit is contained in:
+4
-1
@@ -71,7 +71,10 @@ public class ProposalWriteController {
|
|||||||
@ApiOperation("保存提案")
|
@ApiOperation("保存提案")
|
||||||
@SLog(tag = "提案管理系统-我的提案", msg = "保存提案")
|
@SLog(tag = "提案管理系统-我的提案", msg = "保存提案")
|
||||||
public Result save(@Param("info") ProposalInfo proposalInfo) {
|
public Result save(@Param("info") ProposalInfo proposalInfo) {
|
||||||
if (StrUtil.isBlank(proposalInfo.getCode())) {
|
// 保存草稿允许表单未填完整,只有具备生成编号所需信息时才生成提案编号。
|
||||||
|
if (StrUtil.isBlank(proposalInfo.getCode())
|
||||||
|
&& StrUtil.isNotBlank(proposalInfo.getSessionId())
|
||||||
|
&& StrUtil.isNotBlank(proposalInfo.getDelegationId())) {
|
||||||
proposalInfo.setCode(proposalWriteService.generateProposalCode(proposalInfo.getSessionId(), proposalInfo.getDelegationId()));
|
proposalInfo.setCode(proposalWriteService.generateProposalCode(proposalInfo.getSessionId(), proposalInfo.getDelegationId()));
|
||||||
}
|
}
|
||||||
dao.insertOrUpdate(proposalInfo);
|
dao.insertOrUpdate(proposalInfo);
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="h5-file-upload">
|
||||||
|
<div v-if="upload_mode === 'file' && fileList.length" class="h5-file-list">
|
||||||
|
<div class="h5-file-item" v-for="(file, index) in fileList" :key="file.url || file.name || index">
|
||||||
|
<van-icon name="description" class="h5-file-icon"></van-icon>
|
||||||
|
<div class="h5-file-name van-ellipsis">{{ getFileDisplayName(file) }}</div>
|
||||||
|
<van-icon name="cross" class="h5-file-delete" @click.stop="deleteFile(index)"></van-icon>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<van-uploader
|
<van-uploader
|
||||||
v-model="fileList"
|
v-model="fileList"
|
||||||
:before-read="beforeRead"
|
:before-read="beforeRead"
|
||||||
:after-read="afterRead"
|
:after-read="afterRead"
|
||||||
:before-delete="beforeDelete"
|
:before-delete="beforeDelete"
|
||||||
|
:preview-image="upload_mode !== 'file'"
|
||||||
multiple
|
multiple
|
||||||
progress
|
progress
|
||||||
:accept="accept"
|
:accept="accept"
|
||||||
@@ -142,6 +150,15 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 文件模式使用自定义预览格,优先展示上传时记录的原始文件名。
|
||||||
|
getFileDisplayName(file) {
|
||||||
|
return file.displayName || file.originalName || file.name || (file.file ? file.file.name : "") || ""
|
||||||
|
},
|
||||||
|
// 自定义预览格删除后同步父组件,避免表单继续提交已删除附件。
|
||||||
|
deleteFile(index) {
|
||||||
|
this.fileList.splice(index, 1)
|
||||||
|
this.$emit("update:value", this.fileList)
|
||||||
|
},
|
||||||
beforeDelete(file) {
|
beforeDelete(file) {
|
||||||
this.fileList = this.fileList.filter((f) => f.url !== file.url)
|
this.fileList = this.fileList.filter((f) => f.url !== file.url)
|
||||||
this.$emit("update:value", this.fileList)
|
this.$emit("update:value", this.fileList)
|
||||||
@@ -178,33 +195,43 @@ module.exports = {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
this.$toast(`文件只能是 ${this.accept} 格式!`)
|
this.$toast("文件只能是 " + this.accept + " 格式!")
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
afterRead(files) {
|
afterRead(files) {
|
||||||
this.fileList.map((f) => {
|
const readFiles = Array.isArray(files) ? files : [files]
|
||||||
if (f.file && f.file.name === files.file.name) {
|
const uploadPromises = readFiles
|
||||||
f.status = "loading"
|
.filter((f) => f.file)
|
||||||
}
|
|
||||||
})
|
|
||||||
const uploadPromises = this.fileList
|
|
||||||
.filter((f) => f.status === "loading")
|
|
||||||
.map((f) => {
|
.map((f) => {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append("file", f.file)
|
formData.append("file", f.file)
|
||||||
|
this.$set(f, "status", "loading")
|
||||||
return this.$axios.post(this.action, formData).then((resp) => {
|
return this.$axios.post(this.action, formData).then((resp) => {
|
||||||
if (resp.code === 0) {
|
if (resp.code === 0) {
|
||||||
f.name = f.file.name
|
const fileName = f.file.name
|
||||||
f.size = f.file.size
|
const fileExt = fileName.split(".").pop().toLowerCase()
|
||||||
f.status = null
|
let fileIndex = this.fileList.indexOf(f)
|
||||||
f.url = resp.data
|
if (fileIndex === -1) {
|
||||||
f.response = resp
|
fileIndex = this.fileList.findIndex((item) => {
|
||||||
f.percentage = 100
|
return item.file && item.file.name === fileName && item.file.size === f.file.size
|
||||||
f.isImage = true
|
})
|
||||||
delete f.file
|
}
|
||||||
delete f.content
|
const uploadFile = {
|
||||||
|
displayName: fileName,
|
||||||
|
originalName: fileName,
|
||||||
|
name: fileName,
|
||||||
|
size: f.file.size,
|
||||||
|
status: null,
|
||||||
|
url: resp.data,
|
||||||
|
response: resp,
|
||||||
|
percentage: 100,
|
||||||
|
isImage: ["jpg", "jpeg", "png", "gif", "bmp", "webp"].includes(fileExt)
|
||||||
|
}
|
||||||
|
if (fileIndex > -1) {
|
||||||
|
this.$set(this.fileList, fileIndex, uploadFile)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
f.status = "fail"
|
this.$set(f, "status", "fail")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -241,4 +268,47 @@ module.exports = {
|
|||||||
.van-uploader__wrapper {
|
.van-uploader__wrapper {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.h5-file-upload {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h5-file-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h5-file-item {
|
||||||
|
position: relative;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
padding: 14px 6px 8px;
|
||||||
|
color: #646566;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #f7f8fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h5-file-icon {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h5-file-name {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h5-file-delete {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: 2px;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 12px;
|
||||||
|
background-color: rgba(0, 0, 0, .65);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+7
-14
@@ -219,21 +219,14 @@ layout("/layouts/platform.html"){
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async onSave() {
|
async onSave() {
|
||||||
const valid = await this.$refs["addForm"].validate()
|
// 保存草稿不做必填校验,提交时再统一校验完整表单。
|
||||||
if (valid) {
|
this.$axios.post("/platform/proposal/write/save", {info: JSON.stringify(this.formData)}).then((res) => {
|
||||||
if (!this.formData.name || this.formData.name.trim().length < 1) {
|
if (res.code === 0) {
|
||||||
this.$message.warning("请填写提案名称")
|
this.$message.success(res.msg)
|
||||||
return
|
this.formData = res.data
|
||||||
|
commonUtil.pjaxPush('/platform/proposal/mine')
|
||||||
}
|
}
|
||||||
|
})
|
||||||
this.$axios.post("/platform/proposal/write/save", {info: JSON.stringify(this.formData)}).then((res) => {
|
|
||||||
if (res.code === 0) {
|
|
||||||
this.$message.success(res.msg)
|
|
||||||
this.formData = res.data
|
|
||||||
commonUtil.pjaxPush('/platform/proposal/mine')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+18
-25
@@ -463,33 +463,26 @@ layout("/layouts/platform_h5.html"){
|
|||||||
},
|
},
|
||||||
|
|
||||||
async onSave() {
|
async onSave() {
|
||||||
// 表单验证
|
// 保存草稿不做必填校验,提交时再统一校验完整表单。
|
||||||
try {
|
this.$toast.loading({
|
||||||
await this.$refs.formRef.validate();
|
message: '保存中...',
|
||||||
|
forbidClick: true,
|
||||||
|
});
|
||||||
|
|
||||||
this.$toast.loading({
|
this.$axios.post("/platform/proposal/write/save", {info: JSON.stringify(this.formData)})
|
||||||
message: '保存中...',
|
.then((res) => {
|
||||||
forbidClick: true,
|
this.$toast.clear();
|
||||||
|
if (res.code === 0) {
|
||||||
|
this.$toast.success(res.msg);
|
||||||
|
pjaxReplace('/platform/proposal/mine/h5')
|
||||||
|
} else {
|
||||||
|
this.$toast.fail(res.msg || '保存失败');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.$toast.clear();
|
||||||
|
this.$toast.fail('网络错误,请稍后重试');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$axios.post("/platform/proposal/write/save", {info: JSON.stringify(this.formData)})
|
|
||||||
.then((res) => {
|
|
||||||
this.$toast.clear();
|
|
||||||
if (res.code === 0) {
|
|
||||||
this.$toast.success(res.msg);
|
|
||||||
pjaxReplace('/platform/proposal/mine/h5')
|
|
||||||
} else {
|
|
||||||
this.$toast.fail(res.msg || '保存失败');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
this.$toast.clear();
|
|
||||||
this.$toast.fail('网络错误,请稍后重试');
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
// 表单验证失败
|
|
||||||
console.log('表单验证失败', error);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
|
|||||||
Reference in New Issue
Block a user