import { ActionOptions } from '@/components/DropDownButtons/type';
import type { BasicTableProps } from '@/components/VxeTable';
import { BaseFinancialFinancialBillList } from '@/type/BaseFinancial';
import timeFiltering from '@/utils/timeFiltering';
import { Delete, Connection, View, Filter, Edit } from "@element-plus/icons-vue";
import { reactive } from 'vue';

function useFinancialBillListModel() {
    // 财务应付账单
    const financialBillListOptions = reactive<BasicTableProps>({
        id: 'financial_billList_table',
        border: true,
        keepSource: true,
        showOverflow: true,
        height: 520,
        loading: false,
        stripe: true,
        rowConfig: { isHover: true, keyField: 'id' },
        columnConfig: { resizable: true },
        toolbarConfig: { custom: true },
        columns: [
            { type: "seq", title: '序号', width: 65 },
            { field: 'billCode', title: '账单编号', minWidth: 110 },
            { field: 'billName', title: '账单名称', minWidth: 110 },
            // { field: 'feeItemCategoryName', title: '费项类型', minWidth: 110 },
            { field: 'providerName', title: '渠道商', minWidth: 110 },
            // { field: 'uploadFileName', title: '上传文件', minWidth: 150, slots: { default: 'uploadFileName' } },
            { field: 'originalFileName', title: '原始文件', minWidth: 180, slots: { default: 'originalFileName' } },
            {
                field: 'billTime',
                title: '账单时间',
                minWidth: 110,
                formatter: ({ row }) => {
                    return timeFiltering(row.billTime)
                }
            },
            {
                field: 'belongTime',
                title: '归账时间',
                minWidth: 110,
                formatter: ({ row }) => {
                    return timeFiltering(row.belongTime)
                }
            },
            { field: 'billStateName', title: '账单状态', minWidth: 90 },
            { field: 'verifyStateName', title: '核账状态', minWidth: 90 },
            { field: 'remark', title: '备注', minWidth: 120 },
            {
                field: 'createTime',
                title: '上传时间',
                minWidth: 110,
                formatter: ({ row }) => {
                    return timeFiltering(row.createTime)
                }
            },
            { field: 'createUserName', title: '操作员', minWidth: 110 },
            { title: '操作', slots: { default: 'actions' }, width: 135, fixed: 'right' }
        ],
        data: []
    })

    // 操作类别 
    const financialBillListActionOptions: ActionOptions[] = [
        {
            value: BaseFinancialFinancialBillList.BILL_EDIT,
            label: "账单编辑",
            icon: Edit,
            color: "#02ABE8",
            isDisabled: true,
            permissions: ['sys:financialBillSummary:edit']
        },
        {
            value: BaseFinancialFinancialBillList.BILL_DETAILS,//状态
            label: "账单明细",//文本
            type: "primary",//按钮样式
            icon: View,//按钮图标
            permissions: ['sys:financialBillSummary:add']
        },
        {
            value: BaseFinancialFinancialBillList.BILL_DELETE,
            label: "删除账单",
            type: "danger",
            icon: Delete,
            isDisabled: true,
            permissions: ['sys:financialBillSummary:delete']
        },
        {
            value: BaseFinancialFinancialBillList.BILL_AUDIT_ACCOUNTS,
            label: "账单核账",
            icon: Filter,
            color: "#7D7BEA",
            permissions: ['sys:financialBillSummary:edit']
        },
        {
            value: BaseFinancialFinancialBillList.BILL_ALLOCATION,
            label: "账单分摊",
            type: "success",
            icon: Filter,
            permissions: ['sys:financialBillSummary:edit']
        },
        {
            value: BaseFinancialFinancialBillList.BILL_CORRELATION,
            label: "账单关账",
            type: "info",
            icon: Connection,
            permissions: ['sys:financialBillSummary:updateState']
        },
    ]

    return {
        financialBillListOptions,
        financialBillListActionOptions
    }
}

export { useFinancialBillListModel }