简易模式样式调整

This commit is contained in:
ChenXinXin committed 2024-04-22 17:05:10 +08:00
1 parent 85130fe8b5
commit f6460544f1
1 file changed
+102 -49
+102 -49
View File
@@ -3,12 +3,18 @@
<template v-if="displayMode == 'simple'"> <template v-if="displayMode == 'simple'">
<!-- 简单左侧 >>>>>>>>>>>>> --> <!-- 简单左侧 >>>>>>>>>>>>> -->
<div style="width: 100%;"> <div style="width: 100%;">
<v-card class="d-flex mb-1 overflow-y-auto" height="700" outlined> <v-card class="d-flex py-2 overflow-y-auto " height="700" outlined>
<div class="d-flex flex-column flex-fill align-center"> <div class="d-flex flex-column flex-fill align-center">
<template v-for="(nodeItem, nodeIndex) in workflowConfig.nodeList" :key="index"> <template v-for="(nodeItem, nodeIndex) in workflowConfig.nodeList" :key="index">
<v-card elevation="2" width="240" @click="editNode(nodeItem)"> <v-card elevation="2" width="240" @click="editNode(nodeItem)">
<v-card-text class="pa-4"> <!-- :style="`backgroundColor: ${constantObj.nodeColorClass[nodeItem.properties.type]}`;" -->
<span>{{nodeItem.properties.label}}</span> <v-card-title class="pa-2 " :class="constantObj.nodeColorClass[nodeItem.properties.type]">
<div class="text-truncate" style="width: 80%; font-size: medium;">{{nodeItem.properties.label}}</div>
<v-spacer></v-spacer>
<v-icon color="grey" v-if="!['start','end'].includes(nodeItem.properties.type)" @click.stop="doUiAction('deleteNodeBySimple', nodeItem)">mdi-close</v-icon>
</v-card-title>
<v-card-text class="pa-4" v-if="!['start','end'].includes(nodeItem.properties.type) ">
<span>{{ nodeItem.properties.approverType || nodeItem.properties.noticerType }}</span>
</v-card-text> </v-card-text>
</v-card> </v-card>
<template v-if="!nodeItem.id.startsWith('end-')"> <template v-if="!nodeItem.id.startsWith('end-')">
@@ -175,14 +181,13 @@ Vue.component("process-flow", {
value: 'complex' value: 'complex'
}, },
], ],
nodeColor: { nodeColorClass: {
'start':'#88939F', 'start':'start-background',
'userTask':'#FCAD22', 'approvalTask':'approvalTask-background',
'approvalTask':'#FCAD22', 'noticeTask':'noticeTask-background',
'noticeTask':'#3CB4B2', 'conditionTask':'conditionTask-background',
'conditionTask':'#88939F', 'end':'end-background',
'approvalTask':'#88939F', },
}
}, },
menuList: [ menuList: [
{name: '起点', type: 'start', icon: 'mdi-ray-start'}, {name: '起点', type: 'start', icon: 'mdi-ray-start'},
@@ -232,6 +237,7 @@ Vue.component("process-flow", {
isMobile() { isMobile() {
return window.innerWidth < 600; return window.innerWidth < 600;
}, },
}, },
created(){ created(){
}, },
@@ -252,6 +258,9 @@ Vue.component("process-flow", {
case 'changeDisplayMode': case 'changeDisplayMode':
await this.changeDisplayMode(uiActionData); await this.changeDisplayMode(uiActionData);
break; break;
case 'deleteNodeBySimple':
await this.deleteNodeBySimple(uiActionData);
break;
default: default:
console.error("[doUiAction] uiActionId not find", {uiActionId}); console.error("[doUiAction] uiActionId not find", {uiActionId});
break; break;
@@ -264,6 +273,7 @@ Vue.component("process-flow", {
menuShown(index){ menuShown(index){
return event?.target.dataset.itemIndex == this.activeMenuIndex || false return event?.target.dataset.itemIndex == this.activeMenuIndex || false
}, },
async addNodeBySimple({type, prevIndex = -1}){ async addNodeBySimple({type, prevIndex = -1}){
if(prevIndex == -1) throw new Error("[addNodeBySimple] 出错!"); if(prevIndex == -1) throw new Error("[addNodeBySimple] 出错!");
// 加一个节点和两条线 // 加一个节点和两条线
@@ -272,8 +282,8 @@ Vue.component("process-flow", {
var prevNode = _this.workflowConfig.nodeList[prevIndex] var prevNode = _this.workflowConfig.nodeList[prevIndex]
var nextNode = _this.workflowConfig.nodeList[prevIndex + 1] var nextNode = _this.workflowConfig.nodeList[prevIndex + 1]
var node = await initNodebySimple(type, prevNode) var node = await initNodebySimple(type, prevNode)
var prevLine = initLinebySimple(prevNode, node) var prevLine = this.initLinebySimple(prevNode, node)
var nextLine = initLinebySimple(node, nextNode) var nextLine = this.initLinebySimple(node, nextNode)
_this.workflowConfig.nodeList.splice(prevIndex + 1, 0 ,node) _this.workflowConfig.nodeList.splice(prevIndex + 1, 0 ,node)
_this.workflowConfig.lineList.push(prevLine, nextLine) _this.workflowConfig.lineList.push(prevLine, nextLine)
@@ -299,7 +309,7 @@ Vue.component("process-flow", {
"type": type "type": type
}, },
"text": { "text": {
"x": prevNode.x - 130, "x": prevNode.x - 150,
"y": prevNode.y + 40, "y": prevNode.y + 40,
"value": type == 'approvalTask' ? '审批节点' : '抄送节点', "value": type == 'approvalTask' ? '审批节点' : '抄送节点',
} }
@@ -307,9 +317,11 @@ Vue.component("process-flow", {
return node return node
} }
function initLinebySimple(prevNode, nextNode){ },
initLinebySimple(prevNode, nextNode){
if(!prevNode || !nextNode) throw new Error("[initNodebySimple] 无前置或后置节点!"); if(!prevNode || !nextNode) throw new Error("[initNodebySimple] 无前置或后置节点!");
var Id = _this.getUUID(type) var Id = this.getUUID('line')
var line = { var line = {
"id": Id, "id": Id,
"type": "polyline", "type": "polyline",
@@ -338,9 +350,36 @@ Vue.component("process-flow", {
} }
} }
return line return line
}
}, },
async deleteNodeBySimple(node){
if(!node) throw new Error("[deleteNodeBySimple] node不存在!");
var _this = this
var nodeId = node.id
var preLine = _this.workflowConfig.lineList.find(line => line.targetNodeId == nodeId)
var nextLine = _this.workflowConfig.lineList.find(line => line.sourceNodeId == nodeId)
var preNode = _this.workflowConfig.nodeList.find(node => node.id == preLine.sourceNodeId)
var nextNode = _this.workflowConfig.nodeList.find(node => node.id == nextLine.targetNodeId)
// 创建节点连线
var newLine = _this.initLinebySimple(preNode, nextNode)
// 删除与该节点相连的线
_this.workflowConfig.lineList = _this.workflowConfig.lineList.filter(line => line.sourceNodeId != nodeId && line.targetNodeId != nodeId)
// 删除该节点
_this.workflowConfig.nodeList = _this.workflowConfig.nodeList.filter(node => node.id != nodeId)
// 插入新连线
_this.workflowConfig.lineList.push(newLine)
await this.$emit('reflesh-workflow-config', _this.workflowConfig)
// 两种模式统一数据,待优化
// this.initLogicFlowData()
},
// 切换展示模式 // 切换展示模式
changeDisplayMode(displayMode){ changeDisplayMode(displayMode){
var changeAble = true var changeAble = true
@@ -499,25 +538,26 @@ Vue.component("process-flow", {
}) })
return return
} }
logicFlow.extension.menu.setMenuConfig({ // logicFlow.extension.menu.setMenuConfig({
nodeMenu: [ // nodeMenu: [
{ // {
text: '删除节点', // text: '删除节点',
callback(node) { // callback(node) {
logicFlow.deleteNode(node.id); // logicFlow.deleteNode(node.id);
} // this.setBusinessData()
} // }
], // }
edgeMenu: [ // ],
{ // edgeMenu: [
text: '删除连线', // {
callback(edge) { // text: '删除连线',
logicFlow.deleteEdge(edge.id); // callback(edge) {
this.getBusinessData() // logicFlow.deleteEdge(edge.id);
} // this.setBusinessData()
} // }
] // }
}); // ]
// });
}, },
/** /**
@@ -568,17 +608,19 @@ Vue.component("process-flow", {
} }
this.editLine(data); this.editLine(data);
}); });
// 双击节点 TODO:删除后更新数据 // 双击节点
logicFlow.on("node:dbclick", (e) => { logicFlow.on("node:dbclick", (e) => {
const {id} = e.data; const {id} = e.data;
logicFlow.deleteNode(id); logicFlow.deleteNode(id);
this.setBusinessData()
}); });
// 双击边 TODO:删除后更新数据 // 双击边
logicFlow.on("edge:dbclick", (e) => { logicFlow.on("edge:dbclick", (e) => {
const {id} = e.data; const {id} = e.data;
logicFlow.deleteEdge(id); logicFlow.deleteEdge(id);
this.setBusinessData()
}); });
// // 历史变化 // // 历史变化
// logicFlow.on("history:change", (e) => { // logicFlow.on("history:change", (e) => {
@@ -703,14 +745,6 @@ Vue.component("process-flow", {
return { return {
nodeList: logicFlowData.nodes.map(node => node), nodeList: logicFlowData.nodes.map(node => node),
lineList: logicFlowData.edges.map(line => line) lineList: logicFlowData.edges.map(line => line)
// nodeList: logicFlowData.nodes.map(node => ({
// ...node.properties,
// origin: node
// })),
// lineList: logicFlowData.edges.map(line => ({
// ...line.properties,
// origin: line
// }))
} }
}, },
@@ -862,8 +896,27 @@ Vue.component("process-flow", {
width: 60px; width: 60px;
height: 40px; height: 40px;
} }
/* .v-list-item:hover{ .start-background,
background-color: red; .end-background{
background-color: #EEF4FB;
color: #88939F;
}
.noticeTask-background{
background-color: #E6F8F8;
color: #3CB4B2;
} */ }
.approvalTask-background{
background-color: #FFF9EE;
color: #FCAD22;
}
.conditionTask-background{
background-color: #E0F2FD;
color:#3EA9F0;
}
.omit{
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
}
</style> </style>