Commit a829e8d083380bca2db19fb411a4655fd8f3f02b

Authored by yunlong.li
1 parent 3f90e79d

初步完善模型发布流程

yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/ModelController.java
1 1 package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow;
2 2  
3   -import cn.hutool.core.util.StrUtil;
4 3 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
5   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.TodoTaskRespVO;
6   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelCreateVO;
7 4 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelPageReqVo;
8   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelRespVo;
9   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelUpdateVO;
  5 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelVO;
10 6 import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService;
11 7 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
12 8 import cn.iocoder.yudao.framework.common.pojo.PageResult;
13 9 import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
14   -import com.fasterxml.jackson.databind.ObjectMapper;
15   -import com.fasterxml.jackson.databind.node.ObjectNode;
16 10 import io.swagger.annotations.Api;
17 11 import io.swagger.annotations.ApiOperation;
18 12 import lombok.RequiredArgsConstructor;
19 13 import lombok.extern.slf4j.Slf4j;
20   -import org.activiti.engine.*;
21 14 import org.activiti.engine.repository.Model;
22   -import org.springframework.beans.factory.annotation.Autowired;
23   -import org.springframework.stereotype.Controller;
24 15 import org.springframework.web.bind.annotation.*;
25 16  
26   -import javax.servlet.http.HttpServletRequest;
27 17 import javax.servlet.http.HttpServletResponse;
28 18 import java.io.IOException;
29   -import java.io.UnsupportedEncodingException;
30 19  
31 20 /**
32 21 * 工作流模型
... ... @@ -49,14 +38,14 @@ public class ModelController {
49 38  
50 39 @PostMapping("/create")
51 40 @ApiOperation(value = "新建模型")
52   - public CommonResult<String> newModel(@RequestBody ModelCreateVO modelCreateVO) {
53   - return bpmModelService.newModel(modelCreateVO);
  41 + public CommonResult<String> newModel(@RequestBody ModelVO modelVO) {
  42 + return bpmModelService.newModel(modelVO);
54 43 }
55 44  
56 45 @PostMapping("/update")
57 46 @ApiOperation(value = "修改模型属性")
58   - public CommonResult<String> updateModel(@RequestBody ModelUpdateVO modelUpdateVO) {
59   - return bpmModelService.updateModel(modelUpdateVO);
  47 + public CommonResult<String> updateModel(@RequestBody ModelVO modelVO) {
  48 + return bpmModelService.updateModel(modelVO);
60 49 }
61 50  
62 51 @PostMapping("/delete")
... ... @@ -72,9 +61,9 @@ public class ModelController {
72 61 }
73 62  
74 63 @GetMapping("/exportBpmnXml")
75   - @ApiOperation(value = "导出模型")
76   - public void export(@RequestParam String deploymentId, HttpServletResponse response) throws IOException {
77   - FileResp fileResp = bpmModelService.exportBpmnXml(deploymentId);
  64 + @ApiOperation(value = "导出模型Xml")
  65 + public void export(@RequestParam String modelId, HttpServletResponse response) throws IOException {
  66 + FileResp fileResp = bpmModelService.exportBpmnXml(modelId);
78 67 ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte());
79 68 }
80 69  
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/model/ModelCreateVO.java deleted
1   -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model;
2   -
3   -import io.swagger.annotations.ApiModelProperty;
4   -import lombok.Data;
5   -
6   -/**
7   - * 新增模型 VO
8   - * @author yunlongn
9   - */
10   -@Data
11   -public class ModelCreateVO {
12   -
13   - @ApiModelProperty(value = "模型名字", required = true)
14   - private String name;
15   -
16   - @ApiModelProperty(value = "模型描述")
17   - private String description;
18   -
19   - @ApiModelProperty(value = "版本号")
20   - private Integer revision;
21   -
22   - @ApiModelProperty(value = "key值")
23   - private String key;
24   -}
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/model/ModelUpdateVO.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/model/ModelVO.java
... ... @@ -8,9 +8,9 @@ import lombok.Data;
8 8 * @author yunlongn
9 9 */
10 10 @Data
11   -public class ModelUpdateVO {
  11 +public class ModelVO {
12 12  
13   - @ApiModelProperty(value = "模型Id", required = true)
  13 + @ApiModelProperty(value = "模型Id")
14 14 private String id;
15 15  
16 16 @ApiModelProperty(value = "模型名字", required = true)
... ... @@ -27,6 +27,4 @@ public class ModelUpdateVO {
27 27  
28 28 @ApiModelProperty(value = "bpmnXml")
29 29 private String bpmnXml;
30   -
31   -
32 30 }
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmModelService.java
1 1 package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow;
2 2  
3 3 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
4   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelCreateVO;
5 4 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelPageReqVo;
6   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelRespVo;
7   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelUpdateVO;
  5 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelVO;
8 6 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
9 7 import cn.iocoder.yudao.framework.common.pojo.PageResult;
10 8 import org.activiti.engine.repository.Model;
11 9  
12   -import javax.servlet.http.HttpServletResponse;
13   -
14 10 /**
15 11 * 工作流模型接口
16 12 * @author yunlongn
... ... @@ -27,16 +23,16 @@ public interface BpmModelService {
27 23  
28 24 /**
29 25 * 新增一个模型
30   - * @param modelCreateVO 模型对象
  26 + * @param modelVO 模型对象
31 27 * @return 返回成功
32 28 */
33   - CommonResult<String> newModel(ModelCreateVO modelCreateVO);
  29 + CommonResult<String> newModel(ModelVO modelVO);
34 30 /**
35 31 * 修改模型属性,填充bpmn数据
36   - * @param modelUpdateVO 模型对象
  32 + * @param modelVO 模型对象
37 33 * @return 返回成功
38 34 */
39   - CommonResult<String> updateModel(ModelUpdateVO modelUpdateVO);
  35 + CommonResult<String> updateModel(ModelVO modelVO);
40 36  
41 37 /**
42 38 * 部署模型 使模型成为一个 process
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmModelServiceImpl.java
1 1 package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl;
2 2  
3   -import cn.hutool.core.io.IoUtil;
4 3 import cn.hutool.core.util.StrUtil;
5 4 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
6   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelCreateVO;
7 5 import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelPageReqVo;
8   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelRespVo;
9   -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelUpdateVO;
  6 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelVO;
10 7 import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants;
11 8 import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService;
12 9 import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
... ... @@ -15,26 +12,20 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
15 12 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
16 13 import lombok.RequiredArgsConstructor;
17 14 import lombok.extern.slf4j.Slf4j;
18   -import org.activiti.api.runtime.shared.query.Pageable;
19 15 import org.activiti.bpmn.converter.BpmnXMLConverter;
20 16 import org.activiti.bpmn.model.BpmnModel;
21 17 import org.activiti.engine.RepositoryService;
22 18 import org.activiti.engine.repository.Deployment;
23 19 import org.activiti.engine.repository.Model;
24 20 import org.activiti.engine.repository.ModelQuery;
25   -import org.activiti.engine.repository.ProcessDefinition;
26 21 import org.apache.commons.lang3.exception.ExceptionUtils;
27 22 import org.springframework.stereotype.Service;
28 23 import org.springframework.util.ObjectUtils;
29 24  
30   -import javax.servlet.http.HttpServletResponse;
31 25 import javax.xml.stream.XMLInputFactory;
32 26 import javax.xml.stream.XMLStreamReader;
33 27 import java.io.ByteArrayInputStream;
34   -import java.io.IOException;
35   -import java.io.InputStream;
36 28 import java.io.InputStreamReader;
37   -import java.net.URLEncoder;
38 29 import java.nio.charset.StandardCharsets;
39 30 import java.util.List;
40 31 import java.util.Optional;
... ... @@ -64,64 +55,67 @@ public class BpmModelServiceImpl implements BpmModelService {
64 55 }
65 56  
66 57 @Override
67   - public CommonResult<String> newModel(ModelCreateVO modelCreateVO) {
  58 + public CommonResult<String> newModel(ModelVO modelVO) {
68 59 try {
69 60 //初始化一个空模型
70 61 Model model = repositoryService.newModel();
71   - String name = Optional.ofNullable(modelCreateVO.getName()).orElse("new-process");
  62 + String name = Optional.ofNullable(modelVO.getName()).orElse("new-process");
72 63 //设置一些默认信息
73 64 model.setName(name);
74   - model.setKey(Optional.ofNullable(modelCreateVO.getKey()).orElse("processKey"));
75   - model.setMetaInfo(JsonUtils.toJsonString(modelCreateVO));
  65 + model.setKey(Optional.ofNullable(modelVO.getKey()).orElse("processKey"));
  66 + model.setMetaInfo(JsonUtils.toJsonString(modelVO));
76 67 repositoryService.saveModel(model);
77   - return CommonResult.success("保存成功");
  68 + if (!ObjectUtils.isEmpty(modelVO.getBpmnXml())) {
  69 + repositoryService.addModelEditorSource(model.getId(), modelVO.getBpmnXml().getBytes(StandardCharsets.UTF_8));
  70 + }
  71 + return CommonResult.success(model.getId());
78 72 }catch (Exception e){
79   - log.info("模型创建失败!modelCreateVO = {} e = {} ", modelCreateVO, ExceptionUtils.getStackTrace(e));
  73 + log.info("模型创建失败!modelVO = {} e = {} ", modelVO, ExceptionUtils.getStackTrace(e));
80 74 throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
81 75 }
82 76  
83 77 }
84 78  
85 79 @Override
86   - public CommonResult<String> updateModel(ModelUpdateVO modelUpdateVO) {
  80 + public CommonResult<String> updateModel(ModelVO modelVO) {
87 81 try {
88   - Model model = repositoryService.getModel(modelUpdateVO.getId());
  82 + Model model = repositoryService.getModel(modelVO.getId());
89 83 if (ObjectUtils.isEmpty(model)) {
90 84 throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
91 85 }
92 86 // 只能修改名字跟描述
93   - ModelCreateVO modelCreateVO = JsonUtils.parseObject(model.getMetaInfo(), ModelCreateVO.class);
  87 + ModelVO modelCreateVO = JsonUtils.parseObject(model.getMetaInfo(), ModelVO.class);
94 88 if (ObjectUtils.isEmpty(modelCreateVO)) {
95   - modelCreateVO = new ModelCreateVO();
  89 + modelCreateVO = new ModelVO();
96 90 }
97   - modelCreateVO.setName(modelUpdateVO.getName());
98   - modelCreateVO.setDescription(modelUpdateVO.getDescription());
  91 + modelCreateVO.setName(modelVO.getName());
  92 + modelCreateVO.setDescription(modelVO.getDescription());
99 93 model.setMetaInfo(JsonUtils.toJsonString(modelCreateVO));
100   - model.setName(modelUpdateVO.getName());
  94 + model.setName(modelVO.getName());
  95 + model.setKey(modelVO.getKey());
101 96 // 更新模型
102 97 repositoryService.saveModel(model);
103 98  
104   - repositoryService.addModelEditorSource(model.getId(), modelUpdateVO.getBpmnXml().getBytes(StandardCharsets.UTF_8));
  99 + repositoryService.addModelEditorSource(model.getId(), modelVO.getBpmnXml().getBytes(StandardCharsets.UTF_8));
105 100  
106 101 return CommonResult.success("保存成功");
107 102 }catch (Exception e){
108   - log.info("模型更新失败!modelUpdateVO = {} e = {} ", modelUpdateVO, ExceptionUtils.getStackTrace(e));
  103 + log.info("模型更新失败!modelVO = {}", modelVO, e);
109 104 throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
110 105 }
111 106 }
112 107  
113 108 @Override
114 109 public CommonResult<String> deploy(String modelId) {
115   - // 获取模型
116   - Model modelData = repositoryService.getModel(modelId);
117   - if (ObjectUtils.isEmpty(modelData)) {
118   - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
119   - }
120   - byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
121   - if (bytes == null) {
122   - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
123   - }
124 110 try {
  111 + Model modelData = repositoryService.getModel(modelId);
  112 + if (ObjectUtils.isEmpty(modelData)) {
  113 + throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
  114 + }
  115 + byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
  116 + if (bytes == null) {
  117 + throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
  118 + }
125 119 // 将xml转换为流
126 120 ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
127 121 XMLInputFactory xif = XMLInputFactory.newInstance();
... ... @@ -148,21 +142,21 @@ public class BpmModelServiceImpl implements BpmModelService {
148 142 }
149 143  
150 144 @Override
151   - public FileResp exportBpmnXml(String deploymentId) {
152   -
153   - // 查询流程定义
154   - ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
155   - if (ObjectUtils.isEmpty(pd)) {
156   - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_PROCESS_DEFINITION_NOT_EXISTS);
  145 + public FileResp exportBpmnXml(String modelId) {
  146 + try {
  147 + Model modelData = repositoryService.getModel(modelId);
  148 + if (ObjectUtils.isEmpty(modelData)) {
  149 + throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
  150 + }
  151 + byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
  152 + FileResp fileResp = new FileResp();
  153 + fileResp.setFileName(String.format("%s.bpmn", Optional.ofNullable(modelData.getName()).orElse("流程图")));
  154 + fileResp.setFileByte(bytes);
  155 + return fileResp;
  156 + } catch (Exception e) {
  157 + log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e));
  158 + throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
157 159 }
158   - String resourceName = Optional.ofNullable(pd.getDiagramResourceName()).orElse(pd.getResourceName());
159   - InputStream inputStream = repositoryService.getResourceAsStream(deploymentId,
160   - resourceName);
161   - FileResp fileResp = new FileResp();
162   -
163   - fileResp.setFileName(String.format("%s.bpmn", Optional.ofNullable(pd.getName()).orElse("流程图")));
164   - fileResp.setFileByte(IoUtil.readBytes(inputStream));
165   - return fileResp;
166 160 }
167 161  
168 162 @Override
... ...
yudao-admin-ui/src/api/bpm/model.js
... ... @@ -8,3 +8,41 @@ export function page(query) {
8 8 params: query
9 9 })
10 10 }
  11 +export function exportBpmnXml(query) {
  12 + return request({
  13 + url: '/workflow/models/exportBpmnXml',
  14 + method: 'get',
  15 + params: query
  16 + })
  17 +}
  18 +
  19 +export function modelUpdate(data) {
  20 + return request({
  21 + url: '/workflow/models/update',
  22 + method: 'POST',
  23 + data: data
  24 + })
  25 +}
  26 +
  27 +export function modelSave(data) {
  28 + return request({
  29 + url: '/workflow/models/create',
  30 + method: 'POST',
  31 + data: data
  32 + })
  33 +}
  34 +
  35 +export function modelDelete(data) {
  36 + return request({
  37 + url: '/workflow/models/delete?modelId='+ data.modelId,
  38 + method: 'POST',
  39 + data: data
  40 + })
  41 +}
  42 +export function modelDeploy(data) {
  43 + return request({
  44 + url: '/workflow/models/deploy?modelId='+ data.modelId,
  45 + method: 'POST',
  46 + data: data
  47 + })
  48 +}
... ...
yudao-admin-ui/src/components/bpmn/Header.vue
... ... @@ -2,10 +2,7 @@
2 2 <div>
3 3 <el-button-group>
4 4 <el-tooltip class="item" effect="dark" content="保存并发布" placement="bottom">
5   - <el-button type="primary" size="small" @click="deploy"><i class="fa fa-save"> 保存并发布</i></el-button>
6   - </el-tooltip>
7   - <el-tooltip class="item" effect="dark" content="保存草稿" placement="bottom">
8   - <el-button type="primary" size="small" @click="save"><i class="fa fa-save"> 保存草稿</i></el-button>
  5 + <el-button type="primary" size="small" @click="save"><i class="fa fa-save"> 保存</i></el-button>
9 6 </el-tooltip>
10 7 <el-tooltip class="item" effect="dark" content="打开流程文件" placement="bottom">
11 8 <el-button type="primary" size="small" @click="importXml"><i class="fa fa-folder-open"></i></el-button>
... ... @@ -32,10 +29,13 @@
32 29 <el-tooltip class="item" effect="dark" content="缩小" placement="bottom">
33 30 <el-button size="small" @click="zoom(-0.05)"><i class="fa fa-search-minus"></i></el-button>
34 31 </el-tooltip>
35   - <el-tooltip class="item" effect="dark" content="重置" placement="bottom">
  32 + <el-tooltip class="item" effect="dark" content="重置大小" placement="bottom">
36 33 <el-button size="small" @click="zoom(0)"><i class="fa fa-arrows"></i></el-button>
37 34 </el-tooltip>
38 35 </el-button-group>
  36 +
  37 + <div class="closeClass" @click="beforeClose()"><i class="el-icon-close"></i></div>
  38 +
39 39 </div>
40 40 </template>
41 41  
... ... @@ -74,15 +74,15 @@
74 74 }
75 75 _svg = svg;
76 76 })
77   - that.post(this.Apis.deployProcess, {
78   - processKey: "s1111",
79   - processName: "阿达达",
80   - resourceName: "test01",
81   - xml: _xml,
82   - svg: _svg
83   - }, function (data) {
84   - console.log(data)
85   - });
  77 + // that.post(this.Apis.deployProcess, {
  78 + // processKey: "s1111",
  79 + // processName: "阿达达",
  80 + // resourceName: "test01",
  81 + // xml: _xml,
  82 + // svg: _svg
  83 + // }, function (data) {
  84 + // console.log(data)
  85 + // });
86 86 },
87 87 save(){
88 88 let that = this;
... ... @@ -129,11 +129,24 @@
129 129 let newScale = !val ? 1.0 : ((this.scale + val) <= 0.2) ? 0.2 : (this.scale + val);
130 130 this.modeler.get('canvas').zoom(newScale);
131 131 this.scale = newScale;
  132 + },
  133 + beforeClose(val) {
  134 + this.$emit("beforeClose");
132 135 }
133 136 }
134 137 }
135 138 </script>
136 139  
137 140 <style scoped>
  141 +.closeClass{
  142 +
  143 + float: right;
  144 + width: 50px;
  145 + height: 50px;
  146 + font-size: 20px;
  147 +}
138 148  
  149 +.closeClass:hover{
  150 + cursor:pointer;
  151 +}
139 152 </style>
... ...
yudao-admin-ui/src/components/bpmn/VueBpmn.vue
... ... @@ -4,7 +4,7 @@
4 4 <el-row>
5 5 <el-col :span="24">
6 6 <vue-header class="bpmn-viewer-header" :processData="initData" :modeler="bpmnModeler" @restart="restart" @importXml="importXml"
7   - @handleExportSvg="handleExportSvg" @handleExportBpmn="handleExportBpmn" @processSave="processSave"></vue-header>
  7 + @handleExportSvg="handleExportSvg" @handleExportBpmn="handleExportBpmn" @processSave="processSave" @beforeClose="beforeClose"></vue-header>
8 8 </el-col>
9 9 </el-row>
10 10 <el-row style="margin-left: 1%">
... ... @@ -61,6 +61,7 @@
61 61 },
62 62 props: {
63 63 product: String,
  64 + bpmnData: Object,
64 65 bpmnXml: {
65 66 type: String,
66 67 required: false
... ... @@ -80,8 +81,13 @@
80 81 mounted() {
81 82 let processId = new Date().getTime();
82 83 this.initTemplate = templateXml.initTemplate(processId)
83   - this.initData = {key: "process" + processId, name: "流程" + processId, xml: this.initTemplate}
84   - if (this.bpmnXml != null) {
  84 +
  85 + this.initData = {
  86 + key: this.bpmnData.key ? this.bpmnData.key : "process" + processId,
  87 + name: this.bpmnData.name ? this.bpmnData.name : "流程" + processId,
  88 + description: this.bpmnData.metaInfo ? JSON.parse(this.bpmnData.metaInfo).description : "" ,
  89 + xml: this.initTemplate}
  90 + if (this.bpmnXml != null && this.bpmnXml !== "") {
85 91 this.initTemplate = this.bpmnXml
86 92 }
87 93 this.init();
... ... @@ -205,14 +211,21 @@
205 211 },
206 212 processSave(data){
207 213 let initData = this.initData;
208   - data.procId = initData.key;
209   - data.name = initData.name;
210   - this.$emit("processSave",data);
  214 + const dataXml = this.bpmnData
  215 + dataXml.bpmnXml = this.xmlShow;
  216 + dataXml.name = initData.name;
  217 + dataXml.key = initData.key;
  218 + dataXml.description = initData.description;
  219 + this.$emit("processSave",dataXml);
211 220 },
212 221 restart() {
213 222 let processId = new Date().getTime();
214 223 this.initTemplate = templateXml.initTemplate(processId)
215   - this.initData = {key: "process" + processId, name: "流程" + processId, xml: this.initTemplate}
  224 + this.initData = {
  225 + key: this.bpmnData.key ? this.bpmnData.key : "process" + processId,
  226 + name: this.bpmnData.name ? this.bpmnData.name : "流程" + processId,
  227 + description: this.bpmnData.metaInfo ? JSON.parse(this.bpmnData.metaInfo).description : "" ,
  228 + xml: this.initTemplate}
216 229 this.initDiagram(this.initTemplate)
217 230 },
218 231 importXml() {
... ... @@ -244,6 +257,9 @@
244 257 }
245 258 }
246 259 return moddleExtensions;
  260 + },
  261 + beforeClose() {
  262 + this.$emit("beforeClose");
247 263 }
248 264 }
249 265 }
... ...
yudao-admin-ui/src/views/bpm/model/index.vue
... ... @@ -10,17 +10,18 @@
10 10 <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
11 11 </el-form-item>
12 12 </el-form>
13   -
14 13 <el-row :gutter="10" class="mb8">
15 14 <el-col :span="1.5">
16   - <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
17   - v-hasPermi="['system:login-log:export']">导出</el-button>
18   - <el-button type="warning" icon="el-icon-download" size="mini" @click="openBpmn"
19   - v-hasPermi="['system:login-log:export']">新建</el-button>
  15 + <el-button
  16 + type="primary"
  17 + icon="el-icon-plus"
  18 + size="mini"
  19 + @click="openBpmn"
  20 + v-hasPermi="['infra:config:create']"
  21 + >新建流程</el-button>
20 22 </el-col>
21 23 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
22 24 </el-row>
23   -
24 25 <el-table v-loading="loading" :data="list">
25 26 <el-table-column label="ID" align="center" prop="id" />
26 27 <el-table-column label="name" align="center" prop="metaInfo" >
... ... @@ -33,18 +34,30 @@
33 34 <span>{{ JSON.parse(scope.row.metaInfo).description }}</span>
34 35 </template>
35 36 </el-table-column>
  37 + <el-table-column label="创建时间" align="center" prop="createTime" >
  38 + <template slot-scope="scope">
  39 + <span>{{ parseTime(scope.row.createTime) }}</span>
  40 + </template>
  41 + </el-table-column>
  42 + <el-table-column label="操作" align="center" >
  43 + <template slot-scope="scope">
  44 + <el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button>
  45 + <el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button>
  46 + <el-button size="mini" type="text" icon="el-icon-thumb" @click="modelDeploy(scope.row)">发布</el-button>
  47 + </template>
  48 + </el-table-column>
36 49 </el-table>
37 50  
38 51 <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
39 52 @pagination="getList"/>
40   - <el-dialog title="新建流程" :visible.sync="showBpmnBool" :before-close="close" :fullscreen="true">
41   - <vue-bpmn product="activiti" @processSave="processSave"></vue-bpmn>
  53 + <el-dialog :visible.sync="showBpmnBool" :before-close="close" :fullscreen="true">
  54 + <vue-bpmn v-if="showBpmnBool" product="activiti" @processSave="processSave" :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="close"></vue-bpmn>
42 55 </el-dialog>
43 56 </div>
44 57 </template>
45 58  
46 59 <script>
47   -import { page } from "@/api/bpm/model";
  60 +import { page, exportBpmnXml, modelUpdate, modelSave, modelDelete, modelDeploy } from "@/api/bpm/model";
48 61 import VueBpmn from "@/components/bpmn/VueBpmn";
49 62  
50 63 export default {
... ... @@ -61,6 +74,7 @@ export default {
61 74 // 表格数据
62 75 list: [],
63 76 bpmnXML: null,
  77 + bpmnData: {},
64 78 // 查询参数
65 79 queryParams: {
66 80 pageNo: 1,
... ... @@ -98,27 +112,81 @@ export default {
98 112 this.resetForm("queryForm");
99 113 this.handleQuery();
100 114 },
101   - /** 导出按钮操作 */
102   - handleExport() {
103   - const queryParams = this.queryParams;
104   - this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
105   - confirmButtonText: "确定",
106   - cancelButtonText: "取消",
107   - type: "warning"
108   - }).then(function() {
109   - return exportLoginLog(queryParams);
110   - }).then(response => {
111   - this.downloadExcel(response, '登录日志.xls');
  115 + processSave(data) {
  116 + const that = this;
  117 + // 如果存在id 说明是修改
  118 + if (data.id) {
  119 + let postData = JSON.parse(data.metaInfo)
  120 + postData.bpmnXml = data.bpmnXml
  121 + postData.id = data.id
  122 + postData.name = data.name
  123 + postData.key = data.key
  124 + postData.description = data.description
  125 + modelUpdate(postData).then(response => {
  126 + this.msgSuccess("保存成功");
112 127 })
113   - },
114   - processSave() {
115   - console.log("processSave")
  128 + this.showBpmnBool = false
  129 + this.getList();
  130 + return
  131 + }
  132 + modelSave(data).then(response => {
  133 + that.bpmnData.id = response.data
  134 + this.msgSuccess("保存成功");
  135 + })
  136 +
  137 + this.showBpmnBool = false
  138 + this.getList();
116 139 },
117 140 openBpmn() {
  141 + this.bpmnData = {}
  142 + this.bpmnXML = ""
118 143 this.showBpmnBool = true
119 144 },
120 145 close() {
121 146 this.showBpmnBool = false
  147 + this.getList();
  148 + },
  149 + change(row) {
  150 + const that = this;
  151 + this.bpmnXML = ""
  152 + this.bpmnData = {}
  153 + exportBpmnXml({
  154 + modelId: row.id
  155 + }).then(response => {
  156 + that.bpmnXML = response
  157 + that.bpmnData = row
  158 + that.showBpmnBool = true
  159 + })
  160 + },
  161 + modelDelete(row) {
  162 + const that = this;
  163 + this.$confirm('是否删除该流程!!', "警告", {
  164 + confirmButtonText: "确定",
  165 + cancelButtonText: "取消",
  166 + type: "warning"
  167 + }).then(function() {
  168 + modelDelete({
  169 + modelId: row.id
  170 + }).then(response => {
  171 + that.getList();
  172 + that.msgSuccess("删除成功");
  173 + })
  174 + })
  175 + },
  176 + modelDeploy(row) {
  177 + const that = this;
  178 + this.$confirm('是否部署该流程!!', "提示", {
  179 + confirmButtonText: "确定",
  180 + cancelButtonText: "取消",
  181 + type: "success"
  182 + }).then(function() {
  183 + modelDeploy({
  184 + modelId: row.id
  185 + }).then(response => {
  186 + that.getList();
  187 + that.msgSuccess("部署成功");
  188 + })
  189 + })
122 190 }
123 191 }
124 192 };
... ...