import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { h } from 'vue';
import { ElInputNumber } from 'element-plus';

export const queryFormSchema: FormSchemaGetter = () => [
  {
    component: 'Select',
    fieldName: 'station',
    label: '油站',
    componentProps: {
      placeholder: '请选择油站',
      options: [
        { label: '龙飞加油站', value: '龙飞加油站' },
        { label: '未来城加油站', value: '未来城加油站' },
        { label: '阳光加油站', value: '阳光加油站' },
        { label: '星光加油站', value: '星光加油站' },
        { label: '大地加油站', value: '大地加油站' },
      ],
    },
  },
  {
    component: 'Input',
    fieldName: 'taskName',
    label: '任务名称',
    componentProps: {
      placeholder: '请输入任务名称',
    },
  },
  {
    component: 'Space',
    fieldName: 'duration',
    label: '时长',
    renderComponentContent: (value: any, api: any) => {
        return {
          default: () => [
            h(ElInputNumber, {
              placeholder: '最小值',
              min: 0,
              max: 1000,
              style: { width: '50%' },
              modelValue: value.durationMin,
              'onUpdate:modelValue': (val: number) => api.setValue('durationMin', val),
            }),
            ' - ',
            h(ElInputNumber, {
              placeholder: '最大值',
              min: 0,
              max: 1000,
              style: { width: '50%' },
              modelValue: value.durationMax,
              'onUpdate:modelValue': (val: number) => api.setValue('durationMax', val),
            }),
          ],
        };
      },
  },
  {
    component: 'Input',
    fieldName: 'executor',
    label: '执行人',
    componentProps: {
      placeholder: '请输入执行人',
    },
  },
  {
    component: 'Select',
    fieldName: 'position',
    label: '岗位',
    componentProps: {
      placeholder: '请选择岗位',
      options: [
        { label: '油站经理', value: '油站经理' },
        { label: '当班组长', value: '当班组长' },
        { label: '站长', value: '站长' },
        { label: '营业员', value: '营业员' },
        { label: '安全员', value: '安全员' },
      ],
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'submitTime',
    label: '提交时间',
    componentProps: {
      type: 'daterange',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      startPlaceholder: '开始时间',
      endPlaceholder: '结束时间',
    },
  },
  {
    component: 'Select',
    fieldName: 'belowWarning',
    label: '低于预警时间',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '是', value: true },
        { label: '否', value: false },
      ],
    },
  },
];



export const tableColumns: VxeGridProps['columns'] = [
  {
    field: 'taskName',
    title: '任务名称',
    minWidth: 180,
  },
  {
    field: 'station',
    title: '油站',
    minWidth: 120,
  },
  {
    field: 'executor',
    title: '执行人',
    minWidth: 120,
  },
  {
    field: 'position',
    title: '岗位',
    minWidth: 120,
  },
  {
    field: 'startProcessingTime',
    title: '开始处理时间',
    minWidth: 200,
  },
  {
    field: 'submitTime',
    title: '提交时间',
    minWidth: 200,
  },
  {
    field: 'duration',
    title: '时长/分',
    minWidth: 100,
    align: 'center',
  },
  {
    field: 'belowWarning',
    title: '低于预警时间',
    minWidth: 120,
    align: 'center',
    formatter: (cellValue: boolean) => {
      return cellValue ? '是' : '否';
    },
  },

];
