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

export default function userCurrencyRateTable(){

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

         //获取汇率信息列表
    const getCurrencyRateList = async() =>{
        let res = await getCurrencyRateListApi(listParm)
        if(res && res.code == 200){           
            currencyRateList.list = res.data.records
            listParm.total = res.data.total;
        }
    }
    //页容量改变时触发
    const sizeChange = (size:number) =>{
        listParm.pageSize = size;
        getCurrencyRateList();
    }
    //页数改变时触发
    const currentChange = (page:number) =>{
        listParm.pageNum = page;
        getCurrencyRateList();
    }
    //搜索
    const searchBtn = () =>{
        getCurrencyRateList();
    }
    //重置
    const resetBtn = () =>{
        listParm.currencyCode= '';      
        getCurrencyRateList();
    }
    onMounted(() =>{
        getCurrencyRateList();
    })

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