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/PolicyInfo.vue | 80 ++++++++++++++++++++++++++-------------- 1 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue b/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue index 815c2dc..3840fb5 100644 --- a/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue +++ b/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue @@ -10,10 +10,10 @@ <el-col :span="20"> <el-form-item label="绗﹀悎琛屼笟鏀跨瓥:" label-width="180px" prop="industryPolicy" style="width: 100%"> <div style="display: flex"> - <file-upload v-model="policyInfoForm.fileList" + <file-upload v-model="fileList" :fileType="accept" :isShowTip="false"/> - <div v-if="policyInfoForm.fileList.length === 0" style="color: #a9afbc; margin-left: 10px"> + <div v-if="fileList.length === 0" style="color: #a9afbc; margin-left: 10px"> 鏀寔涓婁紶PDF鏍煎紡鏂囦欢 </div> </div> @@ -159,12 +159,12 @@ <script> -import Cookies from "js-cookie"; import { addProjectInvestmentPolicyCompliance, editProjectInvestmentPolicyCompliance, getProjectInvestmentPolicyComplianceById } from "@/api/projectEngineering/projectInvestmentPolicyCompliance"; +import {newline} from "js-beautify/js/src/javascript/acorn"; export default { name: 'PolicyComplianceForm', @@ -173,25 +173,27 @@ type: Boolean, default: false, required: true - } + }, }, data() { return { + projectForm: {}, policyInfoForm: { - id: '', - projectId: '', - fileList: [], - belongsToIndustryAdjustmentDirectory: null, - belongsToWesternEncouragedDirectory: null, - notBannedOrControlledProject: true, - informationIsTrue: true, - specialPlanningCompliance: '', - energyCheck: null, - annualEnergyConsumption: '', - annualElectricityConsumption: '', - noOnlyCheckType: null, - remarks: '' + // id: '', + // projectId: '', + // fileList: [], + // belongsToIndustryAdjustmentDirectory: null, + // belongsToWesternEncouragedDirectory: null, + // notBannedOrControlledProject: true, + // informationIsTrue: true, + // specialPlanningCompliance: '', + // energyCheck: null, + // annualEnergyConsumption: '', + // annualElectricityConsumption: '', + // noOnlyCheckType: null, + // remarks: '' }, + fileList: [], accept: ['pdf'], rules: { industrialPolicyProhibition: [{required: true, message: '璇烽�夋嫨', trigger: 'change'}], @@ -200,35 +202,42 @@ }; }, mounted() { - this.policyInfoForm.projectId = this.$route.query.projectId; - const policyInfoForm = Cookies.get("policyInfoForm"); - const projectForm = Cookies.get("projectForm"); + const policyInfoForm = localStorage.getItem("policyInfoForm"); + const projectForm = localStorage.getItem("projectForm"); const parsedPolicyInfoForm = policyInfoForm ? JSON.parse(policyInfoForm) : null; const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null; if (parsedPolicyInfoForm) { this.policyInfoForm = parsedPolicyInfoForm + if(this.policyInfoForm.fileList) this.fileList = this.policyInfoForm.fileList } if (parsedProjectForm) { this.projectForm = parsedProjectForm } // 濡傛灉璺敱瀛樺湪id涓旀病鏈夌紦瀛�,瑙嗕负缂栬緫鎴栨煡鐪嬶紝璋冪敤api - if (this.policyInfoForm.projectId && !parsedPolicyInfoForm) { + if (this.$route.query.projectId && !parsedPolicyInfoForm) { this.getProjectInvestmentPolicyCompliance(); + } else { + this.policyInfoForm.informationIsTrue= true; + this.policyInfoForm.notBannedOrControlledProject = true; } + + this.policyInfoForm.projectId = this.projectForm.id; }, beforeDestroy() { - Cookies.set("policyInfoForm", JSON.stringify(this.policyInfoForm)); + if(Object.keys(this.policyInfoForm).length !==0) localStorage.setItem("policyInfoForm", JSON.stringify(this.policyInfoForm)); }, methods: { getProjectInvestmentPolicyCompliance() { - getProjectInvestmentPolicyComplianceById(this.policyInfoForm.projectId).then(res => { + getProjectInvestmentPolicyComplianceById(this.$route.query.projectId).then(res => { this.policyInfoForm = res.data; - if(!this.policyInfoForm.fileList) { - this.policyInfoForm.fileList = [] + this.policyInfoForm.notBannedOrControlledProject = true + this.policyInfoForm.informationIsTrue = true + if (this.policyInfoForm.fileList) { + this.fileList = this.policyInfoForm.fileList + } else { + this.fileList = [] } - this.policyInfoForm.notBannedOrControlledProject =true - this.policyInfoForm.informationIsTrue =true }); }, submit() { @@ -238,7 +247,8 @@ this.$refs["policyInfoFormRef"].validate(valid => { if (valid) { this.policyInfoForm.projectId = this.projectForm.id; - if (this.policyInfoForm.id != null) { + this.policyInfoForm.fileList = this.fileList + if (this.policyInfoForm.id) { editProjectInvestmentPolicyCompliance(this.policyInfoForm).then(response => { this.$modal.msgSuccess("淇敼鎴愬姛"); //璺宠浆鍒颁笅涓粍浠� @@ -257,6 +267,20 @@ } } }, + watch: { + policyInfoForm: { + deep: true, + handler(newVal) { + this.$emit('policyInfoForm', newVal) + } + }, + fileList: { + deep: true, + handler(newVal) { + this.policyInfoForm.fileList = newVal + } + } + } }; </script> -- Gitblit v1.8.0