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: '评价体系名称',
            prop: 'valuationConfigurationName',
            type: 'input',
            value: ''
        },
        
        {
            title: '评价年度',
            prop: 'assessmentYear',
            type: 'date',
            dateOption: {
                type: 'year',
                format: 'YYYY',
                valueFormat: 'YYYY',
            },
            span: 4,
            value: ''
        }
    ]
    const fixedOptionList: IOption[] = [
        {
            title: '我的客户',
            prop: 'enterpriseName',
            type: 'input',
            span: 4,
            value: ''
        },
        {
            title: '评价类型',
            prop: 'assessmentType',
            type: 'select',
            options: [
                { name: '年度评价', value: '3' },
                { name: '季度评价', value: '2' },
                { name: '月度评价', value: '1' }
            ],
            value: '',
            span: 4
        },
        {
            title: '评价等级',
            prop: 'er.LEVEL_',
            type: 'select',
            options: [
                { name: '优秀', value: '1' },
                { name: '良好', value: '2' },
                { name: '合格', value: '3' },
                { name: '可改善', value: '4' },
                { name: '不合格', value: '5' }
            ],
            value: '',
            span: 4
        }
    ]
    const columnsList: COption[] = [
        {
            title: '我的客户',
            prop: 'enterpriseName',
            minWidth: 180,
            sortable: true
        },
        {
            title: '评价体系名称',
            prop: 'valuationConfigurationName',
            minWidth: 120,
            sortable: true
        },
        {
            title: '评价年度',
            prop: 'assessmentYear',
            minWidth: 120,
            render: true,
            sortable: true
        },
        {
            title: '评价类型',
            prop: 'assessmentType',
            minWidth: 120,
            render: true,
            sortable: true
        },
        {
            title: '评价周期',
            prop: 'assessment',
            minWidth: 120,
            render: true,
            sortable: true
        },
        {
            title: '评价等级',
            prop: 'level',
            minWidth: 120,
            render: true,
            sortable: true
        },
        {
            title: '评价结论',
            prop: 'assessmentResult',
            minWidth: 120,
            sortable: true
        }
    ]
    return {
        customOptionList,
        fixedOptionList,
        columnsList
    }
}
