From 6ca4886f61c51c80896bf128af9c61fd685f9d91 Mon Sep 17 00:00:00 2001 From: wangxl <123456> Date: Wed, 18 Dec 2024 01:45:58 +0800 Subject: [PATCH] 222222 --- src/api/index.js | 3 + .../project/components/edit/projectCreate.vue | 51 ++--- .../project/components/edit/projectEdit.vue | 214 +++++++++++------- 3 files changed, 161 insertions(+), 107 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 65613da..af5a253 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -417,6 +417,9 @@ export default { save (params) { return fetch(`/v1/science-admin/com-project/save`, params, 'post', 'json') }, + saveByStep (params) { + return fetch(`/v1/science-admin/com-project/saveByStep`, params, 'post', 'json') + }, updateUnit (params) { return fetch(`/v1/science-admin/com-project/updateUnit`, params, 'post', 'json') }, diff --git a/src/views/report/project/components/edit/projectCreate.vue b/src/views/report/project/components/edit/projectCreate.vue index b6012e6..82aee4a 100644 --- a/src/views/report/project/components/edit/projectCreate.vue +++ b/src/views/report/project/components/edit/projectCreate.vue @@ -4,18 +4,17 @@ <a-spin :spinning="loading" style="width: 100%;height: 100%;"> <div class="page-steps"> <a-steps size="small" :current="current"> - <a-step :status="item.status" v-for="(item,index) in completeStatus" :key="index+'completeStatus'" :title="item.title" /> + <a-step :status="item.status" v-for="(item,index) in stepsArray" :key="index+'stepsArray'" :title="item.title" /> </a-steps> </div> <div class="page-content"> - <project-edit v-model="value" @close="closeWindow" @load="onLoad" :showStatus.sync="showStatus" ref="projCreate" v-if="projType"></project-edit> - <project-edit-key v-model="value" @close="closeWindow" @load="onLoad" :showStatus.sync="showStatus" ref="projCreate" v-else></project-edit-key> + <project-edit v-model="value" @close="closeWindow" @load="onLoad" @next="changeSteps" :stepsArray.sync="stepsArray" ref="projCreate"></project-edit> </div> <div class="page-footer"> <a-button v-if="currSteps > 0" style="margin-left: 40px" type="primary" @click="prev">上一步</a-button> <a-button style="margin-left: 40px" type="primary" @click="save">保 存</a-button> - <a-button v-if="currSteps < completeStatus.length - 1" style="margin-left: 40px" type="primary" @click="next">下一步</a-button> - <a-button v-if="currSteps == completeStatus.length - 1" style="margin-left: 40px" type="primary" @click="submit">完成填写</a-button> + <a-button v-if="currSteps < stepsArray.length - 1" style="margin-left: 40px" type="primary" @click="next">下一步</a-button> + <a-button v-if="currSteps == stepsArray.length - 1" style="margin-left: 40px" type="primary" @click="submit">完成填写</a-button> </div> </a-spin> </div> @@ -36,15 +35,14 @@ export default { projType: getType() == "1", current: 10, currSteps: 0, - completeStatus: [ - { status: "", title: '基本信息' }, - { status: "", title: '项目组成员及单位' }, - { status: "", title: '经费预算及设备明细' }, - { status: "", title: '阶段目标及课题设置' }, - { status: "", title: '绩效指标' }, - { status: "", title: '附件' } + stepsArray: [ + { status: "process", title: '基本信息', showStatus: true }, + { status: "wait", title: '项目组成员及单位', showStatus: false }, + { status: "wait", title: '经费预算及设备明细', showStatus: false }, + { status: "wait", title: '阶段目标及课题设置', showStatus: false }, + { status: "wait", title: '绩效指标', showStatus: false }, + { status: "wait", title: '附件', showStatus: false } ], - showStatus: [true, false, false, false, false, false], stepStyle: { marginBottom: '60px', boxShadow: '0px -1px 0 0 #e8e8e8 inset', @@ -66,35 +64,28 @@ export default { debugger this.currSteps = e this.changeSteps(this.currSteps) - console.log(this.currSteps, 'stepsChange') }, next () { - this.currSteps++; - this.changeSteps(this.currSteps) - console.log(this.currSteps, 'next') + this.$refs.projCreate.submit(this.currSteps, true) }, prev () { this.currSteps--; this.changeSteps(this.currSteps) - console.log(this.currSteps, 'prev') }, changeSteps (e) { - var clone = [].concat(this.completeStatus) - clone[e].status = "process" - this.completeStatus = clone - this.changeShowStatus(e) - }, - changeShowStatus (e) { - var clone = [false, false, false, false, false, false] - clone[e] = true; - this.showStatus = clone - console.log(this.showStatus) + this.currSteps = e + var clone = [].concat(this.stepsArray) + clone.forEach(e => { + e.showStatus = false + }) + clone[e].showStatus = true; + this.stepsArray = clone }, save () { - this.$refs.projCreate.save() + this.$refs.projCreate.save(this.currSteps) }, submit () { - this.$refs.projCreate.submit() + this.$refs.projCreate.submit(this.currSteps, false) }, closeWindow (value) { this.$emit('close', value) diff --git a/src/views/report/project/components/edit/projectEdit.vue b/src/views/report/project/components/edit/projectEdit.vue index d9e22e9..4e4d140 100644 --- a/src/views/report/project/components/edit/projectEdit.vue +++ b/src/views/report/project/components/edit/projectEdit.vue @@ -1,7 +1,7 @@ <template> <div> <a-form-model ref="form" :model="formData" :rules="rules" style="border-top: 0px" class="from-table font-line-space"> - <div v-if="showStatus[0]"> + <div v-if="stepsArray[0].showStatus"> <a-row> <a-col :span="24" style="border-top: 0px;text-align: center;"> <div class="main-title"> @@ -350,20 +350,6 @@ </a-form-model-item> </a-col> </a-row> - <a-row type="flex"> - <a-col :span="4" class="bg-gray"> - <div class="special-middle"> - <div class="required">申请经费(万元)</div> - </div> - </a-col> - <a-col :span="20"> - <a-form-model-item prop="govFunding"> - <!-- <a-input-number v-model="formData.govFunding" @change="govFundingChange" :min="0" :step="0.01" style="width: 100px" /> --> - {{ formData.govFunding }} - <span> 万元</span> - </a-form-model-item> - </a-col> - </a-row> <a-row type="flex"> <a-col :span="4" class="bg-gray"> <div class="special-middle"> @@ -512,7 +498,7 @@ </a-col> </a-row> </div> - <div v-if="showStatus[1]"> + <div v-if="stepsArray[1].showStatus"> <a-row> <a-col :span="24" style="border-top: 0px"> <div class="main-title"> @@ -532,7 +518,7 @@ <!-- 项目主要参与单位及分工 --> <participate-units-edit :participateUnits.sync="formData.participateUnits" /> </div> - <div v-if="showStatus[2]"> + <div v-if="stepsArray[2].showStatus"> <!-- 经费预算 --> <budget-edit :budget.sync="formData.budget" @save="budgetSave" /> <a-row type="flex"> @@ -572,13 +558,13 @@ <!-- 项目承担单位研究资金支出预算明细表 --> <unit-payment-edit :unitPayment.sync="formData.unitPayment" /> </div> - <div v-if="showStatus[3]"> + <div v-if="stepsArray[3].showStatus"> <!-- 项目安排及阶段目标 --> <proj-stage-goals-edit :stageGoals.sync="formData.stageGoals" /> <!-- 项目课题设置 --> <project-sub-edit :projectSubList.sync="formData.projectSubList" /> </div> - <div v-if="showStatus[4]"> + <div v-if="stepsArray[4].showStatus"> <a-row type="flex"> <a-col :span="24" style="text-align: center;"> <div class="special-middle"> @@ -589,7 +575,7 @@ <!-- 项目绩效指标 --> <project-kpi-edit :projectKPI.sync="formData.projectKPI" /> </div> - <div v-if="showStatus[5]"> + <div v-if="stepsArray[5].showStatus"> <!-- 附件 --> <file-edit :fileList.sync="formData.fileList" /> </div> @@ -677,19 +663,19 @@ export default { return null } }, - showStatus: { + stepsArray: { type: Array, default () { - return [true, false, false, false, false, false] + return [] } }, }, created () { - console.log(this.showStatus) this.getProject() }, data () { return { + completeStatus: "0,0,0,0,0,0", overseasShow: false, formData: { id: null, @@ -761,8 +747,8 @@ export default { remark: [{ required: true, message: '请填写附注说明', trigger: 'blur' },], startDate: { required: true, message: '请选择项日开始时间', trigger: 'change' }, endDate: { required: true, message: '请选择项目结束时间', trigger: 'change' }, - totalFunding: [{ required: true, message: '请填写项目总经费', trigger: 'blur' },], - govFunding: [{ required: true, message: '请填写申请科技经费', trigger: 'blur' },], + // totalFunding: [{ required: true, message: '请填写项目总经费', trigger: 'blur' },], + // govFunding: [{ required: true, message: '请填写申请科技经费', trigger: 'blur' },], projAbstract: [{ required: true, message: '请填写项目摘要', trigger: 'blur' },], projKeywords: [{ required: true, message: '请填写关键词', trigger: 'blur' },], researchContent: { required: true, message: '请填写项目实施目标', trigger: 'blur' }, @@ -782,12 +768,72 @@ export default { }, methods: { moment, + save (step) { + var obj = this.getObj(step) + obj.step = step + if (this.checkInfo(step)) { + this.$emit('load', true) + let pars = isEmptyParams(obj) + let par = { ...pars } + this.$api.project.saveByStep(par).then(({ data = {} }) => { + if (data) { + this.formData.id = data + this.$message.success('保存成功!') + this.$emit('close', 'save') + } + this.$emit('load', false) + }).catch(() => { + this.$emit('load', false) + }) + } + }, + submit (step, next) { + if (this.checkInfo(step)) { + this.$refs.form.validate(valid => { + if (valid) { + this.$emit('load', true) + var obj = this.getObj(step) + obj.step = step + let state = obj.projState + if (state != 30) + obj.projState = 10 + let pars = isEmptyParams(obj) + let par = { ...pars } + this.$api.project.saveByStep(par).then(({ data = {} }) => { + if (data) { + this.formData.id = data + if (next) { + this.$emit('close', 'save') + this.$emit('next', step + 1) + var arr = this.completeStatus.split(','); + arr[step] = "1"; + this.completeStatus = arr.toString() + this.formData.completeStatus = this.completeStatus + this.getCompleteStatus(step + 1, this.completeStatus) + } else { + this.$message.success('成功!') + this.$emit('close', 'submit') + } + } + this.$emit('load', false) + }).catch(() => { + this.$emit('load', false) + }) + } else { + this.$message.error('信息未填写完全!') + return false + } + }) + } + }, getProject () { this.$emit('load', true) if (!!this.value) { this.$api.project.getProjectInfoById({ id: this.value }).then(({ data = {} }) => { if (data) { this.formData = data + console.log(data) + this.getCompleteStatus(0, data.completeStatus) this.loadList() } else this.$emit('close', 'error') @@ -800,6 +846,7 @@ export default { this.$api.project.getNewProject({ projType: getType() }).then(({ data = {} }) => { if (data) { this.formData = data + this.getCompleteStatus(0, data.completeStatus) this.loadList() } else this.$emit('close', 'error') @@ -810,12 +857,24 @@ export default { }) } }, + getCompleteStatus (step, completeStatus) { + var arr = completeStatus.split(',') + if (!!arr && arr.length > 0) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == "1") { + this.stepsArray[i].status = "finish" + } + } + this.stepsArray[step].status = "process" + } + }, loadList () { + if (!!!this.formData.cooperativeUnits || this.formData.cooperativeUnits.length == 0) - this.formData.cooperativeUnits = [{ ...Cooperative }, { ...Cooperative }] + this.formData.cooperativeUnits = [] if (!!!this.formData.participateUnits || this.formData.participateUnits.length == 0) - this.formData.participateUnits = [{ ...ParticipateUnit }, { ...ParticipateUnit }] + this.formData.participateUnits = [] //{ ...Cooperative }, { ...Cooperative } if (!!!this.formData.members || this.formData.members.length == 0) this.formData.members = [] @@ -848,60 +907,61 @@ export default { this.formData.managerDept = this.formData.projectKPI.managerDept this.formData.projAttribute = this.formData.projectKPI.projAttribute }, - save () { - this.processProjectYearTarget() - if (this.checkProjName()) { - this.$emit('load', true) - let pars = isEmptyParams(this.formData) - let par = { ...pars } - this.$api.project.save(par).then(({ data = {} }) => { - if (data) { - this.formData.id = data - this.$message.success('保存成功!') - this.$emit('close', 'save') - } - this.$emit('load', false) - }).catch(() => { - this.$emit('load', false) - }) - } - }, - submit () { - this.processProjectYearTarget() - this.$refs.form.validate(valid => { - if (valid) { - if (this.formData.members.length == 0) { - this.$message.error('至少添加一位项目组成员!') - return false - } else { - this.$emit('load', true) - let state = this.formData.projState - if (state != 30) - this.formData.projState = 10 - let pars = isEmptyParams(this.formData) - let par = { ...pars } - this.$api.project.save(par).then(({ data = {} }) => { - if (data) { - this.formData.id = data - this.$message.success('成功!') - this.$emit('close', 'submit') - } - this.$emit('load', false) - }).catch(() => { - this.$emit('load', false) - }) + getObj (step) { + var obj = null + switch (step) { + case 0: { + obj = { + id: null, reportYear: null, batch: null, projState: null, appPersonId: null, appUnitId: null, projType: null, + jobTime: null, address: null, mainResearchAreas: null, + unitLinkName: null, unitLinkMobile: null, unitLinkEmail: null, unitLinkFax: null, + projName: null, knowledgeId: null, startDate: null, endDate: null, + remark: null, projClass: null, subjectScope: null, projAbstract: null, projKeywords: null, + totalFunding: null, govFunding: null, unitFunding: null, selfFunding: null, + researchContent: null, technologyTarget: null, economyTarget: null, achievementTarget: null, technologyReportsTarget: null, otherTarget: null, + fileId: null, downloadId: null, completeStatus: null, step: null } - } else { - this.$message.error('项目信息未填写完全!') - return false + break; } + case 1: + obj = { id: null, members: [], participateUnits: [], completeStatus: null, step: null } + break; + case 2: + obj = { id: null, budget: [], fundPlan: [], deviceList: [], manufactureList: [], unitPayment: [], completeStatus: null, step: null } + break; + case 3: + obj = { id: null, stageGoals: [], projectSubList: [], completeStatus: null, step: null } + break; + case 4: + obj = { id: null, projectKPI: null, completeStatus: null, step: null } + break; + case 5: + obj = { id: null, fileList: [], projState: null, completeStatus: null, step: null } + break; + } + Object.keys(obj).forEach(key => { + obj[key] = this.formData[key]; }) + return obj }, - checkProjName () { - if (this.formData.projName == "" || this.formData.projName == null) { - alert('项目名称不能为空') - return false - } else { + checkInfo (step) { + if (step == 0) { + if (this.formData.projName == "" || this.formData.projName == null) { + alert('项目名称不能为空') + return false + } else return true + } else if (step == 1) { + if (!!!this.formData.members || this.formData.members.length == 0) { + this.$message.error('至少添加一位项目组成员!') + return false + } else return true + } else if (step == 2) { + return true + } else if (step == 3) { + return true + } else if (step == 4) { + return true + } else if (step == 5) { return true } }, -- 2.18.0