imm-element-ui 2.1.4 → 2.1.5

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.
@@ -6449,81 +6449,144 @@ class GridComponent {
6449
6449
  console.log('event---', event);
6450
6450
  this.dragBeforeIndex = event.overIndex;
6451
6451
  }
6452
+ // onRowDragEnd(event: RowDragEndEvent) {
6453
+ // // console.log('event----', event.node,event.overNode)
6454
+ // // console.log('原始索引----', this.dragBeforeIndex)
6455
+ // // console.log('拖拽之后索引----',event.overIndex)
6456
+ // if (!this.gridOptions().dragSort) return;
6457
+ // if (this.dragBeforeIndex == event.overIndex) return;
6458
+ // let col = event.api.getColumnDefs();
6459
+ // let colItem: any = col?.find((v: any) => v.field === this.gridOptions().dragSort!) || {};
6460
+ // // console.log("rowData---",this.rowData())
6461
+ // let map = new Map();
6462
+ // let logMap = new Map();
6463
+ // this.grid?.api.forEachNode((node, index) => {
6464
+ // let id = node.data.id;
6465
+ // let isMovingDown = event.overIndex > this.dragBeforeIndex;
6466
+ // if (
6467
+ // (isMovingDown && index >= this.dragBeforeIndex && index <= event.overIndex) ||
6468
+ // (!isMovingDown && index <= this.dragBeforeIndex && index >= event.overIndex)
6469
+ // ) {
6470
+ // // console.log('node----',node.data,event.overIndex)
6471
+ // let oldValue;
6472
+ // if (index == event.overIndex) {
6473
+ // oldValue = this.dragBeforeIndex;
6474
+ // } else {
6475
+ // oldValue = isMovingDown ? index + 1 : index - 1;
6476
+ // }
6477
+ // // console.log('oldIndex----',oldValue)
6478
+ // if (!id) {
6479
+ // this.upsert()?.subsert[this.subIndex]['maptmp'].set(
6480
+ // index!,
6481
+ // Object.assign(node.data, {
6482
+ // [this.gridOptions().dragSort!]: index + 1,
6483
+ // }),
6484
+ // );
6485
+ // } else {
6486
+ // let o: any;
6487
+ // if (this.upsert()?.subsert[this.subIndex]['maptmp'].has(oldValue!)) {
6488
+ // o = this.upsert()?.subsert[this.subIndex]['maptmp'].get(oldValue!);
6489
+ // Object.assign(o, { [this.gridOptions().dragSort!]: index + 1 });
6490
+ // this.upsert()?.subsert[this.subIndex]['maptmp'].delete(oldValue!);
6491
+ // // console.log('o----', JSON.parse(JSON.stringify(o)));
6492
+ // } else {
6493
+ // o = { id: id, [this.gridOptions().dragSort!]: index + 1 };
6494
+ // }
6495
+ // map.set(index!, o);
6496
+ // }
6497
+ // let old = this.upsert()?.subsert[this.subIndex]['logtmp'].get(oldValue! + this.gridOptions().dragSort!);
6498
+ // if (old) {
6499
+ // logMap.set(index! + this.gridOptions().dragSort!, {
6500
+ // newValue: index + 1,
6501
+ // oldValue: old.oldValue,
6502
+ // id: id,
6503
+ // label: colItem['headerName'] || '排序',
6504
+ // });
6505
+ // this.upsert()?.subsert[this.subIndex]['logtmp'].delete(oldValue! + this.gridOptions().dragSort!);
6506
+ // } else {
6507
+ // logMap.set(index! + this.gridOptions().dragSort!!, {
6508
+ // newValue: index + 1,
6509
+ // oldValue: oldValue + 1,
6510
+ // id: id,
6511
+ // label: colItem['headerName'] || '排序',
6512
+ // });
6513
+ // }
6514
+ // }
6515
+ // });
6516
+ // let dt: any = [];
6517
+ // if (this.upsert()) {
6518
+ // this.upsert()!.subsert[this.subIndex]['maptmp'] = new Map([...this.upsert()!.subsert[this.subIndex]['maptmp'!], ...map]);
6519
+ // this.upsert()!.subsert[this.subIndex]['logtmp'] = new Map([...this.upsert()!.subsert[this.subIndex]['logtmp'], ...logMap]);
6520
+ // this.upsert()?.subsert[this.subIndex]['maptmp'].forEach((value: any, key: any) => {
6521
+ // dt.push(value);
6522
+ // });
6523
+ // this.upsert()['subsert'][this.subIndex]['subData'] = dt;
6524
+ // }
6525
+ // // console.log('dragUpsert----', this.upsert());
6526
+ // }
6452
6527
  onRowDragEnd(event) {
6453
- // console.log('event----', event.node,event.overNode)
6454
- // console.log('原始索引----', this.dragBeforeIndex)
6455
- // console.log('拖拽之后索引----',event.overIndex)
6456
6528
  if (!this.gridOptions().dragSort)
6457
6529
  return;
6458
- if (this.dragBeforeIndex == event.overIndex)
6459
- return;
6460
- let col = event.api.getColumnDefs();
6461
- let colItem = col?.find((v) => v.field === this.gridOptions().dragSort) || {};
6462
- // console.log("rowData---",this.rowData())
6530
+ const sortField = this.gridOptions().dragSort;
6531
+ const colDefs = event.api.getColumnDefs();
6532
+ const colItem = colDefs?.find((v) => v.field === sortField) || {};
6463
6533
  let map = new Map();
6464
6534
  let logMap = new Map();
6535
+ let dt = [];
6536
+ const upsert = this.upsert();
6537
+ if (!upsert)
6538
+ return;
6539
+ const mapTmp = upsert.subsert[this.subIndex]['maptmp'];
6540
+ const logTmp = upsert.subsert[this.subIndex]['logtmp'];
6465
6541
  this.grid?.api.forEachNode((node, index) => {
6466
- let id = node.data.id;
6467
- let isMovingDown = event.overIndex > this.dragBeforeIndex;
6468
- if ((isMovingDown && index >= this.dragBeforeIndex && index <= event.overIndex) ||
6469
- (!isMovingDown && index <= this.dragBeforeIndex && index >= event.overIndex)) {
6470
- // console.log('node----',node.data,event.overIndex)
6471
- let oldValue;
6472
- if (index == event.overIndex) {
6473
- oldValue = this.dragBeforeIndex;
6474
- }
6475
- else {
6476
- oldValue = isMovingDown ? index + 1 : index - 1;
6477
- }
6478
- // console.log('oldIndex----',oldValue)
6479
- if (!id) {
6480
- this.upsert()?.subsert[this.subIndex]['maptmp'].set(index, Object.assign(node.data, {
6481
- [this.gridOptions().dragSort]: index + 1,
6482
- }));
6483
- }
6484
- else {
6485
- let o;
6486
- if (this.upsert()?.subsert[this.subIndex]['maptmp'].has(oldValue)) {
6487
- o = this.upsert()?.subsert[this.subIndex]['maptmp'].get(oldValue);
6488
- Object.assign(o, { [this.gridOptions().dragSort]: index + 1 });
6489
- this.upsert()?.subsert[this.subIndex]['maptmp'].delete(oldValue);
6490
- // console.log('o----', JSON.parse(JSON.stringify(o)));
6491
- }
6492
- else {
6493
- o = { id: id, [this.gridOptions().dragSort]: index + 1 };
6494
- }
6495
- map.set(index, o);
6496
- }
6497
- let old = this.upsert()?.subsert[this.subIndex]['logtmp'].get(oldValue + this.gridOptions().dragSort);
6498
- if (old) {
6499
- logMap.set(index + this.gridOptions().dragSort, {
6500
- newValue: index + 1,
6501
- oldValue: old.oldValue,
6502
- id: id,
6503
- label: colItem['headerName'] || '排序',
6504
- });
6505
- this.upsert()?.subsert[this.subIndex]['logtmp'].delete(oldValue + this.gridOptions().dragSort);
6542
+ const id = node.data.id;
6543
+ const newSort = index + 1;
6544
+ const oldSort = node.data[sortField];
6545
+ // 更新 grid 数据
6546
+ node.data[sortField] = newSort;
6547
+ // ---------------------------
6548
+ // 处理 mapTmp(提交数据)
6549
+ // ---------------------------
6550
+ if (!id) {
6551
+ mapTmp.set(index, {
6552
+ ...node.data,
6553
+ [sortField]: newSort
6554
+ });
6555
+ }
6556
+ else {
6557
+ map.set(index, {
6558
+ id: id,
6559
+ [sortField]: newSort
6560
+ });
6561
+ }
6562
+ if (id) {
6563
+ const key = id + '_' + sortField;
6564
+ let oldLog = logTmp.get(key);
6565
+ if (oldLog) {
6566
+ oldLog.newValue = newSort;
6567
+ logMap.set(key, oldLog);
6506
6568
  }
6507
- else {
6508
- logMap.set(index + this.gridOptions().dragSort, {
6509
- newValue: index + 1,
6510
- oldValue: oldValue + 1,
6569
+ else if (oldSort !== newSort) {
6570
+ logMap.set(key, {
6511
6571
  id: id,
6512
6572
  label: colItem['headerName'] || '排序',
6573
+ oldValue: oldSort,
6574
+ newValue: newSort
6513
6575
  });
6514
6576
  }
6515
6577
  }
6516
6578
  });
6517
- let dt = [];
6518
- if (this.upsert()) {
6519
- this.upsert().subsert[this.subIndex]['maptmp'] = new Map([...this.upsert().subsert[this.subIndex]['maptmp'], ...map]);
6520
- this.upsert().subsert[this.subIndex]['logtmp'] = new Map([...this.upsert().subsert[this.subIndex]['logtmp'], ...logMap]);
6521
- this.upsert()?.subsert[this.subIndex]['maptmp'].forEach((value, key) => {
6579
+ if (upsert) {
6580
+ upsert.subsert[this.subIndex]['maptmp'] =
6581
+ new Map([...mapTmp, ...map]);
6582
+ upsert.subsert[this.subIndex]['logtmp'] =
6583
+ new Map([...logTmp, ...logMap]);
6584
+ upsert.subsert[this.subIndex]['maptmp'].forEach((value) => {
6522
6585
  dt.push(value);
6523
6586
  });
6524
- this.upsert()['subsert'][this.subIndex]['subData'] = dt;
6587
+ upsert.subsert[this.subIndex]['subData'] = dt;
6588
+ console.log('dragUpsert----', upsert);
6525
6589
  }
6526
- // console.log('dragUpsert----', this.upsert());
6527
6590
  }
6528
6591
  // 时间范围添加时分秒
6529
6592
  isRange(columnFilter) {