不动产的开票信息判断 修改

This commit is contained in:
ylj20011123 2026-01-26 09:33:06 +08:00
parent c6a5262222
commit 9a63d91801
3 changed files with 232 additions and 27 deletions

View File

@ -0,0 +1,9 @@
/*
由于现在使用 Iframe 隔离打印方案,
样式已直接在 index.tsx 的 iframe 注入逻辑中定义。
此文件目前仅保留页面基础样式(如有)。
*/
.print-ignore {
/* 页面按钮展示样式 */
}

View File

@ -1,32 +1,206 @@
import { Button } from "antd"
import { Button } from "antd";
import ReactDOM from "react-dom";
import "./index.less";
const ComplaintForwardingProcess = () => {
// 打印附件1
const handlePrintAttachment1 = () => {
}
// 打印附件2
const handlePrintAttachment2 = () => {
}
// 打印附件3
const handlePrintAttachment3 = () => {
}
return <div>
<Button onClick={() => {
handlePrintAttachment1()
}}>1</Button>
<Button onClick={() => {
handlePrintAttachment2()
}}>2</Button>
<Button onClick={() => {
handlePrintAttachment3()
}}>3</Button>
// 附件1 结构
const Attachment1 = () => (
<div className="printContainer">
<div className="printTitle">1</div>
<table className="printTable">
<tbody>
<tr>
<td className="labelCell"></td>
<td className="contentCell"></td>
<td className="labelCell"></td>
<td className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td className="contentCell"></td>
<td className="labelCell"></td>
<td className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td className="contentCell"></td>
<td className="labelCell"></td>
<td className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell">
<div style={{ marginTop: '100px', textAlign: 'right' }}>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div>
}
</td>
</tr>
</tbody>
</table>
</div>
);
// 附件2 结构
const Attachment2 = () => (
<div className="printContainer">
<div className="printTitle">12328</div>
<div style={{ textAlign: 'right', marginBottom: '5px' }}></div>
<table className="printTable">
<tbody>
<tr>
<td className="labelCell"></td>
<td className="contentCell"></td>
<td className="labelCell"></td>
<td className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td className="contentCell"></td>
<td className="labelCell"></td>
<td className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td className="contentCell"></td>
<td className="labelCell"></td>
<td className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell">
<div style={{ marginTop: '50px', textAlign: 'right' }}>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div>
</td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell">
<div style={{ marginTop: '50px', textAlign: 'right' }}>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div>
</td>
</tr>
</tbody>
</table>
</div>
);
export default ComplaintForwardingProcess
// 附件3 结构
const Attachment3 = () => (
<div className="printContainer">
<div className="printTitle"></div>
<div style={{ textAlign: 'right', marginBottom: '5px' }}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<table className="printTable">
<tbody>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td className="contentCell"></td>
<td className="labelCell"></td>
<td className="contentCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell"></td>
</tr>
<tr>
<td className="labelCell"></td>
<td colSpan={3} className="largeCell"></td>
</tr>
</tbody>
</table>
</div>
);
// 真正的打印函数,使用 Iframe 隔离
const handlePrintByIframe = (AttachmentComponent: React.ComponentType) => {
// 1. 创建隐藏的 iframe
const iframe = document.createElement('iframe');
iframe.style.position = 'fixed';
iframe.style.right = '0';
iframe.style.bottom = '0';
iframe.style.width = '0';
iframe.style.height = '0';
iframe.style.border = '0';
document.body.appendChild(iframe);
const iframeDoc = iframe.contentWindow?.document;
if (!iframeDoc) return;
// 2. 注入样式和容器
iframeDoc.open();
iframeDoc.write(`
<html>
<head>
<title></title>
<style>
body { margin: 0; padding: 20px; font-family: SimSun, STSong, serif; }
.printContainer { width: 100%; box-sizing: border-box; }
.printTitle { text-align: center; font-size: 24px; font-weight: bold; margin-bottom: 25px; }
.printTable { width: 100%; border-collapse: collapse; border: 2px solid #000; table-layout: fixed; }
.printTable td { border: 1px solid #000; padding: 12px; font-size: 15px; word-break: break-all; height: 45px; }
.labelCell { background-color: #f2f2f2 !important; width: 110px; font-weight: bold; text-align: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.contentCell { text-align: left; }
.largeCell { height: 180px; vertical-align: top; }
</style>
</head>
<body>
<div id="print-root"></div>
</body>
</html>
`);
iframeDoc.close();
// 3. 将 React 组件渲染到 iframe 中
const printRoot = iframeDoc.getElementById('print-root');
if (printRoot) {
ReactDOM.render(<AttachmentComponent />, printRoot);
}
// 4. 调用打印
setTimeout(() => {
iframe.contentWindow?.focus();
iframe.contentWindow?.print();
// 5. 打印完成后清理
setTimeout(() => {
document.body.removeChild(iframe);
}, 1000);
}, 300);
};
return (
<div style={{ padding: '24px' }}>
<div style={{ display: 'flex', gap: '16px', marginBottom: '24px' }}>
<Button type="primary" onClick={() => handlePrintByIframe(Attachment1)}>1</Button>
<Button type="primary" onClick={() => handlePrintByIframe(Attachment2)}>2</Button>
<Button type="primary" onClick={() => handlePrintByIframe(Attachment3)}>3</Button>
</div>
<div style={{ color: '#999', fontSize: '14px' }}>
使 Iframe ****
</div>
</div>
);
};
export default ComplaintForwardingProcess;

View File

@ -564,9 +564,18 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
PageSize: 999999,
SortStr: "BILLDETAIL_ID"
})
console.log('billDetailbillDetail', billDetail);
let billDetailReq: any = []
// 可能存在的不动产数据
let estateLeaseItems: any = []
// 判断 票据信息里面是否有税务代码
// 2026-01-23 朱老师点头 判断是否有不动产号 有的话 不动产信息必填 不需要一一对应 即 有不动产编号的时候 不动产选择也必须要有
// 判断是不是全部的 不动产商品 都已经选择了不动产
let haveAllShopSelectRealEstate = true
// 判断是否有不动产
let haveRealEstate = false
if (billDetail && billDetail.length > 0) {
// 从当前商品的详情里面取出 用的到的 不动产id
let REALESTATE_IDList: Number[] = []
@ -585,10 +594,16 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
REALESTATE_ID: item.REALESTATE_ID,// 不动产id
BILLDETAIL_DESC: item.BILLDETAIL_DESC // 备注
})
if (item.TABLE_NAME && item.TABLE_NAME.indexOf('30405020') !== -1) {
haveRealEstate = true
if (!item.REALESTATE_ID) {
haveAllShopSelectRealEstate = false
}
}
REALESTATE_IDList.push(Number(item.REALESTATE_ID))
})
console.log('dhaskdhaslhdasl', billDetail);
// REALESTATE_ID 是,隔开的不动产id 这里去查询 记录 有多少条
const req: any = {
searchParameter: {
@ -603,7 +618,6 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
value: encryptAES(JSON.stringify(req))
}
const data: any = await handleGetREALESTATEList(newReq)
console.log('dhaskdhaslhdasl', data);
// 这个服务区的全部不动产的数据 都在data里面
if (data && data.length > 0) {
let unitObj: any = {
@ -634,7 +648,15 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
}
}
// 判断不动产信息是否已经选择了
// haveRealEstate true 说明票的商品明细里面有不动产 不然就是没有
if (haveRealEstate) {
if (haveAllShopSelectRealEstate && estateLeaseItems && estateLeaseItems.length > 0) {
} else {
message.error('请选择不动产信息')
return
}
}
let obj: any = {
billNo: record?.BILL_NO, // 单据编号