add -- 添加流程模型和部署管理模块
This commit is contained in:
302
ruoyi-ui/src/views/workflow/deploy/index.vue
Normal file
302
ruoyi-ui/src/views/workflow/deploy/index.vue
Normal file
@@ -0,0 +1,302 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="流程标识" prop="processKey">
|
||||
<el-input
|
||||
v-model="queryParams.processKey"
|
||||
placeholder="请输入流程标识"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="流程名称" prop="processName">
|
||||
<el-input
|
||||
v-model="queryParams.processName"
|
||||
placeholder="请输入流程名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="流程分类" prop="category">
|
||||
<el-select v-model="queryParams.category" clearable placeholder="请选择" size="small">
|
||||
<el-option
|
||||
v-for="item in categoryOptions"
|
||||
:key="item.categoryId"
|
||||
:label="item.categoryName"
|
||||
:value="item.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="state">
|
||||
<el-select v-model="queryParams.state" size="small" clearable placeholder="请选择状态">
|
||||
<el-option :key="1" label="激活" value="active" />
|
||||
<el-option :key="2" label="挂起" value="suspended" />
|
||||
</el-select>
|
||||
</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-table v-loading="loading" fit :data="deployList">
|
||||
<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">
|
||||
<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-price-tag"
|
||||
@click.native="handlePublish(scope.row)"
|
||||
v-hasPermi="['workflow:deploy:list']"
|
||||
>版本管理</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['workflow:deploy:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-row>
|
||||
|
||||
<!-- 流程图 -->
|
||||
<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="handleChangeState(scope.row, 'suspended')"
|
||||
v-hasPermi="['workflow:deploy:status']"
|
||||
>挂起</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-video-play"
|
||||
v-if="scope.row.suspended"
|
||||
@click.native="handleChangeState(scope.row, 'active')"
|
||||
v-hasPermi="['workflow:deploy:status']"
|
||||
>激活</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['workflow:deploy: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>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listAllCategory } from '@/api/workflow/category'
|
||||
import { listDeploy, listPublish, getBpmnXml, changeState } from '@/api/workflow/deploy'
|
||||
import ProcessViewer from '@/components/ProcessViewer'
|
||||
|
||||
export default {
|
||||
name: 'Deploy',
|
||||
components: {
|
||||
ProcessViewer
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
processKey: null,
|
||||
processName: null,
|
||||
category: null,
|
||||
state: null
|
||||
},
|
||||
deployList: [],
|
||||
categoryOptions: [],
|
||||
processView: {
|
||||
title: '',
|
||||
open: false,
|
||||
index: undefined,
|
||||
xmlData:"",
|
||||
},
|
||||
publish: {
|
||||
open: false,
|
||||
loading: false,
|
||||
dataList: []
|
||||
},
|
||||
publishTotal: 0,
|
||||
publishQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
processKey: ""
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCategoryList();
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询流程分类列表 */
|
||||
getCategoryList() {
|
||||
listAllCategory().then(response => this.categoryOptions = response.data);
|
||||
},
|
||||
/** 查询流程部署列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDeploy(this.queryParams).then(response => {
|
||||
this.deployList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
processKey: null,
|
||||
processName: null,
|
||||
category: null,
|
||||
state: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 查看流程图 */
|
||||
handleProcessView(row) {
|
||||
let definitionId = row.definitionId;
|
||||
this.processView.title = "流程图";
|
||||
this.processView.index = definitionId;
|
||||
// 发送请求,获取xml
|
||||
getBpmnXml(definitionId).then(response => {
|
||||
this.processView.xmlData = response.data;
|
||||
})
|
||||
this.processView.open = true;
|
||||
},
|
||||
getPublishList() {
|
||||
this.publish.loading = true;
|
||||
listPublish(this.publishQueryParams).then(response => {
|
||||
this.publish.dataList = response.rows;
|
||||
this.publishTotal = response.total;
|
||||
this.publish.loading = false;
|
||||
})
|
||||
},
|
||||
handlePublish(row) {
|
||||
this.publishQueryParams.processKey = row.processKey;
|
||||
this.publish.open = true;
|
||||
this.getPublishList();
|
||||
},
|
||||
/** 挂起/激活流程 */
|
||||
handleChangeState(row, state) {
|
||||
const params = {
|
||||
definitionId: row.definitionId,
|
||||
state: state
|
||||
}
|
||||
changeState(params).then(res => {
|
||||
this.$modal.msgSuccess(res.msg)
|
||||
this.getPublishList();
|
||||
});
|
||||
},
|
||||
categoryFormat(row, column) {
|
||||
return this.categoryOptions.find(k => k.code === row.category)?.categoryName ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
295
ruoyi-ui/src/views/workflow/model/designer.vue
Normal file
295
ruoyi-ui/src/views/workflow/model/designer.vue
Normal file
@@ -0,0 +1,295 @@
|
||||
<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-row :gutter="20">
|
||||
<el-col :span="10">
|
||||
<el-divider content-position="left">
|
||||
<span style="font-size: 18px">基础信息</span>
|
||||
</el-divider>
|
||||
<el-form :model="designerForm" ref="designerForm" size="small" label-width="80px" :rules="rules">
|
||||
<el-form-item label="模型标识" prop="processKey">
|
||||
<el-input v-model="designerForm.processKey" clearable disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="模型名称" prop="processName">
|
||||
<el-input v-model="designerForm.processName" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="category">
|
||||
<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-form-item>
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="designerForm.description" type="textarea" placeholder="请输入内容" maxlength="200" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="表单类型" prop="formType">
|
||||
<el-radio-group v-model="designerForm.formType">
|
||||
<el-radio :label="0">内置表单</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="表单" prop="formId">
|
||||
<el-select v-model="designerForm.formId" placeholder="请选择表单" @change="handleFormChange(designerForm.formId)" clearable style="width:100%">
|
||||
<el-option v-for="item in formOptions" :key="item.formId" :label="item.formName" :value="item.formId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="13" :offset="1">
|
||||
<el-divider content-position="left">
|
||||
<span style="font-size: 18px">表单预览</span>
|
||||
</el-divider>
|
||||
<parser v-if="formShow" :form-conf="formContent" />
|
||||
<el-empty v-else description="暂无数据" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</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 { getModel, getBpmnXml, saveModel } from "@/api/workflow/model";
|
||||
import { getForm, listForm } from "@/api/workflow/form";
|
||||
import ProcessDesigner from '@/components/ProcessDesigner';
|
||||
import Parser from '@/utils/generator/parser'
|
||||
import { listAllCategory } from '@/api/workflow/category';
|
||||
|
||||
export default {
|
||||
name: 'Designer',
|
||||
components: { ProcessDesigner, Parser },
|
||||
props: {
|
||||
modelId: {
|
||||
type: String
|
||||
},
|
||||
processName: {
|
||||
type: String
|
||||
},
|
||||
processKey: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
activeStep: 0,
|
||||
designerForm: {},
|
||||
rules: {
|
||||
modelKey: [
|
||||
{ required: true, message: '请输入模型标识', trigger: 'blur' }
|
||||
],
|
||||
modelName: [
|
||||
{ required: true, message: '请输入模型名称', trigger: 'blur' }
|
||||
],
|
||||
category: [
|
||||
{ required: true, message: '请选择分类', trigger: 'change' }
|
||||
],
|
||||
formType: [
|
||||
{ required: true, message: '请选择表单类型', trigger: 'change' }
|
||||
],
|
||||
formId: [
|
||||
{ required: true, message: '请选择表单', trigger: 'change' }
|
||||
]
|
||||
},
|
||||
categoryOptions: [],
|
||||
formOptions: [],
|
||||
formShow: false,
|
||||
formContent: {},
|
||||
loadIndex: 0,
|
||||
loading: false,
|
||||
bpmnXml: '',
|
||||
result: {
|
||||
icon: 'info',
|
||||
title: null,
|
||||
describe: null
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.onLoad();
|
||||
},
|
||||
methods: {
|
||||
onClose () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onPrevious() {
|
||||
this.activeStep--;
|
||||
},
|
||||
onNext() {
|
||||
this.activeStep++;
|
||||
},
|
||||
/**
|
||||
* 初始化加载
|
||||
*/
|
||||
onLoad() {
|
||||
this.getCategoryList();
|
||||
this.getFormList();
|
||||
if (this.modelId) {
|
||||
getModel(this.modelId).then(response => {
|
||||
const data = response.data
|
||||
this.designerForm = {
|
||||
processName: data.modelName,
|
||||
processKey: data.modelKey,
|
||||
category: data.category,
|
||||
description: data.description,
|
||||
formType: data.formType,
|
||||
formId: data.formId
|
||||
}
|
||||
if (data.bpmnXml) {
|
||||
this.bpmnXml = data.bpmnXml
|
||||
}
|
||||
if (data.content) {
|
||||
this.formContent = JSON.parse(data.content)
|
||||
this.formShow = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.designerForm = {
|
||||
processName: this.processName,
|
||||
processKey: this.processKey,
|
||||
formType: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
/** 查询流程分类列表 */
|
||||
getCategoryList() {
|
||||
listAllCategory().then(response => this.categoryOptions = response.data)
|
||||
},
|
||||
/** 查询流程分类列表 */
|
||||
getFormList() {
|
||||
listForm().then(response => this.formOptions = response.rows)
|
||||
},
|
||||
handleFormChange(formId) {
|
||||
this.formShow = false
|
||||
if (formId) {
|
||||
getForm(formId).then(res =>{
|
||||
this.formContent = JSON.parse(res.data.content)
|
||||
this.formShow = true
|
||||
})
|
||||
}
|
||||
},
|
||||
onSave() {
|
||||
|
||||
let refProcessDesigner = this.$refs.modelDesigner.$refs.processDesigner;
|
||||
refProcessDesigner.onSave().then(xml => {
|
||||
this.bpmnXml = xml;
|
||||
let dataBody = {
|
||||
modelName: this.designerForm.processName,
|
||||
modelKey: this.designerForm.processKey,
|
||||
category: this.designerForm.category,
|
||||
description: this.designerForm.description,
|
||||
formType: this.designerForm.formType,
|
||||
formId: this.designerForm.formId,
|
||||
bpmnXml: this.bpmnXml
|
||||
}
|
||||
this.$confirm("是否将此模型保存为新版本?", "提示", {
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: '是',
|
||||
cancelButtonText: '否'
|
||||
}).then(() => {
|
||||
this.confirmSave(dataBody, true)
|
||||
}).catch(action => {
|
||||
if (action === 'cancel') {
|
||||
this.confirmSave(dataBody, false)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
confirmSave(body, newVersion) {
|
||||
this.loading = true;
|
||||
saveModel(Object.assign(body, {
|
||||
newVersion: newVersion
|
||||
})).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.loading = false;
|
||||
this.onNext();
|
||||
this.$emit('save');
|
||||
})
|
||||
},
|
||||
/** xml 文件 */
|
||||
getModelDetail(modelId) {
|
||||
this.loading = true;
|
||||
// 发送请求,获取xml
|
||||
getBpmnXml(modelId).then(res => {
|
||||
this.bpmnXml = res.data;
|
||||
this.loadIndex = modelId;
|
||||
this.loading = false;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</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>
|
||||
525
ruoyi-ui/src/views/workflow/model/index.vue
Normal file
525
ruoyi-ui/src/views/workflow/model/index.vue
Normal file
@@ -0,0 +1,525 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="模型标识" prop="modelKey">
|
||||
<el-input
|
||||
v-model="queryParams.modelKey"
|
||||
placeholder="请输入模型标识"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="模型名称" prop="modelName">
|
||||
<el-input
|
||||
v-model="queryParams.modelName"
|
||||
placeholder="请输入模型名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="流程分类" prop="category">
|
||||
<el-select v-model="queryParams.category" clearable placeholder="请选择" size="small">
|
||||
<el-option
|
||||
v-for="item in categoryOptions"
|
||||
:key="item.categoryId"
|
||||
:label="item.categoryName"
|
||||
:value="item.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</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:model:import']"
|
||||
>导入</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:model:add']"
|
||||
>新增</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:model: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:model:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" fit :data="modelList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="模型标识" align="center" prop="modelKey" :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.modelName }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="流程分类" align="center" prop="categoryName" :formatter="categoryFormat" />
|
||||
<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" prop="description" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" 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-brush"
|
||||
@click="handleDesigner(scope.row)"
|
||||
v-hasPermi="['workflow:model:designer']"
|
||||
>设计</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-video-play"
|
||||
v-hasPermi="['workflow:model:deploy']"
|
||||
@click.native="handleDeploy(scope.row)"
|
||||
>部署</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:model:view']"
|
||||
>流程图</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
icon="el-icon-price-tag"
|
||||
@click.native="handleHistory(scope.row)"
|
||||
v-hasPermi="['workflow:model:list']"
|
||||
>历史</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
icon="el-icon-delete"
|
||||
@click.native="handleDelete(scope.row)"
|
||||
v-hasPermi="['workflow:model:remove']"
|
||||
>删除</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="history.open" width="70%" >
|
||||
<el-table v-loading="history.loading" fit :data="historyList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="模型标识" align="center" prop="modelKey" :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.modelName }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="流程分类" align="center" prop="categoryName" :formatter="categoryFormat" />
|
||||
<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" prop="description" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" 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-video-play"
|
||||
v-hasPermi="['workflow:model:designer']"
|
||||
@click.native="handleDeploy(scope.row)"
|
||||
>部署</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-star-off"
|
||||
v-hasPermi="['workflow:model:designer']"
|
||||
@click.native="handleLatest(scope.row)"
|
||||
>设为最新</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="historyTotal > 0"
|
||||
:total="historyTotal"
|
||||
:page.sync="queryHistoryParams.pageNum"
|
||||
:limit.sync="queryHistoryParams.pageSize"
|
||||
@pagination="getHistoryList"
|
||||
/>
|
||||
</el-dialog>
|
||||
|
||||
<designer
|
||||
v-if="designerOpen"
|
||||
:modelId="designerData.modelId"
|
||||
:processName="designerData.processName"
|
||||
:processKey="designerData.processKey"
|
||||
@save="submitSave()"
|
||||
@close="designerOpen = false"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { exportDeployment, definitionStart } from "@/api/workflow/definition";
|
||||
import { getBpmnXml, listModel, historyModel, latestModel, delModel, deployModel } from "@/api/workflow/model";
|
||||
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: "Model",
|
||||
components: {
|
||||
Parser,
|
||||
ProcessViewer,
|
||||
Designer
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 流程模型表格数据
|
||||
modelList: [],
|
||||
categoryOptions: [],
|
||||
designerOpen: false,
|
||||
designerData: {
|
||||
modelId: null,
|
||||
processName: null,
|
||||
processKey: null
|
||||
},
|
||||
designerModelId: null,
|
||||
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,
|
||||
modelKey: null,
|
||||
modelName: null,
|
||||
category: null
|
||||
},
|
||||
currentRow: null,
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: "流程定义名称不能为空", trigger: "blur" }
|
||||
],
|
||||
category: [{
|
||||
required: true,
|
||||
message: '请选择任意一项',
|
||||
trigger: 'change'
|
||||
}],
|
||||
},
|
||||
history: {
|
||||
open: false,
|
||||
loading: false
|
||||
},
|
||||
historyList: [],
|
||||
historyTotal: 0,
|
||||
queryHistoryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
modelKey: null
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getCategoryList();
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询流程分类列表 */
|
||||
getCategoryList() {
|
||||
listCategory().then(response => this.categoryOptions = response.rows)
|
||||
},
|
||||
/** 查询流程模型列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listModel(this.queryParams).then(response => {
|
||||
this.modelList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 点击取消时关闭dialog并且清空form表格的数据
|
||||
cancel (form) {
|
||||
// 重置form表单
|
||||
this.$refs['upload'].clearFiles()
|
||||
// 关闭dialog
|
||||
this.upload.open = false
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.modelId)
|
||||
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;
|
||||
deployModel({
|
||||
modelId: row.modelId
|
||||
}).then(response => {
|
||||
this.$modal.msgSuccess(response.msg)
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
/** 查看流程图 */
|
||||
handleProcessView(row) {
|
||||
let modelId = row.modelId;
|
||||
this.processView.title = "流程图";
|
||||
this.processView.index = modelId;
|
||||
// 发送请求,获取xml
|
||||
getBpmnXml(modelId).then(response => {
|
||||
this.processView.xmlData = response.data;
|
||||
})
|
||||
this.processView.open = true;
|
||||
},
|
||||
getHistoryList() {
|
||||
this.history.loading = true;
|
||||
historyModel(this.queryHistoryParams).then(response => {
|
||||
this.historyTotal = response.total;
|
||||
this.historyList = response.rows;
|
||||
this.history.loading = false;
|
||||
})
|
||||
},
|
||||
handleHistory(row) {
|
||||
this.history.open = true;
|
||||
this.queryHistoryParams.modelKey = row.modelKey;
|
||||
this.getHistoryList();
|
||||
},
|
||||
/** 设为最新版 */
|
||||
handleLatest(row) {
|
||||
this.$modal.confirm('是否确认将此版本设为最新?').then(() => {
|
||||
this.history.loading = true;
|
||||
latestModel({
|
||||
modelId: row.modelId
|
||||
}).then(response => {
|
||||
this.history.open = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess(response.msg);
|
||||
}).finally(() => {
|
||||
this.history.loading = false;
|
||||
})
|
||||
})
|
||||
},
|
||||
handleCurrentChange(data) {
|
||||
if (data) {
|
||||
this.currentRow = JSON.parse(data.content);
|
||||
}
|
||||
},
|
||||
handleAdd() {
|
||||
const dateTime = new Date().getTime();
|
||||
this.designerData = {
|
||||
processKey: `Process_${dateTime}`,
|
||||
processName: `业务流程_${dateTime}`
|
||||
}
|
||||
this.designerOpen = true;
|
||||
},
|
||||
/** 设计按钮操作 */
|
||||
handleDesigner(row) {
|
||||
this.designerData.modelId = row.modelId;
|
||||
this.designerOpen = true;
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const modelIds = row.modelId || this.ids;
|
||||
this.$modal.confirm('是否确认删除模型编号为"' + modelIds + '"的数据项?').then(() => {
|
||||
this.loading = true;
|
||||
return delModel(modelIds);
|
||||
}).then(() => {
|
||||
this.loading = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
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>
|
||||
Reference in New Issue
Block a user