fantasy-ngzorro 2.1.9 → 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: /**
@@ -4244,7 +4266,10 @@
4244
4266
  (!this.formLinesData ||
4245
4267
  (this.formLinesData && this.formLinesData.length === 0))) {
4246
4268
  this.tableLoading = false;
4247
- this.addFormLine(null, false);
4269
+ // allowEmpty 且仅删除按钮:不自动补空行
4270
+ if (!this.isTrulyEmptyAllowed) {
4271
+ this.addFormLine(null, false);
4272
+ }
4248
4273
  this.showForm = true;
4249
4274
  }
4250
4275
  else {
@@ -4492,6 +4517,9 @@
4492
4517
  var insertAt = this.getInsertIndexAfter(afterLine);
4493
4518
  this.linesFormArray.insert(insertAt, this.newLineItem());
4494
4519
  this.calculateLineNumber();
4520
+ // 跳到新增行所在页,避免页码异常时看不到数据
4521
+ this.paginationPageIndex =
4522
+ Math.floor(insertAt / this.paginationPageSize) + 1;
4495
4523
  setTimeout((/**
4496
4524
  * @return {?}
4497
4525
  */
@@ -4583,14 +4611,16 @@
4583
4611
  this.removeLineFromSelection(removedLine);
4584
4612
  if (!this.isFilterData &&
4585
4613
  this.linesFormArray.controls &&
4586
- this.linesFormArray.controls.length === 0) {
4614
+ this.linesFormArray.controls.length === 0 &&
4615
+ !this.isTrulyEmptyAllowed) {
4587
4616
  this.addFormLine();
4588
4617
  }
4589
4618
  else {
4590
- // 删除尾页的最后一个元素动作
4591
- if (this.paginationPageIndex * this.paginationPageSize ===
4592
- this.linesFormArray.controls.length + this.paginationPageSize) {
4593
- 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;
4594
4624
  }
4595
4625
  this.calculateLineNumber();
4596
4626
  }