import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { selectAllSysAreaList,selectAllSysStationAreaList } from '#/api/system/infoEntry/stationInfo/stationInfo';

export const queryFormSchema: FormSchemaGetter = () => [
 {
     component: 'ApiSelect',
     fieldName: 'areaId',
     label: '所属片区',
     componentProps: {
       placeholder: '请选择所属片区',
       clearable: true,
       api: async () => {
         const resp = await selectAllSysAreaList();
         const data = resp || [];
         return Array.isArray(data)
           ? data.map((item: any) => ({
               label: item.areaName,
               value: item.id,
             }))
           : [];
       },
       labelField: 'label',
       valueField: 'value',
     },
   },
  {
      component: 'ApiSelect',
      fieldName: 'stationId',
      label: '油站',
      componentProps: {
        placeholder: '请选择油站',
        api: async () => {
          const resp = await selectAllSysStationAreaList();
          const data = resp || [];
          return Array.isArray(data)
            ? data.map((item: any) => ({
                label: item.stationName,
                value: item.id.toString(),
              }))
            : [];
        },
      },
    },
  // {
  //   component: 'Input',
  //   fieldName: 'transferPerson',
  //   label: '移交人',
  //   componentProps: {
  //     placeholder: '请输入移交人ID',
  //   },
  // },
  // {
  //   component: 'Input',
  //   fieldName: 'receiver',
  //   label: '接收人',
  //   componentProps: {
  //     placeholder: '请输入接收人ID',
  //   },
  // },
  // {
  //   component: 'Input',
  //   fieldName: 'supervisor',
  //   label: '监交人',
  //   componentProps: {
  //     placeholder: '请输入监交人ID',
  //   },
  // },
  {
    component: 'DatePicker',
    fieldName: 'startHandoverStartTime',
    label: '交接开始',
     componentProps: {
      placeholder: '请选择交接开始日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      style:{
        width:'100%'
      }
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'startHandoverEndTime',
    label: '交接开始',
    componentProps: {
      placeholder: '请选择交接开始结束日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      style:{
        width:'100%'
      }
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'handoverStartTime',
    label: '交接完成',
     componentProps: {
      placeholder: '请选择交接完成日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      style:{
        width:'100%'
      }
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'handoverEndTime',
    label: '交接完成',
     componentProps: {
      placeholder: '请选择交接完成日期',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      style:{
        width:'100%'
      }
    },
  },
];

export const tableColumns: VxeGridProps['columns'] = [
  {
    type: 'checkbox',
    width: 80,
  },
  {
    field: 'areaIdName',
    title: '片区',
    minWidth: 120,
  },
  {
    field: 'stationName',
    title: '交接油站',
    minWidth: 120,
  },
  {
    field: 'handoverStartTime',
    title: '交接开始日期',
    minWidth: 180,
  },
  {
    field: 'handoverEndTime',
    title: '交接完成日期',
    minWidth: 180,
  },
  {
    field: 'transferPersonName',
    title: '移交人',
    minWidth: 120,
  },
  {
    field: 'receiverName',
    title: '接收人',
    minWidth: 120,
  },
  {
    field: 'supervisorName',
    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: 'InputNumber',
    fieldName: 'areaId',
    label: '片区',
    componentProps: {
      placeholder: '请输入片区ID',
      min: 1,
    },
  },
  {
    component: 'InputNumber',
    fieldName: 'stationId',
    label: '油站',
    componentProps: {
      placeholder: '请输入油站ID',
      min: 1,
    },
    rules: 'required',
  },
  {
    component: 'InputNumber',
    fieldName: 'transferPerson',
    label: '移交人',
    componentProps: {
      placeholder: '请输入移交人ID',
      min: 1,
    },
    rules: 'required',
  },
  {
    component: 'InputNumber',
    fieldName: 'receiver',
    label: '接收人',
    componentProps: {
      placeholder: '请输入接收人ID',
      min: 1,
    },
    rules: 'required',
  },
  {
    component: 'InputNumber',
    fieldName: 'supervisor',
    label: '监交人',
    componentProps: {
      placeholder: '请输入监交人ID',
      min: 1,
    },
    rules: 'required',
  },
  {
    component: 'DatePicker',
    fieldName: 'handoverStartTime',
    label: '交接开始时间',
    componentProps: {
      placeholder: '请选择交接开始时间',
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    rules: 'required',
  },
  {
    component: 'DatePicker',
    fieldName: 'handoverEndTime',
    label: '交接完成时间',
    componentProps: {
      placeholder: '请选择交接完成时间',
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    component: 'Select',
    fieldName: 'delFlag',
    label: '删除标志',
    componentProps: {
      placeholder: '请选择删除标志',
      options: [
        { label: '正常', value: 0 },
        { label: '删除', value: 1 },
      ],
    },
  },
];

