import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'

// 表单校验
export const DeliTimeRules = reactive({
  code: [required],
  shift: [required],
  beginTime: [required],
  concurrencyStamp: [required],
})

export const DeliTimeWms = useCrudSchemas(reactive<CrudSchema[]>([
  {
    label: '编号',
    field: 'code',
    sort: 'custom',
    isSearch: true,
  },
  {
    label: '班次',
    field: 'shift',
    dictType: DICT_TYPE.SHIFT,
    dictClass: 'string',
    isTable: true,
    isDetail: true,
    sort: 'custom',
    table: {
      width: 150
    },
    isTableForm: true,
    tableForm: {
      type: 'Select'
    }
  },
  {
    label: '开始时间',
    field: 'beginTime',
    sort: 'custom',
    formatter: dateFormatter,
    isSearch: true,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    form: {
      component: 'DatePicker',
      componentProps: {
        type: 'datetime',
        valueFormat: 'x'
      }
    },
  },
  {
    label: '创建者',
    field: 'creator',
    sort: 'custom',
    table: {
      width: 150
    },
    isTable:true,
    isForm: false,
  },
  {
    label: '创建时间',
    field: 'createTime',
    formatter: dateFormatter,
    detail: {
      dateFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    sort: 'custom',
    table: {
      width: 180
    },
    isTable:true,
    form: {
      component: 'DatePicker',
      componentProps: {
        style: {width:'100%'},
        type: 'datetime',
        dateFormat: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      }
    },
    isForm: false,
    isSearch: true,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      },
    },

  },
  {
    label: '最后更新者',
    field: 'updater',
    sort: 'custom',
    table: {
      width: 150
    },
    isTable:true,
    isForm: false,
  },
  {
    label: '最后更新时间',
    field: 'updateTime',
    formatter: dateFormatter,
    detail: {
      dateFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    sort: 'custom',
    table: {
      width: 180
    },
    isTable:true,
    form: {
      component: 'DatePicker',
      componentProps: {
        style: {width:'100%'},
        type: 'datetime',
        dateFormat: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      }
    },
    isForm: false,
  },
  {
    label: '备注',
    field: 'remark',
    sort: 'custom',
    isSearch: true,
  },
  {
    label: '操作',
    field: 'action',
    isForm: false,
    table: {
      width: 150,
      fixed: 'right'
    }
  }
]))