import type { BasicTableProps, VxeGridInstance, VxeTablePropTypes } from '@/components/VxeTable';
import { ActionOptions } from '@/components/DropDownButtons/type';
import { ref, reactive, unref, computed, onMounted, Ref, watch } from 'vue';
import { Plus, Delete, Setting, Upload, Document, Tickets, View } from "@element-plus/icons-vue";
import { BaseLadingActions, BaseLadingSearchActions } from '@/type/BaseLading';
import { validateCountType, validateFieldType } from '@/utils/feeSeting/validate';
import { useVxeGridHanleHooks } from '@/components/VxeTable/hooks';
import { useFeesetList } from '@/store/list_feeset';
import { useDropDownData } from '@/hooks/useDropDownData';
import { BaseFormula } from '@/type/BaseFormula';
import { isArrayLength, isNumber, isObject } from '@/utils/is';
import { BaseFeesetAction } from '@/type/BaseFeesetAction';
import { deal_FindItemName } from '@/utils/dealFindData';
import { fee_deal_FilterValidate } from '@/utils/feeSeting/dealData';
import { getVxeGridData } from '../business/feeModel/base/data';
import { TempFeeItemModelDto } from '@/api/receivable/receivableModel';
import { BillReceivableDto, LadingPayableStableFeeItemModelDto } from '@/api/lading/ladingModle';
import { useTemplateStore } from '@/store/template';
import { api_customerFeeGroupList, api_getReceivableModelData } from '@/api/lading/lading';
import { resCodeSuccess } from '@/utils/useReturnData';
import { BaseFeeSetType } from '@/type/BastType';
import timeFiltering from '@/utils/timeFiltering';
import { CustomerFeeList } from './common/useFeeDateVersionList';
import { BaseFeeSetProductBind } from '@/type/BaseLadingBill';

type ReceivableTableType = "temporary" | "product" | "closingCost"
/**
 * 提单列表基础数据
 */
function useLadingListModel() {
    // 提单列表配置
    const ladingListOptions = reactive<BasicTableProps>({
        id: 'lading_list_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: "checkbox", width: 45 },
            { field: 'waybillNumber', title: '提单号', minWidth: 90 },
            { field: 'bookingNumber', title: '订舱号', minWidth: 90 },
            { field: 'customerName', title: '客户', minWidth: 90 },
            { field: 'receivableWeight', title: '应收重量', minWidth: 120 },
            { field: 'receivableFee', title: '应收费用', minWidth: 120 },
            { field: 'payableWeight', title: '应付重量', minWidth: 120 },
            { field: 'payableFee', title: '应付费用', minWidth: 120 },
            { field: 'organizationFee', title: '结算费用', minWidth: 120 },
            { field: 'corporateProfits', title: '公司利润', minWidth: 120 },
            { field: 'salespersonProfit', title: '业务员利润', minWidth: 120 },
            { field: 'stakeholderName', title: '账单主体', minWidth: 120 },
            {
                field: 'bookingTime',
                title: '订舱时间',
                formatter: ({ row }) => {
                    return timeFiltering(row.bookingTime)
                },
                minWidth: 120
            },
            {
                field: 'takeOffTime',
                title: '预计起飞时间',
                formatter: ({ row }) => {
                    return timeFiltering(row.takeOffTime)
                },
                minWidth: 130
            },
            { field: 'bookingState', title: '订舱状态', minWidth: 120, slots: { default: 'default_bookingState' } },
            { field: 'operationalState', title: '操作状态', minWidth: 120, slots: { default: 'default_operationalState' } },
            { field: 'receivableState', title: '应收状态', minWidth: 120, slots: { default: 'default_receivableState' } },
            { field: 'payableState', title: '应付状态', minWidth: 120, slots: { default: 'default_payableState' } },
            { title: '操作', slots: { default: 'actions' }, width: 135, fixed: 'right' }
        ],
        data: []
    })

    // 操作类别
    const actionOptions: ActionOptions[] = [
        {
            value: BaseLadingActions.BILL_EDIT,//状态
            label: "编辑提单",//文本
            type: "primary",//按钮样式
            icon: Plus,//按钮图标
            permissions: ['sys:LadingBillMain:edit']
        },
        {
            value: BaseLadingActions.DELETE_BILL_LADING,
            label: "提单删除",
            type: "danger",
            icon: Delete,
            permissions: ['sys:ladingBillMain:delete']
        },
        {
            value: BaseLadingActions.EXPENSE_EDITOR,
            label: "费用编辑",
            color: "#0078f3",
            icon: Setting,
            permissions: ['sys:ladingBillFeeSet:edit'],
            isDisabled: true
        },
        {
            value: BaseLadingActions.COST_TRIAL_CALCULATION,
            label: "费用试算",
            type: "success",
            icon: Document,
            permissions: ['sys:ladingBillMoney:save']
        },
        {
            value: BaseLadingActions.FEESET_DETAILS,
            label: "费用明细",
            color: "#76AA9D",
            icon: Tickets,
            permissions: ['sys:ladingBillFeeSet:edit'],
        },
        // {
        //     value: BaseLadingActions.GROSS_PROFIT_DETAIL,
        //     label: "毛利明细",
        //     color: "#01aee6",
        //     icon: Upload,
        //     permissions: ['sys:ladingBillFeeSet:edit'],
        // },
        {
            value: BaseLadingActions.BILL_PREVIEW,
            label: "账单预览",
            color: "#42BC84",
            icon: View,
            permissions: ['sys:ladingBillMoney:customerBill'],
        },
    ]
    // 搜索按钮组
    const searchActionOptions: ActionOptions[] = [
        {
            value: BaseLadingSearchActions.IMPORT,
            label: "导入",
            color: "#01aee6",
            icon: Upload,
            permissions: ['sys:receivableModel:add', 'sys:receivableModel:edit'],
        },
        {
            value: BaseLadingSearchActions.STATUS_UPDATE,
            label: "状态更新",
            type: "success",
            icon: Setting,
            permissions: ['sys:receivableModel:add', 'sys:receivableModel:edit']
        },
    ]

    return {
        ladingListOptions,
        actionOptions,
        searchActionOptions
    }
}

/**
 * 提单费用明细列表
 * @returns 
 */
function useLadingBillMoneyListModel() {
    // 提单费用列表配置
    const ladingBillMoneyListOptions = reactive<BasicTableProps>({
        id: 'lading_billMoneyList_table',
        border: true,
        keepSource: true,
        showOverflow: true,
        height: 620,
        loading: false,
        stripe: true,
        rowConfig: { isHover: true, keyField: 'id' },
        columnConfig: { resizable: true },
        columns: [
            // { type: "seq", title: '序号', width: 65 },
            { field: 'waybillNumber', title: '提单号', minWidth: 110 },
            { field: 'bookingNumber', title: '订舱号', minWidth: 100 },
            { field: 'trackingId', title: '尾程单号', minWidth: 100 },
            { field: 'feeSetTypeName', title: '结算类型', minWidth: 110 },
            { field: 'providerName', title: '供应商', minWidth: 100 },
            { field: 'productName', title: '产品名称', minWidth: 110 },
            { field: 'feeItemCategoryName', title: '费项类型', minWidth: 90 },
            { field: 'feeWeight', title: '计费重量', minWidth: 110 },
            { field: 'currencyCode', title: '币种', minWidth: 90 },
            { field: 'originalFee', title: '原币费用', minWidth: 100 },
            { field: 'exchangeRate', title: '汇率', minWidth: 90 },
            { field: 'rateVersion', title: '汇率版本', minWidth: 90 },
            { field: 'fee', title: '费用', minWidth: 90 },
            { field: 'formulaDescription', title: '公式描述', minWidth: 150 },
            { title: '操作', slots: { default: 'default_actions' }, align: "center", width: 80, fixed: 'right' }
        ],
        data: []
    })

    return {
        ladingBillMoneyListOptions
    }
}

/**
 * 提单费用明细列表
 * @returns 
 */
function useLadingBillMoneyDetailListModel() {
    // 提单费用明细列表配置
    const ladingBillMoneyListOptions = reactive<BasicTableProps>({
        id: 'lading_billMoneyDetailList_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: 'providerName', title: '供应商', minWidth: 100 },
            { field: 'productName', title: '产品名称', minWidth: 100 },
            { field: 'feeItemCategoryName', title: '费项类型', minWidth: 120 },
            { field: 'feeItemName', title: '费用类型', minWidth: 120 },
            { field: 'feeWeight', title: '计费重量', minWidth: 120 },
            { field: 'currencyCode', title: '币种', minWidth: 90 },
            { field: 'originalFee', title: '原币费用', minWidth: 120 },
            { field: 'rate', title: '汇率', minWidth: 90 },
            { field: 'fee', title: '费用', minWidth: 90 },
        ],
        data: []
    })

    return {
        ladingBillMoneyListOptions
    }
}

/**
 * 提单费用设置、编辑
 */
function useLadingBillMoneySetModel(isLading = false, props?: Recordable) {
    // 下拉列表的value与label键
    const fieldsObj = {
        valueField: 'productId',
        labelField: 'feeSetName'
    }
    let timerCalculator
    // 查看费用设置
    const adCustomerFeeSetDetailRef = ref<{ show: Fn }>()
    // 公式计算
    const formulaModleRef = ref<{ show: Fn }>()
    // 临时费用设置 ref
    const xTemporaryFeeRef = ref<VxeGridInstance>()
    // 产品费用绑定 ref
    const xProductFeeRef = ref<VxeGridInstance>()
    // 结算费用绑定 ref
    const xClosingCostFeeRef = ref<VxeGridInstance>()
    const receivabState = reactive({
        referenceReceivableModelId: "",//参考应收模板编号
        dateVersionList: [] as CustomerFeeList[],//包含客户与结算的日期版本
    })
    // 模版列表
    const templateStore = useTemplateStore()
    // 费用设置列表stroe
    const storeFeesetList = useFeesetList()
    const feeItemCategoryList = computed(() => storeFeesetList.getFeeItemCategoryList)
    const {
        storeDropDownData,
        feeItemLists,
        productList,
        currencyList,
        specialFeeItemList
    } = useDropDownData()
    const countTypeList = computed(() => {
        return storeDropDownData.getCountTypeList.filter(
            item => {
                return isNumber(item.value) && item.value === 0//重量
                    || isNumber(item.value) && item.value === 1//按件
                    || isNumber(item.value) && item.value === 2//按单
                    || isNumber(item.value) && item.value === 8//体积
                    || isNumber(item.value) && item.value === 9//重量
            }
        )
    })
    // 临时费用设置列表-配置
    const temporaryFeeOptions = reactive<BasicTableProps>({
        id: 'lading_detail_table',
        border: true,
        keepSource: true,
        showOverflow: true,
        // height: 220,
        loading: false,
        stripe: true,
        rowConfig: { isHover: true, keyField: 'id_table' },
        editConfig: { trigger: 'click', mode: 'row', autoClear: false, showIcon: false, showAsterisk: false },
        cellStyle: { height: '38px', padding: 0 },
        columnConfig: { resizable: true },
        editRules: {
            feeItemCategoryId: [{ message: '请选择费项类型', validator: validateFieldType }],
            feeItemId: [{ message: '请选择费用类型', validator: validateFieldType }],
            productId: [{ message: '请选择产品名称', validator: validateFieldType }],
            countModel: [{ message: '请选择算法', validator: validateCountType }],
            countOrderNumber: [{ required: true, message: '请输入计算优先级' }],
            // parameter: [{ message: '请输入参数', validator: validateFieldType }],
            offerPrice: [{ required: true, message: '请输入价格' }],
            organizationOfferPrice: [{ required: true, message: '请输入结算价' }],
            currencyCode: [{ message: '请选择币种', validator: validateFieldType }],
            shareType: [{ message: '请选择分摊方式', validator: validateFieldType }],
        },
        columns: [
            // { type: "seq", width: 45 },
            { field: 'feeItemCategoryId', title: '费项类型', editRender: {}, slots: { default: 'default_feeItemCategory', edit: 'edit_feeItemCategory' }, minWidth: 120 },
            { field: 'feeItemId', title: '费用类型', editRender: {}, slots: { default: 'default_feeItemId', edit: 'edit_feeItemId' }, minWidth: 120 },
            { field: 'productId', title: '产品名称', editRender: {}, slots: { default: 'default_productId', edit: 'edit_productId' }, minWidth: 120 },
            { field: 'countModel', title: '算法', editRender: {}, slots: { default: 'default_countModel', edit: 'edit_countModel' }, minWidth: 120 },
            { field: 'countOrderNumber', title: '计算优先级', editRender: {}, slots: { edit: 'edit_countOrderNumber' }, minWidth: 80 },
            { field: 'parameter', title: '参数', editRender: {}, slots: { edit: 'edit_parameter' }, minWidth: 80 },
            { field: 'offerPrice', title: '价格', editRender: {}, slots: { edit: 'edit_price' }, minWidth: 80 },
            { field: 'organizationOfferPrice', title: '结算价', editRender: {}, slots: { edit: 'edit_discount' }, minWidth: 80 },
            { field: 'currencyCode', title: '币种', editRender: {}, slots: { default: 'default_currencyCode', edit: 'edit_currencyCode' }, minWidth: 100 },
            { title: '操作', slots: { header: "header_actions", default: 'default_actions' }, align: "center", width: 60, fixed: 'right' }
        ],
        data: []
    })
    // 产品费用绑定列表-配置
    const productFeeOptions = reactive<BasicTableProps>({
        id: 'product_fee_table',
        border: true,
        keepSource: true,
        showOverflow: true,
        // height: 210,
        loading: false,
        stripe: true,
        rowConfig: { isHover: true, keyField: 'id_table' },
        editConfig: { trigger: 'click', mode: 'row', autoClear: false, showIcon: false, showAsterisk: false },
        cellStyle: { height: '38px', padding: 0 },
        columnConfig: { resizable: true },
        editRules: {
            feeItemCategoryId: [{ message: '请选择费项类型', validator: validateFieldType }],
            productName: [{ message: '请选择产品名称', validator: validateFieldType }],
            // feeSetName: [{ message: '请选择费用名称', validator: validateFieldType }],
            dateVersion: [{ message: '请选择日期版本', validator: validateFieldType }],
        },
        columns: [
            { type: "seq", title: "序号", width: 65 },
            { field: 'feeItemCategoryId', title: '费项类型', editRender: {}, slots: { default: 'default_feeItemCategory', edit: 'edit_feeItemCategory' }, minWidth: 120 },
            { field: 'productName', title: '产品名称', minWidth: 120 },
            // { field: 'feeSetName', title: '费用名称', minWidth: 120 },
            { title: '操作', slots: { default: 'default_actions' }, align: "center", width: 135, fixed: 'right' }
        ],
        data: []
    })
    // 结算费用绑定列表-配置
    const closingCostFeeOptions = reactive<BasicTableProps>({
        id: 'closingcost_fee_table',
        border: true,
        keepSource: true,
        showOverflow: true,
        // height: 210,
        loading: false,
        stripe: true,
        rowConfig: { isHover: true, keyField: 'id_table' },
        editConfig: { trigger: 'click', mode: 'row', autoClear: false, showIcon: false, showAsterisk: false },
        cellStyle: { height: '38px', padding: 0 },
        columnConfig: { resizable: true },
        editRules: {
            feeItemCategoryId: [{ message: '请选择费项类型', validator: validateFieldType }],
            productName: [{ message: '请选择产品名称', validator: validateFieldType }],
            // feeSetName: [{ message: '请选择费用名称', validator: validateFieldType }],
            dateVersion: [{ message: '请选择日期版本', validator: validateFieldType }],
        },
        columns: [
            { type: "seq", title: "序号", width: 65 },
            { field: 'feeItemCategoryId', title: '费项类型', editRender: {}, slots: { default: 'default_feeItemCategory', edit: 'edit_feeItemCategory' }, minWidth: 120 },
            { field: 'productName', title: '产品名称', minWidth: 120 },
            // { field: 'feeSetName', title: '费用名称', minWidth: 120 },
            { title: '操作', slots: { default: 'default_actions' }, align: "center", width: 135, fixed: 'right' }
        ],
        data: []
    })
    onMounted(() => {
        templateStore.addReceivableIdList()
        storeDropDownData.addFeeItemList()
        storeDropDownData.addProductList()
        storeDropDownData.addCountTypeList()
        storeDropDownData.addCurrencyList()
        storeDropDownData.addParametersList()
        // 是否是提单使用
        if (isLading) {
            const columns = [
                // { field: 'weightRatio', title: '计抛系数', editRender: {}, slots: { edit: 'edit_weightRatio' }, minWidth: 120 },
                { field: 'dateVersion', title: '日期版本', editRender: {}, slots: { edit: 'edit_dateVersion' }, minWidth: 120 },
                {
                    field: 'specialFeeItemNameList',
                    title: '特殊费用类型',
                    editRender: {},
                    slots: { edit: 'edit_specialFeeItem' },
                    minWidth: 150,
                    formatter: ({ row }) => {
                        return isArrayLength(row.specialFeeItemNameList) ? row.specialFeeItemNameList.join(",") : ''
                    }
                },
            ]
            const parameter = [{ message: '请输入参数', validator: validateFieldType }]
            if (temporaryFeeOptions.editRules) Object.assign(temporaryFeeOptions.editRules, { parameter })
            productFeeOptions.columns = productFeeOptions.columns?.concat(columns)
            closingCostFeeOptions.columns = closingCostFeeOptions.columns?.concat(columns)
            storeDropDownData.addSpecialFeeItemList()
        }
    })
    // 初始化数据
    const initData = (data) => {
        // 临时费用设置
        if (isArrayLength(data.tempFeeItemModelList)) {
            temporaryFeeOptions.data = data.tempFeeItemModelList.map(item => {
                if (isNumber(item.feeItemCategoryId)) item.feeItemCategoryId = String(item.feeItemCategoryId)
                if (!item.countModel) item.countModel = { countType: undefined }
                return item
            })
        }
        if (isArrayLength(data.stableFeeItemModelList)) {
            const newData = data.stableFeeItemModelList.map((item) => {
                if (isNumber(item.feeItemCategoryId)) item.feeItemCategoryId = String(item.feeItemCategoryId)
                return item
            })
            // 客户
            productFeeOptions.data = newData.filter(item => item.feeSetType === BaseFeeSetType.CUSTOMER_PRICE)
            // 结算
            closingCostFeeOptions.data = newData.filter(item => item.feeSetType === BaseFeeSetType.SETTLEMENT_PRICE)
            // 初始化费用版本
            initDateVersion(newData)
        }
    }
    // 加载
    const setLoading = (isLoad: boolean) => {
        temporaryFeeOptions.loading = isLoad
        productFeeOptions.loading = isLoad
        closingCostFeeOptions.loading = isLoad
    }
    // 费用版本列表
    const initDateVersion = async (list: any[]) => {
        const parentIdList = list.map(item => item.feeSetParentId)
        if (parentIdList.length > 0) {
            const resGroup = await api_customerFeeGroupList({ parentIdList })
            if (resCodeSuccess(resGroup)) {
                receivabState.dateVersionList = resGroup.data || []
            }
        }
    }
    const getDateVersionList = computed(() => receivabState.dateVersionList)
    // 加载模版的数据
    const changeReceivableModelData = async (id: string) => {
        if (!id) return
        setLoading(true)
        const res = await api_getReceivableModelData({ id })
        if (resCodeSuccess(res)) {
            const data = res.data
            initData(data)
        }
        setLoading(false)
    }
    watch(
        () => props?.receivableForm,
        (val: BillReceivableDto) => {
            if (isObject(val)) {
                receivabState.referenceReceivableModelId = val.referenceReceivableModelId
                initData(val)
            }
        }
    )
    // 重置表格数据
    const resetTable = () => {
        receivabState.referenceReceivableModelId = ""
        temporaryFeeOptions.data = []
        productFeeOptions.data = []
        closingCostFeeOptions.data = []
        clearEdit()
    }
    // 清空当前所有表格编辑状态
    const clearEdit = () => {
        unref(xTemporaryFeeRef)?.clearEdit()
        unref(xProductFeeRef)?.clearEdit()
        unref(xClosingCostFeeRef)?.clearEdit()
    }

    // vxe-grid操作事件
    const { updateStatus: updateStatusTemporary } = useVxeGridHanleHooks(xTemporaryFeeRef)
    const { updateStatus: updateStatusProduct } = useVxeGridHanleHooks(xProductFeeRef)
    const { updateStatus: updateStatusClosingCost } = useVxeGridHanleHooks(xClosingCostFeeRef)

    // 删除(临时、产品、结算)
    const deleteTable = (type: ReceivableTableType, scope) => {
        clearEdit()
        const index = scope.rowIndex;
        switch (type) {
            case "temporary":
                temporaryFeeOptions.data && temporaryFeeOptions.data.splice(index, 1);
                break;
            case "product":
                productFeeOptions.data && productFeeOptions.data.splice(index, 1);
                break;
            case "closingCost":
                closingCostFeeOptions.data && closingCostFeeOptions.data.splice(index, 1);
                break;
        }
    }

    // 跳转查看费用
    const hanleGoFeeset = (row: Recordable, type: number) => {
        unref(adCustomerFeeSetDetailRef)?.show({ ...row, id: row.feeSetId }, type)
    }

    // 新增(临时、产品、结算)
    const addTable = (type: ReceivableTableType) => {
        clearEdit()
        switch (type) {
            case "temporary":
                temporaryFeeOptions.data && temporaryFeeOptions.data.push({ countModel: {} });
                break;
            case "product":
                productFeeOptions.data && productFeeOptions.data.push({ countModel: {} });
                break;
            case "closingCost":
                closingCostFeeOptions.data && closingCostFeeOptions.data.push({});
                break;
        }
    }

    // 算法下拉框
    const hanleBlurCalculator = (row: Recordable) => {
        clearTimeout(timerCalculator)
        // 按照公式value显示公式弹框
        timerCalculator = setTimeout(() => {
            if (row.countModel.countType === BaseFormula.FORMULA) {
                unref(formulaModleRef)?.show(unref(storeDropDownData.parametersList), row)
            } else {
                // 如果是其它类型清空公式
                row.countModel.formula = undefined
                row.countModel.formulaExplain = undefined
            }
        }, 100)
    }
    const hanleChangeAction = (scope: Recordable, feeSetType: number) => {
        // 费用操作列表
        switch (feeSetType) {
            case BaseFeeSetProductBind.SETTLEMENT_FEE_BINDING://结算价
                deleteTable('closingCost', scope)
                break;
            case BaseFeeSetProductBind.CUSTOMER_FEE_BINDING://客户价
                deleteTable('product', scope)
                break;
        }
    }
    // 查找列表名称
    const changeProductId = (val, scope) => {
        const itemName = deal_FindItemName(val, unref(productList))
        if (!itemName) return itemName
        scope.row.productName = itemName
        updateStatusTemporary(scope)
    }
    // 查找特殊费用类型名称
    const changeSpecialFeeItem = (valArr: number[], row) => {
        if (!isArrayLength(valArr)) return
        const filteredArray = unref(specialFeeItemList).filter(item => valArr.includes(Number(item.value)))
        row.specialFeeItemNameList = filteredArray.map(item => item.label)
    }
    // 根据费用日期版本更新费用编号
    const changeCustomerFee = (val: string, list: Recordable[], type: ReceivableTableType, scope) => {
        type === "closingCost" ? updateStatusClosingCost(scope) : updateStatusProduct(scope)
        if (!val) return
        const findObj = list.find(item => item.value === val)
        scope.row.feeSetId = findObj?.id//.parentId
    }

    // 获取数据
    const getConfirmData = async () => {
        const results = await Promise.all([unref(xTemporaryFeeRef)?.validate(true), unref(xProductFeeRef)?.validate(true), unref(xClosingCostFeeRef)?.validate(true)])
        // 校验的全部状态
        const isValidate = await fee_deal_FilterValidate(results)
        if (!isValidate) return isValidate
        const receivableModelSetDto: BillReceivableDto = {
            referenceReceivableModelId: receivabState.referenceReceivableModelId,
            tempFeeItemModelList: [],
            stableFeeItemModelList: []
        }
        // 临时费用
        receivableModelSetDto.tempFeeItemModelList = await getVxeGridData<TempFeeItemModelDto>(xTemporaryFeeRef)
        // 稳定费用
        receivableModelSetDto.stableFeeItemModelList = [...await getVxeGridData<LadingPayableStableFeeItemModelDto>(xProductFeeRef), ...await getVxeGridData<LadingPayableStableFeeItemModelDto>(xClosingCostFeeRef)]
        clearEdit()
        return receivableModelSetDto
    }

    return {
        temporaryFeeOptions,
        productFeeOptions,
        closingCostFeeOptions,
        adCustomerFeeSetDetailRef,
        receivabState,
        getDateVersionList,
        addTable,
        deleteTable,
        resetTable,
        getConfirmData,
        hanleBlurCalculator,
        hanleChangeAction,
        changeProductId,
        changeSpecialFeeItem,
        changeReceivableModelData,
        changeCustomerFee,
        xTemporaryFeeRef,
        updateStatusTemporary,
        xProductFeeRef,
        updateStatusProduct,
        xClosingCostFeeRef,
        updateStatusClosingCost,
        feeItemCategoryList,
        feeItemLists,
        productList,
        countTypeList,
        currencyList,
        specialFeeItemList,
        fieldsObj,
        templateStore,
    }
}

export {
    useLadingListModel,
    useLadingBillMoneyListModel,
    useLadingBillMoneySetModel,
    useLadingBillMoneyDetailListModel
}