import type { ActionOptions } from '@/components/DropDownButtons/type';
import { BasicTableProps } from '@/components/VxeTable';
import { EditType } from '@/type/BaseEnum';
import timeFiltering from '@/utils/timeFiltering';
import { Edit, View } from "@element-plus/icons-vue";
import { reactive } from 'vue';

/**
 * 费用审批表格配置
 * @returns 
 */
function useCustomerFeeApprovalModel() {
    const customerFeeApprovalListOptions = reactive<BasicTableProps>({
        id: 'customerfeeapproval_list_table',
        border: true,
        keepSource: true,
        showOverflow: true,
        height: 520,
        loading: false,
        stripe: true,
        rowConfig: { isHover: true, keyField: '_id' },
        columnConfig: { resizable: true },
        columns: [
            { type: "seq", title: '序号', width: 65 },
            { field: 'feeSetName', title: '费用名称', minWidth: 120 },
            { field: 'productName', title: '产品名称', minWidth: 120 },
            { field: 'salesmanName', title: '业务员', minWidth: 100 },
            { 
                field: 'beginDate', 
                title: '生效起始时间', 
                minWidth: 110,  
                formatter: ({ row }) => {
                    return timeFiltering(row.createTime)
                }
            },
            { 
                field: 'endDate', 
                title: '生效结束时间', 
                minWidth: 110,  
                formatter: ({ row }) => {
                    return timeFiltering(row.createTime)
                }
            },
            { field: 'createTime', title: '提交时间', minWidth: 130 },
            { field: 'approvalUserName', title: '当前审批人员', minWidth: 120 },
            { field: 'feeApprovalStatusName', title: '当前审批状态', minWidth: 120, slots: { default: 'feeApprovalStatusName'} },
            { field: 'approvalTimeStr', title: '审批时间', minWidth: 135 },
            { title: '操作', slots: { default: 'actions' }, width: 135, fixed: 'right' }
        ],
        data: []
    })

    // 操作类别
    const customerFeeApprovalListActionOptions: ActionOptions[] = [
        {
            value: EditType.APPROVE,
            label: "审批",
            type: "primary",
            icon: Edit,
            permissions: ['sys:customerFeeApproval:approval']
        },
        {
            value: EditType.VIEW,
            label: "查看",
            type: "success",
            icon: View,
            permissions: ['sys:customerFeeApproval:search']
        }
    ]


    return {
        customerFeeApprovalListOptions,
        customerFeeApprovalListActionOptions
    }
}

export {
    useCustomerFeeApprovalModel
}
