Commit 1294506a95e851830fdfe2f5fe06b6f2d5eec7d3
1 parent
df91c3ce
优化流程 Model 的更新逻辑
Showing
10 changed files
with
144 additions
and
146 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/BpmModelController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.model; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelPageItemRespVO; | |
| 5 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | |
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; | |
| 7 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService; |
| 8 | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 9 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -49,16 +46,19 @@ public class BpmModelController { |
| 49 | 46 | return success(bpmModelService.createModel(createRetVO)); |
| 50 | 47 | } |
| 51 | 48 | |
| 52 | - @PostMapping("/update") | |
| 53 | - @ApiOperation(value = "修改模型属性") | |
| 54 | - public CommonResult<String> updateModel(@RequestBody BpmModelCreateReqVO modelVO) { | |
| 55 | - return bpmModelService.updateModel(modelVO); | |
| 49 | + @PutMapping("/update") | |
| 50 | + @ApiOperation(value = "修改模型") | |
| 51 | + public CommonResult<Boolean> updateModel(@RequestBody BpmModelUpdateReqVO modelVO) { | |
| 52 | + bpmModelService.updateModel(modelVO); | |
| 53 | + return success(true); | |
| 56 | 54 | } |
| 57 | 55 | |
| 58 | - @PostMapping("/delete") | |
| 59 | - @ApiOperation(value = "删除模型") | |
| 60 | - public CommonResult<String> deleteModel(@RequestParam String modelId) { | |
| 61 | - return bpmModelService.deleteModel(modelId); | |
| 56 | + @DeleteMapping("/delete") | |
| 57 | + @ApiOperation("删除模型") | |
| 58 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class) | |
| 59 | + public CommonResult<Boolean> deleteModel(@RequestParam("id") String id) { | |
| 60 | + bpmModelService.deleteModel(id); | |
| 61 | + return success(true); | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | @PostMapping("/deploy") | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelRespVO.java
| ... | ... | @@ -6,14 +6,15 @@ import lombok.Data; |
| 6 | 6 | import lombok.EqualsAndHashCode; |
| 7 | 7 | import lombok.ToString; |
| 8 | 8 | |
| 9 | -import javax.validation.constraints.NotEmpty; | |
| 10 | - | |
| 11 | 9 | @ApiModel("流程模型的创建 Request VO") |
| 12 | 10 | @Data |
| 13 | 11 | @EqualsAndHashCode(callSuper = true) |
| 14 | 12 | @ToString(callSuper = true) |
| 15 | 13 | public class BpmModelRespVO extends BpmModelBaseVO { |
| 16 | 14 | |
| 15 | + @ApiModelProperty(value = "编号", required = true, example = "1024") | |
| 16 | + private String id; | |
| 17 | + | |
| 17 | 18 | @ApiModelProperty(value = "BPMN XML", required = true) |
| 18 | 19 | private String bpmnXml; |
| 19 | 20 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import javax.validation.constraints.NotEmpty; | |
| 10 | + | |
| 11 | +@ApiModel("流程模型的更新 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class BpmModelUpdateReqVO extends BpmModelBaseVO { | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "编号", required = true, example = "1024") | |
| 18 | + @NotEmpty(message = "编号不能为空") | |
| 19 | + private String id; | |
| 20 | + | |
| 21 | + @ApiModelProperty(value = "BPMN XML", required = true) | |
| 22 | + @NotEmpty(message = "BPMN XML 不能为空") | |
| 23 | + private String bpmnXml; | |
| 24 | + | |
| 25 | +} | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.model; |
| 3 | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; |
| 4 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelPageItemRespVO; |
| 5 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; |
| 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelUpdateReqVO; | |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; |
| 8 | 9 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| ... | ... | @@ -64,6 +65,12 @@ public interface ModelConvert { |
| 64 | 65 | model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId()))); |
| 65 | 66 | } |
| 66 | 67 | |
| 68 | + default void copy(Model model, BpmModelUpdateReqVO bean) { | |
| 69 | + model.setName(bean.getName()); | |
| 70 | + model.setCategory(bean.getCategory()); | |
| 71 | + model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId()))); | |
| 72 | + } | |
| 73 | + | |
| 67 | 74 | default BpmModelMetaInfoRespDTO buildMetaInfo(String description, Long formId) { |
| 68 | 75 | BpmModelMetaInfoRespDTO metaInfo = new BpmModelMetaInfoRespDTO(); |
| 69 | 76 | metaInfo.setDescription(description); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java
| ... | ... | @@ -25,8 +25,8 @@ public interface BpmErrorCodeConstants { |
| 25 | 25 | |
| 26 | 26 | // ========== OA 工作流模块 1-009-002-000 ========== |
| 27 | 27 | ErrorCode BPM_MODEL_KEY_EXISTS = new ErrorCode(1009002000, "已经存在流程标识为【{}】的流程"); |
| 28 | + ErrorCode BPMN_MODEL_NOT_EXISTS = new ErrorCode(1009002001, "流程模型不存在"); | |
| 28 | 29 | |
| 29 | - ErrorCode BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS = new ErrorCode(1004001001, "模型数据为空,请先成功设计流程并保存"); | |
| 30 | 30 | ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常"); |
| 31 | 31 | ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001009, "流程数据为空"); |
| 32 | 32 | ErrorCode BPMN_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1004001004, "流程定义不存在"); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/BpmModelService.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.model; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelPageItemRespVO; | |
| 5 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | |
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; | |
| 7 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 8 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | 6 | |
| 7 | +import javax.validation.Valid; | |
| 8 | + | |
| 10 | 9 | /** |
| 11 | 10 | * 流程模型接口 |
| 12 | 11 | * |
| ... | ... | @@ -30,22 +29,20 @@ public interface BpmModelService { |
| 30 | 29 | */ |
| 31 | 30 | BpmModelRespVO getModel(String id); |
| 32 | 31 | |
| 33 | - // TODO @Li:不用返回 CommonResult | |
| 34 | - // TODO @Li:createBpmModal。 | |
| 35 | 32 | /** |
| 36 | 33 | * 创建流程模型 |
| 37 | 34 | * |
| 38 | 35 | * @param modelVO 创建信息 |
| 39 | 36 | * @return 创建的流程模型的编号 |
| 40 | 37 | */ |
| 41 | - String createModel(BpmModelCreateReqVO modelVO); | |
| 38 | + String createModel(@Valid BpmModelCreateReqVO modelVO); | |
| 42 | 39 | |
| 43 | 40 | /** |
| 44 | - * 修改模型属性,填充bpmn数据 | |
| 45 | - * @param modelVO 模型对象 | |
| 46 | - * @return 返回成功 | |
| 41 | + * 修改流程模型 | |
| 42 | + * | |
| 43 | + * @param updateReqVO 更新信息 | |
| 47 | 44 | */ |
| 48 | - CommonResult<String> updateModel(BpmModelCreateReqVO modelVO); | |
| 45 | + void updateModel(@Valid BpmModelUpdateReqVO updateReqVO); | |
| 49 | 46 | |
| 50 | 47 | /** |
| 51 | 48 | * 部署模型 使模型成为一个 process |
| ... | ... | @@ -56,9 +53,9 @@ public interface BpmModelService { |
| 56 | 53 | |
| 57 | 54 | /** |
| 58 | 55 | * 删除模型 |
| 59 | - * @param modelId 模型Id | |
| 60 | - * @return 返回成功 | |
| 56 | + * | |
| 57 | + * @param id 编号 | |
| 61 | 58 | */ |
| 62 | - CommonResult<String> deleteModel(String modelId); | |
| 59 | + void deleteModel(String id); | |
| 63 | 60 | |
| 64 | 61 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/impl/BpmModelServiceImpl.java
| ... | ... | @@ -2,10 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.model.impl; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelPageItemRespVO; | |
| 7 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | |
| 8 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | |
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.*; | |
| 9 | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert; |
| 10 | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; |
| 11 | 8 | import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants; |
| ... | ... | @@ -115,6 +112,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 115 | 112 | if (keyModel != null) { |
| 116 | 113 | throw exception(BPM_MODEL_KEY_EXISTS); |
| 117 | 114 | } |
| 115 | + // TODO @芋艿:需要校验下 key 的格式 | |
| 118 | 116 | |
| 119 | 117 | // 创建流程定义 |
| 120 | 118 | Model model = repositoryService.newModel(); |
| ... | ... | @@ -139,53 +137,22 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 139 | 137 | // return definition.getId(); |
| 140 | 138 | // } |
| 141 | 139 | |
| 142 | -// @Override | |
| 143 | -// @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | |
| 144 | -// public String createModel(BpmModelCreateReqVO createReqVO) { | |
| 145 | -// // 校验流程标识已经存在 | |
| 146 | -// Model keyModel = this.getModelByKey(createReqVO.getKey()); | |
| 147 | -// if (keyModel != null) { | |
| 148 | -// throw exception(BPM_MODEL_KEY_EXISTS); | |
| 149 | -// } | |
| 150 | -// | |
| 151 | -// // 创建流程定义 | |
| 152 | -// Model model = repositoryService.newModel(); | |
| 153 | -// ModelConvert.INSTANCE.copy(model, createReqVO); | |
| 154 | -// // 保存流程定义 | |
| 155 | -// repositoryService.saveModel(model); | |
| 156 | -// // 添加 BPMN XML | |
| 157 | -// repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(createReqVO.getBpmnXml())); | |
| 158 | -// return model.getId(); | |
| 159 | -// } | |
| 160 | - | |
| 161 | 140 | @Override |
| 162 | - public CommonResult<String> updateModel(BpmModelCreateReqVO modelVO) { | |
| 163 | -// try { | |
| 164 | -// Model model = repositoryService.getModel(modelVO.getId()); | |
| 165 | -// if (ObjectUtils.isEmpty(model)) { | |
| 166 | -// throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); | |
| 167 | -// } | |
| 168 | -// // 只能修改名字跟描述 | |
| 169 | -// BpmModelCreateReqVO modelCreateVO = JsonUtils.parseObject(model.getMetaInfo(), BpmModelCreateReqVO.class); | |
| 170 | -// if (ObjectUtils.isEmpty(modelCreateVO)) { | |
| 171 | -// modelCreateVO = new BpmModelCreateReqVO(); | |
| 172 | -// } | |
| 173 | -// modelCreateVO.setName(modelVO.getName()); | |
| 174 | -// modelCreateVO.setDescription(modelVO.getDescription()); | |
| 175 | -// model.setMetaInfo(JsonUtils.toJsonString(modelCreateVO)); | |
| 176 | -// model.setName(modelVO.getName()); | |
| 177 | -// model.setKey(modelVO.getKey()); | |
| 178 | -// // 更新模型 | |
| 179 | -// repositoryService.saveModel(model); | |
| 180 | -// | |
| 181 | -// repositoryService.addModelEditorSource(model.getId(), modelVO.getBpmnXml().getBytes(StandardCharsets.UTF_8)); | |
| 182 | -// | |
| 183 | -// return CommonResult.success("保存成功"); | |
| 184 | -// }catch (Exception e){ | |
| 185 | -// log.info("模型更新失败!modelVO = {}", modelVO, e); | |
| 186 | -// throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); | |
| 187 | -// } | |
| 188 | - return null; | |
| 141 | + @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | |
| 142 | + public void updateModel(BpmModelUpdateReqVO updateReqVO) { | |
| 143 | + // 校验流程模型存在 | |
| 144 | + Model model = repositoryService.getModel(updateReqVO.getId()); | |
| 145 | + if (model == null) { | |
| 146 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | |
| 147 | + } | |
| 148 | + // TODO @芋艿:需要校验下 key 的格式 | |
| 149 | + | |
| 150 | + // 修改流程定义 | |
| 151 | + ModelConvert.INSTANCE.copy(model, updateReqVO); | |
| 152 | + // 更新模型 | |
| 153 | + repositoryService.saveModel(model); | |
| 154 | + // 更新 BPMN XML | |
| 155 | + repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(updateReqVO.getBpmnXml())); | |
| 189 | 156 | } |
| 190 | 157 | |
| 191 | 158 | @Override |
| ... | ... | @@ -193,11 +160,11 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 193 | 160 | try { |
| 194 | 161 | Model modelData = repositoryService.getModel(modelId); |
| 195 | 162 | if (ObjectUtils.isEmpty(modelData)) { |
| 196 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); | |
| 163 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | |
| 197 | 164 | } |
| 198 | 165 | byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); |
| 199 | 166 | if (bytes == null) { |
| 200 | - throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); | |
| 167 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | |
| 201 | 168 | } |
| 202 | 169 | // 将xml转换为流 |
| 203 | 170 | // TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个 |
| ... | ... | @@ -226,10 +193,14 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 226 | 193 | } |
| 227 | 194 | |
| 228 | 195 | @Override |
| 229 | - public CommonResult<String> deleteModel(String modelId) { | |
| 230 | - // TODO @Li:activitie 是逻辑删除么? | |
| 231 | - repositoryService.deleteModel(modelId); | |
| 232 | - return CommonResult.success("删除成功"); | |
| 196 | + public void deleteModel(String id) { | |
| 197 | + // 校验流程模型存在 | |
| 198 | + Model model = repositoryService.getModel(id); | |
| 199 | + if (model == null) { | |
| 200 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_NOT_EXISTS); | |
| 201 | + } | |
| 202 | + // 执行删除 | |
| 203 | + repositoryService.deleteModel(id); | |
| 233 | 204 | } |
| 234 | 205 | |
| 235 | 206 | private Model getModelByKey(String key) { | ... | ... |
yudao-admin-ui/src/api/bpm/model.js
| 1 | 1 | import request from '@/utils/request' |
| 2 | 2 | |
| 3 | -export function page(query) { | |
| 3 | +export function getModelPage(query) { | |
| 4 | 4 | return request({ |
| 5 | 5 | url: '/bpm/model/page', |
| 6 | 6 | method: 'get', |
| ... | ... | @@ -15,15 +15,15 @@ export function getModel(id) { |
| 15 | 15 | }) |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -export function modelUpdate(data) { | |
| 18 | +export function updateModel(data) { | |
| 19 | 19 | return request({ |
| 20 | 20 | url: '/bpm/model/update', |
| 21 | - method: 'POST', | |
| 21 | + method: 'PUT', | |
| 22 | 22 | data: data |
| 23 | 23 | }) |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -export function modelSave(data) { | |
| 26 | +export function createModel(data) { | |
| 27 | 27 | return request({ |
| 28 | 28 | url: '/bpm/model/create', |
| 29 | 29 | method: 'POST', |
| ... | ... | @@ -31,15 +31,14 @@ export function modelSave(data) { |
| 31 | 31 | }) |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -export function modelDelete(data) { | |
| 34 | +export function deleteModel(id) { | |
| 35 | 35 | return request({ |
| 36 | - url: '/bpm/model/delete?modelId='+ data.modelId, | |
| 37 | - method: 'POST', | |
| 38 | - data: data | |
| 36 | + url: '/bpm/model/delete?id=' + id, | |
| 37 | + method: 'DELETE' | |
| 39 | 38 | }) |
| 40 | 39 | } |
| 41 | 40 | |
| 42 | -export function modelDeploy(data) { | |
| 41 | +export function deployModel(data) { | |
| 43 | 42 | return request({ |
| 44 | 43 | url: '/bpm/model/deploy?modelId='+ data.modelId, |
| 45 | 44 | method: 'POST', | ... | ... |
yudao-admin-ui/src/views/bpm/model/index.vue
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | <!-- 操作工具栏 --> |
| 17 | 17 | <el-row :gutter="10" class="mb8"> |
| 18 | 18 | <el-col :span="1.5"> |
| 19 | - <el-button type="primary" icon="el-icon-plus" size="mini" @click="openBpmn" | |
| 19 | + <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" | |
| 20 | 20 | v-hasPermi="['infra:config:create']">新建流程</el-button> |
| 21 | 21 | </el-col> |
| 22 | 22 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| ... | ... | @@ -38,26 +38,26 @@ |
| 38 | 38 | </el-table-column> |
| 39 | 39 | <el-table-column label="操作" align="center" width="240"> |
| 40 | 40 | <template slot-scope="scope"> |
| 41 | - <el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button> | |
| 41 | + <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button> | |
| 42 | 42 | <el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button> |
| 43 | 43 | <el-button size="mini" type="text" icon="el-icon-thumb" @click="modelDeploy(scope.row)">发布</el-button> |
| 44 | 44 | </template> |
| 45 | 45 | </el-table-column> |
| 46 | 46 | </el-table> |
| 47 | - | |
| 47 | + <!-- 分页组件 --> | |
| 48 | 48 | <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" |
| 49 | 49 | @pagination="getList"/> |
| 50 | 50 | |
| 51 | - | |
| 52 | - <el-dialog class="bpmnclass dialogClass" :visible.sync="showBpmnBool" :before-close="close" :fullscreen="true"> | |
| 53 | - <vue-bpmn v-if="showBpmnBool" product="activiti" @processSave="processSave" | |
| 54 | - :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="close" /> | |
| 51 | + <!-- 流程编辑器 --> | |
| 52 | + <el-dialog class="bpmnclass dialogClass" :visible.sync="showBpmnOpen" :before-cancel="cancel" :fullscreen="true"> | |
| 53 | + <vue-bpmn v-if="showBpmnOpen" product="activiti" @processSave="processSave" | |
| 54 | + :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="cancel" /> | |
| 55 | 55 | </el-dialog> |
| 56 | 56 | </div> |
| 57 | 57 | </template> |
| 58 | 58 | |
| 59 | 59 | <script> |
| 60 | -import {modelDelete, modelDeploy, modelSave, modelUpdate, page, getModel} from "@/api/bpm/model"; | |
| 60 | +import {deleteModel, deployModel, createModel, updateModel, getModelPage, getModel} from "@/api/bpm/model"; | |
| 61 | 61 | import VueBpmn from "@/components/bpmn/VueBpmn"; |
| 62 | 62 | |
| 63 | 63 | export default { |
| ... | ... | @@ -68,7 +68,6 @@ export default { |
| 68 | 68 | loading: true, |
| 69 | 69 | // 显示搜索条件 |
| 70 | 70 | showSearch: true, |
| 71 | - showBpmnBool: false, | |
| 72 | 71 | // 总条数 |
| 73 | 72 | total: 0, |
| 74 | 73 | // 表格数据 |
| ... | ... | @@ -79,6 +78,7 @@ export default { |
| 79 | 78 | pageSize: 10 |
| 80 | 79 | }, |
| 81 | 80 | // BPMN 数据 |
| 81 | + showBpmnOpen: false, | |
| 82 | 82 | bpmnXML: null, |
| 83 | 83 | bpmnData: {}, |
| 84 | 84 | }; |
| ... | ... | @@ -88,19 +88,20 @@ export default { |
| 88 | 88 | this.getList(); |
| 89 | 89 | }, |
| 90 | 90 | methods: { |
| 91 | - /** 查询登录日志列表 */ | |
| 91 | + /** 查询流程模型列表 */ | |
| 92 | 92 | getList() { |
| 93 | 93 | this.loading = true; |
| 94 | - page(this.queryParams).then(response => { | |
| 94 | + getModelPage(this.queryParams).then(response => { | |
| 95 | 95 | this.list = response.data.list; |
| 96 | 96 | this.total = response.data.total; |
| 97 | 97 | this.loading = false; |
| 98 | 98 | } |
| 99 | 99 | ); |
| 100 | 100 | }, |
| 101 | - // 登录状态字典翻译 | |
| 102 | - statusFormat(row, column) { | |
| 103 | - return this.selectDictLabel(this.statusOptions, row.status); | |
| 101 | + // 表单重置 | |
| 102 | + reset() { | |
| 103 | + this.bpmnData = {} | |
| 104 | + this.bpmnXML = "" | |
| 104 | 105 | }, |
| 105 | 106 | /** 搜索按钮操作 */ |
| 106 | 107 | handleQuery() { |
| ... | ... | @@ -114,49 +115,48 @@ export default { |
| 114 | 115 | this.handleQuery(); |
| 115 | 116 | }, |
| 116 | 117 | processSave(data) { |
| 117 | - const that = this; | |
| 118 | - // 如果存在id 说明是修改 | |
| 118 | + // 修改的提交 | |
| 119 | 119 | if (data.id) { |
| 120 | - let postData = JSON.parse(data.metaInfo) | |
| 121 | - postData.bpmnXml = data.bpmnXml | |
| 122 | - postData.id = data.id | |
| 123 | - postData.name = data.name | |
| 124 | - postData.key = data.key | |
| 125 | - postData.description = data.description | |
| 126 | - modelUpdate(postData).then(response => { | |
| 127 | - this.msgSuccess("保存成功"); | |
| 120 | + updateModel(data).then(response => { | |
| 121 | + this.msgSuccess("修改成功"); | |
| 122 | + // 关闭弹窗,刷新列表 | |
| 123 | + this.showBpmnOpen = false | |
| 124 | + this.getList(); | |
| 128 | 125 | }) |
| 129 | - this.showBpmnBool = false | |
| 130 | - this.getList(); | |
| 131 | 126 | return |
| 132 | 127 | } |
| 133 | - modelSave(data).then(response => { | |
| 134 | - that.bpmnData.id = response.data | |
| 128 | + // 添加的提交 | |
| 129 | + createModel(data).then(response => { | |
| 130 | + this.bpmnData.id = response.data | |
| 135 | 131 | this.msgSuccess("保存成功"); |
| 132 | + // 关闭弹窗,刷新列表 | |
| 133 | + this.showBpmnOpen = false | |
| 134 | + this.getList(); | |
| 136 | 135 | }) |
| 137 | - | |
| 138 | - this.showBpmnBool = false | |
| 139 | - this.getList(); | |
| 140 | 136 | }, |
| 141 | - openBpmn() { | |
| 142 | - this.bpmnData = {} | |
| 143 | - this.bpmnXML = "" | |
| 144 | - this.showBpmnBool = true | |
| 137 | + handleAdd() { | |
| 138 | + // 重置 Model 信息 | |
| 139 | + this.reset() | |
| 140 | + // 打开弹窗 | |
| 141 | + this.showBpmnOpen = true | |
| 145 | 142 | }, |
| 146 | - close() { | |
| 147 | - this.showBpmnBool = false | |
| 148 | - this.getList(); | |
| 143 | + cancel() { | |
| 144 | + // 打开弹窗 | |
| 145 | + this.showBpmnOpen = false | |
| 146 | + // 重置 Model 信息 | |
| 147 | + this.reset() | |
| 148 | + // 刷新列表 | |
| 149 | + this.getList() | |
| 149 | 150 | }, |
| 150 | - change(row) { | |
| 151 | + handleUpdate(row) { | |
| 151 | 152 | // 重置 Model 信息 |
| 152 | - this.bpmnXML = "" | |
| 153 | - this.bpmnData = {} | |
| 153 | + this.reset() | |
| 154 | 154 | // 获得 Model 信息 |
| 155 | 155 | getModel(row.id).then(response => { |
| 156 | 156 | this.bpmnXML = response.data.bpmnXml |
| 157 | 157 | this.bpmnData = response.data |
| 158 | 158 | // 打开弹窗 |
| 159 | - this.showBpmnBool = true | |
| 159 | + this.showBpmnOpen = true | |
| 160 | 160 | }) |
| 161 | 161 | }, |
| 162 | 162 | modelDelete(row) { |
| ... | ... | @@ -166,9 +166,7 @@ export default { |
| 166 | 166 | cancelButtonText: "取消", |
| 167 | 167 | type: "warning" |
| 168 | 168 | }).then(function() { |
| 169 | - modelDelete({ | |
| 170 | - modelId: row.id | |
| 171 | - }).then(response => { | |
| 169 | + deleteModel(row.id).then(response => { | |
| 172 | 170 | that.getList(); |
| 173 | 171 | that.msgSuccess("删除成功"); |
| 174 | 172 | }) |
| ... | ... | @@ -181,7 +179,7 @@ export default { |
| 181 | 179 | cancelButtonText: "取消", |
| 182 | 180 | type: "success" |
| 183 | 181 | }).then(function() { |
| 184 | - modelDeploy({ | |
| 182 | + deployModel({ | |
| 185 | 183 | modelId: row.id |
| 186 | 184 | }).then(response => { |
| 187 | 185 | that.getList(); | ... | ... |
yudao-admin-ui/src/views/bpm/processDefinition/index.vue
| ... | ... | @@ -33,8 +33,8 @@ |
| 33 | 33 | <el-table-column label="操作" align="center" > |
| 34 | 34 | <template slot-scope="scope"> |
| 35 | 35 | <!-- <el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button>--> |
| 36 | -<!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button>--> | |
| 37 | -<!-- <el-button size="mini" type="text" icon="el-icon-thumb" @click="modelDeploy(scope.row)">发布</el-button>--> | |
| 36 | +<!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="deleteModel(scope.row)">删除</el-button>--> | |
| 37 | +<!-- <el-button size="mini" type="text" icon="el-icon-thumb" @click="deployModel(scope.row)">发布</el-button>--> | |
| 38 | 38 | </template> |
| 39 | 39 | </el-table-column> |
| 40 | 40 | </el-table> |
| ... | ... | @@ -114,14 +114,14 @@ export default { |
| 114 | 114 | postData.name = data.name |
| 115 | 115 | postData.key = data.key |
| 116 | 116 | postData.description = data.description |
| 117 | - modelUpdate(postData).then(response => { | |
| 117 | + updateModel(postData).then(response => { | |
| 118 | 118 | this.msgSuccess("保存成功"); |
| 119 | 119 | }) |
| 120 | 120 | this.showBpmnBool = false |
| 121 | 121 | this.getList(); |
| 122 | 122 | return |
| 123 | 123 | } |
| 124 | - modelSave(data).then(response => { | |
| 124 | + createModel(data).then(response => { | |
| 125 | 125 | that.bpmnData.id = response.data |
| 126 | 126 | this.msgSuccess("保存成功"); |
| 127 | 127 | }) |
| ... | ... | @@ -151,7 +151,7 @@ export default { |
| 151 | 151 | cancelButtonText: "取消", |
| 152 | 152 | type: "warning" |
| 153 | 153 | }).then(function() { |
| 154 | - modelDelete({ | |
| 154 | + deleteModel({ | |
| 155 | 155 | modelId: row.id |
| 156 | 156 | }).then(response => { |
| 157 | 157 | that.getList(); |
| ... | ... | @@ -166,7 +166,7 @@ export default { |
| 166 | 166 | cancelButtonText: "取消", |
| 167 | 167 | type: "success" |
| 168 | 168 | }).then(function() { |
| 169 | - modelDeploy({ | |
| 169 | + deployModel({ | |
| 170 | 170 | modelId: row.id |
| 171 | 171 | }).then(response => { |
| 172 | 172 | that.getList(); | ... | ... |