import { Component } from '@angular/core';
import { SFIcon, SFSchema, SFTagWidgetSchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd/message';
import { of, delay } from 'rxjs';
@Component({
selector: 'form-tag-simple',
template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,
})
export class FormTagSimpleComponent {
schema: SFSchema = {
properties: {
like: {
type: 'number',
title: '兴趣',
enum: [
{ value: 1, label: '电影' },
{ value: 2, label: '书' },
{ value: 3, label: '旅行' },
],
ui: {
widget: 'tag',
} as SFTagWidgetSchema,
default: [1, 2],
},
like1: {
type: 'number',
title: '兴趣',
ui: {
widget: 'tag',
asyncData: () =>
of([
{ value: 1, label: '电影' },
{ value: 2, label: '书' },
{ value: 3, label: '旅行' },
]).pipe(delay(10)),
} as SFTagWidgetSchema,
default: [1, 2],
},
icon: {
type: 'number',
title: '兴趣',
enum: [
{ value: 1, label: 'Twitter', prefixIcon: { type: 'twitter' } as SFIcon },
{ value: 2, label: 'Facebook', suffixIcon: { type: 'facebook' } as SFIcon },
],
ui: {
widget: 'tag',
} as SFTagWidgetSchema,
},
},
};
constructor(private msg: NzMessageService) {}
submit(value: {}): void {
this.msg.success(JSON.stringify(value));
}
}