import { FeeItemCategoryeQueryParam } from "@/api/feeItemCategory/FeeItemCategoryModle";
import { reactive,onMounted } from "vue";
import {getFeeItemCategoryListApi} from "@/api/FeeItemCategory/FeeItemCategory"

export default function userFeeItemCategoryTable(){

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

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

    return{
        feeItemCategoryList,
        listParm,
        getFeeItemCategoryList,
        sizeChange,
        currentChange,
        searchBtn,
        resetBtn
    }
};