mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
完成流程定义的列表的实现
This commit is contained in:
parent
509e11a7b0
commit
f8b34d5b6d
@ -2,12 +2,11 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -16,8 +15,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@ -38,6 +35,7 @@ public class ProcessDefinitionController {
|
||||
return success(bpmDefinitionService.getDefinitionPage(pageReqVO));
|
||||
}
|
||||
|
||||
// TODO 芋艿:需要重写该方法
|
||||
@GetMapping(value = "/getStartForm")
|
||||
public CommonResult<String> getStartForm(@RequestParam("processKey") String processKey){
|
||||
// final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().
|
||||
@ -47,11 +45,12 @@ public class ProcessDefinitionController {
|
||||
return success("/flow/leave/apply");
|
||||
}
|
||||
|
||||
@GetMapping ("/export")
|
||||
@ApiOperation(value = "流程定义的bpmnXml导出")
|
||||
public void getDefinitionPage(@RequestParam String processDefinitionId, HttpServletResponse response) throws IOException {
|
||||
FileResp fileResp = bpmDefinitionService.export(processDefinitionId);
|
||||
ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte());
|
||||
@GetMapping ("/get-bpmn-xml")
|
||||
@ApiOperation(value = "获得流程定义的 BPMN XML")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
|
||||
public CommonResult<String> getDefinitionBpmnXML(@RequestParam("id") String id) {
|
||||
String bpmnXML = bpmDefinitionService.getDefinitionBpmnXML(id);
|
||||
return success(bpmnXML);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmPro
|
||||
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.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.engine.impl.persistence.entity.SuspensionState;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -36,6 +37,7 @@ public interface BpmDefinitionConvert {
|
||||
default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment,
|
||||
BpmProcessDefinitionDO processDefinitionDO, BpmFormDO form) {
|
||||
BpmProcessDefinitionPageItemRespVO respVO = convert(bean);
|
||||
respVO.setSuspensionState(bean.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode());
|
||||
if (deployment != null) {
|
||||
respVO.setDeploymentTime(deployment.getDeploymentTime());
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.BpmProcessDefinitionPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
|
||||
@ -31,12 +31,20 @@ public interface BpmDefinitionService {
|
||||
PageResult<BpmProcessDefinitionPageItemRespVO> getDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导出流程 bpmn 模型
|
||||
* @param processDefinitionId 分页入参
|
||||
* @return 分页model
|
||||
* 获得流程定义对应的 BPMN XML
|
||||
*
|
||||
* @param id 流程定义编号
|
||||
* @return BPMN XML
|
||||
*/
|
||||
// TODO 芋艿:考虑下重写
|
||||
FileResp export(String processDefinitionId);
|
||||
String getDefinitionBpmnXML(String id);
|
||||
|
||||
/**
|
||||
* 获得 Bpmn 模型
|
||||
*
|
||||
* @param processDefinitionId 流程定义的编号
|
||||
* @return Bpmn 模型
|
||||
*/
|
||||
BpmnModel getBpmnModel(String processDefinitionId);
|
||||
|
||||
/**
|
||||
* 获得编号对应的 ProcessDefinition
|
||||
|
@ -48,6 +48,8 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
|
||||
|
||||
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
||||
|
||||
private static final BpmnXMLConverter BPMN_XML_CONVERTER = new BpmnXMLConverter();
|
||||
|
||||
@Resource
|
||||
private RepositoryService repositoryService;
|
||||
@Resource
|
||||
@ -92,14 +94,18 @@ public class BpmDefinitionServiceImpl implements BpmDefinitionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileResp export(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
public String getDefinitionBpmnXML(String id) {
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(id);
|
||||
if (bpmnModel == null) {
|
||||
return null;
|
||||
}
|
||||
byte[] bpmnBytes = BPMN_XML_CONVERTER.convertToXML(bpmnModel);
|
||||
return StrUtil.utf8Str(bpmnBytes);
|
||||
}
|
||||
|
||||
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(bpmnModel);
|
||||
FileResp fileResp = new FileResp();
|
||||
fileResp.setFileName( "export");
|
||||
fileResp.setFileByte(bpmnBytes);
|
||||
return fileResp;
|
||||
@Override
|
||||
public BpmnModel getBpmnModel(String processDefinitionId) {
|
||||
return repositoryService.getBpmnModel(processDefinitionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,8 +20,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_FORM_FIELD_REPEAT;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_FORM_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.FORM_FIELD_REPEAT;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.FORM_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ public class BpmFormServiceImpl implements BpmFormService {
|
||||
|
||||
private void validateFormExists(Long id) {
|
||||
if (formMapper.selectById(id) == null) {
|
||||
throw exception(BPM_FORM_NOT_EXISTS);
|
||||
throw exception(FORM_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class BpmFormServiceImpl implements BpmFormService {
|
||||
continue;
|
||||
}
|
||||
// 如果存在,则报错
|
||||
throw exception(BPM_FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel());
|
||||
throw exception(FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
// 校验流程标识已经存在
|
||||
Model keyModel = this.getModelByKey(createReqVO.getKey());
|
||||
if (keyModel != null) {
|
||||
throw exception(BPM_MODEL_KEY_EXISTS, createReqVO.getKey());
|
||||
throw exception(MODEL_KEY_EXISTS, createReqVO.getKey());
|
||||
}
|
||||
|
||||
// 创建流程定义
|
||||
@ -129,7 +129,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
// 校验流程模型存在
|
||||
Model model = repositoryService.getModel(updateReqVO.getId());
|
||||
if (model == null) {
|
||||
throw exception(BPMN_MODEL_NOT_EXISTS);
|
||||
throw exception(MODEL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 修改流程定义
|
||||
@ -146,11 +146,11 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
// 校验流程模型存在
|
||||
Model model = repositoryService.getModel(id);
|
||||
if (ObjectUtils.isEmpty(model)) {
|
||||
throw exception(BPMN_MODEL_NOT_EXISTS);
|
||||
throw exception(MODEL_NOT_EXISTS);
|
||||
}
|
||||
byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId());
|
||||
if (bpmnBytes == null) {
|
||||
throw exception(BPMN_MODEL_NOT_EXISTS);
|
||||
throw exception(MODEL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 创建流程定义
|
||||
@ -169,7 +169,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
// 校验流程模型存在
|
||||
Model model = repositoryService.getModel(id);
|
||||
if (model == null) {
|
||||
throw exception(BPMN_MODEL_NOT_EXISTS);
|
||||
throw exception(MODEL_NOT_EXISTS);
|
||||
}
|
||||
// 执行删除
|
||||
repositoryService.deleteModel(id);
|
||||
@ -181,7 +181,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
|
||||
private void checkKeyNCName(String key) {
|
||||
if (!ValidationUtils.isXmlNCName(key)) {
|
||||
throw exception(BPMN_MODEL_KEY_VALID);
|
||||
throw exception(MODEL_KEY_VALID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_FORM_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.FORM_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
@ -72,7 +72,7 @@ public class BpmFormServiceTest extends BaseDbUnitTest {
|
||||
BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> formService.updateForm(reqVO), BPM_FORM_NOT_EXISTS);
|
||||
assertServiceException(() -> formService.updateForm(reqVO), FORM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -95,7 +95,7 @@ public class BpmFormServiceTest extends BaseDbUnitTest {
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> formService.deleteForm(id), BPM_FORM_NOT_EXISTS);
|
||||
assertServiceException(() -> formService.deleteForm(id), FORM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -8,9 +8,9 @@ export function getDefinitionPage(query) {
|
||||
})
|
||||
}
|
||||
|
||||
export function exportProcessDefinition(query) {
|
||||
export function getDefinitionBpmnXML(id) {
|
||||
return request({
|
||||
url: '/workflow/process/definition/export?processDefinitionId='+query.id,
|
||||
url: '/bpm/definition/get-bpmn-xml?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -2,10 +2,57 @@
|
||||
<div class="app-container">
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="ID" align="center" prop="id" />
|
||||
<el-table-column label="流程名字" align="center" prop="name" />
|
||||
<el-table-column label="定义编号" align="center" prop="id" />
|
||||
<el-table-column label="定义名称" align="center" prop="name" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="handleBpmnDetail(scope.row)">
|
||||
<span>{{ scope.row.name }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="定义分类" align="center" prop="category" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="表单信息" align="center" prop="formId">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)">
|
||||
<span>{{ scope.row.formName }}</span>
|
||||
</el-button>
|
||||
<label v-else>暂无表单</label>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-tag size="medium" v-if="scope.row">v{{ scope.row.version }}</el-tag>
|
||||
<el-tag size="medium" type="warning" v-else>未部署</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="激活状态" align="center" prop="version" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="success" v-if="scope.row.suspensionState === 1">激活</el-tag>
|
||||
<el-tag type="warning" v-if="scope.row.suspensionState === 2">挂起</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.deploymentTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="定义描述" align="center" prop="description" width="300" show-overflow-tooltip />
|
||||
</el-table>
|
||||
|
||||
<!-- 流程表单配置详情 -->
|
||||
<el-dialog title="表单详情" :visible.sync="detailOpen" width="50%" append-to-body>
|
||||
<parser :key="new Date().getTime()" :form-conf="detailForm" />
|
||||
</el-dialog>
|
||||
|
||||
<!-- 流程模型图的预览 -->
|
||||
<el-dialog title="流程图" :visible.sync="showBpmnOpen" width="80%" append-to-body>
|
||||
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
|
||||
</el-dialog>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
@ -13,10 +60,17 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getDefinitionPage} from "@/api/bpm/definition";
|
||||
import {getDefinitionBpmnXML, getDefinitionPage} from "@/api/bpm/definition";
|
||||
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
|
||||
import {getForm} from "@/api/bpm/form";
|
||||
import {decodeFields} from "@/utils/formGenerator";
|
||||
import Parser from '@/components/parser/Parser'
|
||||
|
||||
export default {
|
||||
name: "processDefinition",
|
||||
components: {
|
||||
Parser
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
@ -29,7 +83,23 @@ export default {
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10
|
||||
}
|
||||
},
|
||||
|
||||
// 流程表单详情
|
||||
detailOpen: false,
|
||||
detailForm: {
|
||||
fields: []
|
||||
},
|
||||
|
||||
// BPMN 数据
|
||||
showBpmnOpen: false,
|
||||
bpmnXML: null,
|
||||
bpmnControlForm: {
|
||||
prefix: "activiti"
|
||||
},
|
||||
|
||||
// 数据字典
|
||||
categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -50,7 +120,33 @@ export default {
|
||||
}
|
||||
);
|
||||
},
|
||||
/** 流程表单的详情按钮操作 */
|
||||
handleFormDetail(row) {
|
||||
getForm(row.formId).then(response => {
|
||||
// 设置值
|
||||
const data = response.data
|
||||
this.detailForm = {
|
||||
...JSON.parse(data.conf),
|
||||
fields: decodeFields(data.fields)
|
||||
}
|
||||
// 弹窗打开
|
||||
this.detailOpen = true
|
||||
})
|
||||
},
|
||||
/** 流程图的详情按钮操作 */
|
||||
handleBpmnDetail(row) {
|
||||
getDefinitionBpmnXML(row.id).then(response => {
|
||||
this.bpmnXML = response.data
|
||||
// 弹窗打开
|
||||
this.showBpmnOpen = true
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.my-process-designer {
|
||||
height: calc(100vh - 200px);
|
||||
}
|
||||
</style>
|
||||
|
@ -26,7 +26,7 @@
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||
v-hasPermi="['infra:config:create']">新建流程</el-button>
|
||||
v-hasPermi="['infra:config:create']">新建流程模型</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@ -72,7 +72,7 @@
|
||||
:active-value="1" :inactive-value="2" @change="handleStatusChange(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="部署时间" align="center" prop="createTime" width="180">
|
||||
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.processDefinition">{{ parseTime(scope.row.processDefinition.deploymentTime) }}</span>
|
||||
</template>
|
||||
@ -256,9 +256,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
.my-process-designer {
|
||||
height: calc(100vh - 200px);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user