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-type',
  standalone: true,
  imports: [CommonNzModule],
  templateUrl: '../../../../shared/simple-form-page/simple-form-page.component.html',
  styleUrl: './type.component.less',
})
export class TypeComponent extends SimpleFormPageComponent<BasicData.Predefine> {
  override showSearchForm = false;
  override editable = false;
  override keyWord: string = '车站类型';
  override key: string = 'value';
  override columns: Column[] = [
    { key: 'seq', label: '序号' },
    { key: 'value', label: '车站类型' },
  ];

  override async fetchList() {
    const list = await this.api.basic.getPredefineList('product');
    this.list = list;
  }
  override async onAdd(data: BasicData.Predefine) {
    return this.api.basic
      .addPredefine({
        seq: 0,
        type: 'product',
        value: data.value,
      })
      .then(() => {
        this.message.success('添加成功');
      });
  }
  override async onDelete(data: BasicData.Predefine) {
    return this.api.basic.deletePredefine('product', data.value).then(() => {
      this.message.success('删除成功');
    });
  }
}
