mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
初步完善模型发布流程
This commit is contained in:
parent
3f90e79d8a
commit
a829e8d083
@ -1,32 +1,21 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.TodoTaskRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelCreateVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelPageReqVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelRespVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelUpdateVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService;
|
||||
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 com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.*;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* 工作流模型
|
||||
@ -49,14 +38,14 @@ public class ModelController {
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation(value = "新建模型")
|
||||
public CommonResult<String> newModel(@RequestBody ModelCreateVO modelCreateVO) {
|
||||
return bpmModelService.newModel(modelCreateVO);
|
||||
public CommonResult<String> newModel(@RequestBody ModelVO modelVO) {
|
||||
return bpmModelService.newModel(modelVO);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改模型属性")
|
||||
public CommonResult<String> updateModel(@RequestBody ModelUpdateVO modelUpdateVO) {
|
||||
return bpmModelService.updateModel(modelUpdateVO);
|
||||
public CommonResult<String> updateModel(@RequestBody ModelVO modelVO) {
|
||||
return bpmModelService.updateModel(modelVO);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ -72,9 +61,9 @@ public class ModelController {
|
||||
}
|
||||
|
||||
@GetMapping("/exportBpmnXml")
|
||||
@ApiOperation(value = "导出模型")
|
||||
public void export(@RequestParam String deploymentId, HttpServletResponse response) throws IOException {
|
||||
FileResp fileResp = bpmModelService.exportBpmnXml(deploymentId);
|
||||
@ApiOperation(value = "导出模型Xml")
|
||||
public void export(@RequestParam String modelId, HttpServletResponse response) throws IOException {
|
||||
FileResp fileResp = bpmModelService.exportBpmnXml(modelId);
|
||||
ServletUtils.writeAttachment(response, fileResp.getFileName(), fileResp.getFileByte());
|
||||
}
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 新增模型 VO
|
||||
* @author yunlongn
|
||||
*/
|
||||
@Data
|
||||
public class ModelCreateVO {
|
||||
|
||||
@ApiModelProperty(value = "模型名字", required = true)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "模型描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "版本号")
|
||||
private Integer revision;
|
||||
|
||||
@ApiModelProperty(value = "key值")
|
||||
private String key;
|
||||
}
|
@ -8,9 +8,9 @@ import lombok.Data;
|
||||
* @author yunlongn
|
||||
*/
|
||||
@Data
|
||||
public class ModelUpdateVO {
|
||||
public class ModelVO {
|
||||
|
||||
@ApiModelProperty(value = "模型Id", required = true)
|
||||
@ApiModelProperty(value = "模型Id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "模型名字", required = true)
|
||||
@ -27,6 +27,4 @@ public class ModelUpdateVO {
|
||||
|
||||
@ApiModelProperty(value = "bpmnXml")
|
||||
private String bpmnXml;
|
||||
|
||||
|
||||
}
|
@ -1,16 +1,12 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelCreateVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelPageReqVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelRespVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelUpdateVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelVO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.activiti.engine.repository.Model;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 工作流模型接口
|
||||
* @author yunlongn
|
||||
@ -27,16 +23,16 @@ public interface BpmModelService {
|
||||
|
||||
/**
|
||||
* 新增一个模型
|
||||
* @param modelCreateVO 模型对象
|
||||
* @param modelVO 模型对象
|
||||
* @return 返回成功
|
||||
*/
|
||||
CommonResult<String> newModel(ModelCreateVO modelCreateVO);
|
||||
CommonResult<String> newModel(ModelVO modelVO);
|
||||
/**
|
||||
* 修改模型属性,填充bpmn数据
|
||||
* @param modelUpdateVO 模型对象
|
||||
* @param modelVO 模型对象
|
||||
* @return 返回成功
|
||||
*/
|
||||
CommonResult<String> updateModel(ModelUpdateVO modelUpdateVO);
|
||||
CommonResult<String> updateModel(ModelVO modelVO);
|
||||
|
||||
/**
|
||||
* 部署模型 使模型成为一个 process
|
||||
|
@ -1,12 +1,9 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelCreateVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelPageReqVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelRespVo;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelUpdateVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.model.ModelVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService;
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
@ -15,26 +12,20 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.api.runtime.shared.query.Pageable;
|
||||
import org.activiti.bpmn.converter.BpmnXMLConverter;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.activiti.engine.repository.ModelQuery;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -64,55 +55,59 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> newModel(ModelCreateVO modelCreateVO) {
|
||||
public CommonResult<String> newModel(ModelVO modelVO) {
|
||||
try {
|
||||
//初始化一个空模型
|
||||
Model model = repositoryService.newModel();
|
||||
String name = Optional.ofNullable(modelCreateVO.getName()).orElse("new-process");
|
||||
String name = Optional.ofNullable(modelVO.getName()).orElse("new-process");
|
||||
//设置一些默认信息
|
||||
model.setName(name);
|
||||
model.setKey(Optional.ofNullable(modelCreateVO.getKey()).orElse("processKey"));
|
||||
model.setMetaInfo(JsonUtils.toJsonString(modelCreateVO));
|
||||
model.setKey(Optional.ofNullable(modelVO.getKey()).orElse("processKey"));
|
||||
model.setMetaInfo(JsonUtils.toJsonString(modelVO));
|
||||
repositoryService.saveModel(model);
|
||||
return CommonResult.success("保存成功");
|
||||
if (!ObjectUtils.isEmpty(modelVO.getBpmnXml())) {
|
||||
repositoryService.addModelEditorSource(model.getId(), modelVO.getBpmnXml().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return CommonResult.success(model.getId());
|
||||
}catch (Exception e){
|
||||
log.info("模型创建失败!modelCreateVO = {} e = {} ", modelCreateVO, ExceptionUtils.getStackTrace(e));
|
||||
log.info("模型创建失败!modelVO = {} e = {} ", modelVO, ExceptionUtils.getStackTrace(e));
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> updateModel(ModelUpdateVO modelUpdateVO) {
|
||||
public CommonResult<String> updateModel(ModelVO modelVO) {
|
||||
try {
|
||||
Model model = repositoryService.getModel(modelUpdateVO.getId());
|
||||
Model model = repositoryService.getModel(modelVO.getId());
|
||||
if (ObjectUtils.isEmpty(model)) {
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
||||
}
|
||||
// 只能修改名字跟描述
|
||||
ModelCreateVO modelCreateVO = JsonUtils.parseObject(model.getMetaInfo(), ModelCreateVO.class);
|
||||
ModelVO modelCreateVO = JsonUtils.parseObject(model.getMetaInfo(), ModelVO.class);
|
||||
if (ObjectUtils.isEmpty(modelCreateVO)) {
|
||||
modelCreateVO = new ModelCreateVO();
|
||||
modelCreateVO = new ModelVO();
|
||||
}
|
||||
modelCreateVO.setName(modelUpdateVO.getName());
|
||||
modelCreateVO.setDescription(modelUpdateVO.getDescription());
|
||||
modelCreateVO.setName(modelVO.getName());
|
||||
modelCreateVO.setDescription(modelVO.getDescription());
|
||||
model.setMetaInfo(JsonUtils.toJsonString(modelCreateVO));
|
||||
model.setName(modelUpdateVO.getName());
|
||||
model.setName(modelVO.getName());
|
||||
model.setKey(modelVO.getKey());
|
||||
// 更新模型
|
||||
repositoryService.saveModel(model);
|
||||
|
||||
repositoryService.addModelEditorSource(model.getId(), modelUpdateVO.getBpmnXml().getBytes(StandardCharsets.UTF_8));
|
||||
repositoryService.addModelEditorSource(model.getId(), modelVO.getBpmnXml().getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
return CommonResult.success("保存成功");
|
||||
}catch (Exception e){
|
||||
log.info("模型更新失败!modelUpdateVO = {} e = {} ", modelUpdateVO, ExceptionUtils.getStackTrace(e));
|
||||
log.info("模型更新失败!modelVO = {}", modelVO, e);
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> deploy(String modelId) {
|
||||
// 获取模型
|
||||
try {
|
||||
Model modelData = repositoryService.getModel(modelId);
|
||||
if (ObjectUtils.isEmpty(modelData)) {
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
||||
@ -121,7 +116,6 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
if (bytes == null) {
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
||||
}
|
||||
try {
|
||||
// 将xml转换为流
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
|
||||
XMLInputFactory xif = XMLInputFactory.newInstance();
|
||||
@ -148,21 +142,21 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileResp exportBpmnXml(String deploymentId) {
|
||||
|
||||
// 查询流程定义
|
||||
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
|
||||
if (ObjectUtils.isEmpty(pd)) {
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_PROCESS_DEFINITION_NOT_EXISTS);
|
||||
public FileResp exportBpmnXml(String modelId) {
|
||||
try {
|
||||
Model modelData = repositoryService.getModel(modelId);
|
||||
if (ObjectUtils.isEmpty(modelData)) {
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
||||
}
|
||||
String resourceName = Optional.ofNullable(pd.getDiagramResourceName()).orElse(pd.getResourceName());
|
||||
InputStream inputStream = repositoryService.getResourceAsStream(deploymentId,
|
||||
resourceName);
|
||||
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
|
||||
FileResp fileResp = new FileResp();
|
||||
|
||||
fileResp.setFileName(String.format("%s.bpmn", Optional.ofNullable(pd.getName()).orElse("流程图")));
|
||||
fileResp.setFileByte(IoUtil.readBytes(inputStream));
|
||||
fileResp.setFileName(String.format("%s.bpmn", Optional.ofNullable(modelData.getName()).orElse("流程图")));
|
||||
fileResp.setFileByte(bytes);
|
||||
return fileResp;
|
||||
} catch (Exception e) {
|
||||
log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e));
|
||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,3 +8,41 @@ export function page(query) {
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function exportBpmnXml(query) {
|
||||
return request({
|
||||
url: '/workflow/models/exportBpmnXml',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function modelUpdate(data) {
|
||||
return request({
|
||||
url: '/workflow/models/update',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function modelSave(data) {
|
||||
return request({
|
||||
url: '/workflow/models/create',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function modelDelete(data) {
|
||||
return request({
|
||||
url: '/workflow/models/delete?modelId='+ data.modelId,
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
export function modelDeploy(data) {
|
||||
return request({
|
||||
url: '/workflow/models/deploy?modelId='+ data.modelId,
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
@ -2,10 +2,7 @@
|
||||
<div>
|
||||
<el-button-group>
|
||||
<el-tooltip class="item" effect="dark" content="保存并发布" placement="bottom">
|
||||
<el-button type="primary" size="small" @click="deploy"><i class="fa fa-save"> 保存并发布</i></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="保存草稿" placement="bottom">
|
||||
<el-button type="primary" size="small" @click="save"><i class="fa fa-save"> 保存草稿</i></el-button>
|
||||
<el-button type="primary" size="small" @click="save"><i class="fa fa-save"> 保存</i></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="打开流程文件" placement="bottom">
|
||||
<el-button type="primary" size="small" @click="importXml"><i class="fa fa-folder-open"></i></el-button>
|
||||
@ -32,10 +29,13 @@
|
||||
<el-tooltip class="item" effect="dark" content="缩小" placement="bottom">
|
||||
<el-button size="small" @click="zoom(-0.05)"><i class="fa fa-search-minus"></i></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="重置" placement="bottom">
|
||||
<el-tooltip class="item" effect="dark" content="重置大小" placement="bottom">
|
||||
<el-button size="small" @click="zoom(0)"><i class="fa fa-arrows"></i></el-button>
|
||||
</el-tooltip>
|
||||
</el-button-group>
|
||||
|
||||
<div class="closeClass" @click="beforeClose()"><i class="el-icon-close"></i></div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -74,15 +74,15 @@
|
||||
}
|
||||
_svg = svg;
|
||||
})
|
||||
that.post(this.Apis.deployProcess, {
|
||||
processKey: "s1111",
|
||||
processName: "阿达达",
|
||||
resourceName: "test01",
|
||||
xml: _xml,
|
||||
svg: _svg
|
||||
}, function (data) {
|
||||
console.log(data)
|
||||
});
|
||||
// that.post(this.Apis.deployProcess, {
|
||||
// processKey: "s1111",
|
||||
// processName: "阿达达",
|
||||
// resourceName: "test01",
|
||||
// xml: _xml,
|
||||
// svg: _svg
|
||||
// }, function (data) {
|
||||
// console.log(data)
|
||||
// });
|
||||
},
|
||||
save(){
|
||||
let that = this;
|
||||
@ -129,11 +129,24 @@
|
||||
let newScale = !val ? 1.0 : ((this.scale + val) <= 0.2) ? 0.2 : (this.scale + val);
|
||||
this.modeler.get('canvas').zoom(newScale);
|
||||
this.scale = newScale;
|
||||
},
|
||||
beforeClose(val) {
|
||||
this.$emit("beforeClose");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.closeClass{
|
||||
|
||||
float: right;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.closeClass:hover{
|
||||
cursor:pointer;
|
||||
}
|
||||
</style>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<vue-header class="bpmn-viewer-header" :processData="initData" :modeler="bpmnModeler" @restart="restart" @importXml="importXml"
|
||||
@handleExportSvg="handleExportSvg" @handleExportBpmn="handleExportBpmn" @processSave="processSave"></vue-header>
|
||||
@handleExportSvg="handleExportSvg" @handleExportBpmn="handleExportBpmn" @processSave="processSave" @beforeClose="beforeClose"></vue-header>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-left: 1%">
|
||||
@ -61,6 +61,7 @@
|
||||
},
|
||||
props: {
|
||||
product: String,
|
||||
bpmnData: Object,
|
||||
bpmnXml: {
|
||||
type: String,
|
||||
required: false
|
||||
@ -80,8 +81,13 @@
|
||||
mounted() {
|
||||
let processId = new Date().getTime();
|
||||
this.initTemplate = templateXml.initTemplate(processId)
|
||||
this.initData = {key: "process" + processId, name: "流程" + processId, xml: this.initTemplate}
|
||||
if (this.bpmnXml != null) {
|
||||
|
||||
this.initData = {
|
||||
key: this.bpmnData.key ? this.bpmnData.key : "process" + processId,
|
||||
name: this.bpmnData.name ? this.bpmnData.name : "流程" + processId,
|
||||
description: this.bpmnData.metaInfo ? JSON.parse(this.bpmnData.metaInfo).description : "" ,
|
||||
xml: this.initTemplate}
|
||||
if (this.bpmnXml != null && this.bpmnXml !== "") {
|
||||
this.initTemplate = this.bpmnXml
|
||||
}
|
||||
this.init();
|
||||
@ -205,14 +211,21 @@
|
||||
},
|
||||
processSave(data){
|
||||
let initData = this.initData;
|
||||
data.procId = initData.key;
|
||||
data.name = initData.name;
|
||||
this.$emit("processSave",data);
|
||||
const dataXml = this.bpmnData
|
||||
dataXml.bpmnXml = this.xmlShow;
|
||||
dataXml.name = initData.name;
|
||||
dataXml.key = initData.key;
|
||||
dataXml.description = initData.description;
|
||||
this.$emit("processSave",dataXml);
|
||||
},
|
||||
restart() {
|
||||
let processId = new Date().getTime();
|
||||
this.initTemplate = templateXml.initTemplate(processId)
|
||||
this.initData = {key: "process" + processId, name: "流程" + processId, xml: this.initTemplate}
|
||||
this.initData = {
|
||||
key: this.bpmnData.key ? this.bpmnData.key : "process" + processId,
|
||||
name: this.bpmnData.name ? this.bpmnData.name : "流程" + processId,
|
||||
description: this.bpmnData.metaInfo ? JSON.parse(this.bpmnData.metaInfo).description : "" ,
|
||||
xml: this.initTemplate}
|
||||
this.initDiagram(this.initTemplate)
|
||||
},
|
||||
importXml() {
|
||||
@ -244,6 +257,9 @@
|
||||
}
|
||||
}
|
||||
return moddleExtensions;
|
||||
},
|
||||
beforeClose() {
|
||||
this.$emit("beforeClose");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,17 +10,18 @@
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||
v-hasPermi="['system:login-log:export']">导出</el-button>
|
||||
<el-button type="warning" icon="el-icon-download" size="mini" @click="openBpmn"
|
||||
v-hasPermi="['system:login-log:export']">新建</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="openBpmn"
|
||||
v-hasPermi="['infra:config:create']"
|
||||
>新建流程</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="ID" align="center" prop="id" />
|
||||
<el-table-column label="name" align="center" prop="metaInfo" >
|
||||
@ -33,18 +34,30 @@
|
||||
<span>{{ JSON.parse(scope.row.metaInfo).description }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" >
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" >
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-thumb" @click="modelDeploy(scope.row)">发布</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
<el-dialog title="新建流程" :visible.sync="showBpmnBool" :before-close="close" :fullscreen="true">
|
||||
<vue-bpmn product="activiti" @processSave="processSave"></vue-bpmn>
|
||||
<el-dialog :visible.sync="showBpmnBool" :before-close="close" :fullscreen="true">
|
||||
<vue-bpmn v-if="showBpmnBool" product="activiti" @processSave="processSave" :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="close"></vue-bpmn>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { page } from "@/api/bpm/model";
|
||||
import { page, exportBpmnXml, modelUpdate, modelSave, modelDelete, modelDeploy } from "@/api/bpm/model";
|
||||
import VueBpmn from "@/components/bpmn/VueBpmn";
|
||||
|
||||
export default {
|
||||
@ -61,6 +74,7 @@ export default {
|
||||
// 表格数据
|
||||
list: [],
|
||||
bpmnXML: null,
|
||||
bpmnData: {},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
@ -98,27 +112,81 @@ export default {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return exportLoginLog(queryParams);
|
||||
}).then(response => {
|
||||
this.downloadExcel(response, '登录日志.xls');
|
||||
processSave(data) {
|
||||
const that = this;
|
||||
// 如果存在id 说明是修改
|
||||
if (data.id) {
|
||||
let postData = JSON.parse(data.metaInfo)
|
||||
postData.bpmnXml = data.bpmnXml
|
||||
postData.id = data.id
|
||||
postData.name = data.name
|
||||
postData.key = data.key
|
||||
postData.description = data.description
|
||||
modelUpdate(postData).then(response => {
|
||||
this.msgSuccess("保存成功");
|
||||
})
|
||||
},
|
||||
processSave() {
|
||||
console.log("processSave")
|
||||
this.showBpmnBool = false
|
||||
this.getList();
|
||||
return
|
||||
}
|
||||
modelSave(data).then(response => {
|
||||
that.bpmnData.id = response.data
|
||||
this.msgSuccess("保存成功");
|
||||
})
|
||||
|
||||
this.showBpmnBool = false
|
||||
this.getList();
|
||||
},
|
||||
openBpmn() {
|
||||
this.bpmnData = {}
|
||||
this.bpmnXML = ""
|
||||
this.showBpmnBool = true
|
||||
},
|
||||
close() {
|
||||
this.showBpmnBool = false
|
||||
this.getList();
|
||||
},
|
||||
change(row) {
|
||||
const that = this;
|
||||
this.bpmnXML = ""
|
||||
this.bpmnData = {}
|
||||
exportBpmnXml({
|
||||
modelId: row.id
|
||||
}).then(response => {
|
||||
that.bpmnXML = response
|
||||
that.bpmnData = row
|
||||
that.showBpmnBool = true
|
||||
})
|
||||
},
|
||||
modelDelete(row) {
|
||||
const that = this;
|
||||
this.$confirm('是否删除该流程!!', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
modelDelete({
|
||||
modelId: row.id
|
||||
}).then(response => {
|
||||
that.getList();
|
||||
that.msgSuccess("删除成功");
|
||||
})
|
||||
})
|
||||
},
|
||||
modelDeploy(row) {
|
||||
const that = this;
|
||||
this.$confirm('是否部署该流程!!', "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "success"
|
||||
}).then(function() {
|
||||
modelDeploy({
|
||||
modelId: row.id
|
||||
}).then(response => {
|
||||
that.getList();
|
||||
that.msgSuccess("部署成功");
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user