明树Git Lab

Commit 662dde01 authored by zhanghan's avatar zhanghan

流程处理完成

parent 355db9e2
Pipeline #111296 passed with stage
in 19 seconds
...@@ -21,18 +21,24 @@ ...@@ -21,18 +21,24 @@
<div v-if="index < activeNodes.length - 1" class="flow-arrow"> <div v-if="index < activeNodes.length - 1" class="flow-arrow">
<div class="arrow-line"></div> <div class="arrow-line"></div>
<div class="arrow-head"></div> <div class="arrow-head"></div>
<div v-if="hasBidirectional(index)" class="bi-arrow">
<div class="arrow-head" style="transform: rotate(180deg)"></div>
<div class="arrow-line"></div>
<div class="arrow-head"></div>
<span class="bi-text">提交/退回</span>
</div>
</div> </div>
</div> </div>
</div> </div>
<svg <svg
v-if="returnPaths.length" v-if="svgPaths.length"
class="return-svg" class="return-svg"
:width="svgWidth" :width="svgWidth"
:height="svgHeight" :height="svgHeight"
> >
<defs> <defs>
<marker <marker
id="arrowMarker" id="arrowEnd"
markerWidth="8" markerWidth="8"
markerHeight="6" markerHeight="6"
refX="8" refX="8"
...@@ -42,14 +48,13 @@ ...@@ -42,14 +48,13 @@
<path d="M0,0 L8,3 L0,6 Z" fill="#909399" /> <path d="M0,0 L8,3 L0,6 Z" fill="#909399" />
</marker> </marker>
</defs> </defs>
<g v-for="(path, i) in returnPaths" :key="i"> <g v-for="(path, i) in svgPaths" :key="i">
<polyline <polyline
:points="path.points" :points="path.points"
fill="none" fill="none"
stroke="#909399" stroke="#909399"
stroke-width="1.5" stroke-width="1.5"
stroke-dasharray="4,3" marker-end="url(#arrowEnd)"
marker-end="url(#arrowMarker)"
/> />
<text <text
:x="path.textX" :x="path.textX"
...@@ -58,9 +63,9 @@ ...@@ -58,9 +63,9 @@
fill="#909399" fill="#909399"
text-anchor="middle" text-anchor="middle"
dominant-baseline="middle" dominant-baseline="middle"
:transform="`rotate(-90, ${path.textX}, ${path.textY})`" :transform="path.textRotate"
> >
退回修改 {{ path.label }}
</text> </text>
</g> </g>
</svg> </svg>
...@@ -85,13 +90,14 @@ const props = defineProps({ ...@@ -85,13 +90,14 @@ const props = defineProps({
const complexNodes = [ const complexNodes = [
{ label: "开始", type: "terminal" }, { label: "开始", type: "terminal" },
{ label: "所属单位员工发起" }, { label: "所属单位员工发起" },
{ label: "所属单位部门长核准", annotation: "提交/退回" }, { label: "所属单位部门长核准" },
{ label: "投管部正/副职指定经办人" }, { label: "投管部经办人初审", returnTo: 1 },
{ label: "投管部经办人初审" }, { label: "投管部正副职审核" },
{ label: "投管部正副职审核", returnTo: 2 },
{ label: "结束", type: "terminal" }, { label: "结束", type: "terminal" },
]; ];
const complexBiIndices = new Set([1, 3]);
const simpleNodes = [ const simpleNodes = [
{ label: "开始", type: "terminal" }, { label: "开始", type: "terminal" },
{ label: "投管部员工发起" }, { label: "投管部员工发起" },
...@@ -99,18 +105,20 @@ const simpleNodes = [ ...@@ -99,18 +105,20 @@ const simpleNodes = [
{ label: "结束", type: "terminal" }, { label: "结束", type: "terminal" },
]; ];
const simpleBiIndices = new Set();
const complexLevelMap = { const complexLevelMap = {
1: 2, 1: 2,
2: 2,
7: 2, 7: 2,
2: 3,
3: 4, 3: 4,
4: 6, 4: 5,
8: 6, 8: 5,
5: 7, 5: 6,
9: 7, 9: 6,
13: 7, 13: 6,
14: 7, 14: 6,
15: 7, 15: 6,
}; };
const simpleLevelMap = { const simpleLevelMap = {
...@@ -125,6 +133,12 @@ const activeNodes = computed(() => { ...@@ -125,6 +133,12 @@ const activeNodes = computed(() => {
return props.flowType === "simple" ? simpleNodes : complexNodes; return props.flowType === "simple" ? simpleNodes : complexNodes;
}); });
const hasBidirectional = (index) => {
const biSet =
props.flowType === "simple" ? simpleBiIndices : complexBiIndices;
return biSet.has(index);
};
const highlightLevel = computed(() => { const highlightLevel = computed(() => {
const map = props.flowType === "simple" ? simpleLevelMap : complexLevelMap; const map = props.flowType === "simple" ? simpleLevelMap : complexLevelMap;
return map[props.currentState] || 0; return map[props.currentState] || 0;
...@@ -148,9 +162,9 @@ const bodyRef = ref(null); ...@@ -148,9 +162,9 @@ const bodyRef = ref(null);
const nodeEls = ref([]); const nodeEls = ref([]);
const svgWidth = ref(0); const svgWidth = ref(0);
const svgHeight = ref(0); const svgHeight = ref(0);
const returnPaths = ref([]); const svgPaths = ref([]);
const calcReturnPaths = () => { const calcSvgPaths = () => {
const body = bodyRef.value; const body = bodyRef.value;
if (!body) return; if (!body) return;
const bodyRect = body.getBoundingClientRect(); const bodyRect = body.getBoundingClientRect();
...@@ -159,8 +173,8 @@ const calcReturnPaths = () => { ...@@ -159,8 +173,8 @@ const calcReturnPaths = () => {
const paths = []; const paths = [];
const nodes = activeNodes.value; const nodes = activeNodes.value;
let offsetX = 0;
let leftOffset = 0;
nodes.forEach((node, index) => { nodes.forEach((node, index) => {
if (node.returnTo === undefined) return; if (node.returnTo === undefined) return;
const sourceEl = nodeEls.value[index]; const sourceEl = nodeEls.value[index];
...@@ -178,27 +192,29 @@ const calcReturnPaths = () => { ...@@ -178,27 +192,29 @@ const calcReturnPaths = () => {
const targetY = targetRect.top + targetRect.height / 2 - bodyRect.top; const targetY = targetRect.top + targetRect.height / 2 - bodyRect.top;
const nodeLeft = sourceRect.left - bodyRect.left; const nodeLeft = sourceRect.left - bodyRect.left;
offsetX += 20; leftOffset += 20;
const lineX = nodeLeft - offsetX; const lineX = nodeLeft - leftOffset;
paths.push({ paths.push({
points: `${nodeLeft},${sourceY} ${lineX},${sourceY} ${lineX},${targetY} ${nodeLeft},${targetY}`, points: `${nodeLeft},${sourceY} ${lineX},${sourceY} ${lineX},${targetY} ${nodeLeft},${targetY}`,
textX: lineX - 8, textX: lineX - 8,
textY: (sourceY + targetY) / 2, textY: (sourceY + targetY) / 2,
textRotate: `rotate(-90, ${lineX - 8}, ${(sourceY + targetY) / 2})`,
label: "返回修改",
}); });
}); });
returnPaths.value = paths; svgPaths.value = paths;
}; };
onMounted(() => { onMounted(() => {
nextTick(calcReturnPaths); nextTick(calcSvgPaths);
}); });
watch( watch(
() => [props.flowType, props.currentState], () => [props.flowType, props.currentState],
() => { () => {
nextTick(() => nextTick(calcReturnPaths)); nextTick(() => nextTick(calcSvgPaths));
}, },
); );
</script> </script>
...@@ -312,6 +328,7 @@ watch( ...@@ -312,6 +328,7 @@ watch(
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
height: 28px; height: 28px;
position: relative;
.arrow-line { .arrow-line {
width: 2px; width: 2px;
...@@ -327,4 +344,24 @@ watch( ...@@ -327,4 +344,24 @@ watch(
border-top: 6px solid #c0c4cc; border-top: 6px solid #c0c4cc;
} }
} }
.bi-arrow {
position: absolute;
left: calc(50% + -4px);
top: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
.bi-text {
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
font-size: 9px;
color: #909399;
white-space: nowrap;
}
}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment