import { str } from "@/utils/mymodelhtml.js";
import { doFetch } from "./doFetch";
export async function start(url, params) {
  try {
    if (!getLodop) {
      return;
    }
  } catch (error) {
    alert("系统检测当前环境未安装相关插件，请先安装C-Lodop插件！");
    return;
  }

  const res = await doFetch({ url, params });
  const data = JSON.parse(JSON.stringify(res?.data?.dataList));
  console.log(data);
  for (let i = 0; i < data.length; i++) {
    const template = str(data[i]);
    console.log(template);
    let LODOP = getLodop();
    LODOP.PRINT_INIT("task1");
    LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", template);
    LODOP.SET_PRINT_PAGESIZE(0, 800, 600, "");
    // LODOP.PREVIEW();
    LODOP.PRINT();
  }
}
