| | |
| | | SavedQueriesList, |
| | | FilterLiveSearch, |
| | | useNotify, |
| | | useListContext |
| | | useListContext, |
| | | SearchInput |
| | | } from 'react-admin'; |
| | | import BookmarkIcon from '@mui/icons-material/BookmarkBorder'; |
| | | import { Box, Typography, Card, CardContent, useTheme, TextField } from '@mui/material'; |
| | | import { Box, Typography, Card, CardContent, useTheme, Input } from '@mui/material'; |
| | | import { RichTreeView } from "@mui/x-tree-view/RichTreeView"; |
| | | import { TreeItem2 } from "@mui/x-tree-view/TreeItem2"; |
| | | |
| | |
| | | const [selectedOption, setSelectedOption] = useState(null); |
| | | const [treeData, setTreeData] = useState([]); |
| | | const [defaultIds, setDefaultIds] = useState(['29']); |
| | | const [condition, setCondition] = useState(''); |
| | | |
| | | const haveChildren = (item) => { |
| | | if (Array.isArray(item)) { |
| | |
| | | return item; |
| | | }; |
| | | useEffect(() => { |
| | | request.post('/matnrGroup/tree') |
| | | http() |
| | | }, [condition]); |
| | | |
| | | const http = () => { |
| | | request.post('/matnrGroup/tree', { condition }) |
| | | .then(res => { |
| | | if (res?.data?.code === 200) { |
| | | let data = res.data.data; |
| | | let items = haveChildren(data) |
| | | |
| | | setTreeData(items) |
| | | setDefaultIds([items.at(0).id]) |
| | | |
| | | |
| | | } else { |
| | | notify(res.data.msg); |
| | |
| | | notify('Error fetching tree data'); |
| | | }); |
| | | |
| | | }, []); |
| | | } |
| | | const handleNodeSelect = (event, nodeId) => { |
| | | setFilters({ groupId: nodeId }); |
| | | }; |
| | | const handleSearch = () => { |
| | | console.log('Search Input:', selectedOption); |
| | | const handleSearch = (e) => { |
| | | setCondition(e.target.value) |
| | | }; |
| | | |
| | | |
| | |
| | | }} |
| | | > |
| | | <CardContent> |
| | | <SavedQueriesList icon={<BookmarkIcon />} /> |
| | | <FilterLiveSearch source="condition" /> |
| | | <Input |
| | | placeholder="搜索物料分区" |
| | | sx={{ '--Input-focused': 1, marginBottom: '10px' }} |
| | | onChange={handleSearch} |
| | | /> |
| | | <RichTreeView |
| | | defaultExpandedItems={defaultIds} |
| | | expansionTrigger="iconContainer" |
| | |
| | | |
| | | import { useReactToPrint } from "react-to-print"; |
| | | |
| | | const InitModal = ({ open, setOpen }) => { |
| | | const PrintModal = ({ open, setOpen }) => { |
| | | const refresh = useRefresh(); |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | |
| | | </FormControl> |
| | | |
| | | <Box> |
| | | <div ref={contentRef} style={{ display: 'flex', justifyContent: 'center' }}> |
| | | <table |
| | | className="contain" |
| | | style={{ |
| | | overflow: 'hidden', |
| | | fontSize: 'small', |
| | | tableLayout: 'fixed', |
| | | width: '280px', |
| | | borderCollapse: 'collapse', // 合并边框 |
| | | border: '1px solid black' // 设置表格整体边框 |
| | | }} |
| | | > |
| | | <tbody> |
| | | <tr style={{ height: '74px' }}> |
| | | <td |
| | | align="center" |
| | | colSpan={3} |
| | | style={{ border: '1px solid black' }} // 设置单元格边框 |
| | | > |
| | | 商品编码 |
| | | </td> |
| | | <td |
| | | align="center" |
| | | className="barcode" |
| | | colSpan={9} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | {/* <img className="template-code" src={barcodeUrl} style={{ width: '90%' }} alt="Barcode" /> */} |
| | | <div style={{ letterSpacing: '2px', marginTop: '1px', textAlign: 'center' }}> |
| | | <span>{'matnr'}</span> |
| | | </div> |
| | | </td> |
| | | </tr> |
| | | <tr style={{ height: '74px' }}> |
| | | <td |
| | | align="center" |
| | | colSpan={3} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | 商品 |
| | | </td> |
| | | <td |
| | | align="center" |
| | | colSpan={5} |
| | | style={{ |
| | | overflow: 'hidden', |
| | | whiteSpace: 'nowrap', |
| | | textOverflow: 'ellipsis', |
| | | border: '1px solid black' |
| | | }} |
| | | > |
| | | {'maktx'} |
| | | </td> |
| | | <td |
| | | align="center" |
| | | colSpan={2} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | 备注 |
| | | </td> |
| | | <td |
| | | align="center" |
| | | colSpan={2} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | {'memo'} |
| | | </td> |
| | | </tr> |
| | | </tbody> |
| | | </table> |
| | | <div style={{ textAlign: 'center' }}> |
| | | <PrintTemp /> |
| | | </div> |
| | | <style>{` |
| | | @media print { |
| | | .print-content { |
| | | display: block!important; |
| | | } |
| | | }`} </style> |
| | | <div ref={contentRef} className="print-content" style={{ textAlign: 'center', display: 'none' }}> |
| | | <PrintTemp /> |
| | | </div> |
| | | </Box> |
| | | </DialogContent> |
| | |
| | | </Button> |
| | | </Box> |
| | | </DialogActions> |
| | | </Dialog> |
| | | </Dialog > |
| | | ); |
| | | } |
| | | |
| | | export default InitModal; |
| | | export default PrintModal; |
| | | |
| | | const PrintTemp = (props) => { |
| | | const [data, setData] = useState([{ |
| | | barcode: '/img/barcode.jpeg', |
| | | product: 'xxxxxx-xx/xx', |
| | | remark: 'xx' |
| | | }]); |
| | | return ( |
| | | <> |
| | | {data.map((item, index) => ( |
| | | <table |
| | | key={index} |
| | | className="contain" |
| | | style={{ |
| | | overflow: 'hidden', |
| | | fontSize: 'small', |
| | | tableLayout: 'fixed', |
| | | width: '280px', |
| | | borderCollapse: 'collapse', |
| | | borderSpacing: 0, |
| | | margin: '0 auto', |
| | | marginTop: '10px', |
| | | }} |
| | | > |
| | | <tbody> |
| | | <tr style={{ height: '74px' }}> |
| | | <td align="center" colSpan={3} style={{ border: '1px solid black' }} > |
| | | 商品编码 |
| | | </td> |
| | | <td |
| | | align="center" |
| | | className="barcode" |
| | | colSpan={9} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | <img className="template-code" src={item.barcode} style={{ width: '90%', verticalAlign: 'middle' }} alt="Barcode" /> |
| | | <div style={{ letterSpacing: '2px', marginTop: '1px', textAlign: 'center' }}> |
| | | <span>{'xxxxxx'}</span> |
| | | </div> |
| | | </td> |
| | | </tr> |
| | | <tr style={{ height: '74px' }}> |
| | | <td |
| | | align="center" |
| | | colSpan={3} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | 商品 |
| | | </td> |
| | | <td |
| | | align="center" |
| | | colSpan={5} |
| | | style={{ |
| | | overflow: 'hidden', |
| | | whiteSpace: 'nowrap', |
| | | textOverflow: 'ellipsis', |
| | | border: '1px solid black' |
| | | }} |
| | | > |
| | | {item.product} |
| | | </td> |
| | | <td |
| | | align="center" |
| | | colSpan={2} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | 备注 |
| | | </td> |
| | | <td |
| | | align="center" |
| | | colSpan={2} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | {item.remark} |
| | | </td> |
| | | </tr> |
| | | </tbody> |
| | | </table> |
| | | ))} |
| | | |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | |