import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';
import {
  selectAllSysAreaList,
  selectAllSysStationAreaList,
} from '#/api/system/infoEntry/stationInfo/stationInfo';
import { getPostList } from '#/api/system/post/post';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'ApiSelect',
    componentProps: {
      api: selectAllSysAreaList,
      labelField: 'areaName',
      valueField: 'id',
      placeholder: '请选择片区',
      clearable: true,
    },
    fieldName: 'areaId',
    label: '片区',
  },
  {
    component: 'ApiSelect',
    componentProps: {
      api: selectAllSysStationAreaList,
      labelField: 'stationName',
      valueField: 'id',
      placeholder: '请选择油站',
      clearable: true,
    },
    fieldName: 'stationId',
    label: '油站',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入任务名称',
      clearable: true,
    },
    fieldName: 'taskName',
    label: '任务名称',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入执行人',
      clearable: true,
    },
    fieldName: 'executorName',
    label: '执行人',
  },
  {
    component: 'ApiSelect',
    componentProps: {
      api: getPostList,
      labelField: 'postName',
      valueField: 'postId',
      placeholder: '请选择岗位名称',
      resultField: 'rows',
      clearable: true,
    },
    fieldName: 'executePosition',
    label: '岗位名称',
  },
  {
    component: 'Select',
    componentProps: {
      options: [
        { label: '未开始取消', value: '0' },
        { label: '待处理', value: '1' },
        { label: '任务过期未完成', value: '2' },
        { label: '任务已完成', value: '3' },
      ],
      clearable: true,
    },
    fieldName: 'status',
    label: '任务状态',
  },
  {
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: '1' },
        { label: '否', value: '0' },
      ],
      clearable: true,
    },
    fieldName: 'isLicensable',
    label: '是否可授权',
  },
  {
    component: 'Select',
    componentProps: {
      options: [
        { label: '未授权', value: '0' },
        { label: '已授权', value: '1' },
        { label: '被授权', value: '2' },
      ],
      clearable: true,
    },
    fieldName: 'authStatus',
    label: '授权状态',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入任务负责人',
      clearable: true,
    },
    fieldName: 'taskLeader',
    label: '任务负责人',
  },
  {
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.TASK_TYPE),
    },
    fieldName: 'taskType',
    clearable: true,
    label: '任务类型',
  },
  {
    component: 'DatePicker',
    componentProps: {
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择创建时间',
    },
    fieldName: 'createTime',
    label: '创建时间',
  },
  {
    component: 'DatePicker',
    componentProps: {
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择操作时间',
    },
    fieldName: 'operateTime',
    label: '操作时间',
  },
  {
    component: 'DatePicker',
    componentProps: {
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择失效时间',
    },
    fieldName: 'expireTime',
    label: '失效时间',
  },
];
export const columns: VxeGridProps['columns'] = [
  // {
  //   type: 'checkbox',
  //   width: 60,
  // },
  // {
  //   type: 'seq',
  //   title: '序号',
  //   // fixed: 'left',
  //   width: 70,
  // },
  {
    field: 'action',
    fixed: 'left',
    slots: { default: 'action' },
    resizable: false,
    title: '操作',
    width: 180,
  },
  {
    title: '任务名称',
    field: 'taskName',
    minWidth: 130,
  },
  {
    title: '任务类型',
    field: 'taskType',
    minWidth: 130,
    slots: { default: 'taskType' },
  },
  {
    title: '是否可授权',
    field: 'isLicensable',
    slots: { default: 'isLicensable' },
    minWidth: 130,
  },
  {
    title: '授权状态',
    field: 'authStatus',
    minWidth: 130,
    slots: { default: 'authStatus' },
  },
  {
    title: '执行人',
    field: 'executorName',
    minWidth: 130,
  },
  {
    title: '岗位名称',
    field: 'executePositionName',
    minWidth: 130,
  },
  {
    title: '油站',
    field: 'stationName',
    minWidth: 130,
  },
  {
    title: '失效时间',
    field: 'expirationTime',
    minWidth: 130,
  },
  {
    title: '操作时间',
    field: 'updateTime',
    minWidth: 130,
  },
  {
    title: '任务状态',
    field: 'status',
    minWidth: 130,
    slots: { default: 'status' },
  },
  {
    title: '创建时间',
    field: 'createTime',
    minWidth: 130,
  },
  {
    title: '任务负责人',
    field: 'TaskLeader',
    minWidth: 130,
  },
  {
    title: '片区',
    field: 'areaIdName',
    minWidth: 130,
  },
];
