import { doFetch } from "@/utils/doFetch"; import React, { useState, useImperativeHandle, forwardRef, useRef, } from "react"; import { useEffect } from "react"; import { ScrollBoard } from "@jiaminghi/data-view-react"; import { useWindowSize } from "@/utils/windowsize"; const pageStyle = ` @media all { .page-break { display: none; } } @media print { html, body { height: initial !important; overflow: initial !important; position:relative; -webkit-print-color-adjust: exact; word-break: break-all; } } @media print { .page-break { margin-top:0; display: block; page-break-before: auto; } } @media print { .page-noprint { display: none !important; } } @page { size: auto; margin: 0px; } `; let columns = [ { title: "物料编码 - 名称", dataIndex: "materieName", key: "materieName", search: false, render: (dom, row) => { return (row.materieCode ?? "") + " - " + (row.materieName ?? ""); }, }, { title: "出库数量", dataIndex: "outstroeNum", key: "outstroeNum", search: false, }, { title: "库存单位", dataIndex: "productionUnitName", key: "productionUnitName", search: false, width: 60, }, ]; function PrintDom({ totalPath, val, totalParams, totalCard }, ref) { console.log(totalCard); let printRef = useRef(); const [data, setdata] = useState({}); useImperativeHandle(ref, () => ({ dom: printRef, })); useEffect(() => { if (val == "detail") { doFetch({ url: totalPath, params: totalParams }).then((res) => { if (res.code == "0000") { setdata(res?.data?.data); } }); } else { } }, [val]); let datas = data?.materialList ? data?.materialList.map((it) => { return columns.map((item) => { if (item.render) { return item.render(it, it); } else { return it[item.dataIndex]; } }); }) : []; return ( <> {val == "detail" && (

出库工单

{totalCard && totalCard[0].itemData .filter((it) => !(it.noshow === true)) .map((it) => { return (
{it.title}: {data[it.key] || "-"}
); })}
{totalCard && totalCard[1].cardTitle}
it.title), data: datas, rowNum: datas.length, hoverPause: false, }} />
)} ); } export default forwardRef(PrintDom);