@lambo-design/workflow-approve 1.0.0-beta.141 → 1.0.0-beta.142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/workflow-approve",
3
- "version": "1.0.0-beta.141",
3
+ "version": "1.0.0-beta.142",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -71,6 +71,7 @@ export default {
71
71
  key: 'selected',
72
72
  width: 56,
73
73
  align: 'center',
74
+ renderHeader: h => h('span'),
74
75
  render: (h, params) => {
75
76
  if (params.row.type === 'group') {
76
77
  return h('div', {
@@ -248,14 +249,21 @@ export default {
248
249
  formatRejectPathLabel(pathIds, nodeNameMap) {
249
250
  return pathIds.map(id => nodeNameMap.get(id) || id).join(' > ')
250
251
  },
251
- formatGatewayPathLabel(gatewayPath) {
252
- if (!Array.isArray(gatewayPath) || gatewayPath.length === 0) {
253
- return ''
254
- }
255
- return gatewayPath
256
- .map(item => item.groupName || item.groupId)
257
- .filter(Boolean)
258
- .join(' > ')
252
+ formatGatewayPathLabel(gatewayPath) {
253
+ if (!Array.isArray(gatewayPath) || gatewayPath.length === 0) {
254
+ return ''
255
+ }
256
+ return gatewayPath
257
+ .map(item => item.groupName || item.groupId)
258
+ .filter(Boolean)
259
+ .join(' > ')
260
+ },
261
+ getRejectNodePrimaryGatewayPath(node) {
262
+ const pathEntries = Array.isArray(node?.pathEntries) && node.pathEntries.length > 0
263
+ ? node.pathEntries
264
+ : this.normalizeRejectNode(node, 0, new Map()).pathEntries
265
+ const primaryEntry = pathEntries.find(item => Array.isArray(item?.gatewayPath) && item.gatewayPath.length > 0)
266
+ return Array.isArray(primaryEntry?.gatewayPath) ? primaryEntry.gatewayPath : []
259
267
  },
260
268
  getRejectNodeGatewaySortKey(gatewayPath) {
261
269
  if (!Array.isArray(gatewayPath) || gatewayPath.length === 0) {
@@ -282,21 +290,8 @@ export default {
282
290
  if (leftPathOrder !== rightPathOrder) {
283
291
  return leftPathOrder - rightPathOrder
284
292
  }
285
- return String(left?.pathKey || '').localeCompare(String(right?.pathKey || ''))
286
- },
287
- getRejectNodeSortKey(node) {
288
- const pathEntries = Array.isArray(node?.pathEntries) ? node.pathEntries : []
289
- if (pathEntries.length === 0) {
290
- const taskName = String(node?.taskName || node?.name || node?.title || node?.taskNode || '')
291
- return `z|z|${taskName}`
292
- }
293
- const firstEntry = pathEntries[0]
294
- const depth = Array.isArray(firstEntry?.gatewayPath) ? firstEntry.gatewayPath.length : 0
295
- const gatewayKey = this.getRejectNodeGatewaySortKey(firstEntry?.gatewayPath)
296
- const pathOrder = typeof firstEntry?.pathOrder === 'number' ? firstEntry.pathOrder : Number.MAX_SAFE_INTEGER
297
- const taskName = String(node?.taskName || node?.name || node?.title || node?.taskNode || '')
298
- return `${String(depth).padStart(4, '0')}|${gatewayKey}|${String(pathOrder).padStart(4, '0')}|${taskName}`
299
- },
293
+ return String(left?.pathKey || '').localeCompare(String(right?.pathKey || ''))
294
+ },
300
295
  getRejectNodePathKeys(node) {
301
296
  if (Array.isArray(node?.pathKeys) && node.pathKeys.length > 0) {
302
297
  return node.pathKeys
@@ -537,14 +532,46 @@ export default {
537
532
 
538
533
  return visibleRows
539
534
  },
540
- sortRejectNodesForTable(nodes) {
541
- const list = Array.isArray(nodes) ? nodes.slice() : []
542
- return list.sort((left, right) => {
543
- const leftSortKey = this.getRejectNodeSortKey(this.normalizeRejectNode(left, 0, new Map()))
544
- const rightSortKey = this.getRejectNodeSortKey(this.normalizeRejectNode(right, 0, new Map()))
545
- return leftSortKey.localeCompare(rightSortKey)
546
- })
547
- },
535
+ sortRejectNodesForTable(nodes) {
536
+ const list = Array.isArray(nodes) ? nodes.slice() : []
537
+ const bucketMap = new Map()
538
+ const bucketOrder = []
539
+
540
+ list.forEach((node, index) => {
541
+ const normalizedNode = this.normalizeRejectNode(node, index, new Map())
542
+ const primaryGatewayPath = this.getRejectNodePrimaryGatewayPath(normalizedNode)
543
+ const gatewayKey = primaryGatewayPath.length > 0
544
+ ? this.getRejectNodeGatewaySortKey(primaryGatewayPath)
545
+ : '__reject_node_no_gateway__'
546
+ let bucket = bucketMap.get(gatewayKey)
547
+ if (!bucket) {
548
+ bucket = {
549
+ gatewayKey,
550
+ hasGateway: primaryGatewayPath.length > 0,
551
+ firstIndex: index,
552
+ nodes: []
553
+ }
554
+ bucketMap.set(gatewayKey, bucket)
555
+ bucketOrder.push(bucket)
556
+ }
557
+ bucket.nodes.push(node)
558
+ })
559
+
560
+ bucketOrder.sort((left, right) => {
561
+ if (left.hasGateway !== right.hasGateway) {
562
+ return left.hasGateway ? 1 : -1
563
+ }
564
+ return left.firstIndex - right.firstIndex
565
+ })
566
+
567
+ const sortedNodes = []
568
+ bucketOrder.forEach(bucket => {
569
+ bucket.nodes.forEach(node => {
570
+ sortedNodes.push(node)
571
+ })
572
+ })
573
+ return sortedNodes
574
+ },
548
575
  mergeRejectNodesByTaskNode(nodes) {
549
576
  const groupedMap = new Map()
550
577
  const sourceNodes = Array.isArray(nodes) ? nodes : []