|  |  | 
 |  |  | import { | 
 |  |  |     useTranslate, | 
 |  |  |     useRecordContext, | 
 |  |  |     useNotify | 
 |  |  |     useNotify, | 
 |  |  |     useRefresh, | 
 |  |  |     useListContext, | 
 |  |  | } from 'react-admin'; | 
 |  |  | import PanelTypography from "../components/PanelTypography"; | 
 |  |  | import * as Common from '@/utils/common' | 
 |  |  | 
 |  |  | import request from '@/utils/request'; | 
 |  |  | import debounce from 'lodash/debounce'; | 
 |  |  | import { DataGrid } from '@mui/x-data-grid'; | 
 |  |  | import PrintModal from './PrintModal'; | 
 |  |  | const AsnOrderPanel = () => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |     if (!record) return null; | 
 |  |  | 
 |  |  |  | 
 |  |  |     const debouncedHttp = useMemo(() => debounce(http, 300), []); | 
 |  |  |  | 
 |  |  |     const StyledTableRow = styled(TableRow)(({ theme }) => ({ | 
 |  |  |         "& .MuiButtonBase-root.": { | 
 |  |  |             padding: "0px 0px", | 
 |  |  |         }, | 
 |  |  |     })); | 
 |  |  |  | 
 |  |  |     const StyledTableCell = styled(TableCell)(({ theme }) => ({ | 
 |  |  |         "& .MuiButtonBase-root": { | 
 |  |  |             padding: "0px 0px", | 
 |  |  |         }, | 
 |  |  |         overflow: "hidden", | 
 |  |  |         textOverflow: "ellipsis", | 
 |  |  |         whiteSpace: "nowrap", | 
 |  |  |         maxWidth: 600, | 
 |  |  |     })); | 
 |  |  |  | 
 |  |  |     const columns = [ | 
 |  |  |         { | 
 |  |  | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'anfme', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.anfme') | 
 |  |  |             headerName: translate('table.field.asnOrderItem.purQty') | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'stockUnit', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.stockUnit') | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'purQty', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.purQty') | 
 |  |  |         }, | 
 |  |  |         // { | 
 |  |  |         //     field: 'purQty', | 
 |  |  |         //     headerName: translate('table.field.asnOrderItem.purQty') | 
 |  |  |         // }, | 
 |  |  |         { | 
 |  |  |             field: 'purUnit', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.purUnit') | 
 |  |  | 
 |  |  |         { | 
 |  |  |             field: 'qty', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.qty') | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'splrBatch', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.splrBatch') | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'splrCode', | 
 |  |  | 
 |  |  |             headerName: translate('table.field.asnOrderItem.splrName') | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'barcode', | 
 |  |  |             field: 'trackCode', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.barcode') | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'prodTime', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.prodTime') | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'packName', | 
 |  |  |             headerName: translate('table.field.asnOrderItem.packName') | 
 |  |  |         }] | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'action', | 
 |  |  |             headerName: '操作', | 
 |  |  |             width: 70, | 
 |  |  |             lockPosition: 'left', | 
 |  |  |             renderCell: (params) => ( | 
 |  |  |                 <PrintButton rows={[params.row.id]} /> | 
 |  |  |             ), | 
 |  |  |  | 
 |  |  |         },] | 
 |  |  |  | 
 |  |  |     const [selectedRows, setSelectedRows] = useState([]); | 
 |  |  |  | 
 |  |  | 
 |  |  |         setMaktx(value) | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     const wakbarcode = () => { | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     const wakprint = () => { | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  | 
 |  |  |                 <TextField value={maktx} onChange={(e) => maktxChange(e.target.value)} label="搜索物料" variant="outlined" sx={{ width: '300px' }} /> | 
 |  |  |  | 
 |  |  |                 <div style={{ display: 'flex', gap: '10px' }}> | 
 |  |  |                     <Button variant="contained" onClick={wakbarcode}>生成条码</Button> | 
 |  |  |                     <Button variant="contained" onClick={wakprint}>打印</Button> | 
 |  |  |                     <PrintsButton rows={selectedRows} /> | 
 |  |  |                 </div> | 
 |  |  |             </div> | 
 |  |  |  | 
 |  |  | 
 |  |  |                 size="small" | 
 |  |  |                 rows={rows} | 
 |  |  |                 columns={columns} | 
 |  |  |                 disableRowSelectionOnClick | 
 |  |  |                 checkboxSelection | 
 |  |  |                 onRowSelectionModelChange={handleSelectionChange} | 
 |  |  |                 selectionModel={selectedRows} | 
 |  |  | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | export default AsnOrderPanel; | 
 |  |  |  | 
 |  |  | const PrintsButton = ({ rows }) => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |     const { resource, selectedIds } = useListContext(); | 
 |  |  |     const notify = useNotify(); | 
 |  |  |     const refresh = useRefresh(); | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |  | 
 |  |  |     const [createDialog, setCreateDialog] = useState(false); | 
 |  |  |  | 
 |  |  |     const modalChange = () => { | 
 |  |  |         if (rows?.length === 0) { | 
 |  |  |             notify('请选择物料'); | 
 |  |  |             return; | 
 |  |  |         } else { | 
 |  |  |             setCreateDialog(true) | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <> | 
 |  |  |             <Button size="small" variant="contained" color="secondary" onClick={modalChange}>{translate("toolbar.batchPrint")}</Button> | 
 |  |  |  | 
 |  |  |             <PrintModal | 
 |  |  |                 open={createDialog} | 
 |  |  |                 setOpen={setCreateDialog} | 
 |  |  |                 rows={rows} | 
 |  |  |             /> | 
 |  |  |         </> | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | const PrintButton = ({ rows }) => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |  | 
 |  |  |     const notify = useNotify(); | 
 |  |  |     const refresh = useRefresh(); | 
 |  |  |  | 
 |  |  |     const [createDialog, setCreateDialog] = useState(false); | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <> | 
 |  |  |             <Button size="small" variant="contained" color="secondary" onClick={() => setCreateDialog(true)}>{translate("toolbar.print")}</Button> | 
 |  |  |  | 
 |  |  |             <PrintModal | 
 |  |  |                 open={createDialog} | 
 |  |  |                 setOpen={setCreateDialog} | 
 |  |  |                 rows={rows} | 
 |  |  |             /> | 
 |  |  |         </> | 
 |  |  |     ) | 
 |  |  | } |