Commit 3f6a5f06fa660f49d492f6511bfece64442b076d
1 parent
64a1d1f0
BPM 模型重构 7:增加任务分配规则的列表 UI 界面
Showing
3 changed files
with
79 additions
and
9 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmTaskAssignRuleController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; | |
| 3 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO; |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | 7 | import io.swagger.annotations.Api; |
| 7 | 8 | import org.springframework.validation.annotation.Validated; |
| 8 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 9 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 10 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 11 | -import org.springframework.web.bind.annotation.RestController; | |
| 9 | +import org.springframework.web.bind.annotation.*; | |
| 12 | 10 | |
| 13 | 11 | import javax.annotation.Resource; |
| 12 | +import javax.validation.Valid; | |
| 14 | 13 | import java.util.List; |
| 15 | 14 | |
| 16 | 15 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -31,4 +30,14 @@ public class BpmTaskAssignRuleController { |
| 31 | 30 | return success(taskAssignRuleService.getTaskAssignRuleList(modelId, processDefinitionId)); |
| 32 | 31 | } |
| 33 | 32 | |
| 33 | + @PostMapping("/create") | |
| 34 | + public CommonResult<String> createTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) { | |
| 35 | + return success("1024"); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @PutMapping("/update") | |
| 39 | + public CommonResult<Boolean> updateTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) { | |
| 40 | + return success(true); | |
| 41 | + } | |
| 42 | + | |
| 34 | 43 | } | ... | ... |
yudao-admin-ui/src/api/bpm/taskAssignRule.js
| ... | ... | @@ -7,3 +7,19 @@ export function getTaskAssignRuleList(query) { |
| 7 | 7 | params: query |
| 8 | 8 | }) |
| 9 | 9 | } |
| 10 | + | |
| 11 | +export function createTaskAssignRule(data) { | |
| 12 | + return request({ | |
| 13 | + url: '/bpm/task-assign-rule/create', | |
| 14 | + method: 'post', | |
| 15 | + data: data | |
| 16 | + }) | |
| 17 | +} | |
| 18 | + | |
| 19 | +export function updateTaskAssignRule(data) { | |
| 20 | + return request({ | |
| 21 | + url: '/bpm/task-assign-rule/update', | |
| 22 | + method: 'put', | |
| 23 | + data: data | |
| 24 | + }) | |
| 25 | +} | ... | ... |
yudao-admin-ui/src/views/bpm/model/index.vue
| ... | ... | @@ -222,7 +222,7 @@ |
| 222 | 222 | </el-dialog> |
| 223 | 223 | <!-- 添加/修改弹窗 --> |
| 224 | 224 | <el-dialog title="修改任务规则" :visible.sync="taskAssignRule.open" width="500px" append-to-body> |
| 225 | - <el-form ref="form" :model="taskAssignRule.form" :rules="taskAssignRule.rules" label-width="110px"> | |
| 225 | + <el-form ref="taskAssignRuleForm" :model="taskAssignRule.form" :rules="taskAssignRule.rules" label-width="110px"> | |
| 226 | 226 | <el-form-item label="任务名称" prop="taskDefinitionName"> |
| 227 | 227 | <el-input v-model="taskAssignRule.form.taskDefinitionName" disabled /> |
| 228 | 228 | </el-form-item> |
| ... | ... | @@ -235,14 +235,14 @@ |
| 235 | 235 | </el-select> |
| 236 | 236 | </el-form-item> |
| 237 | 237 | <el-form-item v-if="taskAssignRule.form.type === 10" label="指定角色" prop="roleIds"> |
| 238 | - <el-select v-model="form.formId" clearable style="width: 100%"> | |
| 238 | + <el-select v-model="taskAssignRule.form.roleIds" multiple clearable style="width: 100%"> | |
| 239 | 239 | <el-option v-for="item in taskAssignRule.roleOptions" :key="parseInt(item.id)" :label="item.name" :value="parseInt(item.id)" /> |
| 240 | 240 | </el-select> |
| 241 | 241 | </el-form-item> |
| 242 | 242 | </el-form> |
| 243 | 243 | <div slot="footer" class="dialog-footer"> |
| 244 | - <el-button type="primary" @click="submitForm">确 定</el-button> | |
| 245 | - <el-button @click="cancel">取 消</el-button> | |
| 244 | + <el-button type="primary" @click="submitAssignRuleForm">确 定</el-button> | |
| 245 | + <el-button @click="cancelAssignRuleForm">取 消</el-button> | |
| 246 | 246 | </div> |
| 247 | 247 | </el-dialog> |
| 248 | 248 | </div> |
| ... | ... | @@ -263,7 +263,7 @@ import {getForm, getSimpleForms} from "@/api/bpm/form"; |
| 263 | 263 | import {decodeFields} from "@/utils/formGenerator"; |
| 264 | 264 | import Parser from '@/components/parser/Parser' |
| 265 | 265 | import {getBaseHeader} from "@/utils/request"; |
| 266 | -import {getTaskAssignRuleList} from "@/api/bpm/taskAssignRule"; | |
| 266 | +import {createTaskAssignRule, getTaskAssignRuleList, updateTaskAssignRule} from "@/api/bpm/taskAssignRule"; | |
| 267 | 267 | import {listSimpleRoles} from "@/api/system/role"; |
| 268 | 268 | |
| 269 | 269 | export default { |
| ... | ... | @@ -597,6 +597,9 @@ export default { |
| 597 | 597 | }, |
| 598 | 598 | /** 处理修改任务分配规则的按钮操作 */ |
| 599 | 599 | handleUpdateTaskAssignRule(row) { |
| 600 | + // 先重置标识 | |
| 601 | + this.resetAssignRuleForm(); | |
| 602 | + // 设置表单 | |
| 600 | 603 | this.taskAssignRule.form = { |
| 601 | 604 | ...row, |
| 602 | 605 | options: [] |
| ... | ... | @@ -606,6 +609,48 @@ export default { |
| 606 | 609 | this.taskAssignRule.form.role = row.options; |
| 607 | 610 | } |
| 608 | 611 | this.taskAssignRule.open = true; |
| 612 | + }, | |
| 613 | + /** 提交任务分配规则的表单 */ | |
| 614 | + submitAssignRuleForm() { | |
| 615 | + this.$refs["taskAssignRuleForm"].validate(valid => { | |
| 616 | + if (valid) { | |
| 617 | + // 构建表单 | |
| 618 | + let form = { | |
| 619 | + ...this.taskAssignRule.form, | |
| 620 | + taskDefinitionName: undefined, | |
| 621 | + }; | |
| 622 | + if (form.type === 10) { | |
| 623 | + form.options = form.roleIds; | |
| 624 | + } | |
| 625 | + form.roleIds = undefined; | |
| 626 | + // 新增 | |
| 627 | + if (!form.id) { | |
| 628 | + createTaskAssignRule(form).then(response => { | |
| 629 | + this.msgSuccess("修改成功"); | |
| 630 | + this.taskAssignRule.open = false; | |
| 631 | + this.doGetTaskAssignRuleList(); | |
| 632 | + }); | |
| 633 | + // 修改 | |
| 634 | + } else { | |
| 635 | + form.taskDefinitionKey = undefined; // 无法修改 | |
| 636 | + updateTaskAssignRule(form).then(response => { | |
| 637 | + this.msgSuccess("修改成功"); | |
| 638 | + this.taskAssignRule.open = false; | |
| 639 | + this.doGetTaskAssignRuleList(); | |
| 640 | + }); | |
| 641 | + } | |
| 642 | + } | |
| 643 | + }); | |
| 644 | + }, | |
| 645 | + /** 取消任务分配规则的表单 */ | |
| 646 | + cancelAssignRuleForm() { | |
| 647 | + this.taskAssignRule.open = false; | |
| 648 | + this.resetAssignRuleForm(); | |
| 649 | + }, | |
| 650 | + // 表单重置 | |
| 651 | + resetAssignRuleForm() { | |
| 652 | + this.taskAssignRule.form = {}; | |
| 653 | + this.resetForm("taskAssignRuleForm"); | |
| 609 | 654 | } |
| 610 | 655 | } |
| 611 | 656 | }; | ... | ... |