fantasy-ngzorro 2.1.8 → 2.1.10

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.
@@ -2603,6 +2603,28 @@
2603
2603
  enumerable: true,
2604
2604
  configurable: true
2605
2605
  });
2606
+ Object.defineProperty(HdFormLinesComponent.prototype, "isTrulyEmptyAllowed", {
2607
+ /** allowEmpty 且操作列仅有删除时:允许 0 行,初始化与删至空都不自动补空行 */
2608
+ get: /**
2609
+ * allowEmpty 且操作列仅有删除时:允许 0 行,初始化与删至空都不自动补空行
2610
+ * @return {?}
2611
+ */
2612
+ function () {
2613
+ /** @type {?} */
2614
+ var buttons = (this.operateButtons || []).filter((/**
2615
+ * @param {?} btn
2616
+ * @return {?}
2617
+ */
2618
+ function (btn) {
2619
+ return ["add", "copy", "delete"].includes(btn);
2620
+ }));
2621
+ return (this.allowEmpty &&
2622
+ buttons.length === 1 &&
2623
+ buttons[0] === "delete");
2624
+ },
2625
+ enumerable: true,
2626
+ configurable: true
2627
+ });
2606
2628
  Object.defineProperty(HdFormLinesComponent.prototype, "lineNumberLeft", {
2607
2629
  /** 勾选列固定时,序号列的 left 偏移 */
2608
2630
  get: /**
@@ -3854,21 +3876,27 @@
3854
3876
  }
3855
3877
  /** @type {?} */
3856
3878
  var debounceMs = onSearchEventDebounceTime != null ? onSearchEventDebounceTime : 0;
3857
- this.debounceTimeout = debounceMs;
3858
- if (this.searchSubscription) {
3859
- this.searchSubscription.unsubscribe();
3879
+ // 未配置或为 0:同步触发,不走 debounceTime(避免异步)
3880
+ if (!debounceMs) {
3881
+ this.triggerEvent(fn, event, line);
3882
+ }
3883
+ else {
3884
+ this.debounceTimeout = debounceMs;
3885
+ if (this.searchSubscription) {
3886
+ this.searchSubscription.unsubscribe();
3887
+ }
3888
+ this.searchSubscription = this.searchSubject
3889
+ .pipe(operators.debounceTime(this.debounceTimeout))
3890
+ .subscribe((/**
3891
+ * @param {?} __0
3892
+ * @return {?}
3893
+ */
3894
+ function (_a) {
3895
+ var fn = _a.fn, event = _a.event, line = _a.line;
3896
+ return _this.triggerEvent(fn, event, line);
3897
+ }));
3898
+ this.searchSubject.next({ fn: fn, event: event, line: line });
3860
3899
  }
3861
- this.searchSubscription = this.searchSubject
3862
- .pipe(operators.debounceTime(this.debounceTimeout))
3863
- .subscribe((/**
3864
- * @param {?} __0
3865
- * @return {?}
3866
- */
3867
- function (_a) {
3868
- var fn = _a.fn, event = _a.event, line = _a.line;
3869
- return _this.triggerEvent(fn, event, line);
3870
- }));
3871
- this.searchSubject.next({ fn: fn, event: event, line: line });
3872
3900
  setTimeout((/**
3873
3901
  * @return {?}
3874
3902
  */
@@ -3899,6 +3927,13 @@
3899
3927
  var debounceMs = onOpenChangeEventDebounceTime != null
3900
3928
  ? onOpenChangeEventDebounceTime
3901
3929
  : 0;
3930
+ // 未配置或为 0:同步触发,不走 debounceTime(避免异步)
3931
+ if (!debounceMs) {
3932
+ if (open) {
3933
+ this.triggerEvent(fn, open, line);
3934
+ }
3935
+ return;
3936
+ }
3902
3937
  this.openChangeDebounceTimeout = debounceMs;
3903
3938
  if (this.openChangeSubscription) {
3904
3939
  this.openChangeSubscription.unsubscribe();
@@ -3990,16 +4025,29 @@
3990
4025
  var debounceMs = item.onChangeEventDebounceTime != null
3991
4026
  ? item.onChangeEventDebounceTime
3992
4027
  : 0;
3993
- formGroupTmp
3994
- .get(item.name)
3995
- .valueChanges.pipe(operators.debounceTime(debounceMs))
3996
- .subscribe((/**
3997
- * @param {?} value
3998
- * @return {?}
3999
- */
4000
- function (value) {
4001
- _this.triggerEvent(item.onChangeEvent, value, formGroupTmp);
4002
- }));
4028
+ /** @type {?} */
4029
+ var control = formGroupTmp.get(item.name);
4030
+ // 未配置或为 0:同步订阅,不走 debounceTime
4031
+ if (debounceMs > 0) {
4032
+ control.valueChanges
4033
+ .pipe(operators.debounceTime(debounceMs))
4034
+ .subscribe((/**
4035
+ * @param {?} value
4036
+ * @return {?}
4037
+ */
4038
+ function (value) {
4039
+ _this.triggerEvent(item.onChangeEvent, value, formGroupTmp);
4040
+ }));
4041
+ }
4042
+ else {
4043
+ control.valueChanges.subscribe((/**
4044
+ * @param {?} value
4045
+ * @return {?}
4046
+ */
4047
+ function (value) {
4048
+ _this.triggerEvent(item.onChangeEvent, value, formGroupTmp);
4049
+ }));
4050
+ }
4003
4051
  }
4004
4052
  }));
4005
4053
  ((/** @type {?} */ (tmpValidateHdFormLines.get("lines")))).insert(((/** @type {?} */ (tmpValidateHdFormLines.get("lines")))).controls.length, formGroupTmp);
@@ -4218,7 +4266,10 @@
4218
4266
  (!this.formLinesData ||
4219
4267
  (this.formLinesData && this.formLinesData.length === 0))) {
4220
4268
  this.tableLoading = false;
4221
- this.addFormLine(null, false);
4269
+ // allowEmpty 且仅删除按钮:不自动补空行
4270
+ if (!this.isTrulyEmptyAllowed) {
4271
+ this.addFormLine(null, false);
4272
+ }
4222
4273
  this.showForm = true;
4223
4274
  }
4224
4275
  else {
@@ -4375,10 +4426,10 @@
4375
4426
  var debounceMs = item.onChangeEventDebounceTime != null
4376
4427
  ? item.onChangeEventDebounceTime
4377
4428
  : 0;
4378
- formGroupSubmit
4379
- .get(item.name)
4380
- .valueChanges.pipe(operators.debounceTime(debounceMs))
4381
- .subscribe((/**
4429
+ /** @type {?} */
4430
+ var control = formGroupSubmit.get(item.name);
4431
+ /** @type {?} */
4432
+ var handleChange = (/**
4382
4433
  * @param {?} value
4383
4434
  * @return {?}
4384
4435
  */
@@ -4387,7 +4438,16 @@
4387
4438
  _this.delayJumpToNextInput();
4388
4439
  }
4389
4440
  _this.triggerEvent(item.onChangeEvent, value, formGroupSubmit);
4390
- }));
4441
+ });
4442
+ // 未配置或为 0:同步订阅,不走 debounceTime
4443
+ if (debounceMs > 0) {
4444
+ control.valueChanges
4445
+ .pipe(operators.debounceTime(debounceMs))
4446
+ .subscribe(handleChange);
4447
+ }
4448
+ else {
4449
+ control.valueChanges.subscribe(handleChange);
4450
+ }
4391
4451
  }
4392
4452
  }));
4393
4453
  return formGroupSubmit;
@@ -4457,6 +4517,9 @@
4457
4517
  var insertAt = this.getInsertIndexAfter(afterLine);
4458
4518
  this.linesFormArray.insert(insertAt, this.newLineItem());
4459
4519
  this.calculateLineNumber();
4520
+ // 跳到新增行所在页,避免页码异常时看不到数据
4521
+ this.paginationPageIndex =
4522
+ Math.floor(insertAt / this.paginationPageSize) + 1;
4460
4523
  setTimeout((/**
4461
4524
  * @return {?}
4462
4525
  */
@@ -4548,14 +4611,16 @@
4548
4611
  this.removeLineFromSelection(removedLine);
4549
4612
  if (!this.isFilterData &&
4550
4613
  this.linesFormArray.controls &&
4551
- this.linesFormArray.controls.length === 0) {
4614
+ this.linesFormArray.controls.length === 0 &&
4615
+ !this.isTrulyEmptyAllowed) {
4552
4616
  this.addFormLine();
4553
4617
  }
4554
4618
  else {
4555
- // 删除尾页的最后一个元素动作
4556
- if (this.paginationPageIndex * this.paginationPageSize ===
4557
- this.linesFormArray.controls.length + this.paginationPageSize) {
4558
- this.paginationPageIndex--;
4619
+ // 当前页已无数据时回退页码,且页码最小为 1(避免删空后变成 0 导致再添加看不见)
4620
+ /** @type {?} */
4621
+ var maxPage = Math.max(1, Math.ceil(this.linesFormArray.controls.length / this.paginationPageSize));
4622
+ if (this.paginationPageIndex > maxPage) {
4623
+ this.paginationPageIndex = maxPage;
4559
4624
  }
4560
4625
  this.calculateLineNumber();
4561
4626
  }
@@ -5441,6 +5506,11 @@
5441
5506
  }
5442
5507
  /** @type {?} */
5443
5508
  var debounceMs = onSearchEventDebounceTime != null ? onSearchEventDebounceTime : 0;
5509
+ // 未配置或为 0:同步触发,不走 debounceTime(避免异步)
5510
+ if (!debounceMs) {
5511
+ this.triggerEvent(fn, event);
5512
+ return;
5513
+ }
5444
5514
  this.debounceTimeout = debounceMs;
5445
5515
  if (this.searchSubscription) {
5446
5516
  this.searchSubscription.unsubscribe();
@@ -5478,6 +5548,13 @@
5478
5548
  var debounceMs = onOpenChangeEventDebounceTime != null
5479
5549
  ? onOpenChangeEventDebounceTime
5480
5550
  : 0;
5551
+ // 未配置或为 0:同步触发,不走 debounceTime(避免异步)
5552
+ if (!debounceMs) {
5553
+ if (open) {
5554
+ this.triggerEvent(fn, open);
5555
+ }
5556
+ return;
5557
+ }
5481
5558
  this.openChangeDebounceTimeout = debounceMs;
5482
5559
  if (this.openChangeSubscription) {
5483
5560
  this.openChangeSubscription.unsubscribe();
@@ -5648,14 +5725,29 @@
5648
5725
  var debounceMs = item.onChangeEventDebounceTime != null
5649
5726
  ? item.onChangeEventDebounceTime
5650
5727
  : 0;
5651
- _this.validateHdForm
5652
- .get(item.name)
5653
- .valueChanges.pipe(operators.debounceTime(debounceMs))
5654
- .subscribe((/**
5655
- * @param {?} value
5656
- * @return {?}
5657
- */
5658
- function (value) { return _this.triggerEvent(item.onChangeEvent, value); }));
5728
+ /** @type {?} */
5729
+ var control = _this.validateHdForm.get(item.name);
5730
+ // 未配置或为 0:同步订阅,不走 debounceTime(避免异步破坏 patchValue 联动回显)
5731
+ if (debounceMs > 0) {
5732
+ control.valueChanges
5733
+ .pipe(operators.debounceTime(debounceMs))
5734
+ .subscribe((/**
5735
+ * @param {?} value
5736
+ * @return {?}
5737
+ */
5738
+ function (value) {
5739
+ return _this.triggerEvent(item.onChangeEvent, value);
5740
+ }));
5741
+ }
5742
+ else {
5743
+ control.valueChanges.subscribe((/**
5744
+ * @param {?} value
5745
+ * @return {?}
5746
+ */
5747
+ function (value) {
5748
+ return _this.triggerEvent(item.onChangeEvent, value);
5749
+ }));
5750
+ }
5659
5751
  }
5660
5752
  }));
5661
5753
  this.validateHdForm.valueChanges.subscribe((/**