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

export default function userFeeItemCategoryTable() {

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

    //获取费用信息列表
    const getFeeItemCategoryList = async () => {
        feeItemCategoryList.loading = true
        let res = await getFeeItemCategoryListApi(listParams)
        if (res && res.code == 200) {
            feeItemCategoryList.list = res.data.records
            listParm.total = res.data.total;
        }
        feeItemCategoryList.loading = false
    }
    // 重置
    const resetParams = () => {
        listParm.categoryName = '';
    }
    // 初始化列表、分页数据
    const { sizeChange, currentChange, searchBtn, resetBtn, listParams } = useQueryList<FeeItemCategoryeQueryParam>(getFeeItemCategoryList, resetParams, listParm)


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