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

// 表单校验
export const TeamSettingRules = reactive({
  endTime: [required],
  concurrencyStamp: [required],
})

export const TeamSetting = useCrudSchemas(reactive<CrudSchema[]>([
  {
    label: 'id',
    field: 'id',
    sort: 'custom',
    isForm: false,
  },
  {
    label: '班组编号',
    field: 'teamCode',
    sort: 'custom',
    isSearch: true,
  },
  {
    label: '班组名称',
    field: 'teamName',
    sort: 'custom',
    isSearch: true,
  },
  {
    label: '班组类型',
    field: 'teamType',
    sort: 'custom',
    isSearch: true,
                // form: {
                //   component: 'SelectV2'
                // },
  },
  {
    label: '结束时间',
    field: 'endTime',
    sort: 'custom',
    formatter: dateFormatter,
    isSearch: false,
    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: 'textOne',
    sort: 'custom',
    isSearch: false,
  },
  {
    label: '备用字段二',
    field: 'textTwo',
    sort: 'custom',
    isSearch: false,
  },
  {
    label: '备用字段三',
    field: 'textThree',
    sort: 'custom',
    isSearch: false,
  },
  {
    label: '备用字段四',
    field: 'textFour',
    sort: 'custom',
    isSearch: false,
  },
  {
    label: '备用字段五',
    field: 'textFive',
    sort: 'custom',
    isSearch: false,
  },
  {
    label: '删除时间',
    field: 'deleteTime',
    sort: 'custom',
    formatter: dateFormatter,
    isSearch: false,
    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: 'status',
    sort: 'custom',
    isSearch: false,
    form: {
      component: 'Radio'
    },
  },
  {
    label: '并发乐观锁',
    field: 'concurrencyStamp',
    sort: 'custom',
    isSearch: false,
    form: {
      component: 'InputNumber',
      value: 0
    },
  },
  {
    label: '备注',
    field: 'remark',
    sort: 'custom',
    isSearch: false,
  },
  {
    label: '创建时间',
    field: 'createTime',
    sort: 'custom',
    formatter: dateFormatter,
    isSearch: false,
    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')]
      }
    },
    isForm: false,
  },
  {
    label: '删除用户名',
    field: 'deleter',
    sort: 'custom',
    isSearch: false,
  },
  {
    label: '位置ID',
    field: 'siteId',
    sort: 'custom',
    isSearch: false,
    form: {
      component: 'InputNumber',
      value: 0
    },
  },
  {
    label: '操作',
    field: 'action',
    isForm: false,
    table: {
      width: 150,
      fixed: 'right'
    }
  }
]))