Commit 24c03cf1767c62b3aa2bcb3886c79635e45cc51e
1 parent
d2a8f3f2
BPM 模型重构 3:设置流程时,去掉 formId、description 等的传递,专注设计本身
Showing
6 changed files
with
42 additions
and
42 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelUpdateReqVO.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum; | |
| 3 | 4 | import io.swagger.annotations.ApiModel; |
| 4 | 5 | import io.swagger.annotations.ApiModelProperty; |
| 5 | 6 | import lombok.Data; |
| ... | ... | @@ -10,9 +11,7 @@ import javax.validation.constraints.NotEmpty; |
| 10 | 11 | |
| 11 | 12 | @ApiModel("流程模型的更新 Request VO") |
| 12 | 13 | @Data |
| 13 | -@EqualsAndHashCode(callSuper = true) | |
| 14 | -@ToString(callSuper = true) | |
| 15 | -public class BpmModelUpdateReqVO extends BpmModelBaseVO { | |
| 14 | +public class BpmModelUpdateReqVO { | |
| 16 | 15 | |
| 17 | 16 | @ApiModelProperty(value = "编号", required = true, example = "1024") |
| 18 | 17 | @NotEmpty(message = "编号不能为空") |
| ... | ... | @@ -27,10 +26,18 @@ public class BpmModelUpdateReqVO extends BpmModelBaseVO { |
| 27 | 26 | @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1") |
| 28 | 27 | private String category; |
| 29 | 28 | |
| 30 | - @ApiModelProperty(value = "表单编号", example = "1024") | |
| 31 | - private Long formId; | |
| 32 | - | |
| 33 | 29 | @ApiModelProperty(value = "BPMN XML", required = true) |
| 34 | 30 | private String bpmnXml; |
| 35 | 31 | |
| 32 | + @ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1") | |
| 33 | + private Integer formType; | |
| 34 | + @ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") | |
| 35 | + private Long formId; | |
| 36 | + @ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create", | |
| 37 | + notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") | |
| 38 | + private String formCustomCreatePath; | |
| 39 | + @ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view", | |
| 40 | + notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") | |
| 41 | + private String formCustomViewPath; | |
| 42 | + | |
| 36 | 43 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/BpmModelConvert.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.convert.model; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 3 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; |
| ... | ... | @@ -15,10 +16,11 @@ import org.mapstruct.factory.Mappers; |
| 15 | 16 | |
| 16 | 17 | import java.util.List; |
| 17 | 18 | import java.util.Map; |
| 19 | +import java.util.Objects; | |
| 18 | 20 | |
| 19 | 21 | |
| 20 | 22 | /** |
| 21 | - * 流程定义 Convert | |
| 23 | + * 流程模型 Convert | |
| 22 | 24 | * |
| 23 | 25 | * @author yunlongn |
| 24 | 26 | */ |
| ... | ... | @@ -95,20 +97,34 @@ public interface BpmModelConvert { |
| 95 | 97 | default void copy(Model model, BpmModelCreateReqVO bean) { |
| 96 | 98 | model.setName(bean.getName()); |
| 97 | 99 | model.setKey(bean.getKey()); |
| 98 | - model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), null))); | |
| 100 | + model.setMetaInfo(buildMetaInfoStr(null, bean.getDescription(), null, null, | |
| 101 | + null, null)); | |
| 99 | 102 | } |
| 100 | 103 | |
| 101 | 104 | default void copy(Model model, BpmModelUpdateReqVO bean) { |
| 102 | 105 | model.setName(bean.getName()); |
| 103 | 106 | model.setCategory(bean.getCategory()); |
| 104 | - model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId()))); | |
| 107 | + model.setMetaInfo(buildMetaInfoStr(JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class), | |
| 108 | + bean.getDescription(), bean.getFormType(), bean.getFormId(), | |
| 109 | + bean.getFormCustomCreatePath(), bean.getFormCustomViewPath())); | |
| 105 | 110 | } |
| 106 | 111 | |
| 107 | - default BpmModelMetaInfoRespDTO buildMetaInfo(String description, Long formId) { | |
| 108 | - BpmModelMetaInfoRespDTO metaInfo = new BpmModelMetaInfoRespDTO(); | |
| 109 | - metaInfo.setDescription(description); | |
| 110 | - metaInfo.setFormId(formId); | |
| 111 | - return metaInfo; | |
| 112 | + default String buildMetaInfoStr(BpmModelMetaInfoRespDTO metaInfo, String description, Integer formType, | |
| 113 | + Long formId, String formCustomCreatePath, String formCustomViewPath) { | |
| 114 | + if (metaInfo == null) { | |
| 115 | + metaInfo = new BpmModelMetaInfoRespDTO(); | |
| 116 | + } | |
| 117 | + // 只有非空,才进行设置,避免更新时的覆盖 | |
| 118 | + if (StrUtil.isNotEmpty(description)) { | |
| 119 | + metaInfo.setDescription(description); | |
| 120 | + } | |
| 121 | + if (Objects.nonNull(formType)) { | |
| 122 | + metaInfo.setFormType(formType); | |
| 123 | + metaInfo.setFormId(formId); | |
| 124 | + metaInfo.setFormCustomCreatePath(formCustomCreatePath); | |
| 125 | + metaInfo.setFormCustomViewPath(formCustomViewPath); | |
| 126 | + } | |
| 127 | + return JsonUtils.toJsonString(metaInfo); | |
| 112 | 128 | } |
| 113 | 129 | |
| 114 | 130 | BpmModelPageItemRespVO.ProcessDefinition convert(ProcessDefinition bean); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java
| ... | ... | @@ -19,7 +19,7 @@ public class BpmModelMetaInfoRespDTO { |
| 19 | 19 | /** |
| 20 | 20 | * 表单类型 |
| 21 | 21 | */ |
| 22 | - private Long formType; | |
| 22 | + private Integer formType; | |
| 23 | 23 | /** |
| 24 | 24 | * 表单编号 |
| 25 | 25 | * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 |
| ... | ... | @@ -29,7 +29,7 @@ public class BpmModelMetaInfoRespDTO { |
| 29 | 29 | * 自定义表单的提交路径,使用 Vue 的路由地址 |
| 30 | 30 | * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 |
| 31 | 31 | */ |
| 32 | - private String formCustomSubmitPath; | |
| 32 | + private String formCustomCreatePath; | |
| 33 | 33 | /** |
| 34 | 34 | * 自定义表单的查看路径,使用 Vue 的路由地址 |
| 35 | 35 | * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmModelServiceImpl.java
| ... | ... | @@ -149,7 +149,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 149 | 149 | if (StrUtil.isEmpty(bpmnXml)) { |
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | - repositoryService.addModelEditorSource(model.getId(), bpmnXml.getBytes(StandardCharsets.UTF_8)); | |
| 152 | + repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml)); | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | @Override | ... | ... |
yudao-admin-ui/src/components/bpmnProcessDesigner/package/penal/base/ElementBaseInfo.vue
| ... | ... | @@ -9,19 +9,6 @@ |
| 9 | 9 | <el-form-item label="流程名称" prop="name"> |
| 10 | 10 | <el-input v-model="model.name" placeholder="请输入流程名称" clearable @change="handleNameUpdate" /> |
| 11 | 11 | </el-form-item> |
| 12 | - <el-form-item label="流程分类" prop="category"> | |
| 13 | - <el-select v-model="model.category" placeholder="请选择流程分类" clearable style="width: 100%"> | |
| 14 | - <el-option v-for="dict in categoryDictDatas" :key="dict.value" :label="dict.label" :value="dict.value"/> | |
| 15 | - </el-select> | |
| 16 | - </el-form-item> | |
| 17 | - <el-form-item label="流程表单" prop="formId"> | |
| 18 | - <el-select v-model="model.formId" placeholder="请选择流程表单,非必选哟!" clearable style="width: 100%"> | |
| 19 | - <el-option v-for="form in forms" :key="form.id" :label="form.name" :value="form.id"/> | |
| 20 | - </el-select> | |
| 21 | - </el-form-item> | |
| 22 | - <el-form-item label="流程描述" prop="description"> | |
| 23 | - <el-input type="textarea" v-model="model.description" clearable @change="handleDescriptionUpdate" /> | |
| 24 | - </el-form-item> | |
| 25 | 12 | </div> |
| 26 | 13 | <div v-else> |
| 27 | 14 | <el-form-item label="ID"> |
| ... | ... | @@ -35,9 +22,6 @@ |
| 35 | 22 | </div> |
| 36 | 23 | </template> |
| 37 | 24 | <script> |
| 38 | -import {DICT_TYPE, getDictDatas} from "@/utils/dict"; | |
| 39 | -import {getSimpleForms} from "@/api/bpm/form"; | |
| 40 | -import {getModel} from "@/api/bpm/model"; | |
| 41 | 25 | |
| 42 | 26 | export default { |
| 43 | 27 | name: "ElementBaseInfo", |
| ... | ... | @@ -54,10 +38,7 @@ export default { |
| 54 | 38 | rules: { |
| 55 | 39 | key: [{ required: true, message: "流程标识不能为空", trigger: "blur" }], |
| 56 | 40 | name: [{ required: true, message: "流程名称不能为空", trigger: "blur" }], |
| 57 | - category: [{ required: true, message: "流程分类不能为空", trigger: "blur" }], | |
| 58 | 41 | }, |
| 59 | - // 数据字典 | |
| 60 | - categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), | |
| 61 | 42 | }; |
| 62 | 43 | }, |
| 63 | 44 | watch: { |
| ... | ... | @@ -77,10 +58,6 @@ export default { |
| 77 | 58 | // } |
| 78 | 59 | }, |
| 79 | 60 | created() { |
| 80 | - // 获得流程表单的下拉框的数据 | |
| 81 | - getSimpleForms().then(response => { | |
| 82 | - this.forms = response.data | |
| 83 | - }) | |
| 84 | 61 | // 针对上传的 bpmn 流程图时,需要延迟 1 秒的时间,保证 key 和 name 的更新 |
| 85 | 62 | setTimeout(() => { |
| 86 | 63 | this.handleKeyUpdate(this.model.key) | ... | ... |
yudao-admin-ui/src/router/index.js
| ... | ... | @@ -171,8 +171,8 @@ export const constantRoutes = [ |
| 171 | 171 | { |
| 172 | 172 | path: 'manager/model/edit', |
| 173 | 173 | component: (resolve) => require(['@/views/bpm/model/modelEditor'], resolve), |
| 174 | - name: '流程模型-编辑', | |
| 175 | - meta: { title: '流程模型-编辑' } | |
| 174 | + name: '设计流程', | |
| 175 | + meta: { title: '设计流程' } | |
| 176 | 176 | } |
| 177 | 177 | ] |
| 178 | 178 | }, | ... | ... |