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 |   85 +++++++++++++++++++++++++++++++-----------
 1 files changed, 63 insertions(+), 22 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue b/src/views/projectEngineering/projectLibrary/component/DocumentsInfo.vue
index f599c38..9e69851 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,72 @@
   },
   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();
+    }
+
+    this.documentsInfoForm.projectId = this.projectForm.id;
+  },
+  beforeDestroy() {
+    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
       }
     }
-  },
-
-  mounted() {
   }
+
 };
 </script>
 

--
Gitblit v1.8.0