import { CustomerRateQueryParam } from "@/api/customerrate/CustomerRateModel";
import { reactive,onMounted } from "vue";
import {getCustomerRateListApi} from "@/api/customerRate/CustomerRate"

export default function userCustomerRateTable(){

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

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

    return{
        customerRateList,
        listParm,
        getCustomerRateList,
        sizeChange,
        currentChange,
        searchBtn,
        resetBtn
    }
};