From 84a14c24edf92f7072e50b51ee37143d658ecfd4 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 11 三月 2025 14:28:09 +0800
Subject: [PATCH] 项目库展示总年度投资金额

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

diff --git a/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue b/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue
index de37951..9e69851 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,26 +60,42 @@
     },
   },
   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();
     }
+
+    this.documentsInfoForm.projectId = this.projectForm.id;
   },
   beforeDestroy() {
-    Cookies.set("documentsInfoForm", JSON.stringify(this.documentsInfoForm));
+    if(Object.keys(this.documentsInfoForm).length !==0) localStorage.setItem("documentsInfoForm", JSON.stringify(this.documentsInfoForm));
   },
+  watch: {
+    documentsInfoForm:{
+      deep: true,
+      handler(newVal) {
+        this.$emit('documentsInfoForm', newVal)
+      }
+    },
+    fileList: {
+      deep: true,
+      handler(newVal) {
+        this.documentsInfoForm.fileList = newVal
+      }
+    }
+  }
 
 };
 </script>

--
Gitblit v1.8.0