| | |
| | | </template> |
| | | |
| | | <script> |
| | | import Cookies from "js-cookie"; |
| | | import { |
| | | addProjectInvestmentInfo, |
| | | editProjectInvestmentInfo, |
| | |
| | | type: Boolean, |
| | | default: false, |
| | | required: true |
| | | } |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | projectForm: {}, |
| | | investmentForm: { |
| | | id: '', |
| | | beCrossRegion: '', |
| | | constructionLocation: '', |
| | | detailedAddress: '', |
| | | beCompensationProject: '', |
| | | compensationReason: '', |
| | | plannedStartDate: '', |
| | | expectedCompletionDate: '', |
| | | nationalIndustryClassification: '', |
| | | industryClassification: '', |
| | | projectNature: '', |
| | | projectAttribute: '', |
| | | useEarth: '', |
| | | contentScale: '', |
| | | code: '', |
| | | projectId: '', |
| | | // id: '', |
| | | // beCrossRegion: '', |
| | | // constructionLocation: '', |
| | | // detailedAddress: '', |
| | | // beCompensationProject: '', |
| | | // compensationReason: '', |
| | | // plannedStartDate: '', |
| | | // expectedCompletionDate: '', |
| | | // nationalIndustryClassification: '', |
| | | // industryClassification: '', |
| | | // projectNature: '', |
| | | // projectAttribute: '', |
| | | // useEarth: '', |
| | | // contentScale: '', |
| | | // code: '', |
| | | // projectId: '', |
| | | }, |
| | | plannedStartDate: '', |
| | | expectedCompletionDate: '', |
| | |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.investmentForm.projectId = this.$route.query.projectId |
| | | // 从Cookies中获取缓存数据 |
| | | const investmentForm = Cookies.get("investmentForm"); |
| | | const projectForm = Cookies.get("projectForm"); |
| | | const investmentForm = localStorage.getItem("investmentForm"); |
| | | const projectForm = localStorage.getItem("projectForm"); |
| | | |
| | | // 尝试解析JSON数据 |
| | | const parsedInvestmentForm = investmentForm ? JSON.parse(investmentForm) : null; |
| | | const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null; |
| | | |
| | | console.log(parsedInvestmentForm) |
| | | // 设置investment和projectForm对象 |
| | | if(parsedInvestmentForm) { |
| | | this.investmentForm = parsedInvestmentForm; |
| | |
| | | this.projectForm = parsedProjectForm; |
| | | } |
| | | // 如果路由存在id且没有缓存,视为编辑或查看,调用api |
| | | if (this.investmentForm.projectId && !investmentForm) { |
| | | if (this.$route.query.projectId && !investmentForm) { |
| | | this.getInvestment(); |
| | | }else { |
| | | this.investmentForm.constructionLocation = this.projectForm.area; |
| | | this.investmentForm.detailedAddress = this.projectForm.projectAddress; |
| | | this.investmentForm.plannedStartDate = this.projectForm.planStartTime; |
| | | this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime; |
| | | } |
| | | this.investmentForm.constructionLocation = this.projectForm.area; |
| | | this.investmentForm.detailedAddress = this.projectForm.projectAddress; |
| | | this.investmentForm.plannedStartDate = this.projectForm.planStartTime; |
| | | this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime; |
| | | }, |
| | | beforeDestroy() { |
| | | Cookies.set("investmentForm", JSON.stringify(this.investmentForm)); |
| | | if(Object.keys(this.investmentForm).length !==0) localStorage.setItem("investmentForm", JSON.stringify(this.investmentForm)); |
| | | }, |
| | | methods: { |
| | | getInvestment() { |
| | | getProjectInvestmentInfoById(this.investmentForm.projectId ).then(res => { |
| | | getProjectInvestmentInfoById(this.$route.query.projectId).then(res => { |
| | | this.investmentForm = res.data; |
| | | this.investmentForm.constructionLocation = this.projectForm.area; |
| | | this.investmentForm.detailedAddress = this.projectForm.projectAddress; |
| | | this.investmentForm.plannedStartDate = this.projectForm.planStartTime; |
| | | this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime; |
| | | this.$nextTick(() => { |
| | | this.investmentForm.constructionLocation = this.projectForm.area; |
| | | this.investmentForm.detailedAddress = this.projectForm.projectAddress; |
| | | this.investmentForm.plannedStartDate = this.projectForm.planStartTime; |
| | | this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime; |
| | | }) |
| | | }); |
| | | }, |
| | | submit() { |
| | |
| | | this.$message.error("请先保存投资管理基本信息") |
| | | } else { |
| | | this.investmentForm.projectId = this.projectForm.id; |
| | | if (this.investmentForm.id != null) { |
| | | if (this.investmentForm.id) { |
| | | editProjectInvestmentInfo(this.investmentForm).then(response => { |
| | | this.$modal.msgSuccess("修改成功"); |
| | | //跳转到下个组件 |