From 7adbf0551f6a6b307e66cdd6537ab45fc5a2bf11 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期五, 29 十一月 2024 04:00:10 +0800
Subject: [PATCH] bug修复和页面查询

---
 src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue |   32 +++++++++++++-------------------
 1 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue b/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue
index de37951..43b95c1 100644
--- a/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue
+++ b/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue
@@ -5,10 +5,10 @@
         <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="documentsInfoForm.fileList"
+              <file-upload v-model="fileList"
                            :fileType="accept"
                            :isShowTip="false"/>
-              <div v-if="documentsInfoForm.fileList.length === 0" style="color: #a9afbc">鏀寔涓婁紶PDF鏍煎紡鏂囦欢</div>
+              <div v-if="fileList.length === 0" style="color: #a9afbc">鏀寔涓婁紶PDF鏍煎紡鏂囦欢</div>
             </div>
           </el-form-item>
         </el-col>
@@ -19,12 +19,6 @@
 
 <script>
 
-import {
-  addProjectInvestmentFunding,
-  editProjectInvestmentFunding,
-  getProjectInvestmentFundingById
-} from "@/api/projectEngineering/projectInvestmentFunding";
-import Cookies from "js-cookie";
 import {addDocumentInfo, getDocumentInfoById} from "@/api/projectEngineering/projectInfo";
 
 export default {
@@ -38,20 +32,19 @@
   data() {
     return {
       documentsInfoForm: {
-        fileList: [],
-        projectId: ''
+        // fileList: [],
+        // projectId: ''
       },
+      fileList: [],
       projectForm: {},
       accept: ['pdf'],
     };
   },
   methods: {
     getDocumentsInfo() {
-      getDocumentInfoById(this.documentsInfoForm.projectId).then(res => {
+      getDocumentInfoById(this.$route.query.projectId).then(res => {
         this.documentsInfoForm = res.data;
-        if(!this.documentsInfoForm.fileList) {
-          this.documentsInfoForm.fileList = []
-        }
+        this.fileList = this.documentsInfoForm.fileList
       });
     },
     submit() {
@@ -59,6 +52,7 @@
         this.$message.error("璇峰厛淇濆瓨鎶曡祫绠$悊鍩烘湰淇℃伅")
       } else {
         this.documentsInfoForm.projectId = this.projectForm.id;
+        this.documentsInfoForm.fileList = this.fileList
         addDocumentInfo(this.documentsInfoForm).then(response => {
           this.$modal.msgSuccess("鎻愪氦鎴愬姛");
         });
@@ -66,25 +60,25 @@
     },
   },
   mounted() {
-    this.documentsInfoForm.projectId = this.$route.query.projectId;
-    const documentsInfoForm = Cookies.get("documentsInfoForm");
-    const projectForm = Cookies.get("projectForm");
+    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.documentsInfoForm.projectId && !parsedDocumentsInfoForm) {
+    if (this.$route.query.projectId && !parsedDocumentsInfoForm) {
       this.getDocumentsInfo();
     }
   },
   beforeDestroy() {
-    Cookies.set("documentsInfoForm", JSON.stringify(this.documentsInfoForm));
+    if(Object.keys(this.documentsInfoForm).length !==0) localStorage.setItem("documentsInfoForm", JSON.stringify(this.documentsInfoForm));
   },
 
 };

--
Gitblit v1.8.0