import { dictionaryEscape, getDictionaryByCode } from '@/utils/dictionary'

interface IOption {
    title: string
    prop: string
    type: string
    value: any
    span?: number
    dateOption?: any
    options?: any[]
    queryHandler?: any
    placeholder?: string
    allowCreate?: boolean
    number?: boolean
    minWidth?: number

    [key: string]: any
}

interface COption {
    title: string
    prop: string
    minWidth: number
    render?: boolean
    formatter?: any
    sortable?: boolean

    [key: string]: any
}

interface TableOptions {
    categoryChange: () => Promise<void>
}

export function useTableOptionConfig({ categoryChange }: TableOptions) {
    const customOptionList: IOption[] = [
        {
            title: '文件限制大小(MB)',
            prop: 'limitFileSize',
            type: 'input',
            value: ''
        },
    ]
    const fixedOptionList: IOption[] = [
        {
            title: '资质类型名称',
            prop: 'qualificationCategoryName',
            type: 'input',
            span: 4,
            value: ''
        },
        {
            title: '资质类型编码',
            prop: 'qualificationCategoryCode',
            type: 'input',
            value: '',
            span: 4
        },
        {
            title: '启用/禁用',
            prop: 'status',
            type: 'select',
            options: [
                { name: '禁用', value: '0' },
                { name: '启用', value: '1' }
            ],
            value: '',
            span: 4
        },
        {
            title: '创建时间',
            prop: 'createTime',
            type: 'date',
            dateOption: {
                type: 'datetimerange',
                format: 'YYYY-MM-DD HH:mm:ss',
                valueFormat: 'YYYY-MM-DD HH:mm:ss',
                defaultTime: [new Date(0, 0, 0, 0, 0, 0), new Date(0, 0, 0, 23, 59, 59)]
            },
            span: 6,
            value: []
        }
    ]
    const columnsList: COption[] = [
        {
            title: '资质类型名称',
            prop: 'qualificationCategoryName',
            minWidth: 160,
            sortable: true
        },
        {
            title: '资质类型编码',
            prop: 'qualificationCategoryCode',
            minWidth: 100,
            sortable: true
        },
        {
            title: '文件限制大小(MB)',
            prop: 'limitFileSize',
            minWidth: 200,
            sortable: true
        },
        {
            title: '备注',
            prop: 'remarks',
            minWidth: 120,
            sortable: true
        },
        {
            title: '启用/禁用',
            prop: 'status',
            minWidth: 120,
            sortable: true,
            render: true
        },
        {
            title: '创建时间',
            prop: 'createTime',
            minWidth: 120,
            sortable: true
        }
    ]
    return {
        customOptionList,
        fixedOptionList,
        columnsList
    }
}
