From b1c351f8a0d16008524d4f17bb1948f836f5a7b0 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期四, 28 十一月 2024 17:02:47 +0800 Subject: [PATCH] 项目库增改 --- src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue | 82 +++++++++++++++++++++++++++------------- 1 files changed, 55 insertions(+), 27 deletions(-) diff --git a/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue b/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue index fd71b70..de37951 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="documentsInfoForm.fileList" :fileType="accept" :isShowTip="false"/> - <div v-if="documentsInfoList.length === 0" style="color: #a9afbc">鏀寔涓婁紶PDF鏍煎紡鏂囦欢</div> + <div v-if="documentsInfoForm.fileList.length === 0" style="color: #a9afbc">鏀寔涓婁紶PDF鏍煎紡鏂囦欢</div> </div> </el-form-item> </el-col> @@ -18,6 +18,14 @@ </template> <script> + +import { + addProjectInvestmentFunding, + editProjectInvestmentFunding, + getProjectInvestmentFundingById +} from "@/api/projectEngineering/projectInvestmentFunding"; +import Cookies from "js-cookie"; +import {addDocumentInfo, getDocumentInfoById} from "@/api/projectEngineering/projectInfo"; export default { props: { @@ -29,36 +37,56 @@ }, data() { return { - fileIdList: [], - documentsInfoList: [], - accept: ['pdf', 'docx', 'xlsx', 'jpg','jpeg'], + documentsInfoForm: { + fileList: [], + projectId: '' + }, + projectForm: {}, + accept: ['pdf'], }; }, - watch: { - // 鐩戝惉 documentsInfoList 鐨勫彉鍖栵紝骞舵洿鏂� fileIdList - documentsInfoList(newVal) { - this.fileIdList = newVal.map(item => item.fileId); + methods: { + getDocumentsInfo() { + getDocumentInfoById(this.documentsInfoForm.projectId).then(res => { + this.documentsInfoForm = res.data; + if(!this.documentsInfoForm.fileList) { + this.documentsInfoForm.fileList = [] + } + }); + }, + submit() { + if (!this.projectForm.id) { + this.$message.error("璇峰厛淇濆瓨鎶曡祫绠$悊鍩烘湰淇℃伅") + } else { + this.documentsInfoForm.projectId = this.projectForm.id; + addDocumentInfo(this.documentsInfoForm).then(response => { + this.$modal.msgSuccess("鎻愪氦鎴愬姛"); + }); + } + }, + }, + mounted() { + this.documentsInfoForm.projectId = this.$route.query.projectId; + const documentsInfoForm = Cookies.get("documentsInfoForm"); + const projectForm = Cookies.get("projectForm"); + + const parsedDocumentsInfoForm = documentsInfoForm ? JSON.parse(documentsInfoForm) : null; + const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null; + if (parsedDocumentsInfoForm) { + this.documentsInfoForm = parsedDocumentsInfoForm + } + if (parsedProjectForm) { + this.projectForm = parsedProjectForm + } + // 濡傛灉璺敱瀛樺湪id涓旀病鏈夌紦瀛�,瑙嗕负缂栬緫鎴栨煡鐪嬶紝璋冪敤api + if (this.documentsInfoForm.projectId && !parsedDocumentsInfoForm) { + this.getDocumentsInfo(); } }, - methods: { - submit() { - console.log("鏂囦欢submit") - }, - handleRemove(file) { - if (file) { - this.fileIdList = this.documentsInfoList.map(item => item.fileId); - localStorage.setItem('fileIdList', JSON.stringify(file)); - } - }, - handleAdd(file) { - if (file && file.length > 0) { - localStorage.setItem('fileIdList', JSON.stringify(file)); - } - } + beforeDestroy() { + Cookies.set("documentsInfoForm", JSON.stringify(this.documentsInfoForm)); }, - mounted() { - } }; </script> -- Gitblit v1.8.0