ngx-axis-appforge 0.0.65 → 0.0.67

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.
@@ -1,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, effect, inject, input, ElementRef, isSignal, Directive, Optional, Inject, Injectable, Injector, HostBinding, untracked, model, ViewChild, output, ViewContainerRef, forwardRef, Pipe, signal, ChangeDetectionStrategy, Component, computed, ContentChild } from '@angular/core';
3
- import { BehaviorSubject, filter, map, catchError, of, Subject, switchMap, debounceTime, Observable, isObservable, merge, NEVER, take, mergeMap, from, mergeWith } from 'rxjs';
3
+ import { BehaviorSubject, filter, map, catchError, of, Subject, switchMap, debounceTime, Observable, isObservable, merge, NEVER, take, mergeMap, from, concat, tap, last, mergeWith } from 'rxjs';
4
4
  import * as i1 from '@angular/common/http';
5
5
  import { HttpContextToken, HttpContext, HttpRequest, HttpEventType, HttpClient } from '@angular/common/http';
6
6
  import * as i5 from '@angular/router';
7
7
  import { ActivatedRoute } from '@angular/router';
8
+ import { utils, writeFile } from 'xlsx-js-style';
8
9
  import * as i2 from '@angular/common';
9
10
  import { CommonModule } from '@angular/common';
10
11
  import * as i3 from 'ng-zorro-antd/message';
@@ -827,6 +828,8 @@ class EventsHandlerService {
827
828
  return this.runScriptEventHandler(e);
828
829
  case "print":
829
830
  return this.printEventHandler(e);
831
+ case "exportExcel":
832
+ return this.exportExcelEventHandler(e);
830
833
  default:
831
834
  if (this.otherHandlers) {
832
835
  for (const h of this.otherHandlers) {
@@ -1036,6 +1039,28 @@ class EventsHandlerService {
1036
1039
  });
1037
1040
  return of(true);
1038
1041
  }
1042
+ exportExcelEventHandler(e) {
1043
+ var scope = e.ref?.getScope();
1044
+ if (scope && e.data) {
1045
+ const wb = utils.book_new();
1046
+ const obs = (e.data.sheets ?? []).map(row => {
1047
+ var table = scope.findInstance(row.tableId);
1048
+ if (table) {
1049
+ const ws = table.callFunction?.("exportExcel");
1050
+ if (ws) {
1051
+ return ws.pipe(map(ws => [row.sheetTitle, ws]));
1052
+ }
1053
+ }
1054
+ return of([row.sheetTitle, utils.json_to_sheet([])]);
1055
+ });
1056
+ return concat(...obs).pipe(tap(row => {
1057
+ utils.book_append_sheet(wb, row[1], row[0]);
1058
+ }), last(), tap(() => {
1059
+ writeFile(wb, e.data.fileName + "." + e.data.bookType, { bookType: e.data.bookType });
1060
+ }), map(_ => true));
1061
+ }
1062
+ return of(false);
1063
+ }
1039
1064
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: EventsHandlerService, deps: [{ token: i1.HttpClient }, { token: i2.PlatformLocation }, { token: i3.NzMessageService }, { token: i2$1.NzModalService }, { token: i5.Router }, { token: AXIS_EVENT_HANDLERS_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1040
1065
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: EventsHandlerService, providedIn: 'root' });
1041
1066
  }
@@ -1819,6 +1844,9 @@ class OptionsNode {
1819
1844
  get contextMenu() {
1820
1845
  return this.config.contextMenu;
1821
1846
  }
1847
+ onPaste(node) {
1848
+ this.config.onPaste?.(node);
1849
+ }
1822
1850
  toElementNode(elements) {
1823
1851
  return new ElementNode(this.id, elements);
1824
1852
  }
@@ -2675,6 +2703,160 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImpor
2675
2703
  ], template: "<form nz-form [formGroup]=\"fg\">\n <nz-form-item>\n <nz-form-label nzSpan=\"6\">\n \u6570\u636E\n </nz-form-label>\n <nz-form-control nzSpan=\"18\">\n <axis-fun-field formControlName=\"data\" [noListen]=\"noListen()\">\n <ng-container [axisDynamic]=\"{component:'axis-components/input-json',inuse:true}\" [standalone]=\"true\"\n ngModel [ngModelOptions]=\"{standalone:true}\"></ng-container>\n </axis-fun-field>\n </nz-form-control>\n </nz-form-item>\n</form>" }]
2676
2704
  }] });
2677
2705
 
2706
+ const sheetsOptions = {
2707
+ "id": "axis-components/edit-table#1",
2708
+ "requiredPermissions": null,
2709
+ "triggeEvents": {
2710
+ "valueChange": [
2711
+ {
2712
+ "name": "setDataSource",
2713
+ "disabled": false,
2714
+ "id": "axis-components/scope#1",
2715
+ "data": {
2716
+ "name": "data",
2717
+ "$data": {
2718
+ "listen": {},
2719
+ "fn": "return value;"
2720
+ }
2721
+ },
2722
+ "target": "scope"
2723
+ }
2724
+ ]
2725
+ },
2726
+ "emitInitEvent": true,
2727
+ "disabledRemoveFn": null,
2728
+ "showExpand": false,
2729
+ "expandFormName": null,
2730
+ "checkedFormName": "checked",
2731
+ "checkboxLinkageForExpand": false,
2732
+ "disableCheckboxFn": null,
2733
+ "showPagination": false,
2734
+ "pageSizeOptions": "10,20,50,100",
2735
+ "component": "axis-components/edit-table",
2736
+ "fields": [
2737
+ {
2738
+ "field": "sheetTitle",
2739
+ "totalAble": false,
2740
+ "totalFn": null,
2741
+ "validators": [
2742
+ {
2743
+ "type": "required",
2744
+ "disabled": false,
2745
+ "minLength": null,
2746
+ "maxLength": null,
2747
+ "minValue": null,
2748
+ "maxValue": null,
2749
+ "pattern": ""
2750
+ }
2751
+ ],
2752
+ "child": {
2753
+ "component": "axis-components/input",
2754
+ "id": "axis-components/input#1",
2755
+ "inuse": true
2756
+ },
2757
+ "inuse": true,
2758
+ "title": "工作表名称",
2759
+ "sortAble": false,
2760
+ "sortOrder": null,
2761
+ "sortPriority": null,
2762
+ "filterAble": false,
2763
+ "filterMultiple": false,
2764
+ "width": 150,
2765
+ "align": "left",
2766
+ "freezeMode": "none"
2767
+ },
2768
+ {
2769
+ "field": "tableId",
2770
+ "totalAble": false,
2771
+ "totalFn": null,
2772
+ "validators": [
2773
+ {
2774
+ "type": "required",
2775
+ "disabled": false,
2776
+ "minLength": null,
2777
+ "maxLength": null,
2778
+ "minValue": null,
2779
+ "maxValue": null,
2780
+ "pattern": ""
2781
+ }
2782
+ ],
2783
+ "child": {
2784
+ "component": "axis-components/input",
2785
+ "id": "axis-components/input#2",
2786
+ "inuse": true
2787
+ },
2788
+ "inuse": true,
2789
+ "title": "表格ID",
2790
+ "sortAble": false,
2791
+ "sortOrder": null,
2792
+ "sortPriority": null,
2793
+ "filterAble": false,
2794
+ "filterMultiple": false,
2795
+ "width": null,
2796
+ "align": "left",
2797
+ "freezeMode": "none"
2798
+ }
2799
+ ],
2800
+ "inuse": true,
2801
+ "style": {
2802
+ "width": "100%"
2803
+ },
2804
+ "disabled": false,
2805
+ "readonly": false,
2806
+ "disabledAppend": false,
2807
+ "disabledRemove": false,
2808
+ "maxLength": null,
2809
+ "size": "middle",
2810
+ "showOrder": true,
2811
+ "showDataSize": true,
2812
+ "bordered": false,
2813
+ "outerBordered": false,
2814
+ "width": null,
2815
+ "showCheckbox": false,
2816
+ "checkeOnRowClick": false,
2817
+ "singleCheck": false,
2818
+ "showTotal": false,
2819
+ "totalTitle": "合计",
2820
+ "pageSize": 10,
2821
+ "showSizeChanger": true
2822
+ };
2823
+
2824
+ class ExportExcelHandler extends FunFieldValueBase {
2825
+ sheetsOptions = sheetsOptions;
2826
+ noListen = inject(InputTrigger).noListen;
2827
+ fg = this.fb.group({
2828
+ sheets: [undefined, FormValidators.requiredFun],
2829
+ fileName: [undefined, FormValidators.requiredFun],
2830
+ bookType: ["xlsx", FormValidators.required],
2831
+ });
2832
+ funFields = {
2833
+ sheets: {
2834
+ defaultValue: [],
2835
+ },
2836
+ fileName: {
2837
+ defaultValue: "数据导出",
2838
+ },
2839
+ };
2840
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ExportExcelHandler, deps: null, target: i0.ɵɵFactoryTarget.Component });
2841
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.4", type: ExportExcelHandler, isStandalone: true, selector: "axis-export-excel-handler", providers: [
2842
+ {
2843
+ provide: NG_VALUE_ACCESSOR,
2844
+ useExisting: forwardRef(() => ExportExcelHandler),
2845
+ multi: true
2846
+ }
2847
+ ], usesInheritance: true, ngImport: i0, template: "<form nz-form [formGroup]=\"fg\">\n <nz-form-item>\n <nz-form-control nzSpan=\"24\">\n <axis-fun-field formControlName=\"sheets\" [noListen]=\"noListen()\">\n <ng-container [axisDynamic]=\"sheetsOptions\" [standalone]=\"true\" ngModel\n [ngModelOptions]=\"{standalone:true}\"></ng-container>\n </axis-fun-field>\n </nz-form-control>\n </nz-form-item>\n <nz-form-item>\n <nz-form-label nzSpan=\"6\" nzRequired>\n \u6587\u4EF6\u540D\u79F0\n </nz-form-label>\n <nz-form-control nzSpan=\"18\">\n <axis-fun-field formControlName=\"fileName\" [noListen]=\"noListen()\">\n <input nz-input ngModel [ngModelOptions]=\"{standalone:true}\" />\n </axis-fun-field>\n </nz-form-control>\n </nz-form-item>\n <nz-form-item>\n <nz-form-label nzSpan=\"6\" nzRequired>\n \u6587\u6863\u683C\u5F0F\n </nz-form-label>\n <nz-form-control nzSpan=\"18\">\n <nz-select formControlName=\"bookType\">\n <nz-option nzValue=\"xlsx\" nzLabel=\"xlsx\"></nz-option>\n <nz-option nzValue=\"xls\" nzLabel=\"xls\"></nz-option>\n </nz-select>\n </nz-form-control>\n </nz-form-item>\n</form>", styles: [""], dependencies: [{ kind: "ngmodule", type: NzFormModule }, { kind: "directive", type: i1$3.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { kind: "directive", type: i1$3.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { kind: "directive", type: i2$3.NzFormDirective, selector: "[nz-form]", inputs: ["nzLayout", "nzNoColon", "nzAutoTips", "nzDisableAutoTips", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzForm"] }, { kind: "component", type: i2$3.NzFormItemComponent, selector: "nz-form-item", exportAs: ["nzFormItem"] }, { kind: "component", type: i2$3.NzFormLabelComponent, selector: "nz-form-label", inputs: ["nzFor", "nzRequired", "nzNoColon", "nzTooltipTitle", "nzTooltipIcon", "nzLabelAlign", "nzLabelWrap"], exportAs: ["nzFormLabel"] }, { kind: "component", type: i2$3.NzFormControlComponent, selector: "nz-form-control", inputs: ["nzSuccessTip", "nzWarningTip", "nzErrorTip", "nzValidatingTip", "nzExtra", "nzAutoTips", "nzDisableAutoTips", "nzHasFeedback", "nzValidateStatus"], exportAs: ["nzFormControl"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3$3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3$3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3$3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3$3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3$3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3$3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: FunField, selector: "axis-fun-field", inputs: ["scopes", "exclude", "scopeId", "onlyFun", "noListen", "disabled", "editTip", "value", "open", "showCreateListenModal", "createListenDataSourceName"], outputs: ["valueChange", "openChange", "showCreateListenModalChange", "createListenDataSourceNameChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3$3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: NzSelectModule }, { kind: "component", type: i4$1.NzOptionComponent, selector: "nz-option", inputs: ["nzTitle", "nzLabel", "nzValue", "nzKey", "nzDisabled", "nzHide", "nzCustomContent"], exportAs: ["nzOption"] }, { kind: "component", type: i4$1.NzSelectComponent, selector: "nz-select", inputs: ["nzId", "nzSize", "nzStatus", "nzVariant", "nzOptionHeightPx", "nzOptionOverflowSize", "nzDropdownClassName", "nzDropdownMatchSelectWidth", "nzDropdownStyle", "nzNotFoundContent", "nzPlaceHolder", "nzPlacement", "nzMaxTagCount", "nzDropdownRender", "nzCustomTemplate", "nzPrefix", "nzSuffixIcon", "nzClearIcon", "nzRemoveIcon", "nzMenuItemSelectedIcon", "nzTokenSeparators", "nzMaxTagPlaceholder", "nzMaxMultipleCount", "nzMode", "nzFilterOption", "compareWith", "nzAllowClear", "nzBorderless", "nzShowSearch", "nzLoading", "nzAutoFocus", "nzAutoClearSearchValue", "nzServerSearch", "nzDisabled", "nzOpen", "nzSelectOnTab", "nzBackdrop", "nzOptions", "nzShowArrow"], outputs: ["nzOnSearch", "nzScrollToBottom", "nzOpenChange", "nzBlur", "nzFocus", "nzOnClear"], exportAs: ["nzSelect"] }, { kind: "ngmodule", type: NzInputModule }, { kind: "directive", type: i4.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzVariant", "nzSize", "nzStepperless", "nzStatus", "disabled"], exportAs: ["nzInput"] }, { kind: "directive", type: DynamicDirective, selector: "[axisDynamic]", inputs: ["axisDynamic", "standalone", "isDesign", "forceRenderOnChange"], outputs: ["onRegisteValueAccess"], exportAs: ["axisDynamic"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2848
+ }
2849
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ExportExcelHandler, decorators: [{
2850
+ type: Component,
2851
+ args: [{ selector: 'axis-export-excel-handler', imports: [NzFormModule, ReactiveFormsModule, FunField, FormsModule, NzSelectModule, NzInputModule, DynamicDirective], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
2852
+ {
2853
+ provide: NG_VALUE_ACCESSOR,
2854
+ useExisting: forwardRef(() => ExportExcelHandler),
2855
+ multi: true
2856
+ }
2857
+ ], template: "<form nz-form [formGroup]=\"fg\">\n <nz-form-item>\n <nz-form-control nzSpan=\"24\">\n <axis-fun-field formControlName=\"sheets\" [noListen]=\"noListen()\">\n <ng-container [axisDynamic]=\"sheetsOptions\" [standalone]=\"true\" ngModel\n [ngModelOptions]=\"{standalone:true}\"></ng-container>\n </axis-fun-field>\n </nz-form-control>\n </nz-form-item>\n <nz-form-item>\n <nz-form-label nzSpan=\"6\" nzRequired>\n \u6587\u4EF6\u540D\u79F0\n </nz-form-label>\n <nz-form-control nzSpan=\"18\">\n <axis-fun-field formControlName=\"fileName\" [noListen]=\"noListen()\">\n <input nz-input ngModel [ngModelOptions]=\"{standalone:true}\" />\n </axis-fun-field>\n </nz-form-control>\n </nz-form-item>\n <nz-form-item>\n <nz-form-label nzSpan=\"6\" nzRequired>\n \u6587\u6863\u683C\u5F0F\n </nz-form-label>\n <nz-form-control nzSpan=\"18\">\n <nz-select formControlName=\"bookType\">\n <nz-option nzValue=\"xlsx\" nzLabel=\"xlsx\"></nz-option>\n <nz-option nzValue=\"xls\" nzLabel=\"xls\"></nz-option>\n </nz-select>\n </nz-form-control>\n </nz-form-item>\n</form>" }]
2858
+ }] });
2859
+
2678
2860
  class MsgTipHandler extends FunFieldValueBase {
2679
2861
  noListen = inject(InputTrigger).noListen;
2680
2862
  fg = this.fb.group({
@@ -2982,6 +3164,13 @@ const baseEventHandlerDescs = {
2982
3164
  dataComponent: PrintHandler,
2983
3165
  target: "service",
2984
3166
  },
3167
+ exportExcel: {
3168
+ name: "exportExcel",
3169
+ title: "导出Excel",
3170
+ icon: "file-excel",
3171
+ dataComponent: ExportExcelHandler,
3172
+ target: "service",
3173
+ },
2985
3174
  };
2986
3175
  const baseEventHandlerDescGroups = [
2987
3176
  {
@@ -2996,6 +3185,7 @@ const baseEventHandlerDescGroups = [
2996
3185
  baseEventHandlerDescs["route"],
2997
3186
  baseEventHandlerDescs["runScript"],
2998
3187
  baseEventHandlerDescs["print"],
3188
+ baseEventHandlerDescs["exportExcel"],
2999
3189
  ]
3000
3190
  }
3001
3191
  ];