diff --git a/src/api/system/workflowManageApi.js b/src/api/system/workflowManageApi.js index 314d6bc06..9cc7e2322 100644 --- a/src/api/system/workflowManageApi.js +++ b/src/api/system/workflowManageApi.js @@ -35,7 +35,7 @@ export function listWorkflowImage(params) { } }).then(response => { const res = response.data - if (res.code !== '0') { + if (res.code != 0) { reject(new Error(res.msg)) return } diff --git a/src/components/contract/ContractChangeMainBody.vue b/src/components/contract/ContractChangeMainBody.vue index 0dc12cd81..69f40143d 100644 --- a/src/components/contract/ContractChangeMainBody.vue +++ b/src/components/contract/ContractChangeMainBody.vue @@ -1,6 +1,6 @@  @@ -125,7 +141,8 @@ export default { describle: '', startNodeFinish: 'Y', steps: [] - } + }, + currentSelectTarget: null } }, created() { @@ -133,6 +150,10 @@ export default { this._initWorkflowSettingInfo() }, methods: { + generateId() { + return `id-${Date.now()}-${Math.random().toString(36).substr(2, 6)}` + }, + async _initWorkflowSettingInfo() { const flowId = this.$route.query.flowId @@ -159,8 +180,39 @@ export default { }, _freshResStep(data) { - // 处理步骤数据的逻辑 - console.log(data) + if (!data) { + this.workflowSettingInfo.steps = [] + return + } + + this.workflowSettingInfo.describle = data.describle || '' + if (data.startNodeFinish) { + this.workflowSettingInfo.startNodeFinish = data.startNodeFinish + } + + const workflowSteps = Array.isArray(data.workflowSteps) ? data.workflowSteps : [] + const steps = workflowSteps.map((step, index) => { + const staffList = Array.isArray(step.workflowStepStaffs) ? step.workflowStepStaffs : [] + const mainStaff = staffList[0] || {} + + const subStaff = staffList.slice(1).map(staff => ({ + id: staff.id || this.generateId(), + staffId: staff.staffId || staff.userId || '', + staffName: staff.staffName || staff.userName || staff.name || '', + staffRole: staff.staffRole || '' + })) + + return { + seq: index, + staffId: mainStaff.staffId || mainStaff.userId || '', + staffName: mainStaff.staffName || mainStaff.userName || mainStaff.name || '', + staffRole: mainStaff.staffRole || '', + type: String(step.type || '2'), + subStaff + } + }) + + this.workflowSettingInfo.steps = steps }, addWorkflowStep() { @@ -176,11 +228,19 @@ export default { chooseStaff(item) { item.from = this._getStaffFromType() - this.$refs.selectStaff.open(item) + this.currentSelectTarget = item + this.$refs.selectStaff.open() }, _getStaffFromType() { - // 根据flowType返回对应的from值 + const type = this.workflowSettingInfo.flowType + if (['30003', '40004', '70007', '80008'].includes(type)) { + return 'purchase' + } + if (['50005', '60006'].includes(type)) { + return 'contract' + } + return '' }, _goBack() { @@ -195,7 +255,7 @@ export default { addStaff(step) { step.subStaff.push({ - id: this.$uuid(), + id: this.generateId(), staffId: '', staffName: '', staffRole: '1001' @@ -212,8 +272,17 @@ export default { } }, - handleStaffSelected(staffs) { - console.log(staffs) + handleStaffSelected(staff) { + if (!this.currentSelectTarget) { + return + } + const target = this.currentSelectTarget + this.$set(target, 'staffId', staff.staffId || staff.userId || '') + this.$set(target, 'staffName', staff.staffName || staff.userName || staff.name || '') + if (staff.staffRole) { + this.$set(target, 'staffRole', staff.staffRole) + } + this.currentSelectTarget = null }, async saveWorkflowSettingInfo() { @@ -250,6 +319,22 @@ export default { >* { margin-right: 15px; } + + .radio-group { + display: inline-flex; + align-items: center; + margin-right: 15px; + + .radio-item { + display: inline-flex; + align-items: center; + margin-right: 12px; + + input { + margin-right: 4px; + } + } + } } .sub-staff-item {