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

export const queryFormSchema: FormSchemaGetter = () => [
  {
    component: 'Select',
    fieldName: 'district',
    label: '片区',
    componentProps: {
      placeholder: '请选择片区',
      options: [
        { label: '华东片区', value: '华东片区' },
        { label: '华南片区', value: '华南片区' },
        { label: '华北片区', value: '华北片区' },
        { label: '华西片区', value: '华西片区' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'stationName',
    label: '交接油站',
    componentProps: {
      placeholder: '请选择交接油站',
      options: [
        { label: '油站1', value: '油站1' },
        { label: '油站2', value: '油站2' },
        { label: '油站3', value: '油站3' },
        { label: '油站4', value: '油站4' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'status',
    label: '状态',
    componentProps: {
      placeholder: '请选择状态',
      options: [
        { label: '待接收', value: '待接收' },
        { label: '接收中', value: '接收中' },
        { label: '已完成', value: '已完成' },
      ],
    },
  },
  {
    component: 'Input',
    fieldName: 'receiver',
    label: '接收人',
    componentProps: {
      placeholder: '请输入接收人',
    },
  },
  {
    component: 'Input',
    fieldName: 'transferor',
    label: '移交人',
    componentProps: {
      placeholder: '请输入移交人',
    },
  },
  {
    component: 'Input',
    fieldName: 'supervisor',
    label: '监交人',
    componentProps: {
      placeholder: '请输入监交人',
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'startDate',
    label: '交接开始日期',
    componentProps: {
      placeholder: '请选择交接开始日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'endDate',
    label: '交接完成日期',
    componentProps: {
      placeholder: '请选择交接完成日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
  },
];

export const tableColumns: VxeGridProps['columns'] = [
  {
    type: 'checkbox',
    width: 80,
  },
  {
    field: 'status',
    title: '状态',
    minWidth: 120,
  },
  {
    field: 'district',
    title: '片区',
    minWidth: 120,
  },
  {
    field: 'stationName',
    title: '交接油站',
    minWidth: 150,
  },
  {
    field: 'startDate',
    title: '交接开始日期',
    minWidth: 180,
  },
  {
    field: 'endDate',
    title: '交接完成日期',
    minWidth: 180,
  },
  {
    field: 'transferor',
    title: '移交人',
    minWidth: 120,
  },
  {
    field: 'receiver',
    title: '接收人',
    minWidth: 120,
  },
  {
    field: 'supervisor',
    title: '监交人',
    minWidth: 120,
  },
  {
    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: 'status',
    label: '状态',
    componentProps: {
      placeholder: '请选择状态',
      options: [
        { label: '待接收', value: '待接收' },
        { label: '接收中', value: '接收中' },
        { label: '已完成', value: '已完成' },
      ],
    },
    rules: 'required',
  },
  {
    component: 'Select',
    fieldName: 'district',
    label: '片区',
    componentProps: {
      placeholder: '请选择片区',
      options: [
        { label: '华东片区', value: '华东片区' },
        { label: '华南片区', value: '华南片区' },
        { label: '华北片区', value: '华北片区' },
        { label: '华西片区', value: '华西片区' },
      ],
    },
    rules: 'required',
  },
  {
    component: 'Select',
    fieldName: 'stationName',
    label: '交接油站',
    componentProps: {
      placeholder: '请选择交接油站',
      options: [
        { label: '油站1', value: '油站1' },
        { label: '油站2', value: '油站2' },
        { label: '油站3', value: '油站3' },
        { label: '油站4', value: '油站4' },
      ],
    },
    rules: 'required',
  },
  {
    component: 'DatePicker',
    fieldName: 'startDate',
    label: '交接开始日期',
    componentProps: {
      placeholder: '请选择交接开始日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
    rules: 'required',
  },
  {
    component: 'DatePicker',
    fieldName: 'endDate',
    label: '交接完成日期',
    componentProps: {
      placeholder: '请选择交接完成日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    component: 'Input',
    fieldName: 'transferor',
    label: '移交人',
    componentProps: {
      placeholder: '请输入移交人',
      maxlength: 50,
    },
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'receiver',
    label: '接收人',
    componentProps: {
      placeholder: '请输入接收人',
      maxlength: 50,
    },
  },
  {
    component: 'Input',
    fieldName: 'supervisor',
    label: '监交人',
    componentProps: {
      placeholder: '请输入监交人',
      maxlength: 50,
    },
  },
];
