refactor: 移除流程定义相关页面与接口

This commit is contained in:
konbai
2022-10-16 02:47:01 +08:00
parent 5eeac80ea8
commit b87b85c55e
8 changed files with 0 additions and 1404 deletions

View File

@@ -1,149 +0,0 @@
package com.ruoyi.web.controller.workflow;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.workflow.domain.bo.WfDesignerBo;
import com.ruoyi.workflow.domain.vo.WfDefinitionVo;
import com.ruoyi.workflow.service.IWfDefinitionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
/**
* 工作流程定义
*
* @author KonBAI
* @date 2022-01-17
*/
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/workflow/definition")
@Deprecated
public class WfDefinitionController extends BaseController {
private final IWfDefinitionService flowDefinitionService;
/**
* 流程定义列表
*
* @param pageQuery 分页参数
*/
@GetMapping(value = "/list")
@SaCheckPermission("workflow:definition:list")
public TableDataInfo<WfDefinitionVo> list(PageQuery pageQuery) {
return flowDefinitionService.list(pageQuery);
}
/**
* 列出指定流程的发布版本列表
*
* @param processKey 流程定义Key
* @return
*/
@GetMapping(value = "/publishList")
@SaCheckPermission("workflow:definition:list")
public TableDataInfo<WfDefinitionVo> publishList(@RequestParam String processKey, PageQuery pageQuery) {
return flowDefinitionService.publishList(processKey, pageQuery);
}
/**
* 导入流程文件
*/
@SaCheckPermission("workflow:definition:designer")
@PostMapping("/import")
public R<Void> importFile(@RequestParam(required = false) String name,
@RequestParam(required = false) String category,
MultipartFile file) {
try (InputStream in = file.getInputStream()) {
flowDefinitionService.importFile(name, category, in);
} catch (Exception e) {
log.error("导入失败:", e);
return R.fail(e.getMessage());
}
return R.ok("导入成功");
}
/**
* 读取xml文件
*/
@SaCheckLogin
@GetMapping("/readXml/{definitionId}")
public R<String> readXml(@PathVariable(value = "definitionId") String definitionId) {
try {
return R.ok(null, flowDefinitionService.readXml(definitionId));
} catch (Exception e) {
return R.fail("加载xml文件异常");
}
}
/**
* 读取图片文件
*/
@SaCheckPermission("workflow:definition:view")
@GetMapping("/readImage/{definitionId}")
public void readImage(@PathVariable(value = "definitionId") String definitionId,
HttpServletResponse response) {
try (OutputStream os = response.getOutputStream()) {
BufferedImage image = ImageIO.read(flowDefinitionService.readImage(definitionId));
response.setContentType("image/png");
if (image != null) {
ImageIO.write(image, "png", os);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 保存流程设计器内的xml文件
*/
@SaCheckPermission("workflow:definition:designer")
@PostMapping("/save")
public R<Void> save(@RequestBody WfDesignerBo bo) {
try (InputStream in = new ByteArrayInputStream(bo.getXml().getBytes(StandardCharsets.UTF_8))) {
flowDefinitionService.importFile(bo.getName(), bo.getCategory(), in);
} catch (Exception e) {
log.error("导入失败:", e);
return R.ok(e.getMessage());
}
return R.ok("导入成功");
}
/**
* 激活或挂起流程定义
*/
@SaCheckPermission("workflow:definition:update")
@PutMapping(value = "/updateState")
public R<Void> updateState(@RequestParam Boolean suspended, @RequestParam String definitionId) {
flowDefinitionService.updateState(suspended, definitionId);
return R.ok();
}
/**
* 删除流程
*/
@SaCheckPermission("workflow:definition:remove")
@DeleteMapping(value = "/delete")
public R<Void> delete(@RequestParam String deployId) {
flowDefinitionService.delete(deployId);
return R.ok();
}
}

View File

@@ -1,75 +0,0 @@
package com.ruoyi.workflow.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.workflow.domain.vo.WfDefinitionVo;
import java.io.IOException;
import java.io.InputStream;
/**
* @author KonBAI
* @createTime 2022/3/10 00:12
*/
@Deprecated
public interface IWfDefinitionService {
boolean exist(String processDefinitionKey);
/**
* 流程定义列表
*
* @param pageQuery 分页参数
* @return 流程定义分页列表数据
*/
TableDataInfo<WfDefinitionVo> list(PageQuery pageQuery);
/**
*
* @param processKey
* @return
*/
TableDataInfo<WfDefinitionVo> publishList(String processKey, PageQuery pageQuery);
/**
* 导入流程文件
*
* @param name
* @param category
* @param in
*/
void importFile(String name, String category, InputStream in);
/**
* 读取xml
* @param definitionId 流程定义ID
* @return
*/
String readXml(String definitionId) throws IOException;
/**
* 激活或挂起流程定义
*
* @param suspended 状态
* @param definitionId 流程定义ID
*/
void updateState(Boolean suspended, String definitionId);
/**
* 删除流程定义
*
* @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
*/
void delete(String deployId);
/**
* 读取图片文件
* @param definitionId 流程定义ID
* @return
*/
InputStream readImage(String definitionId);
}

View File

@@ -1,226 +0,0 @@
package com.ruoyi.workflow.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.flowable.factory.FlowServiceFactory;
import com.ruoyi.workflow.domain.vo.WfDefinitionVo;
import com.ruoyi.workflow.domain.vo.WfFormVo;
import com.ruoyi.workflow.service.IWfDefinitionService;
import com.ruoyi.workflow.service.IWfDeployFormService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.DeploymentBuilder;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.repository.ProcessDefinitionQuery;
import org.flowable.image.impl.DefaultProcessDiagramGenerator;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 流程定义
*
* @author KonBAI
* @date 2022-01-17
*/
@RequiredArgsConstructor
@Service
@Slf4j
public class WfDefinitionServiceImpl extends FlowServiceFactory implements IWfDefinitionService {
private final IWfDeployFormService deployFormService;
private static final String BPMN_FILE_SUFFIX = ".bpmn";
@Override
public boolean exist(String processDefinitionKey) {
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey(processDefinitionKey);
long count = processDefinitionQuery.count();
return count > 0;
}
/**
* 流程定义列表
*
* @param pageQuery 分页参数
* @return 流程定义分页列表数据
*/
@Override
public TableDataInfo<WfDefinitionVo> list(PageQuery pageQuery) {
Page<WfDefinitionVo> page = new Page<>();
// 流程定义列表数据查询
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
.latestVersion()
.orderByProcessDefinitionKey().asc();
long pageTotal = processDefinitionQuery.count();
if (pageTotal <= 0) {
return TableDataInfo.build();
}
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
List<ProcessDefinition> definitionList = processDefinitionQuery.listPage(offset, pageQuery.getPageSize());
List<WfDefinitionVo> definitionVoList = new ArrayList<>();
for (ProcessDefinition processDefinition : definitionList) {
String deploymentId = processDefinition.getDeploymentId();
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
WfDefinitionVo vo = new WfDefinitionVo();
vo.setDefinitionId(processDefinition.getId());
vo.setProcessKey(processDefinition.getKey());
vo.setProcessName(processDefinition.getName());
vo.setVersion(processDefinition.getVersion());
vo.setCategory(processDefinition.getCategory());
vo.setDeploymentId(processDefinition.getDeploymentId());
vo.setSuspended(processDefinition.isSuspended());
WfFormVo formVo = deployFormService.selectDeployFormByDeployId(deploymentId);
if (Objects.nonNull(formVo)) {
vo.setFormId(formVo.getFormId());
vo.setFormName(formVo.getFormName());
}
// 流程定义时间
vo.setCategory(deployment.getCategory());
vo.setDeploymentTime(deployment.getDeploymentTime());
definitionVoList.add(vo);
}
page.setRecords(definitionVoList);
page.setTotal(pageTotal);
return TableDataInfo.build(page);
}
@Override
public TableDataInfo<WfDefinitionVo> publishList(String processKey, PageQuery pageQuery) {
Page<WfDefinitionVo> page = new Page<>();
// 创建查询条件
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey(processKey)
.orderByProcessDefinitionVersion().asc();
long pageTotal = processDefinitionQuery.count();
if (pageTotal <= 0) {
return TableDataInfo.build();
}
// 根据查询条件,查询所有版本
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
List<ProcessDefinition> processDefinitionList = processDefinitionQuery
.listPage(offset, pageQuery.getPageSize());
List<WfDefinitionVo> definitionVoList = processDefinitionList.stream().map(item -> {
WfDefinitionVo vo = new WfDefinitionVo();
vo.setDefinitionId(item.getId());
vo.setProcessKey(item.getKey());
vo.setProcessName(item.getName());
vo.setVersion(item.getVersion());
vo.setCategory(item.getCategory());
vo.setDeploymentId(item.getDeploymentId());
vo.setSuspended(item.isSuspended());
// BeanUtil.copyProperties(item, vo);
return vo;
}).collect(Collectors.toList());
page.setRecords(definitionVoList);
page.setTotal(pageTotal);
return TableDataInfo.build(page);
}
/**
* 导入流程文件
*
* @param name
* @param category
* @param in
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void importFile(String name, String category, InputStream in) {
String processName = name + BPMN_FILE_SUFFIX;
// 创建流程部署
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment()
.name(processName)
.key(name)
.category(category)
.addInputStream(processName, in);
// 部署
deploymentBuilder.deploy();
}
/**
* 读取xml
*
* @param definitionId 流程定义ID
* @return
*/
@Override
public String readXml(String definitionId) throws IOException {
InputStream inputStream = repositoryService.getProcessModel(definitionId);
return IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
}
/**
* 读取xml
*
* @param definitionId 流程定义ID
* @return
*/
@Override
public InputStream readImage(String definitionId) {
//获得图片流
DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionId);
//输出为图片
return diagramGenerator.generateDiagram(
bpmnModel,
"png",
Collections.emptyList(),
Collections.emptyList(),
"宋体",
"宋体",
"宋体",
null,
1.0,
false);
}
/**
* 激活或挂起流程定义
*
* @param suspended 是否暂停状态
* @param definitionId 流程定义ID
*/
@Override
public void updateState(Boolean suspended, String definitionId) {
if (!suspended) {
// 激活
repositoryService.activateProcessDefinitionById(definitionId, true, null);
} else {
// 挂起
repositoryService.suspendProcessDefinitionById(definitionId, true, null);
}
}
/**
* 删除流程定义
*
* @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
*/
@Override
public void delete(String deployId) {
// true 允许级联删除 ,不设置会导致数据库外键关联异常
repositoryService.deleteDeployment(deployId, true);
}
}

View File

@@ -1,96 +0,0 @@
import request from '@/utils/request'
// 查询流程定义列表
export function listDefinition(query) {
return request({
url: '/workflow/definition/list',
method: 'get',
params: query
})
}
// 查询指定流程发布的版本列表
export function publishList(query) {
return request({
url: '/workflow/definition/publishList',
method: 'get',
params: query
})
}
// 部署流程实例
export function definitionStart(procDefId,data) {
return request({
url: '/workflow/definition/start/' + procDefId,
method: 'post',
data: data
})
}
// 获取流程变量
export function getProcessVariables(taskId) {
return request({
url: '/workflow/task/processVariables/' + taskId,
method: 'get'
})
}
// 激活/挂起流程
export function updateState(params) {
return request({
url: '/workflow/definition/updateState',
method: 'put',
params: params
})
}
// 读取xml文件
export function readXml(definitionId) {
return request({
url: '/workflow/definition/readXml/' + definitionId,
method: 'get'
})
}
// 读取image文件
export function readImage(deployId) {
return request({
url: '/workflow/definition/readImage/' + deployId,
method: 'get'
})
}
// 读取image文件
export function getFlowViewer(procInsId) {
return request({
url: '/workflow/task/flowViewer/' + procInsId,
method: 'get'
})
}
// 读取xml文件
export function saveXml(data) {
return request({
url: '/workflow/definition/save',
method: 'post',
data: data
})
}
// 删除流程定义
export function delDeployment(query) {
return request({
url: '/workflow/definition/delete/',
method: 'delete',
params: query
})
}
// 导出流程定义
export function exportDeployment(query) {
return request({
url: '/system/deployment/export',
method: 'get',
params: query
})
}

View File

@@ -74,19 +74,6 @@ export const constantRoutes = [
}
]
},
{
path: '/definition',
component: Layout,
hidden: true,
children: [
{
path: 'designer',
component: () => import('@/views/workflow/definition/designer'),
name: 'Designer',
meta: { title: '流程设计', icon: '' }
}
]
},
{
path: '/work',
component: Layout,

View File

@@ -1,192 +0,0 @@
<template>
<div class="workflow-designer">
<el-container>
<el-header height="70px">
<el-row type="flex" align="middle">
<el-col :span="3">
<div style="display:flex;justify-content:center;">
<el-button type="danger" @click="onClose()">关闭</el-button>
<el-button type="primary" @click="onPrevious()" :disabled="activeStep <= 0">上一步</el-button>
</div>
</el-col>
<el-col :offset="1" :span="16">
<el-steps :active="activeStep" finish-status="success" align-center>
<el-step title="基础设置"></el-step>
<el-step title="流程设计"></el-step>
<el-step title="完成"></el-step>
</el-steps>
</el-col>
<el-col :offset="1" :span="3">
<div style="display:flex;justify-content:center;">
<el-button type="primary" @click="onNext()" :disabled="activeStep >= 1">下一步</el-button>
<el-button type="success" @click="onSave()" :disabled="activeStep !== 1">保存</el-button>
</div>
</el-col>
</el-row>
</el-header>
<el-main>
<div v-if="activeStep === 0">
<div class="app-container">
<el-form size="small" label-width="80px">
<el-form-item label="流程标识">
<el-col :span="11">
<el-input v-model="designerForm.processKey" clearable disabled />
</el-col>
</el-form-item>
<el-form-item label="流程名称">
<el-col :span="11">
<el-input v-model="designerForm.processName" clearable />
</el-col>
</el-form-item>
<el-form-item label="流程分类">
<el-col :span="11">
<el-select v-model="designerForm.category" placeholder="请选择" clearable style="width:100%">
<el-option v-for="item in categoryOptions" :key="item.categoryId" :label="item.categoryName" :value="item.code" />
</el-select>
</el-col>
</el-form-item>
</el-form>
</div>
</div>
<div v-if="activeStep === 1">
<process-designer
ref="modelDesigner"
v-loading="loading"
:bpmnXml="bpmnXml"
:designerForm="designerForm"
/>
</div>
<div v-if="activeStep === 2">
<el-result :icon="result.icon" :title="result.title" :subTitle="result.describe">
<template slot="extra">
<el-button type="primary" size="medium" @click="onClose()">关闭</el-button>
</template>
</el-result>
</div>
</el-main>
<el-footer>
</el-footer>
</el-container>
</div>
</template>
<script>
import { readXml, saveXml } from "@/api/workflow/definition";
import ProcessDesigner from '@/components/ProcessDesigner';
import { listCategory } from '@/api/workflow/category';
export default {
name: 'Designer',
components: { ProcessDesigner },
props: {
designerForm: {
type: Object,
required: true
}
},
data () {
return {
activeStep: 0,
basicInfoForm: {},
categoryOptions: [],
loadIndex: 0,
loading: false,
bpmnXml: '',
result: {
icon: 'info',
title: null,
describe: null
}
};
},
created() {
this.getCategoryList();
if (this.designerForm.definitionId) {
this.getModelDetail(this.designerForm.definitionId)
}
},
methods: {
onClose () {
this.$emit('close');
},
onPrevious() {
this.activeStep--;
},
onNext() {
this.activeStep++;
},
onSave() {
let refProcessDesigner = this.$refs.modelDesigner.$refs.processDesigner;
refProcessDesigner.onSave().then(xml => {
this.bpmnXml = xml;
saveXml({
name: this.designerForm.processName,
category: this.designerForm.category,
xml: this.bpmnXml
}).then(res => {
this.result.icon = 'success';
this.result.title = '成功';
this.result.describe = res.msg;
}).catch(res => {
this.result.icon = 'error';
this.result.title = '失败';
this.result.describe = res.msg;
}).finally(() => {
this.onNext();
this.$emit('save');
})
})
},
/** 查询流程分类列表 */
getCategoryList() {
listCategory().then(response => this.categoryOptions = response.rows)
},
/** xml 文件 */
getModelDetail(definitionId) {
this.loading = true;
// 发送请求获取xml
readXml(definitionId).then(res => {
this.bpmnXml = res.data;
this.loadIndex = definitionId;
this.loading = false;
})
},
saveProcess(xml) {
this.bpmnXml = xml;
saveXml({
name: this.designerForm.processName,
category: this.designerForm.category,
xml: this.bpmnXml
}).then(res => {
this.$message(res.msg)
this.$emit('save');
})
}
}
}
</script>
<style scoped>
.workflow-designer {
position: fixed;
width: 100vw;
height: 100vh;
background: #ebeef5;
top: 0;
left: 0;
z-index: 1010;
padding: 10px;
}
.workflow-designer >>> .el-header {
padding: 10px;
background: #ffffff;
margin-bottom: 5px;
}
.workflow-designer >>> .el-main {
background: #ffffff;
padding: 0;
}
</style>

View File

@@ -1,646 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="开始时间" prop="deployTime">
<el-date-picker clearable size="small"
v-model="queryParams.deployTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择时间">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<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="primary"
plain
icon="el-icon-upload"
size="mini"
@click="handleImport"
v-hasPermi="['workflow:definition:designer']"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['workflow:definition:designer']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['workflow:definition:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['workflow:definition:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" fit :data="definitionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="流程标识" align="center" prop="processKey" :show-overflow-tooltip="true" />
<el-table-column label="流程名称" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-button type="text" @click="handleProcessView(scope.row)">
<span>{{ scope.row.processName }}</span>
</el-button>
</template>
</el-table-column>
<el-table-column label="流程分类" align="center" prop="categoryName" :formatter="categoryFormat" />
<el-table-column label="业务表单" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-button v-if="scope.row.formId" type="text" @click="handleForm(scope.row.formId)">
<span>{{ scope.row.formName }}</span>
</el-button>
<label v-else>暂无表单</label>
</template>
</el-table-column>
<el-table-column label="流程版本" align="center">
<template slot-scope="scope">
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-tag type="success" v-if="!scope.row.suspended">激活</el-tag>
<el-tag type="warning" v-if="scope.row.suspended">挂起</el-tag>
</template>
</el-table-column>
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
type="text"
size="mini"
icon="el-icon-edit"
@click="handleDesigner(scope.row)"
v-hasPermi="['workflow:definition:designer']"
>设计</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['workflow:definition:remove']"
>删除</el-button>
<el-dropdown>
<span class="el-dropdown-link">
<i class="el-icon-d-arrow-right el-icon--right"></i>更多
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
icon="el-icon-view"
@click.native="handleProcessView(scope.row)"
v-hasPermi="['workflow:definition:view']"
>流程图</el-dropdown-item>
<el-dropdown-item
icon="el-icon-connection"
v-if="scope.row.formId == null"
@click.native="handleAddForm(scope.row)"
>配置表单</el-dropdown-item>
<el-dropdown-item
icon="el-icon-price-tag"
@click.native="handlePublish(scope.row)"
v-hasPermi="['workflow:definition:list']"
>版本管理</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- bpmn20.xml导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body @close="cancel('uploadForm')">
<el-upload
ref="upload"
:limit="1"
accept=".xml"
:headers="upload.headers"
:action="upload.url + '?name=' + upload.name+'&category='+ upload.category"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<el-form ref="uploadForm" :model="upload" size="mini" :rules="rules" label-width="80px">
<el-form-item label="流程名称" prop="name">
<el-input v-model="upload.name" clearable/>
</el-form-item>
<el-form-item label="流程分类" prop="category">
<el-select v-model="upload.category" placeholder="请选择" clearable style="width:100%">
<el-option v-for="item in categoryOptions" :key="item.categoryId" :label="item.categoryName"
:value="item.code"/>
</el-select>
</el-form-item>
</el-form>
</div>
<div class="el-upload__tip" style="color:red" slot="tip">提示仅允许导入bpmn20.xml格式文件</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="cancel('uploadForm')"> </el-button>
</div>
</el-dialog>
<!-- 流程图 -->
<el-dialog :title="processView.title" :visible.sync="processView.open" width="70%" append-to-body>
<process-viewer :key="`designer-${processView.index}`" :xml="processView.xmlData" :style="{height: '400px'}" />
</el-dialog>
<!-- 版本管理 -->
<el-dialog title="版本管理" :visible.sync="publish.open" width="50%" append-to-body>
<el-table v-loading="publish.loading" :data="publish.dataList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="流程标识" align="center" prop="processKey" :show-overflow-tooltip="true" />
<el-table-column label="流程名称" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-button type="text" @click="handleProcessView(scope.row)">
<span>{{ scope.row.processName }}</span>
</el-button>
</template>
</el-table-column>
<el-table-column label="流程版本" align="center">
<template slot-scope="scope">
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-tag type="success" v-if="!scope.row.suspended">激活</el-tag>
<el-tag type="warning" v-if="scope.row.suspended">挂起</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
type="text"
size="mini"
icon="el-icon-video-pause"
v-if="!scope.row.suspended"
@click.native="handleUpdateSuspended(scope.row)"
v-hasPermi="['workflow:definition:update']"
>挂起</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-video-play"
v-if="scope.row.suspended"
@click.native="handleUpdateSuspended(scope.row)"
v-hasPermi="['workflow:definition:update']"
>激活</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['workflow:definition:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="publishTotal > 0"
:total="publishTotal"
:page.sync="publishQueryParams.pageNum"
:limit.sync="publishQueryParams.pageSize"
@pagination="getPublishList"
/>
</el-dialog>
<!-- 表单配置详情 -->
<el-dialog :title="formTitle" :visible.sync="formConfOpen" width="50%" append-to-body>
<div class="test-form">
<parser :key="new Date().getTime()" :form-conf="formConf" />
</div>
</el-dialog>
<!-- 挂载表单 -->
<el-dialog :title="formDeployTitle" :visible.sync="formDeployOpen" width="60%" append-to-body>
<el-row :gutter="24">
<el-col :span="10" :xs="24">
<el-table
ref="singleTable"
:data="formList"
border
highlight-current-row
@current-change="handleCurrentChange"
style="width: 100%">
<el-table-column label="表单编号" align="center" prop="formId" />
<el-table-column label="表单名称" align="center" prop="formName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="submitFormDeploy(scope.row)">确定</el-button>
</template>
</el-table-column>
</el-table>
<pagination
small
layout="prev, pager, next"
v-show="formTotal>0"
:total="formTotal"
:page.sync="formQueryParams.pageNum"
:limit.sync="formQueryParams.pageSize"
@pagination="ListFormDeploy"
/>
</el-col>
<el-col :span="14" :xs="24">
<div v-if="currentRow">
<parser :key="new Date().getTime()" :form-conf="currentRow" />
</div>
</el-col>
</el-row>
</el-dialog>
<designer v-if="isDesignerShow" :designerForm="processForm" @save="submitSave()" @close="isDesignerShow = false"></designer>
</div>
</template>
<script>
import { listDefinition, publishList, updateState, delDeployment, exportDeployment, definitionStart, readXml} from "@/api/workflow/definition";
import { getForm, addDeployForm ,listForm } from "@/api/workflow/form";
import { listCategory } from '@/api/workflow/category'
import Parser from '@/utils/generator/parser'
import ProcessViewer from '@/components/ProcessViewer'
import Designer from './designer'
import { getToken } from "@/utils/auth";
export default {
name: "Definition",
components: {
Parser,
ProcessViewer,
Designer
},
data() {
return {
isDesignerShow: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 流程定义表格数据
definitionList: [],
categoryOptions: [],
processForm: {},
publish: {
open: false,
loading: false,
dataList: []
},
publishTotal: 0,
publishQueryParams: {
pageNum: 1,
pageSize: 10,
processKey: ""
},
formConfOpen: false,
formTitle: "",
formDeployOpen: false,
formDeployTitle: "",
formList: [],
formTotal:0,
formConf: {}, // 默认表单数据
processView: {
title: '',
open: false,
index: undefined,
xmlData:"",
},
// bpmn.xml 导入
upload: {
// 是否显示弹出层xml导入
open: false,
// 弹出层标题xml导入
title: "",
// 是否禁用上传
isUploading: false,
name: null,
category: null,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/workflow/definition/import"
},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
category: null,
key: null,
tenantId: null,
deployTime: null,
derivedFrom: null,
derivedFromRoot: null,
parentDeploymentId: null,
engineVersion: null
},
formQueryParams:{
pageNum: 1,
pageSize: 10,
},
// 挂载表单到流程实例
formDeployParam:{
formId: null,
deployId: null
},
currentRow: null,
// 表单参数
form: {},
// 表单校验
rules: {
name: [
{ required: true, message: "流程定义名称不能为空", trigger: "blur" }
],
category: [{
required: true,
message: '请选择任意一项',
trigger: 'change'
}],
}
};
},
created() {
this.getCategoryList();
this.getList();
},
methods: {
/** 查询流程分类列表 */
getCategoryList() {
listCategory().then(response => this.categoryOptions = response.rows)
},
/** 查询流程定义列表 */
getList() {
this.loading = true;
listDefinition(this.queryParams).then(response => {
this.definitionList = response.rows;
this.total = response.total;
this.loading = false;
});
},
getPublishList() {
this.publish.loading = true;
publishList(this.publishQueryParams).then(response => {
this.publish.dataList = response.rows;
this.publishTotal = response.total;
this.publish.loading = false;
})
},
// 点击取消时关闭dialog并且清空form表格的数据
cancel (form) {
// 重置form表单
this.$refs[form].resetFields()
this.$refs['upload'].clearFiles()
// 关闭dialog
this.upload.open = false
},
// 表单重置
reset() {
this.form = {
id: null,
name: null,
category: null,
key: null,
tenantId: null,
deployTime: null,
derivedFrom: null,
derivedFromRoot: null,
parentDeploymentId: null,
engineVersion: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
handlePublish(row) {
this.publishQueryParams.processKey = row.processKey;
this.publish.open = true;
this.getPublishList();
},
/** 表单查看 */
handleForm(formId){
getForm(formId).then(res =>{
this.formTitle = "表单详情";
this.formConfOpen = true;
this.formConf = JSON.parse(res.data.content)
})
},
/** 启动流程 */
handleDefinitionStart(row){
definitionStart(row.id).then(res =>{
this.$modal.msgSuccess(res.msg);
})
},
/** 查看流程图 */
handleProcessView(row) {
let definitionId = row.definitionId;
this.processView.title = "流程图";
this.processView.index = definitionId;
// 发送请求获取xml
readXml(definitionId).then(res => {
this.processView.xmlData = res.data;
})
this.processView.open = true;
},
/** 挂载表单弹框 */
handleAddForm(row){
this.formDeployParam.deployId = row.deploymentId
this.ListFormDeploy()
},
/** 挂载表单列表 */
ListFormDeploy(){
listForm(this.formQueryParams).then(res =>{
this.formList = res.rows;
this.formTotal = res.total;
this.formDeployOpen = true;
this.formDeployTitle = "挂载表单";
})
},
// /** 更改挂载表单弹框 */
// handleEditForm(row){
// this.formDeployParam.deployId = row.deploymentId
// const queryParams = {
// pageNum: 1,
// pageSize: 10
// }
// listForm(queryParams).then(res =>{
// this.formList = res.rows;
// this.formDeployOpen = true;
// this.formDeployTitle = "挂载表单";
// })
// },
/** 挂载表单 */
submitFormDeploy(row){
this.formDeployParam.formId = row.formId;
addDeployForm(this.formDeployParam).then(res =>{
this.$modal.msgSuccess(res.msg);
this.formDeployOpen = false;
this.getList();
})
},
handleCurrentChange(data) {
if (data) {
this.currentRow = JSON.parse(data.content);
}
},
/** 挂起/激活流程 */
handleUpdateSuspended(row) {
const params = {
definitionId: row.definitionId,
suspended: !row.suspended
}
updateState(params).then(res => {
this.$modal.msgSuccess(res.msg)
this.getPublishList();
});
},
handleAdd() {
const dateTime = new Date().getTime();
this.processForm = {
processKey: `Process_${dateTime}`,
processName: `业务流程_${dateTime}`
}
this.isDesignerShow = true;
},
/** 设计按钮操作 */
handleDesigner(row) {
this.processForm = JSON.parse(JSON.stringify(row));
this.isDesignerShow = true;
},
/** 删除按钮操作 */
handleDelete(row) {
// const ids = row.deploymentId || this.ids;
const params = {
deployId: row.deploymentId
}
this.$confirm('是否确认删除流程定义编号为"' + params.deployId + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delDeployment(params);
}).then(() => {
this.getList();
this.getPublishList();
this.$modal.msgSuccess("删除成功");
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有流程定义数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportDeployment(queryParams);
}).then(response => {
this.download(response.msg);
})
},
/** 导入bpmn.xml文件 */
handleImport(){
this.upload.title = "bpmn20.xml文件导入";
this.upload.open = true;
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$message.success(response.msg);
this.getList();
},
// 提交上传文件
submitFileForm() {
this.$refs.uploadForm.validate(valid => {
if (valid) {
this.$refs.upload.submit();
}
});
},
categoryFormat(row, column) {
return this.categoryOptions.find(k => k.code === row.category)?.categoryName ?? '';
},
submitSave() {
this.getList();
}
}
};
</script>

View File

@@ -289,7 +289,6 @@
</template>
<script>
import { exportDeployment, definitionStart } from "@/api/workflow/definition";
import { getBpmnXml, listModel, historyModel, latestModel, addModel, updateModel, saveModel, delModel, deployModel } from "@/api/workflow/model";
import { listCategory } from '@/api/workflow/category'
import ProcessDesigner from '@/components/ProcessDesigner';
@@ -437,12 +436,6 @@ export default {
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 启动流程 */
handleDefinitionStart(row){
definitionStart(row.id).then(response =>{
this.$modal.msgSuccess(response.msg);
})
},
/** 部署流程 */
handleDeploy(row) {
this.loading = true;