@lambo-design/workflow-approve 1.0.0-beta.52 → 1.0.0-beta.53

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.
@@ -512,25 +512,15 @@ export default {
512
512
 
513
513
  Promise.all(requests)
514
514
  .then(results => {
515
- results.forEach(data => {
516
- if (data && data.organCode) {
517
- let obj = {
518
- type: data.organType,
519
- id: data.id,
520
- organId: data.organId,
521
- orders: data.orders,
522
- title: data.organName,
523
- name: data.organName,
524
- com: data.organId,
525
- code: data.organCode,
526
- loading: false,
527
- checked: false,
528
- children: [],
529
- hasChild: true,
530
- };
531
- childsTree.push(obj);
532
- }
533
- });
515
+ let tree
516
+ if (self.ucAdapterType === 'x1'){
517
+ tree = self.x1OrganTree(results)
518
+ } else {
519
+ tree = self.scOrganTree(results)
520
+ }
521
+ for (let value of tree) {
522
+ self.formatOrganTree(value, childsTree, organTreeType)
523
+ }
534
524
  organTree.push(childsTree);
535
525
  const codesSeen = new Map();
536
526
  organTree = organTree.reduce((acc, item, index) => {
@@ -550,6 +540,133 @@ export default {
550
540
  }
551
541
  });
552
542
  },
543
+ x1OrganTree(results){
544
+ const nodeMap = new Map();
545
+ results.forEach(item => {
546
+ const organCode = item.organCode
547
+ const organStruPath = item.organStruPath
548
+ const parts = organStruPath.split('#').filter(p => p);
549
+ let currentNode = nodeMap.get(organCode) || { organCode, organStruPath, item, children: []};
550
+ currentNode.parts = parts;
551
+ nodeMap.set(organCode, currentNode);
552
+ });
553
+ nodeMap.forEach(node => {
554
+ const { organCode, parts } = node;
555
+ let parentCode = null;
556
+ for (let i = 0; i < parts.length - 1; i++) {
557
+ parentCode = parts[i];
558
+ const parentNode = nodeMap.get(parentCode);
559
+
560
+ if (parentNode) {
561
+ if (parentNode.organId === node.item.parentId && !parentNode.children.some(child => child.organCode === organCode)) {
562
+ parentNode.children.push(node);
563
+ } else {
564
+ // 如果直接父节点不在流程类型范围内但祖宗节点在
565
+ let children = parentNode.children;
566
+ for (let j = i + 1; j < parts.length - 1; j++) {
567
+ const partCode = parts[j];
568
+ let existingChild = children.find(child => child.organCode === partCode);
569
+
570
+ if (!existingChild) {
571
+ existingChild = { organCode: partCode, children: [] };
572
+ children.push(existingChild);
573
+ }
574
+ children = existingChild.children;
575
+ }
576
+ // 将当前节点添加到最后一个子节点的 children 中
577
+ children.push(node);
578
+ }
579
+ nodeMap.delete(organCode);
580
+ break;
581
+ }
582
+ }
583
+
584
+ });
585
+ return nodeMap.values()
586
+ },
587
+ scOrganTree(results){
588
+ const nodeMap = new Map();
589
+ results.forEach(item => {
590
+ const organId = item.organId
591
+ const parentId = item.parentId
592
+ let currentNode = nodeMap.get(organId) || { organId, parentId, item, children: []};
593
+ nodeMap.set(organId, currentNode);
594
+ });
595
+ const tree = [];
596
+ nodeMap.forEach((node, organId) => {
597
+ const parentId = node.parentId;
598
+
599
+ // 如果有父节点,则将当前节点添加到父节点的 children 数组中
600
+ if (parentId && nodeMap.has(parentId)) {
601
+ const parentNode = nodeMap.get(parentId);
602
+ parentNode.children.push(node);
603
+ } else {
604
+ tree.push(node);
605
+ }
606
+ });
607
+ return tree
608
+ },
609
+ formatOrganTree(nodeMap, childsTree, organTreeType){
610
+ const self = this
611
+ let obj = {}
612
+ if (nodeMap.item){
613
+ obj = {
614
+ type: nodeMap.item.organType,
615
+ id: nodeMap.item.id,
616
+ organId: nodeMap.item.organId,
617
+ orders: nodeMap.item.orders,
618
+ title: nodeMap.item.organName,
619
+ name: nodeMap.item.organName,
620
+ com: nodeMap.item.organId,
621
+ code: nodeMap.item.organCode,
622
+ loading: false,
623
+ checked: false,
624
+ hasChild: true,
625
+ children: [],
626
+ };
627
+ if (nodeMap.children && nodeMap.children.length > 0){
628
+ for (let child of nodeMap.children){
629
+ self.formatOrganTree(child, obj.children, organTreeType)
630
+ }
631
+ }
632
+ childsTree.push(obj);
633
+ } else {
634
+ let params = {
635
+ orgTreeType: organTreeType,
636
+ }
637
+ ajax.get(self.smartFlowServerContext + '/manage/organ/get/' + nodeMap.organCode, { params: params })
638
+ .then(resp => {
639
+ if (resp.data.code === 200) {
640
+ let data = resp.data.data
641
+ obj = {
642
+ type: data.organType,
643
+ id: data.id,
644
+ organId: data.organId,
645
+ orders: data.orders,
646
+ title: data.organName,
647
+ name: data.organName,
648
+ com: data.organId,
649
+ code: data.organCode,
650
+ loading: false,
651
+ disabled: true,
652
+ checked: false,
653
+ hasChild: true,
654
+ children: [],
655
+ }
656
+ if (nodeMap.children && nodeMap.children.length > 0){
657
+ for (let child of nodeMap.children){
658
+ self.formatOrganTree(child, obj.children, organTreeType)
659
+ }
660
+ }
661
+ childsTree.push(obj);
662
+ }
663
+ })
664
+ .catch(err => {
665
+ console.error(err);
666
+ return [];
667
+ })
668
+ }
669
+ },
553
670
  //获取人员树信息
554
671
  async getReadingRange(row, organTreeType) {
555
672
  let self = this
@@ -1766,7 +1883,7 @@ export default {
1766
1883
  this.permScope = permScope
1767
1884
  this.organTreeType = organTreeType
1768
1885
  this.organTreeRedis(this.permScope)
1769
- if (inputValue){
1886
+ if (inputValue && inputValue.length > 0){
1770
1887
  this.getOrgan(inputValue)
1771
1888
  this.getUser(inputValue)
1772
1889
  this.getRole(inputValue)
@@ -663,7 +663,7 @@ export default {
663
663
  this.permScope = permScope
664
664
  this.organTreeType = organTreeType
665
665
  // this.organTreeRedis(this.permScope)
666
- if (inputValue) {
666
+ if (inputValue && inputValue.length > 0) {
667
667
  //加入已选择的数据
668
668
  this.getUser(inputValue)
669
669
  }