流程编辑
This commit is contained in:
1 parent
7751704fe7
commit
696457321b
6 files changed
+915
-313
No files matched your search
@@ -1,36 +1,105 @@
|
||||
<template id="process-flow">
|
||||
<v-card class="process-flow-container">
|
||||
<!-- 左侧 节点选择列表 >>>>>>>>>>>>> -->
|
||||
<v-card v-if="!readonly" :style="{'width': isMobile ? '100%' : '150px'}" outlined
|
||||
:class="{'pa-4': !isMobile, 'pa-2': isMobile, 'mr-2': !isMobile}" outlined>
|
||||
<div class="menu-item mb-2" v-for="item in menuList" @mousedown.stop.prevent="startDrag(item)">
|
||||
<v-icon small class="mr-1">{{ item.icon }}</v-icon>
|
||||
{{item.name}}
|
||||
<template v-if="displayMode == 'simple'">
|
||||
<!-- 简单左侧 >>>>>>>>>>>>> -->
|
||||
<div style="width: 100%;">
|
||||
<v-card class="d-flex mb-1 overflow-y-auto" height="700" outlined>
|
||||
<div class="d-flex flex-column flex-fill align-center">
|
||||
<template v-for="(nodeItem, nodeIndex) in workflowConfig.nodeList" :key="index">
|
||||
<v-card elevation="2" width="240" @click="editNode(nodeItem)">
|
||||
<v-card-text class="pa-4">
|
||||
<span>{{nodeItem.properties.label}}</span>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<template v-if="!nodeItem.id.startsWith('end-')">
|
||||
<div class="d-flex justify-center" style="position: relative;width: 240px;">
|
||||
<div class="mr-2">
|
||||
<div class="divider-vertical"></div>
|
||||
<div class="arrow"></div>
|
||||
</div>
|
||||
<v-menu
|
||||
:value="menuShown(event, nodeIndex)"
|
||||
:data-menu-Index="nodeIndex"
|
||||
:close-on-content-click="false"
|
||||
offset-x
|
||||
>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<div class="add-btn-box" v-bind="attrs" v-on="on" :data-menu-Index="nodeIndex" @click="showMenuShown"></div>
|
||||
</template>
|
||||
<v-list class="d-flex">
|
||||
<v-list-item :data-from="nodeItem.id" :data-to="workflowConfig.nodeList[nodeIndex + 1].id" @click="addNodeBySimple({type: 'approvalTask', prevIndex: nodeIndex})">
|
||||
<div class="d-flex flex-column align-center add-node-box">
|
||||
<v-icon class="mb-1" color="#FCAD22">mdi-stamper</v-icon>
|
||||
<span>审批节点</span>
|
||||
</div>
|
||||
</v-list-item>
|
||||
<v-list-item :data-from="nodeItem.id" :data-to="workflowConfig.nodeList[nodeIndex + 1].id" @click="addNodeBySimple({type: 'noticeTask', prevIndex: nodeIndex})">
|
||||
<div class="d-flex flex-column align-center add-node-box">
|
||||
<v-icon class="mb-1" color="#3CB4B2">mdi-send</v-icon>
|
||||
<span>抄送节点</span>
|
||||
</div>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</v-card>
|
||||
</div>
|
||||
</v-card>
|
||||
<!-- <<<<<<<<<<<<< 左侧 节点选择列表 -->
|
||||
<!-- <<<<<<<<<<<<< 简单左侧 -->
|
||||
</template>
|
||||
<template v-if="displayMode == 'complex'">
|
||||
<!-- 复杂左侧 >>>>>>>>>>>>> -->
|
||||
<div style="width: 100%;">
|
||||
<!-- <<<<<<<<<<<<< 左上 节点选择列表 -->
|
||||
<v-card v-if="!readonly" class="d-flex mb-1" outlined>
|
||||
<div class="menu-item ma-1" v-for="item in menuList" @mousedown.stop.prevent="startDrag(item)">
|
||||
<v-icon small class="mr-1">{{ item.icon }}</v-icon>
|
||||
<span>{{item.name}}</span>
|
||||
</div>
|
||||
</v-card>
|
||||
<!-- <<<<<<<<<<<<< 左上 节点选择列表 -->
|
||||
<!-- 左下 主内容编辑区 >>>>>>>>>>>>> -->
|
||||
<v-card class="flow-detail pa-2" outlined>
|
||||
<div id="flowContent" ref="flowContent"></div>
|
||||
</v-card>
|
||||
<!-- <<<<<<<<<<<<< 左下 主内容编辑区 -->
|
||||
</div>
|
||||
<!-- <<<<<<<<<<<<< 复杂左侧 -->
|
||||
</template>
|
||||
<template>
|
||||
<!-- 复杂右侧 >>>>>>>>>>>>> -->
|
||||
<div :style="{'width': isMobile ? 'auto' : '350px'}">
|
||||
<!-- 右上 模式切换区 >>>>>>>>>>>>> -->
|
||||
<v-card class="mb-1 d-flex align-center" :class="{'ml-2': !isMobile}" >
|
||||
<!-- <div>{{constantObj.displayModes[displayModeIndex].text}}</div> -->
|
||||
<v-btn v-for="(displayMode, index) in constantObj.displayModes" v-if="index != displayModeIndex" class="ml-1 my-2" style="flex: 1;" color="primary"
|
||||
small outlined @click="doUiAction('changeDisplayMode', displayMode.value)">
|
||||
<span>切换展示模式</span>
|
||||
</v-btn>
|
||||
</v-card>
|
||||
<!-- <<<<<<<<<<<<< 右上 模式切换区 -->
|
||||
<!-- 右下 属性编辑区 >>>>>>>>>>>>> -->
|
||||
<v-card v-show="!readonly" class="pa-2" :class="{'ml-2': !isMobile}" style="height: 100%;" outlined>
|
||||
<div class="font-weight-medium text-subtitle-2 text-subtitle-2 mb-3">
|
||||
<v-icon size="18" class="mr-1">mdi-application-cog-outline</v-icon>
|
||||
<span style="transform: translateY(2px); display: inline-block;">{{editType == 'node' ? '节点属性' : editType == 'line' ? '连线属性' : '属性面板'}}</span>
|
||||
</div>
|
||||
<div v-if="editType == 'node' || editType == 'line'" class="flow-edit-content">
|
||||
<edit-node ref="nodeForm" v-if="editType == 'node'" :lf="logicFlow" :user="user" :group="group" :label="label" :workflow-form="workflowForm" :workflow-config="workflowConfig"
|
||||
:display-mode="displayMode" @reflesh-workflow="setBusinessData"></edit-node>
|
||||
<edit-line ref="lineForm" v-if="editType == 'line'" :lf="logicFlow" @reflesh-workflow="setBusinessData"></edit-line>
|
||||
</div>
|
||||
<div v-else class="text-center mt-8">
|
||||
请选择节点或连接线~
|
||||
</div>
|
||||
</v-card>
|
||||
<!-- <<<<<<<<<<<<< 右下 属性编辑区 -->
|
||||
</div>
|
||||
<!-- <<<<<<<<<<<<< 复杂右侧 -->
|
||||
</template>
|
||||
|
||||
<!-- 中间 主内容编辑区 >>>>>>>>>>>>> -->
|
||||
<v-card class="flow-detail pa-4" outlined>
|
||||
<div id="flowContent" ref="flowContent"></div>
|
||||
</v-card>
|
||||
<!-- <<<<<<<<<<<<< 中间 主内容编辑区 -->
|
||||
|
||||
<!-- 右侧 属性编辑区 >>>>>>>>>>>>> -->
|
||||
<v-card v-show="!readonly" :style="{'width': isMobile ? 'auto' : '300px'}" class="pa-4" :class="{'ml-2': !isMobile}" outlined>
|
||||
<div class="font-weight-medium text-subtitle-2 text-subtitle-2 mb-3">
|
||||
<v-icon size="18" class="mr-1">mdi-application-cog-outline</v-icon>
|
||||
<span style="transform: translateY(2px); display: inline-block;">{{editType == 'node' ? '节点属性' : editType == 'line' ? '连线属性' : '属性面板'}}</span>
|
||||
</div>
|
||||
<div v-if="editType == 'node' || editType == 'line'" class="flow-edit-content">
|
||||
<edit-node ref="nodeForm" v-if="editType == 'node'" :lf="logicFlow" :user="user" :group="group" :mode="mode" :tpl="tpl"></edit-node>
|
||||
<edit-line ref="lineForm" v-if="editType == 'line'" :lf="logicFlow" :mode="mode"></edit-line>
|
||||
</div>
|
||||
<div v-else class="text-center mt-8">
|
||||
请选择节点或连接线~
|
||||
</div>
|
||||
</v-card>
|
||||
<!-- <<<<<<<<<<<<< 右侧 属性编辑区 -->
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
@@ -51,7 +120,7 @@ Vue.component("process-flow", {
|
||||
vuetify: new Vuetify(),
|
||||
name: 'process-flow',
|
||||
props: {
|
||||
data: {
|
||||
workflowConfig: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
@@ -72,7 +141,13 @@ Vue.component("process-flow", {
|
||||
return []
|
||||
}
|
||||
},
|
||||
tpl: {
|
||||
label: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
},
|
||||
workflowForm: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
@@ -86,52 +161,242 @@ Vue.component("process-flow", {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'serial'
|
||||
}
|
||||
},
|
||||
data: () => {
|
||||
return {
|
||||
constantObj: {
|
||||
displayModes: [
|
||||
{
|
||||
text: '简易模式',
|
||||
value: 'simple'
|
||||
},
|
||||
{
|
||||
text: '复杂模式',
|
||||
value: 'complex'
|
||||
},
|
||||
],
|
||||
nodeColor: {
|
||||
'start':'#88939F',
|
||||
'userTask':'#FCAD22',
|
||||
'approvalTask':'#FCAD22',
|
||||
'noticeTask':'#3CB4B2',
|
||||
'conditionTask':'#88939F',
|
||||
'approvalTask':'#88939F',
|
||||
}
|
||||
},
|
||||
menuList: [
|
||||
{name: '起点', type: 'start', icon: 'mdi-ray-start'},
|
||||
{name: '终点', type: 'end', icon: 'mdi-ray-end'},
|
||||
{name: '审批节点', type: 'userTask', icon: 'mdi-account-details-outline'},
|
||||
{name: '处理节点', type: 'receiveTask', icon: 'mdi-account-check-outline'},
|
||||
{name: '审批节点', type: 'approvalTask', icon: 'mdi-account-check-outline'},
|
||||
{name: '抄送节点', type: 'noticeTask', icon: 'mdi-account-check-outline'},
|
||||
{name: '条件节点', type: 'conditionTask', icon: 'mdi-account-check-outline'},
|
||||
],
|
||||
logicFlow: null, // logicflow实例
|
||||
// 是否加载完毕
|
||||
loadEasyFlowFinish: false,
|
||||
// 数据
|
||||
editType: 'flow', //编辑的类型
|
||||
lineTypeList: [
|
||||
{text: '同意', value: 'agree'},
|
||||
{text: '拒绝', value: 'deny'},
|
||||
]
|
||||
displayModeIndex: 1, // 'complex'、'simple'
|
||||
displayMode: 'complex', // 'complex'、'simple'
|
||||
mode: "mode",
|
||||
isAddNodeMenuShown: false,
|
||||
activeMenuIndex: -1,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
mode() {
|
||||
this.logicFlow.clearData();
|
||||
}
|
||||
},
|
||||
workflowConfig: {
|
||||
handler: async function (val) {
|
||||
// 初始化起点和终点
|
||||
if(!val.nodeList.length && !val.lineList.length){
|
||||
let startId = this.getUUID('start')
|
||||
let endId = this.getUUID('end')
|
||||
let lineId = this.getUUID('line')
|
||||
this.workflowConfig = {
|
||||
"nodeList":[
|
||||
{"id":startId,"type":"CustomNode","x":400,"y":160,"properties":{"id":startId,"label":"起点","type":"start"},"text":{"x":400,"y":160,"value":"起点"}},
|
||||
{"id":endId,"type":"CustomNode","x":400,"y":320,"properties":{"id":endId,"label":"终点","type":"end"},"text":{"x":400,"y":320,"value":"终点"}}
|
||||
],
|
||||
"lineList":[
|
||||
{"id":lineId,"type":"polyline","sourceNodeId":startId,"targetNodeId":endId,
|
||||
"startPoint":{"x":400,"y":180},"endPoint":{"x":400,"y":300},
|
||||
"properties":{"from":startId,"to":endId,"label":"连线文本","type":"同意","id":lineId,"Remark":"","endpoint":"Dot"},
|
||||
"text":{"x":400,"y":225,"value":"同意-连线文本"},"pointsList":[{"x":400,"y":180},{"x":400,"y":300}]}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
},
|
||||
created(){
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.initLogicFlowInstance();
|
||||
this.initLogicFlowCustomType();
|
||||
this.initLogicFlowControl();
|
||||
this.initLogicFlowMenu();
|
||||
this.initLogicFlowEvent();
|
||||
this.initLogicFlowData();
|
||||
async doUiAction(uiActionId, uiActionData) {
|
||||
switch (uiActionId) {
|
||||
case 'complexModeInit':
|
||||
await this.initLogicFlowInstance();
|
||||
await this.initLogicFlowCustomType();
|
||||
await this.initLogicFlowControl();
|
||||
await this.initLogicFlowMenu();
|
||||
await this.initLogicFlowEvent();
|
||||
await this.initLogicFlowData();
|
||||
break;
|
||||
case 'changeDisplayMode':
|
||||
await this.changeDisplayMode(uiActionData);
|
||||
break;
|
||||
default:
|
||||
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
showMenuShown(event){
|
||||
this.activeMenuIndex = event?.target.dataset.menuIndex
|
||||
},
|
||||
menuShown(index){
|
||||
return event?.target.dataset.itemIndex == this.activeMenuIndex || false
|
||||
},
|
||||
async addNodeBySimple({type, prevIndex = -1}){
|
||||
if(prevIndex == -1) throw new Error("[addNodeBySimple] 出错!");
|
||||
// 加一个节点和两条线
|
||||
var _this = this
|
||||
|
||||
var prevNode = _this.workflowConfig.nodeList[prevIndex]
|
||||
var nextNode = _this.workflowConfig.nodeList[prevIndex + 1]
|
||||
var node = await initNodebySimple(type, prevNode)
|
||||
var prevLine = initLinebySimple(prevNode, node)
|
||||
var nextLine = initLinebySimple(node, nextNode)
|
||||
|
||||
_this.workflowConfig.nodeList.splice(prevIndex + 1, 0 ,node)
|
||||
_this.workflowConfig.lineList.push(prevLine, nextLine)
|
||||
|
||||
// 去掉原有的连线
|
||||
_this.workflowConfig.lineList = _this.workflowConfig.lineList.filter(line => !(line.sourceNodeId == prevNode.id && line.targetNodeId == nextNode.id))
|
||||
|
||||
this.$emit('reflesh-workflow-config', this.workflowConfig)
|
||||
// 两种模式统一数据,待优化
|
||||
this.initLogicFlowData()
|
||||
|
||||
function initNodebySimple(type = 'approvalTask', prevNode){
|
||||
if(!prevNode) throw new Error("[initNodebySimple] 无前置节点!");
|
||||
var Id = _this.getUUID(type)
|
||||
var node = {
|
||||
"id": Id,
|
||||
"type": "CustomNode",
|
||||
"x": prevNode.x - 150,
|
||||
"y": prevNode.y + 40,
|
||||
"properties": {
|
||||
"id": Id,
|
||||
"label": type == 'approvalTask' ? '审批节点' : '抄送节点',
|
||||
"type": type
|
||||
},
|
||||
"text": {
|
||||
"x": prevNode.x - 130,
|
||||
"y": prevNode.y + 40,
|
||||
"value": type == 'approvalTask' ? '审批节点' : '抄送节点',
|
||||
}
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
function initLinebySimple(prevNode, nextNode){
|
||||
if(!prevNode || !nextNode) throw new Error("[initNodebySimple] 无前置或后置节点!");
|
||||
var Id = _this.getUUID(type)
|
||||
var line = {
|
||||
"id": Id,
|
||||
"type": "polyline",
|
||||
"sourceNodeId": prevNode.id,
|
||||
"targetNodeId": nextNode.id,
|
||||
"startPoint": {
|
||||
"x": prevNode.x + 10,
|
||||
"y": prevNode.y + 20,
|
||||
},
|
||||
"endPoint": {
|
||||
"x": nextNode.x + 10,
|
||||
"y": nextNode.y - 20,
|
||||
},
|
||||
"properties": {
|
||||
"from": prevNode.id,
|
||||
"to": nextNode.id,
|
||||
"label": "连线文本",
|
||||
"type": "同意",
|
||||
"id": Id,
|
||||
"endpoint": "Dot",
|
||||
},
|
||||
"text": {
|
||||
"x": (prevNode.x + nextNode.x) / 2,
|
||||
"y": (prevNode.y + nextNode.y) / 2,
|
||||
"value": "同意-连线文本"
|
||||
}
|
||||
}
|
||||
return line
|
||||
}
|
||||
},
|
||||
|
||||
// 切换展示模式
|
||||
changeDisplayMode(displayMode){
|
||||
var changeAble = true
|
||||
var changeText = ""
|
||||
var lineList = this.workflowConfig.lineList
|
||||
var nodeList = this.workflowConfig.nodeList
|
||||
|
||||
if(displayMode == 'simple'){
|
||||
// 检查是否有多个开始节点或结束节点
|
||||
if(nodeList.filter(n=>n.properties.type == 'start').length != 1 || nodeList.filter(n=>n.properties.type == 'end').length != 1){
|
||||
changeAble = false
|
||||
changeText = "只允许存在1个开始节点或结束节点"
|
||||
}
|
||||
|
||||
// 检查是否有条件节点
|
||||
if(changeAble && nodeList.filter(n=>n.properties.type == 'conditionTask').length){
|
||||
changeAble = false
|
||||
changeText = "存在条件节点"
|
||||
}
|
||||
|
||||
// 检查是否有多线程:有两条线的sourceNodeId/targetNodeId一样
|
||||
var hasSerial = _.some(lineList, (item, index) => {
|
||||
return _.some(lineList.slice(0, index), prevItem => {
|
||||
return prevItem.sourceNodeId === item.sourceNodeId || prevItem.targetNodeId === item.targetNodeId
|
||||
})
|
||||
})
|
||||
if(changeAble && hasSerial){
|
||||
changeAble = false
|
||||
changeText = "存在多线程"
|
||||
}
|
||||
|
||||
// 检查是否存在节点未连接
|
||||
if(changeAble && lineList.length != nodeList.length - 1){
|
||||
changeAble = false
|
||||
changeText = "存在节点未连接"
|
||||
}
|
||||
}
|
||||
if(changeAble){
|
||||
this.displayMode = displayMode
|
||||
this.displayModeIndex = this.constantObj.displayModes.findIndex(m=>m.value == displayMode)
|
||||
this.editType = null
|
||||
|
||||
if(this.displayMode == 'complex'){
|
||||
this.$nextTick(()=>{
|
||||
this.doUiAction('complexModeInit')
|
||||
})
|
||||
}
|
||||
|
||||
}else{
|
||||
window.vtoast.fail("当前结构不能切换到简易模式:" + changeText + "!");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 初始化logicFlow实例
|
||||
*/
|
||||
@@ -161,7 +426,9 @@ Vue.component("process-flow", {
|
||||
stopScrollGraph: true,
|
||||
edgeType: 'polyline',
|
||||
plugins: [MiniMap, Menu, SelectionSelect, Control, Popup],
|
||||
isSilentMode: this.readonly
|
||||
isSilentMode: this.readonly,
|
||||
width: 1100,
|
||||
height: 700
|
||||
|
||||
});
|
||||
},
|
||||
@@ -189,7 +456,7 @@ Vue.component("process-flow", {
|
||||
if (_this.currentNodeId === this.id) {
|
||||
style.fill = "#4caf50";
|
||||
} else {
|
||||
const rawNode = _this.data.nodeList.find(o => o.id === this.id)
|
||||
const rawNode = _this.workflowConfig.nodeList.find(o => o.id === this.id)
|
||||
if (rawNode && rawNode.inPath) {
|
||||
style.fill = "#d4ffd6";
|
||||
}
|
||||
@@ -250,6 +517,7 @@ Vue.component("process-flow", {
|
||||
text: '删除连线',
|
||||
callback(edge) {
|
||||
logicFlow.deleteEdge(edge.id);
|
||||
this.getBusinessData()
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -267,14 +535,13 @@ Vue.component("process-flow", {
|
||||
// 添加节点
|
||||
logicFlow.on('node:add', (e) => {
|
||||
const {data} = e;
|
||||
this.data.nodeList.push(data);
|
||||
this.workflowConfig.nodeList.push(data);
|
||||
this.addNode(data);
|
||||
this.editNode(data);
|
||||
});
|
||||
// 选中节点
|
||||
logicFlow.on("node:click", (e) => {
|
||||
const {data} = e;
|
||||
data.properties.userList = [];
|
||||
this.editNode(data);
|
||||
});
|
||||
// 添加边
|
||||
@@ -305,7 +572,7 @@ Vue.component("process-flow", {
|
||||
Remark: '',
|
||||
endpoint: 'Dot' // 线的类型
|
||||
}
|
||||
this.data.lineList.push(line);
|
||||
this.workflowConfig.lineList.push(line);
|
||||
logicFlow.updateText(id, line.label);
|
||||
logicFlow.setProperties(id, line);
|
||||
this.editLine(logicFlow.getEdgeDataById(id));
|
||||
@@ -320,13 +587,14 @@ Vue.component("process-flow", {
|
||||
}
|
||||
this.editLine(data);
|
||||
});
|
||||
// 双击节点
|
||||
// 双击节点 TODO:删除后更新数据
|
||||
logicFlow.on("node:dbclick", (e) => {
|
||||
const {id} = e.data;
|
||||
logicFlow.deleteNode(id);
|
||||
|
||||
});
|
||||
|
||||
// 双击边
|
||||
// 双击边 TODO:删除后更新数据
|
||||
logicFlow.on("edge:dbclick", (e) => {
|
||||
const {id} = e.data;
|
||||
logicFlow.deleteEdge(id);
|
||||
@@ -354,7 +622,7 @@ Vue.component("process-flow", {
|
||||
// this.logicFlow.render({ "nodes":[], "edges":[] })
|
||||
// this.logicFlow.render({"nodes":[{"id":"3","type":"CustomNode","x":380,"y":140,"properties":{},"text":{"x":380,"y":140,"value":"开始"}},{"id":"1","type":"CustomNode","x":380,"y":280,"properties":{},"text":{"x":380,"y":280,"value":"经理"}},{"id":"2","type":"CustomNode","x":380,"y":420,"properties":{},"text":{"x":380,"y":420,"value":"结束"}}],"edges":[{"id":"a2ed12a0-7548-4725-a8e6-290d565d66da","type":"polyline","sourceNodeId":"3","targetNodeId":"1","startPoint":{"x":380,"y":160},"endPoint":{"x":380,"y":260},"properties":{},"text":{"x":380,"y":190,"value":"开始"},"pointsList":[{"x":380,"y":160},{"x":380,"y":260}]},{"id":"135f3e3a-d8c5-4329-83d6-833512175ea4","type":"polyline","sourceNodeId":"2","targetNodeId":"1","startPoint":{"x":330,"y":420},"endPoint":{"x":330,"y":280},"properties":{},"text":{"x":265,"y":350,"value":"经理审核拒绝"},"pointsList":[{"x":330,"y":420},{"x":265,"y":420},{"x":265,"y":280},{"x":330,"y":280}]},{"id":"c4dbefa6-1ce0-4cef-babe-444329affea7","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":430,"y":280},"endPoint":{"x":430,"y":420},"properties":{},"text":{"x":495,"y":350,"value":"经理审核通过"},"pointsList":[{"x":430,"y":280},{"x":495,"y":280},{"x":495,"y":420},{"x":430,"y":420}]},{"id":"6fb6a3b1-a8fc-4d22-b9f0-5692208118d5","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":348,"y":300},"endPoint":{"x":348,"y":400},"properties":{},"text":{"x":348,"y":350,"value":"同意-连线文本"},"pointsList":[{"x":348,"y":300},{"x":348,"y":400}]}]})
|
||||
// this.logicFlow.render({"nodes":[{"id":"start-c31f75a55c48","type":"CustomNode","x":100,"y":80,"properties":{"id":"start-c31f75a55c48","label":"起点","type":"start","assignType":"person","assignValue":["admin"],"lineTypeList":"同意"},"text":{"x":100,"y":80,"value":"起点"}},{"id":"end-72e945407d48","type":"CustomNode","x":540,"y":80,"properties":{"id":"end-72e945407d48","label":"终点","type":"end","assignType":"person","assignValue":["admin"],"lineTypeList":""},"text":{"x":540,"y":80,"value":"终点"}},{"id":"userTask-fa96d9f1f548","type":"CustomNode","x":320,"y":80,"properties":{"id":"userTask-fa96d9f1f548","label":"审批节点","type":"userTask","assignType":"person","assignValue":["admin"],"lineTypeList":"同意,拒绝"},"text":{"x":320,"y":80,"value":"审批节点"}}],"edges":[{"id":"line-8c746156fb48","type":"polyline","sourceNodeId":"start-c31f75a55c48","targetNodeId":"userTask-fa96d9f1f548","startPoint":{"x":150,"y":80},"endPoint":{"x":270,"y":80},"properties":{"from":"start-c31f75a55c48","to":"userTask-fa96d9f1f548","label":"同意-连线文本3","type":"同意","id":"line-8c746156fb48","Remark":"","endpoint":"Dot"},"text":{"x":210,"y":80,"value":"同意-连线文本3"},"pointsList":[{"x":150,"y":80},{"x":270,"y":80}]},{"id":"line-088a246e9248","type":"polyline","sourceNodeId":"userTask-fa96d9f1f548","targetNodeId":"end-72e945407d48","startPoint":{"x":370,"y":80},"endPoint":{"x":490,"y":80},"properties":{"from":"userTask-fa96d9f1f548","to":"end-72e945407d48","label":"同意-连线文本","type":"同意","id":"line-088a246e9248","Remark":"","endpoint":"Dot"},"text":{"x":430,"y":80,"value":"同意-连线文本"},"pointsList":[{"x":370,"y":80},{"x":490,"y":80}]}]});
|
||||
this.logicFlow.render(this.parseBusinessDataTologicFlowData(this.data));
|
||||
this.logicFlow.render(this.parseBusinessDataTologicFlowData(this.workflowConfig));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -387,9 +655,6 @@ Vue.component("process-flow", {
|
||||
id,
|
||||
label: funObj.name,
|
||||
type: funObj.type,
|
||||
assignType: 'person',
|
||||
assignValue: ['<$ ctx.userInfo.userId $>'],
|
||||
lineTypeList: funObj.type === 'start' ? '同意' : funObj.type === 'end' ? '' : '同意,拒绝',
|
||||
}
|
||||
}
|
||||
this.logicFlow.dnd.startDrag(node);
|
||||
@@ -400,7 +665,7 @@ Vue.component("process-flow", {
|
||||
* @param node
|
||||
*/
|
||||
addNode(node) {
|
||||
this.data.nodeList.push(node);
|
||||
this.workflowConfig.nodeList.push(node);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -414,7 +679,7 @@ Vue.component("process-flow", {
|
||||
this.editType = 'node';
|
||||
// this.currentNodeId = node.id;
|
||||
this.$nextTick(function () {
|
||||
this.$refs.nodeForm.init(node);
|
||||
this.$refs.nodeForm.doUiAction('init', node);
|
||||
})
|
||||
},
|
||||
|
||||
@@ -427,11 +692,10 @@ Vue.component("process-flow", {
|
||||
return
|
||||
}
|
||||
let fromNodeData = this.logicFlow.getNodeDataById(line.sourceNodeId).properties;
|
||||
const lineTypeList = fromNodeData.lineTypeList ? fromNodeData.lineTypeList.split(',') : [];
|
||||
this.editType = 'line';
|
||||
// this.currentLineId = line.id;
|
||||
this.$nextTick(function () {
|
||||
this.$refs.lineForm.init(line, lineTypeList);
|
||||
this.$refs.lineForm.init(line);
|
||||
})
|
||||
},
|
||||
|
||||
@@ -443,20 +707,29 @@ Vue.component("process-flow", {
|
||||
return this.parseLogicFlowDataToBusinessData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置流程图业务数据(组件外使用)
|
||||
*/
|
||||
setBusinessData(){
|
||||
this.workflowConfig = this.parseLogicFlowDataToBusinessData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 将流程设计器数据转换为业务数据
|
||||
*/
|
||||
parseLogicFlowDataToBusinessData() {
|
||||
const logicFlowData = this.getOrderedGraphData();
|
||||
return {
|
||||
nodeList: logicFlowData.nodes.map(node => ({
|
||||
...node.properties,
|
||||
origin: node
|
||||
})),
|
||||
lineList: logicFlowData.edges.map(line => ({
|
||||
...line.properties,
|
||||
origin: line
|
||||
}))
|
||||
nodeList: logicFlowData.nodes.map(node => node),
|
||||
lineList: logicFlowData.edges.map(line => line)
|
||||
// nodeList: logicFlowData.nodes.map(node => ({
|
||||
// ...node.properties,
|
||||
// origin: node
|
||||
// })),
|
||||
// lineList: logicFlowData.edges.map(line => ({
|
||||
// ...line.properties,
|
||||
// origin: line
|
||||
// }))
|
||||
}
|
||||
},
|
||||
|
||||
@@ -490,8 +763,8 @@ Vue.component("process-flow", {
|
||||
*/
|
||||
parseBusinessDataTologicFlowData() {
|
||||
return {
|
||||
nodes: this.data.nodeList.map(node => node.origin).filter(node => node != null),
|
||||
edges: this.data.lineList.map(line => line.origin).filter(line => line != null)
|
||||
nodes: this.workflowConfig.nodeList.map(node => node).filter(node => node != null),
|
||||
edges: this.workflowConfig.lineList.map(line => line).filter(line => line != null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -503,9 +776,8 @@ Vue.component("process-flow", {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
/* height: calc(100vh - 260px); */
|
||||
height: 500px;
|
||||
color: #606266;
|
||||
margin-bottom: 20px;
|
||||
height: 700px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.lf-element-text {
|
||||
@@ -519,8 +791,8 @@ Vue.component("process-flow", {
|
||||
}
|
||||
|
||||
#flowContent {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
/* width: 100%; */
|
||||
height: 650px;
|
||||
position: relative;
|
||||
background-image: url("/<$ ctx.app.config.appId $>/public/images/point.png");
|
||||
background-repeat: repeat;
|
||||
@@ -528,13 +800,6 @@ Vue.component("process-flow", {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.item {
|
||||
position: absolute;
|
||||
width: 60px;
|
||||
height: 90px;
|
||||
border: 1px solid #007AFF;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
padding: 8px 10px;
|
||||
background: #f5f8fa;
|
||||
@@ -542,6 +807,7 @@ Vue.component("process-flow", {
|
||||
cursor: move;
|
||||
border: 1px dashed #f5f8fa;
|
||||
border-radius: 3px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.menu-item:hover {
|
||||
@@ -563,5 +829,60 @@ Vue.component("process-flow", {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
.divider-vertical{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.divider-vertical::before{
|
||||
content: '';
|
||||
display: block;
|
||||
width: 2px;
|
||||
height: 60px;
|
||||
background: #dbdbdb;
|
||||
}
|
||||
.arrow{
|
||||
width: 0px;
|
||||
height: 6px;
|
||||
border: 6px solid;
|
||||
border-color: #dbdbdb transparent transparent transparent;
|
||||
justify-self: center;
|
||||
}
|
||||
.add-btn-box{
|
||||
position: absolute;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-color: #A0B5C8;
|
||||
border-radius: 50%;
|
||||
align-self: center;
|
||||
margin-bottom: 10px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
.add-btn-box::before{
|
||||
content: '';
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 2px;
|
||||
height: 15px;
|
||||
left: 10px;
|
||||
top: 4px;
|
||||
background-color: #fff;
|
||||
}
|
||||
.add-btn-box::after{
|
||||
content: '';
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
height: 2px;
|
||||
width: 14px;
|
||||
top: 10px;
|
||||
left: 4px;
|
||||
background-color: #fff;
|
||||
}
|
||||
.add-node-box{
|
||||
width: 60px;
|
||||
height: 40px;
|
||||
}
|
||||
/* .v-list-item:hover{
|
||||
background-color: red;
|
||||
|
||||
} */
|
||||
</style>
|
||||
Reference in new issue
Block a user