import { Component, inject } from '@angular/core';
import { YelonFormModule, SFSchema, SFStringWidgetSchema, SFTextWidgetSchema } from '@yelon/form';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'form-text-simple',
template: ` <sf [schema]="schema" [loading]="loading" (formSubmit)="submit($event)" /> `,
standalone: true,
imports: [YelonFormModule]
})
export class FormTextSimpleComponent {
private readonly msg = inject(NzMessageService);
loading = false;
schema: SFSchema = {
properties: {
id1: { type: 'number', ui: { widget: 'text' } as SFTextWidgetSchema },
id2: { type: 'number', ui: { widget: 'text', defaultText: 'default text' } as SFTextWidgetSchema },
name: {
type: 'string',
title: 'Name',
ui: {
addOnAfter: 'RMB',
placeholder: 'RMB结算'
} as SFStringWidgetSchema
}
},
required: ['name']
};
submit(value: {}): void {
this.loading = true;
setTimeout(() => {
this.loading = false;
this.msg.success(JSON.stringify(value));
}, 1000);
}
}