import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

export const queryFormSchema: FormSchemaGetter = () => [
  {
    component: 'Select',
    fieldName: 'stationName',
    label: '油站',
    componentProps: {
      placeholder: '请选择油站',
      options: [
        { label: '第一加油站', value: '第一加油站' },
        { label: '第二加油站', value: '第二加油站' },
        { label: '第三加油站', value: '第三加油站' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'type',
    label: '类型',
    componentProps: {
      placeholder: '请选择类型',
      options: [
        { label: '灭火器', value: 'fire_extinguisher' },
        { label: '防毒面具', value: 'gas_mask' },
        { label: '急救箱', value: 'first_aid_kit' },
        { label: '防护服', value: 'protective_clothing' },
        { label: '消防栓', value: 'fire_hydrant' },
      ],
    },
  },
];

export const tableColumns: VxeGridProps['columns'] = [
  {
    type: 'checkbox',
    width: 80,
  },
  {
    field: 'stationName',
    title: '油站',
    minWidth: 120,
  },
  {
    field: 'name',
    title: '名称',
    minWidth: 120,
  },
  {
    field: 'type',
    title: '类型',
    minWidth: 120,
    formatter: ({ cellValue }) => ({
      fire_extinguisher: '灭火器',
      gas_mask: '防毒面具',
      first_aid_kit: '急救箱',
      protective_clothing: '防护服',
      fire_hydrant: '消防栓',
    })[cellValue] || cellValue,
  },
  {
    field: 'unit',
    title: '单位',
    minWidth: 80,
  },
  {
    field: 'quantity',
    title: '数量',
    minWidth: 80,
  },
  {
    field: 'remark',
    title: '备注',
    minWidth: 150,
  },
  {
    field: 'createBy',
    title: '操作人',
    minWidth: 120,
  },
  {
    field: 'createTime',
    title: '操作时间',
    minWidth: 180,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 150,
  },
];

export const drawerFormSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
    fieldName: 'id',
  },
  {
    component: 'Select',
    fieldName: 'stationName',
    label: '油站',
    componentProps: {
      placeholder: '请选择油站',
      options: [
        { label: '第一加油站', value: '第一加油站' },
        { label: '第二加油站', value: '第二加油站' },
        { label: '第三加油站', value: '第三加油站' },
      ],
    },
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'name',
    label: '名称',
    componentProps: {
      placeholder: '请输入名称',
      maxlength: 100,
    },
    rules: 'required',
  },
  {
    component: 'Select',
    fieldName: 'type',
    label: '类型',
    componentProps: {
      placeholder: '请选择类型',
      options: [
        { label: '灭火器', value: 'fire_extinguisher' },
        { label: '防毒面具', value: 'gas_mask' },
        { label: '急救箱', value: 'first_aid_kit' },
        { label: '防护服', value: 'protective_clothing' },
        { label: '消防栓', value: 'fire_hydrant' },
      ],
    },
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'unit',
    label: '单位',
    componentProps: {
      placeholder: '请输入单位',
      maxlength: 20,
    },
    rules: 'required',
  },
  {
    component: 'InputNumber',
    fieldName: 'quantity',
    label: '数量',
    componentProps: {
      placeholder: '请输入数量',
      min: 0,
      step: 1,
    },
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'remark',
    label: '备注',
    componentProps: {
      maxlength: 500,
      type: 'textarea',
      showWordLimit: true,
    },
  },
];
