diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/MaintenanceOrderController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/MaintenanceOrderController.java index 9c832d6..b3beee3 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/MaintenanceOrderController.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/MaintenanceOrderController.java @@ -107,9 +107,9 @@ public class MaintenanceOrderController { @Operation(summary = "提交审批") @PreAuthorize("@ss.hasPermission('imt:remote-maintenance-order:submitApprove')") - @GetMapping("/submitApprove/{id}") - public Boolean submitApprove(@PathVariable("id") String id){ - return maintenanceOrderService.submitApprove(id); + @PostMapping("/submitApprove") + public Boolean submitApprove(@Valid @RequestBody MaintenanceSubmitApproveVO vo){ + return maintenanceOrderService.submitApprove(vo); } @Operation(summary = "根据设备id获取故障次数") diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceSubmitApproveVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceSubmitApproveVO.java new file mode 100644 index 0000000..44a502b --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceSubmitApproveVO.java @@ -0,0 +1,24 @@ +package com.inspur.module.system.controller.maintenance.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; + +/** + * @Author xusd + * @Date 2024/9/19 17:51 + **/ +@Data +public class MaintenanceSubmitApproveVO { + + @Schema(description = "维修工单id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "维修工单id不能为空") + private String maintenanceOrderId; + + @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}") + private Map> startUserSelectAssignees; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderService.java index f7f2fef..1a44d71 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderService.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderService.java @@ -95,10 +95,10 @@ public interface MaintenanceOrderService { * * @Author xusd * @Date 18:19 2024/9/12 - * @param id + * @param vo * @return java.lang.Boolean */ - Boolean submitApprove(String id); + Boolean submitApprove(MaintenanceSubmitApproveVO vo); /** * 根据设备id获取故障次数 diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java index 7deaf09..c25ecce 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java @@ -234,20 +234,19 @@ public class MaintenanceOrderServiceImpl implements MaintenanceOrderService { @Override @Transactional(rollbackFor = Exception.class) - public Boolean submitApprove(String id) { + public Boolean submitApprove(MaintenanceSubmitApproveVO vo) { // 发起 BPM 流程 // Map processInstanceVariables = new HashMap<>(); // processInstanceVariables.put("day", day); - Map> startUserSelectAssignees = new HashMap<>(); String processInstanceId = processInstanceApi.createProcessInstance(getLoginUserId(), new BpmProcessInstanceCreateReqDTO() .setProcessDefinitionKey(PROCESS_KEY) // .setVariables(processInstanceVariables) - .setBusinessKey(String.valueOf(id)) - .setStartUserSelectAssignees(startUserSelectAssignees)); + .setBusinessKey(vo.getMaintenanceOrderId()) + .setStartUserSelectAssignees(vo.getStartUserSelectAssignees())); // 将工作流的编号、状态、审批状态,更新到 业务表 中 return maintenanceOrderMapper.updateById(new MaintenanceOrderDO() - .setMaintenanceOrderId(id) + .setMaintenanceOrderId(vo.getMaintenanceOrderId()) .setProcessInstanceId(processInstanceId) .setStatus(1) .setApproveStatus(1)) > 0; diff --git a/imt-ui/src/api/system/maintenance/maintenance.js b/imt-ui/src/api/system/maintenance/maintenance.js index 930f65e..b5a2914 100644 --- a/imt-ui/src/api/system/maintenance/maintenance.js +++ b/imt-ui/src/api/system/maintenance/maintenance.js @@ -70,10 +70,11 @@ export function getRemoteMaintenanceOrderRecord(id) { } // 提交审批 -export function submitMaintenanceApprove(id) { +export function submitMaintenanceApprove(data) { return request({ - url: '/maintenance/submitApprove/' + id, - method: 'get' + url: '/maintenance/submitApprove', + method: 'post', + data: data }) } diff --git a/imt-ui/src/views/bpm/processInstance/create/index.vue b/imt-ui/src/views/bpm/processInstance/create/index.vue index a5a16d4..4ae654a 100644 --- a/imt-ui/src/views/bpm/processInstance/create/index.vue +++ b/imt-ui/src/views/bpm/processInstance/create/index.vue @@ -33,10 +33,45 @@ 申请信息【{{ selectProcessInstance.name }}】 选择其它流程 - +
+
+ +
@@ -61,6 +96,7 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict"; import {decodeFields} from "@/utils/formGenerator"; import Parser from '@/components/parser/Parser' import {createProcessInstance} from "@/api/bpm/processInstance"; +import {listSimpleUsers} from '@/api/system/user' import {getModel} from "@/api/bpm/model"; // 流程实例的发起 @@ -71,6 +107,7 @@ export default { }, data() { return { + test:[], // 遮罩层 loading: true, // 表格数据 @@ -95,6 +132,9 @@ export default { // 数据字典 categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), + startUserSelectAssigneesFormRules:{}, + startUserSelectTasks:[], + userList:[], }; }, created() { @@ -123,24 +163,49 @@ export default { }, /** 处理选择流程的按钮操作 **/ handleSelect(row) { + console.log("row",row); // 设置选择的流程 this.selectProcessInstance = row; - console.log(row) + this.startUserSelectAssignees = {} + console.log("row",row) // 流程表单 - if (row.formId) { - // 设置对应的表单 - this.detailForm = { - ...JSON.parse(row.formConf), - fields: decodeFields(row.formFields) - } - + if (row.formType === 10) { // 加载流程图 - getProcessDefinitionBpmnXML(row.id).then(response => { + getProcessDefinitionBpmnXML(row.id).then(async response => { + console.log("response.data", response.data) this.bpmnXML = response.data.bpmnXml; + this.startUserSelectTasks = response.data.startUserSelectTasks; + // 设置指定审批人 + if (this.startUserSelectTasks.length > 0) { + console.log("this.startUserSelectTasks",this.startUserSelectTasks) + // this.detailForm.formRules.push({ + // type: 'startUserSelect', + // props: { + // title: '指定审批人' + // } + // }) + // 设置校验规则 + for (const userTask of this.startUserSelectTasks) { + this.$set(this.startUserSelectAssignees, userTask.id, []); + this.$set(this.startUserSelectAssigneesFormRules, userTask.id, [{required: true, message: '请选择审批人', trigger: 'change'}]); + } + // 加载用户列表 + await listSimpleUsers().then(res=>{ + this.userList = res.data; + console.log("this.userList",this.userList); + }) + } + console.log("this.startUserSelectAssigneesFormRules",this.startUserSelectAssigneesFormRules) + // 设置对应的表单 + this.detailForm = { + ...JSON.parse(row.formConf), + fields: decodeFields(row.formFields), + formRules: this.startUserSelectAssigneesFormRules, + } + console.log("this.detailForm",this.detailForm) }) } else if (row.formCustomCreatePath) { - this.$router.push({ path: row.formCustomCreatePath}); - // 这里暂时无需加载流程图,因为跳出到另外个 Tab; + this.$router.push({ path: row.formCustomCreatePath, query: { id: row.id}}); } }, /** 提交按钮 */ diff --git a/imt-ui/src/views/system/maintenance/maintenanceInfo/create.vue b/imt-ui/src/views/system/maintenance/maintenanceInfo/create.vue index e748e6d..851530b 100644 --- a/imt-ui/src/views/system/maintenance/maintenanceInfo/create.vue +++ b/imt-ui/src/views/system/maintenance/maintenanceInfo/create.vue @@ -79,7 +79,36 @@ - @@ -131,6 +230,8 @@ import {getCustomerSelection} from '@/api/system/baseData/customerInfo' import RemoteMaintenanceOrderForm from './RemoteMaintenanceOrderForm.vue'; import {DICT_TYPE} from "@/utils/dict"; import ApproveRecord from "@/views/bpm/processInstance/approveRecord.vue"; +import {getProcessDefinitionBpmnXML} from "@/api/bpm/definition"; +import {listSimpleUsers} from "@/api/system/user"; export default { name: "RemoteMaintenanceOrder", @@ -145,6 +246,12 @@ export default { }, data() { return { + submitApproveForm:{}, + startUserSelectAssignees:{}, + startUserSelectAssigneesFormRules:{}, + startUserSelectTasks:[], + userList:[], + submitApproveOpen: false, cascaderValue:[], equipCascader:[], componentSelection:[], @@ -181,14 +288,55 @@ export default { this.initSelection(); }, methods: { - submitApprove(row){ + closeSubmitApprove(){ + this.submitApproveOpen = false; + this.$refs.startUserSelectAssigneesFormRef.resetFields(); + }, + openSubmitApprove(row){ const maintenanceOrderId = row.maintenanceOrderId; - this.$modal.confirm('是否确认提交维修工单编号为"' + row.maintenanceOrderNo + '"的数据项?').then(()=>{ + console.log(maintenanceOrderId); + // 加载流程图实体 + getProcessDefinitionBpmnXML(null,"maintenance_approve").then(async response => { + console.log("response.data", response.data) + this.bpmnXML = response.data.bpmnXml; + this.startUserSelectTasks = response.data.startUserSelectTasks; + // 设置指定审批人 + if (this.startUserSelectTasks.length > 0) { + this.submitApproveOpen = true; + RemoteMaintenanceOrderApi.getRemoteMaintenanceOrderRecord(maintenanceOrderId).then(res=>{ + console.log("res.data",res.data); + this.submitApproveForm = res.data; + }) + listSimpleUsers().then(res=>{ + this.userList = res.data; + }) + console.log("this.startUserSelectTasks",this.startUserSelectTasks) + // 设置校验规则 + for (const userTask of this.startUserSelectTasks) { + this.$set(this.startUserSelectAssignees, userTask.id, []); + this.$set(this.startUserSelectAssigneesFormRules, userTask.id, [{required: true, message: '请选择审批人', trigger: 'change'}]); + } + }else { + this.$modal.confirm('是否确认提交维修工单编号为"' + row.maintenanceOrderNo + '"的数据项?').then(()=>{ + this.submitApprove(row.maintenanceOrderId); + }) + } + }) + }, + async submitApprove(maintenanceOrderId){ + console.log(maintenanceOrderId); + if (this.startUserSelectTasks.length > 0) { + await this.$refs.startUserSelectAssigneesFormRef.validate(); + } + const data = { + maintenanceOrderId:maintenanceOrderId, + startUserSelectAssignees: this.startUserSelectAssignees + } + await RemoteMaintenanceOrderApi.submitMaintenanceApprove(data).then(res=>{ this.loading = true; - RemoteMaintenanceOrderApi.submitMaintenanceApprove(maintenanceOrderId).then(res=>{ - this.getList(); - this.$modal.msgSuccess("提交审批成功"); - }) + this.$modal.msgSuccess("提交审批成功"); + this.submitApproveOpen = false; + this.getList(); }) }, openApproveRecord(approveId){