import { getMaterialListReloadApi, getMaterialListExportApi } from "@/api/modules/foundationMaterial";
import { useMsg } from "@/hooks/useMsg";

// 导出
export const handleExport = async (params: any) => {
    const { initParam } = params;
    const result = await getMaterialListExportApi(initParam);
    if (result?.code === 0) {
        useMsg("success", "导出成功 ！");
    }
};
//刷新
export const handleReload = async (params: any) => {
    const { selectionList, proTable } = params;
    let length = selectionList.length;
    let ids: any = [];
    if (length && length > 100) {
        useMsg("warning", "选中刷新数据最大100条 ！");
        return;
    }
    selectionList.forEach((item: any) => {
        ids.push(item.id);
    });
    let id = ids.join(",");
    const result = await getMaterialListReloadApi({ id });
    if (result?.code === 0) {
        useMsg("success", "数据刷新成功 ！");
        proTable.value!.getTableList();
    }
};

export const btnClick: any = {
    export: handleExport,
    reset: handleReload
};
