
import { ActionOptions } from '@/components/DropDownButtons/type';
import type { BasicTableProps, VxeGridInstance } from '@/components/VxeTable';
import { AccountPeriodType } from '@/type/BaseEnum';
import { Edit, Delete, Odometer, Refresh } from "@element-plus/icons-vue";
import { ref, reactive } from 'vue';

/**
 * 账期列表表格配置
 * @returns 
 */
function useAccountPeriodModel() {
    // vxe-table ref
    const accountPeriodTableRef = ref<VxeGridInstance>();
    // 基础数据
    const accountPeriodGridOptions = reactive<BasicTableProps>({
        id: 'account_period_table',
        border: true,
        keepSource: true,
        showOverflow: true,
        height: 520,
        loading: false,
        columnConfig: {
            resizable: true
        },
        columns: [
            { field: 'customerName', title: '客户名称', minWidth: 160 },
            { field: 'accountPeriodName', title: '账期类型', minWidth: 130 },
            { field: 'accountingPeriodLimit', title: '账期额度', minWidth: 120 },
            { field: 'checkoutTypesName', title: '结账类型', minWidth: 120 },
            { field: 'checkoutDays', title: '结账天数', minWidth: 120 },
            { field: 'deleteFlag', title: '状态', width: 110, slots: { default: 'deleteFlag' } },
            { field: 'createUserName', title: '创建人', minWidth: 120 },
            { title: '操作', slots: { default: 'actions' }, width: 130, fixed: "right" },
        ],
        data: []
    })
    // 操作类别
    const actionOptions: ActionOptions[] = [
        {
            value: AccountPeriodType.EDIT,//状态
            label: "编辑",//文本
            type: "primary",//按钮样式
            icon: Edit,//按钮图标
            permissions: ['sys:accountPeriod:edit'],
            isDisabled: true
        },
        // {
        //     value: AccountPeriodType.DELETE,
        //     label: "删除",
        //     type: "danger",
        //     icon: Delete,
        //     permissions: ['sys:accountPeriod:delete'],
        //     isDisabled: true
        // },
        {
            value: AccountPeriodType.VIEW,
            label: "查看",
            color: "#01aee6",
            icon: Odometer,
            permissions: ['sys:accountPeriod:edit'],
        },
        {
            value: AccountPeriodType.FEESET_ACTIVE,
            label: "启用",
            islabel: "停用",
            color: "#F9961B",
            type: "primary",
            icon: Refresh,
            permissions: ['sys:accountPeriod:edit'],
            isDisabled: true
        }
    ]

    return {
        accountPeriodTableRef,
        accountPeriodGridOptions,
        actionOptions
    }
}

export {
    useAccountPeriodModel
}