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

export const queryFormSchema: FormSchemaGetter = () => [
  {
    component: 'Select',
    fieldName: 'area',
    label: '片区',
    componentProps: {
      placeholder: '请选择片区',
      options: [
        { label: '片区1', value: 'area1' },
        { label: '片区2', value: 'area2' },
        { label: '片区3', value: 'area3' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'station',
    label: '油站',
    componentProps: {
      placeholder: '请选择油站',
      options: [
        { label: '油站1', value: 'station1' },
        { label: '油站2', value: 'station2' },
        { label: '油站3', value: 'station3' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'status',
    label: '完成状态',
    componentProps: {
      placeholder: '请选择完成状态',
      options: [
        { label: '按时完成', value: 'onTime' },
        { label: '逾期完成', value: 'overdue' },
      ],
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'handleTime',
    label: '处理时间',
    componentProps: {
      placeholder: '请选择处理时间',
      type: 'date',
    },
  },
  {
    component: 'Select',
    fieldName: 'position',
    label: '岗位',
    componentProps: {
      placeholder: '请选择岗位',
      options: [
        { label: '站长', value: 'manager' },
        { label: '营业员', value: 'clerk' },
        { label: '安全员', value: 'safety' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'comment',
    label: '评论',
    componentProps: {
      placeholder: '请选择评论状态',
      options: [
        { label: '未评', value: 'uncommented' },
        { label: '已评', value: 'commented' },
      ],
    },
  },
  {
    component: 'Select',
    fieldName: 'createType',
    label: '创建',
    componentProps: {
      placeholder: '请选择创建方式',
      options: [
        { label: '系统', value: 'system' },
        { label: '新增', value: 'manual' },
      ],
    },
  },
  {
    component: 'Input',
    fieldName: 'executor',
    label: '执行人',
    componentProps: {
      placeholder: '请输入执行人',
    },
  },
  {
    component: 'Input',
    fieldName: 'taskName',
    label: '任务名称',
    componentProps: {
      placeholder: '请输入任务名称',
    },
  },
];

export const tableColumns: VxeGridProps['columns'] = [
  {
    type: 'checkbox',
    width: 80,
  },
  {
    field: 'taskName',
    title: '任务名称',
    minWidth: 150,
  },
  {
    field: 'station',
    title: '油站',
    minWidth: 120,
  },
  {
    field: 'executor',
    title: '执行人',
    minWidth: 120,
  },
  {
    field: 'position',
    title: '岗位',
    minWidth: 120,
    formatter: (cellValue: string) => {
      return cellValue === 'manager' ? '站长' : cellValue === 'clerk' ? '营业员' : '安全员';
    },
  },
  {
    field: 'comment',
    title: '评论',
    minWidth: 100,
    align: 'center',
    formatter: (cellValue: string) => {
      return cellValue === 'commented' ? '已评' : '未评';
    },
  },
  {
    field: 'deadline',
    title: '截止时间',
    minWidth: 180,
  },
  {
    field: 'handleTime',
    title: '处理时间',
    minWidth: 180,
  },
  {
    field: 'status',
    title: '完成状态',
    minWidth: 120,
    align: 'center',
    formatter: (cellValue: string) => {
      return cellValue === 'onTime' ? '按时完成' : '逾期完成';
    },
  },
  {
    field: 'createType',
    title: '创建',
    minWidth: 100,
    align: 'center',
    formatter: (cellValue: string) => {
      return cellValue === 'system' ? '系统' : '新增';
    },
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 150,
  },
];
