import { BizContainer, BizValueType, ButtonAccess, ModeType, } from '@/components'; import { business } from '@/services'; import { formatBankCard, formatIdCard, formatPhone } from '@/utils/format'; import { useIntl } from '@@/exports'; import { EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons'; import { ProColumns } from '@ant-design/pro-components'; import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import { Button, Image, Modal, Space, Tag } from 'antd'; import React, { useState } from 'react'; interface IOrderSupplierListProps { ghost?: boolean; orderId?: BusinessAPI.OrderVO['orderId']; supplierInvoiceVO?: BusinessAPI.SupplierInvoiceVO; search?: boolean; onValueChange?: () => void; mode?: ModeType; trigger?: () => React.ReactNode; } export default function OrderSupplierList(props: IOrderSupplierListProps) { const { ghost = false, orderId, search = true, mode = 'page', trigger, onValueChange, supplierInvoiceVO, } = props; const intl = useIntl(); const intlPrefix = 'orderSupplier'; const [showIdCard, setShowIdCard] = useState>({}); const [showBankCard, setShowBankCard] = useState>({}); const [showPhone, setShowPhone] = useState>({}); const [activeKey, setActiveKey] = useState('ALL'); // 发票预览相关状态 const [invoiceVisible, setInvoiceVisible] = useState(false); const [contractVisible, setContractVisible] = useState(false); const [wechatQrVisible, setWechatQrVisible] = useState(false); const [paymentVoucherVisible, setPaymentVoucherVisible] = useState(false); const [currentRecord, setCurrentRecord] = useState(null); const columns: ProColumns[] = [ { title: intl.formatMessage({ id: intlPrefix + '.column.order' }), dataIndex: 'orderVO', key: 'orderId', valueType: 'order', }, { title: intl.formatMessage({ id: intlPrefix + '.column.name' }), dataIndex: 'name', key: 'name', }, { title: intl.formatMessage({ id: intlPrefix + '.column.invoiceAmount' }), dataIndex: 'invoiceAmount', key: 'invoiceAmount', valueType: 'money', search: false, }, { title: intl.formatMessage({ id: intlPrefix + '.column.depositAmount' }), dataIndex: 'depositAmount', key: 'depositAmount', valueType: 'money', search: false, }, // 剩余付款金额 { title: intl.formatMessage({ id: intlPrefix + '.column.remainingAmount', }), dataIndex: 'remainingAmount', key: 'remainingAmount', valueType: 'money', search: false, renderText: (_, record) => { return record.invoiceAmount - record.depositAmount || 0; }, }, { title: intl.formatMessage({ id: intlPrefix + '.column.supplierInvoice' }), dataIndex: 'supplierInvoiceVO', key: 'supplierInvoiceId', search: false, valueType: 'supplierInvoice', }, { title: intl.formatMessage({ id: intlPrefix + '.column.invoiceUpload' }), dataIndex: 'invoiceUpload', key: 'invoiceUpload', search: false, valueType: 'switch', render: (_, record) => ( {record.invoiceUpload ? intl.formatMessage({ id: intlPrefix + '.column.invoiceUpload.uploaded', }) : intl.formatMessage({ id: intlPrefix + '.column.invoiceUpload.notUploaded', })} ), }, { title: intl.formatMessage({ id: intlPrefix + '.column.contractUpload' }), dataIndex: 'contractUpload', key: 'contractUpload', search: false, valueType: 'switch', render: (_, record) => ( {record.contractUpload ? intl.formatMessage({ id: intlPrefix + '.column.contractUpload.uploaded', }) : intl.formatMessage({ id: intlPrefix + '.column.contractUpload.notUploaded', })} ), }, { title: intl.formatMessage({ id: intlPrefix + '.column.idCard', }), dataIndex: 'idCard', key: 'idCard', search: false, render: (_, record) => (
{formatIdCard(record.idCard, showIdCard[record.orderSupplierId])} { setShowIdCard((prev) => ({ ...prev, [record.orderSupplierId]: !prev[record.orderSupplierId], })); }} > {showIdCard[record.orderSupplierId] ? ( ) : ( )}
), }, { title: intl.formatMessage({ id: intlPrefix + '.column.phone' }), dataIndex: 'phone', key: 'phone', search: false, render: (_, record) => (
{formatPhone(record.phone, showPhone[record.orderSupplierId])} { setShowPhone((prev) => ({ ...prev, [record.orderSupplierId]: !prev[record.orderSupplierId], })); }} > {showPhone[record.orderSupplierId] ? ( ) : ( )}
), }, { title: intl.formatMessage({ id: intlPrefix + '.column.bankCard' }), dataIndex: 'bankCard', key: 'bankCard', search: false, render: (_, record) => (
{formatBankCard( record?.bankCard || '', showBankCard[record.orderSupplierId], )} { setShowBankCard((prev) => ({ ...prev, [record.orderSupplierId]: !prev[record.orderSupplierId], })); }} > {showBankCard[record.orderSupplierId] ? ( ) : ( )}
), }, { title: intl.formatMessage({ id: intlPrefix + '.column.orderCompany' }), dataIndex: 'orderCompany', key: 'companyId', valueType: 'company', }, { title: intl.formatMessage({ id: intlPrefix + '.column.isPaid' }), dataIndex: 'isPaid', key: 'isPaid', valueType: 'select', valueEnum: { true: { text: intl.formatMessage({ id: intlPrefix + '.column.isPaid.paid', }), status: 'success', }, false: { text: intl.formatMessage({ id: intlPrefix + '.column.isPaid.unpaid', }), status: 'processing', }, }, }, ]; const detailColumns: ProDescriptionsItemProps< BusinessAPI.OrderSupplierVO, BizValueType >[] = columns as ProDescriptionsItemProps< BusinessAPI.OrderSupplierVO, BizValueType >[]; return ( <> rowKey={'orderSupplierId'} permission={'operation-order-supplier'} func={business.orderSupplier} method={'orderSupplier'} methodUpper={'OrderSupplier'} intlPrefix={intlPrefix} modeType={mode} onValueChange={onValueChange} container={{ ghost, }} status={false} page={{ fieldProps: { bordered: true, ghost, //@ts-ignore search, params: { ...(activeKey !== 'ALL' && { isPaid: activeKey! as any, }), ...(supplierInvoiceVO && { invoiceId: supplierInvoiceVO.supplierInvoiceId, }), poStates: ['COMPLETED'], type: 'FARMER', }, tableAlertOptionRender: (props) => { return ( ); }, toolbar: { menu: { type: 'tab', activeKey: activeKey, items: [ // 全部 { key: 'ALL', label: intl.formatMessage({ id: intlPrefix + '.tab.all', }), }, // 已支付 { key: 'true', label: intl.formatMessage({ id: intlPrefix + '.tab.paid', }), }, // 未支付 { key: 'false', label: intl.formatMessage({ id: intlPrefix + '.tab.unpaid', }), }, ], onChange: (key) => { setActiveKey(key as string); }, }, }, }, columns, options: (orderSupplierVO) => { let btn = []; if (orderSupplierVO.invoiceUpload) { btn.push( { setCurrentRecord(orderSupplierVO); setInvoiceVisible(true); }} > 查看发票 , ); } if (orderSupplierVO.wechatQr) { btn.push( { setCurrentRecord(orderSupplierVO); setWechatQrVisible(true); }} > 查看微信收款码 , ); } if (orderSupplierVO.contractUpload) { btn.push( { setCurrentRecord(orderSupplierVO); setContractVisible(true); }} > 查看合同 , ); } if (orderSupplierVO.isPaid) { btn.push( { setCurrentRecord(orderSupplierVO); setPaymentVoucherVisible(true); }} > 查看付款凭证 , ); } return btn; }, }} create={false} update={false} destroy={false} detail={{ rowId: orderId, formType: 'drawer', columns: detailColumns, trigger, }} /> {/* 发票预览Modal */} setInvoiceVisible(false)} footer={null} width={800} centered > {currentRecord?.invoiceImg && currentRecord.invoiceImg.length > 0 ? (
{currentRecord.invoiceImg.map((item, index) => (

发票 {index + 1}

{item.fileName加载中...
} />

{item.fileName || `发票${index + 1}`}

))} ) : (
暂无发票图片
)}
{/* 合同预览Modal */} setContractVisible(false)} footer={null} width={800} centered > {currentRecord?.contractImg && currentRecord.contractImg.length > 0 ? (
{currentRecord.contractImg.map((item, index) => (

合同 {index + 1}

{item.fileName加载中...
} />

{item.fileName || `合同${index + 1}`}

))} ) : (
暂无合同图片
)}
{/* 微信收款码预览Modal */} setWechatQrVisible(false)} footer={null} width={400} centered > {currentRecord?.wechatQr ? (
微信收款码加载中...
} /> ) : (
暂无微信收款码
)}
{/* 付款凭证预览Modal */} setPaymentVoucherVisible(false)} footer={null} width={800} centered >
暂无付款凭证图片
); }