@lambo-design/workflow-approve 1.0.0-beta.77 → 1.0.0-beta.79

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.77",
3
+ "version": "1.0.0-beta.79",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -13,7 +13,7 @@
13
13
  "axios": "^0.24.0",
14
14
  "axios-cache-plugin": "^0.1.0",
15
15
  "@lambo-design/core": "^4.7.1-beta.167",
16
- "@lambo-design/shared": "^1.0.0-beta.279"
16
+ "@lambo-design/shared": "^1.0.0-beta.280"
17
17
  },
18
18
  "dependencies": {
19
19
  "bpmn-js": "^7.3.1",
@@ -404,54 +404,110 @@ export default {
404
404
  if (this.sortBy === 'time') {
405
405
  // 按时间排序:将所有审批记录平铺,按时间排序,然后重新分组
406
406
  let allRecords = [];
407
- let pendingGroups = []; // 待审批的分组
408
407
 
409
408
  // 平铺所有审批记录
410
409
  this.itemList.forEach(nodeGroup => {
411
410
  // 确保 nodeGroup 是数组
412
411
  if (Array.isArray(nodeGroup)) {
413
- // 检查这个节点组是否包含待审批的记录
414
- let hasPendingRecords = nodeGroup.some(record => this.isPendingAudit(record));
415
-
416
- if (hasPendingRecords) {
417
- // 如果包含待审批记录,整个节点组作为一个待审批组
418
- if (nodeGroup.length > 0) {
419
- // 使用第一个记录的时间作为排序时间,或使用当前时间
420
- let sortTime = this.getRecordTime(nodeGroup[0]) || new Date().toISOString();
421
- pendingGroups.push({
422
- records: nodeGroup,
412
+ nodeGroup.forEach(record => {
413
+ if (record && typeof record === 'object') {
414
+ // 获取准确的时间用于排序
415
+ let sortTime = this.getRecordTime(record);
416
+ let timestamp = new Date(sortTime).getTime();
417
+
418
+ // 验证时间戳是否有效
419
+ if (isNaN(timestamp)) {
420
+ console.warn('时间戳解析失败:', {
421
+ record: record,
422
+ sortTime: sortTime,
423
+ auditDate: record.auditDate,
424
+ createTime: record.createTime
425
+ });
426
+ // 使用当前时间作为后备
427
+ timestamp = new Date().getTime();
428
+ sortTime = new Date().toISOString();
429
+ }
430
+
431
+ allRecords.push({
432
+ record: record,
423
433
  sortTime: sortTime,
424
- isPending: true
434
+ timestamp: timestamp
425
435
  });
426
436
  }
427
- } else {
428
- // 如果是已审批记录,按个人分组
429
- nodeGroup.forEach(record => {
430
- if (record && typeof record === 'object') {
431
- record.sortTime = this.getRecordTime(record);
432
- allRecords.push({
433
- records: [record],
434
- sortTime: record.sortTime,
435
- isPending: false
436
- });
437
- }
438
- });
439
- }
437
+ });
440
438
  }
441
439
  });
442
440
 
443
- // 合并所有记录(已审批+待审批)
444
- let allGroups = [...allRecords, ...pendingGroups];
441
+ // 调试信息:打印排序前的数据
442
+ console.log('排序前的记录:', allRecords.map(item => ({
443
+ auditResult: item.record.auditResult,
444
+ auditDate: item.record.auditDate,
445
+ createTime: item.record.createTime,
446
+ sortTime: item.sortTime,
447
+ timestamp: item.timestamp,
448
+ date: new Date(item.timestamp)
449
+ })));
450
+
451
+ // 按时间戳排序(倒序,最新在前)
452
+ allRecords.sort((a, b) => {
453
+ // 使用时间戳进行排序,避免字符串比较问题
454
+ return b.timestamp - a.timestamp;
455
+ });
445
456
 
446
- // 按时间排序(倒序,最新在前)
447
- allGroups.sort((a, b) => {
448
- const timeA = new Date(a.sortTime).getTime();
449
- const timeB = new Date(b.sortTime).getTime();
450
- return timeB - timeA; // 倒序排列
457
+ // 调试信息:打印排序后的数据
458
+ console.log('排序后的记录:', allRecords.map(item => ({
459
+ auditResult: item.record.auditResult,
460
+ auditDate: item.record.auditDate,
461
+ createTime: item.record.createTime,
462
+ sortTime: item.sortTime,
463
+ timestamp: item.timestamp,
464
+ date: new Date(item.timestamp)
465
+ })));
466
+
467
+ // 重新分组:相同状态且时间相近的记录分为一组
468
+ let groupedRecords = [];
469
+ let currentGroup = [];
470
+
471
+ allRecords.forEach((item, index) => {
472
+ if (currentGroup.length === 0) {
473
+ // 第一个记录,直接加入
474
+ currentGroup.push(item.record);
475
+ } else {
476
+ // 检查是否应该与当前组合并
477
+ let shouldGroup = false;
478
+
479
+ // 如果都是待审批状态且是同一个节点,则分为一组
480
+ if (this.isPendingAudit(item.record) &&
481
+ currentGroup.some(r => this.isPendingAudit(r) && r.taskName === item.record.taskName)) {
482
+ shouldGroup = true;
483
+ }
484
+ // 如果都是已审批状态且时间非常接近(同一天或几分钟内),可以考虑分组,但通常按个人分组
485
+ else if (!this.isPendingAudit(item.record) &&
486
+ currentGroup.length === 1 &&
487
+ !this.isPendingAudit(currentGroup[0]) &&
488
+ currentGroup[0].taskName === item.record.taskName) {
489
+ // 暂时不分组已审批记录,每个人一组
490
+ shouldGroup = false;
491
+ }
492
+
493
+ if (shouldGroup) {
494
+ currentGroup.push(item.record);
495
+ } else {
496
+ // 开始新的分组
497
+ if (currentGroup.length > 0) {
498
+ groupedRecords.push([...currentGroup]);
499
+ }
500
+ currentGroup = [item.record];
501
+ }
502
+ }
451
503
  });
452
504
 
453
- // 返回记录数组
454
- return allGroups.map(group => group.records);
505
+ // 添加最后一组
506
+ if (currentGroup.length > 0) {
507
+ groupedRecords.push(currentGroup);
508
+ }
509
+
510
+ return groupedRecords;
455
511
  } else {
456
512
  // 按节点分组:保持原有的节点分组结构
457
513
  return this.itemList;
@@ -615,10 +671,55 @@ export default {
615
671
  },
616
672
  getRecordTime(item) {
617
673
  // 获取记录的时间用于排序
618
- if (item.auditResult) {
619
- return item.auditDate || item.createTime;
674
+ let timeStr = '';
675
+
676
+ if (item.auditResult && item.auditResult !== '') {
677
+ // 已审批记录:优先使用审批时间
678
+ timeStr = item.auditDate || item.createTime;
679
+ } else {
680
+ // 待审批记录:使用创建时间
681
+ timeStr = item.createTime || item.auditDate;
682
+ }
683
+
684
+ // 如果没有时间,使用当前时间
685
+ if (!timeStr) {
686
+ return new Date().toISOString();
687
+ }
688
+
689
+ // 标准化时间格式
690
+ try {
691
+ // 处理中国标准时间格式 "YYYY-MM-DD HH:mm:ss"
692
+ if (typeof timeStr === 'string') {
693
+ // 移除可能的多余空格
694
+ timeStr = timeStr.trim();
695
+
696
+ // 检查是否是标准格式 "YYYY-MM-DD HH:mm:ss"
697
+ if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(timeStr)) {
698
+ // 直接使用 new Date() 解析,这样会按本地时区处理
699
+ let date = new Date(timeStr);
700
+ if (!isNaN(date.getTime())) {
701
+ return date.toISOString();
702
+ }
703
+ }
704
+
705
+ // 如果包含 T 但没有时区信息,添加本地时区
706
+ if (timeStr.includes('T') && !timeStr.includes('Z') && !timeStr.includes('+')) {
707
+ timeStr += 'Z';
708
+ }
709
+ }
710
+
711
+ // 验证时间是否有效
712
+ let date = new Date(timeStr);
713
+ if (isNaN(date.getTime())) {
714
+ console.warn('Invalid date format:', timeStr);
715
+ return new Date().toISOString();
716
+ }
717
+
718
+ return date.toISOString();
719
+ } catch (error) {
720
+ console.warn('Error parsing date:', timeStr, error);
721
+ return new Date().toISOString();
620
722
  }
621
- return item.createTime || item.auditDate;
622
723
  },
623
724
  getTimelineDotColor(auditResult) {
624
725
  if (this.auditPassStatus.includes(auditResult)) {
package/src/portrait.vue CHANGED
@@ -309,7 +309,7 @@
309
309
  </FormItem>
310
310
  </Col>
311
311
  </Row>
312
- <FormItem label="处理方式:">
312
+ <FormItem v-if="item.remainDay != 0 || item.remainTime != 0 || item.inAdvanceDay != 0 || item.inAdvanceTime != 0" label="处理方式:">
313
313
  <Select v-model="item.processing" style="width:200px" placeholder="自动同意">
314
314
  <Option v-for="item in handleTypeList" :value="item.value" :key="item.value">
315
315
  {{ item.label }}