[update] 修改企标流程各模块的数据格式

This commit is contained in:
lideqin
2023-11-09 15:28:36 +08:00
parent 3d90dde143
commit 370f59d7bd
11 changed files with 351 additions and 539 deletions
@@ -126,6 +126,7 @@ import {
} from '@/api/workCenter'
import MainDrafterInitBaseInfo from './modules/MainDrafterInitBaseInfo'
import ApproveBaseInfo from './modules/ApproveBaseInfo'
import { WorkCenterMixin } from '@/mixins/WorkCenterMixin'
// 人员信息
const personalInfo = [ // 人员信息的数据
@@ -181,18 +182,21 @@ export default {
PersonnelInfo,
UserSelectModal
},
mixins: [WorkCenterMixin],
computed: {
pageTitle () {
return this.$t('flowCenter') + this.$route.meta.title
return this.$t('flowCenter') + this.$route.meta.title + '(' + this.currentNodeName + ')'
}
},
mounted () {
// 获取人员信息结构
this.getPersonInfoStructure()
if (this.$route.query.taskId) {
this.currentNodeName = this.$route.query.taskName
// 有流程id说明是从流程中心来的,需要初始化数据
this.getProcessData(this.$route.query.taskId)
} else {
// 没有taskId说明是新建进来的,初始化人员信息
this.personnelInfoData = personalInfo
this.currentNodeName = '标准化工程师发起'
}
// 初始化节点
const taskName = this.$route.query.taskName
@@ -216,6 +220,7 @@ export default {
this.disabled = false
} else {
this.disabled = true
this.initPersonInfoData()
}
// 如果是查看进入的,不可编辑,不可操作
if (this.$route.query.onlyLook) {
@@ -230,7 +235,8 @@ export default {
disabled: false,
onlyLook: false, // 是否仅查看
currentNode: 1, // 当前节点
model: [],
currentNodeName: '',
model: {},
processInfoForm: this.$form.createForm(this),
labelCol: {
xs: { span: 24 },
@@ -273,8 +279,8 @@ export default {
},
methods: {
// 根据流程id获取数据并回显
getProcessData (processId) {
enStandardChangeGetDataById({ processInstanceId: processId }).then(res => {
getProcessData (taskId) {
enStandardChangeGetDataById(taskId).then(res => {
if (res.success) {
this.model = res.result
this.$nextTick(() => {
@@ -283,17 +289,6 @@ export default {
// 初始化流程审批信息,todo:需要判断是不是草稿进来的,草稿进来的才回显审批信息
// this.approvalInfoForm.setFieldsValue(pick(this.model[0], 'commitText', 'commitFile'))
})
// 初始化业务基本信息的申请类型和项目类别
this.formInline.applicationCategory = this.model[0].applicationCategory
this.formInline.projectType = this.model[0].projectType
// 初始化人员信息 todo: 发起人还没处理
this.personnelInfoData = personalInfo.map(item => {
if (item.fieldName) {
return { ...item, userList: this.model[0][item.fieldName + '_dictText'], canChoose: false }
} else {
return item
}
})
// 初始化业务基本信息中组件内容
} else {
this.$message.warning(res.message)
@@ -319,34 +314,40 @@ export default {
// 流程审批信息
const approvalInfoForm = this.approvalInfoForm.getFieldsValue()
// 人员信息的数据, 处理成对象
const personnelInfo = this.$refs.personnelInfo.stepsData
const personnelObj = {}
for (const item of personnelInfo) {
if (item.fieldName) {
personnelObj[item.fieldName] = item.user
const personnelObj = this.$refs.personnelInfo.getDataObj()
// 需要传给后端的
const paramObj = {}
paramObj.common = { ...processInfoForm, ...approvalInfoForm }
paramObj.flowUser = personnelObj
if (this.$refs.baseInfoRef) {
// 业务基本信息
const baseInfo = this.$refs.baseInfoRef.getData()
const param = { ...processInfoForm, ...approvalInfoForm, ...personnelObj, ...baseInfo.formInline }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag || (baseInfo.dataSource && baseInfo.dataSource.length <= 0)) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
}
// 需要传给后端的数组
const arr = []
// 业务基本信息
const baseInfo = this.$refs.baseInfoRef.getData()
const param = { ...processInfoForm, ...baseInfo.formInline, ...approvalInfoForm, ...personnelObj }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
if (baseInfo.dataSource && baseInfo.dataSource.length > 0) {
for (const item of baseInfo.dataSource) {
arr.push({ ...item, ...param })
if (baseInfo.dataSource) {
paramObj.dataList = baseInfo.dataSource.map(item => {
return { ...item, ...baseInfo.formInline }
})
} else {
paramObj.dataList = [baseInfo.formInline]
}
} else {
arr.push(param)
const param = { ...processInfoForm, ...approvalInfoForm, ...personnelObj }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
}
this.loading = true
// 保存到草稿
enStandardChangeSave(arr).then(res => {
enStandardChangeSave(paramObj).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
@@ -361,37 +362,33 @@ export default {
handleStart () {
if (this.loading) return
// 人员信息的数据, 处理成对象
const personnelInfo = this.$refs.personnelInfo.stepsData
const personnelObj = {}
for (const item of personnelInfo) {
if (item.fieldName && item.canChoose) {
personnelObj[item.fieldName] = item.user
}
}
// 校验是否填了所有能填的人员信息
if (!Object.values(personnelObj).every(v => !!v)) {
this.$message.warning(this.$t('pleaseEnterPersonnelInfo'))
const personnelObj = this.$refs.personnelInfo.getDataObjVerify()
if (!personnelObj) {
return
}
// 流程信息的校验
this.processInfoForm.validateFields((err, values) => {
// 流程审批信息的校验
this.approvalInfoForm.validateFields((approvalErr, approvalValues) => {
this.$refs.baseInfoRef.getDataValidate(data => {
if (!err && !approvalErr && data) {
const arr = [] // 需要传给后端的数据
enStandardChangeApproval(arr).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
this.approvalInfoForm.validateFields(async (approvalErr, approvalValues) => {
const data = await this.$refs.baseInfoRef.getDataValidate()
if (!err && !approvalErr && data) {
const param = {} // 需要传给后端的数据
param.common = { ...values, ...approvalValues }
param.flowUser = personnelObj
param.dataList = data.dataSource.map(item => {
return { ...item, ...data.formInline }
})
enStandardChangeApproval(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
})
},