import { CurrencyRateQueryParam } from "@/api/costdata/currencyrate/CurrencyRateModle";
import { reactive } from "vue";
import { getCurrencyRateListApi } from "@/api/costdata/currencyRate/CurrencyRate"
import { useQueryList } from "@/hooks/useQueryList";

export default function userCurrencyRateTable() {

    //定义表格数据
    const currencyRateList = reactive({
        list: [],
        loading: false
    });
    //定义列表查询的参数
    const listParm = reactive<CurrencyRateQueryParam>({
        currencyCode: '',
        pageNum: 1,
        pageSize: 10,
        total: 0
    })

    //获取汇率信息列表
    const getCurrencyRateList = async () => {
        currencyRateList.loading = true
        let res = await getCurrencyRateListApi(listParams)
        if (res && res.code == 200) {
            currencyRateList.list = res.data.records
            listParm.total = res.data.total;
        }
        currencyRateList.loading = false
    }

    // 重置
    const resetParams = () => {
        listParm.currencyCode = '';
    }
    // 初始化列表、分页数据
    const { sizeChange, currentChange, searchBtn, resetBtn, listParams } = useQueryList<CurrencyRateQueryParam>(getCurrencyRateList, resetParams, listParm)

    return {
        currencyRateList,
        listParm,
        getCurrencyRateList,
        sizeChange,
        currentChange,
        searchBtn,
        resetBtn
    }
};