3.1.8 • Published 2 years ago

@orendaco/of v3.1.8

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Of

Dynamic Form Orenda

Code scaffolding

HTML

 <of #vcForm [schemaModel]="schemaModel">
               <of-field id="templateRef" [controlItemTpl]="control">
                    <ng-template #control>
                      <form [formGroup]="schemaModel.form">
                        <nz-input-group nzCompact>
                          <nz-select formControlName="templateOpt" style="width: 50%">
                            <nz-option [nzLabel]="'Option 1'"
                                       [nzValue]="'1'"></nz-option>
                            <nz-option [nzLabel]="'Option 2'"
                                       [nzValue]="'2'"></nz-option>
                          </nz-select>
              
                          <of-item-wrap [schemaModel]="schemaModel" dataField="templateInput"
                                        style="width: 50%">
                            <input formControlName="templateInput"
                                   nz-input
                                   placeholder="templateInput"
                            />
                          </of-item-wrap>
              
                        </nz-input-group>
                      </form>
                    </ng-template>
                  </of-field>
          </of>

TS

formDisable$ = new BehaviorSubject(false);
ngaySinhMin$ = new BehaviorSubject<Date>(new Date(1991, 2, 27));
danTocOption$ = new BehaviorSubject<IOfSelectOptionDto[]>([{
displayText: 'Kinh',
value: '1'
}, {
displayText: 'Mông',
value: '2'
}]);
schemaModel = new OfSchemaModel({
    fields: [
      new OfTextModel({
        label: 'Mã',
        dataField: 'ma',
        required: true,
        validations: [
          {
            name: 'email'
          }
        ],
        disabled: true

      }),
      new OfTextModel({
        label: 'Họ tên',
        dataField: 'tenDayDu',
        required: true,
        disabledAsync: this.formDisable$
      }),

      new OfSelectModel({
        label: 'Giới tính',
        dataField: 'gioiTinhId',
        value: 1,
        options: [
          { displayText: 'Nam', value: '1' },
          { displayText: 'Nữ', value: '2' }
        ]
      }),
      new OfSelectAsyncModel({
        label: 'Dân tộc async',
        dataField: 'danToc',
        value: 1,
        optionsAsync: this.danTocOption$
      }),
      new OfSelectApiModel({
        label: 'Tỉnh',
        dataField: 'tinhId',
        functionService: this.selectSp.getoptions({
          type: SelectOptionType.Tinh
        } as any),
        keyCache: 'tinh'
      }),
      new OfSelectCascadeModel({
        label: 'Huyện',
        dataField: 'huyenId',
        cascadeField: 'tinhId',
        functionService: (cascade) => {
          return this.selectSp.getoptions({
            type: SelectOptionType.Huyen,
            cascader: cascade
          } as any);
        },
        renderOptionFunc: (opt) => {
          if (opt) {
            return opt.value + ' - ' + opt.displayText;
          }
          return '';
        },
        renderSelectedFunc: (opt) => {
          if (opt) {
            return `<b>${opt.value}</b>` + ' - ' + opt.displayText;
          }
          return '';
        }
      }),
      new OfSelectCascadeModel({
        label: 'Xã',
        dataField: 'xaId',
        cascadeField: 'huyenId',
        functionService: (cascade) => {
          return this.selectSp.getoptions({
            type: SelectOptionType.Xa,
            cascader: cascade
          } as any);
        },
        keyCache: 'xa'
      }),

      new OfSelectSearchServerModel({
        label: 'Quận huyện search',
        dataField: 'huyenSearchServerId',
        functionService: (dto) => {
          return this.searchSp.getoptions({
            ...dto,
            type: SelectSearchServerType.Huyen
          });
        }
      }),
      new OfSelectSearchServerModel({
        label: 'Quận huyện search showPagination',
        dataField: 'huyenSearchServerId',
        functionService: (dto) => {
          return this.searchSp.getoptions({
            ...dto,
            type: SelectSearchServerType.Huyen
          });
        },
        showPagination: true
      }),
        new OfSelectAdvancedSearchModel({
            label: 'Quận huyện search advanced',
            dataField: 'huyenSelectAdvancedSearchId',
            functionService: (dto) => {
              return this.searchSp.getoptions({
                ...dto,
                type: SelectSearchServerType.Huyen
              } as any);
            },
            showPagination: true,
            componentAdvanced: HomeComponent
          }),
      new OfSelectAdvancedSearchModel({
        label: 'Quận huyện search advanced modal',
        dataField: 'huyenSelectAdvancedSearchModalId',
        functionService: (dto) => {
          return this.searchSp.getoptions({
            ...dto,
            type: SelectSearchServerType.Huyen
          } as any);
        },
        showPagination: true,
        componentAdvanced: SearchModalComponent,
        nzModalConfig: {
          nzFooter: null,
          nzStyle: { top: '20px' }
        },
        showComponentType: 'modal'
      }),
      new OfCheckBoxModel({
        label: '',
        dataField: 'checkBox',
        checkBoxLabel: 'Check box',
        disabledAsync: this.formDisable$
      }),
      new OfDateModel({
        label: 'Ngày sinh',
        dataField: 'ngaySinh',
        required: true,
        notGreaterThanCurrent: true,
        minDateAsync: this.ngaySinhMin$,
        disabledAsync: this.formDisable$
      }),
      new OfCurrencyModel({
        label: 'Đơn giá',
        dataField: 'donGia',
        disabledAsync: this.formDisable$
      }),
      new OfContentHtmlModel({
        label: ' ',
        dataField: 'benhNhanId',
        content: '<h3>content string html</h3>',
        disabledAsync: this.formDisable$
      }),
      new OfTextAreaModel({
        label: 'Ghi chú',
        dataField: 'ghiChu',
        rows: 2,
        disabledAsync: this.formDisable$
      }),
      new OfNumberModel({
        label: 'Số thứ tự',
        dataField: 'soThuTu',
        min: 10,
        max: 100,
        step: 2,
        disabledAsync: this.formDisable$
      }),
      new OfNumberModel({
        label: 'Điện thoại',
        dataField: 'dienThoai',
        onlyKeyNumber: true,
        disabledAsync: this.formDisable$
      }),
      new OfPwdModel({
        label: 'Mật khẩu',
        dataField: 'matKhau',
        disabledAsync: this.formDisable$,
        validations: [
          {
            name: 'password'
          }
        ]
      }),
      new OfRadioModel({
        label: 'Loại',
        dataField: 'loai',
        items: [{
          label: 'Loại 1',
          value: 1
        }, {
          label: 'Loại 2',
          value: 2
        }, {
          label: 'Loại 3',
          value: 3
        }]
      }),
      new OfSwitchModel({
        label: 'Switch',
        dataField: 'switch',
        yesText: 'Có'
      }),
      new OfTemplateRefModel({
        label: 'templateRef',
        dataField: 'templateRef',
        controls: [
          new OfExtendControlModel({
            dataField: 'templateOpt',
            value: '1'
          }),
          new OfExtendControlModel({
            dataField: 'templateInput',
            required: true
          })
        ]
      })
    ]
  });

Table

Html

<o-table #vcTable [setting]="otSetting" [items]="pageConfig.items" [loading]="pageConfig.loading$ | async">
  <o-column type="checkbox"></o-column>
  <o-column name="value" headerText="Id" cellAlign="center" [width]="50" [allowSorting]="true"></o-column>
  <o-column name="displayText" headerText="Tên" [width]="100"></o-column>
  <o-column headerText="Tên">
    <ng-template #template let-data="data">
      <div>
        <span>{{data.value}} - {{data.displayText}}</span>
      </div>
    </ng-template>
  </o-column>
  <o-column name="value" headerText="Tiền vnd" type="vnd" [width]="100"></o-column>
  <o-column name="displayText" headerText="Tên 1" *ngIf="showCol"></o-column>
  <o-column name="displayText" headerText="Tên 2"></o-column>
  <o-column name="displayText" headerText="Tên 3"></o-column>
  <o-column name="displayText" headerText="Tên 4" fix="right"></o-column>
  <ng-template #expand let-data="data">
    {{data|json}}
  </ng-template>
</o-table>
<op #vcPage [config]="pageConfig"></op>

TS

 @ViewChild('vcPage') vcPage!: OpComponent;


  pageConfig = new OpConfigModel<any>({
    type: 'ord-custom',
    sourceType: 'func',
    dataSourceFunc: (dto) => {
      dto.type = 27;
      return this.selectSp.getoptions(dto).pipe(map(result => {
        return {
          items: result,
          totalCount: result.length
        };
      }));
    }
  });
  otSetting: OTableSettingModel;
  showCol = false;

  constructor(private selectSp: SelectoptionServiceProxy) {
  }

  ngOnInit(): void {
    this.otSetting = new OTableSettingModel({
      bordered: true,
      scrollY: '60vh',
      expandable: true
    });
  }

  search() {
    this.vcPage.search({});
  }

Tree Table

HTML

<button nz-button
        (click)="expand = !expand; vcTreeTable.expandAll(expand)"> Expand
</button>
<o-table-tree #vcTreeTable
              [setting]="setting"
              [items]="items"
              (expandChange)="expandChange($event)"
              (nodeCheckedChange)="nodeChecked = $event"
>
<!--    <o-tree-column type="checkbox"></o-tree-column>-->
<!--    <o-tree-column headerText="Tên"-->
<!--                   name="ten"-->
<!--                   [isContainIconExpand]="true"-->
<!--                   [width]="300"-->
<!--                   [hasTreeIndex]="true"></o-tree-column>-->
<!--    <o-tree-column headerText="Tên đầy đủ">-->
<!--        <ng-template #template-->
<!--                     let-data="data">-->
<!--            {{data?.tenDayDu}}-->
<!--        </ng-template>-->
<!--    </o-tree-column>-->
</o-table-tree>

TS

 setting = new OTreeTableSettingModel({
        primaryKey: 'id',
        parentKey: 'parentId',
        //  expandAllAfterLoad: true,
        loadAsync: true,
        scrollY: '60vh',
        singleChecked: false,
        columns: [{
            type: 'checkbox',
            width: 60
        },
            {
                headerText: 'Tên',
                name: 'ten',
                isContainIconExpand: true,
                hasTreeIndex: true,
                width: 300
            },
            {
                headerText: 'Tên đầy đủ',
                renderHtml: (record) => {
                    return record?.tenDayDu;
                }
            }
        ]
    });

    expandChange(node: IOTreeTableNode) {
        const children = this.allItems.filter(s => s.parentId === node.id);
        this.vcTreeTable.setChildrenForNode(node, children);
    }
3.1.8

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

2.0.63

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

2.0.28

2 years ago

2.0.29

2 years ago

2.0.37

2 years ago

2.0.38

2 years ago

2.0.35

2 years ago

2.0.36

2 years ago

2.0.33

2 years ago

2.0.31

2 years ago

2.0.32

2 years ago

2.0.30

2 years ago

2.0.39

2 years ago

2.0.46

2 years ago

2.0.45

2 years ago

2.0.42

2 years ago

2.0.43

2 years ago

2.0.40

2 years ago

2.0.41

2 years ago

2.0.59

2 years ago

2.0.57

2 years ago

2.0.58

2 years ago

2.0.55

2 years ago

2.0.56

2 years ago

2.0.53

2 years ago

2.0.54

2 years ago

2.0.51

2 years ago

2.0.52

2 years ago

2.0.50

2 years ago

2.0.62

2 years ago

2.0.60

2 years ago

2.0.61

2 years ago

2.0.26

3 years ago

2.0.27

3 years ago

2.0.24

3 years ago

2.0.25

3 years ago

2.0.23

3 years ago

2.0.22

3 years ago

2.0.21

3 years ago

2.0.20

3 years ago

2.0.19

3 years ago

2.0.17

3 years ago

2.0.18

3 years ago

2.0.16

3 years ago

2.0.15

3 years ago

2.0.14

3 years ago

2.0.11

3 years ago

2.0.12

3 years ago

2.0.10

3 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.6

3 years ago

2.0.1

3 years ago

1.0.139

3 years ago

1.0.136

3 years ago

1.0.135

3 years ago

1.0.138

3 years ago

1.0.137

3 years ago

1.0.132

3 years ago

1.0.134

3 years ago

1.0.133

3 years ago

1.0.131

3 years ago

1.0.130

3 years ago

1.0.129

3 years ago

1.0.128

3 years ago

1.0.127

3 years ago

1.0.126

3 years ago

1.0.121

3 years ago

1.0.123

3 years ago

1.0.122

3 years ago

1.0.125

3 years ago

1.0.101

3 years ago

1.0.100

3 years ago

1.0.106

3 years ago

1.0.109

3 years ago

1.0.108

3 years ago

1.0.103

3 years ago

1.0.102

3 years ago

1.0.105

3 years ago

1.0.104

3 years ago

1.0.120

3 years ago

1.0.110

3 years ago

1.0.112

3 years ago

1.0.111

3 years ago

1.0.118

3 years ago

1.0.117

3 years ago

1.0.119

3 years ago

1.0.113

3 years ago

1.0.116

3 years ago

1.0.115

3 years ago

1.0.95

3 years ago

1.0.94

3 years ago

1.0.93

3 years ago

1.0.99

3 years ago

1.0.98

3 years ago

1.0.97

3 years ago

1.0.96

3 years ago

1.0.91

3 years ago

1.0.92

3 years ago

1.0.89

3 years ago

1.0.90

3 years ago

1.0.83

3 years ago

1.0.82

3 years ago

1.0.88

3 years ago

1.0.86

3 years ago

1.0.73

3 years ago

1.0.72

3 years ago

1.0.71

3 years ago

1.0.77

3 years ago

1.0.76

3 years ago

1.0.75

3 years ago

1.0.74

3 years ago

1.0.78

3 years ago

1.0.80

3 years ago

1.0.81

3 years ago

1.0.69

3 years ago

1.0.70

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.40

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.45

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.55

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.19

3 years ago

1.0.2

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.33

3 years ago

1.0.11

3 years ago

1.0.32

3 years ago

1.0.10

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.15

3 years ago

1.0.12

3 years ago

1.0.1

3 years ago