import { FeeItemQueryParam } from "@/api/feeItem/FeeItemModle";
import { reactive,onMounted } from "vue";
import {getFeeItemListApi} from "@/api/FeeItem/FeeItem"
import{getfeeItemSpecialFlagApi} from "@/api/base/basedata"
import{ListIitem} from "@/api/base/BaseDataModel"

export default function userFeeItemTable(){

    //特殊计费标志
    const feeItemSpecialFlagSelectList = reactive({
        list:[] as ListIitem[]
             });

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

         //获取费用信息列表
    const getFeeItemList = async() =>{
        let res = await getFeeItemListApi(listParm)
        if(res && res.code == 200){           
            feeItemList.list = res.data.records
            listParm.total = res.data.total;
        }
    }

    //获取费项科目类型下拉框数据
    const getfeeItemSpecialFlagSelectList =async () => {
        let res = await getfeeItemSpecialFlagApi()
        if(res && res.code == 200)
        {
            debugger;
            feeItemSpecialFlagSelectList.list = res.data;
        }
    }


    //页容量改变时触发
    const sizeChange = (size:number) =>{
        listParm.pageSize = size;
        getFeeItemList();
    }
    //页数改变时触发
    const currentChange = (page:number) =>{
        listParm.pageNum = page;
        getFeeItemList();
    }
    //搜索
    const searchBtn = () =>{
        getFeeItemList();
    }
    //重置
    const resetBtn = () =>{
        listParm.itemName= '';          
        getFeeItemList();
    }
    onMounted(() =>{
        getFeeItemList();
        getfeeItemSpecialFlagSelectList();
    })

    return{
        feeItemSpecialFlagSelectList,
        feeItemList,
        listParm,
        getFeeItemList,
        sizeChange,
        currentChange,
        searchBtn,
        resetBtn
    }
};