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

/**
 * 财务应付明细
 * @returns 
 */
function useFinancialBillDetailListModel() {
    // 财务应付明细列表配置
    const financialBillDetailListOptions = reactive<BasicTableProps>({
        id: 'financial_billDetailList_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: 'feeItemCategoryName', title: '费项类型', minWidth: 110 },
            { field: 'stakeholderName', title: '所属主体', minWidth: 110 },
            {
                field: 'billTime',
                title: '账单时间',
                minWidth: 110,
                formatter: ({ row }) => {
                    return timeFiltering(row.billTime)
                }
            },
            { field: 'providerName', title: '渠道商', minWidth: 110 },
            { field: 'feeItemName', title: '费用名称', minWidth: 110 },
            { field: 'feeTypeNamePostfix', title: '名称后缀', minWidth: 110 },
            { field: 'currencyCode', title: '币种', minWidth: 90 },
            { field: 'offerPrice', title: '单价', minWidth: 90 },
            { field: 'originalFee', title: '原币', minWidth: 100 },
            { field: 'rateVersion', title: '汇率版本', minWidth: 110 },
            { field: 'exchangeRate', title: '汇率', minWidth: 90 },
            { field: 'fee', title: '费用', minWidth: 90 },
            { field: 'shareTypeName', title: '分摊方式', minWidth: 110 },
            { field: 'groupShareTypeName', title: '分组分摊方式', minWidth: 140 },
            { field: 'accountType', title: '账目类型', minWidth: 110, slots: { default: 'accountType' } },
            { field: 'airlinesName', title: '航空公司', minWidth: 110 },
            { field: 'groupCode', title: '分组编号', minWidth: 110, slots: { header: 'groupCode' } },
            { field: 'waybillNumber', title: '提单号', minWidth: 100 },
            { field: 'orderId', title: '订单号', minWidth: 110 },
            { field: 'trackingId', title: '尾程单号', minWidth: 110 },
            { field: 'countryName', title: '国家/地区', minWidth: 110 },
            { field: 'departurePortName', title: '起始港', minWidth: 100 },
            { field: 'destinationPortName', title: '目的港', minWidth: 100 },
            { field: 'zipCode', title: '邮编', minWidth: 90 },
            { field: 'address', title: '地址', minWidth: 100 },
            { field: 'partitionName', title: '区间名称', minWidth: 110 },
            { field: 'weight', title: '重量', minWidth: 90 },
            { field: 'countFeeWeight', title: '计费重量', minWidth: 110 },
            { field: 'calculateUnitName', title: '重量单位', minWidth: 110 },
            { field: 'orderPieces', title: '件数', minWidth: 90 },
            { field: 'volume', title: '体积', minWidth: 90 },
            { field: 'length', title: '长', minWidth: 80 },
            { field: 'width', title: '宽', minWidth: 80 },
            { field: 'height', title: '高', minWidth: 80 },
            { field: 'billDetailStateName', title: '状态', minWidth: 90 },
            { title: '操作', slots: { default: 'actions' }, width: 135, fixed: 'right' }
        ],
        data: []
    })

    // TODO 权限字段暂未处理
    // 操作类别 
    const financialBillDetailActionOptions: ActionOptions[] = [
        {
            value: BaseFinancialBillDetailListActions.PREINSTALL,//状态
            label: "预设参考",//文本
            type: "info",//按钮样式
            icon: View,//按钮图标
            permissions: ['sys:financialBillDetail:save']
        },
        {
            value: BaseFinancialBillDetailListActions.EDIT,//状态
            label: "编辑",//文本
            type: "primary",//按钮样式
            icon: Plus,//按钮图标
            permissions: ['sys:financialBillDetail:save'],
            isDisabled: true
        },
        {
            value: BaseFinancialBillDetailListActions.DELETE,
            label: "删除",
            type: "danger",
            icon: Delete,
            permissions: ['sys:financialBillDetail:delete'],
            isDisabled: true
        },
    ]

    return {
        financialBillDetailListOptions,
        financialBillDetailActionOptions
    }
}

export {
    useFinancialBillDetailListModel
}