import ButtonConfirm from '@/components/ButtomConfirm'; import { RESPONSE_CODE } from '@/constants/enum'; import InvoicingDrawerForm from '@/pages/Order/OrderWarning/components/InvoicingDrawerForm'; import ReissueModal from '@/pages/Order/OrderWarning/components/ReissueModal'; import ReissueModal_old from '@/pages/Order/OrderWarning/components/ReissueModal_old'; import { postKingdeeRepSalBillOutbound, postKingdeeRepSalOrderSave, postServiceInvoiceCancelApply, postServiceOrderCancelSend, postServiceOrderConfirmInvoice, postServiceOrderGetCurrentOptNode, postServiceOrderNoNeedSend, postServiceOrderOrderCancel, postServiceOrderProcureOrder, postServiceOrderProcurePrint, postServiceOrderProvideProcurementRoles, postServiceOrderQueryServiceOrder, postServiceOrderSaleCancelInvoicing, postServiceOrderSalesConfirm, postServiceOrderWarningOrderStatistics, } from '@/services'; import { FloatAdd, copyToClipboard, enumToProTableEnumValue, enumValueToLabel, formatDateTime, formatdate, getAliYunOSSFileNameFromUrl, isImageName, } from '@/utils'; import { getReceivingCompanyOptions, getSalesCodeOptions, isAdmin, isExaminer, isFinance, isProcure, isSales, isSupplier, isWarehousekeeper, } from '@/utils/order'; import { getUserInfo } from '@/utils/user'; import { ClockCircleTwoTone, ContainerTwoTone, CopyOutlined, CopyTwoTone, EditTwoTone, QuestionCircleOutlined, } from '@ant-design/icons'; import { ActionType, ProColumns, ProFormInstance, ProFormSelect, ProTable, } from '@ant-design/pro-components'; import { Badge, Button, Checkbox, Divider, Flex, FloatButton, Image, Popconfirm, Radio, Space, Spin, Tag, Tooltip, message, } from 'antd'; import Base64 from 'base-64'; import { format } from 'date-fns'; import { cloneDeep } from 'lodash'; import React, { Key, useEffect, useRef, useState } from 'react'; import OrderPrintModal from '../../OrderPrint/OrderPrintModal'; import { AFTER_INVOICING_STATUS, CHECK_TYPE, LOGISTICS_STATUS_OPTIONS, MAIN_ORDER_COLUMNS, MODIFIED_AUDIT_STATUS_OPTIONS, ORDER_STATUS_OPTIONS, PAYEE_OPTIONS, PAYMENT_CHANNEL_OPTIONS, PAYMENT_RECEIPTS_STATUS_OPTIONS, POST_AUDIT_OPTIONS, PROCURE_ORDER_STATUS, PROCURE_PRIMARY_ORDER_STATUS_OPTIONS, PRODUCT_BELONG_DEPARTMENT_OPTIONS, SHIPPING_WAREHOUSE_OPTIONS, TAGS_COLOR, getInvoicingType, getNeedInvoicing, } from '../constant'; import AfterSalesDrawer from './components/AfterSalesDrawer'; import ApplyForInvoicingModal from './components/ApplyForInvoicingModal'; import AttachmentModal from './components/AttachmentModal'; import CheckModal from './components/CheckModal'; import ConfirmReceiptModal from './components/ConfirmReceiptModal'; import DeliverInfoDrawer from './components/DeliverInfoDrawer'; import DeliverModal from './components/DeliverModal'; import FeedbackRegistrationModal from './components/FeedbackRegistrationModal'; import FinancialDrawer from './components/FinancialDrawer'; import FinancialEditDrawer from './components/FinancialEditDrawer'; import FinancialMergeDrawer from './components/FinancialMergeDrawer'; import FinancialReceiptsModal from './components/FinancialReceiptsModal'; import HistoryModal from './components/HistoryModal'; import ImagesViewerModal from './components/ImagesViewerModal'; import ImportModal from './components/ImportModal'; import ModifiedDiffModal from './components/ModifiedDiffModal'; import OrderDrawer from './components/OrderDrawer'; import OrderNotesEditModal from './components/OrderNotesEditModal'; import ProcureCheckModal from './components/ProcureCheckModal'; import ProcureConvertModal from './components/ProcureConvertModal'; import ProductionTimeModal from './components/ProductionTimeModal'; import ShippingWarehouseChangeModal from './components/ShippingWarehouseChangeModal'; import UploadPayBillModal from './components/UploadPayBillModal'; import './index.less'; import { OrderListItemType, OrderType } from './type.d'; // import { useParams } from '@umijs/max'; const OrderPage = () => { const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false); const [checkVisible, setCheckVisible] = useState<boolean>(false); const [orderPrintVisible, setOrderPrintVisible] = useState<boolean>(false); const [salesCodeOptions, setSalesCodeOptions] = useState([]); const [allMainChecked, setAllMainChecked] = useState(false); const [salesCodeSelect, setSalesCodeSelect] = useState(); const [imagesViewerModalVisible, setImagesViewerModalVisible] = useState<boolean>(false); const [data, setData] = useState([]); //列表数据 const [notesEditVisible, setNotesEditVisible] = useState<boolean>(false); const [financialMergeDrawerVisible, setFinancialMergeDrawerVisible] = useState<boolean>(false); const [attachmentModalVisible, setAttachmentModalVisible] = useState<boolean>(false); const [uploadPayBillModalVisible, setUploadPayBillModalVisible] = useState<boolean>(false); const [ feedbackRegistrationModalVisible, setFeedbackRegistrationModalVisible, ] = useState<boolean>(false); const [modifiedDiffModalVisible, setModifiedDiffModalVisible] = useState<boolean>(false); const [financialReceiptsModalVisible, setFinancialReceiptsModalVisible] = useState(false); const [financialVisible, setFinancialVisible] = useState<boolean>(false); const [financialEditVisible, setFinancialEditVisible] = useState<boolean>(false); const [afterSalesDrawerVisible, setAfterSalesDrawerVisible] = useState<boolean>(false); const [historyModalVisible, setHistoryModalVisible] = useState<boolean>(false); const [isRePrintOrder, setIsRePrintOrder] = useState<boolean>(false); const [isSendProduct, setIsSendProduct] = useState<boolean>(false); const [isMainOrder, setIsMainOrder] = useState<boolean>(false); const [importModalVisible, setImportModalVisible] = useState<boolean>(false); const [reissueVisible, setReissueVisible] = useState<boolean>(false); const [reissueVisibleOld, setReissueVisibleOld] = useState<boolean>(false); const [applyForInvoicingVisible, setApplyForInvoicingVisible] = useState<boolean>(false); const [procureCheckModalVisible, setProcureCheckModalVisible] = useState<boolean>(false); const [procureConvertModalVisible, setProcureConvertModalVisible] = useState<boolean>(false); const [invoicingDrawerFormVisible, setInvoicingDrawerFormVisible] = useState<boolean>(false); const [confirmReceiptVisible, setConfirmReceiptVisible] = useState<boolean>(false); const [productionTimeModalVisible, setProductionTimeModalVisible] = useState<boolean>(false); const [deliverVisible, setDeliverVisible] = useState<boolean>(false); const [deliverInfoDrawerVisible, setDeliverInfoDrawerVisible] = useState<boolean>(false); const [orderOptType, setOrderOptType] = useState<string>(''); const [isEdit, setIsEdit] = useState<boolean>(false); const [expandedRowKeys] = useState<Key[]>([]); const [notesType, setNotesType] = useState(1); const [notes, setNotes] = useState(1); const [rolePath, setRolePath] = useState([]); //当前角色权限(新增跟打印按钮) const userInfo = getUserInfo(); // const [tableHeight, setTableHeight] = useState(200); const [selectedRows, setSelectedRows] = useState([]); const [mainOrderIdSubOrderIdRelationsMap] = useState(new Map()); //主订单id与子订单id的对照关系,用于主订单子订单的勾选校验,子订单全选中对应的主订单自动勾选上 const [selectedMainOrderKeys, setSelectedMainOrderKeys] = useState<any[]>([]); const [selectedSubOrderKeys, setSelectedSubOrderKeys] = useState<any[]>([]); const [pageSize, setPageSize] = useState(10); const [currentPage, setCurrentPage] = useState(1); const [orderCheckType, setOrderCheckType] = useState(''); const [imagesViewerOptType, setImagesViewerOptType] = useState(''); const [filterCondifion] = useState(0); const [mainOrderSelectedMap] = useState(new Map()); //选中的主订单Map key:主订单id value:主订单数据 const [subOrderSelectedMap, setSubOrderSelectedMap] = useState(new Map()); //选中的子订单Map key:主订单id value:选中的子订单数据集合 const [currentOptMainId, setCurrentMainId] = useState<any>(undefined); //当前操作对象的主订单id // const [currentOptMainId, setCurrentMainId] = useState<any>(undefined); //当前操作对象的主订单id const [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id // const [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id const [subOrderCount, setSubOrderCount] = useState(0); const [sorted] = useState(false); const mainTableRef = useRef<ActionType>(); const mainTableFormRef = useRef<ProFormInstance>(); let [searchParams, setSearchParam] = useState(Object); //表格的查询条件存储 console.log(searchParams); const [messageApi, contextHolder] = message.useMessage(); console.log(messageApi); const [ shippingWarehouseChangeModalVisible, setShippingWarehouseChangeModalVisible, ] = useState(false); const [ids, setIds] = useState([]); const [recordOptNode, setRecordOptNode] = useState(null); const roleCode = userInfo?.roleSmallVO?.code; const [activeTabKey, setActiveTabKey] = useState(1); // **新增状态** const triggerRecordOptNode = async (id) => { const res = await postServiceOrderGetCurrentOptNode({ query: { id, }, }); setRecordOptNode(res.data); }; const refreshTable = () => { mainTableRef.current?.reload(); //刷新表格数据的时候,取消选中行 setSelectedRows([]); setSelectedSubOrderKeys([]); }; /*useEffect(() => { let initAfterInvoicingStatus = async () => { const afteInvoicingStatus = await getAfterInvoicingStatus(); setAfterInvoicingStatus(afteInvoicingStatus); }; initAfterInvoicingStatus(); }, []);*/ useEffect(() => { // 使用URLSearchParams来解析查询参数 const params = new URLSearchParams(location.search); const id = params.get('id'); const subOrderId = params.get('subOrderId'); if (id) { mainTableFormRef.current?.setFieldValue('id', id); } if (subOrderId) { mainTableFormRef.current?.setFieldValue('subOrderId', subOrderId); } }, []); /** * 复制订单到剪贴板 * @param record */ function copyOrderToClipboard(record: any) { let text = ''; text += record?.id; text += ',' + record?.salesCode; text += ',' + record?.customerName; text += ',' + record?.customerContactNumber; text += ',' + record?.customerShippingAddress; if (!isSupplier()) { text += ',' + record?.institutionContactName; text += ',' + record?.institution; } record?.subOrderInformationLists?.forEach((item) => { text += '\n'; text += item?.productName; text += ' ' + item?.parameters; text += ' ' + item?.quantity; text += ' ' + item?.unit; if (!isSupplier()) { text += ' ¥' + item?.subOrderPayment; } text += ' ' + item?.id; }); if (copyToClipboard(text)) { message.info('已复制到剪贴板'); } else { message.info('无法复制到剪贴板'); } } const MyToolTip = ({ title, content }) => { return ( <Tooltip color="#FFFFFF" placement="bottom" title={<div className="px-5 py-4 text-black">{title}</div>} > {content} </Tooltip> ); }; /** * 检查是否可以打印 * @param paths 按钮集合 * @returns */ function checkePrintable(paths: any) { if ( !paths?.includes('printOrder') && !paths?.includes('supplierPrint') && !paths?.includes('procurePrint') && !paths?.includes('rePrintOrder') ) { return false; } return true; } /** * 重置当前的操作对象 */ function clearOptObject() { setCurrentMainId(undefined); setCurretnOptSubId(undefined); setIsMainOrder(false); } /** * 初始化当前的操作对象 * @param subId * @param mainId */ function createOptObject(subId: any, mainId: any) { setCurrentMainId(mainId); setCurretnOptSubId(subId); } /** * 检查当前操作是否异常 */ // function checkOptValid() { // if ((currentOptMainId === undefined || currentOptMainId === null) && (curretnOptSubId === undefined || curretnOptSubId === null)) { // message.error("页面错误:当前操作对象为空,请联系系统管理员"); // return false; // } // //检查数据是否存在 // //主订单数据 // if (!Array.from(mainOrderIdSubOrderIdRelationsMap.keys()).includes(currentOptMainId)) { // message.error("页面错误:当前操作主订单对象为空,请联系系统管理员"); // } // //子订单 // let allSubIds = []; // for (const idList of mainOrderIdSubOrderIdRelationsMap.values()) { // allSubIds.push(...idList); // } // if (!allSubIds.includes(curretnOptSubId)) { // message.error("页面错误:当前操作子订单对象为空,请联系系统管理员"); // return false // } // return true; // } /** * 获取当前选中子订单的其中一个主订单 */ function getFirstMainOrder() { let mainId = [...subOrderSelectedMap.values()].flat()[0].mainOrderId; for (let item of data) { if (item.id === mainId) { return item; } } return null; } /** * 返回当前操作的主订单数据 */ function buildMainOrder() { if (!currentOptMainId) { message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员'); return; } let mainOrderClone = null; let matchedData = data.filter((item) => { return item.id === currentOptMainId; }); if (matchedData.length > 0) { mainOrderClone = cloneDeep(matchedData[0]); } if (!mainOrderClone) { message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员'); } return mainOrderClone; } /** * 返回当前操作的子订单集合 */ function buildSubOrders() { if (!currentOptMainId) { message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员'); return; } let cloneSubOrders = []; //如果没有传当前操作的子订单id,说明是操作主订单 if (curretnOptSubId === undefined || curretnOptSubId === null) { // if (!curretnOptSubId) { //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象 let currentOptSubOrders = subOrderSelectedMap.get(currentOptMainId); if ( currentOptSubOrders === null || currentOptSubOrders === undefined || currentOptSubOrders.length === 0 ) { for (let item of data) { if (item.id === currentOptMainId) { for (let subOrder of item?.subOrderInformationLists) { cloneSubOrders.push(cloneDeep(subOrder)); } } } } else { cloneSubOrders = currentOptSubOrders.map((item) => { return cloneDeep(item); }); } } else { //操作的是子订单 for (let item of data) { if (item.id === currentOptMainId) { for (let subOrder of item?.subOrderInformationLists) { if (subOrder.id === curretnOptSubId) { cloneSubOrders.push(cloneDeep(subOrder)); break; } } } } } if (cloneSubOrders.length === 0) { message.error('页面错误:当前操作的订单数据不存在,请联系系统管理员'); return; } return cloneSubOrders; } /** * 获取当前操作申请开票的订单总金额 */ function getApplyInvoicingTotalPayment() { let subOrders = isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders(); let totalPayment = 0; if (subOrders && subOrders.length > 0) { let mainIds = subOrders?.map((item: any) => { return item.mainOrderId; }); let uniqueMainIds = [...new Set(mainIds)]; let dataMap = data.reduce((map, obj: any) => { map.set(obj.id, obj); return map; }, new Map()); uniqueMainIds.forEach((id: any) => { let o = dataMap.get(id); if (o) { totalPayment = FloatAdd(totalPayment, o.totalPayment); } }); } return totalPayment; } /** * 根据主订单id,将该主订单下的所有子订单取消选中 */ const removeSelectedSubOrderKeysByMainOrderId = (id: any) => { let currentMainOrderAllSubOrderIds = mainOrderIdSubOrderIdRelationsMap.get(id); if (currentMainOrderAllSubOrderIds) { let newSelectedSubOrderKeys = selectedSubOrderKeys.filter((item) => { return !currentMainOrderAllSubOrderIds.includes(item); }); setSelectedSubOrderKeys(newSelectedSubOrderKeys); } }; /** * 根据主订单id取消选中主订单 * @param id */ const removeSelecetMainOrderKeyByMainOrderId = (id: any) => { if (selectedMainOrderKeys.includes(id)) { let newSelectedMainOrderKeys = selectedMainOrderKeys.filter((item) => { return item !== id; }); setSelectedMainOrderKeys(newSelectedMainOrderKeys); } }; const onCheckboxChange = (record: never) => { let newSelectedMainOrderKeys = []; if (selectedMainOrderKeys.includes(record.id)) { newSelectedMainOrderKeys = selectedMainOrderKeys.filter( (key) => key !== record.id, ); removeSelectedSubOrderKeysByMainOrderId(record.id); setSelectedRows([]); //删除选中主订单的信息 mainOrderSelectedMap.delete(record.id); //删除选中主订单附属子订单的信息 subOrderSelectedMap.delete(record.id); //总选中按钮取消选中 setAllMainChecked(false); } else { newSelectedMainOrderKeys = [...selectedMainOrderKeys, record.id]; //子订单全部自动选中 let subIds = record.subOrderInformationLists?.map((item) => { return item.id; }); let newSelectedSubOrderKeys = [...selectedSubOrderKeys]; for (let subId of subIds) { if (!selectedSubOrderKeys.includes(subId)) { newSelectedSubOrderKeys.push(subId); } } setSelectedSubOrderKeys(newSelectedSubOrderKeys); setSelectedRows(record.subOrderInformationLists); //选中主订单 mainOrderSelectedMap.set(record.id, record); //选中子订单 subOrderSelectedMap.set(record.id, record.subOrderInformationLists); setSubOrderSelectedMap(new Map(subOrderSelectedMap)); //如果所有主订单都勾选上了,那么勾选上总选中按钮 if ( mainOrderSelectedMap?.size === mainOrderIdSubOrderIdRelationsMap.size ) { setAllMainChecked(true); } } setSelectedMainOrderKeys(newSelectedMainOrderKeys); }; // const handleTableExpand = (mainOrderIds: any) => { // setExpandedRowKeys(mainOrderIds); // }; const allMainCheckBoxChange = () => { let checked = !allMainChecked; setAllMainChecked(checked); if (checked) { let mainOrderIds = data?.map((item) => { mainOrderSelectedMap.set(item.id, item); return item.id; }); let subOrderIds = []; for (let subIdList of mainOrderIdSubOrderIdRelationsMap.values()) { subOrderIds.push(...subIdList); } if (data) { for (let item of data) { mainOrderSelectedMap.set(item.id, item); subOrderSelectedMap.set(item.id, item.subOrderInformationLists); } } setSelectedMainOrderKeys(mainOrderIds); setSelectedSubOrderKeys(subOrderIds); } else { setSelectedMainOrderKeys([]); setSelectedSubOrderKeys([]); mainOrderSelectedMap.clear(); subOrderSelectedMap.clear(); } }; //表头渲染 const OrderTableHeader = () => { return ( <Flex className="w-full"> <Flex className="w-[1%] ml-[7px]"> <Checkbox onChange={allMainCheckBoxChange} checked={allMainChecked} ></Checkbox> </Flex> <Flex className="w-[30%] ml-[1%]"> <span className="font-medium">商品信息</span> </Flex> <Flex className="w-[13%]"> <span className="font-medium">交易金额</span> </Flex> {!isSupplier() ? ( <> <Flex className="w-[10%]"> <span className="font-medium">支付</span> </Flex> <Flex className="w-[12%]"> <span className="font-medium">其他</span> </Flex> </> ) : ( '' )} <Flex className="w-[10%]"> <span className="font-medium">交易状态</span> </Flex> <Flex className="w-[17%]"> <span className="font-medium">操作</span> </Flex> </Flex> ); }; //子订单内容渲染 const SubOderRander = ({ record, optRecord }) => { /** * 获取订单状态标签 * @param optRecord */ function getOrderStatusTag(optRecord: any): import('react').ReactNode { console.log(optRecord); const orderStatus = optRecord.orderStatus; const paymentMethod = optRecord.paymentMethod; let orderStatusTagText = enumValueToLabel( optRecord.orderStatus, ORDER_STATUS_OPTIONS, ); if (orderStatus === 'WAIT_CONFIRM_DELIVER_AFTER_INVOICE') { if (optRecord.afterInvoicingStatus !== 'COMPLETE_INVOICING') { orderStatusTagText = '待开票'; } else { orderStatusTagText = '待确认发货'; } } //如果是未审核或者领导已审核,付款状态为预付款则需要财务审核【财务待审核】,否则仓库审核【】 if (orderStatus === 'UNAUDITED' || orderStatus === 'LEADER_AUDITED') { if (paymentMethod === 'PAYMENT_IN_ADVANCE') { orderStatusTagText = '财务待审核'; } else { orderStatusTagText = '仓库待审核'; } } //如果是财务已审核,显示为【仓库待审核】 if (orderStatus === 'FINANCE_PROCESS') { orderStatusTagText = '仓库待审核'; } if (orderStatus === 'AUDIT_FAILED') { return ( <MyToolTip key="key" title={optRecord.checkNotes + ' ' + optRecord.postAuditNotes} content={ <> <Tag color={TAGS_COLOR.get(optRecord.orderStatus)} style={{ marginRight: '4px' }} > {orderStatusTagText} </Tag> <QuestionCircleOutlined style={{ color: '#C1C1C1' }} /> </> } /> ); } if ( orderStatus === 'AFTER_SALES_COMPLETION' || orderStatus === 'IN_AFTER_SALES' ) { return ( <Tag color={TAGS_COLOR.get(optRecord.orderStatus)} style={{ marginRight: '4px' }} > {orderStatusTagText} </Tag> ); } if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') { return ( <MyToolTip key="key" title={optRecord.checkNotes} content={ <> <Tag color={TAGS_COLOR.get(optRecord.orderStatus)} style={{ marginRight: '4px' }} > {orderStatusTagText} </Tag> <QuestionCircleOutlined style={{ color: '#C1C1C1' }} /> </> } /> ); } return ( <Tag key="key" color={TAGS_COLOR.get(optRecord.orderStatus)}> {orderStatusTagText} </Tag> ); } /** * 获取后置审核状态标签 * @param optRecord */ function getPostAuditStatusTag(optRecord: any): import('react').ReactNode { return ( <Tag key="key" color={TAGS_COLOR.get(optRecord.postAuditStatus)}> {enumValueToLabel(optRecord.postAuditStatus, POST_AUDIT_OPTIONS)} </Tag> ); } //申请开票附件处理 const getAfterAnnexList = () => { // let links = []; let afterAnnexList = optRecord.afterAnnexList; let i = 1; let images = []; let otherAnnex = []; if (afterAnnexList?.length > 0) { for (let url of afterAnnexList) { let name = getAliYunOSSFileNameFromUrl(url); if (isImageName(name)) { images.push({ name: name, url: url }); } else { otherAnnex.push({ name: '附件' + i++, url: url }); } } } return ( <div className="pl-1"> <Image.PreviewGroup className="mr-10" preview={{ onChange: (current, prev) => console.log(`current index: ${current}, prev index: ${prev}`), }} > {images.map((item, index) => ( <React.Fragment key={index}> {index > 0 ? <Divider type="vertical" /> : ''} <Image className="max-h-[50px] max-w-[70px]" src={item.url} title={item.name} />{' '} </React.Fragment> ))} </Image.PreviewGroup> {otherAnnex.map((item, index) => { return ( <Popconfirm title="下载或预览" key={index} onConfirm={() => { window.open( '/previewApi/onlinePreview?url=' + encodeURIComponent(Base64.encode(item.url)), ); }} onCancel={() => { window.open(item.url); }} okText="预览" cancelText="下载" > <Button className="px-1" key={index} type="link"> {item.name} </Button> </Popconfirm> ); })} </div> ); }; //财务审核附件处理 const getInvoicingCheckAnnexList = () => { let invoicingCheckAnnexList = optRecord.invoicingCheckAnnexList; return ( <div> <Image.PreviewGroup className="mr-10" preview={{ onChange: (current, prev) => console.log(`current index: ${current}, prev index: ${prev}`), }} > {invoicingCheckAnnexList.map((url, index) => ( <React.Fragment key={index}> <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '} <Divider type="vertical" /> </React.Fragment> ))} </Image.PreviewGroup> </div> ); }; return ( <> <Flex className="w-full border-b-indigo-500"> <Flex vertical className="w-[31%]" gap="small"> {/* 商品名称 */} <div> <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer" onClick={() => { copyToClipboard(optRecord.productName); message.info('商品名称复制成功:' + optRecord.productName); }} title={optRecord.productName} > <span className="font-medium text-black "> {optRecord.productName} </span> </div> <div className="text-xs text-[#8C8C8C]"> <span className="cursor-pointer" onClick={() => { copyToClipboard(optRecord.id); message.info('子订单编号复制成功:' + optRecord.id); }} > {optRecord.id} </span> {(roleCode === 'salesRepresentative' || roleCode === 'salesManager') && !optRecord.isCurrentUserOrder ? ( <span className="text-[#f44e4e]">(非本账号订单)</span> ) : ( '' )} {optRecord.modifiedOptFlag !== null ? ( <span className="text-[#f44e4e] cursor-pointer"> {optRecord.modifiedOptFlag === 'MODIFY' ? '(修改中)' : ''} {optRecord.modifiedOptFlag === 'DELETE' ? '(删除中)' : ''} {optRecord.modifiedOptFlag === 'INSERT' ? '(新增中)' : ''} </span> ) : ( '' )} {optRecord.modified ? ( <Tooltip title="点击查看详情"> <span className="text-[#f44e4e] cursor-pointer" onClick={async () => { createOptObject(optRecord.id, record.id); setModifiedDiffModalVisible(true); }} > (内容有变化) </span> </Tooltip> ) : ( '' )} {!optRecord.logicDelete ? ( <span className="text-[#f44e4e]">(已作废)</span> ) : ( '' )} </div> </div> <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer" title={optRecord.parameters} onClick={() => { copyToClipboard(optRecord.parameters); message.info('商品名称复制成功:' + optRecord.parameters); }} > <span className="text-[#8C8C8C]"> 参数:{optRecord.parameters} </span> </div> </Flex> <Flex className="w-[13%]" vertical gap="small"> {!isSupplier() ? ( <> <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis" title={optRecord.productPrice} > <span className="text-[#8C8C8C]">单价:</span> <span className="text-slate-700"> ¥{optRecord.productPrice} </span> </div> </> ) : ( '' )} <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis" title={optRecord.quantity} > <span className="text-[#8C8C8C]">数量:</span> <span className="text-slate-700"> x{optRecord.quantity + ' '} </span> <span className="text-[#8C8C8C]">{optRecord.unit}</span> </div> {!isSupplier() ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis" title={optRecord.subOrderPayment} > <span className="text-[#8C8C8C]">合计:</span> <span className="text-slate-700"> ¥{optRecord.subOrderPayment} </span> </div> ) : ( '' )} </Flex> <Flex className="w-[10%]" vertical gap="small"> {!isSupplier() ? ( <> {/* 支付方式 */} <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <span className="text-slate-700"> {optRecord.paymentMethodText} </span> </div> {/* 支付渠道 */} <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <span className="text-slate-700"> {enumValueToLabel( optRecord.paymentChannel, PAYMENT_CHANNEL_OPTIONS, )} </span> </div> {/* 回款审核状态 */} {optRecord.paymentReceiptStatus !== null ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tag className="hover:cursor-pointer" onMouseEnter={(e: any) => { e.target.innerText = '点击查看回款凭证'; }} onMouseLeave={(e: any) => { e.target.innerText = enumValueToLabel( optRecord.paymentReceiptStatus, PAYMENT_RECEIPTS_STATUS_OPTIONS, ); }} onClick={() => { createOptObject(optRecord.id, record.id); setImagesViewerOptType('paymentReceipt'); setImagesViewerModalVisible(true); }} key="key" color={TAGS_COLOR.get(optRecord.paymentReceiptStatus)} > {enumValueToLabel( optRecord.paymentReceiptStatus, PAYMENT_RECEIPTS_STATUS_OPTIONS, )} </Tag> </div> ) : ( '' )} </> ) : ( '' )} </Flex> <Flex className="w-[13%]" vertical gap="small"> {!isSupplier() ? ( <> {/* 所属部门 */} <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis" title={enumValueToLabel( optRecord.productBelongBusiness, PRODUCT_BELONG_DEPARTMENT_OPTIONS, )} > <span className="text-slate-700"> {enumValueToLabel( optRecord.productBelongBusiness, PRODUCT_BELONG_DEPARTMENT_OPTIONS, )} </span> </div> {/* 开票类型 */} {optRecord.invoicingStatus !== null ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <span className="text-slate-700"> {getInvoicingType(optRecord)} </span> </div> ) : ( '' )} {/* 开票状态 */} {optRecord.afterInvoicingStatus !== null ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tooltip title={ optRecord.invoicingUrgentCause !== null && optRecord.afterInvoicingStatus === 'URGENT_INVOICE_AUDITING' ? optRecord.invoicingUrgentCause : enumValueToLabel( optRecord.afterInvoicingStatus, AFTER_INVOICING_STATUS, ) } > <Tag color={TAGS_COLOR.get(optRecord.afterInvoicingStatus)} > {enumValueToLabel( optRecord.afterInvoicingStatus, AFTER_INVOICING_STATUS, )} </Tag> </Tooltip> </div> ) : ( '' )} {/* 是否加急图标显示 */} {optRecord.isUrgent ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tooltip title={'期望开票时间:' + formatdate(optRecord.deadline)} > <Tag color="red">加急开票</Tag> </Tooltip> </div> ) : ( '' )} {(roleCode === 'warehouseKeeper' || roleCode === 'admin') && optRecord.shippingWarehouse !== null ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis" title={enumValueToLabel( optRecord.shippingWarehouse, SHIPPING_WAREHOUSE_OPTIONS, )} > <span className="text-slate-700"> {enumValueToLabel( optRecord.shippingWarehouse, SHIPPING_WAREHOUSE_OPTIONS, )} </span> </div> ) : ( '' )} {/* 生产时间 */} <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> {optRecord.productionStartTime !== null || optRecord.productionEndTime !== null ? ( <MyToolTip title={ formatdate(optRecord.productionStartTime) + ' 至 ' + formatdate(optRecord.productionEndTime) } content={ <Button type="link" size="small" style={{ padding: 0 }}> 生产时间 </Button> } /> ) : ( '' )} </div> </> ) : ( '' )} </Flex> <Flex className="w-[10%]" vertical gap="small"> {/* 开票状态 */} {!isSupplier() ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tag color={ optRecord.invoicingTime === null || optRecord.invoicingTime === undefined ? TAGS_COLOR.get(optRecord.invoicingStatus) : 'success' } > {getNeedInvoicing(optRecord)} </Tag> </div> ) : ( '' )} {/* 订单状态 */} <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> {getOrderStatusTag(optRecord)} </div> {/* 后置审核状态 */} {optRecord.postAuditStatus !== null ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> {getPostAuditStatusTag(optRecord)} </div> ) : ( '' )} {/**采购是否已下单状态 */} {optRecord.procureOrderStatus !== null && optRecord.procureOrderStatus !== undefined ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tag color="success"> {enumValueToLabel( optRecord.procureOrderStatus, PROCURE_ORDER_STATUS, )} </Tag> </div> ) : ( '' )} {/* 物流信息 */} <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> {optRecord.orderStatus === 'CONFIRM_RECEIPT' || optRecord.orderStatus === 'AFTER_SALES_COMPLETION' || optRecord.orderStatus === 'IN_AFTER_SALES' || optRecord.orderStatus === 'SHIPPED' ? ( <MyToolTip title={ optRecord.serialNumber === undefined ? '暂无物流信息' : enumValueToLabel( optRecord.logisticsMethod, LOGISTICS_STATUS_OPTIONS, ) + ' ' + optRecord.serialNumber + ' ' + optRecord.logisticsNotes } content={ <Button type="link" size="small" style={{ padding: 0 }}> 物流信息 </Button> } /> ) : ( '' )} {/* 修改审核状态 */} {optRecord.modifiedAuditStatus !== null && optRecord.modifiedAuditStatus !== 'AUDIT_FAILURE' ? ( <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tooltip title={recordOptNode ? recordOptNode : <Spin />} onOpenChange={(open) => { console.log('open:' + open); console.log('id:' + optRecord.id); if (open) { triggerRecordOptNode(optRecord.id); } else { setRecordOptNode(null); } }} > <Tag color={TAGS_COLOR.get(optRecord.modifiedAuditStatus)}> {enumValueToLabel( optRecord.modifiedAuditStatus, MODIFIED_AUDIT_STATUS_OPTIONS, )} </Tag> </Tooltip> </div> ) : ( '' )} {optRecord.modifiedAuditStatus === 'AUDIT_FAILURE' ? ( <MyToolTip key="key" title={optRecord.modifiedAuditNotes} content={ <> <Tag color={TAGS_COLOR.get(optRecord.modifiedAuditNotes)} style={{ marginRight: '4px' }} > {enumValueToLabel( optRecord.modifiedAuditStatus, MODIFIED_AUDIT_STATUS_OPTIONS, )} </Tag> <QuestionCircleOutlined style={{ color: '#C1C1C1' }} /> </> } /> ) : ( '' )} </div> </Flex> <Flex className="w-[18%]" wrap="wrap" gap="small"> {optRecord.paths?.includes('postAudit') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT); }} > 后置审核 </Button> ) : ( '' )} {/* 加急审核 */} {optRecord.paths?.includes('URGENT_INVOICE_AUDITING') ? ( <Button className="p-0" type="link" onClick={() => { console.log('here'); setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING); }} > 加急审核(新) </Button> ) : ( '' )} {optRecord.paths?.includes('URGENT_INVOICE_AUDITING_old') ? ( <Button className="p-0" type="link" onClick={() => { console.log('here'); setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD); }} > 加急审核(旧) </Button> ) : ( '' )} {optRecord.paths?.includes('salesConfirm') && ( <ButtonConfirm className="p-0" title="是否确认此商城订单信息无误?确认无误之后订单将进入审核流程。" text="订单确认" onConfirm={async () => { let res = await postServiceOrderSalesConfirm({ data: { subOrderIds: [optRecord.id], }, }); if (res && res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); } }} /> )} {optRecord.paths?.includes('uploadPaymentReceiptBill') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setUploadPayBillModalVisible(true); }} > 回款 </Button> ) : ( '' )} {optRecord.paths?.includes('reissue_old') ? ( /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'|| optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/ <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setReissueVisibleOld(true); }} > 重新开票(旧) </Button> ) : ( '' )} {optRecord.paths?.includes('reissue') ? ( /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'|| optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/ <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setReissueVisible(true); }} > 重新开票(新) </Button> ) : ( '' )} {optRecord.paths?.includes('confirmReissue_old') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE_OLD); }} > 重新开票审核(旧) </Button> ) : ( '' )} {optRecord.paths?.includes('confirmReissue') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE); }} > 重新开票审核(新) </Button> ) : ( '' )} {optRecord.paths?.includes('leaderAudit') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.LEADER_AUDIT); }} > 审核 </Button> ) : ( '' )} {optRecord.paths?.includes('creditAudit') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.CREDIT_AUDIT); }} > 赊账审核 </Button> ) : ( '' )} {optRecord.paths?.includes('auditPaymentReceipt') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT); }} > 回款审核 </Button> ) : ( '' )} {optRecord.paths?.includes('modifiedAuditRequest') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.NODE_OPERATING_AUDIT); }} > 节点修改审核 </Button> ) : ( '' )} {optRecord.paths?.includes('applyModify') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setOrderDrawerVisible(true); setOrderOptType('order-change-normal'); }} > 申请修改 </Button> ) : ( '' )} {optRecord.paths?.includes('modifiedLeaderAuditRequest') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.MODIFY_LEADER_AUDIT); }} > 领导修改审核 </Button> ) : ( '' )} {optRecord.paths?.includes('shippingWarehouseChangeRequest') ? ( <Button className="p-0" type="link" onClick={() => { setIds([optRecord.id]); createOptObject(optRecord.id, record.id); setShippingWarehouseChangeModalVisible(true); }} > 修改仓库 </Button> ) : ( '' )} {optRecord.paths?.includes('saleCancelInvoicing_old') ? ( <ButtonConfirm className="p-0" title="确认取消申请开票?" text="取消申请(旧)" onConfirm={async () => { let res = await postServiceOrderSaleCancelInvoicing({ data: { subOrderIds: [optRecord.id], }, }); if (res && res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); } }} /> ) : ( '' )} {optRecord.paths?.includes('saleCancelInvoicing') ? ( <ButtonConfirm className="p-0" title="确认取消申请开票?" text="取消申请(新)" onConfirm={async () => { let res = await postServiceInvoiceCancelApply({ data: { subOrderIds: [optRecord.id], }, }); if (res && res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); } }} /> ) : ( '' )} {optRecord.paths?.includes('noNeedInvoicingEdit') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setFinancialEditVisible(true); setIsMainOrder(false); }} > 编辑时间 </Button> ) : ( '' )} {optRecord.paths?.includes('sendProduct') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setDeliverVisible(true); setIsSendProduct(true); setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); }} > 仓库发货 </Button> ) : ( '' )} {optRecord.paths?.includes('supplierSendOrder') ? ( <Button className="p-0" type="link" onClick={() => { optRecord.mainOrderId = record.id; setSelectedRows([cloneDeep(optRecord)]); //克隆一份数据,避免后续修改污染 setDeliverVisible(true); setIsSendProduct(true); setOrderCheckType(CHECK_TYPE.SUPPLIER); }} > 供应商发货 </Button> ) : ( '' )} {optRecord.paths?.includes('procureSend') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setDeliverVisible(true); setIsSendProduct(true); setOrderCheckType(CHECK_TYPE.PROCURE); }} > {isSupplier() ? '发货' : '采购发货'} </Button> ) : ( '' )} {optRecord.paths?.includes('editProductionTime') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setProductionTimeModalVisible(true); }} > 生产时间 </Button> ) : ( '' )} {optRecord.paths?.includes('queryAnnex') && optRecord.listAnnex?.length > 0 ? ( <Button className="p-0" type="link" onClick={() => { optRecord.mainOrderId = record.id; createOptObject(optRecord.id, record.id); setAttachmentModalVisible(true); }} > 附件 </Button> ) : ( '' )} {optRecord.paths?.includes('modifySendInformation') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setDeliverVisible(true); setIsSendProduct(false); }} > 修改发货信息 </Button> ) : ( '' )} {optRecord.paths?.includes('printOrder') ? ( <Button className="p-0" type="link" onClick={async () => { createOptObject(optRecord.id, record.id); setOrderPrintVisible(true); setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); }} > 仓库打印 </Button> ) : ( '' )} {optRecord.paths?.includes('supplierPrint') ? ( <Button className="p-0" type="link" onClick={async () => { createOptObject(optRecord.id, record.id); setOrderPrintVisible(true); setOrderCheckType(CHECK_TYPE.SUPPLIER); }} > 供应商打印 </Button> ) : ( '' )} {optRecord.paths?.includes('procurePrint') ? ( <ButtonConfirm className="p-0" title="确认打印?" text="采购打印" onConfirm={async () => { let res = await postServiceOrderProcurePrint({ data: { ids: [optRecord.id], }, }); if (res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); } }} /> ) : ( // <Button // className="p-0" // type="link" // onClick={async () => { // setOrderPrintVisible(true); // setSelectedRows([optRecord]); // setOrderRow(record); // setOrderCheckType(CHECK_TYPE.PROCURE); // }} // > // 采购打印 // </Button> '' )} {optRecord.paths?.includes('editOrder') && false ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setFinancialVisible(true); setIsEdit(true); }} > 编辑 </Button> ) : ( '' )} {optRecord.paths?.includes('invoicing') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setFinancialVisible(true); setIsEdit(false); setIsMainOrder(false); }} > 开票 </Button> ) : ( '' )} {optRecord.paths?.includes('applyInvoicing') ? ( <Button className="p-0" type="link" onClick={() => { setInvoicingDrawerFormVisible(true); createOptObject(optRecord.id, record.id); setIsEdit(false); setIsMainOrder(false); }} > 申请开票(新) </Button> ) : ( '' )} {optRecord.paths?.includes('applyInvoicing_old') ? ( <Button className="p-0" type="link" onClick={() => { setApplyForInvoicingVisible(true); createOptObject(optRecord.id, record.id); setIsEdit(false); setIsMainOrder(false); }} > 申请开票(旧) </Button> ) : ( '' )} {optRecord.paths?.includes('checkOrder') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(optRecord.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); }} > 审核 </Button> ) : ( '' )} {optRecord.paths?.includes('afterSalesCheck') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.AFTER_SALES); }} > 售后审核 </Button> ) : ( '' )} {optRecord.paths?.includes('financeCheckOrder') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.FINALCIAL); }} > 财务审核 </Button> ) : ( '' )} {optRecord.paths?.includes('procureCheckOrder') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setOrderCheckType(CHECK_TYPE.PROCURE); setProcureCheckModalVisible(true); }} > 采购审核 </Button> ) : ( '' )} {optRecord.paths?.includes('procureConvertProcure') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setOrderCheckType(CHECK_TYPE.PROCURE); setProcureConvertModalVisible(true); }} > 转发 </Button> ) : ( '' )} {optRecord.paths?.includes('rePrintOrder') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setOrderPrintVisible(true); setIsRePrintOrder(true); }} > 重新打印 </Button> ) : ( '' )} {optRecord.paths?.includes('confirmReceipt') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setConfirmReceiptVisible(true); }} > 确认收货 </Button> ) : ( '' )} {optRecord.paths?.includes('applyAfterSales') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setOrderDrawerVisible(true); setOrderOptType('after_sales'); }} > 申请售后 </Button> ) : ( '' )} {optRecord.paths?.includes('procureOrder') ? ( <ButtonConfirm className="p-0" title="是否已下单?" text="下单" onConfirm={async () => { let res = await postServiceOrderProcureOrder({ data: { subIds: [optRecord.id] }, }); if (res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); return true; } }} /> ) : ( '' )} {optRecord.paths?.includes('cancelSend') ? ( <ButtonConfirm className="p-0" title="是否取消发货" text="取消发货" onConfirm={async () => { let res = await postServiceOrderCancelSend({ data: { subIds: [optRecord.id] }, }); if (res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); return true; } }} /> ) : ( '' )} {optRecord.paths?.includes('noNeedSend') ? ( <ButtonConfirm className="p-0" title="此订单是否无需发货?" text="无需发货" onConfirm={async () => { let res = await postServiceOrderNoNeedSend({ data: { ids: [optRecord.id] }, }); if (res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); return true; } }} /> ) : ( '' )} {optRecord.paths?.includes('viewImages') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setImagesViewerOptType('shippingReceipt'); setImagesViewerModalVisible(true); }} > 查看收货凭证 </Button> ) : ( '' )} {optRecord.paths?.includes('confirmDeliver') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setOrderCheckType(CHECK_TYPE.CONFIRM_DELIVER); setCheckVisible(true); }} > 确认发货 </Button> ) : ( '' )} {optRecord.paths?.includes('feedbackRegistration') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(optRecord.id, record.id); setFeedbackRegistrationModalVisible(true); }} > 回访登记 </Button> ) : ( '' )} {optRecord.paths?.includes('confirmInvoice') ? ( <ButtonConfirm className="p-0" title="已和客户确认发票??" text="确认发票" onConfirm={async () => { const data = await postServiceOrderConfirmInvoice({ data: [optRecord.id], }); if (data.result === RESPONSE_CODE.SUCCESS) { message.success(data.message); refreshTable(); } }} /> ) : ( '' )} {optRecord.paths?.includes('orderCancel') ? ( <ButtonConfirm className="p-0" title="确认作废?" text="作废" onConfirm={async () => { let body = { ids: [optRecord.id], checkIsMainOrderId: false }; const data = await postServiceOrderOrderCancel({ data: body, }); if (data.result === RESPONSE_CODE.SUCCESS) { message.success(data.message); refreshTable(); } }} /> ) : ( '' )} </Flex> </Flex> <Flex title={optRecord.notes}> <div className="max-w-[1100px] overflow-hidden whitespace-normal overflow-ellipsis hover:cursor-pointer" onClick={() => { copyToClipboard(optRecord.notes); message.info('备注复制成功:' + optRecord.notes); }} > <span className="text-[#8C8C8C]"> 备注: {optRecord.notes === null ? '暂无备注' : optRecord.notes} </span> </div> {!isSupplier() && (isSales() || isWarehousekeeper() || isAdmin()) && ( <EditTwoTone className="pl-1 pr-1 hover:curcor-pointer" onClick={() => { setNotesEditVisible(true); setSelectedRows([optRecord.id]); setNotes(optRecord.notes); setNotesType(1); }} /> )} </Flex> {(isProcure() || isWarehousekeeper() || isSales() || isAdmin()) && !isSupplier() ? ( <div className="pt-2"> <Flex title={optRecord.supplierName}> <div> <span className="text-[#8C8C8C]"> 所属采购: {optRecord.supplierName === null ? '暂无' : optRecord.supplierName} </span> </div> <Divider type="vertical" /> <div className="overflow-hidden whitespace-normal overflow-ellipsis hover:cursor-pointer"> <span className="text-[#8C8C8C]"> 采购备注: {optRecord.procureNotes === null ? '暂无备注' : optRecord.procureNotes} </span> </div> {/* 编辑备注按钮 */} {(isProcure() || isAdmin()) && ( <EditTwoTone className="pl-1 pr-1 hover:curcor-pointer" onClick={() => { setSelectedRows([optRecord.id]); setNotes(optRecord.procureNotes); setNotesEditVisible(true); setNotesType(2); }} /> )} </Flex> {(isAdmin() || isProcure()) && ( <Flex title={optRecord.supplierNotes}> <div className="max-w-[90%] whitespace-no-wrap overflow-hidden overflow-ellipsis"> <span className="text-[#8C8C8C]"> 供应商备注: {optRecord.supplierNotes === null ? '暂无备注' : optRecord.supplierNotes} </span> </div> {/* 编辑备注按钮 */} <EditTwoTone className="pl-1 hover:curcor-pointer" onClick={() => { setSelectedRows([optRecord.id]); setNotes(optRecord.supplierNotes); setNotesEditVisible(true); setNotesType(3); }} /> </Flex> )} </div> ) : ( '' )} {isAdmin() || isSales() || isFinance() ? ( <Flex title={optRecord.notes} className="pt-2"> <div className="flex items-center"> <div className="flex items-center max-w-[500px]"> <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tooltip title={optRecord.applyInvoicingNotes} placement="topLeft" > <span className="text-[#8C8C8C]"> 申请开票备注: {optRecord.applyInvoicingNotes === undefined || optRecord.applyInvoicingNotes === null ? '暂无备注' : optRecord.applyInvoicingNotes} </span> </Tooltip> </div> {getAfterAnnexList()} <Tooltip title="编辑"> <EditTwoTone className="pl-1 hover:curcor-pointer" onClick={() => { setNotesEditVisible(true); setSelectedRows([optRecord.id]); setNotes(optRecord.applyInvoicingNotes); setNotesType(4); }} /> </Tooltip> </div> <Divider type="vertical" className="mx-5" /> <div className="flex items-center max-w-[500px]"> <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tooltip title={optRecord.checkNotes} placement="topLeft"> <span className="text-[#8C8C8C] mr-3"> 财务审核备注: {optRecord.checkNotes === undefined || optRecord.checkNotes === null ? '暂无备注' : optRecord.checkNotes} </span> </Tooltip> </div> {getInvoicingCheckAnnexList()} </div> </div> </Flex> ) : ( '' )} {isAdmin() || isSales() || isFinance() ? ( <Flex title={optRecord.notes} className="pt-2"> <div className="flex items-center"> <div className="flex items-center max-w-[500px]"> <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tooltip title={optRecord.reissueNotes} placement="topLeft"> <span className="text-[#8C8C8C]"> 重新开票备注: {optRecord.reissueNotes === undefined || optRecord.reissueNotes === null ? '暂无备注' : optRecord.reissueNotes} </span> </Tooltip> </div> <Tooltip title="编辑"> <EditTwoTone className="pl-1 hover:curcor-pointer" onClick={() => { setNotesEditVisible(true); setSelectedRows([optRecord.id]); setNotes(optRecord.reissueNotes); setNotesType(5); }} /> </Tooltip> </div> <Divider type="vertical" className="mx-5" /> </div> </Flex> ) : ( '' )} {isAdmin() || isSales() ? ( <Flex title={optRecord.notes} className="pt-2"> <div className="flex items-center"> <div className="flex items-center max-w-[500px]"> <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis"> <Tooltip title={optRecord.feedbackRegistrationContent} placement="topLeft" > <span className="text-[#8C8C8C] mr-3"> 产品回访登记: {optRecord.feedbackRegistrationContent === undefined || optRecord.feedbackRegistrationContent === null ? '暂无' : optRecord.feedbackRegistrationContent} </span> </Tooltip> </div> </div> </div> </Flex> ) : ( '' )} </> ); }; const expandedRowRender = (record) => { let subOrders = record.subOrderInformationLists; return ( <ProTable id="sub-table" className="w-full " showHeader={false} columns={[ { title: 'ID', dataIndex: 'id', key: 'id', render: (text: any, optRecord: any) => { return <SubOderRander record={record} optRecord={optRecord} />; }, }, ]} rowSelection={{ onSelect: (row: any) => { let subId = row.id; let mainId = row.mainOrderId; let newSelectedSubOrderKeys = [...selectedSubOrderKeys]; let currentMainOrderSelectedSubOrderList = subOrderSelectedMap.get(mainId); if (!selectedSubOrderKeys.includes(subId)) { //选中子订单 newSelectedSubOrderKeys.push(subId); //在Map中添加对应的主订单中的子订单 if (currentMainOrderSelectedSubOrderList) { currentMainOrderSelectedSubOrderList.push(row); } else { currentMainOrderSelectedSubOrderList = [row]; } //如果该主订单的所有子订单都选中了,那么勾选上主订单 if ( currentMainOrderSelectedSubOrderList?.length === mainOrderIdSubOrderIdRelationsMap.get(mainId)?.length ) { selectedMainOrderKeys.push(mainId, record); mainOrderSelectedMap.set(mainId, record); } //如果所有主订单都勾选上了,那么勾选上总选中按钮 if ( mainOrderSelectedMap?.size === mainOrderIdSubOrderIdRelationsMap.size ) { setAllMainChecked(true); } } else { //取消选中子订单 newSelectedSubOrderKeys = newSelectedSubOrderKeys.filter( (item) => { return item !== subId; }, ); removeSelecetMainOrderKeyByMainOrderId(mainId); //某个子订单取消勾选了,对应的主订单也要取消勾选 //在Map中删除掉对应的主订单中的子订单 if (currentMainOrderSelectedSubOrderList) { currentMainOrderSelectedSubOrderList = currentMainOrderSelectedSubOrderList.filter((item) => { return item.id !== subId; }); } else { subOrderSelectedMap.set(mainId, [row]); } mainOrderSelectedMap.delete(mainId); //总选中按钮取消选中 setAllMainChecked(false); } //如果该主订单已经没有子订单选中,删除key if (currentMainOrderSelectedSubOrderList?.length === 0) { subOrderSelectedMap.delete(record.id); } else { subOrderSelectedMap.set( record.id, currentMainOrderSelectedSubOrderList, ); } setSelectedSubOrderKeys(newSelectedSubOrderKeys); setSelectedRows(currentMainOrderSelectedSubOrderList); }, selectedRowKeys: selectedSubOrderKeys, // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom // 注释该行则默认不显示下拉选项 // selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT], // defaultSelectedRowKeys: [], }} rowKey="id" headerTitle={false} search={false} options={false} dataSource={subOrders} pagination={false} tableAlertRender={false} /> ); }; // 主订单内容渲染 const MainOrderColumnRender = ({ record }: { record: OrderListItemType }) => { return ( <Flex vertical={true}> {/* 编号、时间、销售信息 */} <Flex className="px-4 py-4 bg-white rounded-t-lg" justify="space-between" > <Flex wrap="wrap" gap="middle" vertical> <Flex> <Flex> <Checkbox onChange={() => onCheckboxChange(record)} checked={selectedMainOrderKeys.includes(record.id)} > <Space split={<Divider type="vertical" />}> <div> <span className="text-[#8C8C8C]">订单号:</span> <span className="text-slate-700">{record.id}</span> {record.modified ? ( <Tooltip title="点击查看详情"> <span className="text-[#f44e4e] cursor-pointer" onClick={async () => { createOptObject(null, record.id); setModifiedDiffModalVisible(true); }} > (修改过) </span> </Tooltip> ) : ( '' )} </div> </Space> </Checkbox> <Tooltip title="点击复制订单号"> <CopyOutlined className="hover:cursor-pointer" style={{ color: '#8C8C8C' }} onClick={() => { copyToClipboard(record.id); message.info('订单号复制成功!'); }} /> </Tooltip> <Divider type="vertical" /> <span>{formatDateTime(record.createTime)}</span> <Divider type="vertical" /> <Space split={<Divider type="vertical" />}> <div className="hover:cursor-pointer" onClick={() => { copyToClipboard(record.salesCode); message.info('代表复制成功:' + record.salesCode); }} > <span className="text-[#8C8C8C]">代表:</span> <span className="text-slate-700">{record.salesCode}</span> </div> {!isSupplier() ? ( <> <div title={record.institution} className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[150px]" > <span className="text-[#8C8C8C]">单位:</span> <span className="text-slate-700"> {record.institution} </span> </div> <span> <span className="text-[#8C8C8C]">联系人:</span> <span className="text-slate-700"> {record.institutionContactName + ' '} </span> </span> </> ) : ( '' )} <div title={record.institution} className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[150px]" > <span className="hover:cursor-pointer" onClick={() => { copyToClipboard(record.customerName); message.info('收货人复制成功:' + record.customerName); }} > <span className="text-[#8C8C8C]">收货人:</span> {!isSupplier() && ( <Tooltip className="order-tooltip" title="详情"> <ContainerTwoTone className="px-1 hover:curcor-pointer" onClick={() => { createOptObject(null, record.id); setDeliverInfoDrawerVisible(true); }} /> </Tooltip> )} <span className="text-slate-700"> {record.customerName + ' '} </span> </span> </div> {isSupplier() ? ( <div title={record.customerShippingAddress} className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[400px] hover:cursor-pointer" onClick={() => { copyToClipboard(record.customerShippingAddress); message.info( '收货地址复制成功:' + record.customerShippingAddress, ); }} > <span className="text-[#8C8C8C]">收货地址:</span> <span className="text-slate-700"> {record.customerShippingAddress} </span> </div> ) : ( '' )} </Space> </Flex> </Flex> {isSupplier() ? ( <Flex className="pl-6" align="center"> <Flex className="hover:cursor-pointer" onClick={() => { copyToClipboard(record.customerContactNumber); message.info( '联系电话复制成功:' + record.customerContactNumber, ); }} > <span className="text-[#8C8C8C]">联系电话:</span> <span className="text-slate-700"> {record.customerContactNumber + ' '} </span> </Flex> </Flex> ) : ( '' )} <Flex className="pl-6" align="center"> {roleCode === 'finance' ? ( <div title={enumValueToLabel( record.receivingCompany, getReceivingCompanyOptions(PAYEE_OPTIONS), )} className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[400px]" > <span className="text-[#8C8C8C]">开票收款单位:</span> <span className="text-slate-700"> {record.receivingCompany !== null ? enumValueToLabel( record.receivingCompany, getReceivingCompanyOptions(PAYEE_OPTIONS), ) : '暂无'} </span> </div> ) : ( '' )} {roleCode === 'finance' ? <Divider type="vertical" /> : ''} <div title={record.notes}> <div className="max-w-[850px] whitespace-normal overflow-hidden overflow-ellipsis hover:cursor-pointer" onClick={() => { copyToClipboard(record.notes); message.info('备注复制成功:' + record.notes); }} > <span className="text-[#8C8C8C]">备注:</span> <span className="ml-2"> {record.notes === null ? '暂无备注' : record.notes} </span> </div> </div> {!isSupplier() ? ( <Tooltip title="编辑"> <EditTwoTone className="pl-1 hover:curcor-pointer" onClick={() => { setNotesEditVisible(true); setSelectedRows([record.id]); setNotes(record.notes); setNotesType(0); }} /> </Tooltip> ) : ( '' )} {record.goodsWeight !== null ? ( <div title={record.goodsWeight + 'kg'} className="pl-3"> <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer" onClick={() => { copyToClipboard(record.goodsWeight + 'kg'); message.info( '包裹重量复制成功:' + record.goodsWeight + 'kg', ); }} > <span className="text-[#8C8C8C]">包裹重量:</span> <span className="ml-2">{record.goodsWeight + 'kg'}</span> </div> </div> ) : ( '' )} {record.goodsVolume !== null ? ( <div title={record.goodsVolume + 'm³'} className="pl-3"> <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer" onClick={() => { copyToClipboard(record.goodsVolume + 'm³'); message.info( '包裹体积复制成功:' + record.goodsVolume + 'm³', ); }} > <span className="text-[#8C8C8C]">包裹体积:</span> <span className="ml-2">{record.goodsVolume + 'm³'}</span> </div> </div> ) : ( '' )} </Flex> </Flex> <Flex wrap="wrap" gap="middle" vertical> <Flex justify="flex-end"> <Flex wrap="wrap" gap="middle" align="center"> {!isSupplier() ? ( <div> <span className="text-[#8C8C8C]">总金额:¥</span> <span className="text-lg font-medium"> {record.totalPayment} </span> </div> ) : ( '' )} {rolePath?.includes('addOrder') ? ( <Tooltip title="复制"> <CopyTwoTone className="hover:cursor-pointer" onClick={() => { createOptObject(null, record.id); copyOrderToClipboard(record); setOrderOptType('copy'); setOrderDrawerVisible(true); }} /> </Tooltip> ) : ( <Tooltip title="复制文本"> <CopyTwoTone className="hover:cursor-pointer" onClick={() => { copyOrderToClipboard(record); }} /> </Tooltip> )} {!isSupplier() ? ( <Tooltip title="历史"> <ClockCircleTwoTone className="hover:cursor-pointer" onClick={() => { setHistoryModalVisible(true); if (subOrderSelectedMap.get(record.id)?.length) { setSelectedRows(subOrderSelectedMap.get(record.id)); } else { setSelectedRows(record.subOrderInformationLists); } }} /> </Tooltip> ) : ( '' )} </Flex> </Flex> <Flex justify="flex-end"> <Space.Compact direction="vertical" align="end"> <Space wrap> {record.paths?.includes('postAudit') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(null); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT); }} > 后置审核 </Button> ) : ( '' )} {record.paths?.includes('URGENT_INVOICE_AUDITING') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING); }} > 加急审核(新) </Button> ) : ( '' )} {record.paths?.includes('URGENT_INVOICE_AUDITING_old') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType( CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD, ); }} > 加急审核(旧) </Button> ) : ( '' )} {record.paths?.includes('salesConfirm') && ( <ButtonConfirm className="p-0" title="是否确认此商城订单信息无误?确认无误之后订单将进入审核流程。" text="订单确认" onConfirm={async () => { let subIds = subOrderSelectedMap .get(record.id) ?.map((item) => { return item.id; }); if (subIds === null || subIds === undefined) { subIds = record.subOrderInformationLists.map( (item) => { return item.id; }, ); } let res = await postServiceOrderSalesConfirm({ data: { subOrderIds: subIds, }, }); if (res && res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); } }} /> )} {record.paths?.includes('uploadPaymentReceiptBill') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setUploadPayBillModalVisible(true); }} > 回款 </Button> ) : ( '' )} {record.paths?.includes('modifiedAuditRequest') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.NODE_OPERATING_AUDIT); }} > 节点修改审核 </Button> ) : ( '' )} {record.paths?.includes('auditPaymentReceipt') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT); }} > 回款审核 </Button> ) : ( '' )} {record.paths?.includes('modifiedLeaderAuditRequest') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.MODIFY_LEADER_AUDIT); }} > 领导修改审核 </Button> ) : ( '' )} {false ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setFinancialReceiptsModalVisible(true); setIsEdit(true); }} > 收款记录 </Button> ) : ( '' )} {record.paths?.includes('reissue_old') ? ( /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'|| optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/ <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setReissueVisibleOld(true); console.log(reissueVisible); }} > 重新开票(旧) </Button> ) : ( '' )} {record.paths?.includes('confirmReissue_old') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(null); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE_OLD); }} > 重新开票审核(旧) </Button> ) : ( '' )} {record.paths?.includes('reissue') ? ( /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'|| optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/ <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setReissueVisible(true); }} > 重新开票(新) </Button> ) : ( '' )} {record.paths?.includes('confirmReissue') ? ( <Button className="p-0" type="link" onClick={() => { setCurrentMainId(record.id); setCurretnOptSubId(null); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE); }} > 重新开票审核(新) </Button> ) : ( '' )} {record.paths?.includes('procureOrder') ? ( <ButtonConfirm className="p-0" title="是否下单?" text="下单" onConfirm={async () => { let subIds = subOrderSelectedMap .get(record.id) ?.map((item) => { return item.id; }); if (subIds === null || subIds === undefined) { subIds = record.subOrderInformationLists.map( (item) => { return item.id; }, ); } let res = await postServiceOrderProcureOrder({ data: { subIds: subIds }, }); if (res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); return true; } }} /> ) : ( '' )} {record.paths?.includes('cancelSend') ? ( <ButtonConfirm className="p-0" title="是否取消发货?" text="取消发货" onConfirm={async () => { let subIds = subOrderSelectedMap .get(record.id) ?.map((item) => { return item.id; }); if (subIds === null || subIds === undefined) { subIds = record.subOrderInformationLists.map( (item) => { return item.id; }, ); } let res = await postServiceOrderCancelSend({ data: { subIds: subIds }, }); if (res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); return true; } }} /> ) : ( '' )} {record.paths?.includes('applyModify') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setOrderDrawerVisible(true); setOrderOptType('order-change-normal'); }} > 申请修改 </Button> ) : ( '' )} {record.paths?.includes('leaderAudit') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); setSelectedRows(selectedSubOrders); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'LEADER_PROCESS' ) { message.error('请选择领导待审核的子订单进行审核'); return; } } createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.LEADER_AUDIT); }} > 审核 </Button> ) : ( '' )} {record.paths?.includes('changeOrderAudit') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); setSelectedRows(selectedSubOrders); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'MODIFY_APPLY_WAIT_FOR_AUDIT' ) { message.error('请选择[修改待审核]的子订单进行审核'); return; } } createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType( CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT, ); }} > 审核 </Button> ) : ( '' )} {record.paths?.includes('creditAudit') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); setSelectedRows(selectedSubOrders); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'CREDIT_CONFIRM' ) { message.error('请选择[赊账待审核]的子订单进行审核'); return; } } createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.CREDIT_AUDIT); }} > 赊账审核 </Button> ) : ( '' )} {record.paths?.includes('editProductionTime') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setProductionTimeModalVisible(true); }} > 生产时间 </Button> ) : ( '' )} {record.paths?.includes('procureConvertProcure') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( !selectedSubOrders[i].paths.includes( 'procureConvertProcure', ) ) { message.error('请选择允许转发的子订单进行转发'); return; } } createOptObject(null, record.id); setOrderCheckType(CHECK_TYPE.PROCURE); setProcureConvertModalVisible(true); }} > 转发 </Button> ) : ( '' )} {record.paths?.includes('sendProduct') ? ( <Button className="p-0" type="link" onClick={() => { if (!subOrderSelectedMap.get(record.id)?.length) { return message.error('请选择选择子订单'); } createOptObject(null, record.id); setDeliverVisible(true); setIsSendProduct(true); setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); }} > 仓库发货 </Button> ) : ( '' )} {/* 供应商发货 */} {record.paths?.includes('supplierSendOrder') ? ( <Button className="p-0" type="link" onClick={() => { if (!subOrderSelectedMap.get(record.id)?.length) { return message.error('请选择选择子订单'); } createOptObject(null, record.id); setDeliverVisible(true); setIsSendProduct(true); setOrderCheckType(CHECK_TYPE.SUPPLIER); }} > 供应商发货 </Button> ) : ( '' )} {record.paths?.includes('procureSend') ? ( <Button className="p-0" type="link" onClick={() => { if (!subOrderSelectedMap.get(record.id)?.length) { return message.error('请选择选择子订单'); } createOptObject(null, record.id); setDeliverVisible(true); setIsSendProduct(true); setOrderCheckType(CHECK_TYPE.PROCURE); }} > {isSupplier() ? '发货' : '采购发货'} </Button> ) : ( '' )} {record.paths?.includes('printOrder') ? ( <Button className="p-0" type="link" onClick={() => { const selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (!selectedSubOrders?.length) { return message.error('请选择选择子订单'); } for (let subOrderRecord of selectedSubOrders) { let paths = subOrderRecord.paths; if (!checkePrintable(paths)) { return message.error('请选择可以打印的子订单'); } } createOptObject(null, record.id); setOrderPrintVisible(true); setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); }} > 仓库打印 </Button> ) : ( '' )} {record.paths?.includes('supplierPrint') ? ( <Button className="p-0" type="link" onClick={() => { if (!subOrderSelectedMap.get(record.id)?.length) { return message.error('请选择选择子订单'); } createOptObject(null, record.id); setOrderPrintVisible(true); setOrderCheckType(CHECK_TYPE.SUPPLIER); }} > 供应商打印 </Button> ) : ( '' )} {record.paths?.includes('rePrintOrder') ? ( <Button className="p-0" type="link" onClick={() => { if (!subOrderSelectedMap.get(record.id)?.length) { return message.error('请选择选择子订单'); } createOptObject(null, record.id); setOrderPrintVisible(true); setIsRePrintOrder(true); }} > 重新打印 </Button> ) : ( '' )} {record.paths?.includes('confirmReceipt') ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setConfirmReceiptVisible(true); }} > 确认收货 </Button> ) : ( '' )} {record.paths?.includes('modifySendInformation') ? ( <Button className="p-0" type="link" onClick={() => { if (!subOrderSelectedMap.get(record.id)?.length) { return message.error( '请选择已经发货或者已经确认收货的子订单', ); } for (let row of subOrderSelectedMap.get(record.id)) { if ( row.orderStatus !== 'CONFIRM_RECEIPT' && row.orderStatus !== 'SHIPPED' ) { return message.error( '请选择已经发货或者已经确认收货的子订单', ); } } createOptObject(null, record.id); setDeliverVisible(true); setIsSendProduct(false); }} > 修改发货信息 </Button> ) : ( '' )} {record.paths?.includes('invoicing') ? ( <Button type="link" className="p-0" onClick={() => { createOptObject(null, record.id); setFinancialVisible(true); setIsEdit(false); }} > 开票 </Button> ) : ( '' )} {record.paths?.includes('applyInvoicing_old') ? ( <Button type="link" className="p-0" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].invoicingStatus === 'UN_INVOICE' || selectedSubOrders[i].afterInvoicingStatus === 'APPLY_FOR_INVOICING' ) { message.error( '请选择需要开票且未申请开票的子订单进行申请', ); return; } } createOptObject(null, record.id); setApplyForInvoicingVisible(true); setIsEdit(false); setIsMainOrder(false); }} > 申请开票(旧) </Button> ) : ( '' )} {record.paths?.includes('applyInvoicing') ? ( <Button type="link" className="p-0" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].invoicingStatus === 'UN_INVOICE' || selectedSubOrders[i].afterInvoicingStatus === 'APPLY_FOR_INVOICING' ) { message.error( '请选择需要开票且未申请开票的子订单进行申请', ); return; } } createOptObject(null, record.id); setInvoicingDrawerFormVisible(true); setIsEdit(false); setIsMainOrder(false); }} > 申请开票(新) </Button> ) : ( '' )} {record.paths?.includes('confirmInvoice') ? ( <ButtonConfirm className="p-0" title="已和客户确认发票?" text="确认发票" onConfirm={async () => { const data = await postServiceOrderConfirmInvoice({ data: [ ...record.subOrderInformationLists.map( (subOrder) => subOrder.id, ), ], }); if (data.result === RESPONSE_CODE.SUCCESS) { message.success(data.message); refreshTable(); } }} /> ) : ( '' )} {record.paths?.includes('updateOrder') ? ( <Button className="p-0" type="link" onClick={() => { //勾选的子订单:如果有勾选,后面只校验有勾选的 let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if ( selectedSubOrders === undefined || selectedSubOrders.length === 0 ) { selectedSubOrders = record.subOrderInformationLists; } for ( let index = 0; index < selectedSubOrders.length; index++ ) { let orderStatus = selectedSubOrders[index].orderStatus; //仓库管理员在审核之后的任何时候都可以编辑 if ( roleCode !== 'warehouseKeeper' && roleCode !== 'admin' ) { //是审核通过及之后的订单 if ( orderStatus !== 'UNAUDITED' && orderStatus !== 'AUDIT_FAILED' && orderStatus !== 'LEADER_PROCESS' && orderStatus !== 'SALES_CONFIRM' && orderStatus !== 'CREDIT_CONFIRM' ) { message.error( '请选择【未审核、审核失败、销售待确认、赊账待审核】的订单进行编辑', ); return; } } else { //仓库管理员只能编辑是还未审核的订单 if ( roleCode !== 'admin' && (orderStatus === 'UNAUDITED' || orderStatus === 'AUDIT_FAILED') ) { message.error('请选择已审核的订单进行编辑'); return; } } } createOptObject(null, record.id); setOrderDrawerVisible(true); setOrderOptType('edit'); }} > 编辑 </Button> ) : ( '' )} {record?.subOrderInformationLists[0].paths?.includes( 'noNeedInvoicingEdit', ) ? ( <Button className="p-0" type="link" onClick={() => { createOptObject(null, record.id); setFinancialEditVisible(true); setIsMainOrder(true); }} > 财务编辑 </Button> ) : ( '' )} {record.paths?.includes('checkOrder') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); setSelectedRows(selectedSubOrders); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { let orderStatus = selectedSubOrders[i].orderStatus; if ( orderStatus !== 'UNAUDITED' && orderStatus !== 'FINANCE_PROCESS' && orderStatus !== 'LEADER_AUDITED' ) { message.error( '请选择未审核或者领导已审核的子订单进行审核', ); return; } } createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); }} > 审核 </Button> ) : ( '' )} {record.paths?.includes('afterSalesCheck') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); setSelectedRows(selectedSubOrders); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'IN_AFTER_SALES' ) { message.error('请选择售后中的子订单进行审核'); return; } } createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.AFTER_SALES); }} > 售后审核 </Button> ) : ( '' )} {record.paths?.includes('noNeedSend') ? ( <ButtonConfirm className="p-0" title="此订单是否无需发货?" text="无需发货" onConfirm={async () => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } setSelectedRows(selectedSubOrders); for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'AUDITED' && selectedSubOrders[i].orderStatus !== 'PROCURE_PROCESS' && selectedSubOrders[i].orderStatus !== 'PROCURE_PROCESS_FOR_MINE' && selectedSubOrders[i].orderStatus !== 'PROCURE_WAIT_SHIP' && selectedSubOrders[i].orderStatus !== 'SUPPLIER_WAIT_SHIP' && selectedSubOrders[i].orderStatus !== 'WAIT_SHIP' ) { message.error( '请选择未发货的子订单进行无需发货操作', ); return; } } const data = await postServiceOrderNoNeedSend({ data: { ids: selectedSubOrders.map((item) => { return item.id; }), }, }); if (data.result === RESPONSE_CODE.SUCCESS) { message.success(data.message); refreshTable(); } }} /> ) : ( '' )} {record.paths?.includes('saleCancelInvoicing_old') ? ( <ButtonConfirm className="p-0" title="确认取消申请开票?" text="取消申请(旧)" onConfirm={async () => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } console.log(selectedSubOrders); for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].afterInvoicingStatus !== 'APPLY_FOR_INVOICING' ) { message.error( '请选择已[申请开票]的子订单进行取消申请', ); return; } } let res = await postServiceOrderSaleCancelInvoicing({ data: { subOrderIds: selectedSubOrders.map((item) => { return item.id; }), }, }); if (res && res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); } }} /> ) : ( '' )} {/* 财务审核:主订单暂无 */} {record.paths?.includes('financeCheckOrder') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); setSelectedRows(selectedSubOrders); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'UNAUDITED' && selectedSubOrders[i].orderStatus !== 'FINANCE_PROCESS' && selectedSubOrders[i].orderStatus !== 'LEADER_AUDITED' ) { message.error( '请选择[未审核]、[财务待审核]、[领导已审核]的子订单进行审核', ); return; } } createOptObject(null, record.id); setCheckVisible(true); setOrderCheckType(CHECK_TYPE.FINALCIAL); }} > 财务审核 </Button> ) : ( '' )} {/* 采购审核 */} {record.paths?.includes('procureCheckOrder') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); setSelectedRows(selectedSubOrders); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'PROCURE_UN_PROCESS' ) { message.error('请选择未审核的子订单进行审核'); return; } } createOptObject(null, record.id); setProcureCheckModalVisible(true); setOrderCheckType(CHECK_TYPE.PROCURE); }} > 采购审核 </Button> ) : ( '' )} {record.paths?.includes('applyAfterSales') ? ( <Button className="p-0" type="link" onClick={() => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } setSelectedRows(selectedSubOrders); for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'CONFIRM_RECEIPT' && selectedSubOrders[i].orderStatus !== 'AFTER_SALES_FAILURE' ) { message.error('请选择确认收货状态的子订单进行售后'); return; } } createOptObject(null, record.id); setOrderDrawerVisible(true); setOrderOptType('after-sales'); }} > 申请售后 </Button> ) : ( '' )} {/* {record.paths?.includes('afterSalesCompletion') ? ( <ButtonConfirm className="p-0" title="售后是否已完成?" text="完成售后" onConfirm={async () => { let selectedSubOrders = subOrderSelectedMap.get(record.id); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'IN_AFTER_SALES' ) { message.error( '请选择售后中状态的子订单进行完成售后', ); return false; } } const ids = selectedSubOrders?.map((item) => { return item.id; }); let body = { ids: ids, }; const data = await postServiceOrderAfterSalesCompletion( { data: body, }, ); if (data.result === RESPONSE_CODE.SUCCESS) { message.success(data.message); refreshTable(); } }} /> ) : ( '' )} */} {record.paths?.includes('salOrderSave') ? ( <ButtonConfirm className="p-0" title="是否推送至金蝶ERP?" text="推送ERP" onConfirm={async () => { let res = await postKingdeeRepSalOrderSave({ data: { id: record.id, }, }); if (res && res.result === RESPONSE_CODE.SUCCESS) { message.success('推送成功'); mainTableRef.current.reload(); } }} /> ) : ( '' )} {record.paths?.includes('salBillOutbound') ? ( <ButtonConfirm className="p-0" title="是否下推金蝶ERP出库单?" text="下推出库" onConfirm={async () => { let res = await postKingdeeRepSalBillOutbound({ data: { id: record.id, }, }); if (res && res.result === RESPONSE_CODE.SUCCESS) { message.success('下推成功'); mainTableRef.current.reload(); } }} /> ) : ( '' )} {record.paths?.includes('orderCancel') ? ( <ButtonConfirm className="p-0" title="确认作废?" text="作废" onConfirm={async () => { let body = { ids: [record.id], checkIsMainOrderId: true, }; const data = await postServiceOrderOrderCancel({ data: body, }); if (data.result === RESPONSE_CODE.SUCCESS) { message.success(data.message); refreshTable(); } }} /> ) : ( '' )} {record.paths?.includes('procurePrint') ? ( <ButtonConfirm className="p-0" title="确认打印?" text="采购打印" onConfirm={async () => { let selectedSubOrders = subOrderSelectedMap.get( record.id, ); if (selectedSubOrders === undefined) { selectedSubOrders = record.subOrderInformationLists; } for (let i = 0; i < selectedSubOrders.length; i++) { if ( selectedSubOrders[i].orderStatus !== 'PROCURE_PROCESS_FOR_MINE' ) { message.error( '请选择采购待打印状态的子订单进行打印', ); return false; } } const ids = selectedSubOrders?.map((item) => { return item.id; }); let res = await postServiceOrderProcurePrint({ data: { ids: ids, }, }); if (res.result === RESPONSE_CODE.SUCCESS) { message.success(res.message); refreshTable(); } }} /> ) : ( // <Button // className="p-0" // type="link" // onClick={() => { // if (!subOrderSelectedMap.get(record.id)?.length) { // return message.error('请选择选择子订单'); // } // setSelectedRows(subOrderSelectedMap.get(record.id)); // setOrderRow(record); // setOrderPrintVisible(true); // setOrderCheckType(CHECK_TYPE.PROCURE); // }} // > // 采购打印 // </Button> '' )} </Space> </Space.Compact> </Flex> </Flex> </Flex> <Flex className="p-0 pb-[24px] pt-[4px] pl-[23px] pr-[5px] bg-white rounded-b-lg"> {expandedRowRender(record)} </Flex> </Flex> ); }; // 主订单列表 const mainOrdersColumns: ProColumns<OrderType>[] = MAIN_ORDER_COLUMNS.map( (item) => { //首能账号只能搜索订单编号 let canSearchIndex = [ 'id', 'salesCode', 'subNotes', 'orderStatus', 'createTime', 'modifiedAuditStatus', ]; if (isSupplier() && !canSearchIndex.includes(item.dataIndex)) { item.search = false; } canSearchIndex = [ 'id', 'salesCode', 'customerName', 'institution', 'productName', 'orderStatus', 'createTime', ]; if (isExaminer() && !canSearchIndex.includes(item.dataIndex)) { item.search = false; } if (item.dataIndex === 'name') { return { ...item, title: <OrderTableHeader />, render: (text, record) => { return <MainOrderColumnRender record={record} />; }, }; } /** * 采购的订单状态筛选内容 */ if (roleCode === 'procure' && item.dataIndex === 'orderStatus') { item.valueEnum = enumToProTableEnumValue( PROCURE_PRIMARY_ORDER_STATUS_OPTIONS, ); } return item; }, ); /** * 采购可以筛选供应商备注 */ if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) { mainOrdersColumns.push({ title: '供应商备注', width: 120, dataIndex: 'supplierNotes', valueType: 'text', hideInTable: true, }); } /** * 采购可以筛选其他采购 */ if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) { mainOrdersColumns.push({ title: '采购名称', width: 120, dataIndex: 'supplierName', valueType: 'select', request: async () => { const res = await postServiceOrderProvideProcurementRoles(); let options = res.data?.map((item) => { return { label: item, value: item }; }); return options; }, hideInTable: true, }); } /** * 排除采购 */ if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) { mainOrdersColumns.push({ title: '采购排除', width: 120, dataIndex: 'excludeProcureNames', fieldProps: { mode: 'multiple', }, valueType: 'select', request: async () => { const res = await postServiceOrderProvideProcurementRoles(); let options = res.data?.map((item) => { return { label: item, value: item }; }); return options; }, hideInTable: true, }); } /** * 仓库可以筛选发货仓库 */ if (roleCode === 'warehouseKeeper' || roleCode === 'admin') { mainOrdersColumns.push({ title: '发货仓库', width: 120, dataIndex: 'shippingWarehouse', valueType: 'select', valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS), hideInTable: true, }); } //判断是否是采购,是的话新增一个筛选条件 if (roleCode === 'procure' || roleCode === 'admin') { mainOrdersColumns.push({ title: isSupplier() ? '下单状态' : '采购下单状态', dataIndex: 'procureOrderStatus', valueType: 'select', hideInTable: true, valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS), }); } //选择天数1 const options1 = [ { label: '超过15天', value: 15, }, { label: '超过30天', value: 30, }, ]; const options2 = [ { label: '超过15天', value: 15, }, { label: '超过30天', value: 30, }, ]; const options3 = [ { label: '超过5天', value: 5, }, { label: '超过10天', value: 10, }, ]; const options4 = [ { label: '超过30天', value: 30, }, { label: '超过75天', value: 75, }, { label: '超过90天', value: 90, }, { label: '超过120天', value: 120, }, ]; //选择天数 const [calDate, setCalDate] = useState<string | null>(null); const [value1, setValue1] = useState(0); const radioOnChange1 = ({ target: { value } }) => { const currentDate = new Date(); // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 const newDate = new Date(currentDate); newDate.setDate(currentDate.getDate() - value); const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss'); setCalDate(formattedDate); setValue1(value); }; const [invoiceWarningNum, setInvoiceWarningNum] = useState(0); const [invoiceRefundWarningNum, setInvoiceRefundWarningNum] = useState(0); const [waitConfirmPayment, setWaitConfirmPayment] = useState(0); const [waitFeedback, setWaitFeedback] = useState(0); const [staticSalesCode, setStaticSalesCode] = useState(userInfo.username); const [salesCodePermission, setSalesCodePermission] = useState(false); //修改预警数请求salesCode const changeSalesCode = () => { if (salesCodeSelect === undefined) { setStaticSalesCode(userInfo.username); } else { setStaticSalesCode(salesCodeSelect); } }; //选择栏权限 const permission = () => { const { roles } = userInfo; const boolean = roles?.includes('SALES_MANAGER') || roles?.includes('ADMIN'); if (boolean) { setSalesCodePermission(true); } }; async function getInvoiceWarningNum() { changeSalesCode(); const res = await postServiceOrderWarningOrderStatistics({ data: { salesCode: staticSalesCode, }, }); setInvoiceWarningNum(res.data.waitConfirmInvoice); setInvoiceRefundWarningNum(res.data.waitConfirmReceipt); setWaitConfirmPayment(res.data.waitConfirmPayment); setWaitFeedback(res.data.waitFeedback); } useEffect(() => { //预警订单数 getInvoiceWarningNum(); permission(); }, [salesCodeSelect]); //biaojiup // 监听 calDate 变化,触发请求 useEffect(() => { mainTableRef.current?.reload(); }, [calDate]); useEffect(() => { if ( activeTabKey === 1 || activeTabKey === 2 || activeTabKey === 3 || activeTabKey === 4 ) { setValue1(0); // 清空 value1 } mainTableRef.current?.reload(); // **修改位置:在选择第二个标签时请求request2** }, [activeTabKey]); // 修改位置:监听 value1 的变化 useEffect(() => { if (value1 === 0) { // 这里执行你希望在 value1 为 0 时的逻辑 mainTableRef.current?.reload(); // 重新请求数据 } }, [value1]); // 添加了 value1 作为依赖 //biaojidown2 //取消单选,将时间设为null const handleSetNull = () => { setCalDate(null); // 这应该会触发 useEffect }; const selectSalesCode = (value) => { setSalesCodeSelect(value); // 这应该会触发 useEffect }; const warningOptions = [ { value: 1, label: ( <span> 确认收货预警 <Badge count={invoiceRefundWarningNum} style={{ marginLeft: 8 }} /> </span> ), }, { value: 2, label: ( <span> 回访登记预警 <Badge count={waitFeedback} style={{ marginLeft: 8 }} /> </span> ), }, { value: 3, label: ( <span> 确认发票预警 <Badge count={invoiceWarningNum} style={{ marginLeft: 8 }} /> </span> ), }, { value: 4, label: ( <span> 订单回款预警 <Badge count={waitConfirmPayment} style={{ marginLeft: 8 }} /> </span> ), }, ]; return ( <div className="order-page-container"> <div id="resizeDiv"></div> <div key={'activeTabKey'}> <Radio.Group options={warningOptions} onChange={(e) => { setActiveTabKey(e.target.value); mainTableRef.current?.reload(); // 重新请求数据 }} value={activeTabKey} optionType="button" /> </div> <div style={{ height: '25px' }}></div> <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', width: '100%', }} > {/* 左边的 Radio.Group */} <span style={{ flex: '1' }}> {' '} {/* 修改:设置 flex 属性 */} <Radio.Group value={value1} onChange={radioOnChange1}> {(activeTabKey === 1 ? options1 : activeTabKey === 2 ? options2 : activeTabKey === 3 ? options3 : options4 ).map((option) => ( <Radio key={option.value} value={option.value} onClick={(e) => { radioOnChange1( e as unknown as React.ChangeEvent<HTMLInputElement>, ); handleSetNull(); }} > {option.label} </Radio> ))} </Radio.Group> </span> {/* 右边的 ProFormSelect */} <span style={{ width: '300px', marginLeft: 'auto', marginTop: '30px' }}> {' '} {/* 修改:设置 width 和 marginLeft */} {salesCodePermission && ( <ProFormSelect name="salesCode" key="salesCode" width="200px" actionRef={mainTableRef} formRef={mainTableFormRef} initialValue={userInfo.username} showSearch label="销售代表" placeholder="请输入销售代表" options={salesCodeOptions} onChange={(_, option) => { if (option === undefined) { selectSalesCode(userInfo.username); } // if (option.value !== undefined) { // selectSalesCode(option.value); // } if (option && option.value !== undefined) { selectSalesCode(option.value); } mainTableRef.current?.reload(); }} request={async () => { let options = await getSalesCodeOptions(); setSalesCodeOptions(options); return options; }} /> )} </span> </div> <div style={{ height: '15px' }}></div> <ProTable id="main-table" // tableStyle={{backgroundColor:'red'}} actionRef={mainTableRef} formRef={mainTableFormRef} expandIconColumnIndex={-1} columns={mainOrdersColumns} rowKey="id" pagination={{ showQuickJumper: true, pageSize: pageSize, current: currentPage, showSizeChanger: true, onChange: (page, size) => { setPageSize(size); setCurrentPage(page); }, showTotal: (total, range) => { return ( <> <span> {'第 ' + range[0] + '-' + range[1] + ' 条/总共 ' + total + ' 条主订单 '} </span> <span className="text-[#8C8C8C]"> {' (' + subOrderCount + ' 条子订单)'} </span> </> ); }, }} // showHeader={false} expandedRowKeys={expandedRowKeys} // expandable={{ expandedRowRender }} dateFormatter="string" options={false} headerTitle="" search={false} request={async ( // 第一个参数 params 查询表单和 params 参数的结合 // 第一个参数中一定会有 pageSize 和 current ,这两个参数是 antd 的规范 params, sorter, filter, ) => { //订单id处理 /** * 以params中的id为主,如果params没id,则取url中的id * 第一次进来这个页面,url带有id的话,会自动填充到查询表单中,但是第一次查询params不会带这个id进来 */ let orderIds = mainTableFormRef.current?.getFieldValue('id'); let subOrderId = mainTableFormRef.current?.getFieldValue('subOrderId'); params.id = params.id || orderIds; params.subOrderId = params.subOrderId || subOrderId; if (params.id !== '') { params.id = params.id?.replace(/ /g, ''); if (params.id?.indexOf(',')) { params.id = params.id.split(','); params.id = params.id.filter((id) => { return id !== ''; }); } } params.salesCode = userInfo.username; params.condition = filterCondifion; //排序 params.sorted = sorted; //是否只查看已作废 params.isDeleteQueryOrder = filterCondifion === 70; let finalParams = { ...params, }; if (value1 === 0) { // const currentDate = new Date(); // const newDate = new Date(currentDate); // newDate.setDate(currentDate.getDate() - 0); handleSetNull(); } if (activeTabKey === 1) { // // 第一段代码 // if (calDate === 'null') { // params.applyTimeLe = null; // } else { // params.applyTimeLe = calDate; // } // params.applyTimeIsNotNull = true; // 要求申请时间非空 params.orderStatus = 'SHIPPED'; // 发票确认预警 params.isDeleteQueryOrder = false; // 强制查询非作废订单 console.log(userInfo, '5656userInfo'); params.salesCode = userInfo.username; if (salesCodeSelect !== undefined && salesCodeSelect !== null) { params.salesCode = salesCodeSelect; } // params.paymentMethod = 'UNPAID'; finalParams = { ...params, statusDatetimeLe: calDate, }; } else if (activeTabKey === 2) { // // 第一段代码 // if (calDate === 'null') { // params.applyTimeLe = null; // } else { // params.applyTimeLe = calDate; // } // params.applyTimeIsNotNull = true; // 要求申请时间非空 params.salesCode = userInfo.username; if (salesCodeSelect !== undefined && salesCodeSelect !== null) { params.salesCode = salesCodeSelect; } params.warningStatus = 'waitFeedbackWarning'; // 发票确认预警 params.isDeleteQueryOrder = false; // 强制查询非作废订单 // params.paymentMethod = 'UNPAID'; finalParams = { ...params, confirmReceiptDatetimeLe: calDate, }; } else if (activeTabKey === 3) { // 第一段代码 // if (calDate === 'null') { // params.applyTimeLe = null; // } else { // params.applyTimeLe = calDate; // } // params.applyTimeIsNotNull = true; // 要求申请时间非空 params.salesCode = userInfo.username; if (salesCodeSelect !== undefined && salesCodeSelect !== null) { params.salesCode = salesCodeSelect; } params.warningStatus = 'invoiceConfirmWarning'; // 发票确认预警 params.isDeleteQueryOrder = false; // 强制查询非作废订单 // params.paymentMethod = 'UNPAID'; finalParams = { ...params, invoicingEndTime: calDate, }; } else if (activeTabKey === 4) { params.warningStatus = 'paymentReceiptStatusWarning'; // 用于回款预警 if (calDate === 'null') { params.applyTimeLe = null; } else { params.applyTimeLe = calDate; } params.salesCode = userInfo.username; if (salesCodeSelect !== undefined && salesCodeSelect !== null) { params.salesCode = salesCodeSelect; } params.isDeleteQueryOrder = false; // 强制查询非作废订单 params.paymentNotReceipt = true; // 在回款预警中标记未支付订单 finalParams = { ...params, }; } //保存这个搜索条件 setSearchParam(params); const { data } = await postServiceOrderQueryServiceOrder({ // ...params, // FIXME: remove @ts-ignore // @ts-ignore sorter, filter, data: finalParams, }); setRolePath(data.specialPath); setSubOrderCount(data.count); setAllMainChecked(false); setSelectedMainOrderKeys([]); subOrderSelectedMap.clear(); mainOrderSelectedMap.clear(); setData(data?.data); //主订单id与子订单id的对照关系保存 mainOrderIdSubOrderIdRelationsMap.clear(); for (let row of data?.data) { let mianOrderId = row.id; let subOrderIds = row.subOrderInformationLists?.map((item) => { //目前子订单存储的totalPayment不准确,这里重新处理取主订单的totalPayment //totalPayment在财务开票计算金额时使用到 item.totalPayment = row.totalPayment; return item.id; }); mainOrderIdSubOrderIdRelationsMap.set(mianOrderId, subOrderIds); } // 请求完成后触发 getInvoiceWarningNum getInvoiceWarningNum(); return { data: data?.data || [], total: data?.total || 0, }; }} toolbar={{ multipleLine: true, }} // toolBarRender={() => { // return toolBarRender(); // }} /> {orderDrawerVisible && ( <OrderDrawer data={orderOptType === 'add' ? {} : buildMainOrder()} subOrders={orderOptType === 'add' ? [] : buildSubOrders()} onClose={(isSuccess: boolean) => { setOrderDrawerVisible(false); clearOptObject(); if (isSuccess) { refreshTable(); } }} orderOptType={orderOptType} /> )} {checkVisible && ( <CheckModal setCheckVisible={(val: boolean) => { setCheckVisible(val); if (!val) { clearOptObject(); } }} data={isMainOrder ? getFirstMainOrder() : buildMainOrder()} subOrders={ isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders() } orderCheckType={orderCheckType} openOrderDrawer={(type: any, id: any) => { setCurrentMainId(id); setOrderOptType(type); setOrderDrawerVisible(true); }} onClose={() => { clearOptObject(); setCheckVisible(false); refreshTable(); }} /> )} {applyForInvoicingVisible && ( <ApplyForInvoicingModal setCheckVisible={(val: boolean) => { setApplyForInvoicingVisible(val); if (!val) { clearOptObject(); } }} subOrders={ isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders() } totalPayment={getApplyInvoicingTotalPayment()} isMainOrder={isMainOrder} isEdit={isEdit} onClose={() => { setApplyForInvoicingVisible(false); setIsMainOrder(false); clearOptObject(); refreshTable(); }} /> )} {notesEditVisible && ( <OrderNotesEditModal setNotesEditVisible={(val: boolean) => { setNotesEditVisible(val); if (!val) { clearOptObject(); } }} ids={selectedRows} notesType={notesType} notes={notes} onClose={() => { setNotesEditVisible(false); setSelectedRows([]); setNotes(notes); setNotesType(1); refreshTable(); }} /> )} {deliverVisible && ( <DeliverModal data={buildSubOrders()} isSendProduct={isSendProduct} setVisible={(val: boolean) => { setDeliverVisible(val); if (!val) { clearOptObject(); } }} sendType={orderCheckType} onClose={() => { clearOptObject(); setDeliverVisible(false); setIsSendProduct(false); refreshTable(); }} /> )} {financialVisible && ( <FinancialDrawer isEdit={isEdit} mainOrder={isMainOrder ? getFirstMainOrder() : buildMainOrder()} subOrders={ isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders() } isMainOrder={isMainOrder} cancel={() => { setFinancialVisible(false); clearOptObject(); setIsMainOrder(false); setIsEdit(false); }} onClose={() => { setFinancialVisible(false); clearOptObject(); refreshTable(); setIsMainOrder(false); setIsEdit(false); }} /> )} {financialEditVisible && ( <FinancialEditDrawer mainOrder={buildMainOrder()} subOrders={buildSubOrders()} isMainOrder={isMainOrder} setVisible={() => { setFinancialEditVisible(false); clearOptObject(); }} onClose={() => { setFinancialEditVisible(false); refreshTable(); setIsMainOrder(false); clearOptObject(); }} /> )} {orderPrintVisible && ( <OrderPrintModal mainOrder={buildMainOrder()} subOrders={buildSubOrders()} isRePrint={isRePrintOrder} setVisible={(val: boolean) => { setOrderPrintVisible(val); if (!val) { clearOptObject(); } }} printOptType={orderCheckType} onClose={() => { setOrderPrintVisible(false); clearOptObject(); setIsRePrintOrder(false); refreshTable(); }} /> )} {confirmReceiptVisible && ( <ConfirmReceiptModal data={buildSubOrders()} onClose={() => { setConfirmReceiptVisible(false); clearOptObject(); refreshTable(); }} /> )} {imagesViewerModalVisible && ( <ImagesViewerModal optType={imagesViewerOptType} setVisible={(val: boolean) => { setImagesViewerModalVisible(val); if (!val) { clearOptObject(); } }} onClose={() => { setImagesViewerModalVisible(false); }} orderRow={buildSubOrders()[0]} /> )} {importModalVisible && ( <ImportModal onClose={() => { setImportModalVisible(false); refreshTable(); }} /> )} {attachmentModalVisible && ( <AttachmentModal data={buildSubOrders()[0]} onClose={() => { setAttachmentModalVisible(false); clearOptObject(); }} /> )} {historyModalVisible && ( <HistoryModal subOrders={selectedRows} isCancelledOrder={filterCondifion === 70} onClose={() => { setHistoryModalVisible(false); setSelectedRows({}); clearOptObject(); }} /> )} {deliverInfoDrawerVisible && ( <DeliverInfoDrawer data={buildMainOrder()} onClose={() => { setDeliverInfoDrawerVisible(false); clearOptObject(); }} /> )} {deliverInfoDrawerVisible && ( <DeliverInfoDrawer data={buildMainOrder()} onClose={() => { setDeliverInfoDrawerVisible(false); clearOptObject(); }} /> )} {procureCheckModalVisible && ( <ProcureCheckModal setCheckVisible={(val: boolean) => { setProcureCheckModalVisible(val); if (!val) { clearOptObject(); } }} isMainOrder={isMainOrder} orders={ isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders() } onClose={() => { setProcureCheckModalVisible(false); clearOptObject(); setIsMainOrder(false); refreshTable(); }} /> )} {afterSalesDrawerVisible && ( <AfterSalesDrawer setVisible={(val: boolean) => { setAfterSalesDrawerVisible(val); if (!val) { clearOptObject(); } }} mainOrder={buildMainOrder()} subOrders={buildSubOrders()} onClose={() => { setAfterSalesDrawerVisible(false); clearOptObject(); refreshTable(); }} /> )} {procureConvertModalVisible && ( <ProcureConvertModal setVisible={(val: boolean) => { setProcureConvertModalVisible(val); if (!val) { clearOptObject(); } }} subOrders={buildSubOrders()} onClose={() => { setProcureConvertModalVisible(false); clearOptObject(); refreshTable(); }} /> )} {financialMergeDrawerVisible && ( <FinancialMergeDrawer setVisible={(val: boolean) => { setFinancialMergeDrawerVisible(val); if (!val) { clearOptObject(); } }} dataList={ isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders() } onClose={() => { setFinancialMergeDrawerVisible(false); setIsMainOrder(false); clearOptObject(); refreshTable(); }} /> )} {financialReceiptsModalVisible && ( <FinancialReceiptsModal setVisible={(val: boolean) => { setFinancialReceiptsModalVisible(val); if (!val) { clearOptObject(); } }} datas={selectedRows} onClose={() => { setFinancialReceiptsModalVisible(false); setSelectedRows({}); refreshTable(); }} /> )} {shippingWarehouseChangeModalVisible && ( <ShippingWarehouseChangeModal setVisible={(val: boolean) => { setShippingWarehouseChangeModalVisible(val); if (!val) { clearOptObject(); } }} subOrderIds={ids} originShippingWarehouse={buildSubOrders()[0].shippingWarehouse} onClose={() => { setShippingWarehouseChangeModalVisible(false); clearOptObject(); setIds([]); refreshTable(); }} /> )} {reissueVisible && ( <ReissueModal setVisible={(val: boolean) => { setReissueVisible(val); if (!val) { clearOptObject(); } }} subOrders={ isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders() } onClose={() => { setReissueVisible(false); clearOptObject(); refreshTable(); }} /> )} {reissueVisibleOld && ( <ReissueModal_old setVisible={(val: boolean) => { setReissueVisibleOld(val); console.log(reissueVisible); if (!val) { clearOptObject(); } }} mainOrder={buildMainOrder()} subOrders={buildSubOrders()} onClose={() => { setReissueVisibleOld(false); clearOptObject(); refreshTable(); }} /> )} {productionTimeModalVisible && ( <ProductionTimeModal setVisible={(val: boolean) => { setProductionTimeModalVisible(val); if (!val) { clearOptObject(); } }} subOrders={buildSubOrders()} onClose={() => { setProductionTimeModalVisible(false); clearOptObject(); refreshTable(); }} /> )} {modifiedDiffModalVisible && ( <ModifiedDiffModal setVisible={(val: boolean) => { setModifiedDiffModalVisible(val); if (!val) { clearOptObject(); } }} subOrders={buildSubOrders()} mainOrder={buildMainOrder()} onClose={() => { setModifiedDiffModalVisible(false); clearOptObject(); }} /> )} {uploadPayBillModalVisible && ( <UploadPayBillModal setVisible={(val: boolean) => { setUploadPayBillModalVisible(val); if (!val) { clearOptObject(); } }} subOrders={buildSubOrders()} mainOrder={buildMainOrder()} onClose={() => { setUploadPayBillModalVisible(false); clearOptObject(); refreshTable(); }} /> )} {feedbackRegistrationModalVisible && ( <FeedbackRegistrationModal setVisible={(val: boolean) => { setFeedbackRegistrationModalVisible(val); if (!val) { clearOptObject(); } }} subOrders={buildSubOrders()} mainOrder={buildMainOrder()} onClose={() => { setFeedbackRegistrationModalVisible(false); clearOptObject(); refreshTable(); }} /> )} {invoicingDrawerFormVisible && ( <InvoicingDrawerForm dataList={ isMainOrder ? [...subOrderSelectedMap.values()].flat() : buildSubOrders() } setVisible={(val: boolean) => { setInvoicingDrawerFormVisible(val); if (!val) { clearOptObject(); } }} mainOrder={isMainOrder ? getFirstMainOrder() : buildMainOrder()} onClose={() => { setInvoicingDrawerFormVisible(false); setIsMainOrder(true); clearOptObject(); refreshTable(); }} /> )} {contextHolder} <FloatButton.BackTop visibilityHeight={0} /> </div> ); }; export default OrderPage;