This commit is contained in:
ylj20011123 2025-08-22 19:40:37 +08:00
parent 56f4ce81f7
commit c819d0e880
2 changed files with 563 additions and 269 deletions

View File

@ -1,6 +1,6 @@
// 数电的开票 // 数电的开票
import ProTable, { ActionType } from "@ant-design/pro-table"; import ProTable, { ActionType } from "@ant-design/pro-table";
import { FormInstance, Button, message, Tag } from "antd"; import { FormInstance, Button, message, Tag, Popconfirm } from "antd";
import { useRef, useState } from "react"; import { useRef, useState } from "react";
import { connect } from "umi"; import { connect } from "umi";
import { Datum } from "@/types/invoice"; import { Datum } from "@/types/invoice";
@ -32,8 +32,45 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
return; return;
} }
let obj: any = {
billNo: record?.billNo, // 单据编号
billDate: record?.billDate, // 单据日期
totalAmount: record?.totalAmount, // 单据金额
includeTaxFlag: "1",// 判断是否含税
autoInvoice: "1",// 自动开票标记
invoiceType: record?.invoiceType, //发票种类
buyerName: record?.buyerName, // 购买方名称
buyerProperty: "0", // 购买方性质 0-企业1-个人2-非企业单位
sellerTaxpayerId: "91530112MA7MQ2JR9U", // 销方税号 写死
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司", // 销方名称 写死
sellerBankAndAccount: "13710884704", // 销方银行和账号 写死
sellerAddressAndTel: "", // 销方地址和电话 写死 应该可以不传
drawer: record?.drawer,// 开票人
buyerRecipientPhone: record?.buyerRecipientPhone || "",// 购方收票手机号
buyerRecipientMail: record?.buyerRecipientMail || "",// 购方收件邮箱
redReason: record?.redReason,
blueinvoiceNo: record?.blueinvoiceNo,
billDetail: [
{
amount: record?.amount, // 明细金额 明细金额含税标识includeTaxFlag=1时该金额为含税金额
detailId: record?.detailId,// 业务系统明细id 业务系统明细id用于反写回原业务系统明细 【长度50】
goodsName: record?.goodsName,// 商品名称 商品名称与商品编码2填1需提前在系统维护【长度GBK92字节】
lineProperty: 2,// 行性质 行性质1折扣行(折扣行必须紧跟被折扣的正常商品行)2正常商品行
price: record?.price, // 单价 单价【长度整数位加小数位最大16位小数位最多13小数点占1位】price有值则quantity必填含税标识includeTaxFlag=1时该金额为含税金额
quantity: record?.quantity,// 数量 数量【长度整数位加小数位最大16位小数位最多13小数点占1位】quantity有值则price必填
revenueCode: record?.revenueCode,// 税收分类编码 税收分类编码,开票项补全或映射会补全税收分类编码,未走开票项补全或映射必填
taxRate: record?.taxRate,// 税率 税率【0.130.090.06等】。不传时根据开票项匹配税率
units: record?.units// 计量单位 计量单位【长度GBK22字节】
}
]
}
console.log('objobj', obj);
// 构造原始数据 // 构造原始数据
const originalData = [record]; // 将record作为data数组的一项 const originalData = [obj]; // 将record作为data数组的一项
// 将data字段进行base64加密 // 将data字段进行base64加密
const dataString = JSON.stringify(originalData); const dataString = JSON.stringify(originalData);
@ -56,7 +93,11 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
const response = await handleGetKaiPiao(invoiceData, accessToken); const response = await handleGetKaiPiao(invoiceData, accessToken);
console.log('开票响应:', response); console.log('开票响应:', response);
if (response && response.code === 200) { if (response && response.success) {
let res: any = JSON.parse(decodeURIComponent(escape(atob(response.data))));
console.log('最终结果:', res);
message.success({ content: `单据 ${record.billNo} 开票申请已提交成功`, key: 'invoice' }); message.success({ content: `单据 ${record.billNo} 开票申请已提交成功`, key: 'invoice' });
} else { } else {
message.error({ content: `开票申请失败: ${response?.message || '未知错误'}`, key: 'invoice' }); message.error({ content: `开票申请失败: ${response?.message || '未知错误'}`, key: 'invoice' });
@ -71,185 +112,105 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
{ {
title: '单据编号', title: '单据编号',
dataIndex: 'billNo', dataIndex: 'billNo',
key: 'billNo',
width: 180, width: 180,
align: 'center',
ellipsis: true, ellipsis: true,
search: true,
hideInSearch: false, hideInSearch: false,
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '购方名称', title: '购方名称',
dataIndex: 'buyerName', dataIndex: 'buyerName',
key: 'buyerName',
width: 200, width: 200,
align: 'center',
ellipsis: true, ellipsis: true,
search: false, hideInSearch: false,
hideInSearch: true,
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '购方税号', title: '购方税号',
dataIndex: 'buyerTaxpayerId', dataIndex: 'buyerTaxpayerId',
key: 'buyerTaxpayerId',
width: 180, width: 180,
align: 'center',
ellipsis: true, ellipsis: true,
search: false,
hideInSearch: true, hideInSearch: true,
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '销方名称', title: '销方名称',
dataIndex: 'sellerName', dataIndex: 'sellerName',
key: 'sellerName',
width: 200, width: 200,
align: 'center',
ellipsis: true, ellipsis: true,
search: false,
hideInSearch: true, hideInSearch: true,
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '销方税号', title: '销方税号',
dataIndex: 'sellerTaxpayerId', dataIndex: 'sellerTaxpayerId',
key: 'sellerTaxpayerId',
width: 180, width: 180,
align: 'center',
ellipsis: true, ellipsis: true,
search: true,
hideInSearch: false, hideInSearch: false,
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '单据日期', title: '单据日期',
dataIndex: 'billDate', dataIndex: 'billDate',
key: 'billDate',
width: 120, width: 120,
search: false, align: 'center',
hideInSearch: true, hideInSearch: true,
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '单据金额', title: '单据金额',
dataIndex: 'totalAmount', dataIndex: 'totalAmount',
key: 'totalAmount',
width: 120, width: 120,
search: false, align: 'center',
hideInSearch: true, hideInSearch: true,
render: (text: number) => text ? `¥${text.toFixed(2)}` : '-', render: (text: number) => text ? `¥${text.toFixed(2)}` : '-',
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '含税标识', title: '含税标识',
dataIndex: 'includeTaxFlag', dataIndex: 'includeTaxFlag',
key: 'includeTaxFlag',
width: 100, width: 100,
search: false, align: 'center',
hideInSearch: true, hideInSearch: true,
render: (text: string) => ( render: (text: string) => (
<Tag color={text === '1' ? 'green' : 'blue'}> <Tag color={text === '1' ? 'green' : 'blue'}>
{text === '1' ? '含税' : '不含税'} {text === '1' ? '含税' : '不含税'}
</Tag> </Tag>
), ),
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
},
{
title: '发票性质',
dataIndex: 'invoiceProperty',
key: 'invoiceProperty',
width: 100,
search: true,
hideInSearch: false,
valueType: 'select',
valueEnum: {
'0': { text: '蓝票', status: 'Success' },
'1': { text: '红票', status: 'Error' },
},
render: (text: string) => (
<Tag color={text === '1' ? 'red' : 'green'}>
{text === '1' ? '红票' : '蓝票'}
</Tag>
),
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
},
{
title: '自动开票',
dataIndex: 'autoInvoice',
key: 'autoInvoice',
width: 100,
search: false,
hideInSearch: true,
render: (text: string) => (
<Tag color={text === '1' ? 'green' : 'default'}>
{text === '1' ? '是' : '否'}
</Tag>
),
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'remark', dataIndex: 'remark',
key: 'remark',
width: 150, width: 150,
ellipsis: true, ellipsis: true,
search: false, align: 'center',
hideInSearch: true, hideInSearch: true,
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
{ {
title: '操作', title: '操作',
key: 'action', dataIndex: 'action',
width: 120, width: 120,
fixed: 'center', fixed: 'right',
search: false, align: 'center',
hideInSearch: true, hideInSearch: true,
render: (text: any, record: Datum) => ( render: (text: any, record: Datum) => (
<Button <Popconfirm
type="primary" title="确认发起开票?"
size="small" onConfirm={
onClick={() => handleInvoice(record)} () => {
handleInvoice(record)
}
}
onCancel={() => { }}
okText="确认"
cancelText="取消"
> >
< Button type="primary" size="small" > </Button >
</Button> </Popconfirm >
), ),
onHeaderCell: () => ({
style: { textAlign: 'center' }
}),
}, },
] ]
return ( return (
<div> <div>
<style>
{`
.ant-table-tbody > tr > td {
text-align: left !important;
}
.ant-table-thead > tr > th {
text-align: center !important;
}
`}
</style>
<ProTable <ProTable
actionRef={actionRef} actionRef={actionRef}
formRef={formRef} formRef={formRef}
@ -261,16 +222,9 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
rowKey={(record) => { rowKey={(record) => {
return `${record?.billNo}` return `${record?.billNo}`
}} }}
scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} scroll={{ x: "100%", y: 'calc(100vh - 450px)' }}
headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}></span>} headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}></span>}
search={{ search={{ span: 6, labelWidth: 100 }}
span: 8,
labelWidth: 100,
searchText: '查询',
resetText: '重置',
collapseRender: false,
collapsed: false
}}
request={async (params: any) => { request={async (params: any) => {
let req: any = { let req: any = {
appId: "FPY001", appId: "FPY001",
@ -301,166 +255,135 @@ const DigitalElectronics: React.FC<{ currentUser: any }> = (props) => {
// 模拟数据 // 模拟数据
const mockData: any = [ const mockData: any = [
// 专票
{ {
billNo: "SRM_20250820001", billNo: "SRM_202508220945", // 单据编号
billDate: "2023-05-17", billDate: "2025-08-22", // 单据日期
totalAmount: 11300, totalAmount: 10, // 单据金额
autoInvoice: "0", includeTaxFlag: "1",// 判断是否含税
invoiceType: "08xdp", autoInvoice: "1",// 自动开票标记
buyerName: "深圳市顺丰快运有限公司test01", invoiceType: "08xdp", //发票种类
buyerProperty: "0", buyerName: "深圳市顺丰快运有限公司test01", // 购买方名称
buyerProperty: "0", // 购买方性质
sellerTaxpayerId: "91530112MA7MQ2JR9U", // 销方税号 写死
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司", // 销方名称 写死
sellerBankAndAccount: "13710884704", // 销方银行和账号 写死
sellerAddressAndTel: "", // 销方地址和电话 写死 应该可以不传
drawer: "测试人",// 开票人
buyerRecipientPhone: "18158132615",// 购方收票手机号
buyerRecipientMail: "",// 购方收件邮箱
amount: 10, // 明细金额 明细金额含税标识includeTaxFlag=1时该金额为含税金额
detailId: "1194121661989796666",// 业务系统明细id 业务系统明细id用于反写回原业务系统明细 【长度50】
goodsName: "蜂胶口腔膜",// 商品名称 商品名称与商品编码2填1需提前在系统维护【长度GBK92字节】
lineProperty: 2,// 行性质 行性质1折扣行(折扣行必须紧跟被折扣的正常商品行)2正常商品行
price: 10,// 单价 单价【长度整数位加小数位最大16位小数位最多13小数点占1位】price有值则quantity必填含税标识includeTaxFlag=1时该金额为含税金额
quantity: 1,// 数量 数量【长度整数位加小数位最大16位小数位最多13小数点占1位】quantity有值则price必填
revenueCode: "1070304990000000000",// 税收分类编码 税收分类编码,开票项补全或映射会补全税收分类编码,未走开票项补全或映射必填
taxRate: "0.13",// 税率 税率【0.130.090.06等】。不传时根据开票项匹配税率
units: "个"// 计量单位 计量单位【长度GBK22字节】
// billDetail: [
// {
// }
// ]
},
{
billNo: "SRM_202508220966", // 单据编号
billDate: "2025-08-22", // 单据日期
totalAmount: 10, // 单据金额
includeTaxFlag: "1",// 判断是否含税
autoInvoice: "1",// 自动开票标记
invoiceType: "10xdp", //发票种类
buyerName: "深圳市顺丰快运有限公司test01", // 购买方名称
buyerProperty: "0", // 购买方性质
sellerTaxpayerId: "91530112MA7MQ2JR9U", // 销方税号 写死
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司", // 销方名称 写死
sellerBankAndAccount: "13710884704", // 销方银行和账号 写死
sellerAddressAndTel: "", // 销方地址和电话 写死 应该可以不传
drawer: "测试人",// 开票人
buyerRecipientPhone: "18158132615",// 购方收票手机号
buyerRecipientMail: "",// 购方收件邮箱
amount: 10, // 明细金额 明细金额含税标识includeTaxFlag=1时该金额为含税金额
detailId: "1194121661989796666",// 业务系统明细id 业务系统明细id用于反写回原业务系统明细 【长度50】
goodsName: "蜂胶口腔膜",// 商品名称 商品名称与商品编码2填1需提前在系统维护【长度GBK92字节】
lineProperty: 2,// 行性质 行性质1折扣行(折扣行必须紧跟被折扣的正常商品行)2正常商品行
price: 10,// 单价 单价【长度整数位加小数位最大16位小数位最多13小数点占1位】price有值则quantity必填含税标识includeTaxFlag=1时该金额为含税金额
quantity: 1,// 数量 数量【长度整数位加小数位最大16位小数位最多13小数点占1位】quantity有值则price必填
revenueCode: "1070304990000000000",// 税收分类编码 税收分类编码,开票项补全或映射会补全税收分类编码,未走开票项补全或映射必填
taxRate: "0.13",// 税率 税率【0.130.090.06等】。不传时根据开票项匹配税率
units: "个"// 计量单位 计量单位【长度GBK22字节】
// billDetail: [
// {
// }
// ]
},
// 普票
{
billNo: "SRM_202508221427", // 单据编号
billDate: "2025-08-22", // 单据日期
totalAmount: -10, // 单据金额
includeTaxFlag: "1",// 判断是否含税
invoiceProperty: 1,
autoMerge: 1,
autoInvoice: "1",// 自动开票标记
invoiceType: "10xdp", //发票种类
buyerName: "深圳市顺丰快运有限公司test01", // 购买方名称
buyerProperty: "0", // 购买方性质
sellerTaxpayerId: "91530112MA7MQ2JR9U", // 销方税号 写死
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司", // 销方名称 写死
sellerBankAndAccount: "13710884704", // 销方银行和账号 写死
sellerAddressAndTel: "", // 销方地址和电话 写死 应该可以不传
drawer: "测试人",// 开票人
buyerRecipientPhone: "18158132615",// 购方收票手机号
buyerRecipientMail: "",// 购方收件邮箱
amount: -10, // 明细金额 明细金额含税标识includeTaxFlag=1时该金额为含税金额
detailId: "1194121661989796666",// 业务系统明细id 业务系统明细id用于反写回原业务系统明细 【长度50】
goodsName: "蜂胶口腔膜",// 商品名称 商品名称与商品编码2填1需提前在系统维护【长度GBK92字节】
lineProperty: 2,// 行性质 行性质1折扣行(折扣行必须紧跟被折扣的正常商品行)2正常商品行
price: -10,// 单价 单价【长度整数位加小数位最大16位小数位最多13小数点占1位】price有值则quantity必填含税标识includeTaxFlag=1时该金额为含税金额
quantity: 1,// 数量 数量【长度整数位加小数位最大16位小数位最多13小数点占1位】quantity有值则price必填
revenueCode: "1070304990000000000",// 税收分类编码 税收分类编码,开票项补全或映射会补全税收分类编码,未走开票项补全或映射必填
taxRate: "0.13",// 税率 税率【0.130.090.06等】。不传时根据开票项匹配税率
units: "个",// 计量单位 计量单位【长度GBK22字节】
redReason: "2",
blueinvoiceNo: "200_20250822181151135_0001"
// billDetail: [
// {
// }
// ]
},
{
billNo: "202508220003",
billDate: "2025-08-22",
autoInvoice: "1",
includeTaxFlag: "0",
invoiceProperty: "1",
invoiceType: "10xdp",
totalAmount: -60,
buyerTaxpayerId: "91440300MA5G9GK78Y",
buyerName: "金蝶票据云科技(深圳)有限公司",
sellerTaxpayerId: "91530112MA7MQ2JR9U", sellerTaxpayerId: "91530112MA7MQ2JR9U",
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司", sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司",
sellerBankAndAccount: "13710884704", sellerBankAndAccount: "13710884704",
sellerAddressAndTel: "高新技术产业园南区科技南十二路58996989", sellerAddressAndTel: "高新技术产业园南区科技南十二路58996989",
drawer: "开票人", drawer: "王协芬",
autoMerge: "0",
blueinvoiceNo: "22871379197244241920",
redReason: "2",
billDetail: [ billDetail: [
{ {
amount: 11300, amount: -60,
detailId: "1194121661989796666", goodsName: "通天口服液",
goodsName: "蜂胶口腔膜",
lineProperty: 2, lineProperty: 2,
price: 11300, price: -12,
quantity: 1, quantity: 5,
revenueCode: "1070304990000000000", revenueCode: "1070304990000000000",
taxRate: "0.13", taxRate: "0.09",
units: "个" units: "盒"
}
]
},
{
billNo: "SRM_20250820002",
billDate: "2025-08-20",
buyerName: "深圳电子有限公司",
buyerTaxpayerId: "91440300123456789C",
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司",
sellerTaxpayerId: "91530112MA7MQ2JR9U",
totalAmount: 1.13,
includeTaxFlag: "1",
buyerProperty: "0",
sellerBankAndAccount: "",
sellerAddressAndTel: "",
pushMatchRules: "3",
drawer: "",
invoiceProperty: "0",
autoInvoice: "0",
invoiceType: "08xdp",
buyerRecipientPhone: "18158132615",
buyerRecipientMail: "",
remark: "设备采购款",
billDetail: [
{
amount: 1,
detailId: "1194121661989796666",
goodsName: "蜂胶口腔膜",
lineProperty: 1,
price: 11300,
quantity: 1,
revenueCode: "1070304990000000000",
taxRate: "0.13",
units: "个"
}
]
},
{
billNo: "SRM_20250820003",
billDate: "2025-08-19",
buyerName: "杭州互联网有限公司",
buyerTaxpayerId: "91330100123456789E",
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司",
sellerTaxpayerId: "91530112MA7MQ2JR9U",
totalAmount: 1.13,
includeTaxFlag: "1",
buyerProperty: "0",
sellerBankAndAccount: "",
pushMatchRules: "3",
sellerAddressAndTel: "",
drawer: "",
invoiceProperty: "0",
autoInvoice: "1",
invoiceType: "08xdp",
buyerRecipientPhone: "18158132615",
buyerRecipientMail: "",
remark: "技术咨询服务",
billDetail: [
{
amount: 1,
detailId: "1194121661989796666",
goodsName: "蜂胶口腔膜",
lineProperty: 2,
price: 1,
quantity: 1,
revenueCode: "1070304990000000000",
taxRate: "0.13",
units: "个"
}
]
},
{
billNo: "SRM_20250820004",
billDate: "2025-08-18",
buyerName: "成都科技有限公司",
buyerTaxpayerId: "91510100123456789G",
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司",
sellerTaxpayerId: "91530112MA7MQ2JR9U",
totalAmount: 1.13,
includeTaxFlag: "1",
buyerProperty: "0",
sellerBankAndAccount: "",
sellerAddressAndTel: "",
pushMatchRules: "3",
drawer: "",
invoiceProperty: "1",
autoInvoice: "0",
invoiceType: "08xdp",
buyerRecipientPhone: "18158132615",
buyerRecipientMail: "",
remark: "物流服务费红冲",
billDetail: [
{
amount: 1,
detailId: "1194121661989796666",
goodsName: "蜂胶口腔膜",
lineProperty: 1,
price: 11300,
quantity: 1,
revenueCode: "1070304990000000000",
taxRate: "0.13",
units: "个"
}
]
},
{
billNo: "SRM_20250820005",
billDate: "2025-08-17",
buyerName: "西安制造有限公司",
buyerTaxpayerId: "91610100123456789I",
sellerName: "云南交投集团经营开发有限公司彩云驿商业管理分公司",
sellerTaxpayerId: "91530112MA7MQ2JR9U",
totalAmount: 1.13,
includeTaxFlag: "1",
buyerProperty: "0",
sellerBankAndAccount: "",
sellerAddressAndTel: "",
pushMatchRules: "3",
drawer: "",
invoiceProperty: "0",
autoInvoice: "1",
invoiceType: "08xdp",
buyerRecipientPhone: "18158132615",
buyerRecipientMail: "",
remark: "原材料采购",
billDetail: [
{
amount: 1,
detailId: "1194121661989796666",
goodsName: "蜂胶口腔膜",
lineProperty: 2,
price: 1,
quantity: 1,
revenueCode: "1070304990000000000",
taxRate: "0.13",
units: "个"
} }
] ]
} }

View File

@ -1,2 +1,373 @@
// 开票查询 import React, { useRef, useState } from 'react';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { Button, message, Tag, FormInstance, Popconfirm } from 'antd';
import { handleGetInvoicePageTable } from '../Invoicing/service';
import { handleGetAppToken, handleGetInvoiceSearch, handleGetSDToken } from '../DigitalElectronics/service';
// 定义查询接口的返回类型
export interface ApifoxModel {
businessSystemCode: string;
data: Data;
interfaceCode: InterfaceCode;
requestId: string;
[property: string]: any;
}
export interface Data {
sellerTaxpayerId: string;
serialNo: string;
[property: string]: any;
}
export enum InterfaceCode {
BillInvoiceQuery = "BILL.INVOICE.QUERY",
}
// 发票查询页面组件
const InvoiceSearch: React.FC = () => {
const actionRef = useRef<ActionType>();
const formRef = useRef<FormInstance>();
// 第一个接口的token
const [appToken, setAppToken] = useState<any>()
// 第二个接口的token
const [accessToken, setAccessToken] = useState<any>()
// 查看详情
const handleViewDetail = (record: any) => {
message.info('查看详情功能待开发');
console.log('详情数据:', record);
};
// 表格列定义
const columns: ProColumns<any>[] = [
{
title: '序号',
dataIndex: 'index',
valueType: "index",
width: 48,
align: 'center',
ellipsis: true,
hideInSearch: true,
},
{
title: '单据编号',
dataIndex: 'billNo',
width: 150,
ellipsis: true,
align: 'center',
hideInSearch: false,
},
{
title: '发票代码',
dataIndex: 'invoiceCode',
width: 120,
ellipsis: true,
align: 'center',
hideInSearch: true,
},
{
title: '发票号码',
dataIndex: 'invoiceNumber',
width: 120,
ellipsis: true,
align: 'center',
hideInSearch: true,
},
{
title: '发票种类',
dataIndex: 'invoiceType',
width: 120,
ellipsis: true,
align: 'center',
valueType: 'select',
valueEnum: {
'004': { text: '增值税纸质专用发票' },
'007': { text: '增值税纸质普通发票' },
'025': { text: '增值税电子普通发票(卷票)' },
'026': { text: '增值税电子普通发票' },
'028': { text: '增值税电子专用发票' },
'08xdp': { text: '数电专票' },
'10xdp': { text: '数电普票' },
},
},
{
title: '购方名称',
dataIndex: 'buyerName',
width: 200,
ellipsis: true,
align: 'center',
hideInSearch: true,
},
{
title: '购方税号',
dataIndex: 'buyerTaxpayerId',
width: 180,
ellipsis: true,
align: 'center',
hideInSearch: false,
},
{
title: '销方名称',
dataIndex: 'sellerName',
width: 180,
align: 'center',
ellipsis: true,
hideInSearch: true,
},
{
title: '销方税号',
dataIndex: 'sellerTaxpayerId',
width: 180,
align: 'center',
ellipsis: true,
hideInSearch: false,
},
{
title: '开票日期',
dataIndex: 'invoiceDate',
valueType: 'date',
width: 120,
ellipsis: true,
align: 'center',
hideInSearch: true,
render: (text, record) => {
if (record.invoiceDate) {
return new Date(record.invoiceDate).toLocaleDateString();
}
return '-';
},
},
{
title: '合计金额',
dataIndex: 'totalAmount',
width: 120,
align: 'center',
hideInSearch: true,
render: (text) => {
if (text !== undefined && text !== null) {
return `¥${Number(text).toFixed(2)}`;
}
return '-';
},
},
{
title: '合计税额',
dataIndex: 'totalTaxAmount',
width: 120,
align: 'center',
hideInSearch: true,
render: (text) => {
if (text !== undefined && text !== null) {
return `¥${Number(text).toFixed(2)}`;
}
return '-';
},
},
{
title: '发票状态',
dataIndex: 'invoiceStatus',
width: 100,
align: 'center',
ellipsis: true,
hideInSearch: false,
valueType: 'select',
valueEnum: {
0: { text: '正常', status: 'Success' },
1: { text: '作废', status: 'Error' },
2: { text: '红冲', status: 'Warning' },
},
},
{
title: '操作',
valueType: 'option',
width: 200,
align: 'center',
fixed: 'right',
hideInSearch: true,
render: (text, record) => [
<Popconfirm
title="确认撤回?"
onConfirm={async () => {
await handleRevoke(record)
}}
onCancel={() => { }}
okText="确认"
cancelText="取消"
>
< Button type="primary" size="small" ></Button >
</Popconfirm>,
<Popconfirm
title="确认红冲?"
onConfirm={async () => {
await handleRedReversal(record)
}}
onCancel={() => { }}
okText="确认"
cancelText="取消"
>
< Button type="primary" size="small" ></Button >
</Popconfirm>
],
},
];
// 撤回
const handleRevoke = async (params: any) => {
console.log('paramsparamsparams', params);
const queryData = {
sellerTaxpayerId: "91530112MA7MQ2JR9U",
serialNos: params.billNo || "",
};
// 将data字段进行base64加密
const dataString = JSON.stringify(queryData);
const encryptedData = btoa(unescape(encodeURIComponent(dataString)));
const req: any = {
requestId: Date.now().toString(),
businessSystemCode: "BUSINESS_YCIC",
interfaceCode: "BILL.WITHDRAW",
data: encryptedData
}
// 他这个接口 就一个地址 改不一样的参数就能调不一样的接口
const data = await handleGetInvoiceSearch(req, accessToken)
if (data && data.success) {
let res = JSON.parse(decodeURIComponent(escape(atob(data.data))))
if (res && res.length > 0) {
let result = res[0]
message.success(result.message)
actionRef.current?.reload()
}
} else {
message.error(data?.message || '查询失败');
}
}
// 红冲
const handleRedReversal = async (params: any) => {
const queryData = {
billNo: params?.billNo || "",
drawer: params?.drawer || "",
orgCode: params?.orgCode || "",
sellerTaxpayerId: "91530112MA7MQ2JR9U",
redReason: "",
};
// 将data字段进行base64加密
const dataString = JSON.stringify(queryData);
const encryptedData = btoa(unescape(encodeURIComponent(dataString)));
const req: any = {
requestId: Date.now().toString(),
businessSystemCode: "BUSINESS_YCIC",
interfaceCode: "BILL.QUICK.RED",
data: encryptedData
}
// 他这个接口 就一个地址 改不一样的参数就能调不一样的接口
const data = await handleGetInvoiceSearch(req, accessToken)
console.log('datadatadatadata', data);
if (data && data.success) {
let res = JSON.parse(decodeURIComponent(escape(atob(data.data))))
console.log('resresresresres', res);
if (res && res.length > 0) {
let result = res[0]
message.success(result.message)
actionRef.current?.reload()
}
} else {
message.error(data?.message || '查询失败');
}
}
// 请求表格数据
const request = async (params: any) => {
try {
console.log('查询参数:', params);
let req: any = {
appId: "FPY001",
appSecret: "FPY001fpy@2023***",
accountId: "2280459335882518528",
tenantid: "xhcamzchwbgonerr",
language: ""
}
const token = await handleGetAppToken(req)
console.log('tokentokentoken', token);
let appToken: any = token.data.app_token
let tokenReq: any = {
user: "18620126214",
apptoken: appToken,
tenantid: "xhcamzchwbgonerr",
accountId: "2280459335882518528",
usertype: ""
}
const accessToken: any = await handleGetSDToken(tokenReq)
console.log('accessTokenaccessTokenaccessToken', accessToken);
setAppToken(appToken)
setAccessToken(accessToken.data.access_token)
// 构造查询数据
const queryData = {
sellerTaxpayerId: "91530112MA7MQ2JR9U",
serialNo: params.serialNo || "SRM_202508220966",
};
// 将data字段进行base64加密
const dataString = JSON.stringify(queryData);
const encryptedData = btoa(unescape(encodeURIComponent(dataString)));
// 构造最终请求参数
const requestParams = {
businessSystemCode: "BUSINESS_YCIC",
interfaceCode: "BILL.INVOICE.QUERY",
requestId: Date.now().toString(),
data: encryptedData
};
console.log('最终请求参数:', requestParams);
// 调用查询接口 (这里需要传入正确的code参数)
const response = await handleGetInvoiceSearch(requestParams, accessToken.data.access_token);
console.log('responseresponseresponseresponse', response);
if (response && response.success) {
let res = JSON.parse(decodeURIComponent(escape(atob(response.data))))
console.log('最终请求结果:', res);
let result = res[0].invoiceList
return { data: result || [], success: true };
} else {
message.error(response?.message || '查询失败');
return { data: [], success: true };
}
} catch (error) {
console.error('查询异常:', error);
message.error('查询异常,请重试');
return {
data: [],
success: false,
total: 0,
};
}
};
return (
<div>
<ProTable
actionRef={actionRef}
formRef={formRef}
columns={columns}
request={request}
bordered
rowKey="id"
scroll={{ x: "100%", y: 'calc(100vh - 450px)' }}
headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}></span>}
search={{ span: 6 }}
toolBarRender={() => [
]}
/>
</div>
);
};
export default InvoiceSearch;