web端职代会管理: 修复congress_materials职代会资料文件的fileType,fileSize字段为空的问题;
This commit is contained in:
+88
-10
@@ -53,7 +53,7 @@ layout("/layouts/platform.html"){
|
||||
</el-card>
|
||||
|
||||
<el-dialog :title="formData.id ? '编辑投票' : '新增投票'" :visible.sync="dialogFormVisible"
|
||||
width="850px" :close-on-click-modal="false">
|
||||
width="880px" :close-on-click-modal="false">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
@@ -77,11 +77,27 @@ layout("/layouts/platform.html"){
|
||||
<el-input v-model.trim="formData.name" maxlength="255" show-word-limit></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="资料" prop="materialsId">
|
||||
<el-select v-model="formData.materialsId" filterable style="width:100%"
|
||||
:disabled="!formData.sessionId || !formData.typeId">
|
||||
<el-option v-for="item in materialOptions" :key="item.id"
|
||||
:label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="17">
|
||||
<el-select v-model="formData.materialsId" filterable style="width:100%"
|
||||
:disabled="materialUploadDisabled">
|
||||
<el-option v-for="item in materialOptions" :key="item.id"
|
||||
:label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="7">
|
||||
<el-upload action="/platform/sys/file/uploadDynamicReturnUrl" :show-file-list="false"
|
||||
:disabled="materialUploadDisabled || materialUploadLoading"
|
||||
:before-upload="beforeMaterialUpload"
|
||||
:on-success="uploadMaterialSuccess"
|
||||
:on-error="uploadMaterialError"
|
||||
accept=".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx">
|
||||
<el-button type="primary" icon="el-icon-upload" style="width:100%"
|
||||
:loading="materialUploadLoading"
|
||||
:disabled="materialUploadDisabled || materialUploadLoading">上传资料</el-button>
|
||||
</el-upload>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
@@ -157,6 +173,8 @@ layout("/layouts/platform.html"){
|
||||
sessionOptions: [],
|
||||
typeOptions: [],
|
||||
materialOptions: [],
|
||||
materialUploadLoading: false,
|
||||
materialLoadSeq: 0,
|
||||
voteItems: [],
|
||||
pageForm: {pageNumber: 1, pageSize: 10, totalCount: 0, sessionId: "", name: ""},
|
||||
formData: {},
|
||||
@@ -172,7 +190,10 @@ layout("/layouts/platform.html"){
|
||||
},
|
||||
computed: {
|
||||
voteTypeOptions() {
|
||||
return this.typeOptions.filter(v => !!v.isVote)
|
||||
return this.typeOptions.filter(v => Number(v.isVote) === 1)
|
||||
},
|
||||
materialUploadDisabled() {
|
||||
return !this.formData.sessionId || !this.formData.typeId
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -188,20 +209,77 @@ layout("/layouts/platform.html"){
|
||||
if (typesRes.code === 0) this.typeOptions = typesRes.data || []
|
||||
},
|
||||
async loadMaterials() {
|
||||
const seq = ++this.materialLoadSeq
|
||||
this.materialOptions = []
|
||||
if (!this.formData.sessionId || !this.formData.typeId) return
|
||||
const res = await this.$axios.post("/platform/congress/materials/issue/materials", {
|
||||
sessionId: this.formData.sessionId,
|
||||
typeId: this.formData.typeId
|
||||
})
|
||||
if (res.code === 0) this.materialOptions = res.data || []
|
||||
if (seq === this.materialLoadSeq && res.code === 0) this.materialOptions = res.data || []
|
||||
},
|
||||
getUploadedUrl(res) {
|
||||
if (!res) return ""
|
||||
if (typeof res === "string") return res
|
||||
return res.data || res.url || res.fileUrl || res.path || res.filePath || ""
|
||||
},
|
||||
fileNameWithoutExt(name) {
|
||||
return name ? String(name).replace(/\.[^/.]+$/, "") : ""
|
||||
},
|
||||
fileExtension(name) {
|
||||
const fileName = String(name || "")
|
||||
const index = fileName.lastIndexOf(".")
|
||||
return index >= 0 ? fileName.substring(index + 1).toLowerCase() : ""
|
||||
},
|
||||
beforeMaterialUpload(file) {
|
||||
if (this.materialUploadDisabled) {
|
||||
this.$message.warning("请先选择届次和投票类型")
|
||||
return false
|
||||
}
|
||||
this.materialUploadLoading = true
|
||||
return true
|
||||
},
|
||||
async uploadMaterialSuccess(response, file) {
|
||||
const fileUrl = this.getUploadedUrl(response)
|
||||
if (!fileUrl) {
|
||||
this.materialUploadLoading = false
|
||||
this.$message.error(response && response.msg ? response.msg : "上传资料失败")
|
||||
return
|
||||
}
|
||||
const fileName = file.name || "附件"
|
||||
try {
|
||||
const res = await this.$axios.post("/platform/congress/materials/issue/uploadMaterial", {
|
||||
sessionId: this.formData.sessionId,
|
||||
typeId: this.formData.typeId,
|
||||
name: this.fileNameWithoutExt(fileName),
|
||||
fileName: fileName,
|
||||
fileUrl: fileUrl,
|
||||
fileType: this.fileExtension(fileName),
|
||||
fileSize: file.raw && file.raw.size ? file.raw.size : ""
|
||||
})
|
||||
if (res.code === 0) {
|
||||
await this.loadMaterials()
|
||||
this.formData.materialsId = res.data && res.data.id ? res.data.id : res.data
|
||||
this.$message.success("上传资料成功")
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
} finally {
|
||||
this.materialUploadLoading = false
|
||||
}
|
||||
},
|
||||
uploadMaterialError() {
|
||||
this.materialUploadLoading = false
|
||||
this.$message.error("上传资料失败")
|
||||
},
|
||||
async sessionChanged() {
|
||||
this.formData.materialsId = ""
|
||||
this.materialOptions = []
|
||||
await this.loadMaterials()
|
||||
},
|
||||
async typeChanged() {
|
||||
this.formData.materialsId = ""
|
||||
this.materialOptions = []
|
||||
await this.loadMaterials()
|
||||
},
|
||||
addVoteItem() {
|
||||
@@ -262,7 +340,7 @@ layout("/layouts/platform.html"){
|
||||
const res = await this.$axios.post("/platform/congress/materials/issue/save", data)
|
||||
if (res.code === 0) {
|
||||
this.dialogFormVisible = false
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("保存成功")
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
@@ -276,7 +354,7 @@ layout("/layouts/platform.html"){
|
||||
this.$confirm("确认删除该投票议题吗?", "提示", {type: "warning"}).then(async () => {
|
||||
const res = await this.$axios.post("/platform/congress/materials/issue/delete", {id})
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("删除成功")
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
|
||||
+8
-3
@@ -160,6 +160,11 @@ layout("/layouts/platform.html"){
|
||||
fileNameWithoutExt(name) {
|
||||
return name ? String(name).replace(/\.[^/.]+$/, "") : ""
|
||||
},
|
||||
fileExtension(name) {
|
||||
const fileName = String(name || "")
|
||||
const index = fileName.lastIndexOf(".")
|
||||
return index >= 0 ? fileName.substring(index + 1).toLowerCase() : ""
|
||||
},
|
||||
getUploadFileUrl(file) {
|
||||
return file && file.response && file.response.data ? file.response.data : file && (file.url || file.data) || ""
|
||||
},
|
||||
@@ -175,7 +180,7 @@ layout("/layouts/platform.html"){
|
||||
const fileName = file.name || this.fileNameFromUrl(this.getUploadFileUrl(file))
|
||||
this.$set(this.formData, "fileName", fileName)
|
||||
this.$set(this.formData, "fileUrl", this.getUploadFileUrl(file))
|
||||
this.$set(this.formData, "fileType", file.raw && file.raw.type ? file.raw.type : file.type || "")
|
||||
this.$set(this.formData, "fileType", this.fileExtension(fileName))
|
||||
this.$set(this.formData, "fileSize", file.raw && file.raw.size ? file.raw.size : file.size || "")
|
||||
if (!this.formData.name && fileName) {
|
||||
this.$set(this.formData, "name", this.fileNameWithoutExt(fileName))
|
||||
@@ -190,7 +195,7 @@ layout("/layouts/platform.html"){
|
||||
const res = await this.$axios.post("/platform/congress/materials/manage/save", this.formData)
|
||||
if (res.code === 0) {
|
||||
this.dialogFormVisible = false
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("保存成功")
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
@@ -204,7 +209,7 @@ layout("/layouts/platform.html"){
|
||||
this.$confirm("确认删除该会议资料吗?", "提示", {type: "warning"}).then(async () => {
|
||||
const res = await this.$axios.post("/platform/congress/materials/manage/delete", {id})
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("删除成功")
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
|
||||
+2
-2
@@ -98,7 +98,7 @@ layout("/layouts/platform.html"){
|
||||
const res = await this.$axios.post("/platform/congress/materials/type/save", this.formData)
|
||||
if (res.code === 0) {
|
||||
this.dialogFormVisible = false
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("保存成功")
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
@@ -112,7 +112,7 @@ layout("/layouts/platform.html"){
|
||||
this.$confirm("确认删除该资料类型吗?", "提示", {type: "warning"}).then(async () => {
|
||||
const res = await this.$axios.post("/platform/congress/materials/type/delete", {id})
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("删除成功")
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
|
||||
@@ -129,7 +129,7 @@ layout("/layouts/platform.html"){
|
||||
const res = await this.$axios.post("/platform/congress/signIn/save", this.formData)
|
||||
if (res.code === 0) {
|
||||
this.dialogFormVisible = false
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("保存成功")
|
||||
this.pageData()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
@@ -143,7 +143,7 @@ layout("/layouts/platform.html"){
|
||||
this.$confirm("确认删除该会议签到配置吗?", "提示", {type: "warning"}).then(async () => {
|
||||
const res = await this.$axios.post("/platform/congress/signIn/delete", {id})
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.$message.success("删除成功")
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
|
||||
Reference in New Issue
Block a user