| | |
| | | } |
| | | })) |
| | | setData(val) |
| | | setTimeout(() => { |
| | | val.forEach((el) => { |
| | | jsbarcode(`#barcode${el.code}`, el.code, { height: 30 }); |
| | | }); |
| | | }, 10); |
| | | |
| | | |
| | | |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | |
| | | if (rows?.length > 0) { |
| | | http(); |
| | | } |
| | | |
| | | }, [rows]); |
| | | |
| | | // 在数据更新后生成条码 |
| | | useEffect(() => { |
| | | if (data.length > 0) { |
| | | // 等待DOM更新后再生成条码 |
| | | setTimeout(() => { |
| | | data.forEach((item) => { |
| | | const barcodeElement = document.getElementById(`barcode${item.code}`); |
| | | if (barcodeElement) { |
| | | try { |
| | | jsbarcode(`#barcode${item.code}`, item.code, { height: 30 }); |
| | | } catch (error) { |
| | | console.error(`生成条码失败: ${item.code}`, error); |
| | | } |
| | | } |
| | | }); |
| | | }, 100); |
| | | } |
| | | }, [data]); |
| | | |
| | | |
| | | return ( |
| | |
| | | colSpan={9} |
| | | style={{ border: '1px solid black' }} |
| | | > |
| | | {/* <img id={"barcode" + item.code} style={{ width: '70%', verticalAlign: 'middle' }} /> */} |
| | | <img className="template-code" src={item.barcode} style={{ width: '90%', verticalAlign: 'middle' }} alt="Barcode" /> |
| | | <img id={`barcode${item.code}`} style={{ width: '90%', verticalAlign: 'middle' }} alt="Barcode" /> |
| | | <div style={{ letterSpacing: '2px', marginTop: '1px', textAlign: 'center' }}> |
| | | <span>{item.code}</span> |
| | | </div> |