From eb2a77ad38d79b2370dbfe213bdd5ace02f94c4d Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期五, 29 十一月 2024 09:12:59 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue | 69 +++++++++++++++++++++++----------- 1 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue b/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue index f599c38..43b95c1 100644 --- a/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue +++ b/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue @@ -1,14 +1,14 @@ <template> <div class="policy-info"> - <el-form ref="demoFormRef" :disabled="disabled" :model="fileIdList" class="dialog_form"> + <el-form ref="demoFormRef" :disabled="disabled" :model="documentsInfoForm" class="dialog_form"> <el-row :gutter="0"> <el-col :span="20"> <el-form-item label="闄勪欢:" label-width="100px" prop="appendix" style="width: 100%"> <div style="display: flex;gap: 10px"> - <file-upload v-model="documentsInfoList" + <file-upload v-model="fileList" :fileType="accept" :isShowTip="false"/> - <div v-if="documentsInfoList.length === 0" style="color: #a9afbc">鏀寔涓婁紶PDF鏍煎紡鏂囦欢</div> + <div v-if="fileList.length === 0" style="color: #a9afbc">鏀寔涓婁紶PDF鏍煎紡鏂囦欢</div> </div> </el-form-item> </el-col> @@ -18,6 +18,8 @@ </template> <script> + +import {addDocumentInfo, getDocumentInfoById} from "@/api/projectEngineering/projectInfo"; export default { props: { @@ -29,33 +31,56 @@ }, data() { return { - fileIdList: [], - documentsInfoList: [], - accept: ['pdf', 'docx', 'xlsx', 'jpg','jpeg'], + documentsInfoForm: { + // fileList: [], + // projectId: '' + }, + fileList: [], + projectForm: {}, + accept: ['pdf'], }; }, - watch: { - // 鐩戝惉 documentsInfoList 鐨勫彉鍖栵紝骞舵洿鏂� fileIdList - documentsInfoList(newVal) { - this.fileIdList = newVal.map(item => item.fileId); - } - }, methods: { - handleRemove(file) { - if (file) { - this.fileIdList = this.documentsInfoList.map(item => item.fileId); - localStorage.setItem('fileIdList', JSON.stringify(file)); + getDocumentsInfo() { + getDocumentInfoById(this.$route.query.projectId).then(res => { + this.documentsInfoForm = res.data; + this.fileList = this.documentsInfoForm.fileList + }); + }, + submit() { + if (!this.projectForm.id) { + this.$message.error("璇峰厛淇濆瓨鎶曡祫绠$悊鍩烘湰淇℃伅") + } else { + this.documentsInfoForm.projectId = this.projectForm.id; + this.documentsInfoForm.fileList = this.fileList + addDocumentInfo(this.documentsInfoForm).then(response => { + this.$modal.msgSuccess("鎻愪氦鎴愬姛"); + }); } }, - handleAdd(file) { - if (file && file.length > 0) { - localStorage.setItem('fileIdList', JSON.stringify(file)); - } + }, + mounted() { + const documentsInfoForm = localStorage.getItem("documentsInfoForm"); + const projectForm = localStorage.getItem("projectForm"); + + const parsedDocumentsInfoForm = documentsInfoForm ? JSON.parse(documentsInfoForm) : null; + const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null; + if (parsedDocumentsInfoForm) { + this.documentsInfoForm = parsedDocumentsInfoForm + if(this.documentsInfoForm.fileList) this.fileList = this.documentsInfoForm.fileList + } + if (parsedProjectForm) { + this.projectForm = parsedProjectForm + } + // 濡傛灉璺敱瀛樺湪id涓旀病鏈夌紦瀛�,瑙嗕负缂栬緫鎴栨煡鐪嬶紝璋冪敤api + if (this.$route.query.projectId && !parsedDocumentsInfoForm) { + this.getDocumentsInfo(); } }, + beforeDestroy() { + if(Object.keys(this.documentsInfoForm).length !==0) localStorage.setItem("documentsInfoForm", JSON.stringify(this.documentsInfoForm)); + }, - mounted() { - } }; </script> -- Gitblit v1.8.0