<template>
|
<el-card class="card-container">
|
<div class="flex-container mb-4">
|
<el-tabs v-model="currentTab" @tab-click="handleClick">
|
<el-tab-pane
|
v-for="item in TABS_DATA"
|
:key="item.value"
|
:label="item.label"
|
:name="item.value"
|
>
|
<template slot-scope="item">
|
<div class="tab-label">{{ item.label }}</div>
|
</template>
|
</el-tab-pane>
|
</el-tabs>
|
</div>
|
<component
|
:is="componentName"
|
ref="childRef"
|
:disabled="disabled"
|
class="full-width custom-height"
|
/>
|
<div v-if="!disabled" class="button-container">
|
<el-button class="save-button" type="primary" @click="submit">保存</el-button>
|
<el-button class="reset-button" @click="reset">重置</el-button>
|
<!-- <el-button v-else class="cancel-button" @click="cancel">取消</el-button> -->
|
</div>
|
</el-card>
|
</template>
|
|
<script>
|
import BasicInfo from '@/views/projectEngineering/projectLibrary/component/BasicInfo';
|
import InvestInfo from '@/views/projectEngineering/projectLibrary/component/InvestInfo';
|
import InvestmentFunds from '@/views/projectEngineering/projectLibrary/component/investmentFunds';
|
import LegalPerson from '@/views/projectEngineering/projectLibrary/component/legalPerson';
|
import PolicyInfo from '@/views/projectEngineering/projectLibrary/component/PolicyInfo';
|
import DocumentsInfo from '@/views/projectEngineering/projectLibrary/component/DocumentsInfo';
|
import { addProject, getProject, updateProject, getProjectCode } from '@/api/projectInfo';
|
|
export default {
|
data() {
|
return {
|
currentTab: '项目管理基础信息',
|
id: this.$route.query.id || '',
|
disabled: false,
|
componentName: BasicInfo,
|
TABS_DATA: [
|
{
|
label: '项目管理基础信息',
|
value: '项目管理基础信息',
|
componentName: BasicInfo
|
},
|
{
|
label: '投资管理基础信息',
|
value: '任务下发',
|
componentName: InvestInfo
|
},
|
{
|
label: ' 项目投资及资金来源',
|
value: '项目投资及资金来源',
|
componentName: InvestmentFunds
|
},
|
{
|
label: '项目(法人)单位登记信息',
|
value: '项目(法人)单位登记信息',
|
componentName: LegalPerson
|
},
|
{
|
label: '投资项目产业政策符合情况',
|
value: '投资项目产业政策符合情况',
|
componentName: PolicyInfo
|
},
|
{
|
label: '相关文书',
|
value: '相关文书',
|
componentName: DocumentsInfo
|
}
|
],
|
childRef: null,
|
};
|
},
|
methods: {
|
handleClick(tabTarget) {
|
this.componentName = this.TABS_DATA[tabTarget.index].componentName;
|
},
|
submit() {
|
if (!this.projectForm.projectName) {
|
this.$message.error('请输入项目名称');
|
return;
|
}
|
if (this.projectForm.contact) {
|
const phoneRegex = /^1[3-9]\d{9}$/;
|
if (!phoneRegex.test(this.projectForm.contact)) {
|
this.$message.error('请输入正确的手机号码');
|
return;
|
}
|
}
|
if (this.$refs.childRef) {
|
this.$refs.childRef.$refs.demoFormRef.validate((valid) => {
|
if (valid) {
|
const payload = {
|
projectInfoInsertDTO: this.projectForm,
|
projectInvestmentInfo: this.investment,
|
projectInvestmentFunding: this.investmentFunds,
|
projectUnitRegistrationInfo: this.legalPerson,
|
investmentProjectPolicyComplianceDTO: this.investmentProjectPolicyComplianceDTO,
|
fileIdList: this.fileIdList
|
};
|
if (this.id) {
|
updateProject(payload).then(res => {
|
if (res.code === 200) {
|
this.$message.success(res.msg);
|
this.$router.push({ path: '/projectEngineering/project/projectLibrary' });
|
} else {
|
this.$message.error(res.msg);
|
}
|
});
|
} else {
|
addProject(payload).then(res => {
|
if (res.code === 200) {
|
this.$message.success(res.msg);
|
this.$router.push({ path: '/projectEngineering/project/projectLibrary' });
|
} else {
|
this.$message.error(res.msg);
|
}
|
});
|
}
|
}
|
});
|
}
|
},
|
getProjectInfo(id) {
|
getProject(id, 0).then(res => {
|
if (res.data) {
|
this.investment = res.data.projectInvestmentInfo || {};
|
this.investmentFunds = res.data.projectInvestmentFunding || {};
|
this.legalPerson = res.data.projectUnitRegistrationInfo || {};
|
this.investmentProjectPolicyComplianceDTO = res.data.investmentProjectPolicyComplianceDTO || {};
|
if (res.data.investmentProjectPolicyComplianceDTO && res.data.investmentProjectPolicyComplianceDTO.sysOssVos.length > 0) {
|
this.fileList = res.data.investmentProjectPolicyComplianceDTO.sysOssVos.map(item => ({
|
fileId: item.ossId,
|
name: item.originalName,
|
url: item.url
|
}));
|
} else {
|
this.fileList = [];
|
}
|
|
if (res.data.fileIdList) {
|
this.fileIdList = res.data.fileIdList;
|
this.documentsInfoList = res.data.sysOssVos.map(item => ({
|
fileId: item.ossId,
|
name: item.originalName,
|
url: item.url
|
}));
|
}
|
this.projectForm = res.data.projectInfoInsertDTO || {};
|
this.projectList = res.data.projectInfoInsertDTO.sysOssVos.map(item => ({
|
fileId: item.ossId,
|
name: item.originalName,
|
url: item.url
|
}));
|
}
|
});
|
},
|
reset() {
|
if (this.id) {
|
this.getProjectInfo(this.id);
|
} else {
|
this.getProjectCodeApi();
|
this.resetPlanLibrary();
|
this.fileList = [];
|
this.fileIdList = [];
|
this.projectList = [];
|
this.documentsInfoList = [];
|
}
|
},
|
cancel() {
|
this.$router.push({ path: '/projectEngineering/project/reserveProjects', query: { projectCategory: '1' } });
|
localStorage.removeItem('fileIdList');
|
},
|
getProjectCodeApi() {
|
getProjectCode().then(res => {
|
if (res.code === 200) {
|
this.projectForm.projectCode = res.msg;
|
}
|
});
|
},
|
},
|
created() {
|
// 在组件创建时获取项目信息,如果 id 存在
|
if (this.id) {
|
this.getProjectInfo(this.id);
|
} else {
|
this.getProjectCodeApi();
|
}
|
},
|
|
};
|
</script>
|
|
<style scoped>
|
|
::v-deep .el-tabs__nav-wrap::after {
|
background-color: rgba(0, 0, 0, 0) !important;
|
}
|
.flex-container {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 16px;
|
}
|
|
.tab-label {
|
font-size: 14px;
|
}
|
|
.full-width {
|
width: 100%;
|
}
|
|
.custom-height {
|
height: calc(100% - 55px);
|
}
|
|
.button-container {
|
margin-top: 3%;
|
margin-left: 3%;
|
display: flex;
|
}
|
|
.save-button,
|
.reset-button {
|
width: 72px;
|
}
|
</style>
|