ngx-axis-appforge 0.0.65 → 0.0.66

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,33 @@ 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
+ if (ws instanceof Observable) {
1052
+ return ws.pipe(map(ws => [row.sheetTitle, ws]));
1053
+ }
1054
+ else {
1055
+ return of([row.sheetTitle, ws]);
1056
+ }
1057
+ }
1058
+ }
1059
+ return of([row.sheetTitle, utils.json_to_sheet([])]);
1060
+ });
1061
+ return concat(...obs).pipe(tap(row => {
1062
+ utils.book_append_sheet(wb, row[1], row[0]);
1063
+ }), last(), tap(() => {
1064
+ writeFile(wb, e.data.fileName + "." + e.data.bookType, { bookType: e.data.bookType });
1065
+ }), map(_ => true));
1066
+ }
1067
+ return of(false);
1068
+ }
1039
1069
  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
1070
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: EventsHandlerService, providedIn: 'root' });
1041
1071
  }
@@ -1819,6 +1849,9 @@ class OptionsNode {
1819
1849
  get contextMenu() {
1820
1850
  return this.config.contextMenu;
1821
1851
  }
1852
+ onPaste(node) {
1853
+ this.config.onPaste?.(node);
1854
+ }
1822
1855
  toElementNode(elements) {
1823
1856
  return new ElementNode(this.id, elements);
1824
1857
  }
@@ -2675,6 +2708,160 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImpor
2675
2708
  ], 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
2709
  }] });
2677
2710
 
2711
+ const sheetsOptions = {
2712
+ "id": "axis-components/edit-table#1",
2713
+ "requiredPermissions": null,
2714
+ "triggeEvents": {
2715
+ "valueChange": [
2716
+ {
2717
+ "name": "setDataSource",
2718
+ "disabled": false,
2719
+ "id": "axis-components/scope#1",
2720
+ "data": {
2721
+ "name": "data",
2722
+ "$data": {
2723
+ "listen": {},
2724
+ "fn": "return value;"
2725
+ }
2726
+ },
2727
+ "target": "scope"
2728
+ }
2729
+ ]
2730
+ },
2731
+ "emitInitEvent": true,
2732
+ "disabledRemoveFn": null,
2733
+ "showExpand": false,
2734
+ "expandFormName": null,
2735
+ "checkedFormName": "checked",
2736
+ "checkboxLinkageForExpand": false,
2737
+ "disableCheckboxFn": null,
2738
+ "showPagination": false,
2739
+ "pageSizeOptions": "10,20,50,100",
2740
+ "component": "axis-components/edit-table",
2741
+ "fields": [
2742
+ {
2743
+ "field": "sheetTitle",
2744
+ "totalAble": false,
2745
+ "totalFn": null,
2746
+ "validators": [
2747
+ {
2748
+ "type": "required",
2749
+ "disabled": false,
2750
+ "minLength": null,
2751
+ "maxLength": null,
2752
+ "minValue": null,
2753
+ "maxValue": null,
2754
+ "pattern": ""
2755
+ }
2756
+ ],
2757
+ "child": {
2758
+ "component": "axis-components/input",
2759
+ "id": "axis-components/input#1",
2760
+ "inuse": true
2761
+ },
2762
+ "inuse": true,
2763
+ "title": "工作表名称",
2764
+ "sortAble": false,
2765
+ "sortOrder": null,
2766
+ "sortPriority": null,
2767
+ "filterAble": false,
2768
+ "filterMultiple": false,
2769
+ "width": 150,
2770
+ "align": "left",
2771
+ "freezeMode": "none"
2772
+ },
2773
+ {
2774
+ "field": "tableId",
2775
+ "totalAble": false,
2776
+ "totalFn": null,
2777
+ "validators": [
2778
+ {
2779
+ "type": "required",
2780
+ "disabled": false,
2781
+ "minLength": null,
2782
+ "maxLength": null,
2783
+ "minValue": null,
2784
+ "maxValue": null,
2785
+ "pattern": ""
2786
+ }
2787
+ ],
2788
+ "child": {
2789
+ "component": "axis-components/input",
2790
+ "id": "axis-components/input#2",
2791
+ "inuse": true
2792
+ },
2793
+ "inuse": true,
2794
+ "title": "表格ID",
2795
+ "sortAble": false,
2796
+ "sortOrder": null,
2797
+ "sortPriority": null,
2798
+ "filterAble": false,
2799
+ "filterMultiple": false,
2800
+ "width": null,
2801
+ "align": "left",
2802
+ "freezeMode": "none"
2803
+ }
2804
+ ],
2805
+ "inuse": true,
2806
+ "style": {
2807
+ "width": "100%"
2808
+ },
2809
+ "disabled": false,
2810
+ "readonly": false,
2811
+ "disabledAppend": false,
2812
+ "disabledRemove": false,
2813
+ "maxLength": null,
2814
+ "size": "middle",
2815
+ "showOrder": true,
2816
+ "showDataSize": true,
2817
+ "bordered": false,
2818
+ "outerBordered": false,
2819
+ "width": null,
2820
+ "showCheckbox": false,
2821
+ "checkeOnRowClick": false,
2822
+ "singleCheck": false,
2823
+ "showTotal": false,
2824
+ "totalTitle": "合计",
2825
+ "pageSize": 10,
2826
+ "showSizeChanger": true
2827
+ };
2828
+
2829
+ class ExportExcelHandler extends FunFieldValueBase {
2830
+ sheetsOptions = sheetsOptions;
2831
+ noListen = inject(InputTrigger).noListen;
2832
+ fg = this.fb.group({
2833
+ sheets: [undefined, FormValidators.requiredFun],
2834
+ fileName: [undefined, FormValidators.requiredFun],
2835
+ bookType: ["xlsx", FormValidators.required],
2836
+ });
2837
+ funFields = {
2838
+ sheets: {
2839
+ defaultValue: [],
2840
+ },
2841
+ fileName: {
2842
+ defaultValue: "数据导出",
2843
+ },
2844
+ };
2845
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ExportExcelHandler, deps: null, target: i0.ɵɵFactoryTarget.Component });
2846
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.4", type: ExportExcelHandler, isStandalone: true, selector: "axis-export-excel-handler", providers: [
2847
+ {
2848
+ provide: NG_VALUE_ACCESSOR,
2849
+ useExisting: forwardRef(() => ExportExcelHandler),
2850
+ multi: true
2851
+ }
2852
+ ], 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 });
2853
+ }
2854
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ExportExcelHandler, decorators: [{
2855
+ type: Component,
2856
+ args: [{ selector: 'axis-export-excel-handler', imports: [NzFormModule, ReactiveFormsModule, FunField, FormsModule, NzSelectModule, NzInputModule, DynamicDirective], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
2857
+ {
2858
+ provide: NG_VALUE_ACCESSOR,
2859
+ useExisting: forwardRef(() => ExportExcelHandler),
2860
+ multi: true
2861
+ }
2862
+ ], 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>" }]
2863
+ }] });
2864
+
2678
2865
  class MsgTipHandler extends FunFieldValueBase {
2679
2866
  noListen = inject(InputTrigger).noListen;
2680
2867
  fg = this.fb.group({
@@ -2982,6 +3169,13 @@ const baseEventHandlerDescs = {
2982
3169
  dataComponent: PrintHandler,
2983
3170
  target: "service",
2984
3171
  },
3172
+ exportExcel: {
3173
+ name: "exportExcel",
3174
+ title: "导出Excel",
3175
+ icon: "file-excel",
3176
+ dataComponent: ExportExcelHandler,
3177
+ target: "service",
3178
+ },
2985
3179
  };
2986
3180
  const baseEventHandlerDescGroups = [
2987
3181
  {
@@ -2996,6 +3190,7 @@ const baseEventHandlerDescGroups = [
2996
3190
  baseEventHandlerDescs["route"],
2997
3191
  baseEventHandlerDescs["runScript"],
2998
3192
  baseEventHandlerDescs["print"],
3193
+ baseEventHandlerDescs["exportExcel"],
2999
3194
  ]
3000
3195
  }
3001
3196
  ];