mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-11-01 03:28:41 +08:00 
			
		
		
		
	BPM 模型重构 3:设置流程时,去掉 formId、description 等的传递,专注设计本身
This commit is contained in:
		| @ -1,5 +1,6 @@ | |||||||
| package cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo; | package cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo; | ||||||
|  |  | ||||||
|  | import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum; | ||||||
| import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
| @ -10,9 +11,7 @@ import javax.validation.constraints.NotEmpty; | |||||||
|  |  | ||||||
| @ApiModel("流程模型的更新 Request VO") | @ApiModel("流程模型的更新 Request VO") | ||||||
| @Data | @Data | ||||||
| @EqualsAndHashCode(callSuper = true) | public class BpmModelUpdateReqVO { | ||||||
| @ToString(callSuper = true) |  | ||||||
| public class BpmModelUpdateReqVO extends BpmModelBaseVO { |  | ||||||
|  |  | ||||||
|     @ApiModelProperty(value = "编号", required = true, example = "1024") |     @ApiModelProperty(value = "编号", required = true, example = "1024") | ||||||
|     @NotEmpty(message = "编号不能为空") |     @NotEmpty(message = "编号不能为空") | ||||||
| @ -27,10 +26,18 @@ public class BpmModelUpdateReqVO extends BpmModelBaseVO { | |||||||
|     @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1") |     @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1") | ||||||
|     private String category; |     private String category; | ||||||
|  |  | ||||||
|     @ApiModelProperty(value = "表单编号", example = "1024") |  | ||||||
|     private Long formId; |  | ||||||
|  |  | ||||||
|     @ApiModelProperty(value = "BPMN XML", required = true) |     @ApiModelProperty(value = "BPMN XML", required = true) | ||||||
|     private String bpmnXml; |     private String bpmnXml; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1") | ||||||
|  |     private Integer formType; | ||||||
|  |     @ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") | ||||||
|  |     private Long formId; | ||||||
|  |     @ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create", | ||||||
|  |             notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") | ||||||
|  |     private String formCustomCreatePath; | ||||||
|  |     @ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view", | ||||||
|  |             notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空") | ||||||
|  |     private String formCustomViewPath; | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| package cn.iocoder.yudao.adminserver.modules.bpm.convert.model; | package cn.iocoder.yudao.adminserver.modules.bpm.convert.model; | ||||||
|  |  | ||||||
|  | import cn.hutool.core.util.StrUtil; | ||||||
| import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; | ||||||
| import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | ||||||
| import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; | ||||||
| @ -15,10 +16,11 @@ import org.mapstruct.factory.Mappers; | |||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  | import java.util.Objects; | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 流程定义 Convert |  * 流程模型 Convert | ||||||
|  * |  * | ||||||
|  * @author yunlongn |  * @author yunlongn | ||||||
|  */ |  */ | ||||||
| @ -95,20 +97,34 @@ public interface BpmModelConvert { | |||||||
|     default void copy(Model model, BpmModelCreateReqVO bean) { |     default void copy(Model model, BpmModelCreateReqVO bean) { | ||||||
|         model.setName(bean.getName()); |         model.setName(bean.getName()); | ||||||
|         model.setKey(bean.getKey()); |         model.setKey(bean.getKey()); | ||||||
|         model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), null))); |         model.setMetaInfo(buildMetaInfoStr(null, bean.getDescription(), null, null, | ||||||
|  |                 null, null)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     default void copy(Model model, BpmModelUpdateReqVO bean) { |     default void copy(Model model, BpmModelUpdateReqVO bean) { | ||||||
|         model.setName(bean.getName()); |         model.setName(bean.getName()); | ||||||
|         model.setCategory(bean.getCategory()); |         model.setCategory(bean.getCategory()); | ||||||
|         model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId()))); |         model.setMetaInfo(buildMetaInfoStr(JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class), | ||||||
|  |                 bean.getDescription(), bean.getFormType(), bean.getFormId(), | ||||||
|  |                 bean.getFormCustomCreatePath(), bean.getFormCustomViewPath())); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     default BpmModelMetaInfoRespDTO buildMetaInfo(String description, Long formId) { |     default String buildMetaInfoStr(BpmModelMetaInfoRespDTO metaInfo, String description, Integer formType, | ||||||
|         BpmModelMetaInfoRespDTO metaInfo = new BpmModelMetaInfoRespDTO(); |                                     Long formId, String formCustomCreatePath, String formCustomViewPath) { | ||||||
|         metaInfo.setDescription(description); |         if (metaInfo == null) { | ||||||
|         metaInfo.setFormId(formId); |             metaInfo = new BpmModelMetaInfoRespDTO(); | ||||||
|         return metaInfo; |         } | ||||||
|  |         // 只有非空,才进行设置,避免更新时的覆盖 | ||||||
|  |         if (StrUtil.isNotEmpty(description)) { | ||||||
|  |             metaInfo.setDescription(description); | ||||||
|  |         } | ||||||
|  |         if (Objects.nonNull(formType)) { | ||||||
|  |             metaInfo.setFormType(formType); | ||||||
|  |             metaInfo.setFormId(formId); | ||||||
|  |             metaInfo.setFormCustomCreatePath(formCustomCreatePath); | ||||||
|  |             metaInfo.setFormCustomViewPath(formCustomViewPath); | ||||||
|  |         } | ||||||
|  |         return JsonUtils.toJsonString(metaInfo); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     BpmModelPageItemRespVO.ProcessDefinition convert(ProcessDefinition bean); |     BpmModelPageItemRespVO.ProcessDefinition convert(ProcessDefinition bean); | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ public class BpmModelMetaInfoRespDTO { | |||||||
|     /** |     /** | ||||||
|      * 表单类型 |      * 表单类型 | ||||||
|      */ |      */ | ||||||
|     private Long formType; |     private Integer formType; | ||||||
|     /** |     /** | ||||||
|      * 表单编号 |      * 表单编号 | ||||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 |      * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 | ||||||
| @ -29,7 +29,7 @@ public class BpmModelMetaInfoRespDTO { | |||||||
|      * 自定义表单的提交路径,使用 Vue 的路由地址 |      * 自定义表单的提交路径,使用 Vue 的路由地址 | ||||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 |      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 | ||||||
|      */ |      */ | ||||||
|     private String formCustomSubmitPath; |     private String formCustomCreatePath; | ||||||
|     /** |     /** | ||||||
|      * 自定义表单的查看路径,使用 Vue 的路由地址 |      * 自定义表单的查看路径,使用 Vue 的路由地址 | ||||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 |      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 | ||||||
|  | |||||||
| @ -149,7 +149,7 @@ public class BpmModelServiceImpl implements BpmModelService { | |||||||
|         if (StrUtil.isEmpty(bpmnXml)) { |         if (StrUtil.isEmpty(bpmnXml)) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         repositoryService.addModelEditorSource(model.getId(), bpmnXml.getBytes(StandardCharsets.UTF_8)); |         repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -9,19 +9,6 @@ | |||||||
|         <el-form-item label="流程名称" prop="name"> |         <el-form-item label="流程名称" prop="name"> | ||||||
|           <el-input v-model="model.name" placeholder="请输入流程名称" clearable @change="handleNameUpdate" /> |           <el-input v-model="model.name" placeholder="请输入流程名称" clearable @change="handleNameUpdate" /> | ||||||
|         </el-form-item> |         </el-form-item> | ||||||
|         <el-form-item label="流程分类" prop="category"> |  | ||||||
|           <el-select v-model="model.category" placeholder="请选择流程分类" clearable style="width: 100%"> |  | ||||||
|             <el-option v-for="dict in categoryDictDatas" :key="dict.value" :label="dict.label" :value="dict.value"/> |  | ||||||
|           </el-select> |  | ||||||
|         </el-form-item> |  | ||||||
|         <el-form-item label="流程表单" prop="formId"> |  | ||||||
|           <el-select v-model="model.formId" placeholder="请选择流程表单,非必选哟!" clearable style="width: 100%"> |  | ||||||
|             <el-option v-for="form in forms" :key="form.id" :label="form.name" :value="form.id"/> |  | ||||||
|           </el-select> |  | ||||||
|         </el-form-item> |  | ||||||
|         <el-form-item label="流程描述" prop="description"> |  | ||||||
|           <el-input type="textarea" v-model="model.description" clearable @change="handleDescriptionUpdate" /> |  | ||||||
|         </el-form-item> |  | ||||||
|       </div> |       </div> | ||||||
|       <div v-else> |       <div v-else> | ||||||
|         <el-form-item label="ID"> |         <el-form-item label="ID"> | ||||||
| @ -35,9 +22,6 @@ | |||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| <script> | <script> | ||||||
| import {DICT_TYPE, getDictDatas} from "@/utils/dict"; |  | ||||||
| import {getSimpleForms} from "@/api/bpm/form"; |  | ||||||
| import {getModel} from "@/api/bpm/model"; |  | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   name: "ElementBaseInfo", |   name: "ElementBaseInfo", | ||||||
| @ -54,10 +38,7 @@ export default { | |||||||
|       rules: { |       rules: { | ||||||
|         key: [{ required: true, message: "流程标识不能为空", trigger: "blur" }], |         key: [{ required: true, message: "流程标识不能为空", trigger: "blur" }], | ||||||
|         name: [{ required: true, message: "流程名称不能为空", trigger: "blur" }], |         name: [{ required: true, message: "流程名称不能为空", trigger: "blur" }], | ||||||
|         category: [{ required: true, message: "流程分类不能为空", trigger: "blur" }], |  | ||||||
|       }, |       }, | ||||||
|       // 数据字典 |  | ||||||
|       categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), |  | ||||||
|     }; |     }; | ||||||
|   }, |   }, | ||||||
|   watch: { |   watch: { | ||||||
| @ -77,10 +58,6 @@ export default { | |||||||
|     // } |     // } | ||||||
|   }, |   }, | ||||||
|   created() { |   created() { | ||||||
|     // 获得流程表单的下拉框的数据 |  | ||||||
|     getSimpleForms().then(response => { |  | ||||||
|       this.forms = response.data |  | ||||||
|     }) |  | ||||||
|     // 针对上传的 bpmn 流程图时,需要延迟 1 秒的时间,保证 key 和 name 的更新 |     // 针对上传的 bpmn 流程图时,需要延迟 1 秒的时间,保证 key 和 name 的更新 | ||||||
|     setTimeout(() => { |     setTimeout(() => { | ||||||
|       this.handleKeyUpdate(this.model.key) |       this.handleKeyUpdate(this.model.key) | ||||||
|  | |||||||
| @ -171,8 +171,8 @@ export const constantRoutes = [ | |||||||
|       { |       { | ||||||
|         path: 'manager/model/edit', |         path: 'manager/model/edit', | ||||||
|         component: (resolve) => require(['@/views/bpm/model/modelEditor'], resolve), |         component: (resolve) => require(['@/views/bpm/model/modelEditor'], resolve), | ||||||
|         name: '流程模型-编辑', |         name: '设计流程', | ||||||
|         meta: { title: '流程模型-编辑' } |         meta: { title: '设计流程' } | ||||||
|       } |       } | ||||||
|     ] |     ] | ||||||
|   }, |   }, | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV