import { Component } from '@angular/core';
import { CommonNzModule } from '../../../../common.nz.module';
import { Column, SimpleFormPageComponent } from '../../../../shared/simple-form-page/simple-form-page.component';

@Component({
  selector: 'app-post',
  standalone: true,
  imports: [SimpleFormPageComponent, CommonNzModule],
  templateUrl: '../../../../shared/simple-form-page/simple-form-page.component.html',
  styleUrl: './post.component.less',
})
export class PostComponent extends SimpleFormPageComponent<BasicData.Predefine> {
  override keyWord: string = '岗位';
  override showSearchForm = false;
  override editable = false;
  override key: string = 'value';
  override columns: Column[] = [
    { key: 'seq', label: '序号' },
    { key: 'value', label: '岗位名称' },
  ];
  override inputFields = [{ label: '岗位名称', key: 'value', initValue: '' }];
  override async fetchList() {
    const list = await this.api.basic.getPredefineList('job');
    this.list = list;
  }
  override async onAdd(data: BasicData.Predefine) {
    return this.api.basic.addPredefine({
      ...data,
      type: 'job',
    });
  }
  override async onDelete(data: BasicData.Predefine) {
    return this.api.basic.deletePredefine('job', data.value);
  }
}
