diff --git a/src/pages/Client/Client/Components/CommunicationHistoryModal.tsx b/src/pages/Client/Client/Components/CommunicationHistoryModal.tsx index bd8c161..3b26af8 100644 --- a/src/pages/Client/Client/Components/CommunicationHistoryModal.tsx +++ b/src/pages/Client/Client/Components/CommunicationHistoryModal.tsx @@ -15,6 +15,7 @@ import { } from '@ant-design/pro-components'; import { Descriptions, Popconfirm, message } from 'antd'; import { useEffect, useRef, useState } from 'react'; +import '../index.less'; import ClientModal from './ClientModal'; import InformationHistoryModal from './InformationHistoryModal'; export default ({ record }) => { @@ -258,6 +259,7 @@ export default ({ record }) => { ]; return ( <ModalForm + className="client-index" title="客户详情" trigger={<a type="primary">查看</a>} modalProps={{ @@ -267,9 +269,10 @@ export default ({ record }) => { return true; }} > - <Descriptions items={items} column={2} /> + <Descriptions className="client-index" items={items} column={2} /> <ClientModal key={'add'} + className="client-index" data={recordSave} reloadTable={() => { actionRef.current?.reload(); @@ -278,6 +281,7 @@ export default ({ record }) => { /> <EditableProTable rowKey="tid" + className="client-index" formRef={ref} actionRef={actionRef} recordCreatorProps={false} diff --git a/src/pages/Client/Client/Components/InformationHistoryModal.tsx b/src/pages/Client/Client/Components/InformationHistoryModal.tsx index 002d940..125889b 100644 --- a/src/pages/Client/Client/Components/InformationHistoryModal.tsx +++ b/src/pages/Client/Client/Components/InformationHistoryModal.tsx @@ -8,6 +8,7 @@ import { import { ModalForm } from '@ant-design/pro-components'; import { Button, Descriptions, Space } from 'antd'; import { useEffect, useRef, useState } from 'react'; +import '../index.less'; export default ({ data, reloadTable }) => { // const [isModalVisible, setIsModalVisible] = useState(false); // 控制 ClientModal 的显示 @@ -153,6 +154,7 @@ export default ({ data, reloadTable }) => { return ( <Space> <ModalForm + className="client-index" title="跟进记录" trigger={<Button type="link">查看</Button>} submitter={{ @@ -171,6 +173,7 @@ export default ({ data, reloadTable }) => { ...defaultDoms, <> <ClientInformationModal + className="client-index" key={'modify'} data={data} // 将表单数据传递给 ClientModal reloadTable={() => { diff --git a/src/pages/Client/Client/index.css b/src/pages/Client/Client/index.css new file mode 100644 index 0000000..6770180 --- /dev/null +++ b/src/pages/Client/Client/index.css @@ -0,0 +1,15 @@ +.client-index td { + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', + 'WenQuanYi Micro Hei', sans-serif; + font-size: 13px; + word-wrap: break-word; + + /* 优先使用 */ + word-break: break-word; + + /* 强制断行,适用于长单词 */ + white-space: normal; + + /* 允许内容换行 */ +} diff --git a/src/pages/Client/Client/index.less b/src/pages/Client/Client/index.less new file mode 100644 index 0000000..06a9a6a --- /dev/null +++ b/src/pages/Client/Client/index.less @@ -0,0 +1,9 @@ +.client-index td { + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', + 'WenQuanYi Micro Hei', sans-serif; + font-size: 13px; + word-wrap: break-word; /* 优先使用 */ + word-break: break-word; /* 强制断行,适用于长单词 */ + white-space: normal; /* 允许内容换行 */ +} diff --git a/src/pages/Client/Client/index.tsx b/src/pages/Client/Client/index.tsx index b26d68f..555092e 100644 --- a/src/pages/Client/Client/index.tsx +++ b/src/pages/Client/Client/index.tsx @@ -17,7 +17,7 @@ import type { ActionType } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components'; import { Badge, Button, Radio, Space, message } from 'antd'; import { useEffect, useRef, useState } from 'react'; - +import './index.less'; const columns = [ { dataIndex: 'index', @@ -415,7 +415,7 @@ export default () => { actionRef.current?.reload(); }, [groupFilter]); return ( - <> + <div className="client-index"> <Space direction="vertical" size="middle" style={{ display: 'flex' }}> <div key={'groupFilter'}> <Radio.Group @@ -527,6 +527,6 @@ export default () => { /> </Space> {contextHolder} - </> + </div> ); }; diff --git a/src/pages/Client/FollowRecord/Components/CommunicationHistoryModal.tsx b/src/pages/Client/FollowRecord/Components/CommunicationHistoryModal.tsx index 761d2ec..5beff1c 100644 --- a/src/pages/Client/FollowRecord/Components/CommunicationHistoryModal.tsx +++ b/src/pages/Client/FollowRecord/Components/CommunicationHistoryModal.tsx @@ -6,6 +6,7 @@ import { import { ModalForm } from '@ant-design/pro-components'; import { Button, Descriptions, Space } from 'antd'; import { useEffect, useRef, useState } from 'react'; +import '../index.less'; export default ({ data, reloadTable }) => { // const [isModalVisible, setIsModalVisible] = useState(false); // 控制 ClientModal 的显示 @@ -180,6 +181,7 @@ export default ({ data, reloadTable }) => { return ( <Space> <ModalForm + className="client-index" title="跟进记录" trigger={<Button type="primary">查看</Button>} submitter={{ diff --git a/src/pages/Client/FollowRecord/index.less b/src/pages/Client/FollowRecord/index.less new file mode 100644 index 0000000..06a9a6a --- /dev/null +++ b/src/pages/Client/FollowRecord/index.less @@ -0,0 +1,9 @@ +.client-index td { + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', + 'WenQuanYi Micro Hei', sans-serif; + font-size: 13px; + word-wrap: break-word; /* 优先使用 */ + word-break: break-word; /* 强制断行,适用于长单词 */ + white-space: normal; /* 允许内容换行 */ +} diff --git a/src/pages/Client/FollowRecord/index.tsx b/src/pages/Client/FollowRecord/index.tsx index 2d51800..d59c3f4 100644 --- a/src/pages/Client/FollowRecord/index.tsx +++ b/src/pages/Client/FollowRecord/index.tsx @@ -12,6 +12,7 @@ import type { ActionType } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components'; import { Button, Popconfirm, Space, message } from 'antd'; import { useRef, useState } from 'react'; +import './index.less'; export default () => { const actionRef = useRef<ActionType>(); @@ -328,7 +329,7 @@ export default () => { // actionRef.current?.reload(); // }, [groupFilter]); return ( - <> + <div className="client-index"> <Space direction="vertical" size="middle" style={{ display: 'flex' }}> <ProTable columns={columns} @@ -410,6 +411,6 @@ export default () => { /> </Space> {/* {contextHolder} */} - </> + </div> ); }; diff --git a/src/pages/Order/Order/index copy.tsx b/src/pages/Order/Order/index copy.tsx new file mode 100644 index 0000000..53ade4a --- /dev/null +++ b/src/pages/Order/Order/index copy.tsx @@ -0,0 +1,5561 @@ +import ButtonConfirm from '@/components/ButtomConfirm'; +import { RESPONSE_CODE } from '@/constants/enum'; +import ImportExpressBillModal from '@/pages/Order/Order/components/ImportExpressBillModal'; +import InvoicingDrawerForm from '@/pages/Order/Order/components/InvoicingDrawerForm'; +import ReissueModal from '@/pages/Order/Order/components/ReissueModal'; +import ReissueModal_old from '@/pages/Order/Order/components/ReissueModal_old'; +import { + postKingdeeRepSalBillOutbound, + postKingdeeRepSalOrderSave, + postServiceConstCanApplyAfterInvoicingStatus, + postServiceInvoiceCancelApply, + postServiceOrderCancelSend, + postServiceOrderConfirmInvoice, + postServiceOrderGetCurrentOptNode, + postServiceOrderNoNeedSend, + postServiceOrderOrderCancel, + postServiceOrderProcureOrder, + postServiceOrderProcurePrint, + postServiceOrderProvideProcurementRoles, + postServiceOrderQueryServiceOrder, + postServiceOrderSaleCancelInvoicing, + postServiceOrderSalesConfirm, + postServiceOrderWarningOrderStatistics, +} from '@/services'; +import { downloadFile } from '@/services/order'; +import { + FloatAdd, + copyToClipboard, + enumToProTableEnumValue, + enumValueToLabel, + formatDateTime, + formatdate, + getAliYunOSSFileNameFromUrl, + isImageName, +} from '@/utils'; +import { + getReceivingCompanyOptions, + isAdmin, + isExaminer, + isFinance, + isProcure, + isSales, + isSupplier, + isWarehousekeeper, +} from '@/utils/order'; +import { getUserInfo } from '@/utils/user'; +import { + ClockCircleTwoTone, + ContainerTwoTone, + CopyOutlined, + CopyTwoTone, + DownOutlined, + EditTwoTone, + QuestionCircleOutlined, +} from '@ant-design/icons'; +import { + ActionType, + ProColumns, + ProFormInstance, + ProTable, +} from '@ant-design/pro-components'; +import { useModel } from '@umijs/max'; +import { + Button, + Card, + Checkbox, + Col, + Divider, + Dropdown, + Flex, + FloatButton, + Image, + MenuProps, + Modal, + Popconfirm, + Radio, + Row, + Space, + Spin, + Tag, + Tooltip, + message, +} from 'antd'; +import Base64 from 'base-64'; +import { cloneDeep } from 'lodash'; +import React, { Key, useEffect, useMemo, 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 { useNavigate } from 'react-router-dom'; +import { history } from '@umijs/max'; +// import { format } from 'fecha'; + +const OrderPage = () => { + const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false); + const [checkVisible, setCheckVisible] = useState<boolean>(false); + const [orderPrintVisible, setOrderPrintVisible] = useState<boolean>(false); + const [allMainChecked, setAllMainChecked] = useState(false); + 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, setFilterCondition] = 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 [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id + const [subOrderCount, setSubOrderCount] = useState(0); + const [sorted, setSorted] = useState(false); + const mainTableRef = useRef<ActionType>(); + const mainTableFormRef = useRef<ProFormInstance>(); + let [searchParams, setSearchParam] = useState(Object); //表格的查询条件存储 + const [messageApi, contextHolder] = message.useMessage(); + const [ + shippingWarehouseChangeModalVisible, + setShippingWarehouseChangeModalVisible, + ] = useState(false); + const [canApplyAfterInvoicingStatus, setCanApplyAfterInvoicingStatus] = + useState([]); + const [ids, setIds] = useState([]); + const [recordOptNode, setRecordOptNode] = useState(null); + const roleCode = userInfo?.roleSmallVO?.code; + const roles = userInfo?.roles; + const canMergeInvoicing = useMemo(() => { + if (subOrderSelectedMap.size === 0) { + return false; + } + // 检查 value.items 中的每个元素 + console.log( + 'map' + JSON.stringify([...subOrderSelectedMap.values()].flat()), + ); + return [...subOrderSelectedMap.values()] + .flat() + .every((subItem) => subItem.paths?.includes('applyInvoicing_old')); + }, [selectedSubOrderKeys]); + + console.log(JSON.stringify(userInfo)); + const triggerRecordOptNode = async (id) => { + const res = await postServiceOrderGetCurrentOptNode({ + query: { + id, + }, + }); + setRecordOptNode(res.data); + }; + + const exportLoading = () => { + messageApi.open({ + type: 'loading', + content: '正在导出文件...', + duration: 0, + }); + }; + + const exportLoadingDestory = () => { + messageApi.destroy(); + }; + + 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); + } + }, []); + + useEffect(() => { + const initEnum = async () => { + let invoiceTypeRet = await postServiceConstCanApplyAfterInvoicingStatus(); + if (invoiceTypeRet.result === RESPONSE_CODE.SUCCESS) { + setCanApplyAfterInvoicingStatus(invoiceTypeRet.data); + } + }; + initEnum(); + }, []); + + /** + * 复制订单到剪贴板 + * @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; + } + + /** + * 财务是否选中排序 + * @param e + */ + function financeSorted(e: any) { + let checked = e?.target.checked; + setSorted(checked); + refreshTable(); + } + + /** + * 重置当前的操作对象 + */ + 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 === undefined || currentOptMainId === null) { + 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 === null) { + message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员'); + } + + return mainOrderClone; + } + + /** + * 返回当前操作的子订单集合 + */ + function buildSubOrders() { + if (currentOptMainId === undefined || currentOptMainId === null) { + message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员'); + return; + } + + let cloneSubOrders = []; + + //如果没有传当前操作的子订单id,说明是操作主订单 + if (curretnOptSubId === undefined || curretnOptSubId === null) { + //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象 + 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 { + 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.uid && ( + <span className="text-[#f44e4e] cursor-pointer"> + (商城订单) + </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.invoiceConfirmStatusText !== null && ( + <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> + <Tag color={'success'} style={{ marginRight: '4px' }}> + {optRecord.invoiceConfirmStatusText} + </Tag> + </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 () => { + let body = [optRecord.id]; + const data = await postServiceOrderConfirmInvoice({ + data: body, + }); + 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('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('confirmInvoice') ? ( + <ButtonConfirm + className="p-0" + title="已和客户确认发票?" + text="确认发票" + onConfirm={async () => { + let body = [ + ...record.subOrderInformationLists.map( + (subOrder) => subOrder.id, + ), + ]; + const data = await postServiceOrderConfirmInvoice({ + data: body, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + refreshTable(); + } + }} + /> + ) : ( + '' + )} + + {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 (roles.includes('PROCURE') && item.dataIndex === 'orderStatus') { + item.valueEnum = enumToProTableEnumValue( + PROCURE_PRIMARY_ORDER_STATUS_OPTIONS, + ); + } + return item; + }, + ); + + /** + * 采购可以筛选供应商备注 + */ + if ( + (roleCode === 'procure' || + roles.includes('PROCURE') || + roleCode === 'admin') && + !isSupplier() + ) { + mainOrdersColumns.push({ + title: '供应商备注', + width: 120, + dataIndex: 'supplierNotes', + valueType: 'text', + hideInTable: true, + }); + } + + /** + * 采购可以筛选其他采购 + */ + if ( + (roleCode === 'procure' || + roles.includes('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' || + roles.includes('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' || + roles.includes('PROCURE') || + roleCode === 'admin' + ) { + mainOrdersColumns.push({ + title: isSupplier() ? '下单状态' : '采购下单状态', + dataIndex: 'procureOrderStatus', + valueType: 'select', + hideInTable: true, + valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS), + }); + } + + function toolBarRender() { + let toolBtns = []; + let radios: any[] = []; + + radios.push(<Radio value={0}>全部</Radio>); + + if ( + roleCode === 'admin' || + roleCode === 'salesManager' || + roles.includes('PROCURE') || + roleCode === 'salesRepresentative' + ) { + radios.push(<Radio value={70}>只看作废</Radio>); + } + + if (roleCode === 'warehouseKeeper') { + radios.push(<Radio value={40}>待处理</Radio>); + } + + //采购可以筛选出需要处理的订单 + if (roles.includes('PROCURE') && !isSupplier()) { + radios.push(<Radio value={60}>其他采购</Radio>); + radios.push(<Radio value={10}>待处理</Radio>); + } + + //财务可以将需要处理的订单排序到前面 + if (roleCode === 'finance') { + radios.push(<Radio value={50}>加急</Radio>); + + radios.push(<Radio value={40}>待处理</Radio>); + + radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>); + } + + if (roleCode === 'salesRepresentative' || roleCode === 'salesManager') { + radios.push(<Radio value={30}>只看我创建</Radio>); + + radios.push(<Radio value={40}>待审核</Radio>); + } + + if (roleCode === 'admin') { + radios.push(<Radio value={10}>待处理</Radio>); + radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>); + } + + //筛选按钮配置 + let radioGroup = ( + <Radio.Group + onChange={(e: any) => { + setFilterCondition(e.target.value); + refreshTable(); + }} + defaultValue={0} + > + {radios} + </Radio.Group> + ); + + toolBtns.push(radioGroup); + + toolBtns.push(<ImportExpressBillModal></ImportExpressBillModal>); + + //导出按钮配置 + const exportItems: MenuProps['items'] = [ + { + label: '导出查询结果订单', + key: '2', + onClick: async () => { + let body = { flag: 50, ...searchParams }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + { + label: '导出已选中订单', + key: '1', + onClick: async () => { + if (mainOrderSelectedMap.size === 0) { + message.error('请选择订单'); + return; + } + let body = { flag: 30, id: Array.from(mainOrderSelectedMap.keys()) }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + { + label: '导出当天订单', + key: '4', + onClick: async () => { + let body = { flag: 40, ids: [] }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + { + label: '导出所有订单', + key: '3', + onClick: async () => { + let body = { flag: 10, ids: [] }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + ]; + + const exportMenuProps = { + items: exportItems, + onClick: () => {}, + }; + + //一键审核按钮配置 + const auditItems: MenuProps['items'] = [ + { + label: '后置审核', + key: '1', + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT); + }, + }, + { + label: '加急开票审核(旧)', + key: '2', + disabled: true, + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD); + }, + }, + { + label: '领导审核', + key: '3', + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.LEADER_AUDIT); + }, + }, + { + label: '修改申请审核', + key: '4', + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT); + }, + }, + ]; + + const auditProps = { + items: auditItems, + onClick: () => {}, + }; + + if (rolePath?.includes('leaderMergeAudit')) { + toolBtns.push( + <Dropdown + disabled={selectedSubOrderKeys.length === 0} + menu={auditProps} + > + <Button> + <Space> + 一键审核 + <DownOutlined /> + </Space> + </Button> + </Dropdown>, + ); + } + + if (rolePath?.includes('mergeAudit')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setIsMainOrder(true); + if (roles.includes('PROCURE')) { + setProcureCheckModalVisible(true); + } + + if (roleCode === 'warehouseKeeper') { + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); + } + }} + disabled={selectedSubOrderKeys?.length === 0} + > + 一键审核 + </Button>, + ); + } + + if (rolePath?.includes('mergeProcureOrder')) { + toolBtns.push( + <Button + key="mergeProcureOrder" + type="primary" + disabled={selectedSubOrderKeys.length === 0} + onClick={() => { + Modal.confirm({ + title: '一键下单', + content: '选中的订单是否都已下单?', + onOk: async () => { + let res = await postServiceOrderProcureOrder({ + data: { subIds: [...selectedSubOrderKeys.values()].flat() }, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + refreshTable(); + return true; + } + }, + }); + }} + > + 一键下单 + </Button>, + ); + } + + if (rolePath?.includes('mergeApplyInvoicing')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setIsEdit(false); + setIsMainOrder(true); + setApplyForInvoicingVisible(true); + }} + disabled={!canMergeInvoicing} /*{selectedSubOrderKeys?.length === 0}*/ + > + {roleCode === 'admin' ? '合并(销售)' : '合并开票'} + </Button>, + ); + } + + <Button + type="primary" + key="out" + onClick={() => { + setIsEdit(false); + setIsMainOrder(true); + setInvoicingDrawerFormVisible(true); + }} + disabled={selectedSubOrderKeys?.length === 0} + > + 申请开票(旧) + </Button>; + + if (rolePath?.includes('mergeInvoicing')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + //检查订单状态是否正确 + // 遍历Map中的键值对 + let errorIds = new Set(); + [...subOrderSelectedMap.values()].flat().forEach((subOrder) => { + if ( + subOrder.afterInvoicingStatus !== 'APPLY_FOR_INVOICING' && + subOrder.afterInvoicingStatus !== 'PARTIAL_INVOICING' + ) { + errorIds.add(subOrder.mainOrderId); + return; + } + }); + if (errorIds.size > 0) { + message.error( + '订单号为:' + + [...errorIds.values()].join(',') + + '的订单存在不是[申请开票]或者[部分开票]状态的子订单,请检查!', + ); + return; + } + setIsMainOrder(true); + setFinancialVisible(true); + }} + disabled={selectedSubOrderKeys?.length === 0} + > + {roleCode === 'admin' ? '合并(财务)' : '合并开票'} + </Button>, + ); + } + + toolBtns.push( + <Button + type="primary" + key="inv" + onClick={() => { + setIsMainOrder(true); + let flat = [...subOrderSelectedMap.values()].flat(); + //遍历flat,判断afterInvoicingStatusList存在于canApplyAfterInvoicingStatus + flat.forEach((item) => { + if ( + item.invoicingStatus === 'UN_INVOICE' || + (item.afterInvoicingStatus !== null && + !canApplyAfterInvoicingStatus.includes( + item.afterInvoicingStatus, + )) + ) { + message.error('存在不能进行开票的订单'); + return; + } + }); + //遍历afterInvoicingStatusList + setInvoicingDrawerFormVisible(true); + }} + disabled={selectedSubOrderKeys?.length === 0} + > + 申请开票 + </Button>, + ); + + if (rolePath?.includes('addOrder')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setOrderDrawerVisible(true); + setOrderOptType('add'); + }} + > + 新增 + </Button>, + ); + } + + if (rolePath?.includes('importExcel')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setImportModalVisible(true); + }} + > + 批量发货 + </Button>, + ); + } + + if (rolePath?.includes('export')) { + toolBtns.push( + <Dropdown menu={exportMenuProps}> + <Button> + <Space> + 导出 + <DownOutlined /> + </Space> + </Button> + </Dropdown>, + ); + } + + return toolBtns; + } + function setOriginTime(value) { + const currentDate = new Date(); + + // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 + const newDate = new Date(currentDate); + newDate.setDate(currentDate.getDate() - value); + // 检查日期是否有效,并格式化输出 + function formatDate(date) { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需加1 + const day = String(date.getDate()).padStart(2, '0'); // 确保是两位数 + return `${year}-${month}-${day} ${date.toTimeString().split(' ')[0]}`; // 获取时间部分 + } + const formattedDate = formatDate(newDate); + // const formattedDate = format(newDate, 'YYYY-MM-dd HH:mm:ss'); + return formattedDate; + } + const [invoiceWarningNum, setInvoiceWarningNum] = useState(0); + const [invoiceRefundWarningNum, setInvoiceRefundWarningNum] = useState(0); + const [waitConfirmPayment, setWaitConfirmPayment] = useState(0); + const [waitFeedback, setWaitFeedback] = useState(0); + const [open, setOpen] = useState(false); + const { openCount, setOpenCount } = useModel('count'); + + async function getInvoiceWarningNum() { + const res = await postServiceOrderWarningOrderStatistics({ + data: { + salesCode: userInfo.username, + waitConfirmReiceptStatusDateTimeLe: setOriginTime(7), + waitFeedbackStatusDateTimeLe: setOriginTime(20), + waitConfirmInvoiceStatusDateTimeLe: setOriginTime(5), + waitConfirmPaymentStatusDateTimeLe: setOriginTime(30), + }, + }); + if ( + (res.data.waitConfirmInvoice !== 0 || + res.data.waitConfirmReceipt !== 0) && + openCount !== true + ) { + setOpenCount(true); + setOpen(true); + } + setInvoiceWarningNum(res.data.waitConfirmInvoice); + setInvoiceRefundWarningNum(res.data.waitConfirmReceipt); + setWaitConfirmPayment(res.data.waitConfirmPayment); + setWaitFeedback(res.data.waitFeedback); + } + + useEffect(() => { + //预警订单数 + getInvoiceWarningNum(); + }, []); + // 隐藏弹窗 + const navigateToWarning = () => { + setOpen(false); + // history.push('/order/OrderWarning'); + // window.location.replace = '/order/OrderWarning'; + // navigate('/order/OrderWarning'); + history.push('/order/OrderWarning'); + // location.href = '/order/OrderWarning'; + // history.pushState(null, '', '/order/OrderWarning'); + }; + return ( + <div className="order-page-container"> + <div id="resizeDiv"></div> + <div id="resizeDiv"></div> + {roleCode === 'SALES_REPRESENTATIVE' && ( + <Modal + title="订单预警提醒" + open={open} + width={800} + closable={false} + footer={[ + <Button + key="confirm" + size="large" + type="primary" + onClick={navigateToWarning} + > + 去处理 + </Button>, + ]} + > + <Row + gutter={16} + justify="space-between" // Aligns Cols to the start and end + align="middle" // Vertically center contents + > + {/* 新增卡片1: 待确认收货订单 */} + <Col span={6}> + {' '} + {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} + <div + style={{ + display: 'flex', + justifyContent: 'center', + marginTop: '20px', + }} + > + <Card + bordered={true} + style={{ + backgroundColor: '#f0f0f0', // 背景颜色 + width: '200px', // 卡片宽度 + height: '200px', // 卡片高度 + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '18px', // 字体大小 + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '40px', // 字体大小 + justifyContent: 'center', + display: 'flex', + alignItems: 'center', + marginBottom: '20px', + }} + > + {invoiceRefundWarningNum} + </div> + 待确认收货订单 + </div> + </Card> + </div> + </Col> + + {/* 新增卡片2: 待回访登记订单 */} + <Col span={6}> + {' '} + {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} + <div + style={{ + display: 'flex', + justifyContent: 'center', + marginTop: '20px', + }} + > + <Card + bordered={true} + style={{ + backgroundColor: '#f0f0f0', // 背景颜色 + width: '200px', // 卡片宽度 + height: '200px', // 卡片高度 + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '18px', // 字体大小 + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '40px', // 字体大小 + justifyContent: 'center', + display: 'flex', + alignItems: 'center', + marginBottom: '20px', + }} + > + {waitFeedback} + </div> + 待回访登记订单 + </div> + </Card> + </div> + </Col> + + {/* 现有卡片: 发票待确认订单 */} + <Col span={6}> + {' '} + {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} + <div + style={{ + display: 'flex', + justifyContent: 'center', + marginTop: '20px', + }} + > + <Card + bordered={true} + style={{ + backgroundColor: '#f0f0f0', // 背景颜色 + width: '200px', // 卡片宽度 + height: '200px', // 卡片高度 + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '18px', // 字体大小 + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '40px', // 字体大小 + justifyContent: 'center', + display: 'flex', + alignItems: 'center', + marginBottom: '20px', + }} + > + {invoiceWarningNum} + </div> + 待确认发票订单 + </div> + </Card> + </div> + </Col> + + {/* 现有卡片: 回款待确认订单 */} + <Col span={6}> + {' '} + {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} + <div + style={{ + display: 'flex', + justifyContent: 'center', + marginTop: '20px', + }} + > + <Card + bordered={true} + style={{ + backgroundColor: '#f0f0f0', // 背景颜色 + width: '200px', // 卡片宽度 + height: '200px', // 卡片高度 + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '18px', // 字体大小 + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '40px', // 字体大小 + justifyContent: 'center', + display: 'flex', + alignItems: 'center', + marginBottom: '20px', + }} + > + {waitConfirmPayment} + </div> + 待回款订单 + </div> + </Card> + </div> + </Col> + </Row> + + <div> + <p + style={{ + color: 'red', + paddingLeft: '20px', + paddingRight: '20px', + marginTop: '10px', + }} + > + 预警说明: + </p> + <div + style={{ + marginLeft: '20px', + marginRight: '20px', + marginBottom: '20px', + }} + > + <span style={{ color: 'red' }}>确认收货预警:</span> + <span> + 从发货之日起计算,国内超过7天(海外30天)未【确认收货】,将进行确认收货预警提醒,超过10天(海外60天)未确认收货将锁单,并且每次登录都会提醒 + </span> + </div> + <div + style={{ + marginLeft: '20px', + marginRight: '20px', + marginBottom: '20px', + }} + > + <span style={{ color: 'red' }}>回访登记预警:</span> + <span> + 从【确认收货】之日起计算,国内超过20天(海外30天)未【回访登记】,将进行回访登记预警提醒,超过45天(海外60天)未回访登记将锁单,并且每次登录都会提醒 + </span> + </div> + <div + style={{ + marginLeft: '20px', + marginRight: '20px', + marginBottom: '20px', + }} + > + <span style={{ color: 'red' }}>确认发票预警:</span> + <span> + 从发票开出之日起,超过5天未和客户确认发票(不开票的订单除外)的订单将会进行第一次提醒;超过15天未和客户确认发票(不开票的订单除外)的订单将会每天进行一次提醒,并限制下单功能 + </span> + </div> + <div + style={{ + marginLeft: '20px', + marginRight: '20px', + marginBottom: '20px', + }} + > + <span style={{ color: 'red' }}>回款预警:</span> + <span> + 从【发票确认】之日起,超过30天未确认回款的订单将会每周提醒,超过90天未确认回款的订单将会每天进行一次提醒,并限制下单功能 + </span> + </div> + </div> + </Modal> + )} + <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={{ + labelWidth: 'auto', + // onCollapse: resize, + }} + 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.condition = filterCondifion; + + //排序 + params.sorted = sorted; + //是否只查看已作废 + params.isDeleteQueryOrder = filterCondifion === 70; + //保存这个搜索条件 + setSearchParam(params); + const { data } = await postServiceOrderQueryServiceOrder({ + // ...params, + // FIXME: remove @ts-ignore + // @ts-ignore + sorter, + filter, + data: { ...params }, + }); + + 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); + } + + 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; diff --git a/src/pages/Order/Order/index.tsx b/src/pages/Order/Order/index.tsx index 53ade4a..b97d01d 100644 --- a/src/pages/Order/Order/index.tsx +++ b/src/pages/Order/Order/index.tsx @@ -1,4593 +1,17 @@ -import ButtonConfirm from '@/components/ButtomConfirm'; -import { RESPONSE_CODE } from '@/constants/enum'; -import ImportExpressBillModal from '@/pages/Order/Order/components/ImportExpressBillModal'; -import InvoicingDrawerForm from '@/pages/Order/Order/components/InvoicingDrawerForm'; -import ReissueModal from '@/pages/Order/Order/components/ReissueModal'; -import ReissueModal_old from '@/pages/Order/Order/components/ReissueModal_old'; -import { - postKingdeeRepSalBillOutbound, - postKingdeeRepSalOrderSave, - postServiceConstCanApplyAfterInvoicingStatus, - postServiceInvoiceCancelApply, - postServiceOrderCancelSend, - postServiceOrderConfirmInvoice, - postServiceOrderGetCurrentOptNode, - postServiceOrderNoNeedSend, - postServiceOrderOrderCancel, - postServiceOrderProcureOrder, - postServiceOrderProcurePrint, - postServiceOrderProvideProcurementRoles, - postServiceOrderQueryServiceOrder, - postServiceOrderSaleCancelInvoicing, - postServiceOrderSalesConfirm, - postServiceOrderWarningOrderStatistics, -} from '@/services'; -import { downloadFile } from '@/services/order'; -import { - FloatAdd, - copyToClipboard, - enumToProTableEnumValue, - enumValueToLabel, - formatDateTime, - formatdate, - getAliYunOSSFileNameFromUrl, - isImageName, -} from '@/utils'; -import { - getReceivingCompanyOptions, - isAdmin, - isExaminer, - isFinance, - isProcure, - isSales, - isSupplier, - isWarehousekeeper, -} from '@/utils/order'; +import { postServiceOrderWarningOrderStatistics } from '@/services'; import { getUserInfo } from '@/utils/user'; -import { - ClockCircleTwoTone, - ContainerTwoTone, - CopyOutlined, - CopyTwoTone, - DownOutlined, - EditTwoTone, - QuestionCircleOutlined, -} from '@ant-design/icons'; -import { - ActionType, - ProColumns, - ProFormInstance, - ProTable, -} from '@ant-design/pro-components'; import { useModel } from '@umijs/max'; -import { - Button, - Card, - Checkbox, - Col, - Divider, - Dropdown, - Flex, - FloatButton, - Image, - MenuProps, - Modal, - Popconfirm, - Radio, - Row, - Space, - Spin, - Tag, - Tooltip, - message, -} from 'antd'; -import Base64 from 'base-64'; -import { cloneDeep } from 'lodash'; -import React, { Key, useEffect, useMemo, 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 { Button, Card, Col, Modal, Row } from 'antd'; +import { useEffect, useState } from 'react'; +import OrderList from '../OrderList/OrderList'; import './index.less'; -import { OrderListItemType, OrderType } from './type.d'; // import { useNavigate } from 'react-router-dom'; import { history } from '@umijs/max'; // import { format } from 'fecha'; const OrderPage = () => { - const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false); - const [checkVisible, setCheckVisible] = useState<boolean>(false); - const [orderPrintVisible, setOrderPrintVisible] = useState<boolean>(false); - const [allMainChecked, setAllMainChecked] = useState(false); - 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, setFilterCondition] = 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 [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id - const [subOrderCount, setSubOrderCount] = useState(0); - const [sorted, setSorted] = useState(false); - const mainTableRef = useRef<ActionType>(); - const mainTableFormRef = useRef<ProFormInstance>(); - let [searchParams, setSearchParam] = useState(Object); //表格的查询条件存储 - const [messageApi, contextHolder] = message.useMessage(); - const [ - shippingWarehouseChangeModalVisible, - setShippingWarehouseChangeModalVisible, - ] = useState(false); - const [canApplyAfterInvoicingStatus, setCanApplyAfterInvoicingStatus] = - useState([]); - const [ids, setIds] = useState([]); - const [recordOptNode, setRecordOptNode] = useState(null); - const roleCode = userInfo?.roleSmallVO?.code; - const roles = userInfo?.roles; - const canMergeInvoicing = useMemo(() => { - if (subOrderSelectedMap.size === 0) { - return false; - } - // 检查 value.items 中的每个元素 - console.log( - 'map' + JSON.stringify([...subOrderSelectedMap.values()].flat()), - ); - return [...subOrderSelectedMap.values()] - .flat() - .every((subItem) => subItem.paths?.includes('applyInvoicing_old')); - }, [selectedSubOrderKeys]); - - console.log(JSON.stringify(userInfo)); - const triggerRecordOptNode = async (id) => { - const res = await postServiceOrderGetCurrentOptNode({ - query: { - id, - }, - }); - setRecordOptNode(res.data); - }; - - const exportLoading = () => { - messageApi.open({ - type: 'loading', - content: '正在导出文件...', - duration: 0, - }); - }; - - const exportLoadingDestory = () => { - messageApi.destroy(); - }; - - 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); - } - }, []); - - useEffect(() => { - const initEnum = async () => { - let invoiceTypeRet = await postServiceConstCanApplyAfterInvoicingStatus(); - if (invoiceTypeRet.result === RESPONSE_CODE.SUCCESS) { - setCanApplyAfterInvoicingStatus(invoiceTypeRet.data); - } - }; - initEnum(); - }, []); - - /** - * 复制订单到剪贴板 - * @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; - } - - /** - * 财务是否选中排序 - * @param e - */ - function financeSorted(e: any) { - let checked = e?.target.checked; - setSorted(checked); - refreshTable(); - } - - /** - * 重置当前的操作对象 - */ - 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 === undefined || currentOptMainId === null) { - 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 === null) { - message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员'); - } - - return mainOrderClone; - } - - /** - * 返回当前操作的子订单集合 - */ - function buildSubOrders() { - if (currentOptMainId === undefined || currentOptMainId === null) { - message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员'); - return; - } - - let cloneSubOrders = []; - - //如果没有传当前操作的子订单id,说明是操作主订单 - if (curretnOptSubId === undefined || curretnOptSubId === null) { - //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象 - 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 { - 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.uid && ( - <span className="text-[#f44e4e] cursor-pointer"> - (商城订单) - </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.invoiceConfirmStatusText !== null && ( - <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> - <Tag color={'success'} style={{ marginRight: '4px' }}> - {optRecord.invoiceConfirmStatusText} - </Tag> - </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 () => { - let body = [optRecord.id]; - const data = await postServiceOrderConfirmInvoice({ - data: body, - }); - 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('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('confirmInvoice') ? ( - <ButtonConfirm - className="p-0" - title="已和客户确认发票?" - text="确认发票" - onConfirm={async () => { - let body = [ - ...record.subOrderInformationLists.map( - (subOrder) => subOrder.id, - ), - ]; - const data = await postServiceOrderConfirmInvoice({ - data: body, - }); - if (data.result === RESPONSE_CODE.SUCCESS) { - message.success(data.message); - refreshTable(); - } - }} - /> - ) : ( - '' - )} - - {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 (roles.includes('PROCURE') && item.dataIndex === 'orderStatus') { - item.valueEnum = enumToProTableEnumValue( - PROCURE_PRIMARY_ORDER_STATUS_OPTIONS, - ); - } - return item; - }, - ); - - /** - * 采购可以筛选供应商备注 - */ - if ( - (roleCode === 'procure' || - roles.includes('PROCURE') || - roleCode === 'admin') && - !isSupplier() - ) { - mainOrdersColumns.push({ - title: '供应商备注', - width: 120, - dataIndex: 'supplierNotes', - valueType: 'text', - hideInTable: true, - }); - } - - /** - * 采购可以筛选其他采购 - */ - if ( - (roleCode === 'procure' || - roles.includes('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' || - roles.includes('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' || - roles.includes('PROCURE') || - roleCode === 'admin' - ) { - mainOrdersColumns.push({ - title: isSupplier() ? '下单状态' : '采购下单状态', - dataIndex: 'procureOrderStatus', - valueType: 'select', - hideInTable: true, - valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS), - }); - } - - function toolBarRender() { - let toolBtns = []; - let radios: any[] = []; - - radios.push(<Radio value={0}>全部</Radio>); - - if ( - roleCode === 'admin' || - roleCode === 'salesManager' || - roles.includes('PROCURE') || - roleCode === 'salesRepresentative' - ) { - radios.push(<Radio value={70}>只看作废</Radio>); - } - - if (roleCode === 'warehouseKeeper') { - radios.push(<Radio value={40}>待处理</Radio>); - } - - //采购可以筛选出需要处理的订单 - if (roles.includes('PROCURE') && !isSupplier()) { - radios.push(<Radio value={60}>其他采购</Radio>); - radios.push(<Radio value={10}>待处理</Radio>); - } - - //财务可以将需要处理的订单排序到前面 - if (roleCode === 'finance') { - radios.push(<Radio value={50}>加急</Radio>); - - radios.push(<Radio value={40}>待处理</Radio>); - - radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>); - } - - if (roleCode === 'salesRepresentative' || roleCode === 'salesManager') { - radios.push(<Radio value={30}>只看我创建</Radio>); - - radios.push(<Radio value={40}>待审核</Radio>); - } - - if (roleCode === 'admin') { - radios.push(<Radio value={10}>待处理</Radio>); - radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>); - } - - //筛选按钮配置 - let radioGroup = ( - <Radio.Group - onChange={(e: any) => { - setFilterCondition(e.target.value); - refreshTable(); - }} - defaultValue={0} - > - {radios} - </Radio.Group> - ); - - toolBtns.push(radioGroup); - - toolBtns.push(<ImportExpressBillModal></ImportExpressBillModal>); - - //导出按钮配置 - const exportItems: MenuProps['items'] = [ - { - label: '导出查询结果订单', - key: '2', - onClick: async () => { - let body = { flag: 50, ...searchParams }; - exportLoading(); - downloadFile( - '/api/service/order/export', - '订单导出结果.xls', - 'POST', - body, - exportLoadingDestory, - ); - }, - }, - { - label: '导出已选中订单', - key: '1', - onClick: async () => { - if (mainOrderSelectedMap.size === 0) { - message.error('请选择订单'); - return; - } - let body = { flag: 30, id: Array.from(mainOrderSelectedMap.keys()) }; - exportLoading(); - downloadFile( - '/api/service/order/export', - '订单导出结果.xls', - 'POST', - body, - exportLoadingDestory, - ); - }, - }, - { - label: '导出当天订单', - key: '4', - onClick: async () => { - let body = { flag: 40, ids: [] }; - exportLoading(); - downloadFile( - '/api/service/order/export', - '订单导出结果.xls', - 'POST', - body, - exportLoadingDestory, - ); - }, - }, - { - label: '导出所有订单', - key: '3', - onClick: async () => { - let body = { flag: 10, ids: [] }; - exportLoading(); - downloadFile( - '/api/service/order/export', - '订单导出结果.xls', - 'POST', - body, - exportLoadingDestory, - ); - }, - }, - ]; - - const exportMenuProps = { - items: exportItems, - onClick: () => {}, - }; - - //一键审核按钮配置 - const auditItems: MenuProps['items'] = [ - { - label: '后置审核', - key: '1', - onClick: async () => { - setIsMainOrder(true); - setCheckVisible(true); - setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT); - }, - }, - { - label: '加急开票审核(旧)', - key: '2', - disabled: true, - onClick: async () => { - setIsMainOrder(true); - setCheckVisible(true); - setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD); - }, - }, - { - label: '领导审核', - key: '3', - onClick: async () => { - setIsMainOrder(true); - setCheckVisible(true); - setOrderCheckType(CHECK_TYPE.LEADER_AUDIT); - }, - }, - { - label: '修改申请审核', - key: '4', - onClick: async () => { - setIsMainOrder(true); - setCheckVisible(true); - setOrderCheckType(CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT); - }, - }, - ]; - - const auditProps = { - items: auditItems, - onClick: () => {}, - }; - - if (rolePath?.includes('leaderMergeAudit')) { - toolBtns.push( - <Dropdown - disabled={selectedSubOrderKeys.length === 0} - menu={auditProps} - > - <Button> - <Space> - 一键审核 - <DownOutlined /> - </Space> - </Button> - </Dropdown>, - ); - } - - if (rolePath?.includes('mergeAudit')) { - toolBtns.push( - <Button - type="primary" - key="out" - onClick={() => { - setIsMainOrder(true); - if (roles.includes('PROCURE')) { - setProcureCheckModalVisible(true); - } - - if (roleCode === 'warehouseKeeper') { - setCheckVisible(true); - setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); - } - }} - disabled={selectedSubOrderKeys?.length === 0} - > - 一键审核 - </Button>, - ); - } - - if (rolePath?.includes('mergeProcureOrder')) { - toolBtns.push( - <Button - key="mergeProcureOrder" - type="primary" - disabled={selectedSubOrderKeys.length === 0} - onClick={() => { - Modal.confirm({ - title: '一键下单', - content: '选中的订单是否都已下单?', - onOk: async () => { - let res = await postServiceOrderProcureOrder({ - data: { subIds: [...selectedSubOrderKeys.values()].flat() }, - }); - if (res.result === RESPONSE_CODE.SUCCESS) { - message.success(res.message); - refreshTable(); - return true; - } - }, - }); - }} - > - 一键下单 - </Button>, - ); - } - - if (rolePath?.includes('mergeApplyInvoicing')) { - toolBtns.push( - <Button - type="primary" - key="out" - onClick={() => { - setIsEdit(false); - setIsMainOrder(true); - setApplyForInvoicingVisible(true); - }} - disabled={!canMergeInvoicing} /*{selectedSubOrderKeys?.length === 0}*/ - > - {roleCode === 'admin' ? '合并(销售)' : '合并开票'} - </Button>, - ); - } - - <Button - type="primary" - key="out" - onClick={() => { - setIsEdit(false); - setIsMainOrder(true); - setInvoicingDrawerFormVisible(true); - }} - disabled={selectedSubOrderKeys?.length === 0} - > - 申请开票(旧) - </Button>; - - if (rolePath?.includes('mergeInvoicing')) { - toolBtns.push( - <Button - type="primary" - key="out" - onClick={() => { - //检查订单状态是否正确 - // 遍历Map中的键值对 - let errorIds = new Set(); - [...subOrderSelectedMap.values()].flat().forEach((subOrder) => { - if ( - subOrder.afterInvoicingStatus !== 'APPLY_FOR_INVOICING' && - subOrder.afterInvoicingStatus !== 'PARTIAL_INVOICING' - ) { - errorIds.add(subOrder.mainOrderId); - return; - } - }); - if (errorIds.size > 0) { - message.error( - '订单号为:' + - [...errorIds.values()].join(',') + - '的订单存在不是[申请开票]或者[部分开票]状态的子订单,请检查!', - ); - return; - } - setIsMainOrder(true); - setFinancialVisible(true); - }} - disabled={selectedSubOrderKeys?.length === 0} - > - {roleCode === 'admin' ? '合并(财务)' : '合并开票'} - </Button>, - ); - } - - toolBtns.push( - <Button - type="primary" - key="inv" - onClick={() => { - setIsMainOrder(true); - let flat = [...subOrderSelectedMap.values()].flat(); - //遍历flat,判断afterInvoicingStatusList存在于canApplyAfterInvoicingStatus - flat.forEach((item) => { - if ( - item.invoicingStatus === 'UN_INVOICE' || - (item.afterInvoicingStatus !== null && - !canApplyAfterInvoicingStatus.includes( - item.afterInvoicingStatus, - )) - ) { - message.error('存在不能进行开票的订单'); - return; - } - }); - //遍历afterInvoicingStatusList - setInvoicingDrawerFormVisible(true); - }} - disabled={selectedSubOrderKeys?.length === 0} - > - 申请开票 - </Button>, - ); - - if (rolePath?.includes('addOrder')) { - toolBtns.push( - <Button - type="primary" - key="out" - onClick={() => { - setOrderDrawerVisible(true); - setOrderOptType('add'); - }} - > - 新增 - </Button>, - ); - } - - if (rolePath?.includes('importExcel')) { - toolBtns.push( - <Button - type="primary" - key="out" - onClick={() => { - setImportModalVisible(true); - }} - > - 批量发货 - </Button>, - ); - } - - if (rolePath?.includes('export')) { - toolBtns.push( - <Dropdown menu={exportMenuProps}> - <Button> - <Space> - 导出 - <DownOutlined /> - </Space> - </Button> - </Dropdown>, - ); - } - - return toolBtns; - } + const roleCode = userInfo?.roles[0]; function setOriginTime(value) { const currentDate = new Date(); @@ -4609,6 +33,7 @@ const OrderPage = () => { const [invoiceRefundWarningNum, setInvoiceRefundWarningNum] = useState(0); const [waitConfirmPayment, setWaitConfirmPayment] = useState(0); const [waitFeedback, setWaitFeedback] = useState(0); + const [invoiceCreateWarningNum, setInvoiceCreateWarningNum] = useState(0); const [open, setOpen] = useState(false); const { openCount, setOpenCount } = useModel('count'); @@ -4617,6 +42,7 @@ const OrderPage = () => { data: { salesCode: userInfo.username, waitConfirmReiceptStatusDateTimeLe: setOriginTime(7), + waitConfirmPaymentOrderCreatedDateTimeGe: setOriginTime(21), waitFeedbackStatusDateTimeLe: setOriginTime(20), waitConfirmInvoiceStatusDateTimeLe: setOriginTime(5), waitConfirmPaymentStatusDateTimeLe: setOriginTime(30), @@ -4624,16 +50,23 @@ const OrderPage = () => { }); if ( (res.data.waitConfirmInvoice !== 0 || - res.data.waitConfirmReceipt !== 0) && - openCount !== true + res.data.waitConfirmReceipt !== 0 || + res.data.waitConfirmPayment !== 0 || + res.data.waitFeedback !== 0 || + res.data.waitInvoicing !== 0) && + openCount !== 'true' ) { - setOpenCount(true); + console.log(open, '5656re222s', res); + + setOpenCount('true'); setOpen(true); } + console.log(open, '5656res', res); setInvoiceWarningNum(res.data.waitConfirmInvoice); setInvoiceRefundWarningNum(res.data.waitConfirmReceipt); setWaitConfirmPayment(res.data.waitConfirmPayment); setWaitFeedback(res.data.waitFeedback); + setInvoiceCreateWarningNum(res.data.waitInvoicing); } useEffect(() => { @@ -4658,7 +91,7 @@ const OrderPage = () => { <Modal title="订单预警提醒" open={open} - width={800} + width={1200} closable={false} footer={[ <Button @@ -4677,7 +110,7 @@ const OrderPage = () => { align="middle" // Vertically center contents > {/* 新增卡片1: 待确认收货订单 */} - <Col span={6}> + <Col span={4}> {' '} {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} <div @@ -4724,8 +157,56 @@ const OrderPage = () => { </div> </Col> + {/* 新增卡片1: 待确认收货订单 */} + <Col span={4}> + {' '} + {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} + <div + style={{ + display: 'flex', + justifyContent: 'center', + marginTop: '20px', + }} + > + <Card + bordered={true} + style={{ + backgroundColor: '#f0f0f0', // 背景颜色 + width: '200px', // 卡片宽度 + height: '200px', // 卡片高度 + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '18px', // 字体大小 + }} + > + <div + style={{ + fontWeight: 'bold', // 字体加粗 + color: 'black', // 字体颜色 + fontSize: '40px', // 字体大小 + justifyContent: 'center', + display: 'flex', + alignItems: 'center', + marginBottom: '20px', + }} + > + {invoiceCreateWarningNum} + </div> + 待开票订单 + </div> + </Card> + </div> + </Col> + {/* 新增卡片2: 待回访登记订单 */} - <Col span={6}> + <Col span={4}> {' '} {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} <div @@ -4773,7 +254,7 @@ const OrderPage = () => { </Col> {/* 现有卡片: 发票待确认订单 */} - <Col span={6}> + <Col span={4}> {' '} {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} <div @@ -4821,7 +302,7 @@ const OrderPage = () => { </Col> {/* 现有卡片: 回款待确认订单 */} - <Col span={6}> + <Col span={4}> {' '} {/* 修改位置:将 span 改为 6,以保证一行四个卡片 */} <div @@ -4899,6 +380,18 @@ const OrderPage = () => { marginBottom: '20px', }} > + <span style={{ color: 'red' }}>开票预警:</span> + <span> + 需要开票的订单从确认收货后开始计算,超过21天未申请开票的订单将会在每日登录时进行预警提醒;超过40天未申请开票将预警并锁单。 + </span> + </div> + <div + style={{ + marginLeft: '20px', + marginRight: '20px', + marginBottom: '20px', + }} + > <span style={{ color: 'red' }}>回访登记预警:</span> <span> 从【确认收货】之日起计算,国内超过20天(海外30天)未【回访登记】,将进行回访登记预警提醒,超过45天(海外60天)未回访登记将锁单,并且每次登录都会提醒 @@ -4931,629 +424,8 @@ const OrderPage = () => { </div> </Modal> )} - <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={{ - labelWidth: 'auto', - // onCollapse: resize, - }} - 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.condition = filterCondifion; - - //排序 - params.sorted = sorted; - //是否只查看已作废 - params.isDeleteQueryOrder = filterCondifion === 70; - //保存这个搜索条件 - setSearchParam(params); - const { data } = await postServiceOrderQueryServiceOrder({ - // ...params, - // FIXME: remove @ts-ignore - // @ts-ignore - sorter, - filter, - data: { ...params }, - }); - - 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); - } - - 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} /> + <OrderList paramsNew={{}} searchShow={true} toolbarShow={true} /> </div> ); }; diff --git a/src/pages/Order/OrderList/AfterSalesDrawer.tsx b/src/pages/Order/OrderList/AfterSalesDrawer.tsx new file mode 100644 index 0000000..edc6bfd --- /dev/null +++ b/src/pages/Order/OrderList/AfterSalesDrawer.tsx @@ -0,0 +1,101 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderApplyAfterSales } from '@/services'; +import { enumToSelect } from '@/utils'; +import { + DrawerForm, + ProFormDigit, + ProFormSelect, + ProFormTextArea, + ProFormUploadDragger, +} from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +import { AFTE_SALES_PLAN_OPTIONS } from '../constant'; +export default ({ setVisible, mainOrder, subOrders, onClose }) => { + let subOrderIds = subOrders?.map((item: { id: any }) => { + return item.id; + }); + + let mainOrderId = mainOrder.id; + const [form] = Form.useForm<{ + afterSalesNotes: string; + afterSalesPlan: string; + ids: []; + totalPayment: number; + filePaths: any[]; + }>(); + + return ( + <DrawerForm<{ + afterSalesNotes: string; + afterSalesPlan: string; + subOrderIds: []; + totalPayment: number; + mainId: number; + filePaths: any[]; + }> + title="申请售后" + open + resize={{ + onResize() { + console.log('resize!'); + }, + maxWidth: window.innerWidth * 0.8, + minWidth: 500, + }} + form={form} + autoFocusFirstInput + drawerProps={{ + destroyOnClose: true, + onClose: () => { + setVisible(false); + }, + }} + onFinish={async (values) => { + values.subOrderIds = subOrderIds; + values.mainId = mainOrderId; + values.filePaths = values.filePaths?.map((file) => { + return { url: file.response.data[0] }; + }); + let res = await postServiceOrderApplyAfterSales({ data: values }); + if (res?.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + > + <ProFormSelect + key="key" + label="售后方案" + width="lg" + showSearch + name="afterSalesPlan" + options={enumToSelect(AFTE_SALES_PLAN_OPTIONS)} + placeholder="请搜索" + rules={[{ required: true, message: '售后方案必填' }]} + ></ProFormSelect> + <ProFormDigit + width="lg" + name="totalPayment" + label="总金额调整" + min={0} + initialValue={mainOrder.totalPayment} + rules={[{ required: true, message: '总金额必填' }]} + /> + <ProFormTextArea + width="lg" + label="售后原因" + name="afterSalesNotes" + rules={[{ required: true, message: '售后原因必填' }]} + /> + <ProFormUploadDragger + key="filePaths" + label="附件" + name="filePaths" + action="/api/service/order/fileProcess" + fieldProps={{ + headers: { Authorization: localStorage.getItem('token') }, + }} + /> + </DrawerForm> + ); +}; diff --git a/src/pages/Order/OrderList/ApplyForInvoicingModal.tsx b/src/pages/Order/OrderList/ApplyForInvoicingModal.tsx new file mode 100644 index 0000000..8e5c92d --- /dev/null +++ b/src/pages/Order/OrderList/ApplyForInvoicingModal.tsx @@ -0,0 +1,217 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderApplyInvoicing } from '@/services'; +import { enumToSelect, getAliYunOSSFileNameFromUrl } from '@/utils'; +import { + ModalForm, + ProFormSelect, + ProFormText, + ProFormTextArea, + ProFormUploadDragger, +} from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +import { useEffect, useState } from 'react'; +import { PAYEE_OPTIONS } from '../constant'; +export default ({ + setCheckVisible, + isEdit, + subOrders, + isMainOrder, + totalPayment, + onClose, +}) => { + const [isUrgent, setIsUrgent] = useState(''); + let sumPrice = totalPayment; + + let ids = subOrders?.map((item) => { + return item.id; + }); + + let mainIdSet = new Set(); + subOrders?.forEach((item: { mainOrderId: unknown }) => { + mainIdSet.add(item.mainOrderId); + }); + + let mainIds = Array.from(mainIdSet).join(','); + + let newListAnnex = []; + + //回显,子订单可以编辑备注跟附件 + if (isEdit) { + newListAnnex = subOrders.afterAnnexList?.map((path) => { + let i = 0; + return { + uid: i++, + name: getAliYunOSSFileNameFromUrl(path), + status: 'uploaded', + url: path, + response: { data: [path] }, + }; + }); + subOrders.filePaths = newListAnnex; + } + + const [form] = Form.useForm<{ + applyInvoicingNotes: string; + filePaths: any; + subIds: any[]; + afterInvoicingUpdate: boolean; + receivingCompany: string; + isUrgent: boolean; + deadline: string; + }>(); + + useEffect(() => { + //显示拼接的主订单id + form.setFieldValue('applyInvoicingNotes', mainIds); + }, []); + + return ( + <ModalForm<{ + applyInvoicingNotes: string; + filePaths: any; + subIds: any[]; + afterInvoicingUpdate: boolean; + }> + width={500} + open + title={isEdit ? '修改信息' : '申请开票'} + initialValues={subOrders} + form={form} + autoFocusFirstInput + modalProps={{ + okText: '确认', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setCheckVisible(false); + }, + }} + submitter={{ + render: (props, defaultDoms) => { + return defaultDoms; + }, + }} + submitTimeout={2000} + onFinish={async (values) => { + values.subIds = ids; + //附件处理 + values.filePaths = values.filePaths?.map((item) => { + return { url: item.response.data[0] }; + }); + + if (isEdit) { + values.afterInvoicingUpdate = true; + } else { + values.afterInvoicingUpdate = false; + } + + const res = await postServiceOrderApplyInvoicing({ data: values }); + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onOpenChange={setCheckVisible} + > + {isMainOrder ? ( + <div className="mb-[24px]"> + <span>选中子订单金额之和:</span> + <span className="text-red-500">{sumPrice}¥</span> + </div> + ) : ( + '' + )} + + <div className="mb-1"> + 如果需要合并订单,请将需要合并的订单id写在备注中,id之间用英文逗号隔开。 + </div> + <ProFormTextArea + width="lg" + name="applyInvoicingNotes" + key="applyInvoicingNotes" + placeholder="请输入备注" + onMetaChange={(val) => { + console.log(val); + }} + proFieldProps={{ + onchange: () => { + message.info('change'); + }, + }} + /> + <ProFormText + width="lg" + name="purchaser" + label="抬头名称" + key="purchaser" + placeholder="请输入抬头名称" + rules={[{ required: true, message: '抬头名称必填' }]} + /> + <ProFormSelect + placeholder="选择收款单位" + name="receivingCompany" + width="lg" + key="receivingCompany" + label={ + <div> + <span>开票收款单位</span> + <span className="pl-2 text-xs text-gray-400"> + 财务开票将依据这个字段,选择对应的公司开票(若对[收款单位]没有要求,请任意选择一个) + </span> + </div> + } + options={enumToSelect(PAYEE_OPTIONS)} + rules={[{ required: true, message: '开票收款单位必填' }]} + /> + <ProFormSelect + placeholder="选择是否加急" + name="isUrgent" + width="lg" + key="isUrgent" + label="是否加急" + options={[ + { label: '是', value: 'true' }, + { label: '否', value: 'false' }, + ]} + rules={[{ required: true, message: '是否加急必填' }]} + onChange={(val: any) => { + setIsUrgent(val); + }} + /> + + {/* <ProFormDatePicker + key="deadline" + label="期望开票时间" + name="deadline" + rules={[{ required: isUrgent === 'true', message: '期望开票时间必填' }]} + hidden={isUrgent !== 'true'} + /> */} + + <ProFormTextArea + key="invoicingUrgentCause" + label="加急开票原因" + name="invoicingUrgentCause" + rules={[{ required: isUrgent === 'true', message: '加急开票原因' }]} + hidden={isUrgent !== 'true'} + /> + + <ProFormUploadDragger + key="2" + label={ + <div> + <span>开票明细确认表</span> + <span className="pl-2 text-xs text-gray-400"> + 如果开票信息有变更,如开票内容跟下单内容不一致、下单抬头和付款抬头不一致,请上传开票明细确认表。 + </span> + </div> + } + name="filePaths" + action="/api/service/order/fileProcess" + fieldProps={{ + headers: { Authorization: localStorage.getItem('token') }, + }} + /> + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/AttachmentModal.tsx b/src/pages/Order/OrderList/AttachmentModal.tsx new file mode 100644 index 0000000..018a8b5 --- /dev/null +++ b/src/pages/Order/OrderList/AttachmentModal.tsx @@ -0,0 +1,162 @@ +import { getAliYunOSSFileNameFromUrl, isImageName } from '@/utils'; +import { ModalForm } from '@ant-design/pro-components'; +import { Button, Card, Divider, Empty, Form, Image, List, message } from 'antd'; +import Base64 from 'base-64'; +import { cloneDeep } from 'lodash'; +import React, { useEffect, useState } from 'react'; + +export default ({ data, onClose }) => { + let newData = cloneDeep(data); + const [fileList, setFileList] = useState<[]>([]); + console.log(fileList); + const [form] = Form.useForm<{ + subOrderId: ''; + listAnnex: []; + }>(); + + let newListAnnex = newData.listAnnex?.map((path) => { + let i = 0; + return { + uid: i++, + name: getAliYunOSSFileNameFromUrl(path), + status: 'uploaded', + url: path, + response: { data: [path] }, + }; + }); + newData.listAnnex = newListAnnex; + + //将图片和其他文件区分开 + let images: any[] = []; + let otherAnnex: any[] = []; + newListAnnex.forEach((item: any) => { + if (isImageName(item.name)) { + images.push(item); + } else { + otherAnnex.push(item); + } + }); + + useEffect(() => { + setFileList(newData.listAnnex); + }, []); + + return ( + <ModalForm + width={800} + open + title="查看附件" + initialValues={newData} + form={form} + modalProps={{ + onCancel: onClose, + }} + submitter={{ + render: () => { + return [ + <Button + key="back" + onClick={() => { + onClose(); + }} + > + 返回 + </Button>, + ]; + }, + }} + > + {newListAnnex?.length <= 0 ? ( + <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> + ) : ( + // <ProFormUploadDragger + // name="listAnnex" + // action="/api/service/order/fileProcess" + // disabled + // fieldProps={{ + // headers: { Authorization: localStorage.getItem('token') }, + // // onRemove: (file) => { + // // const index = fileList[listMeta.index].indexOf(file); + // // console.log(index); + // // const newFileList = fileList.slice(); + // // newFileList.splice(index, 1); + // // setFileList(newFileList); + // // }, + // // beforeUpload: (file) => { + // // fileList[listMeta.index] = [...fileList[listMeta.index], file as RcFile]; + // // setFileList(fileList); + // // return true; + // // }, + // fileList, + // // defaultFileList: itemFileList + // }} + // /> + <> + <Card> + <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}> + <Image + className="max-h-[200px] max-w-[200px]" + src={item.url} + title={item.name} + />{' '} + <Divider type="vertical" /> + </React.Fragment> + ))} + </Image.PreviewGroup> + </Card> + <Divider /> + + <div> + <List + size="small" + header={<div>其他类型文件</div>} + bordered + dataSource={otherAnnex} + renderItem={(item) => ( + <List.Item + actions={[ + <Button + type="link" + key="key" + href={item.url} + target="blank" + className="py-1" + > + 下载 + </Button>, + <Button + type="link" + key="key" + className="py-1" + onClick={() => { + message.info(item.url); + window.open( + '/previewApi/onlinePreview?url=' + + encodeURIComponent(Base64.encode(item.url)), + ); + }} + > + 预览 + </Button>, + ]} + > + <div> + <span>{item.name}</span> + </div> + </List.Item> + )} + /> + </div> + </> + )} + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/BaseModal.tsx b/src/pages/Order/OrderList/BaseModal.tsx new file mode 100644 index 0000000..104826f --- /dev/null +++ b/src/pages/Order/OrderList/BaseModal.tsx @@ -0,0 +1,35 @@ +import { ModalForm } from '@ant-design/pro-components'; +import { Form } from 'antd'; + +// import { cloneDeep } from 'lodash'; +export default ({ setVisible, onClose }) => { + const [form] = Form.useForm<{ name: string; company: string }>(); + + return ( + <> + <ModalForm<{ + name: string; + company: string; + }> + width={500} + open + title="标题" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '通过', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + onFinish={async (values) => { + console.log(values); + onClose(); + }} + onOpenChange={setVisible} + ></ModalForm> + </> + ); +}; diff --git a/src/pages/Order/OrderList/CheckModal.tsx b/src/pages/Order/OrderList/CheckModal.tsx new file mode 100644 index 0000000..7f09ff4 --- /dev/null +++ b/src/pages/Order/OrderList/CheckModal.tsx @@ -0,0 +1,768 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postPrepaidAudit, + postServiceOrderAfterSalesCheck, + postServiceOrderAudit, + postServiceOrderFileProcess, + postServiceOrderFinanceCheckOrder, + postServiceOrderLeaderAudit, + postServiceOrderToProcureAudit, +} from '@/services'; +import { + ModalForm, + ProFormText, + ProFormTextArea, + ProList, +} from '@ant-design/pro-components'; +import { + Button, + Col, + Divider, + Form, + Image, + Modal, + Row, + Space, + Tag, + UploadFile, + message, +} from 'antd'; +import Upload, { RcFile, UploadProps } from 'antd/es/upload'; +import { useEffect, useRef, useState } from 'react'; +import { + AFTE_SALES_PLAN_OPTIONS, + CHECK_TYPE, + COMFIR_RECEIPT_IMAGES_NUMBER, +} from '../constant'; +// import { cloneDeep } from 'lodash'; +import InvoiceSubOrderInfoTable from '@/pages/Order/Order/components/InvoiceSubOrderInfoTable'; +import { enumValueToLabel, transImageFile } from '@/utils'; +import { PlusOutlined } from '@ant-design/icons'; +import { cloneDeep } from 'lodash'; + +export default ({ + setCheckVisible, + data, + subOrders, + orderCheckType, + openOrderDrawer, + onClose, +}) => { + const [previewOpen, setPreviewOpen] = useState(false); + const [aPopoverTitle, setAPopoverTitle] = useState('审核'); + const [previewImage, setPreviewImage] = useState(''); + const [previewTitle, setPreviewTitle] = useState(''); + const [paymentReceiptsImages, setPymentReceiptsImages] = useState<any[]>([]); + const fileListObj = useRef<UploadFile[]>([]); //使用引用类型,使得在useEffect里面设置监听事件后,不用更新监听事件也能保持obj与外界一致 + const getBase64 = (file: RcFile): Promise<string> => + new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result as string); + reader.onerror = (error) => reject(error); + }); + const [fileList, setFileList] = useState<UploadFile[]>([]); + const handleCancel = () => setPreviewOpen(false); + const [messageApi, contextHolder] = message.useMessage(); + const [form] = Form.useForm<{ name: string; company: string }>(); + let subOrderIds: any[] = subOrders?.map((subOrder) => subOrder.id); + const [mainOrderId] = useState(data.id); + + const [afterSalesInfo, setAfterSalesInfo] = useState<any>(); + const [prepaidProofImages, setPrepaidProofImages] = useState<any[]>([]); + /** + * 审核类型 + */ + function checkType(check: string) { + if (orderCheckType === check) { + return true; + } + return false; + } + + const getOrderAfterSalesInfo = async () => { + // let res = await postServiceOrderQueryAfterSalesInfoSnapshot({ + // data: { subOrderIds: subOrderIds }, + // }); + + //附件 + let annex = subOrders[0].afterSalesAnnexList; + let index = 1; + let annexLinks = annex?.map((f) => { + return ( + <Button className="p-0 pr-1" type="link" key="key" href={f}> + {'附件' + index++} + </Button> + ); + }); + + console.log(annexLinks); + + setAfterSalesInfo( + <div className="my-5"> + <Row gutter={[16, 24]}> + <Col span={6}> + <span className="text-[#333333]">售后方案</span> + </Col> + <Col span={18}> + {enumValueToLabel( + subOrders[0]?.afterSalesPlan, + AFTE_SALES_PLAN_OPTIONS, + )} + </Col> + <Col span={6}> + <span className="className='text-[#333333]'">售后原因</span> + </Col> + <Col span={18}>{subOrders[0]?.afterSalesNotes}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">附件</span> + </Col> + <Col span={18}>{annexLinks}</Col> + </Row> + </div>, + ); + }; + + useEffect(() => { + if (checkType(CHECK_TYPE.CONFIRM_DELIVER)) { + setAPopoverTitle('确认发货'); + } + getOrderAfterSalesInfo(); + + let paymentReceiptsImagesList: any[] = []; + subOrders?.forEach((item: any) => { + if (item.paymentReceiptAnnexList) { + paymentReceiptsImagesList.push(...item.paymentReceiptAnnexList); + } + }); + //去重 + paymentReceiptsImagesList = [...new Set(paymentReceiptsImagesList)]; + setPymentReceiptsImages(paymentReceiptsImagesList); + + //预存审核的凭证 + let proofImages: any[] = []; + subOrders?.forEach((item) => { + let images = item.proofImages; + if (images !== null && images !== undefined) { + proofImages.push(...images); + } + }); + setPrepaidProofImages(proofImages); + }, []); + + const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { + //fileListObj得在change里变化,change的参数是已经处理过的file数组 + //beforeUpload中的参数file是未处理过,还需要Base64拿到文件数据处理 + fileListObj.current = newFileList; + setFileList(newFileList); + }; + + /** 粘贴快捷键的回调 */ + const onPaste = async (e: any) => { + /** 获取剪切板的数据clipboardData */ + let clipboardData = e.clipboardData, + i = 0, + items, + item, + types; + + /** 为空判断 */ + if (clipboardData) { + items = clipboardData.items; + if (!items) { + message.info('您的剪贴板中没有照片'); + return; + } + + item = items[0]; + types = clipboardData.types || []; + /** 遍历剪切板的数据 */ + for (; i < types.length; i++) { + if (types[i] === 'Files') { + item = items[i]; + break; + } + } + + /** 判断文件是否为图片 */ + if (item && item.kind === 'file' && item.type.match(/^image\//i)) { + const imgItem = item.getAsFile(); + const newFileList = cloneDeep(fileListObj.current); + let filteredArray = newFileList.filter( + (obj) => obj.status !== 'removed', + ); //过滤掉状态为已删除的照片 + const listItem = { + ...imgItem, + status: 'done', + url: await getBase64(imgItem), + originFileObj: imgItem, + }; + + if (filteredArray.length >= COMFIR_RECEIPT_IMAGES_NUMBER) { + message.info('发货照片数量不能超过3'); + return; + } + fileListObj.current = filteredArray; + filteredArray.push(listItem); + setFileList(filteredArray); + return; + } + } + + message.info('您的剪贴板中没有照片'); + }; + useEffect(() => { + //回显售后信息 + // if (checkType(CHECK_TYPE.AFTER_SALES)) { + // getOrderAfterSalesInfo(); + // } + + document.addEventListener('paste', onPaste); + return () => { + document.removeEventListener('paste', onPaste); + }; + }, []); + const uploadButton = ( + <div> + <PlusOutlined /> + <div style={{ marginTop: 8 }}>上传凭证</div> + </div> + ); + const handlePreview = async (file: UploadFile) => { + if (!file.url && !file.preview) { + file.preview = await getBase64(file.originFileObj as RcFile); + } + setPreviewImage(file.url || (file.preview as string)); + setPreviewOpen(true); + setPreviewTitle( + file.name || + file.originFileObj?.name || + file.url!.substring(file.url!.lastIndexOf('/') + 1), + ); + }; + + const handleBeforeUpload = (file: any) => { + setFileList([...fileList, file]); + return false; + }; + + const props: UploadProps = { + onRemove: (file) => { + const index = fileList.indexOf(file); + const newFileList = fileList.slice(); + newFileList.splice(index, 1); + setFileList(newFileList); + }, + beforeUpload: handleBeforeUpload, + listType: 'picture-card', + onPreview: handlePreview, + fileList, + onChange: handleChange, + accept: 'image/png, image/jpeg, image/png', + // action: '/api/service/order/fileProcess', + name: 'files', + headers: { Authorization: localStorage.getItem('token') }, + }; + + //仓库审核 + async function doCheck(body: object) { + const data = await postServiceOrderAudit({ + data: body, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + } + + /** + * + * @param body 财务审核 + */ + async function doFinancailCheck(values: any, isAgree: boolean) { + if (fileList.length <= 0) { + message.error('凭证不能为空'); + return; + } + messageApi.open({ + type: 'loading', + content: '正在上传图片...', + duration: 0, + }); + //附件处理 + let formData = new FormData(); + //附件处理 + for (let file of fileList) { + if (file.originFileObj) { + formData.append('files', file.originFileObj as RcFile); + } else { + //有url的话取url(源文件),没url取thumbUrl。有url的时候thumbUrl是略缩图 + if (file?.url === undefined || file?.url === null) { + formData.append( + 'files', + transImageFile(file?.thumbUrl), + file?.originFileObj?.name, + ); + } else { + formData.append( + 'files', + transImageFile(file?.url), + file?.originFileObj?.name, + ); + } + } + } + let res = await postServiceOrderFileProcess({ + data: formData, + }); + messageApi.destroy(); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success('上传成功!'); + + let fileUrls = res?.data?.map((item) => { + return { url: item }; + }); + //财务审核 + const data = await postServiceOrderFinanceCheckOrder({ + data: { + ...values, + checkNotes: values.name, + ids: subOrderIds, + checkPassOrReject: isAgree, + invoicingCheckAnnex: fileUrls, + }, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + } else { + message.success('上传失败'); + } + } + + /** + * + * @param body 售后审核 + */ + async function doAfterSalesCheck(body: object) { + const data = await postServiceOrderAfterSalesCheck({ + data: body, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + } + + /** + * + * @param body 领导审核 + */ + async function doLeaderCheck(body: object) { + const data = await postServiceOrderLeaderAudit({ + data: body, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + } + + /** + * 预存审核 + * @param body + */ + async function doPrepaidAudit(body: any) { + const data = await postPrepaidAudit({ + data: body, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + } + + function computeType() { + let type: string = ''; + if (checkType(CHECK_TYPE.CONFIRM_DELIVER)) { + type = 'confirm_deliver'; + } + if (checkType(CHECK_TYPE.WEARHOUSE_KEEPER)) { + type = 'warehouse_audit'; + } + if (checkType(CHECK_TYPE.WAITING_FOR_POST_AUDIT)) { + type = 'post_audit'; + } + if (checkType(CHECK_TYPE.NODE_OPERATING_AUDIT)) { + type = 'node_operating_audit'; + } + if (checkType(CHECK_TYPE.MODIFY_LEADER_AUDIT)) { + type = 'modify_leader_audit'; + } + if (checkType(CHECK_TYPE.URGENT_INVOICE_AUDITING)) { + type = 'urgent_invoice_audit'; + } + if (checkType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT)) { + type = 'payment_receipt_audit'; + } + if (checkType(CHECK_TYPE.CONFIRM_REISSUE)) { + type = 'confirm_reissue'; + } + if (checkType(CHECK_TYPE.CREDIT_AUDIT)) { + type = 'credit_audit'; + } + if (checkType(CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD)) { + type = 'urgent_invoice_audit_old'; + } + if (checkType(CHECK_TYPE.CONFIRM_REISSUE_OLD)) { + type = 'confirm_reissue_old'; + } + return type; + } + + return ( + <> + <ModalForm<{ + name: string; + company: string; + }> + width={500} + open + title={aPopoverTitle} + form={form} + autoFocusFirstInput + modalProps={{ + okText: '通过', + cancelText: '驳回', + destroyOnClose: true, + onCancel: () => { + setCheckVisible(false); + }, + }} + submitter={{ + render: (props, defaultDoms) => { + let myDoms = []; + if (!checkType(CHECK_TYPE.CONFIRM_DELIVER)) { + myDoms.push( + <Button + key="驳回" + onClick={async () => { + if (checkType(CHECK_TYPE.AFTER_SALES)) { + doAfterSalesCheck({ + applyType: 'after-sales', + isAfterSalesSuccess: false, + subOrderIds: subOrderIds, + mainId: mainOrderId, + afterSalesRejectionNotes: form.getFieldValue('name'), + }); + return; + } + + if (checkType(CHECK_TYPE.FINALCIAL)) { + let values = { name: form.getFieldValue('name') }; + doFinancailCheck(values, false); + return; + } + + if (checkType(CHECK_TYPE.LEADER_AUDIT)) { + doLeaderCheck({ + pass: false, + subOrderIds: subOrderIds, + reason: form.getFieldValue('name'), + }); + return; + } + + if (checkType(CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT)) { + doAfterSalesCheck({ + applyType: 'order-change-normal', + isAfterSalesSuccess: false, + subOrderIds: subOrderIds, + mainId: mainOrderId, + afterSalesRejectionNotes: form.getFieldValue('name'), + }); + return; + } + + //预存审核,先暂时共用同一个审核弹窗 + if (checkType(CHECK_TYPE.PREPAID_AUDIT)) { + return doPrepaidAudit({ + pass: false, + ids: subOrderIds, + auditNotes: form.getFieldValue('name'), + }); + } + + let type = ''; + type = computeType(); + console.log('type:' + type); + doCheck({ + pass: false, + subOrderIds: subOrderIds, + type: type, + notes: form.getFieldValue('name'), + }); + }} + > + 驳回 + </Button>, + ); + } + + //如果是仓库审核,那么显示这个外部采购 + if (checkType(CHECK_TYPE.WEARHOUSE_KEEPER)) { + myDoms.push( + <Button + key="外部采购" + onClick={async () => { + let res = await postServiceOrderToProcureAudit({ + data: { + subOrderIds: subOrderIds, + }, + }); + + if (res && res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + > + 外部采购 + </Button>, + ); + } + + //确认 + myDoms.push(defaultDoms[1]); + return myDoms; + }, + }} + submitTimeout={2000} + onFinish={async (values) => { + if (checkType(CHECK_TYPE.AFTER_SALES)) { + //审核通过 + return doAfterSalesCheck({ + applyType: 'after-sales', + isAfterSalesSuccess: true, + subOrderIds: subOrderIds, + mainId: mainOrderId, + afterSalesRejectionNotes: values.name, + }); + } + console.log('h'); + if (checkType(CHECK_TYPE.FINALCIAL)) { + doFinancailCheck(values, true); + return; + } + + if (checkType(CHECK_TYPE.LEADER_AUDIT)) { + doLeaderCheck({ + pass: true, + subOrderIds: subOrderIds, + reason: values.name, + }); + return; + } + + if (checkType(CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT)) { + //审核通过 + return doAfterSalesCheck({ + applyType: 'order-change-normal', + isAfterSalesSuccess: true, + subOrderIds: subOrderIds, + mainId: mainOrderId, + afterSalesRejectionNotes: values.name, + }); + } + + //预存审核,先暂时共用同一个审核弹窗 + if (checkType(CHECK_TYPE.PREPAID_AUDIT)) { + return doPrepaidAudit({ + pass: true, + ids: subOrderIds, + auditNotes: form.getFieldValue('name'), + }); + } + + let type = ''; + type = computeType(); + doCheck({ + ...values, + pass: true, + subOrderIds: subOrderIds, + type: type, + notes: form.getFieldValue('name'), + }); + }} + onOpenChange={setCheckVisible} + > + {checkType(CHECK_TYPE.AFTER_SALES) ? ( + <> + {afterSalesInfo} + <Button + className="px-0" + type="link" + onClick={() => { + console.log(data); + openOrderDrawer('after-sales-check', mainOrderId); + }} + > + 查看旧订单 + </Button> + </> + ) : ( + '' + )} + + {checkType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT) ? ( + <> + <Divider orientation="center"> + <span className="text-sm">回款凭证</span> + </Divider> + <Image.PreviewGroup + className="mr-10" + preview={{ + onChange: (current, prev) => + console.log(`current index: ${current}, prev index: ${prev}`), + }} + > + {paymentReceiptsImages.map((url) => ( + <> + <Image width={120} src={url} /> <Divider type="vertical" /> + </> + ))} + </Image.PreviewGroup> + <Divider></Divider> + </> + ) : ( + '' + )} + + {checkType(CHECK_TYPE.PREPAID_AUDIT) && ( + <> + <Divider orientation="center"> + <span className="text-sm">凭证</span> + </Divider> + <Image.PreviewGroup + className="mr-10" + preview={{ + onChange: (current, prev) => + console.log(`current index: ${current}, prev index: ${prev}`), + }} + > + {prepaidProofImages.map((url) => ( + <> + <Image width={120} src={url} /> <Divider type="vertical" /> + </> + ))} + </Image.PreviewGroup> + <Divider></Divider> + </> + )} + + {checkType('prepaidAudit') ? ( + <div>请特别注意手机号码和充值金额。</div> + ) : ( + <div>请特别注意订单总金额与订单金额。</div> + )} + {!checkType(CHECK_TYPE.CONFIRM_DELIVER) ? ( + <ProFormTextArea + width="lg" + name="name" + placeholder="若驳回,请填写驳回理由" + /> + ) : ( + <></> + )} + {checkType(CHECK_TYPE.FINALCIAL) ? ( + <> + <ProFormText + width="md" + name="bankStatementSerialNumbersText" + label="流水号" + rules={[ + { + required: true, + message: '请输入流水号!', + }, + ]} + placeholder={'多个流水号用逗号隔开'} + /> + <div className="pb-4 text-xs decoration-gray-50"> + 可复制照片粘贴 + </div> + <Upload {...props}> + {fileList.length < COMFIR_RECEIPT_IMAGES_NUMBER + ? uploadButton + : ''} + </Upload> + </> + ) : ( + '' + )} + {checkType(CHECK_TYPE.CONFIRM_REISSUE) && ( + <> + <InvoiceSubOrderInfoTable + subOrderIds={subOrderIds} + ></InvoiceSubOrderInfoTable> + </> + )} + {checkType(CHECK_TYPE.URGENT_INVOICE_AUDITING) ? ( + <> + <ProList + rowKey="id" + headerTitle="发票信息" + metas={{ + title: { + dataIndex: 'name', + }, + avatar: { + dataIndex: 'image', + editable: false, + }, + description: { + dataIndex: 'desc', + }, + subTitle: { + render: () => { + return ( + <Space size={0}> + <Tag color="blue">Ant Design</Tag> + <Tag color="#5BD8A6">TechUI</Tag> + </Space> + ); + }, + }, + actions: { + render: (text, row, index, action) => [ + <a + onClick={() => { + action?.startEditable(row.id); + }} + key="link" + > + 编辑 + </a>, + ], + }, + }} + ></ProList> + </> + ) : ( + '' + )} + </ModalForm> + + <Modal + open={previewOpen} + title={previewTitle} + footer={null} + onCancel={handleCancel} + > + <img alt="图片预览" style={{ width: '100%' }} src={previewImage} /> + </Modal> + {contextHolder} + </> + ); +}; diff --git a/src/pages/Order/OrderList/ConfirmReceiptModal.tsx b/src/pages/Order/OrderList/ConfirmReceiptModal.tsx new file mode 100644 index 0000000..8053dd0 --- /dev/null +++ b/src/pages/Order/OrderList/ConfirmReceiptModal.tsx @@ -0,0 +1,200 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderConfirmReceipt } from '@/services'; +import { PlusOutlined } from '@ant-design/icons'; +import { Button, Modal, Upload, message } from 'antd'; +import { RcFile, UploadFile, UploadProps } from 'antd/es/upload'; +import { cloneDeep } from 'lodash'; +import { useEffect, useRef, useState } from 'react'; +import { COMFIR_RECEIPT_IMAGES_NUMBER } from '../constant'; +export default ({ data, onClose }) => { + const subIds = data?.map((item) => { + return item.id; + }); + // const [form] = Form.useForm<{ name: string; company: string }>(); + const [previewOpen, setPreviewOpen] = useState(false); + const [previewImage, setPreviewImage] = useState(''); + const [previewTitle, setPreviewTitle] = useState(''); + const fileListObj = useRef<UploadFile[]>([]); //使用引用类型,使得在useEffect里面设置监听事件后,不用更新监听事件也能保持obj与外界一致 + const getBase64 = (file: RcFile): Promise<string> => + new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result as string); + reader.onerror = (error) => reject(error); + }); + const [fileList, setFileList] = useState<UploadFile[]>([]); + const [uploading, setUploading] = useState(false); + const handleCancel = () => setPreviewOpen(false); + + const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { + //fileListObj得在change里变化,change的参数是已经处理过的file数组 + //beforeUpload中的参数file是未处理过,还需要Base64拿到文件数据处理 + fileListObj.current = newFileList; + setFileList(newFileList); + }; + + /** 粘贴快捷键的回调 */ + const onPaste = async (e: any) => { + /** 获取剪切板的数据clipboardData */ + let clipboardData = e.clipboardData, + i = 0, + items, + item, + types; + + /** 为空判断 */ + if (clipboardData) { + items = clipboardData.items; + if (!items) { + message.info('您的剪贴板中没有照片'); + return; + } + + item = items[0]; + types = clipboardData.types || []; + /** 遍历剪切板的数据 */ + for (; i < types.length; i++) { + if (types[i] === 'Files') { + item = items[i]; + break; + } + } + + /** 判断文件是否为图片 */ + if (item && item.kind === 'file' && item.type.match(/^image\//i)) { + const imgItem = item.getAsFile(); + const newFileList = cloneDeep(fileListObj.current); + let filteredArray = newFileList.filter( + (obj) => obj.status !== 'removed', + ); //过滤掉状态为已删除的照片 + const listItem = { + ...imgItem, + status: 'done', + url: await getBase64(imgItem), + originFileObj: imgItem, + }; + + if (filteredArray.length >= COMFIR_RECEIPT_IMAGES_NUMBER) { + message.info('发货凭证照片数量不能超过3'); + return; + } + fileListObj.current = filteredArray; + filteredArray.push(listItem); + setFileList(filteredArray); + return; + } + } + + message.info('您的剪贴板中没有照片'); + }; + useEffect(() => { + document.addEventListener('paste', onPaste); + return () => { + document.removeEventListener('paste', onPaste); + }; + }, []); + const uploadButton = ( + <div> + <PlusOutlined /> + <div style={{ marginTop: 8 }}>上传凭证</div> + </div> + ); + const handlePreview = async (file: UploadFile) => { + if (!file.url && !file.preview) { + file.preview = await getBase64(file.originFileObj as RcFile); + } + setPreviewImage(file.url || (file.preview as string)); + setPreviewOpen(true); + setPreviewTitle( + file.name || + file.originFileObj?.name || + file.url!.substring(file.url!.lastIndexOf('/') + 1), + ); + }; + + const handleUpload = async () => { + const formData = new FormData(); + fileList.forEach((file) => { + //originFileObj二进制文件 + formData.append('files', file.originFileObj as RcFile); + }); + // console.log(fileList[0] as RcFile) + // formData.append('file', fileList[0] as RcFile); + formData.append('subIds', subIds); + setUploading(true); + // You can use any AJAX library you like + const res = await postServiceOrderConfirmReceipt({ + data: formData, + headers: { + 'Content-Type': + 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', + }, + }); + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + + setUploading(false); + }; + + const props: UploadProps = { + onRemove: (file) => { + const index = fileList.indexOf(file); + const newFileList = fileList.slice(); + newFileList.splice(index, 1); + setFileList(newFileList); + }, + beforeUpload: (file) => { + setFileList([...fileList, file]); + return false; + }, + listType: 'picture-card', + onPreview: handlePreview, + fileList, + onChange: handleChange, + accept: 'image/png, image/jpeg, image/png', + }; + + return ( + <> + <Modal + width={500} + open + title="确认收货" + footer={[ + <Button key="cancel" onClick={onClose}> + 取消 + </Button>, + <Button + type="primary" + key="ok" + onClick={handleUpload} + disabled={fileList.length === 0} + loading={uploading} + > + {uploading ? '上传中' : '提交'} + </Button>, + ]} + onCancel={async () => { + onClose(); + }} + > + <div className="pt-4 font-semibold">请将买家确认收货的凭证照片上传</div> + <div className="pb-4 text-xs decoration-gray-50">可复制照片粘贴</div> + <Upload {...props}> + {fileList.length < COMFIR_RECEIPT_IMAGES_NUMBER ? uploadButton : ''} + </Upload> + </Modal> + <Modal + open={previewOpen} + title={previewTitle} + footer={null} + onCancel={handleCancel} + > + <img alt="图片预览" style={{ width: '100%' }} src={previewImage} /> + </Modal> + </> + ); +}; diff --git a/src/pages/Order/OrderList/DeliverInfoDrawer.tsx b/src/pages/Order/OrderList/DeliverInfoDrawer.tsx new file mode 100644 index 0000000..d1b05c4 --- /dev/null +++ b/src/pages/Order/OrderList/DeliverInfoDrawer.tsx @@ -0,0 +1,98 @@ +import { postDistrictSelOrderProvince } from '@/services'; +import { enumValueToLabel } from '@/utils'; +import { getReceivingCompanyOptions } from '@/utils/order'; +import { Col, Drawer, Row } from 'antd'; +import { useEffect, useState } from 'react'; +import { PAYEE_OPTIONS } from '../constant'; + +export default ({ data, onClose }) => { + const [province, setProvince] = useState(''); + const [city, setCity] = useState(''); + const [district, setDistrict] = useState(''); + + useEffect(() => { + const fetchData = async () => { + if (data.id !== undefined) { + const resp = await postDistrictSelOrderProvince({ + data: data.id, + }); + if (resp && resp.data) { + if (resp.data.province) { + setProvince(resp.data.province); + } + if (resp.data.city) { + setCity(resp.data.city); + } + if (resp.data.district) { + setDistrict(resp.data.district); + } + } + } + }; + + fetchData(); + }, [data.id]); + return ( + <> + <Drawer + width={500} + title="基本信息" + placement="right" + onClose={onClose} + open + > + <Row gutter={[16, 24]}> + <Col span={6}> + <span className="text-[#333333]">收货人</span> + </Col> + <Col span={18}>{data.customerName}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">联系方式</span> + </Col> + <Col span={18}>{data.customerContactNumber}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">省市区</span> + </Col> + <Col span={18}> + {province} {city} {district} + </Col> + <Col span={6}> + <span className="className='text-[#333333]'">收货地址</span> + </Col> + <Col span={18}>{data.customerShippingAddress}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">课题组老师</span> + </Col> + <Col span={18}>{data.institutionContactName}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">单位名称</span> + </Col> + <Col span={18}>{data.institution}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">开户银行</span> + </Col> + <Col span={18}>{data.bank}</Col> + + <Col span={6}> + <span className="className='text-[#333333]'">开票收款单位</span> + </Col> + <Col span={18}> + {enumValueToLabel( + data.receivingCompany, + getReceivingCompanyOptions(PAYEE_OPTIONS), + )} + </Col> + + <Col span={6}> + <span className="className='text-[#333333]'">银行账号</span> + </Col> + <Col span={18}>{data.bankAccountNumber}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">开票识别号</span> + </Col> + <Col span={18}>{data.invoiceIdentificationNumber}</Col> + </Row> + </Drawer> + </> + ); +}; diff --git a/src/pages/Order/OrderList/DeliverModal.tsx b/src/pages/Order/OrderList/DeliverModal.tsx new file mode 100644 index 0000000..87aaf9a --- /dev/null +++ b/src/pages/Order/OrderList/DeliverModal.tsx @@ -0,0 +1,373 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postServiceOrderProcureSend, + postServiceOrderSendProduct, + postServiceOrderSupplierSendOrder, +} from '@/services'; +import { enumToSelect } from '@/utils'; +import { + ProColumns, + ProForm, + ProFormSelect, + ProFormText, + ProTable, +} from '@ant-design/pro-components'; +import { + Button, + Col, + Flex, + Input, + InputNumber, + Modal, + Row, + Select, + message, +} from 'antd'; +import { cloneDeep } from 'lodash'; +import { useEffect, useRef, useState } from 'react'; +import { CHECK_TYPE, LOGISTICS_STATUS_OPTIONS } from '../constant'; + +const DeliverModal = ({ + data: propsData, + isSendProduct, + setVisible, + sendType, + onClose, +}) => { + const [data, setData] = useState(propsData || {}); + const form = useRef(); + + /** + * 是供应商发货还是普通发货 + * @param typeString + * @returns + */ + function optType(typeString: string) { + if (sendType === typeString) { + return true; + } + + return false; + } + + useEffect(() => { + setData(propsData); + }, [propsData]); + + const handleChange = (key: string, index: number, obj: any) => { + const newData = cloneDeep(data); + if (typeof obj !== 'object') { + newData[index][key] = obj; + } else { + newData[index][key] = obj.target?.value; + } + setData(newData); + }; + const columns: ProColumns<any>[] = [ + { + title: 'ID', + dataIndex: 'id', + width: 120, + render: (_, record) => <Input value={record.id} disabled />, + }, + { + title: '商品编号', + dataIndex: 'productCode', + width: 120, + render: (_, record) => <Input value={record.productCode} disabled />, + }, + { + title: '商品名称', + dataIndex: 'productName', + width: 120, + render: (_, record) => <Input value={record.productName} disabled />, + }, + { + title: '商品参数', + dataIndex: 'parameters', + width: 80, + render: (_, record) => <Input value={record.parameters} disabled />, + }, + { + title: '商品数量', + dataIndex: 'status', + render: (_, record) => <InputNumber value={record.quantity} disabled />, + }, + { + title: '包裹数量', + dataIndex: 'packageNumber', + render: (_, record, index) => ( + <InputNumber + min={1} + value={record.packageNumber} + defaultValue={1} + onChange={(value) => handleChange('packageNumber', index, value)} + /> + ), + }, + { + title: '物流方式', + key: 'logisticsMethod', + render: (_, record, index) => ( + <Select + style={{ minWidth: 150 }} + placeholder="请输入物流方式" + value={record.logisticsMethod} + options={enumToSelect(LOGISTICS_STATUS_OPTIONS)} + onChange={(value) => { + handleChange('logisticsMethod', index, value); //修改时更改record数据 + if (value === 'OTHER_LOGISTICS') { + message.info( + '您选择的是[其他物流方式],请将该物流方式写在备注中', + ); + } + }} + /> + ), + }, + { + title: '物流单号', + key: 'serialNumber', + render: (_, record, index) => ( + <Input + placeholder="请输入物流单号" + value={record.serialNumber} + onChange={(value) => { + handleChange('serialNumber', index, value); + }} + /> + ), + }, + { + title: '物流备注', + dataIndex: 'packageNumber', + render: (_, record, index) => ( + <Input.TextArea + value={record.logisticsNotes} + onChange={(value) => handleChange('logisticsNotes', index, value)} + /> + ), + }, + ]; + + return ( + <Modal + open + width={1000} + title={isSendProduct ? '发货' : '修改发货信息'} + onOk={async () => { + //请求体封装 + let list = data.map((item) => { + return { + id: item.id, + logisticsMethod: item.logisticsMethod, + serialNumber: item.serialNumber, + packageNumber: + item.packageNumber === null || item.packageNumber === undefined + ? 1 + : item.packageNumber, + logisticsNotes: item.logisticsNotes, + }; + }); + + for (let item of list) { + let method = item.logisticsMethod; + let notes = item.logisticsNotes; + if ( + method === 'OTHER_LOGISTICS' && + (notes === '' || notes === undefined) + ) { + message.error( + '请检查:物流方式为[其他物流方式]的记录中,物流备注不能为空!请将实际的物流方式填写在备注中!', + ); + return; + } + } + let body = { id: data[0].mainOrderId, list: list, flag: false }; + if (isSendProduct) { + body.flag = true; + } + //发货请求 + let res; + if (optType(CHECK_TYPE.SUPPLIER)) { + res = await postServiceOrderSupplierSendOrder({ data: body }); + } else if (optType(CHECK_TYPE.PROCURE)) { + res = await postServiceOrderProcureSend({ data: body }); + } else { + res = await postServiceOrderSendProduct({ data: body }); + } + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onCancel={() => { + setVisible(false); + }} + footer={[ + <Button + key="back" + onClick={() => { + setVisible(false); + }} + > + 取消 + </Button>, + <Button + key="selfDeliver" + type="primary" + onClick={async () => { + //请求体封装 + let list = data.map((item) => { + return { + id: item.id, + deliverType: 'SELF_DELIVER', + }; + }); + + let body = { id: data[0].mainOrderId, list: list, flag: false }; + if (isSendProduct) { + body.flag = true; + } + //发货请求 + let res; + if (optType(CHECK_TYPE.SUPPLIER)) { + res = await postServiceOrderSupplierSendOrder({ data: body }); + } else if (optType(CHECK_TYPE.PROCURE)) { + res = await postServiceOrderProcureSend({ data: body }); + } else { + res = await postServiceOrderSendProduct({ data: body }); + } + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + > + 自行派送 + </Button>, + <Button + key="submit" + type="primary" + onClick={async () => { + //请求体封装 + let list = data.map((item) => { + return { + id: item.id, + logisticsMethod: item.logisticsMethod, + serialNumber: item.serialNumber, + packageNumber: + item.packageNumber === null || + item.packageNumber === undefined + ? 1 + : item.packageNumber, + logisticsNotes: item.logisticsNotes, + }; + }); + + for (let item of list) { + let method = item.logisticsMethod; + let notes = item.logisticsNotes; + if ( + method === 'OTHER_LOGISTICS' && + (notes === '' || notes === undefined) + ) { + message.error( + '请检查:物流方式为[其他物流方式]的记录中,物流备注不能为空!请将实际的物流方式填写在备注中!', + ); + return; + } + } + let body = { id: data[0].mainOrderId, list: list, flag: false }; + if (isSendProduct) { + body.flag = true; + } + //发货请求 + let res; + if (optType(CHECK_TYPE.SUPPLIER)) { + res = await postServiceOrderSupplierSendOrder({ data: body }); + } else if (optType(CHECK_TYPE.PROCURE)) { + res = await postServiceOrderProcureSend({ data: body }); + } else { + res = await postServiceOrderSendProduct({ data: body }); + } + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + > + 确认 + </Button>, + ]} + > + <Flex vertical> + <strong>将物流方式和物流单号更新到下方所有订单</strong> + <span className="text-[red] py-1"> + 选择【其他物流方式】时,需要将对应的物流方式填写在备注中。例如:如果发圆通快递,系统上没有这个选项,就需要选【其他物流方式】,然后把“圆通快递”填在备注上。 + </span> + </Flex> + + <ProForm + layout="inline" + submitter={false} + className="mb-8" + formRef={form} + > + <Row gutter={[0, 6]}> + <Col> + <ProFormSelect + placeholder="请输入物流方式" + name="logisticsMethod" + width="sm" + label="物流方式" + options={enumToSelect(LOGISTICS_STATUS_OPTIONS)} + /> + <ProFormText name="logisticsNotes" label="物流备注"></ProFormText> + </Col> + <Col> + <ProFormText name="serialNumber" label="物流单号"></ProFormText> + </Col> + </Row> + + <Button + type="primary" + onClick={() => { + const values = form.current.getFieldsValue(); + if (values.logisticsMethod === 'OTHER_LOGISTICS') { + message.info( + '自动填充成功!您选择的是其他物流方式,请将物流方式写在物流备注中!', + ); + } + let newData = cloneDeep(data); + newData = newData.map((item) => ({ + ...item, + logisticsMethod: values.logisticsMethod, + serialNumber: values.serialNumber, + logisticsNotes: values.logisticsNotes, + })); + setData(newData); + }} + > + 批量更新 + </Button> + </ProForm> + <ProTable<any> + className="px-0" + dataSource={data} + rowKey="id" + pagination={false} + columns={columns} + search={false} + dateFormatter="string" + options={false} + scroll={{ x: 1400 }} + /> + </Modal> + ); +}; + +export default DeliverModal; diff --git a/src/pages/Order/OrderList/FeedbackRegistrationModal.tsx b/src/pages/Order/OrderList/FeedbackRegistrationModal.tsx new file mode 100644 index 0000000..c16cb78 --- /dev/null +++ b/src/pages/Order/OrderList/FeedbackRegistrationModal.tsx @@ -0,0 +1,72 @@ +import { postServiceOrderFeedbackRegistration } from '@/services/request'; +import { Input, Modal } from 'antd'; +import { useState } from 'react'; + +// import { cloneDeep } from 'lodash'; +export default ({ setVisible, subOrders, mainOrder, onClose }) => { + const [isModalOpen] = useState(true); + const { TextArea } = Input; + const [textValue, setTextValue] = useState(''); + + const handleOk = async () => { + console.log(subOrders, '5656subOrders', mainOrder); + await postServiceOrderFeedbackRegistration({ + data: { + id: subOrders[0].id, + feedbackRegistrationContent: textValue, + }, + }); + onClose(); + // setIsModalOpen(false); + // onClose(); + }; + const handleCancel = () => { + setVisible(false); + onClose(); + // setIsModalOpen(false); + // onClose(); + }; + const handleChange = (e) => { + setTextValue(e.target.value); + }; + return ( + <> + {/* <ModalForm<{ + filePaths: any; + }> + width={500} + open + title="回访登记" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '提交', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + onFinish={async () => { + onClose(); + }} + onOpenChange={setVisible} + > + <TextArea rows={6} placeholder="请输入" /> + </ModalForm> */} + <Modal + title="回访登记" + open={isModalOpen} + onOk={handleOk} + onCancel={handleCancel} + > + <TextArea + rows={6} + placeholder="请输入" + onChange={handleChange} + value={textValue} + /> + </Modal> + </> + ); +}; diff --git a/src/pages/Order/OrderList/FinancialDrawer.tsx b/src/pages/Order/OrderList/FinancialDrawer.tsx new file mode 100644 index 0000000..faa6f36 --- /dev/null +++ b/src/pages/Order/OrderList/FinancialDrawer.tsx @@ -0,0 +1,275 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postServiceOrderEditOrder, + postServiceOrderInvoicing, +} from '@/services'; +import { FloatAdd, enumToSelect, enumValueToLabel } from '@/utils'; +import { getReceivingCompanyOptions } from '@/utils/order'; +import { + DrawerForm, + ProFormDatePicker, + ProFormDigit, + ProFormSelect, + ProFormText, + ProFormTextArea, +} from '@ant-design/pro-components'; +import { Button, Form, message } from 'antd'; +import { useEffect, useState } from 'react'; +import { INVOCING_STATUS_OPTIONS_OLD, PAYEE_OPTIONS } from '../constant'; + +export default ({ + mainOrder, + subOrders, + isEdit, + isMainOrder, + cancel, + onClose, +}) => { + const [invoicingStatus, setInvoicingStatus] = useState(''); + const subIds = subOrders.map((item) => item.id); + useEffect(() => { + // 在组件挂载或数据变化时,更新组件状态 + if (mainOrder) { + setInvoicingStatus(subOrders[0]?.invoicingStatus); + } + }, [mainOrder]); + useEffect(() => { + console.log(JSON.stringify(subOrders)); + }, []); + + const [form] = Form.useForm<{ name: string; company: string }>(); + + /** + * 自动选择收款公司 + * @param receivingCompany + */ + function chooseReceivingCompany(receivingCompany: any) { + form.setFieldValue('payee', receivingCompany); + } + + /** + * 计算选中子订单的主订单金额之和 + */ + function computeTotalPayment() { + let distinctMap = new Map(); + + subOrders?.forEach((item: any) => { + distinctMap.set(item.mainOrderId, item.totalPayment); + }); + + let sum = 0; + for (let p of distinctMap.values()) { + sum = FloatAdd(p, sum); + } + + form.setFieldValue('money', sum); + } + + return ( + <DrawerForm<{ + name: string; + company: string; + }> + open + title="财务信息" + resize={{ + onResize() { + console.log('resize!'); + }, + maxWidth: window.innerWidth * 0.8, + minWidth: 400, + }} + initialValues={mainOrder} + form={form} + autoFocusFirstInput + drawerProps={{ + destroyOnClose: true, + }} + submitTimeout={2000} + onFinish={async (values) => { + let res; + let body = values; + body.subIds = subIds; + if (isEdit) { + res = await postServiceOrderEditOrder({ data: body }); + } else { + res = await postServiceOrderInvoicing({ data: body }); + } + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onOpenChange={(val) => { + return !val && cancel(); + }} + > + {isMainOrder ? ( + <ProFormSelect + placeholder="选择是否需要开票" + name="invoicingStatus" + width="lg" + label="是否需要开票" + options={enumToSelect(INVOCING_STATUS_OPTIONS_OLD)} + onChange={setInvoicingStatus} + initialValue={subOrders[0]?.invoicingStatus} + // disabled={mainInfoDisbled} + rules={[{ required: true, message: '是否需要开票必填' }]} + /> + ) : ( + '' + )} + + <ProFormTextArea + width="lg" + name="invoiceIdentificationNumber" + label="开票信息" + placeholder="请输入开票信息" + disabled + /> + <ProFormText + width="lg" + name="bank" + label="开户银行" + placeholder="请输入开户银行" + disabled + /> + <ProFormText + width="lg" + name="bankAccountNumber" + label="开户银行账号" + placeholder="请输入开户银行账号" + disabled + /> + + {invoicingStatus !== 'UN_INVOICE' + ? [ + <ProFormDatePicker + key="invoicingTime" + width="lg" + name="invoicingTime" + label="开票时间" + disabled={isEdit} + rules={[ + { required: !isEdit ? true : false, message: '这是必填项' }, + ]} + initialValue={subOrders[0]?.invoicingTime} + />, + <ProFormText + key="purchaser" + width="lg" + name="purchaser" + label="抬头名称" + disabled={isEdit} + rules={[ + { required: !isEdit ? true : false, message: '这是必填项' }, + ]} + initialValue={subOrders[0]?.purchaser} + />, + <ProFormDatePicker + key="financialReceiptIssuanceTime" + width="lg" + name="financialReceiptIssuanceTime" + label="开收据时间" + initialValue={subOrders[0]?.financialReceiptIssuanceTime} + />, + <ProFormDatePicker + key="collectMoneyTime" + width="lg" + name="collectMoneyTime" + label="收款时间" + initialValue={subOrders[0]?.collectMoneyTime} + />, + <ProFormText + width="lg" + key="invoiceNumber" + name="invoiceNumber" + label="发票号码" + initialValue={subOrders[0]?.invoiceNumber} + rules={[{ required: true, message: '发票号码必填' }]} + />, + <div + key="salesChooseReceivingCompany" + hidden={subOrders[0].receivingCompany === null} + > + <span className={'pl-2 text-xs text-gray-400'}> + 销售申请开票时选择了: + {enumValueToLabel( + subOrders[0].receivingCompany, + getReceivingCompanyOptions(PAYEE_OPTIONS), + )} + </span> + <span + hidden={subOrders[0].receivingCompany === 'ANY'} + className={ + 'pl-2 text-xs text-[#1677ff] cursor-pointer hover:text-[#64abf7]' + } + onClick={() => { + chooseReceivingCompany(subOrders[0].receivingCompany); + }} + > + 选择 + </span> + </div>, + <ProFormSelect + key="payee" + placeholder="选择收款单位" + name="payee" + width="lg" + showSearch + label="收款单位" + options={enumToSelect(PAYEE_OPTIONS)} + initialValue={subOrders[0]?.payee} + rules={[{ required: true, message: '收款单位必填' }]} + />, + + <div id="total-payment" key="money"> + <ProFormDigit + key="money" + name="money" + width="lg" + label="金额" + rules={[{ required: true, message: '金额必填' }]} + tooltip="点击计算,合计所有子订单对应主订单总额" + fieldProps={{ + addonAfter: ( + <Button + className="rounded-l-none" + type="primary" + onClick={computeTotalPayment} + > + 计算 + </Button> + ), + }} + /> + </div>, + ] + : ''} + + <ProFormSelect + placeholder="是否完全开票" + name="afterInvoicingStatus" + width="lg" + label="是否完全开票" + options={[ + { label: '完全开票', value: 'COMPLETE_INVOICING' }, + { label: '部分开票', value: 'PARTIAL_INVOICING' }, + ]} + // disabled={mainInfoDisbled} + initialValue={ + subOrders[0]?.afterInvoicingStatus === 'APPLY_FOR_INVOICING' + ? 'COMPLETE_INVOICING' + : subOrders[0]?.afterInvoicingStatus + } + rules={[{ required: true, message: '是否完全开票必填' }]} + /> + <ProFormTextArea + width="lg" + name="invoicingNotes" + label="备注" + initialValue={subOrders[0]?.invoicingNotes} + /> + </DrawerForm> + ); +}; diff --git a/src/pages/Order/OrderList/FinancialEditDrawer.tsx b/src/pages/Order/OrderList/FinancialEditDrawer.tsx new file mode 100644 index 0000000..8408638 --- /dev/null +++ b/src/pages/Order/OrderList/FinancialEditDrawer.tsx @@ -0,0 +1,154 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderNoNeedInvoicingEdit } from '@/services'; +import { enumToSelect } from '@/utils'; +import { + DrawerForm, + ProFormDatePicker, + ProFormSelect, + ProFormText, +} from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +import { useEffect, useState } from 'react'; +import { INVOCING_STATUS_OPTIONS_OLD } from '../constant'; + +export default ({ mainOrder, subOrders, setVisible, isMainOrder, onClose }) => { + const [invoicingStatus, setInvoicingStatus] = useState(''); + useEffect(() => { + setInvoicingStatus(subOrders[0]?.invoicingStatus); + }, []); + const subOrderIds = subOrders?.map((subOrder) => { + return subOrder?.id; + }); + const mainOrderId = mainOrder.id; + const [form] = Form.useForm<{ + collectMoneyTime: string; + subIds: []; + financialReceiptIssuanceTime: string; + }>(); + + //回显开收据时间和收款时间 + if (!isMainOrder) { + form.setFieldValue('collectMoneyTime', subOrders[0].collectMoneyTime); + form.setFieldValue( + 'financialReceiptIssuanceTime', + subOrders[0].financialReceiptIssuanceTime, + ); + } + + return ( + <DrawerForm<{ + collectMoneyTime: string; + financialReceiptIssuanceTime: string; + subIds: []; + }> + open + title={isMainOrder ? '编辑开票信息' : '编辑收款时间'} + resize={{ + onResize() { + console.log('resize!'); + }, + maxWidth: window.innerWidth * 0.8, + minWidth: 400, + }} + initialValues={mainOrder} + form={form} + autoFocusFirstInput + drawerProps={{ + destroyOnClose: true, + }} + submitTimeout={2000} + onFinish={async (values) => { + let body = { + ...values, + mainOrderId: mainOrderId, + subIds: subOrderIds, + }; + + if (!isMainOrder) { + body.invoicingStatus = 'UN_INVOICE'; + } + + let res = await postServiceOrderNoNeedInvoicingEdit({ + data: body, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onOpenChange={(val) => { + return !val && setVisible(val); + }} + > + {isMainOrder ? ( + <ProFormSelect + placeholder="选择是否需要开票" + name="invoicingStatus" + width="lg" + label="是否需要开票" + options={enumToSelect(INVOCING_STATUS_OPTIONS_OLD)} + onChange={setInvoicingStatus} + initialValue={subOrders[0]?.invoicingStatus} + // disabled={mainInfoDisbled} + rules={[{ required: true, message: '是否需要开票必填' }]} + /> + ) : ( + '' + )} + + {invoicingStatus !== 'UN_INVOICE' ? ( + <> + <ProFormText + key="invoiceIdentificationNumber" + width="lg" + name="invoiceIdentificationNumber" + label="开票信息" + placeholder="请输入开票信息" + rules={[{ required: true, message: '开票信息必填' }]} + /> + <ProFormText + key="bank" + width="lg" + name="bank" + label="开户银行" + placeholder="请输入开户银行" + /> + <ProFormText + key="bankAccountNumber" + width="lg" + name="bankAccountNumber" + label="开户银行账号" + placeholder="请输入开户银行账号" + /> + </> + ) : ( + '' + )} + + <ProFormDatePicker + key="financialReceiptIssuanceTime" + width="lg" + name="financialReceiptIssuanceTime" + label="开收据时间" + // rules={[ + // { + // required: !isMainOrder && invoicingStatus === 'UN_INVOICE', + // message: '开收据时间必填', + // }, + // ]} + /> + <ProFormDatePicker + key="collectMoneyTime" + width="lg" + name="collectMoneyTime" + label="收款时间" + // rules={[ + // { + // required: !isMainOrder && invoicingStatus === 'UN_INVOICE', + // message: '收款时间必填', + // }, + // ]} + /> + </DrawerForm> + ); +}; diff --git a/src/pages/Order/OrderList/FinancialMergeDrawer.tsx b/src/pages/Order/OrderList/FinancialMergeDrawer.tsx new file mode 100644 index 0000000..8ee91bd --- /dev/null +++ b/src/pages/Order/OrderList/FinancialMergeDrawer.tsx @@ -0,0 +1,150 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { enumToSelect } from '@/utils'; +import { + DrawerForm, + ProFormDatePicker, + ProFormDigit, + ProFormSelect, + ProFormText, + ProFormTextArea, +} from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +import { PAYEE_OPTIONS } from '../constant'; + +export default ({ dataList, setVisible, onClose }) => { + // let subOrderIds = dataList?.map((item) => { + // return item.id; + // }); + let firstMainOrder = dataList[0]; + let bank = firstMainOrder?.bank; + let bankAccountNumber = firstMainOrder?.bankAccountNumber; + let invoiceIdentificationNumber = firstMainOrder?.invoiceIdentificationNumber; + + const [form] = Form.useForm<{ + invoicingTime: string; + financialReceiptIssuanceTime: string; + invoicingNotes: string; + afterInvoicingStatus: string; + collectMoneyTime: string; + }>(); + return ( + <DrawerForm + open + title="合并开票" + resize={{ + onResize() { + console.log('resize!'); + }, + maxWidth: window.innerWidth * 0.8, + minWidth: 400, + }} + form={form} + autoFocusFirstInput + drawerProps={{ + destroyOnClose: true, + }} + submitTimeout={2000} + onFinish={async (values) => { + console.log(values); + let res; + let body = values; + body.subIds = subIds; + body.mainOrderId = mainOrder.id; + body.mainorderOrSubOrderInvoicing = isMainOrder; + if (isEdit) { + res = await postServiceOrderEditOrder({ data: body }); + } else { + res = await postServiceOrderInvoicing({ data: body }); + } + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onOpenChange={(val) => { + return !val && setVisible(); + }} + > + <ProFormText + width="lg" + name="invoiceIdentificationNumber" + label="开票信息" + placeholder="请输入开票信息" + initialValue={invoiceIdentificationNumber} + disabled + /> + <ProFormText + width="lg" + name="bank" + label="开户银行" + placeholder="请输入开户银行" + initialValue={bank} + disabled + /> + <ProFormText + width="lg" + name="bankAccountNumber" + label="开户银行账号" + placeholder="请输入开户银行账号" + initialValue={bankAccountNumber} + disabled + /> + + <ProFormDatePicker + key="invoicingTime" + width="lg" + name="invoicingTime" + label="开票时间" + rules={[{ required: true, message: '这是必填项' }]} + /> + <ProFormDatePicker + key="financialReceiptIssuanceTime" + width="lg" + name="financialReceiptIssuanceTime" + label="开收据时间" + /> + <ProFormDatePicker + key="collectMoneyTime" + width="lg" + name="collectMoneyTime" + label="收款时间" + /> + <ProFormText + width="lg" + key="invoiceNumber" + name="invoiceNumber" + label="发票号码" + rules={[{ required: true, message: '发票号码必填' }]} + /> + <ProFormSelect + key="payee" + placeholder="选择收款单位" + name="payee" + width="lg" + label="收款单位" + options={enumToSelect(PAYEE_OPTIONS)} + rules={[{ required: true, message: '收款单位必填' }]} + /> + + <ProFormDigit + key="money" + name="money" + width="lg" + label="金额" + rules={[{ required: true, message: '金额必填' }]} + /> + <ProFormSelect + placeholder="是否完全开票" + name="afterInvoicingStatus" + width="lg" + label="是否完全开票" + options={[ + { label: '完全开票', value: 'COMPLETE_INVOICING' }, + { label: '部分开票', value: 'PARTIAL_INVOICING' }, + ]} + initialValue={'COMPLETE_INVOICING'} + /> + <ProFormTextArea width="lg" name="invoicingNotes" label="备注" /> + </DrawerForm> + ); +}; diff --git a/src/pages/Order/OrderList/FinancialReceiptsModal.tsx b/src/pages/Order/OrderList/FinancialReceiptsModal.tsx new file mode 100644 index 0000000..e593212 --- /dev/null +++ b/src/pages/Order/OrderList/FinancialReceiptsModal.tsx @@ -0,0 +1,270 @@ +import { postServiceOrderUpdateHirePurchase } from '@/services'; +import { + EditableProTable, + ModalForm, + ProColumns, + ProForm, +} from '@ant-design/pro-components'; +import { Form } from 'antd'; +import { useState } from 'react'; + +// import { cloneDeep } from 'lodash'; +export default ({ setVisible, datas, onClose }) => { + const [form] = Form.useForm<{ name: string; company: string }>(); + type DataSourceType = { + id: React.Key; + hirePurchaseMethod?: string; + hirePurchaseMethodName?: string; + money?: number; + updateTime?: string; + notes?: string; + }; + const defaultData: DataSourceType[] = [ + { + id: 1, + hirePurchaseMethod: 'ADVANCE_CHARGE', + hirePurchaseMethodName: '预付款', + money: undefined, + updateTime: undefined, + notes: undefined, + }, + { + id: 2, + hirePurchaseMethod: 'PAYMENT_FOR_SHIPMENT', + hirePurchaseMethodName: '发货款', + money: undefined, + updateTime: undefined, + notes: undefined, + }, + { + id: 3, + hirePurchaseMethod: 'ACCEPTANCE_PAYMENT', + hirePurchaseMethodName: '验收款', + money: undefined, + updateTime: undefined, + notes: undefined, + }, + { + id: 4, + hirePurchaseMethod: 'BALANCE_PAYMENT', + hirePurchaseMethodName: '尾款', + money: undefined, + updateTime: undefined, + notes: undefined, + }, + ]; + const [editableKeys, setEditableRowKeys] = useState<React.Key[]>(() => + // defaultData.map((item) => item.id), + [1, 2, 3, 4], + ); + const columns: ProColumns<DataSourceType>[] = [ + { + title: '款项', + dataIndex: 'hirePurchaseMethodName', + editable: false, + width: '10%', + }, + { + title: '已收金额', + dataIndex: 'money', + valueType: 'digit', + width: '15%', + }, + { + title: '收款时间', + dataIndex: 'updateTime', + valueType: 'dateTime', + width: '25%', + }, + { + title: '备注', + dataIndex: 'receiptsNotes', + }, + ]; + return ( + <> + <ModalForm<{ + name: string; + company: string; + }> + width={1100} + open + title="收款记录" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '保存', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + onFinish={async (values) => { + let res = await postServiceOrderUpdateHirePurchase({ + data: { + mainOrderId: datas[0].id, + list: values.dataSource, + }, + }); + console.log(res); + onClose(); + }} + onOpenChange={setVisible} + > + <ProForm.Item + label="" + name="dataSource" + initialValue={defaultData} + trigger="onValuesChange" + > + <EditableProTable<DataSourceType> + rowKey="id" + toolBarRender={false} + columns={columns} + recordCreatorProps={{ + newRecordType: 'dataSource', + position: 'top', + record: () => ({ + id: Date.now(), + addonBefore: 'ccccccc', + decs: 'testdesc', + }), + style: { + display: 'none', + }, + }} + editable={{ + type: 'multiple', + editableKeys, + onChange: setEditableRowKeys, + actionRender: (row, _, dom) => { + return [dom.delete]; + }, + }} + /> + </ProForm.Item> + + {/* <ProForm.Group> + <ProFormText + width="sm" + name="name1" + label="款项" + tooltip="最长为 24 位" + initialValue={"预付款"} + disabled + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="company" + label="收款时间" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="price" + label="收款金额" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="notes" + label="备注" + placeholder="请输入名称" + /> + </ProForm.Group> + + <ProForm.Group> + <ProFormText + width="sm" + name="name2" + initialValue={"发货款"} + disabled + tooltip="最长为 24 位" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="company" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="price" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="notes" + placeholder="请输入名称" + /> + </ProForm.Group> + + <ProForm.Group> + <ProFormText + width="sm" + name="name3" + initialValue={"验收款"} + disabled + tooltip="最长为 24 位" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="company" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="price" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="notes" + placeholder="请输入名称" + /> + </ProForm.Group> + + <ProForm.Group> + <ProFormText + width="sm" + name="name4" + disabled + initialValue={"尾款"} + tooltip="最长为 24 位" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="company" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="price" + placeholder="请输入名称" + /> + + <ProFormText + width="sm" + name="notes" + placeholder="请输入名称" + /> + </ProForm.Group> */} + </ModalForm> + </> + ); +}; diff --git a/src/pages/Order/OrderList/HistoryModal.tsx b/src/pages/Order/OrderList/HistoryModal.tsx new file mode 100644 index 0000000..1c0a57a --- /dev/null +++ b/src/pages/Order/OrderList/HistoryModal.tsx @@ -0,0 +1,158 @@ +import { postServiceOrderQueryHistoryOrderRecord } from '@/services'; +import { formatDateTime } from '@/utils'; +import { Button, Col, Empty, Flex, Modal, Row, Spin } from 'antd'; +import { useEffect, useState } from 'react'; + +export default ({ subOrders, isCancelledOrder, onClose }) => { + let subOrderIds = subOrders?.map((subOrder: any) => { + return subOrder.id; + }); + + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + let i = 0; + + const handleOk = () => { + onClose(); + }; + + /** + * 获取历史记录 + */ + const getHistory = async () => { + let res = await postServiceOrderQueryHistoryOrderRecord({ + data: { ids: subOrderIds, isDeleteQueryOrder: isCancelledOrder }, + }); + setData(res.data); + setLoading(false); + }; + + const getRecord = (history: any) => { + let record = []; + record.push( + <span className="pr-2 text-[#5E5E5E]"> + {formatDateTime(history.createTime)} + </span>, + ); + + record.push(<span className="text-[#3b83e5]">{history.createByName}</span>); + + record.push(<span>进行了</span>); + + // let label = enumValueToLabel(history.status, ORDER_STATUS_OPTIONS); + + // if ( + // history.record !== 'INVOICING' && history.record !== 'order-change-normal' && history.record !== 'order-change-normal-CHECK' && + // history.record?.indexOf(':') === -1 && + // label !== undefined && + // label !== '' + // ) { + // record.push( + // <> + // <span>,订单状态为:</span> + // <span className="text-[#3b83e5]">{label}</span> + // </>, + // ); + // } + + if (history.record?.indexOf(':') !== -1) { + let values = history.record?.split(':'); + let type = values[0]; + let target = values[1]; + if (target === 'null') { + target = '未指定'; + } + //采购转发 + if (type === 'PROCURE_CONVERT_PROCURE') { + record.push( + <> + <span>采购转发,{history.createByName}将订单转发给了</span> + <span className="text-[#3b83e5]">{target}</span> + </>, + ); + } + } else { + record.push( + <span className="text-[#3b83e5]"> + {history.recordText + + (history.record === 'INVOICING' + ? '(开票号码:' + history.invoiceNumber + ')' + : '')} + </span>, + ); + } + + if (history.notes !== null) { + record.push(<span className="pl-1">{'备注:' + history.notes}</span>); + } + + if (history.description !== null) { + record.push( + <span className="pl-1">{'描述:' + history.description}</span>, + ); + } + + return record; + }; + + useEffect(() => { + getHistory(); + }, []); + + const handleCancel = () => { + onClose(); + }; + + return ( + <> + <Modal + title="订单历史记录" + open + width={650} + onOk={handleOk} + onCancel={handleCancel} + footer={() => ( + <> + <Button onClick={handleCancel}>返回</Button> + </> + )} + > + <Spin tip="加载中" spinning={loading}> + <Row className="max-h-[500px] overflow-auto" gutter={[0, 14]}> + {data.map((item) => { + return ( + <Col span={24} key={i}> + <Flex vertical> + <div> + <span className="py-2 text-[#5E5E5E]"> + {'商品' + ++i} + </span> + <span className="text-[#8C8C8C]"> + -【{item.productName}】 + </span> + </div> + + <Flex vertical> + {item.historySubOrderRecordDto?.map((history) => { + return ( + <div className="py-1" key={history.id}> + {getRecord(history)} + </div> + ); + })} + </Flex> + </Flex> + </Col> + ); + })} + </Row> + {data?.length <= 0 ? ( + <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> + ) : ( + '' + )} + </Spin> + </Modal> + </> + ); +}; diff --git a/src/pages/Order/OrderList/ImagesViewerModal.tsx b/src/pages/Order/OrderList/ImagesViewerModal.tsx new file mode 100644 index 0000000..6151ed4 --- /dev/null +++ b/src/pages/Order/OrderList/ImagesViewerModal.tsx @@ -0,0 +1,68 @@ +import { postServiceOrderViewImages } from '@/services'; +import { Button, Divider, Image, Modal } from 'antd'; +import { useEffect, useState } from 'react'; +export default ({ setVisible, optType, onClose, orderRow }) => { + const [images, setImages] = useState<any[]>([]); + const [title, setTitle] = useState('收货凭证'); + const handleOk = () => { + onClose(); + setVisible(false); + }; + + const handleCancel = () => { + onClose(); + setVisible(false); + }; + + async function getImages() { + const res = await postServiceOrderViewImages({ + data: { subId: orderRow.id }, + }); + const images = res.data; + setImages(images); + } + useEffect(() => { + if (optType === 'shippingReceipt') { + setTitle('收货凭证'); + getImages(); + } else if (optType === 'paymentReceipt') { + let paymentReceiptsImagesList: any[] = []; + if (orderRow.paymentReceiptAnnexList) { + paymentReceiptsImagesList.push(...orderRow.paymentReceiptAnnexList); + } + //去重 + paymentReceiptsImagesList = [...new Set(paymentReceiptsImagesList)]; + setImages(paymentReceiptsImagesList); + } + }, []); + + return ( + <> + <Modal + title={title} + open + onOk={handleOk} + onCancel={handleCancel} + footer={[ + <Button key="back" onClick={handleCancel}> + 返回 + </Button>, + ]} + > + <Image.PreviewGroup + className="mr-10" + preview={{ + onChange: (current, prev) => + console.log(`current index: ${current}, prev index: ${prev}`), + }} + > + {images.map((url) => ( + <> + <Image width={120} src={url} /> <Divider type="vertical" /> + </> + ))} + </Image.PreviewGroup> + </Modal> + </> + ); +}; diff --git a/src/pages/Order/OrderList/ImportExpressBillModal copy.tsx b/src/pages/Order/OrderList/ImportExpressBillModal copy.tsx new file mode 100644 index 0000000..c126eb9 --- /dev/null +++ b/src/pages/Order/OrderList/ImportExpressBillModal copy.tsx @@ -0,0 +1,50 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postOrderImportImportWeightAndVolume } from '@/services'; +import { ModalForm, ProFormUploadDragger } from '@ant-design/pro-components'; +import { Button, Form, message } from 'antd'; + +export default () => { + const [form] = Form.useForm(); + const [messageApi, contextHolder] = message.useMessage(); + return ( + <> + <ModalForm + title="导入重量、体积" + trigger={<Button type="primary">导入重量、体积</Button>} + form={form} + autoFocusFirstInput + modalProps={{ + destroyOnClose: true, + }} + submitTimeout={2000} + onFinish={async (values) => { + console.log(values); + const formData = new FormData(); + formData.append('file', values.express[0].originFileObj); + messageApi.open({ + type: 'loading', + content: '正在导入...', + duration: 0, + }); + const res = await postOrderImportImportWeightAndVolume({ + data: formData, + headers: { + 'Content-Type': + 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', + }, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.error('导入成功'); + } else { + message.error('导入失败'); + } + messageApi.destroy(); + return true; + }} + > + <ProFormUploadDragger max={1} label="上传快递单" name="express" /> + </ModalForm> + {contextHolder} + </> + ); +}; diff --git a/src/pages/Order/OrderList/ImportExpressBillModal.tsx b/src/pages/Order/OrderList/ImportExpressBillModal.tsx new file mode 100644 index 0000000..c126eb9 --- /dev/null +++ b/src/pages/Order/OrderList/ImportExpressBillModal.tsx @@ -0,0 +1,50 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postOrderImportImportWeightAndVolume } from '@/services'; +import { ModalForm, ProFormUploadDragger } from '@ant-design/pro-components'; +import { Button, Form, message } from 'antd'; + +export default () => { + const [form] = Form.useForm(); + const [messageApi, contextHolder] = message.useMessage(); + return ( + <> + <ModalForm + title="导入重量、体积" + trigger={<Button type="primary">导入重量、体积</Button>} + form={form} + autoFocusFirstInput + modalProps={{ + destroyOnClose: true, + }} + submitTimeout={2000} + onFinish={async (values) => { + console.log(values); + const formData = new FormData(); + formData.append('file', values.express[0].originFileObj); + messageApi.open({ + type: 'loading', + content: '正在导入...', + duration: 0, + }); + const res = await postOrderImportImportWeightAndVolume({ + data: formData, + headers: { + 'Content-Type': + 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', + }, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.error('导入成功'); + } else { + message.error('导入失败'); + } + messageApi.destroy(); + return true; + }} + > + <ProFormUploadDragger max={1} label="上传快递单" name="express" /> + </ModalForm> + {contextHolder} + </> + ); +}; diff --git a/src/pages/Order/OrderList/ImportModal.tsx b/src/pages/Order/OrderList/ImportModal.tsx new file mode 100644 index 0000000..b2ee452 --- /dev/null +++ b/src/pages/Order/OrderList/ImportModal.tsx @@ -0,0 +1,134 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderImportExcel } from '@/services'; +import { downloadFile } from '@/services/order'; +import { UploadOutlined } from '@ant-design/icons'; +import { Button, Modal, Upload, message } from 'antd'; +import { RcFile, UploadFile, UploadProps } from 'antd/es/upload'; +import { useState } from 'react'; +export default ({ onClose }) => { + // const [form] = Form.useForm<{ name: string; company: string }>(); + const [messageApi, contextHolder] = message.useMessage(); + const [fileList, setFileList] = useState<UploadFile[]>([]); + const [uploading, setUploading] = useState(false); + const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => + setFileList(newFileList); + + const exportLoading = (content: string) => { + messageApi.open({ + type: 'loading', + content: content, + duration: 0, + }); + }; + + const exportLoadingDestory = () => { + messageApi.destroy(); + }; + const downloadTemplate = async () => { + exportLoading('正在下载模板...'); + downloadFile( + '/api/service/order/exportTemplate', + '订单.xlsx', + 'post', + {}, + exportLoadingDestory, + ); + }; + + const handleUpload = async () => { + const formData = new FormData(); + fileList.forEach((file) => { + //originFileObj二进制文件 + formData.append('file', file.originFileObj as RcFile); + }); + // console.log(fileList[0] as RcFile) + // formData.append('file', fileList[0] as RcFile); + setUploading(true); + // You can use any AJAX library you like + const res = await postServiceOrderImportExcel({ + data: formData, + headers: { + 'Content-Type': + 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', + }, + }); + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } else { + if (res.message === '表格中没有数据') { + setUploading(false); + return; + } + //存在错误信息,下载错误信息模板 + exportLoading('正在下载错误信息...'); + downloadFile( + '/api/service/order/errorExcelInformation', + '订单.xlsx', + 'post', + formData, + exportLoadingDestory, + ); + } + + setUploading(false); + }; + + const props: UploadProps = { + onRemove: (file) => { + const index = fileList.indexOf(file); + const newFileList = fileList.slice(); + newFileList.splice(index, 1); + setFileList(newFileList); + }, + beforeUpload: (file) => { + setFileList([...fileList, file]); + + return false; + }, + fileList, + onChange: handleChange, + accept: '.xlsx', + }; + + return ( + <> + <Modal + width={500} + open + title="批量发货" + footer={[ + <Button key="cancel" onClick={onClose}> + 取消 + </Button>, + <Button + type="primary" + key="ok" + onClick={handleUpload} + disabled={fileList.length === 0} + loading={uploading} + > + {uploading ? '上传中' : '提交'} + </Button>, + ]} + onCancel={async () => { + onClose(); + }} + > + <div className="py-4 font-semibold"> + 导入发货信息 + <Button type="link" onClick={downloadTemplate}> + 下载模板 + </Button> + </div> + <Upload {...props}> + <Button icon={<UploadOutlined />} disabled={fileList.length > 0}> + 点击选择文件 + </Button> + </Upload> + </Modal> + {contextHolder} + </> + ); +}; diff --git a/src/pages/Order/OrderList/InvoiceSubOrderInfoTable.tsx b/src/pages/Order/OrderList/InvoiceSubOrderInfoTable.tsx new file mode 100644 index 0000000..cd8950e --- /dev/null +++ b/src/pages/Order/OrderList/InvoiceSubOrderInfoTable.tsx @@ -0,0 +1,70 @@ +import { postServiceOrderGetReissueInfo } from '@/services'; +import type { ProColumns } from '@ant-design/pro-components'; +import { ProTable } from '@ant-design/pro-components'; +import { Button, Divider } from 'antd'; +import { useEffect, useState } from 'react'; + +const columns: ProColumns[] = [ + { + title: '发票号码', + width: 80, + dataIndex: 'invoiceNumber', + render: (_) => _, + }, + { + title: '关联订单', + dataIndex: 'subOrderIds', + render: (_, { subOrderIds }) => { + console.log(JSON.stringify(_)); + console.log(JSON.stringify(subOrderIds)); + return ( + <> + {subOrderIds.map((subOrderId, index) => { + return ( + <> + <Button + key={index} + className="pl-1 pr-0" + type="link" + target="_blank" + href={'/order/order?id=' + subOrderId} + > + {subOrderId} + </Button> + <Divider type="vertical" /> + </> + ); + })} + </> + ); + }, + }, +]; + +export default ({ subOrderIds }) => { + const [reissueInfos, setReissueInfos] = useState([]); + useEffect(() => { + console.log('info'); + const getReissueInfo = async () => { + let res = await postServiceOrderGetReissueInfo({ + data: subOrderIds, + }); + setReissueInfos(res.data); + }; + getReissueInfo(); + }, []); + return ( + <ProTable + dataSource={reissueInfos} + rowKey="key" + pagination={false} + size={'small'} + //设置左右下边距为0 + options={false} + columns={columns} + search={false} + dateFormatter="string" + headerTitle="发票信息" + /> + ); +}; diff --git a/src/pages/Order/OrderList/InvoicingDrawerForm.tsx b/src/pages/Order/OrderList/InvoicingDrawerForm.tsx new file mode 100644 index 0000000..fc53a97 --- /dev/null +++ b/src/pages/Order/OrderList/InvoicingDrawerForm.tsx @@ -0,0 +1,611 @@ +// import { PlusOutlined } from '@ant-design/icons'; +import InvoiceModal from '@/pages/Invoice/waitProcessRecord/components/InvoiceModal'; +import { + postServiceConstGetPayeeEnum, + postServiceConstInitInvoiceDetailNames, + postServiceConstInvoiceType, + postServiceConstInvoicingType, + postServiceConstListInvoiceDetailNames, + postServiceInvoiceApplyInvoice, + postServiceInvoiceQueryCompanyInfo, + postServiceInvoiceWaitReissueInvoices, +} from '@/services'; +import { + FloatAdd, + FloatMul, + FloatSub, + enum2ReverseSelect, + enumToSelect, +} from '@/utils'; +import { convertCurrency } from '@/utils/numberUtil'; +import { + DrawerForm, + FormListActionType, + ProCard, + ProFormDigit, + ProFormGroup, + ProFormInstance, + ProFormList, + ProFormMoney, + ProFormSelect, + ProFormText, + ProFormTextArea, +} from '@ant-design/pro-components'; +import { Button, Divider, Form, Space, Tooltip, message } from 'antd'; +import { useEffect, useRef, useState } from 'react'; + +export default ({ dataList, setVisible, mainOrder, onClose }) => { + // let subOrderIds = dataList?.map((item) => { + // return item.id; + // }) + const [form] = Form.useForm(); + const [projectOptions] = useState(); + const [dataListCopy] = useState(dataList); + const listActionRef = useRef<FormListActionType>(); + const formRef = useRef<ProFormInstance>(); + useEffect(() => { + const initOptions = async () => { + const res = await postServiceConstInitInvoiceDetailNames({ + data: dataListCopy.map((item) => { + return item.productName; + }), + }); + const options = res.data; + const datas = dataListCopy.map((item) => { + return { + ...item, + projectName: options[item.productName], + }; + }); + const initialValue = datas.map((item) => { + return { + productName: item.productName, + projectName: item.projectName, + subOrderId: item.id, + specification: item.parameters, + unit: item.unit, + quantity: item.quantity, + price: item.productPrice, + totalPrice: item.quantity * item.productPrice, + }; + }); + form.setFieldValue('invoiceDetails', initialValue); + form.setFieldValue('contacts', mainOrder.customerName); + }; + initOptions(); + }, []); + + useEffect(() => {}, [projectOptions]); + + function copyToClipboard(text: string) { + // 创建一个临时的textarea元素 + const textarea = document.createElement('textarea'); + textarea.value = text; + + // 将textarea元素添加到DOM中 + document.body.appendChild(textarea); + + // 选中textarea中的文本 + textarea.select(); + + try { + // 尝试执行复制命令 + document.execCommand('copy'); + return true; + } catch (err) { + return false; + } finally { + // 移除临时的textarea元素 + document.body.removeChild(textarea); + } + } + // 定义一个计算总金额的函数 + const calculateTotalPrice = (index: number) => { + const invoiceDetails = form.getFieldValue('invoiceDetails'); + if (invoiceDetails && invoiceDetails[index]) { + const quantity = invoiceDetails[index].quantity || 0; + const price = invoiceDetails[index].price || 0; + const totalPrice = FloatMul(quantity, price); + const newInvoiceDetails = [...invoiceDetails]; + newInvoiceDetails[index] = { ...newInvoiceDetails[index], totalPrice }; + form.setFieldsValue({ invoiceDetails: newInvoiceDetails }); + } + const totalPrice = invoiceDetails.reduce((accumulator, currentValue) => { + return FloatAdd(accumulator, currentValue.quantity * currentValue.price); + }, 0); + form.setFieldValue('price', totalPrice); + }; + useEffect(() => {}, []); + return ( + <DrawerForm + open + title="申请开票" + resize={{ + maxWidth: window.innerWidth * 0.8, + minWidth: 500, + }} + form={form} + formRef={formRef} + autoFocusFirstInput + drawerProps={{ + destroyOnClose: true, + }} + submitter={{ + render: (props, defaultDoms) => { + return [ + <InvoiceModal + key={'invoicePreview'} + button={<Button type="primary"> 发票预览 </Button>} + getRecord={() => { + const totalPrice = form + .getFieldValue('invoiceDetails') + .reduce((accumulator, currentValue) => { + return FloatAdd(accumulator, currentValue.totalPrice); + }, 0); + const partyBName = form.getFieldValue('partyBName'); + const openBank = form.getFieldValue('openBank'); + const bankAccount = form.getFieldValue('bankAccount'); + const bankCode = form.getFieldValue('bankCode'); + return { + ...form.getFieldsValue(), + totalPrice: totalPrice, + totalPriceText: convertCurrency(totalPrice), + comment: + '开户名称: ' + + partyBName + + '\n' + + '开户行: ' + + openBank + + '\n' + + '账号: ' + + bankAccount + + '\n' + + '银行联行号: ' + + bankCode, + }; + }} + />, + ...defaultDoms, + ]; + }, + }} + submitTimeout={2000} + onFinish={async (values) => { + postServiceInvoiceApplyInvoice({ + data: { + ...values, + subOrderIds: dataListCopy.map((item) => { + return item.id; + }), + }, + }); + onClose(); + }} + onOpenChange={(val) => { + return !val && setVisible(); + }} + > + <ProFormList + name="subOrderIdObjs" + readonly={true} + label="开票订单" + initialValue={dataListCopy.map((item) => { + return { + value: item.id, + }; + })} + deleteIconProps={false} + copyIconProps={false} + > + <ProFormGroup key="group"> + <ProFormText readonly={true} name="value" label="" /> + </ProFormGroup> + </ProFormList> + <ProFormSelect + name="ReissueInvoiceRecordIds" + label="重开的发票" + fieldProps={{ + mode: 'multiple', + }} + placeholder="请选择重开发票" + request={async () => { + let reissueIds = dataListCopy.map((item) => { + return item.id; + }); + let res = await postServiceInvoiceWaitReissueInvoices({ + data: reissueIds, + }); + return enum2ReverseSelect(res.data); + }} + /> + <ProFormSelect + key="key" + label="购方名称" + width="lg" + showSearch + name="partyAName" + placeholder="请搜索购方" + rules={[{ required: true, message: '购方名称必填' }]} + onChange={(_, option) => { + form.setFieldValue('partyATaxid', option.taxId); + }} + fieldProps={{ + optionItemRender(item) { + if (item.type === 'add') { + return <>{item.name}</>; + } + return ( + <> + {item.name} + <Divider type="vertical" /> + {item.taxId} + </> + ); + }, + }} + debounceTime={1000} + request={async (value) => { + const keywords = value.keyWords; + const res = await postServiceInvoiceQueryCompanyInfo({ + data: { + nameLike: keywords, + taxIdIsNotNull: true, + }, + }); + let options = res?.data?.map((company) => { + return { + ...company, + label: company.name, + value: company.name, + key: company.id, + }; + }); + + //第一个商品默认为要新增的商品 + if (keywords.trim() !== '') { + options.unshift({ + name: keywords, + type: 'add', + label: keywords, + value: keywords, + key: keywords, + }); + } + return options; + }} + /> + <ProFormText + width="md" + name="partyATaxid" + label="购方税号" + rules={[{ required: true, message: '购方税号必填' }]} + placeholder="请输入名称" + /> + <ProFormText + width="md" + name="partyAOpenBank" + label="开户银行" + placeholder="请输入名称" + /> + <ProFormText + width="md" + name="partyABankAccount" + label="开户行账号" + placeholder="请输入名称" + /> + <ProFormText + name="contacts" + label="联系人" + rules={[{ required: true, message: '请选择银行联行号!' }]} + /> + <ProFormSelect + name="invoicingType" + label="开具类型" + request={async () => { + let invoicingTypeRet = await postServiceConstInvoicingType(); + let options = enumToSelect(invoicingTypeRet.data); + return options; + }} + placeholder="请选择开具类型" + rules={[{ required: true, message: '请选择开具类型!' }]} + /> + <ProFormSelect + name="type" + label="开票类型" + placeholder="请选择开票类型" + rules={[{ required: true, message: '请选择开票类型!' }]} + request={async () => { + let invoiceTypeRet = await postServiceConstInvoiceType(); + let options = enumToSelect(invoiceTypeRet.data); + return options; + }} + /> + <ProFormSelect + name="partyB" + label="开票收款单位" + request={async () => { + const res = await postServiceConstGetPayeeEnum(); + let options = res?.data?.map((payee: any) => { + return { + ...payee, + label: payee.payeeName, + value: payee.name, + }; + }); + return options; + }} + onChange={(_, option) => { + if (option) { + form.setFieldsValue({ + partyBName: option.payeeName, + partyBTaxid: option.taxId, + bankAccount: option.bankAccount, + openBank: option.openBank, + bankCode: option.bankCode, + }); + } + }} + placeholder="请选择收款单位" + rules={[{ required: true, message: '请选择收款单位!' }]} + /> + <ProFormText + name="partyBName" + label="开票收款单位名称" + hidden + rules={[{ required: true, message: '请选择收款单位!' }]} + /> + <ProFormText + name="partyBTaxid" + label="开票收款单位税号" + hidden + rules={[{ required: true, message: '请选择收款单位!' }]} + /> + <ProFormText + name="bankAccount" + label="账号" + hidden + rules={[{ required: true, message: '请选择账号!' }]} + /> + <ProFormText + name="openBank" + label="开户行" + hidden + rules={[{ required: true, message: '请选择开户行!' }]} + /> + <ProFormText + name="bankCode" + label="银行联行号" + hidden + rules={[{ required: true, message: '请选择银行联行号!' }]} + /> + <ProFormSelect + name="isUrgent" + label="是否加急" + valueEnum={{ + true: '是', + false: '否', + }} + placeholder="请选择是否加急" + rules={[{ required: true, message: '请选择是否加急!' }]} + /> + <ProFormMoney + label="开票金额" + name="price" + locale="zh-CN" + disabled={true} + rules={[{ required: true, message: '请填写开票金额!' }]} + initialValue={dataListCopy.reduce((accumulator, currentValue) => { + return accumulator + currentValue.subOrderPayment; + }, 0)} + /> + <ProFormList + name="invoiceDetails" + label="开票明细" + actionRef={listActionRef} + actionGuard={{ + beforeRemoveRow: async (index) => { + const list = listActionRef.current?.getList(); + const totalPrice = list[index].totalPrice; + form.setFieldValue( + 'price', + FloatSub(form.getFieldValue('price'), totalPrice), + ); + return true; + }, + }} + rules={[ + { + required: true, + validator: async (_, value) => { + if (value && value.length > 0) { + return; + } + throw new Error('至少要有一项!'); + }, + }, + ]} + itemRender={(doms, listMeta) => { + return ( + <ProCard + bordered + extra={doms.action} + title={'明细' + (listMeta.index + 1)} + style={{ + marginBlockEnd: 8, + }} + > + <Tooltip title="点击复制商品名称"> + <Space + className="hover:cursor-pointer" + style={{ + margin: 16, + marginTop: 4, + marginLeft: 0, + fontSize: 15, + }} + onClick={() => { + copyToClipboard(listMeta.record.productName); + message.info('商品名称复制成功!'); + }} + > + 商品名称:{listMeta.record.productName} + </Space> + </Tooltip> + <ProFormSelect + key={'projectName' + listMeta.index} + width="md" + showSearch + name="projectName" + rules={[{ required: true, message: '请输入开票项目名称!' }]} + request={async (value) => { + const keywords = value.keyWords; + const res = await postServiceConstListInvoiceDetailNames({ + data: { + nameLike: keywords, + }, + }); + let options = res?.data?.map((c: any) => { + return { + ...c, + label: + '*' + + c.productAndServiceCatagoryAbbreviation + + '*' + + c.name, + value: + '*' + + c.productAndServiceCatagoryAbbreviation + + '*' + + c?.name, + key: c.id, + }; + }); + return options; + }} + fieldProps={{ + filterOption() { + return true; + }, + }} + onChange={(_, option) => { + let index = listMeta.index; + let copyList = form.getFieldValue('invoiceDetails'); + let currentData = copyList[index]; + currentData.projectName = + '*' + + option.productAndServiceCatagoryAbbreviation + + '*' + + option.name; + form.setFieldValue('invoiceDetails', copyList); + }} + debounceTime={1000} + label="项目名称" + initialValue={listMeta.record.projectName} + placeholder="请输入名称" + /> + <ProFormText + key={'specification' + listMeta.index} + name="specification" + label="规格型号" + rules={[ + { + message: '规格型号不能为空!', + required: true, + }, + { + validator: (_, value) => { + let len = 0; + // 判断是否为全角字符 + for (let i = 0; i < value.length; i++) { + // 获取字符的Unicode值 + const code = value.charCodeAt(i); + // 判断是否为全角字符 + if ( + (code >= 0xff01 && code <= 0xff5e) || + (code >= 0x4e00 && code <= 0x9fff) + ) { + len += 2; // 全角字符 + } else { + len += 1; // 半角字符 + } + } + if (len <= 40) { + return Promise.resolve(); + } + return Promise.reject( + new Error('规格型号不能超过40个字符!'), + ); + }, + }, + ]} + placeholder="请输入名称" + /> + <ProFormText + key={'unit' + listMeta.index} + name="unit" + label="单位" + placeholder="请输入名称" + /> + <ProFormDigit + key={'quantity' + listMeta.index} + label="数量" + name="quantity" + rules={[ + { + validator: (_, value) => { + if (value === undefined || value > 0) { + return Promise.resolve(); + } + return Promise.reject(new Error('数量必须大于0')); + }, + }, + ]} + onChange={() => calculateTotalPrice(listMeta.index)} + /> + + <ProFormDigit + key={'price' + listMeta.index} + label="单价" + name="price" + rules={[ + { + validator: (_, value) => { + if (value === undefined || value > 0) { + return Promise.resolve(); + } + return Promise.reject(new Error('单价必须大于0')); + }, + }, + ]} + onChange={() => calculateTotalPrice(listMeta.index)} + /> + + <ProFormMoney + key={'totalPrice' + listMeta.index} + label="金额" + name="totalPrice" + rules={[ + { + validator: (_, value) => { + if (value === undefined || value > 0) { + return Promise.resolve(); + } + return Promise.reject(new Error('金额必须大于0')); + }, + }, + ]} + readonly={true} + locale="zh-CN" + /> + </ProCard> + ); + }} + ></ProFormList> + <ProFormTextArea + name="applyInvoicingNotes" + label="备注" + placeholder="请输入名称" + /> + </DrawerForm> + ); +}; diff --git a/src/pages/Order/OrderList/KingdeeCustomerModal.tsx b/src/pages/Order/OrderList/KingdeeCustomerModal.tsx new file mode 100644 index 0000000..17026a9 --- /dev/null +++ b/src/pages/Order/OrderList/KingdeeCustomerModal.tsx @@ -0,0 +1,189 @@ +import { + postKingdeeRepCustomerDetail, + postKingdeeRepCustomerSave, +} from '@/services'; +import { getTeacherCustomFieldNumber } from '@/utils/kingdee'; +import { CloseCircleOutlined } from '@ant-design/icons'; +import { + ModalForm, + ProFormGroup, + ProFormList, + ProFormText, +} from '@ant-design/pro-components'; +import { Form, message } from 'antd'; + +// import { cloneDeep } from 'lodash'; +export default ({ setVisible, data, onClose }) => { + const [form] = Form.useForm(); + + /** + * 回显客户信息 + * @param id + */ + async function queryAndShowCustomer(id: any) { + //查询客户信息 + let res = await postKingdeeRepCustomerDetail({ + data: { + id: id, + }, + }); + + if (res) { + form.setFieldValue('name', res.name); + form.setFieldValue('id', res.id); + form.setFieldValue('contact_persons', res.bomentity); + let customFiledNumber = await getTeacherCustomFieldNumber(); + form.setFieldValue('teacherName', res.custom_field[customFiledNumber]); + } + } + + if (data) { + //修改 + if (data.id) { + queryAndShowCustomer(data.id); + } else { + //新增 + form.setFieldValue('name', data.name); + form.setFieldValue('contact_persons', [{}]); + } + } + return ( + <> + <ModalForm + width={900} + open + title="客户信息" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '保存', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + onFinish={async (values) => { + //查询客户自定义字段,课题组 + let custom_field_umber = await getTeacherCustomFieldNumber(); + + if (custom_field_umber) { + let customFieldObj = {}; + customFieldObj[custom_field_umber] = values.teacherName; + values.custom_field = customFieldObj; + } + let customSaveRes = await postKingdeeRepCustomerSave({ + data: values, + }); + if (customSaveRes) { + let id_number_map = customSaveRes.id_number_map; + let ids = customSaveRes.ids; + if (id_number_map && ids) { + message.success('保存成功'); + let id = ids[0]; + onClose(id); + } + } + }} + onOpenChange={setVisible} + > + <ProFormText key="key" name="id" label="id" placeholder="id" hidden /> + <ProFormGroup key="group"> + <ProFormText + name="name" + width="md" + label={ + <> + <span>客户名称</span> + <span className="pl-2 text-xs text-gray-400"> + 请按照[单位]-[姓名][手机号]命名,例如:清华大学-张三12345678919 + </span> + </> + } + initialValue={data} + placeholder="请输入客户名称" + rules={[ + { + required: true, + pattern: new RegExp('^.+-.+$'), + message: + '格式错误,若无单位可写:“无-姓名手机号”,例如:无-张三12345678919', + }, + { required: true, message: '客户名称必填' }, + ]} + /> + <ProFormText + name="teacherName" + width="md" + label="课题组老师" + placeholder="请输入课题组老师" + rules={[ + { required: true, message: '课题组老师必填,若没有请填“无”' }, + ]} + /> + </ProFormGroup> + + <ProFormList + creatorButtonProps={{ disabled: false }} + name="contact_persons" + label="联系人信息" + actionGuard={{ + beforeRemoveRow: async () => { + return new Promise((resolve) => { + let contactPersons = form.getFieldValue('contact_persons'); + if (contactPersons.length === 1) { + message.error('至少要有一个联系人'); + resolve(false); + return; + } + resolve(true); + }); + }, + beforeAddRow: (defaultValue) => { + defaultValue.id = undefined; //复制的时候要把id去掉 + return defaultValue; + }, + }} + deleteIconProps={{ + Icon: CloseCircleOutlined, + tooltipText: '不需要这行了', + }} + > + <ProFormGroup key="group"> + {[ + <ProFormText + key="key" + name="id" + label="id" + placeholder="id" + hidden + />, + <ProFormText + key="key" + name="contact_person" + label="收货人姓名" + placeholder="联系人姓名" + rules={[{ required: true, message: '收货人姓名必填' }]} + />, + <ProFormText + key="key" + name="mobile" + label="联系方式" + placeholder="联系方式" + rules={[{ required: true, message: '联系方式必填' }]} + />, + <ProFormText + key="key" + name="contact_address" + label="收货地址" + width="md" + placeholder="请输入收货地址" + rules={[{ required: true, message: '收货地址必填' }]} + />, + ]} + </ProFormGroup> + </ProFormList> + </ModalForm> + </> + ); +}; diff --git a/src/pages/Order/OrderList/LazySelect.tsx b/src/pages/Order/OrderList/LazySelect.tsx new file mode 100644 index 0000000..652950a --- /dev/null +++ b/src/pages/Order/OrderList/LazySelect.tsx @@ -0,0 +1,136 @@ +import { Select, Spin } from 'antd'; +import debounce from 'lodash/debounce'; +import difference from 'lodash/difference'; +import { useEffect, useState } from 'react'; + +/** + * 懒加载 Select ,适用于数据超大的下拉框 + * @param {Select 官方属性} props + */ +const LazySelect = (props) => { + const { value, onChange, query, pageSize } = props; + // 清除 porps 中 query,避免控制台警告 + const selectProps = { ...props, query: undefined }; + + const [selected, setSelected] = useState(value); + const [data, setData] = useState([]); + const [loading, setLoading] = useState(false); + const [current, setCurrent] = useState(1); + const [total, setTotal] = useState(0); + const [searchText] = useState(''); + + const getSelectedArray = (obj) => { + let selectedValues = obj; + // 如果是单选,将值封装为数组 + if (obj && obj instanceof Array === false) { + selectedValues = [obj]; + } + return selectedValues; + }; + + // 添加 300 毫秒防抖 + const handleQuery = debounce(async (param) => { + setLoading(true); + const resp = await query(param); + const resData = resp.data; + let options = resData?.data?.map((p: any) => { + return { + ...p, + label: p.productName, + value: p.productName, + key: p.id, + }; + }); + // 搜索服务端异步加载 + // const handleSearch = (filter) => { + // setSearchText(filter); + // handleQuery({ + // filter, + // selectedValues: getSelectedArray(selected), + // pageSize, + // current + // }); + // }; + + //第一个商品默认为要新增的商品 + // if (searchValue?.trim() !== "") { + // options.unshift({ productName: searchValue, type: "add", label: searchValue, value: searchValue }) + // } + // return options; + setTotal(resData.total); + setData(data.concat(options)); + setLoading(false); + }, 300); + + // 组件初始化时加载一次数据 + useEffect(() => { + handleQuery({ + filter: '', + selectedValues: getSelectedArray(value), + }); + }, []); + + // 外部注入的 value 变化后,如果 value 在 data 中不存在,则加载数据 + useEffect(() => { + setSelected(value); + const dataKeys = data.map((item) => item.value); + const diff = difference(getSelectedArray(value), dataKeys); + if (diff && diff.length > 0) { + handleQuery({ + filter: '', + selectedValues: getSelectedArray(value), + }); + } + }, [value]); + + const keywordChange = (newWord: string) => { + setData([]); + setTotal(0); + setCurrent(1); + handleSearch(newWord); + }; + + const handleChange = (newValue, option) => { + setSelected(newValue); + if (onChange) { + // 将值通过 onChange 传递到外部 + onChange(newValue, option); + } + }; + + const scrollEnd = (e) => { + e.persist(); + const { target } = e; + // 滚动 触底 看接口是否还有剩余的值没传过来 + if (target.scrollTop + target.offsetHeight === target.scrollHeight) { + if (current * pageSize < total) { + setCurrent(current + 1); + handleSearch(searchText); + } + } + }; + + return ( + <Select + {...selectProps} + value={selected} + loading={loading} + onSearch={keywordChange} + onChange={handleChange} + onPopupScroll={scrollEnd} + filterOption={false} + options={data} + showSearch + showArrow + notFoundContent={loading ? <Spin size="small" /> : null} + > + {/* {data.map(d => ( + <Option key={d.value} title={d.label}> + {d.label} + </Option> + ))} */} + </Select> + ); +}; + +export default LazySelect; diff --git a/src/pages/Order/OrderList/MessageListDrawer.tsx b/src/pages/Order/OrderList/MessageListDrawer.tsx new file mode 100644 index 0000000..6cdcdd9 --- /dev/null +++ b/src/pages/Order/OrderList/MessageListDrawer.tsx @@ -0,0 +1,206 @@ +import ButtonConfirm from '@/components/ButtomConfirm'; +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postOrderErpMessageQueryMyMessage, + postOrderErpMessageRead, + postOrderErpMessageReadAll, +} from '@/services'; +import { formatDateTime, getUserInfo } from '@/utils'; +import { UserOutlined } from '@ant-design/icons'; +import { + Avatar, + Badge, + Button, + Checkbox, + Drawer, + Flex, + List, + message, +} from 'antd'; +import { useEffect, useState } from 'react'; + +export default ({ setVisible }) => { + const userInfo = getUserInfo(); + const [current, setCurrent] = useState<number>(1); //当前页码 + const [total, setTotal] = useState(0); + const [messageListData, setMessageListData] = useState<any[]>([]); //列表数据 + const [loading, setLoading] = useState(false); + const [initLoading, setInitLoading] = useState(true); + const [onlyUnread, setOnlyUnread] = useState(false); + const [readFlagList, setReadFlagList] = useState<any[]>([]); //消息未读标识 + + /** + * 获取消息列表 + */ + async function getMessageListData() { + setLoading(true); + let res = await postOrderErpMessageQueryMyMessage({ + data: { + username: userInfo.username, + current: current, + isReaded: onlyUnread ? onlyUnread : null, + }, + }).finally(() => { + setLoading(false); + }); + if (res && res.result === RESPONSE_CODE.SUCCESS) { + setMessageListData([...messageListData, ...res?.data?.data]); + let reqReadNumList = res?.data?.data?.map((item: any) => { + return item.isReaded; + }); + + setReadFlagList([...readFlagList, ...reqReadNumList]); + setTotal(res?.data?.total); + } + } + + /** + * 跳转到订单列表 + */ + function toOrderList(mainOrderIds: any) { + window.open('/order/order?id=' + mainOrderIds.join(','), '_blank'); + } + + /** + * 仅展示未读 + */ + function onlyUnreadChange() { + setOnlyUnread(!onlyUnread); + setCurrent(1); + setMessageListData([]); + setReadFlagList([]); + } + + /** + * 仅展示未读 + */ + async function read(ids: any[]) { + let res = await postOrderErpMessageRead({ + data: ids, + }); + + if (res && res.result === RESPONSE_CODE.SUCCESS) { + message.success('已读'); + return true; + } + + return false; + } + + /** + * 全部标记为已读 + */ + async function readAll() { + let res = await postOrderErpMessageReadAll(); + if (res && res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + let newReadFlagList = readFlagList.map(() => true); + setReadFlagList(newReadFlagList); + } + } + + const loadMore = + !initLoading && !loading && messageListData.length < total ? ( + <div + style={{ + textAlign: 'center', + marginTop: 12, + height: 32, + lineHeight: '32px', + }} + > + <Button + onClick={() => { + setCurrent(current + 1); + }} + > + 加载更多 + </Button> + </div> + ) : messageListData.length > 0 && messageListData.length >= total ? ( + <span>没有更多消息了</span> + ) : null; + + useEffect(() => { + getMessageListData().finally(() => { + setInitLoading(false); + }); + }, [onlyUnread, current]); + + return ( + <> + <Drawer + title="消息列表" + onClose={() => { + setVisible(false); + }} + open={true} + width={450} + styles={{ body: { paddingTop: 0 } }} + > + <Flex align="center" justify="space-between"> + <div> + <Checkbox onChange={onlyUnreadChange} checked={onlyUnread}> + 仅展示未读 + </Checkbox> + </div> + + <ButtonConfirm + title={'是否全部标记为已读?'} + text={'全部标记为已读'} + className="p-0" + onConfirm={readAll} + placement="bottomLeft" + /> + </Flex> + + <List + className="demo-loadmore-list" + loading={initLoading} + itemLayout="horizontal" + loadMore={loadMore} + dataSource={messageListData} + renderItem={(item: any, index: any) => ( + <List.Item key={item.id}> + <List.Item.Meta + avatar={ + <Badge dot={!readFlagList[index]}> + <Avatar shape="square" icon={<UserOutlined />} /> + </Badge> + } + /> + <Flex + vertical + className="w-full hover:cursor-pointer" + onClick={async () => { + toOrderList(item.mainOrderIds); + + let readSuccess = await read([item.mesUsrRelId]); + if (readSuccess) { + let newUnreadNumList = [...readFlagList]; + newUnreadNumList[index] = true; + setReadFlagList([...newUnreadNumList]); + } + }} + > + <Flex> + <div> + {item.content} + {/* <span className="text-[#8C8C8C]"> + (点击跳转到对应主订单) + </span> */} + </div> + </Flex> + <Flex> + <span className="text-xs text-[#8C8C8C] pt-1"> + {formatDateTime(item.createTime)} + </span> + </Flex> + </Flex> + </List.Item> + )} + /> + </Drawer> + </> + ); +}; diff --git a/src/pages/Order/OrderList/ModifiedDiffModal.tsx b/src/pages/Order/OrderList/ModifiedDiffModal.tsx new file mode 100644 index 0000000..b8c0210 --- /dev/null +++ b/src/pages/Order/OrderList/ModifiedDiffModal.tsx @@ -0,0 +1,302 @@ +import { postServiceOrderModifiedDiff } from '@/services'; +import { enumValueToLabel, getAliYunOSSFileNameFromUrl } from '@/utils'; +import { getReceivingCompanyOptions, isSupplier } from '@/utils/order'; +import { Button, Divider, Modal, Space, Table, TableProps } from 'antd'; +import { useEffect, useState } from 'react'; +import { + PAYEE_OPTIONS, + PAYMENT_CHANNEL_OPTIONS, + PAYMENT_METHOD_OPTIONS, + PRODUCT_BELONG_DEPARTMENT_OPTIONS, + SHIPPING_WAREHOUSE_OPTIONS, +} from '../constant'; +import './table.less'; + +export default ({ setVisible, subOrders, mainOrder, onClose }) => { + let subIds = subOrders?.map((item: any) => { + return item.id; + }); + + let mainId = mainOrder?.id; + + const [subOrderDiffs, setSubOrderDiffs] = useState([]); + const [mainOrderDiffs, setMainOrderDiffs] = useState([]); + + function isSupplierUnvisibleField(field: any) { + //主订单字段 + let unvisibleFields = [ + 'receivingCompany', + 'invoiceIdentificationNumber', + 'bankAccountNumber', + 'bank', + 'totalPayment', + 'institution', + 'institutionContactName', + ]; + //子订单字段 + unvisibleFields.push( + ...[ + 'listAnnex', + 'shippingWarehouse', + 'productBelongBusiness', + 'subOrderPayment', + 'productPrice', + ], + ); + + return isSupplier() && unvisibleFields.includes(field); + } + + async function loadData() { + let res = await postServiceOrderModifiedDiff({ + data: { + subOrderIds: subIds, + mainOrderId: mainId, + }, + }); + let subOrderDiffs = res?.data?.subOrderDiffs; + let mainOrderDiffs = res?.data?.mainOrderDiffs; + + setSubOrderDiffs(subOrderDiffs); + setMainOrderDiffs(mainOrderDiffs); + } + + useEffect(() => { + loadData(); + }, []); + + function toChineseName(key: any, text: any) { + let newText = text; + if (key === '所属事业部') { + newText = enumValueToLabel(text, PRODUCT_BELONG_DEPARTMENT_OPTIONS); + } + if (key === '发货仓库') { + newText = enumValueToLabel(text, SHIPPING_WAREHOUSE_OPTIONS); + } + if (key === '支付渠道') { + newText = enumValueToLabel(text, PAYMENT_CHANNEL_OPTIONS); + } + if (key === '支付方式') { + newText = enumValueToLabel(text, PAYMENT_METHOD_OPTIONS); + } + if (key === '单价' || key === '合计') { + newText = '¥' + newText; + } + if (key === '开票收款单位') { + newText = enumValueToLabel( + text, + getReceivingCompanyOptions(PAYEE_OPTIONS), + ); + } + return newText; + } + + function cellRender(value: any, record: any) { + if (record.fieldName === '附件') { + return ( + <Space className="max-w-[300px]" wrap> + {value?.map((item: any, index: any) => { + let fileName = getAliYunOSSFileNameFromUrl(item); + return ( + <Button + className="p-0 pr-2" + key={index} + danger={record.isDiff} + type="link" + onClick={() => { + window.open( + '/previewApi/onlinePreview?url=' + + encodeURIComponent(Base64.encode(item)), + ); + }} + > + {fileName} + </Button> + ); + })} + </Space> + ); + } + return ( + <div + title={toChineseName(record.fieldName, value)} + className="max-w-[250px] whitespace-no-wrap overflow-hidden overflow-ellipsis" + > + <span className={record.isDiff ? 'text-[red]' : ''}> + {toChineseName(record.fieldName, value)} + </span> + </div> + ); + } + + interface DataType { + fieldName: string; + oldValue: string; + newValue: string; + isDiff: boolean; + } + + const columns: TableProps<DataType>['columns'] = [ + { + title: '字段名', + dataIndex: 'fieldName', + key: 'fieldName', + render(value) { + return ( + <div + title={value} + className="max-w-[80px] whitespace-no-wrap overflow-hidden overflow-ellipsis" + > + {value} + </div> + ); + }, + }, + { + title: '修改前字段值', + dataIndex: 'oldValue', + key: 'oldValue', + render(value, record) { + return cellRender(value, record); + }, + }, + { + title: '修改后(当前)字段值', + dataIndex: 'newValue', + key: 'newValue', + render(value, record) { + return cellRender(value, record); + }, + }, + ]; + + function loadSubOrderDiffTable(item: any, index: any) { + //转换为表格数据 + let oldDatas = item[0]; + let curDatas = item[1]; + let diffFiledNames = oldDatas?.diffFieldsName; + + let tableData = []; + let visibleFields = [ + ['productName', '商品名称'], + ['productCode', '商品编码'], + ['parameters', '商品参数'], + ['quantity', '数量'], + ['productPrice', '单价'], + ['unit', '单位'], + ['subOrderPayment', '合计'], + ['productBelongBusiness', '所属事业部'], + ['shippingWarehouse', '发货仓库'], + ['notes', '备注'], + ['paymentChannel', '支付渠道'], + ['paymentMethod', '支付方式'], + ['listAnnex', '附件'], + ]; + for (let field of visibleFields) { + let filedKey = field[0]; + let filedName = field[1]; + + if (!isSupplierUnvisibleField(filedKey)) { + tableData.push({ + fieldName: filedName, + oldValue: oldDatas[filedKey], + newValue: curDatas[filedKey], + isDiff: diffFiledNames?.includes(filedKey), + }); + } + } + return ( + <> + <Divider orientation="left">商品{index + 1}:</Divider> + <Table + className="myTable" + size="small" + pagination={false} + key={index} + columns={columns} + dataSource={tableData} + /> + </> + ); + } + + function loadMainOrderDiffTable(item: any, index: any) { + if (!item || item.length <= 0) { + return; + } + //转换为表格数据 + let oldDatas = item[0]; + let curDatas = item[1]; + let diffFiledNames = oldDatas?.diffFieldsName; + + let tableData = []; + let visibleFields = [ + ['salesCode', '销售代号'], + ['customerName', '收货人姓名'], + ['customerContactNumber', '收货人联系手机号'], + ['customerShippingAddress', '收货人地址信息'], + ['institutionContactName', '单位联系人'], + ['institution', '单位'], + ['totalPayment', '支付总金额'], + ['notes', '备注'], + ['bank', '开户银行'], + ['bankAccountNumber', '银行账号'], + ['invoiceIdentificationNumber', '开票识别号'], + ['receivingCompany', '开票收款单位'], + ]; + for (let field of visibleFields) { + let filedKey = field[0]; + let filedName = field[1]; + + if (!isSupplierUnvisibleField(filedKey)) { + tableData.push({ + fieldName: filedName, + oldValue: oldDatas[filedKey], + newValue: curDatas[filedKey], + isDiff: diffFiledNames?.includes(filedKey), + }); + } + } + return ( + <Table + className="myTable" + size="small" + pagination={false} + key={index} + columns={columns} + dataSource={tableData} + /> + ); + } + + return ( + <> + <Modal + width={700} + open + title="信息对比" + okText="返回" + cancelText={false} + onOk={() => { + setVisible(false); + onClose(); + }} + onCancel={() => { + setVisible(false); + }} + cancelButtonProps={{ + hidden: true, + }} + destroyOnClose={true} + > + <Divider>主订单信息:</Divider> + {loadMainOrderDiffTable(mainOrderDiffs, 0)} + + <Divider>子订单信息:</Divider> + {subOrderDiffs?.map((item: any, index) => { + return loadSubOrderDiffTable(item, index); + })} + </Modal> + </> + ); +}; diff --git a/src/pages/Order/OrderList/OrderDrawer copy.tsx b/src/pages/Order/OrderList/OrderDrawer copy.tsx new file mode 100644 index 0000000..77f1243 --- /dev/null +++ b/src/pages/Order/OrderList/OrderDrawer copy.tsx @@ -0,0 +1,1154 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postKingdeeRepCustomer, + postKingdeeRepCustomerDetail, + postKingdeeRepMaterial, + postKingdeeRepMaterialUnit, + postKingdeeRepMeasureUnit, + postServiceOrderAddOrder, + postServiceOrderQuerySalesCode, + postServiceOrderUpdateOrder, +} from '@/services'; +import { + enumToSelect, + getAliYunOSSFileNameFromUrl, + getUserInfo, +} from '@/utils'; +import { getTeacherCustomFieldNumber } from '@/utils/kingdee'; +import { + DrawerForm, + FormListActionType, + ProCard, + ProFormDateTimePicker, + ProFormDigit, + ProFormList, + ProFormSelect, + ProFormText, + ProFormTextArea, + ProFormUploadDragger, +} from '@ant-design/pro-components'; +import { Button, Form, message } from 'antd'; +import { cloneDeep } from 'lodash'; +import { useEffect, useRef, useState } from 'react'; +import { + INVOCING_STATUS_OPTIONS, + INVOCING_STATUS_OPTIONS_OLD, + PAYMENT_CHANNEL_OPTIONS, + PAYMENT_METHOD_OPTIONS, + PRODUCT_BELONG_DEPARTMENT_OPTIONS, +} from '../constant'; +import KingdeeCustomerModal from './KingdeeCustomerModal'; + +export default ({ onClose, data, subOrders, orderOptType }) => { + const [invoicingStatus, setInvoicingStatus] = useState(''); + const [salesCodeOptions, setSalesCodeOptions] = useState([]); + const [customer, setCustomer] = useState({}); + const [kingdeeCstomerModalVisible, setKingdeeCstomerModalVisible] = + useState(false); + const [ + productParametersDisabledFlagList, + setProductParametersDisabledFlagList, + ] = useState([]); + // const [productInvStockOptionsList, setProductInvStockOptionsList] = useState( + // [], + // ); //商品的仓库选项 + const [productUnitOptionsList, setProductUnitOptionsList] = useState([]); //商品的单位选项 + const [productCustomerContactOptions, setProductCustomerContactOptions] = + useState([]); //客户的收货人选项 + const [form] = Form.useForm<{ + salesCode: ''; + customerName: ''; + customerContactNumber: ''; + institution: ''; + institutionContactName: ''; + customerShippingAddress: ''; + totalPayment: ''; + paymentChannel: ''; + paymentMethod: ''; + productBelongBusiness: ''; + invoicingStatus: ''; + invoiceIdentificationNumber: ''; + invoicingTime: ''; + bank: ''; + bankAccountNumber: ''; + deleteSubOrderLists: []; + notes: ''; + list: [ + { + productCode: ''; + productName: ''; + quantity: ''; + productPrice: ''; + parameters: ''; + subOrderPayment: ''; + unit: ''; + serialNumber: ''; + notes: ''; + }, + ]; + }>(); + + let originSubOrders = cloneDeep(subOrders); + /** + * 获取当前的操作类型boolean值 + * @param type 操作类型,如果与当前匹配返回true + */ + function optType(type: string) { + return orderOptType === type; + } + + /** + * + * @returns 获取开票选项 + */ + function getInvoicingSelect() { + if (optType('edit')) { + return enumToSelect(INVOCING_STATUS_OPTIONS_OLD); + } + return enumToSelect(INVOCING_STATUS_OPTIONS); + } + + const fileList: any = []; + + const getSalesCodeOptions = async () => { + const res = await postServiceOrderQuerySalesCode(); + let options = res.data?.map((item) => { + return { + label: item.userName, + value: item.userName, + number: item.number, + }; + }); + setSalesCodeOptions(options); + + if (optType('copy') || optType('edit')) { + let includeFlag = false; + //销售代码校验,如果是旧的销售代码,则提示并清空 + for (let option of options) { + if (option.value === data.salesCode) { + includeFlag = true; + } + } + if (!includeFlag) { + form.resetFields(['salesCode']); + message.warning('检测到销售代码为旧的,已清空,请重新选择'); + } + } + }; + + //复制的时候,如果是不需要开票,要把开票信息清空 + if (optType('copy') && data.invoicingStatus === 'UN_INVOICE') { + data.invoiceIdentificationNumber = undefined; + } + + if (subOrders !== undefined && subOrders.length > 0) { + data.list = subOrders; + } + + const actionRef = useRef< + FormListActionType<{ + name: string; + }> + >(); + + useEffect(() => { + form.setFieldsValue({ ...data }); + //如果是新建,需要清空list + if (optType('add')) { + form.resetFields(['list']); + } + }, [data]); + + /** + * 选择客户后自动为收货人Select添加选项,填充课题组和单位信息 + * @param option 客户选项 + */ + async function autoFillCustomerContactSelectOptions(customerId: any) { + //查询单位详细信息 + let res = await postKingdeeRepCustomerDetail({ + data: { + id: customerId, + }, + }); + + //erp客户名称 + form.setFieldValue('erpCustomerName', res?.name); + + //重新设置当前option + form.setFieldValue('erpCustomerId', { + label: res?.name, + value: res?.id, + id: res?.id, + }); + + //查询客户自定义字段,课题组 + let entity_number = await getTeacherCustomFieldNumber(); + + //在单位详细信息中拿到自定义字段的值 + let customField = res?.custom_field; + if (customField) { + let teacherName = customField[entity_number]; + //填充到课题组老师表单字段中 + form.setFieldValue('institutionContactName', teacherName); + } + + //单位名称,从客户名称中获取,客户名称规则<单位名称>-<联系人名称和电话> + let namePortions = res?.name?.split('-'); + if (namePortions && namePortions.length >= 2) { + form.setFieldValue('institution', namePortions[0]); + } + + //如果原来的收货信息没有包含在这次查询出来的收货人选项中,那么清除原来的收货人信息 + let existFlag = false; + + //填充收货人选项 + let newProductCustomerContactOptions = res?.bomentity?.map((item) => { + let address = + item.contact_person + ',' + item.mobile + ',' + item.contact_address; + if (address === data.contactAddress) { + existFlag = true; + } + return { ...item, label: address, value: address }; + }); + + setProductCustomerContactOptions(newProductCustomerContactOptions); + + if (!existFlag) { + //清空原来的收货人信息 + form.setFieldValue('customerShippingAddress', undefined); + form.setFieldValue('customerContactNumber', undefined); + form.setFieldValue('customerName', undefined); + form.setFieldValue('erpCustomerAddress', undefined); + } + } + + /** + * 回显金蝶信息 + */ + async function showKindeeInfo() { + //客户信息 + if (data.customerId) { + //客户回显 + autoFillCustomerContactSelectOptions(data.customerId); + } + + //商品单位回显 + let list = data?.subOrderInformationLists; + if (list) { + let newProductUnitOptionsList = [...productUnitOptionsList]; + for (let i = 0; i < list.length; i++) { + newProductUnitOptionsList[i] = [ + { label: list[i].unit, value: list[i].unitId }, + ]; + } + setProductUnitOptionsList(newProductUnitOptionsList); + } + } + + /** + * + * @param option 商品名称所对应的商品数据 + * @param currentRowData list中当前行的数据 + */ + async function autoFillProductInfo( + option: any, + currentRowData: any, + index: any, + ) { + let newProductParametersDisabledFlagList = [ + ...productParametersDisabledFlagList, + ]; + let newProductUnitOptionsList = [...productUnitOptionsList]; + newProductUnitOptionsList[index] = []; + + //是新增商品 + if (option.type === 'add') { + //商品参数开放权限可以编辑 + newProductParametersDisabledFlagList[index] = false; + + //清空商品信息 + let copyList = form.getFieldValue('list'); + let currentData = copyList[index]; + currentData.productCode = undefined; + currentData.parameters = undefined; + currentData.unit = undefined; + currentData.subOrderPayment = undefined; + currentData.quantity = undefined; + currentData.notes = undefined; + currentData.productPrice = undefined; + form.setFieldValue('list', copyList); + + //查询计量单价列表 + let res = await postKingdeeRepMeasureUnit({ data: {} }); + if (res && res?.rows) { + for (let row of res?.rows) { + newProductUnitOptionsList[index].push({ + label: row.name, + value: row.id, + }); + } + } + } else { + //选择的是已有的商品,进行内容自动填充 + let copyList = form.getFieldValue('list'); + let currentData = copyList[index]; + currentData.productCode = option?.number; + currentData.parameters = option?.model; + currentData.unit = option?.base_unit_name; + + //商品id + currentData.materialId = option?.id; + + //单位 + currentData.unit = option.base_unit_name; + currentData.unitId = option.base_unit_id; + + form.setFieldValue('list', copyList); + + //商品所在的仓库选项填充 + // let res = await postKingdeeRepMaterialStock({ + // data: { + // material_id: option.id, + // }, + // }); + // let newProductInvStockOptionsList = [...productInvStockOptionsList]; + // newProductInvStockOptionsList[index] = res?.rows?.map((item) => { + // return { label: item.inv_stock, value: item.inv_stock_id }; + // }); + // setProductInvStockOptionsList(newProductInvStockOptionsList); + + //商品单位填充,查询商品单位列表 + let res = await postKingdeeRepMaterialUnit({ + data: { material_id: option.id }, + }); + if (res && res.rows) { + for (let row of res.rows) { + newProductUnitOptionsList[index].push({ + label: row.unit_name, + value: row.unit_id, + }); + } + } + //商品参数不允许编辑 + newProductParametersDisabledFlagList[index] = true; + } + + setProductParametersDisabledFlagList(newProductParametersDisabledFlagList); + setProductUnitOptionsList(newProductUnitOptionsList); + } + + /** + * 选择收货人后自动填充信息 + * @param option 收货人信息 + */ + async function autoFillCustomerInfo(option: any) { + form.setFieldValue('customerShippingAddress', option.contact_address); + form.setFieldValue('customerContactNumber', option.mobile); + form.setFieldValue('customerName', option.contact_person); + + //erp收货地址:需要与客户联系人中的地址一样:姓名,手机号,地址 + form.setFieldValue('contactAddress', option.value); + } + + /** + * 填充销售代表的信息 + * @param option + */ + function autoFillSalesInfo(option: any) { + console.log(option); + //销售代表对应职员编码填充 + form.setFieldValue('empNumber', option.number); + } + + /** + * 选择商品单位后自动填充 + * @param option + * @param index + */ + function autoFillUnit(option: any, index: any) { + let copyList = form.getFieldValue('list'); + let currentData = copyList[index]; + currentData.unit = option?.label; + form.setFieldValue('list', copyList); + } + + /** + * 计算子订单金额 + * @param listMeta 当前商品信息 + */ + function computeSubOrderPayment(listMeta: any) { + let quantity = listMeta?.record?.quantity; + let productPrice = listMeta?.record?.productPrice; + quantity = quantity === '' || quantity === undefined ? 0 : quantity; + productPrice = + productPrice === '' || productPrice === undefined ? 0 : productPrice; + + listMeta.subOrderPayment = quantity * productPrice; + let list = form.getFieldValue('list'); + list[listMeta?.index].subOrderPayment = quantity * productPrice; + form.setFieldValue('list', list); + } + + /** + * 计算支付总额 + */ + function computeTotalPayment() { + let list = form.getFieldValue('list'); + let totalPayment = 0; + list?.forEach((subOrder: any) => { + let subOrderPayment = subOrder?.subOrderPayment; + if (subOrderPayment === '' || subOrderPayment === undefined) { + totalPayment += 0; + } else { + totalPayment += subOrderPayment; + } + }); + form.setFieldValue('totalPayment', totalPayment); + } + + useEffect(() => { + getSalesCodeOptions(); + showKindeeInfo(); + }, []); + + useEffect(() => { + // 在组件挂载或数据变化时,更新组件状态 + if (data) { + setInvoicingStatus(data.invoicingStatus); + } + }, [data]); + + // let mainInfoDisbled = optType('edit'); + if (optType('edit') || optType('copy')) { + //如果是复制,需要开票,不回显是否需要开票字段 + if (optType('copy')) { + if (data.invoicingStatus === 'INVOICED') { + data.invoicingStatus = undefined; + } + } + //订单修改和新增的子订单列表命名是list + data.list = data.subOrderInformationLists; + //主订单事业部默认显示子订单第一条的事业部 + data.productBelongBusiness = data.list[0].productBelongBusiness; + data.paymentMethod = data.list[0].paymentMethod; + data.paymentChannel = data.list[0].paymentChannel; + data.invoicingStatus = data.list[0].invoicingStatus; + + data.list = data.list?.map((item) => { + item.filePaths = item.listAnnex?.map((path) => { + let i = 0; + return { + uid: i++, + name: getAliYunOSSFileNameFromUrl(path), + status: 'uploaded', + url: path, + response: { data: [path] }, + }; + }); + return item; + }); + } + + return ( + <> + <DrawerForm<{ + deleteSubOrderLists: any; + name: string; + company: string; + }> + open + width="35%" + title={optType('add') || optType('copy') ? '新建订单' : '修改订单'} + resize={{ + onResize() { + console.log('resize!'); + }, + maxWidth: window.innerWidth * 0.8, + minWidth: 400, + }} + // layout="horizontal" + // labelCol={{ span: 8 }} + form={form} + autoFocusFirstInput + drawerProps={{ + destroyOnClose: true, + maskClosable: false, + }} + submitTimeout={2000} + onFinish={async (values) => { + let res = {}; + //附件处理 + let list = values.list; + // console.log(list); + list = list.map((item) => { + item.filePaths = item.filePaths?.map((file) => { + console.log(file); + return { url: file.response.data[0] }; + }); + return item; + }); + + values.list = list; + values.institution = values.institution?.trim(); + values.institutionContactName = values.institutionContactName?.trim(); + + if (typeof values.erpCustomerId !== 'string') { + values.erpCustomerId = values.erpCustomerId?.id; + } + + if (optType('add') || optType('copy')) { + res = await postServiceOrderAddOrder({ data: values }); + } else { + //计算已删除的子订单id + const originIds = originSubOrders.map((item) => { + return item.id; + }); + const curIds = form.getFieldValue('list')?.map((item) => { + return item.id; + }); + let diff = originIds.filter((item) => !curIds.includes(item)); + values.deleteSubOrderLists = diff; + res = await postServiceOrderUpdateOrder({ data: values }); + } + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + // 不返回不会关闭弹框 + onClose(true); + return true; + } + }} + onOpenChange={(val) => { + return !val && onClose(); + }} + > + <h2>订单基本信息</h2> + <ProFormText + key="id" + name="id" + width="lg" + disabled + label="id" + placeholder="id" + hidden + /> + + <ProFormText + key="empNumber" + name="empNumber" + width="lg" + label="销售职员编码" + placeholder="销售职员编码" + hidden + /> + + <ProFormSelect + name="salesCode" + key="salesCode" + width="lg" + showSearch + label="销售代表" + placeholder="请输入销售代表" + rules={[{ required: true, message: '销售代表必填' }]} + options={salesCodeOptions} + onChange={(_, option) => { + autoFillSalesInfo(option); + }} + // disabled={mainInfoDisbled} + /> + + <ProFormText + key="erpCustomerName" + name="erpCustomerName" + hidden + ></ProFormText> + + <ProFormText + key="contactAddress" + name="contactAddress" + hidden + ></ProFormText> + + <ProFormSelect + name="erpCustomerId" + key="erpCustomerId" + width="lg" + showSearch + label={ + <> + <span>客户</span> + <span + className="pl-2 text-xs text-[#1677ff] cursor-pointer" + onClick={() => { + let customerId = form.getFieldValue('erpCustomerId'); + if (typeof customerId === 'string') { + setCustomer({ ...customer, id: customerId }); + } else { + setCustomer({ ...customer, id: customerId.id }); + } + setKingdeeCstomerModalVisible(true); + }} + > + 编辑客户信息 + </span> + </> + } + placeholder="请选择客户" + rules={[{ required: true, message: '客户必填' }]} + onChange={(_, option) => { + //新增客户 + if (option.type === 'add') { + setCustomer({ name: option.name }); + setKingdeeCstomerModalVisible(true); + return; + } + autoFillCustomerContactSelectOptions(option.id); + }} + initialValue={{ + label: data?.erpCustomerName, + value: data?.customerId, + id: data?.customerId, + }} + fieldProps={{ + optionItemRender(item) { + if (item.type === 'add') { + return ( + <div title={item.name + '(新增客户)'}> + <span style={{ color: '#333333' }}>{item.name}</span> + {' | '} + <span style={{ color: 'orange' }}>自定义</span> + </div> + ); + } + return ( + <div + title={ + item.name + + ' | ' + + item.customerContactNumber + + ' | ' + + (item.customerShippingAddress === undefined + ? '无地址' + : item.customerShippingAddress) + + ' | ' + + item.institutionContactName + + ' | ' + + item.institution + } + > + <span style={{ color: '#333333' }}>{item.name}</span> + </div> + ); + }, + }} + debounceTime={1000} + request={async (value, {}) => { + const keywords = value.keyWords; + const res = await postKingdeeRepCustomer({ + data: { search: keywords }, + }); + console.log(res); + + let options = res?.rows?.map((c: any) => { + return { + ...c, + label: c.name, + value: c.id, + key: c.id, + }; + }); + + //第一个商品默认为要新增客户 + if (keywords.trim() !== '') { + options.unshift({ + name: keywords, + type: 'add', + label: keywords, + value: 3.1415926, + key: keywords, + }); + } + return options; + }} + /> + <ProFormSelect + key="customerName" + label="收货人" + width="lg" + showSearch + name="customerName" + placeholder="请选择收货人" + rules={[{ required: true, message: '收货人必填' }]} + onChange={(_, option) => { + autoFillCustomerInfo(option); + }} + initialValue={data.contactAddress} + options={productCustomerContactOptions} + /> + <ProFormText + width="lg" + key="customerContactNumber" + name="customerContactNumber" + label="联系方式" + placeholder="请输入联系方式" + rules={[{ required: true, message: '联系方式必填' }]} + disabled + /> + <ProFormText + width="lg" + key="institution" + name="institution" + label="单位" + placeholder="请输入单位" + rules={[{ required: true, message: '单位必填' }]} + disabled + /> + <ProFormText + width="lg" + key="institutionContactName" + name="institutionContactName" + label="课题组" + placeholder="请输入课题组" + rules={[{ required: true, message: '课题组必填' }]} + disabled + /> + <ProFormTextArea + width="lg" + key="customerShippingAddress" + name="customerShippingAddress" + label="收货地址" + placeholder="请输入收货地址" + rules={[{ required: true, message: '收货地址必填' }]} + disabled + /> + <div id="total-payment"> + <ProFormDigit + name="totalPayment" + width="lg" + key="totalPayment" + label="支付总额(¥)" + rules={[{ required: true, message: '支付总额必填' }]} + tooltip="点击计算,合计所有子订单金额" + fieldProps={{ + addonAfter: ( + <Button + className="rounded-l-none" + type="primary" + onClick={computeTotalPayment} + > + 计算 + </Button> + ), + }} + // disabled={mainInfoDisbled} + /> + </div> + + <ProFormSelect + placeholder="请输入支付渠道" + name="paymentChannel" + width="lg" + key="paymentChannel" + label="支付渠道" + options={enumToSelect(PAYMENT_CHANNEL_OPTIONS)} + rules={[{ required: true, message: '支付渠道必填' }]} + // disabled={mainInfoDisbled} + /> + <ProFormSelect + placeholder="请输入支付方式" + name="paymentMethod" + width="lg" + key="paymentMethod" + label="支付方式" + options={enumToSelect(PAYMENT_METHOD_OPTIONS)} + rules={[{ required: true, message: '支付方式必填' }]} + // disabled={mainInfoDisbled} + /> + <ProFormSelect + placeholder="选择是否需要开票" + name="invoicingStatus" + width="lg" + key="invoicingStatus" + label="是否需要开票" + options={getInvoicingSelect()} + // disabled={mainInfoDisbled} + onChange={(_, option) => { + setInvoicingStatus(option.value); + if (option.value === 'UN_INVOICE') { + form.setFieldValue('invoiceIdentificationNumber', undefined); + form.setFieldValue('bank', undefined); + form.setFieldValue('bankAccountNumber', undefined); + } + }} + rules={[{ required: true, message: '是否需要开票必填' }]} + /> + <ProFormText + width="lg" + name="invoiceIdentificationNumber" + label="开票信息" + key="invoiceIdentificationNumber" + // disabled={mainInfoDisbled} + hidden={invoicingStatus === 'UN_INVOICE'} + placeholder="请输入开票信息" + rules={[ + { + required: invoicingStatus === 'UN_INVOICE' ? false : true, + message: '开票信息必填', + }, + ]} + /> + + {getUserInfo().roleSmallVO?.code === 'admin' ? ( + <ProFormDateTimePicker + width="lg" + key="invoicingTime" + name="invoicingTime" + // disabled={mainInfoDisbled} + hidden={invoicingStatus === 'UN_INVOICE'} + label="开票时间" + placeholder="请输入开票时间" + /> + ) : ( + '' + )} + <ProFormText + width="lg" + name="bank" + key="bank" + label="开户银行" + // disabled={mainInfoDisbled} + hidden={invoicingStatus === 'UN_INVOICE'} + placeholder="请输入开户银行" + /> + <ProFormText + width="lg" + key="bankAccountNumber" + name="bankAccountNumber" + hidden={invoicingStatus === 'UN_INVOICE'} + label="银行账号" + // disabled={mainInfoDisbled} + placeholder="请输入银行账号" + /> + <ProFormTextArea + width="lg" + name="notes" + label="备注" + key="notes" + // disabled={mainInfoDisbled} + placeholder="请输入备注" + rules={[ + { + max: 120, // 最大长度为120个字符 + message: '备注不能超过120个字符', + }, + ]} + /> + + <h2>商品信息</h2> + <ProFormList + creatorButtonProps={{ disabled: false }} + name="list" + label="" + copyIconProps={false} //复制按钮不显示 + initialValue={[ + { + productCode: '', + productName: '', + quantity: '', + productPrice: '', + parameters: '', + subOrderPayment: '', + }, + ]} + actionGuard={{ + beforeRemoveRow: async (index) => { + return new Promise((resolve) => { + if (index === 0) { + message.error('第一行数据不能删除'); + resolve(false); + return; + } + resolve(true); + }); + }, + }} + itemRender={(doms, listMeta) => { + if (optType('edit')) { + let i = 0; + let defaultFileList = listMeta.record?.listAnnex?.map((annex) => { + return { + uid: i++, + name: annex, + status: 'uploaded', + url: annex, + response: { data: [annex] }, + }; + }); + fileList[listMeta.index] = defaultFileList; + } + let itemFileList = fileList[listMeta.index]; + return ( + <ProCard + bordered + extra={doms.action} + title={'商品' + (listMeta.index + 1)} + style={{ + marginBlockEnd: 8, + }} + > + {[ + <ProFormText + key={'material' + listMeta.index} + name="materialId" + hidden + ></ProFormText>, + <ProFormSelect + key="key" + label="商品名称" + width="lg" + showSearch + name="productName" + // options={options} + placeholder="请搜索商品" + rules={[{ required: true, message: '商品名称必填' }]} + onChange={(_, option) => { + autoFillProductInfo(option, listMeta, listMeta.index); + }} + initialValue={{ + label: listMeta?.record?.productName, + value: listMeta?.record?.materialId, + }} + fieldProps={{ + optionItemRender(item) { + if (item.type === 'add') { + return ( + <div title={item.name + '(新增商品信息)'}> + <span style={{ color: '#333333' }}> + {item.label} + </span> + {' | '} + <span style={{ color: 'orange' }}>新增商品</span> + </div> + ); + } + return ( + <div + title={ + item.label + + ' | ' + + (item.model === undefined + ? '无参数' + : item.model) + + ' | ' + + item.base_unit_name + } + > + <span style={{ color: '#333333' }}> + {item.label} + </span> + {' | '} + <span style={{ color: '#339999' }}> + {item.model === undefined ? '无参数' : item.model} + </span> + {' | '} + <span style={{ color: '#666666' }}> + {item.base_unit_name === undefined + ? '无单位' + : item.base_unit_name} + </span> + </div> + ); + }, + }} + debounceTime={1000} + request={async (value) => { + const keywords = value.keyWords; + const res = await postKingdeeRepMaterial({ + data: { search: keywords }, + }); + let options = res?.rows?.map((p: any) => { + return { + ...p, + label: p.name, + value: p.id + '|' + p.name, + key: p.id, + }; + }); + + //第一个商品默认为要新增的商品 + if (keywords.trim() !== '') { + options.unshift({ + productName: keywords, + type: 'add', + label: keywords, + value: 13 + '|' + keywords, + key: keywords, + }); + } + return options; + }} + />, + <ProFormText + key={'productCode' + listMeta.index} + width="lg" + name="productCode" + disabled + label={ + <> + <span>商品编码</span> + <span className="pl-2 text-xs text-gray-400"> + 新增商品时,商品编码由系统自动生成 + </span> + </> + } + placeholder="商品编码" + />, + // <ProFormSelect + // key="inv_stock" + // placeholder="请选择仓库" + // name="invStockId" + // width="lg" + // label="仓库" + // options={productInvStockOptionsList[listMeta.index]} + // />, + <ProFormText + key={'parameters' + listMeta.index} + width="lg" + name="parameters" + label="商品参数" + placeholder="请输入商品参数" + rules={[{ required: true, message: '商品参数必填' }]} + disabled={ + productParametersDisabledFlagList[listMeta.index] !== + false + } + />, + <ProFormDigit + key={'quantity' + listMeta.index} + width="lg" + name="quantity" + label="商品数量" + fieldProps={{ + onChange: (value) => { + listMeta.record.quantity = value; + computeSubOrderPayment(listMeta); + }, + }} + placeholder="请输入商品数量" + rules={[{ required: true, message: '商品数量必填' }]} + />, + + <ProFormDigit + key={'productPrice' + listMeta.index} + width="lg" + name="productPrice" + label="商品单价" + fieldProps={{ + onChange: (value) => { + listMeta.record.productPrice = value; + computeSubOrderPayment(listMeta); + }, + }} + placeholder="请输入商品单价" + rules={[{ required: true, message: '商品单价必填' }]} + />, + + <ProFormSelect + key="unitId" + placeholder="请选择单位" + name="unitId" + width="lg" + label="单位" + showSearch + onChange={(_, option) => { + autoFillUnit(option, listMeta.index); + }} + options={productUnitOptionsList[listMeta.index]} + rules={[{ required: true, message: '商品单位必填' }]} + />, + <ProFormText + key={'unit' + listMeta.index} + width="lg" + name="unit" + label="商品单位" + placeholder="请输入商品单位" + rules={[{ required: true, message: '商品单位必填' }]} + hidden + />, + + <ProFormDigit + width="lg" + key={'subOrderPayment' + listMeta.index} + name="subOrderPayment" + label="子订单金额" + placeholder="请输入子订单金额" + tooltip="商品数量和单价变化后会自动计算子订单金额" + rules={[{ required: true, message: '子订单金额必填' }]} + />, + <ProFormSelect + key={'productBelongBusiness' + listMeta.index} + placeholder="请输入所属事业部" + name="productBelongBusiness" + width="lg" + label="所属事业部" + options={enumToSelect(PRODUCT_BELONG_DEPARTMENT_OPTIONS)} + initialValue={'EXPERIMENTAL_CONSUMABLES'} + rules={[{ required: true, message: '所属事业部必填' }]} + // disabled={mainInfoDisbled} + />, + <ProFormTextArea + key={'notes' + listMeta.index} + width="lg" + name="notes" + label={ + <div> + <span>备注</span> + <span className="pl-2 text-xs text-gray-400"> + 备注将体现在出货单上,请将需要仓管看见的信息写在备注上,例如需要开收据等信息。 + </span> + </div> + } + placeholder="请输入备注" + rules={[ + { + max: 120, // 最大长度为120个字符 + message: '备注不能超过120个字符', + }, + ]} + />, + <> + <ProFormUploadDragger + key={'filePaths' + listMeta.index} + label="附件" + name="filePaths" + action="/api/service/order/fileProcess" + fieldProps={{ + headers: { + Authorization: localStorage.getItem('token'), + }, + itemFileList, + }} + /> + </>, + ]} + </ProCard> + ); + }} + actionRef={actionRef} + ></ProFormList> + </DrawerForm> + + {kingdeeCstomerModalVisible && ( + <KingdeeCustomerModal + setVisible={setKingdeeCstomerModalVisible} + data={customer} + onClose={(customerId: any) => { + setKingdeeCstomerModalVisible(false); + //回显已经新建好的客户 + autoFillCustomerContactSelectOptions(customerId); + }} + /> + )} + </> + ); +}; diff --git a/src/pages/Order/OrderList/OrderDrawer.tsx b/src/pages/Order/OrderList/OrderDrawer.tsx new file mode 100644 index 0000000..e514914 --- /dev/null +++ b/src/pages/Order/OrderList/OrderDrawer.tsx @@ -0,0 +1,2017 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postCanrdApiUserAddressList, + postCanrdApiUserDetail, + postCanrdApiUserNowMoneyCheck, + postDistrictSelectByLevel, + postDistrictSelectByNameAndLevel, + postDistrictSelOrderProvince, + postKingdeeRepCustomerDetail, + postKingdeeRepMaterial, + postKingdeeRepMaterialUnit, + postKingdeeRepMeasureUnit, + postPrepaidPhoneAvailableList, + postResearchGroupsNameSet, + postServiceOrderAddOrder, + postServiceOrderAfterSalesQuerySnapshotOrder, + postServiceOrderApplyAfterSales, + postServiceOrderApplyModify, + postServiceOrderUpdateOrder, +} from '@/services'; +import { + enumToSelect, + FloatAdd, + FloatMul, + getAliYunOSSFileNameFromUrl, + getUserInfo, +} from '@/utils'; +import { getTeacherCustomFieldNumber } from '@/utils/kingdee'; +import { getSalesCodeOptions } from '@/utils/order'; +import { getDefaultString } from '@/utils/StringUtil'; +import { + DrawerForm, + FormListActionType, + ProCard, + ProFormDateTimePicker, + ProFormDigit, + ProFormList, + ProFormSelect, + ProFormText, + ProFormTextArea, + ProFormUploadDragger, +} from '@ant-design/pro-components'; +import { Button, Form, message, Modal } from 'antd'; +import { cloneDeep } from 'lodash'; +import { useEffect, useRef, useState } from 'react'; +import { + AFTE_SALES_PLAN_OPTIONS, + INVOCING_STATUS_OPTIONS, + INVOCING_STATUS_OPTIONS_OLD, + PAYEE_OPTIONS, + PAYMENT_CHANNEL_OPTIONS, + PAYMENT_METHOD_OPTIONS, + PRODUCT_BELONG_DEPARTMENT_OPTIONS, + SHIPPING_WAREHOUSE_OPTIONS, +} from '../constant'; +import KingdeeCustomerModal from './KingdeeCustomerModal'; + +export default ({ onClose, data, subOrders, orderOptType }) => { + const [invoicingStatus, setInvoicingStatus] = useState(''); + const [salesCodeOptions, setSalesCodeOptions] = useState([]); + const [submitBtnLoading, setSubmitBtnLoading] = useState(false); + const [drawerTitle, setDrawerTitle] = useState(''); + const [hasLocalData, setHasLocalData] = useState(false); + // const [customer, setCustomer] = useState({}); + const [localSaveLoading, setLocalSaveLoading] = useState(false); + const [kingdeeCstomerModalVisible, setKingdeeCstomerModalVisible] = + useState(false); + const [paymentMethod, setPaymentMethod] = useState(''); + const [customerRequestCount, setCustomerRequestCount] = useState(0); + const [ + productParametersDisabledFlagList, + setProductParametersDisabledFlagList, + ] = useState([]); + // const [productInvStockOptionsList, setProductInvStockOptionsList] = useState( + // [], + // ); //商品的仓库选项 + const [productUnitOptionsList, setProductUnitOptionsList] = useState([]); //商品的单位选项 + //省市区 + const [province, setProvince] = useState(''); + const [city, setCity] = useState(''); + const [district, setDistrict] = useState(''); + // const [productCustomerContactOptions, setProductCustomerContactOptions] = + // useState([]); //客户的收货人选项 + const [form] = Form.useForm<{ + isLocalData: boolean; + salesCode: ''; + customerName: ''; + customerContactNumber: ''; + institution: ''; + institutionContactName: ''; + customerShippingAddress: ''; + totalPayment: ''; + paymentChannel: ''; + paymentMethod: ''; + productBelongBusiness: ''; + invoicingStatus: ''; + invoiceIdentificationNumber: ''; + invoicingTime: ''; + bank: ''; + bankAccountNumber: ''; + deleteSubOrderLists: []; + filePaths: []; + notes: ''; + invoiceFirst: boolean; + list: [ + { + productCode: ''; + productName: ''; + quantity: ''; + productPrice: ''; + parameters: ''; + subOrderPayment: ''; + unit: ''; + serialNumber: ''; + notes: ''; + }, + ]; + }>(); + const [accountOptions, setAccountOptions] = useState<any>([]); + + let copyData = cloneDeep(data); + + let originSubOrders = cloneDeep(subOrders); + + /** + * 获取当前的操作类型boolean值 + * @param type 操作类型,如果与当前匹配返回true + */ + function optType(type: string) { + return orderOptType === type; + } + + /** + * 获取销售代码枚举,在复制和编辑的时候判断是否为旧的代码 + */ + const loadSalesCodeOptions = async () => { + let options = await getSalesCodeOptions(); + setSalesCodeOptions(options); + + if (optType('copy') || optType('edit')) { + let includeFlag = false; + //销售代码校验,如果是旧的销售代码,则提示并清空 + for (let option of options) { + if (option.value === copyData.salesCode) { + includeFlag = true; + } + } + + if (!includeFlag) { + form.resetFields(['salesCode']); + message.warning('检测到销售代码为旧的,已清空,请重新选择'); + } + } + }; + + /** + * 选择客户后自动为收货人Select添加选项,填充课题组和单位信息 + * @param option 客户选项 + */ + async function autoFillCustomerContactSelectOptions(customerId: any) { + //查询单位详细信息 + let res = await postKingdeeRepCustomerDetail({ + data: { + id: customerId, + }, + }); + + //erp客户名称 + form.setFieldValue('erpCustomerName', res?.name); + + //重新设置当前option + form.setFieldValue('erpCustomerId', { + label: res?.name, + value: res?.id, + id: res?.id, + }); + + //查询客户自定义字段,课题组 + let entity_number = await getTeacherCustomFieldNumber(); + + //在单位详细信息中拿到自定义字段的值 + let customField = res?.custom_field; + if (customField) { + let teacherName = customField[entity_number]; + //填充到课题组老师表单字段中 + form.setFieldValue('institutionContactName', teacherName); + } + + //单位名称,从客户名称中获取,客户名称规则<单位名称>-<联系人名称和电话> + let namePortions = res?.name?.split('-'); + if (namePortions && namePortions.length >= 2) { + form.setFieldValue('institution', namePortions[0]); + } + + //如果原来的收货信息没有包含在这次查询出来的收货人选项中,那么清除原来的收货人信息 + let existFlag = false; + + //填充收货人选项 + // let newProductCustomerContactOptions = res?.bomentity?.map((item) => { + // let address = + // item.contact_person + ',' + item.mobile + ',' + item.contact_address; + // if (address === data.contactAddress) { + // existFlag = true; + // } + // return { ...item, label: address, value: address }; + // }); + + // setProductCustomerContactOptions(newProductCustomerContactOptions); + + if (!existFlag) { + //清空原来的收货人信息 + form.setFieldValue('customerShippingAddress', undefined); + form.setFieldValue('customerContactNumber', undefined); + form.setFieldValue('customerName', undefined); + form.setFieldValue('erpCustomerAddress', undefined); + } + } + + /** + * 回显金蝶信息 + */ + // async function showKindeeInfo() { + // //客户信息 + // if (copyData.customerId) { + // //客户回显 + // autoFillCustomerContactSelectOptions(copyData.customerId); + // } + + // //商品单位回显 + // let list = copyData?.subOrderInformationLists; + // if (list) { + // let newProductUnitOptionsList = [...productUnitOptionsList]; + // for (let i = 0; i < list.length; i++) { + // newProductUnitOptionsList[i] = [ + // { label: list[i].unit, value: list[i].unitId }, + // ]; + // } + // setProductUnitOptionsList(newProductUnitOptionsList); + // } + // } + + /** + * 加载预存账号的options + */ + async function loadAccountOptions(phone: any) { + let newAccountOptions = []; + //预存账号id + let uid = copyData.prepaidUid; + let res = await postCanrdApiUserDetail({ data: { uid: uid } }); + if (res && res.result === RESPONSE_CODE.SUCCESS && res.data !== null) { + let uidDetail = res.data; + uidDetail.value = uid; + uidDetail.label = uidDetail.realName; + newAccountOptions.push(uidDetail); + } + + // 查询当前手机号允许使用的预存账号 + if (phone) { + let res = await postPrepaidPhoneAvailableList({ data: { phone: phone } }); + if (res && res.result === RESPONSE_CODE.SUCCESS) { + let uidDetails = res.data; + for (let detail of uidDetails) { + detail.value = detail.uid; + detail.label = detail.realName; + newAccountOptions.push(detail); + } + } + } + + console.log(newAccountOptions); + setAccountOptions(newAccountOptions); + } + + /** + * 构建回显数据 + */ + function buildOrderData() { + // let mainInfoDisbled = optType('edit'); + if (!optType('add')) { + if (subOrders !== undefined && subOrders.length > 0) { + copyData.subOrderInformationLists = subOrders; + } + + //如果是复制,需要开票,不回显是否需要开票字段 + if (optType('copy')) { + if (copyData.invoicingStatus === 'INVOICED') { + copyData.invoicingStatus = undefined; + + //复制的时候,如果是不需要开票,要把开票信息清空 + if (copyData.invoicingStatus === 'UN_INVOICE') { + copyData.invoiceIdentificationNumber = undefined; + } + } + } + //主订单事业部默认显示子订单第一条的事业部 + copyData.productBelongBusiness = + copyData.subOrderInformationLists[0].productBelongBusiness; + copyData.paymentMethod = + copyData.subOrderInformationLists[0].paymentMethod; + copyData.paymentChannel = + copyData.subOrderInformationLists[0].paymentChannel; + copyData.invoicingStatus = + copyData.subOrderInformationLists[0].invoicingStatus; + + copyData.customerNameString = copyData.customerName; + + setPaymentMethod(copyData.paymentMethod); + + //子订单数据处理:子订单在表单中的命名为list + let i = 0; + let newList = copyData.subOrderInformationLists?.map((item) => { + item.filePaths = item.listAnnex?.map((path) => { + return { + uid: i++, + name: getAliYunOSSFileNameFromUrl(path), + status: 'uploaded', + url: path, + response: { data: [path] }, + }; + }); + return item; + }); + + copyData['list'] = newList; + + //发货仓库处理 + for (let listItem of copyData.list) { + if (listItem.shippingWarehouse === null) { + listItem.shippingWarehouse = 'DALANG_WAREHOUSE'; + } + } + setInvoicingStatus(copyData.invoicingStatus); + form.setFieldsValue({ ...copyData }); + //如果是新建,需要清空list + if (optType('add')) { + form.resetFields(['list']); + } + + if (!optType('after-sales-check')) { + // showKindeeInfo(); + } + + loadAccountOptions(form.getFieldValue('customerContactNumber')); + } + } + + /** + * 获取旧订单信息 + * @param id + */ + async function getOldOrderData(id: any) { + let res = await postServiceOrderAfterSalesQuerySnapshotOrder({ + data: { + mainOrderId: id, + }, + }); + + copyData = res.data.mainOrder; + copyData.subOrderInformationLists = res.data.subOrders; + originSubOrders = res.data.subOrders; + + //客户显示 + form.setFieldValue('erpCustomerId', { + label: copyData.erpCustomerName, + value: copyData.customerId, + }); + + buildOrderData(); + } + + /** + * + * @returns 获取开票选项 + */ + function getInvoicingSelect() { + if (optType('edit') || optType('after-sales-check')) { + return enumToSelect(INVOCING_STATUS_OPTIONS_OLD); + } + return enumToSelect(INVOCING_STATUS_OPTIONS); + } + + const fileList: any = []; + + useEffect(() => { + //弹窗标题 + if (optType('add')) { + setDrawerTitle('新增订单'); + } + if (optType('copy')) { + setDrawerTitle('复制订单'); + } + if (optType('edit')) { + setDrawerTitle('修改订单'); + } + if (optType('after-sales')) { + setDrawerTitle('申请售后'); + } + if (optType('after-sales-check')) { + setDrawerTitle('订单信息'); + } + if (optType('order-change-normal')) { + setDrawerTitle('申请修改'); + } + }, []); + + const actionRef = useRef< + FormListActionType<{ + name: string; + }> + >(); + + useEffect(() => { + form.setFieldsValue({ ...data }); + //如果是新建,需要清空list + if (optType('add')) { + form.resetFields(['list']); + } + }, [data]); + + /** + * 所属部门修改事件 + * 如果选择实验耗材事业部,那么发货仓库默认是大朗仓库 + * @param val + */ + function productBelongBusinessChange(val: any, index: any) { + if (val === 'EXPERIMENTAL_CONSUMABLES') { + let list = form.getFieldValue('list'); + let currentData = list[index]; + if (currentData) { + currentData.shippingWarehouse = 'DALANG_WAREHOUSE'; + form.setFieldValue('list', list); + message.info('已默认选择大朗仓库'); + } + } + } + + /** + * + * @param option 商品名称所对应的商品数据 + * @param currentRowData list中当前行的数据 + */ + async function autoFillProductInfo( + option: any, + currentRowData: any, + index: any, + ) { + let newProductParametersDisabledFlagList = [ + ...productParametersDisabledFlagList, + ]; + let newProductUnitOptionsList = [...productUnitOptionsList]; + newProductUnitOptionsList[index] = []; + + //是新增商品 + if (option.type === 'add') { + //商品参数开放权限可以编辑 + newProductParametersDisabledFlagList[index] = false; + + //清空商品信息 + let copyList = form.getFieldValue('list'); + let currentData = copyList[index]; + currentData.productCode = undefined; + currentData.parameters = undefined; + currentData.unit = undefined; + currentData.subOrderPayment = undefined; + currentData.quantity = undefined; + currentData.notes = undefined; + currentData.productPrice = undefined; + + currentData.unitId = undefined; + currentData.materialId = undefined; + form.setFieldValue('list', copyList); + + //todo 查询计量单价列表 + if (false) { + let res = await postKingdeeRepMeasureUnit({ data: {} }); + if (res && res?.rows) { + for (let row of res?.rows) { + newProductUnitOptionsList[index].push({ + label: row.name, + value: row.id, + }); + } + } + } + } else { + //选择的是已有的商品,进行内容自动填充 + let copyList = form.getFieldValue('list'); + let currentData = copyList[index]; + currentData.productCode = option?.number; + currentData.parameters = option?.model; + currentData.unit = option?.base_unit_name; + + //商品id + currentData.materialId = option?.id; + + //单位 + currentData.unit = option.base_unit_name; + currentData.unitId = option.base_unit_id; + + form.setFieldValue('list', copyList); + + //商品所在的仓库选项填充 + // let res = await postKingdeeRepMaterialStock({ + // data: { + // material_id: option.id, + // }, + // }); + // let newProductInvStockOptionsList = [...productInvStockOptionsList]; + // newProductInvStockOptionsList[index] = res?.rows?.map((item) => { + // return { label: item.inv_stock, value: item.inv_stock_id }; + // }); + // setProductInvStockOptionsList(newProductInvStockOptionsList); + + //商品单位填充,查询商品单位列表 + let res = await postKingdeeRepMaterialUnit({ + data: { material_id: option.id }, + }); + if (res && res.rows) { + for (let row of res.rows) { + newProductUnitOptionsList[index].push({ + label: row.unit_name, + value: row.unit_id, + }); + } + } + //商品参数不允许编辑 + newProductParametersDisabledFlagList[index] = true; + } + + setProductParametersDisabledFlagList(newProductParametersDisabledFlagList); + setProductUnitOptionsList(newProductUnitOptionsList); + } + + /** + * 选择收货人后自动填充信息 + * @param option 收货人信息 + */ + async function autoFillCustomerInfo(option: any) { + if (option === undefined || option === null || option.type === 'add') { + form.setFieldValue('customerShippingAddress', undefined); + form.setFieldValue('customerContactNumber', undefined); + form.setFieldValue('institution', undefined); + form.setFieldValue('institutionContactName', undefined); + form.setFieldValue('customerShippingAddress', undefined); + + if (option !== undefined && option !== null) { + form.setFieldValue('customerNameString', option.name); + } + } else { + form.setFieldValue('customerShippingAddress', option.fullAddress); + form.setFieldValue('customerContactNumber', option.phone); + form.setFieldValue('institution', option.institution); + form.setFieldValue( + 'institutionContactName', + option.institutionContactName, + ); + form.setFieldValue( + 'customerShippingAddress', + getDefaultString(option.province) + + getDefaultString(option.city) + + getDefaultString(option.district) + + getDefaultString(option.detail), + ); + form.setFieldValue('customerNameString', option.realName); + + loadAccountOptions(option.phone); + } + + //erp收货地址:需要与客户联系人中的地址一样:姓名,手机号,地址 + // form.setFieldValue('contactAddress', option.value); + } + + /** + * 填充销售代表的信息 + * @param option + */ + function autoFillSalesInfo(option: any) { + //销售代表对应职员编码填充 + form.setFieldValue('empNumber', option.number); + } + + /** + * todo 选择商品单位后自动填充 + * @param option + * @param index + */ + // function autoFillUnit(option: any, index: any) { + // let copyList = form.getFieldValue('list'); + // let currentData = copyList[index]; + // currentData.unit = option?.label; + // form.setFieldValue('list', copyList); + // } + + /** + * 计算子订单金额 + * @param listMeta 当前商品信息 + */ + function computeSubOrderPayment(listMeta: any) { + let quantity = listMeta?.record?.quantity; + let productPrice = listMeta?.record?.productPrice; + quantity = quantity === '' || quantity === undefined ? 0 : quantity; + productPrice = + productPrice === '' || productPrice === undefined ? 0 : productPrice; + quantity = parseInt(quantity); + productPrice = parseFloat(productPrice); + + listMeta.subOrderPayment = FloatMul(quantity, productPrice); + let list = form.getFieldValue('list'); + list[listMeta?.index].subOrderPayment = FloatMul(quantity, productPrice); + form.setFieldValue('list', list); + } + + /** + * 计算支付总额 + */ + function computeTotalPayment() { + let list = form.getFieldValue('list'); + let totalPayment = 0; + list?.forEach((subOrder: any) => { + let subOrderPayment = subOrder?.subOrderPayment; + if (subOrderPayment !== '' && subOrderPayment !== undefined) { + totalPayment = FloatAdd(subOrderPayment, totalPayment); + } + }); + form.setFieldValue('totalPayment', totalPayment); + } + + /** + * 检查用户额度 + * @param option + */ + const checkAccountMoney = async (uid: any, subPrice: any) => { + let res = await postCanrdApiUserNowMoneyCheck({ + data: { uid: uid, subPrice: subPrice }, + }); + if (res && res.result === RESPONSE_CODE.SUCCESS && res.data) { + let data = res.data; + let isCredit = data.isCredit; + if (isCredit) { + return true; + } + + message.error( + '用户余额不足,当前预减的金额为:' + + data.subPrice + + ',当前账号余额为:' + + data.nowMoney + + ',当前账号可赊账额度为:' + + data.creditLimit, + ); + return false; + } + + return false; + }; + + /** + * 总金额改变触发事件 + * 如果是预存单,需要检查余额 + * @param value + */ + const totalPaymentChange = (value: any) => { + let paymentMethod = form.getFieldValue('paymentMethod'); + let prepaidUid = form.getFieldValue('prepaidUid'); + if ( + value && + paymentMethod && + paymentMethod === 'WITHHOLDING_ADVANCE_DEPOSIT' && + prepaidUid + ) { + let valid = checkAccountMoney(prepaidUid, value); + if (!valid) { + form.setFieldValue('prepaidUid', undefined); + } + } + }; + + /** + * 检查客户是否可以编辑 + * @returns + */ + // const customerEditable = () => { + // let erpCustomerId = form.getFieldValue('erpCustomerId'); + // if ( + // optType('after-sales-check') || + // erpCustomerId === null || + // erpCustomerId === undefined + // ) { + // return false; + // } + + // return true; + // }; + + /** + * 是否有草稿 + */ + function checkHasLocalData() { + let preOrderData = localStorage.getItem('preOrderData'); + let hasLocalData = + preOrderData !== null && + preOrderData !== undefined && + preOrderData !== ''; + setHasLocalData(hasLocalData); + return hasLocalData; + } + + /** + * 保存表单数据到本地 + */ + function saveFormDataToLocal() { + let preOrderData = localStorage.getItem('preOrderData'); + let values = form.getFieldsValue(); + values.isLocalData = true; //标识为本地草稿数据 + let formData = JSON.stringify(values); + + //检查本地是否已有数据 + if (preOrderData) { + Modal.confirm({ + title: '提示', + content: '检测到本地有订单数据,是否覆盖?', + onOk: () => { + localStorage.setItem('preOrderData', formData); + message.success('本地保存成功'); + }, + onCancel: () => { + message.info('取消保存'); + }, + }); + } else { + localStorage.setItem('preOrderData', formData); + message.success('本地保存成功'); + } + + checkHasLocalData(); + setLocalSaveLoading(false); + } + + /** + * 使用草稿数据 + */ + function useLocalFormData() { + let preOrderData = localStorage.getItem('preOrderData'); + if (preOrderData) { + let formData = JSON.parse(preOrderData); + formData.customerName = { + label: formData.customerNameString, + value: formData.customerName, + }; + console.log(formData); + form.setFieldsValue(formData); + setPaymentMethod(formData.paymentMethod); + } + } + + const validateContactNumber = (_: any, value: any) => { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + const phoneRegex = /^\d{1,11}(-\d{1,11})?$/; + + if (emailRegex.test(value) || phoneRegex.test(value)) { + return Promise.resolve(); + } + return Promise.reject( + new Error('联系方式必须是邮箱或手机号格式(不能包含空格等特殊符号)'), + ); + }; + + /** + * 刪除草稿数据 + */ + function removeLocalFormData() { + localStorage.removeItem('preOrderData'); + } + + useEffect(() => { + checkHasLocalData(); + loadSalesCodeOptions(); + if (optType('after-sales-check')) { + getOldOrderData(data.id); + } else { + buildOrderData(); + } + }, []); + + return ( + <> + <DrawerForm<{ + isLocalData: any; + deleteSubOrderLists: any; + name: string; + company: string; + }> + open + width="35%" + title={drawerTitle} + resize={{ + onResize() { + console.log('resize!'); + }, + maxWidth: window.innerWidth * 0.8, + minWidth: 400, + }} + onFinishFailed={() => { + message.error('表单项存在错误,请检查'); + setSubmitBtnLoading(false); + }} + submitter={{ + render: (props) => { + return [ + <Button + key="cancel" + onClick={() => { + onClose(); + }} + > + 取消 + </Button>, + <Button + key="localSave" + loading={localSaveLoading} + hidden={!optType('add') && !optType('copy')} + onClick={() => { + setLocalSaveLoading(true); + saveFormDataToLocal(); + }} + > + 本地保存 + </Button>, + <Button + key="ok" + type="primary" + loading={submitBtnLoading} + disabled={optType('after-sales-check')} + onClick={() => { + setSubmitBtnLoading(true); + props.submit(); + }} + > + 提交 + </Button>, + ]; + }, + }} + form={form} + autoFocusFirstInput + drawerProps={{ + destroyOnClose: true, + maskClosable: false, + extra: [ + <Button + key="useLocalData" + hidden={!hasLocalData} + type="link" + onClick={() => { + useLocalFormData(); + }} + > + 使用草稿 + </Button>, + ], + }} + submitTimeout={2000} + onFinish={async (values) => { + let res = {}; + //附件处理 + let list = values.list; + // console.log(list); + list = list.map((item) => { + item.filePaths = item.filePaths?.map((file) => { + return { url: file.response.data[0] }; + }); + return item; + }); + + values.list = list; + values.institution = values.institution?.trim(); + values.institutionContactName = values.institutionContactName?.trim(); + values.customerName = values.customerNameString.trim(); + // values.customerShippingAddress = + // province + city + district + values.customerShippingAddress; + + if (typeof values.erpCustomerId !== 'string') { + values.erpCustomerId = values.erpCustomerId?.id; + } + values.province = province; + values.city = city; + values.district = district; + //新增 + if (optType('add') || optType('copy')) { + res = await postServiceOrderAddOrder({ data: values }); + } + //修改或者申请售后或者申请修改 + if ( + optType('edit') || + optType('after-sales') || + optType('order-change-normal') + ) { + //计算已删除的子订单id + + let originIds = []; + if (originSubOrders !== undefined && originSubOrders.length > 0) { + originIds = originSubOrders?.map((item) => { + return item.id; + }); + } + + const curIds = form.getFieldValue('list')?.map((item) => { + return item.id; + }); + let diff = originIds.filter((item) => !curIds.includes(item)); + values.deleteSubOrderLists = diff; + + if (optType('edit')) { + values.province = province; + values.city = city; + values.district = district; + res = await postServiceOrderUpdateOrder({ data: values }); + } + + values.applyType = orderOptType; + if (optType('after-sales')) { + values.filePaths = values.filePaths?.map((file) => { + return { url: file.response.data[0] }; + }); + res = await postServiceOrderApplyAfterSales({ data: values }); + } + + if (optType('order-change-normal')) { + values.filePaths = values.filePaths?.map((file) => { + return { url: file.response.data[0] }; + }); + res = await postServiceOrderApplyModify({ data: values }); + } + } + + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + // 不返回不会关闭弹框 + onClose(true); + + //判断保存的数据是否是本地草稿,是的话将草稿删除 + let isLocalData = form.getFieldValue('isLocalData'); + if (isLocalData) { + removeLocalFormData(); + checkHasLocalData(); + } + + return true; + } + + setSubmitBtnLoading(false); + }} + onOpenChange={(val) => { + return !val && onClose(); + }} + > + {optType('after-sales') ? ( + <> + <h2>售后信息</h2> + <ProFormSelect + key="key" + label="售后方案" + width="lg" + showSearch + name="afterSalesPlan" + options={enumToSelect(AFTE_SALES_PLAN_OPTIONS)} + placeholder="请搜索" + rules={[{ required: true, message: '售后方案必填' }]} + ></ProFormSelect> + <ProFormTextArea + width="lg" + label="售后原因" + name="afterSalesNotes" + rules={[{ required: true, message: '售后原因必填' }]} + /> + <ProFormUploadDragger + key="filePaths" + label="售后附件" + name="filePaths" + action="/api/service/order/fileProcess" + fieldProps={{ + headers: { Authorization: localStorage.getItem('token') }, + }} + /> + </> + ) : ( + '' + )} + + <h2>订单基本信息</h2> + <ProFormText + key="id" + name="id" + width="lg" + disabled + label="id" + placeholder="id" + hidden + /> + <ProFormText + key="empNumber" + name="empNumber" + width="lg" + label="销售职员编码" + placeholder="销售职员编码" + hidden + /> + <ProFormSelect + name="salesCode" + key="salesCode" + width="lg" + showSearch + label="销售代表" + placeholder="请输入销售代表" + rules={[{ required: true, message: '销售代表必填' }]} + options={salesCodeOptions} + onChange={(_, option) => { + autoFillSalesInfo(option); + }} + disabled={optType('after-sales-check')} + /> + <ProFormText + key="erpCustomerName" + name="erpCustomerName" + hidden + ></ProFormText> + <ProFormText + key="customerNameString" + name="customerNameString" + hidden + ></ProFormText> + + <ProFormText + key="contactAddress" + name="contactAddress" + hidden + ></ProFormText> + <ProFormSelect + key="customerName" + label="收货人" + width="lg" + showSearch + name="customerName" + placeholder="请选择收货人" + rules={[{ required: true, message: '收货人必填' }]} + onChange={(_, option) => { + autoFillCustomerInfo(option); + }} + fieldProps={{ + filterOption() { + return true; + }, + optionItemRender(item: any) { + if (item.type === 'add') { + return ( + <div title={item.name + '(新增客户)'}> + <span style={{ color: '#333333' }}>{item.name}</span> + {' | '} + <span style={{ color: 'orange' }}>自定义</span> + </div> + ); + } + + let title = ''; + let realName = item.realName; + let phone = item.phone; + let province = item.province; + let city = item.city; + let district = item.district; + let detail = item.detail; + let institution = item.institution; + let institutionContactName = item.institutionContactName; + + let address = + getDefaultString(province) + + getDefaultString(city) + + getDefaultString(district) + + getDefaultString(detail); + + title = + getDefaultString(realName) + + '|' + + getDefaultString(phone) + + '|' + + getDefaultString(institution) + + '|' + + getDefaultString(institutionContactName) + + '|' + + address; + + return ( + <div title={title} className="whitespace-normal"> + <span style={{ color: '#333333' }}> + {getDefaultString(realName)} + </span> + | + <span className="text-sky-600"> + {getDefaultString(phone)} + </span> + | + <span style={{ color: '#333333' }}> + {getDefaultString(institution)} + </span> + | + <span style={{ color: '#333333' }}> + {getDefaultString(institutionContactName)} + </span> + |<span className="text-orange-400">{address}</span> + </div> + ); + }, + }} + debounceTime={1000} + request={async (value, {}) => { + const keywords = value.keyWords; + if (keywords === '') { + return []; + } + const res = await postCanrdApiUserAddressList({ + data: { keywords: keywords }, + }); + let options = res?.data?.map((c: any) => { + return { + ...c, + label: c.name, + value: c.id, + key: c.id, + }; + }); + console.log(form.getFieldValue('customerShippingAddress')); + console.log(form.getFieldValue('id')); + if (form.getFieldValue('id') !== undefined) { + const resp = await postDistrictSelOrderProvince({ + data: form.getFieldValue('id'), + }); + if (resp && resp.data) { + if (resp.data.province) { + setProvince(resp.data.province); + form.setFieldValue('province', resp.data.province); + } + if (resp.data.city) { + setCity(resp.data.city); + form.setFieldValue('city', resp.data.city); + } + if (resp.data.district) { + setDistrict(resp.data.district); + form.setFieldValue('district', resp.data.district); + } + } + console.log(form.getFieldsValue()); + } + //判断如果是在修改或者复制,那么第一次请求的时候,默认生成当前收货人信息的option + + let realName = form.getFieldValue('customerName'); + let detail = form.getFieldValue('customerShippingAddress'); + let institution = form.getFieldValue('institution'); + let institutionContactName = form.getFieldValue( + 'institutionContactNam', + ); + if (customerRequestCount === 0) { + setCustomerRequestCount(1); + options.push({ + label: realName, + value: realName, + key: realName, + realName: realName, + detail: detail, + institution: institution, + institutionContactName: institutionContactName, + }); + } + //第一个商品默认为要新增客户 + if (keywords.trim() !== '') { + options.unshift({ + name: keywords, + type: 'add', + label: keywords, + value: 3.1415926, + key: keywords, + }); + } + + return options; + }} + /> + + <ProFormText + width="lg" + key="customerContactNumber" + name="customerContactNumber" + label="联系方式" + placeholder="请输入联系方式" + fieldProps={{ + onBlur: (v) => { + loadAccountOptions(v.target.value); + }, + }} + rules={[ + { required: true, message: '联系方式必填' }, + { validator: validateContactNumber }, + ]} + /> + <ProFormText + width="lg" + key="institution" + name="institution" + label="单位" + placeholder="请输入单位" + rules={[{ required: true, message: '单位必填' }]} + /> + {/*<ProFormText + width="lg" + key="institutionContactName" + name="institutionContactName" + label="课题组" + placeholder="请输入课题组" + rules={[{ required: true, message: '课题组必填' }]} + />*/} + <ProFormSelect + key={'institutionContactName'} + width="md" + showSearch + name="institutionContactName" + rules={[{ required: true, message: '请输入课题组名称!' }]} + request={async (value) => { + const keywords = value.keyWords; + const res = await postResearchGroupsNameSet({ + data: { + status: 'ADD_AUDIT_PASS', + groupName: keywords, + }, + }); + let options = res?.data?.map((c: any) => { + return { + label: c, + value: c, + key: c, + }; + }); + return options; + }} + fieldProps={{ + filterOption() { + return true; + }, + }} + debounceTime={1000} + label="课题组名称" + placeholder="请输入名称" + /> + <div + style={{ + display: 'flex', + justifyContent: 'space-between', + width: 340, + }} + > + <ProFormSelect + name="province" + key="province" + width={100} + label="省" + allowClear={false} + fieldProps={{ + labelInValue: true, + }} + onChange={(value) => { + console.log(value); + + if (value !== undefined || value !== null) { + console.log('setProvince'); + + setProvince(value?.value); + } + }} + placeholder="请选择" + rules={[ + { + required: true, + message: '请选择!', + }, + ]} + request={async () => { + let province = []; + let res = await postDistrictSelectByLevel({ data: 1 }); + if (res) { + res.data.forEach((item) => { + province.push({ value: item.district, label: item.district }); + }); + } + return province; + }} + /> + <ProFormSelect + key={province} + name="city" + width={100} + label="市" + allowClear={false} + disabled={province === ''} + fieldProps={{ + labelInValue: true, + }} + placeholder="请选择" + onChange={(value) => { + if (value !== undefined || value !== null) { + setCity(value?.value); + } + }} + rules={[ + { + required: true, + message: '请选择!', + }, + ]} + request={async () => { + let cityOptions = []; + console.log(form.getFieldValue('id')); + if (form.getFieldValue('id')) { + const resp = await postDistrictSelOrderProvince({ + data: form.getFieldValue('id'), + }); + if ( + resp.data.province !== null && + resp.data.province !== undefined + ) { + console.log('province is ok'); + let res = await postDistrictSelectByNameAndLevel({ + data: { district: resp.data.province, level: 1 }, + }); + if (res && res.data) { + cityOptions = res.data.map((item) => ({ + value: item.district, + label: item.district, + })); + } + } + } + if (province !== '') { + console.log(province); + console.log('province is okk'); + let res = await postDistrictSelectByNameAndLevel({ + data: { district: province, level: 1 }, + }); + if (res && res.data) { + cityOptions = res.data.map((item) => ({ + value: item.district, + label: item.district, + })); + } + } + return cityOptions; + }} + /> + <ProFormSelect + key={city ? city.toString() : 'district'} + name="district" + width={100} + label="区" + allowClear={false} + onChange={(value) => { + if (value !== undefined || value !== null) { + setDistrict(value?.value); + } + }} + disabled={city === ''} + fieldProps={{ + labelInValue: true, + }} + placeholder="请选择" + rules={[ + { + required: true, + message: '请选择!', + }, + ]} + request={async () => { + let districtOptions = []; + if (form.getFieldValue('id')) { + const resp = await postDistrictSelOrderProvince({ + data: form.getFieldValue('id'), + }); + if (resp.data.city !== null && resp.data.city !== undefined) { + let res = await postDistrictSelectByNameAndLevel({ + data: { district: resp.data.city, level: 2 }, + }); + if (res && res.data) { + districtOptions = res.data.map((item) => ({ + value: item.district, + label: item.district, + })); + } + } + } + if (city !== '') { + let res = await postDistrictSelectByNameAndLevel({ + data: { district: city, level: 2 }, + }); + if (res && res.data) { + districtOptions = res.data.map((item) => ({ + value: item.district, + label: item.district, + })); + } + } + return districtOptions; + }} + /> + </div> + <ProFormTextArea + width="lg" + key="customerShippingAddress" + name="customerShippingAddress" + label="收货地址" + placeholder="请输入收货地址" + rules={[{ required: true, message: '收货地址必填' }]} + /> + <div id="total-payment"> + <ProFormDigit + name="totalPayment" + width="lg" + key="totalPayment" + label="支付总额(¥)" + rules={[ + { required: true, message: '支付总额必填' }, + { + validator: (_, value) => { + let paymentMethod = form.getFieldValue('paymentMethod'); + if ( + value <= 0 && + paymentMethod && + paymentMethod === 'WITHHOLDING_ADVANCE_DEPOSIT' + ) { + return Promise.reject( + new Error( + '支付总额必须大于0 (扣预存的订单现在也必须填写实际金额)', + ), + ); + } + return Promise.resolve(); + }, + }, + ]} + tooltip="点击计算,合计所有子订单金额" + fieldProps={{ + addonAfter: ( + <Button + className="rounded-l-none" + type="primary" + disabled={optType('after-sales-check')} + onClick={computeTotalPayment} + > + 计算 + </Button> + ), + onChange: (value: any) => { + totalPaymentChange(value); + }, + }} + disabled={optType('after-sales-check')} + /> + </div> + + <ProFormSelect + placeholder="请输入支付渠道" + name="paymentChannel" + width="lg" + key="paymentChannel" + label="支付渠道" + options={enumToSelect(PAYMENT_CHANNEL_OPTIONS)} + rules={[{ required: true, message: '支付渠道必填' }]} + disabled={optType('after-sales-check')} + /> + <ProFormSelect + placeholder="请输入支付方式" + name="paymentMethod" + width="lg" + key="paymentMethod" + label="支付方式" + onChange={(val: any) => { + setPaymentMethod(val); + }} + options={enumToSelect(PAYMENT_METHOD_OPTIONS)} + rules={[{ required: true, message: '支付方式必填' }]} + disabled={optType('after-sales-check')} + /> + <ProFormSelect + name="prepaidUid" + key="prepaidUid" + width="lg" + hidden={paymentMethod !== 'WITHHOLDING_ADVANCE_DEPOSIT'} + showSearch + label="预存账号" + onChange={(value: any) => { + //检查用户额度 + let valid = checkAccountMoney( + value, + form.getFieldValue('totalPayment'), + ); + if (!valid) { + form.setFieldValue('prepaidUid', undefined); + } + }} + placeholder="请选择预存账号" + rules={[ + { + required: paymentMethod === 'WITHHOLDING_ADVANCE_DEPOSIT', + message: '支付方式为扣预存时,预存账号必填', + }, + ]} + fieldProps={{ + filterOption() { + return true; + }, + optionItemRender(item) { + let name = + item.label + + ' | ' + + item.institution + + ' | ' + + item.nowMoney + + '¥' + + ' | ' + + item.phone; + return ( + <div title={name}> + <span style={{ color: '#333333' }}>{name}</span> + </div> + ); + }, + }} + debounceTime={1000} + // request={async (value, {}) => { + // const keywords = value.keyWords; + // const res = await postCanrdApiUserList({ + // data: { keywords: keywords, pageSize: 50 }, + // }); + // let options = res?.data?.data?.map((c: any) => { + // return { + // ...c, + // label: c.realName, + // value: c.uid, + // key: c.uid, + // }; + // }); + // return options; + // }} + options={accountOptions} + /> + <ProFormSelect + placeholder="选择是否需要开票" + name="invoicingStatus" + width="lg" + key="invoicingStatus" + label="是否需要开票" + options={getInvoicingSelect()} + disabled={optType('after-sales-check')} + onChange={(_, option) => { + setInvoicingStatus(option.value); + if (option.value === 'UN_INVOICE') { + form.setFieldValue('invoiceIdentificationNumber', undefined); + form.setFieldValue('bank', undefined); + form.setFieldValue('bankAccountNumber', undefined); + form.setFieldValue('invoiceFirst', false); + } + }} + rules={[{ required: true, message: '是否需要开票必填' }]} + /> + <ProFormSelect + placeholder="是否开票后发货" + name="invoiceFirst" + width="lg" + key="invoiceFirst" + label="是否开票后发货" + disabled={optType('after-sales-check')} + hidden={invoicingStatus === 'UN_INVOICE'} + options={[ + { + value: true, + label: '是', + }, + { + value: false, + label: '否', + }, + ]} + /> + + <ProFormSelect + placeholder="收款单位" + name="receivingCompany" + width="lg" + key="receivingCompany" + showSearch + label="开票收款单位" + tooltip="财务开票将依据这个字段,选择对应的公司开票" + options={enumToSelect(PAYEE_OPTIONS)} + disabled={optType('after-sales-check')} + hidden={invoicingStatus === 'UN_INVOICE'} + /> + + <ProFormTextArea + width="lg" + name="invoiceIdentificationNumber" + label="开票信息" + key="invoiceIdentificationNumber" + disabled={optType('after-sales-check')} + hidden={invoicingStatus === 'UN_INVOICE'} + placeholder="请输入开票信息" + rules={[ + { + required: invoicingStatus === 'UN_INVOICE' ? false : true, + message: '开票信息必填', + }, + ]} + /> + + {getUserInfo().roleSmallVO?.code === 'admin' ? ( + <ProFormDateTimePicker + width="lg" + key="invoicingTime" + name="invoicingTime" + disabled={optType('after-sales-check')} + hidden={invoicingStatus === 'UN_INVOICE'} + label="开票时间" + placeholder="请输入开票时间" + /> + ) : ( + '' + )} + <ProFormText + width="lg" + name="bank" + key="bank" + label="开户银行" + disabled={optType('after-sales-check')} + hidden={invoicingStatus === 'UN_INVOICE'} + placeholder="请输入开户银行" + /> + <ProFormText + width="lg" + key="bankAccountNumber" + name="bankAccountNumber" + hidden={invoicingStatus === 'UN_INVOICE'} + label="银行账号" + disabled={optType('after-sales-check')} + placeholder="请输入银行账号" + /> + <ProFormTextArea + width="lg" + name="notes" + label="备注" + key="notes" + disabled={optType('after-sales-check')} + placeholder="请输入备注" + rules={[ + { + max: 1000, // 最大长度为1000个字符 + message: '备注不能超过1000个字符', + }, + { + validator: (rule, value) => { + let totalPayment = form.getFieldValue('totalPayment'); + let list = form.getFieldValue('list'); + let reduce = list.reduce( + (sum, item) => FloatAdd(sum, item.subOrderPayment), + 0, + ); + if (reduce === totalPayment || value) { + return Promise.resolve(); + } + return Promise.reject(new Error('请填写订单金额不一致的原因')); + }, + }, + ]} + /> + + <h2>商品信息</h2> + <ProFormList + creatorButtonProps={{ disabled: optType('after-sales-check') }} + deleteIconProps={!optType('after-sales-check')} + name="list" + label="" + copyIconProps={false} //复制按钮不显示 + initialValue={[ + { + productCode: '', + productName: '', + quantity: '', + productPrice: '', + parameters: '', + subOrderPayment: '', + }, + ]} + actionGuard={{ + beforeRemoveRow: async () => { + return new Promise((resolve) => { + let list = form.getFieldValue('list'); + if (list && list.length === 1) { + message.error('至少需要保留一个商品'); + resolve(false); + return; + } + resolve(true); + }); + }, + }} + itemRender={(doms, listMeta) => { + if (optType('edit')) { + let i = 0; + let defaultFileList = listMeta.record?.listAnnex?.map((annex) => { + return { + uid: i++, + name: annex, + status: 'uploaded', + url: annex, + response: { data: [annex] }, + }; + }); + fileList[listMeta.index] = defaultFileList; + } + let itemFileList = fileList[listMeta.index]; + return ( + <ProCard + bordered + extra={doms.action} + title={'商品' + (listMeta.index + 1)} + style={{ + marginBlockEnd: 8, + }} + > + {[ + <ProFormText + key={'material' + listMeta.index} + name="materialId" + hidden + ></ProFormText>, + <ProFormSelect + key="key" + label="商品名称" + width="lg" + showSearch + name="productName" + disabled={optType('after-sales-check')} + placeholder="请搜索商品" + tooltip="空格将作为或条件。例如输入[极片 电池],那么查找出来的将是包含[极片]或者包含[电池]的搜索结果" + rules={[{ required: true, message: '商品名称必填' }]} + onChange={(_, option) => { + autoFillProductInfo(option, listMeta, listMeta.index); + }} + initialValue={{ + label: listMeta?.record?.productName, + value: listMeta?.record?.materialId, + }} + fieldProps={{ + filterOption() { + return true; + }, + optionItemRender(item) { + if (item.type === 'add') { + return ( + <div title={item.name + '(新增商品信息)'}> + <span style={{ color: '#333333' }}> + {item.label} + </span> + {' | '} + <span style={{ color: 'orange' }}>新增商品</span> + </div> + ); + } + return ( + <div + title={ + item.label + + ' | ' + + (item.model === undefined + ? '无参数' + : item.model) + + ' | ' + + item.base_unit_name + } + > + <span style={{ color: '#333333' }}> + {item.label} + </span> + {' | '} + <span style={{ color: '#339999' }}> + {item.model === undefined ? '无参数' : item.model} + </span> + {' | '} + <span style={{ color: '#666666' }}> + {item.base_unit_name === undefined + ? '无单位' + : item.base_unit_name} + </span> + </div> + ); + }, + }} + debounceTime={1000} + request={async (value) => { + const keywords = value.keyWords; + const res = await postKingdeeRepMaterial({ + data: { search: keywords }, + }); + console.log(res.customerShippingAddress); + + let options = res?.rows?.map((p: any) => { + return { + ...p, + label: p.name, + value: p.id + '|' + p.name, + key: p.id, + }; + }); + + //第一个商品默认为要新增的商品 + if (keywords.trim() !== '') { + options.unshift({ + productName: keywords, + type: 'add', + label: keywords, + value: 13 + '|' + keywords, + key: keywords, + }); + } + return options; + }} + />, + <ProFormText + key="orderStatus" + name="orderStatus" + width="lg" + disabled + label="orderStatus" + placeholder="orderStatus" + hidden + />, + <ProFormText + key={'productCode' + listMeta.index} + width="lg" + name="productCode" + disabled + label={ + <> + <span>商品编码</span> + <span className="pl-2 text-xs text-gray-400"> + 新增商品时,商品编码由系统自动生成 + </span> + </> + } + placeholder="未输入商品名称" + />, + // <ProFormSelect + // key="inv_stock" + // placeholder="请选择仓库" + // name="invStockId" + // width="lg" + // label="仓库" + // options={productInvStockOptionsList[listMeta.index]} + // />, + <ProFormText + key={'parameters' + listMeta.index} + width="lg" + name="parameters" + label="商品参数" + placeholder="请输入商品参数" + disabled={ + productParametersDisabledFlagList[listMeta.index] !== + false || optType('after-sales-check') + } + />, + <ProFormDigit + key={'quantity' + listMeta.index} + width="lg" + name="quantity" + label="商品数量" + fieldProps={{ + onChange: (value) => { + // 确保变更后的值为整数 + const intValue = parseInt(value, 10); + if (!isNaN(intValue)) { + listMeta.record.quantity = intValue; + computeSubOrderPayment(listMeta); + } + }, + parser: (value) => { + // 将输入的值转换为整数,如果不是合法数字则返回空字符串触发校验错误 + return value ? parseInt(value, 10) : ''; + }, + formatter: (value) => { + // 在显示时始终将其格式化为不带小数部分的整数字符串 + return value ? value.toString() : ''; + }, + }} + placeholder="请输入商品数量" + disabled={optType('after-sales-check')} + rules={[{ required: true, message: '商品数量必填' }]} + />, + <ProFormDigit + key={'productPrice' + listMeta.index} + width="lg" + name="productPrice" + label="商品单价" + fieldProps={{ + onChange: (value) => { + listMeta.record.productPrice = value; + computeSubOrderPayment(listMeta); + }, + }} + placeholder="请输入商品单价" + disabled={optType('after-sales-check')} + rules={[{ required: true, message: '商品单价必填' }]} + />, + <ProFormText + key={'unit' + listMeta.index} + width="lg" + name="unit" + label="商品单位" + placeholder="请输入商品单位" + disabled={ + productParametersDisabledFlagList[listMeta.index] !== + false || optType('after-sales-check') + } + rules={[{ required: true, message: '商品单位必填' }]} + />, + + <ProFormDigit + width="lg" + key={'subOrderPayment' + listMeta.index} + name="subOrderPayment" + label="子订单金额" + placeholder="请输入子订单金额" + tooltip="商品数量和单价变化后会自动计算子订单金额" + disabled={optType('after-sales-check')} + rules={[{ required: true, message: '子订单金额必填' }]} + />, + <ProFormSelect + key={'productBelongBusiness' + listMeta.index} + placeholder="请输入所属事业部" + name="productBelongBusiness" + width="lg" + label="所属事业部" + options={enumToSelect(PRODUCT_BELONG_DEPARTMENT_OPTIONS)} + onChange={(val: any) => { + productBelongBusinessChange(val, listMeta.index); + }} + initialValue={'EXPERIMENTAL_CONSUMABLES'} + rules={[{ required: true, message: '所属事业部必填' }]} + disabled={optType('after-sales-check')} + />, + <ProFormSelect + key={'shippingWarehouse' + listMeta.index} + placeholder="请选择发货仓库" + name="shippingWarehouse" + width="lg" + label="发货仓库" + options={enumToSelect(SHIPPING_WAREHOUSE_OPTIONS)} + disabled={optType('after-sales-check')} + />, + <ProFormTextArea + key={'notes' + listMeta.index} + width="lg" + name="notes" + disabled={optType('after-sales-check')} + label={ + <div> + <span>备注</span> + <span className="pl-2 text-xs text-gray-400"> + 备注将体现在出货单上,请将需要仓管看见的信息写在备注上,例如需要开收据等信息。 + </span> + </div> + } + placeholder="请输入备注" + rules={[ + { + max: 1000, // 最大长度为1000个字符 + message: '备注不能超过1000个字符', + }, + ]} + />, + <> + <ProFormUploadDragger + key={'filePaths' + listMeta.index} + label="附件" + name="filePaths" + action="/api/service/order/fileProcess" + disabled={optType('after-sales-check')} + fieldProps={{ + headers: { + Authorization: localStorage.getItem('token'), + }, + itemFileList, + }} + /> + </>, + ]} + </ProCard> + ); + }} + actionRef={actionRef} + ></ProFormList> + </DrawerForm> + {kingdeeCstomerModalVisible && ( + <KingdeeCustomerModal + setVisible={setKingdeeCstomerModalVisible} + data={customer} + onClose={(customerId: any) => { + setKingdeeCstomerModalVisible(false); + //回显已经新建好的客户 + autoFillCustomerContactSelectOptions(customerId); + }} + /> + )} + </> + ); +}; diff --git a/src/pages/Order/OrderList/OrderList.tsx b/src/pages/Order/OrderList/OrderList.tsx new file mode 100644 index 0000000..f2e02fc --- /dev/null +++ b/src/pages/Order/OrderList/OrderList.tsx @@ -0,0 +1,5235 @@ +import ButtonConfirm from '@/components/ButtomConfirm'; +import { RESPONSE_CODE } from '@/constants/enum'; +import ImportExpressBillModal from '@/pages/Order/OrderList/ImportExpressBillModal'; +import InvoicingDrawerForm from '@/pages/Order/OrderList/InvoicingDrawerForm'; +import ReissueModal from '@/pages/Order/OrderList/ReissueModal'; +import ReissueModal_old from '@/pages/Order/OrderList/ReissueModal_old'; +import { + postKingdeeRepSalBillOutbound, + postKingdeeRepSalOrderSave, + postServiceConstCanApplyAfterInvoicingStatus, + postServiceInvoiceCancelApply, + postServiceOrderCancelSend, + postServiceOrderConfirmInvoice, + postServiceOrderGetCurrentOptNode, + postServiceOrderNoNeedSend, + postServiceOrderOrderCancel, + postServiceOrderProcureOrder, + postServiceOrderProcurePrint, + postServiceOrderProvideProcurementRoles, + postServiceOrderQueryServiceOrder, + postServiceOrderSaleCancelInvoicing, + postServiceOrderSalesConfirm, +} from '@/services'; +import { downloadFile } from '@/services/order'; +import { + FloatAdd, + copyToClipboard, + enumToProTableEnumValue, + enumValueToLabel, + formatDateTime, + formatdate, + getAliYunOSSFileNameFromUrl, + isImageName, +} from '@/utils'; +import { + getReceivingCompanyOptions, + isAdmin, + isExaminer, + isFinance, + isProcure, + isSales, + isSupplier, + isWarehousekeeper, +} from '@/utils/order'; +import { getUserInfo } from '@/utils/user'; +import { + ClockCircleTwoTone, + ContainerTwoTone, + CopyOutlined, + CopyTwoTone, + DownOutlined, + EditTwoTone, + QuestionCircleOutlined, +} from '@ant-design/icons'; +import { + ActionType, + ProColumns, + ProFormInstance, + ProTable, +} from '@ant-design/pro-components'; +import { + Button, + Checkbox, + Divider, + Dropdown, + Flex, + FloatButton, + Image, + MenuProps, + Modal, + Popconfirm, + Radio, + Space, + Spin, + Tag, + Tooltip, + message, +} from 'antd'; +import Base64 from 'base-64'; +import { cloneDeep } from 'lodash'; +import React, { Key, useEffect, useMemo, 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 './AfterSalesDrawer'; +import ApplyForInvoicingModal from './ApplyForInvoicingModal'; +import AttachmentModal from './AttachmentModal'; +import CheckModal from './CheckModal'; +import ConfirmReceiptModal from './ConfirmReceiptModal'; +import DeliverInfoDrawer from './DeliverInfoDrawer'; +import DeliverModal from './DeliverModal'; +import FeedbackRegistrationModal from './FeedbackRegistrationModal'; +import FinancialDrawer from './FinancialDrawer'; +import FinancialEditDrawer from './FinancialEditDrawer'; +import FinancialMergeDrawer from './FinancialMergeDrawer'; +import FinancialReceiptsModal from './FinancialReceiptsModal'; +import HistoryModal from './HistoryModal'; +import ImagesViewerModal from './ImagesViewerModal'; +import ImportModal from './ImportModal'; +import ModifiedDiffModal from './ModifiedDiffModal'; +import OrderDrawer from './OrderDrawer'; +import OrderNotesEditModal from './OrderNotesEditModal'; +import ProcureCheckModal from './ProcureCheckModal'; +import ProcureConvertModal from './ProcureConvertModal'; +import ProductionTimeModal from './ProductionTimeModal'; +import ShippingWarehouseChangeModal from './ShippingWarehouseChangeModal'; +import UploadPayBillModal from './UploadPayBillModal'; +import './index.less'; +import { OrderListItemType, OrderType } from './type.d'; +// import { useNavigate } from 'react-router-dom'; +// import { format } from 'fecha'; + +const OrderList = ({ paramsNew, searchShow, toolbarShow }) => { + const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false); + const [checkVisible, setCheckVisible] = useState<boolean>(false); + const [orderPrintVisible, setOrderPrintVisible] = useState<boolean>(false); + const [allMainChecked, setAllMainChecked] = useState(false); + 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, setFilterCondition] = 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 [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id + const [subOrderCount, setSubOrderCount] = useState(0); + const [sorted, setSorted] = useState(false); + const mainTableRef = useRef<ActionType>(); + const mainTableFormRef = useRef<ProFormInstance>(); + let [searchParams, setSearchParam] = useState(Object); //表格的查询条件存储 + const [messageApi, contextHolder] = message.useMessage(); + const [ + shippingWarehouseChangeModalVisible, + setShippingWarehouseChangeModalVisible, + ] = useState(false); + const [canApplyAfterInvoicingStatus, setCanApplyAfterInvoicingStatus] = + useState([]); + const [ids, setIds] = useState([]); + const [recordOptNode, setRecordOptNode] = useState(null); + const roleCode = userInfo?.roleSmallVO?.code; + const roles = userInfo?.roles; + const [newParams, setNewParams] = useState<any>(); + const canMergeInvoicing = useMemo(() => { + if (subOrderSelectedMap.size === 0) { + return false; + } + // 检查 value.items 中的每个元素 + console.log( + 'map' + JSON.stringify([...subOrderSelectedMap.values()].flat()), + ); + return [...subOrderSelectedMap.values()] + .flat() + .every((subItem) => subItem.paths?.includes('applyInvoicing_old')); + }, [selectedSubOrderKeys]); + + console.log(JSON.stringify(userInfo)); + const triggerRecordOptNode = async (id) => { + const res = await postServiceOrderGetCurrentOptNode({ + query: { + id, + }, + }); + setRecordOptNode(res.data); + }; + + const exportLoading = () => { + messageApi.open({ + type: 'loading', + content: '正在导出文件...', + duration: 0, + }); + }; + + const exportLoadingDestory = () => { + messageApi.destroy(); + }; + + 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); + } + }, []); + + useEffect(() => { + const initEnum = async () => { + let invoiceTypeRet = await postServiceConstCanApplyAfterInvoicingStatus(); + if (invoiceTypeRet.result === RESPONSE_CODE.SUCCESS) { + setCanApplyAfterInvoicingStatus(invoiceTypeRet.data); + } + }; + initEnum(); + }, []); + + /** + * 复制订单到剪贴板 + * @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; + } + + /** + * 财务是否选中排序 + * @param e + */ + function financeSorted(e: any) { + let checked = e?.target.checked; + setSorted(checked); + refreshTable(); + } + + /** + * 重置当前的操作对象 + */ + 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 === undefined || currentOptMainId === null) { + 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 === null) { + message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员'); + } + + return mainOrderClone; + } + + /** + * 返回当前操作的子订单集合 + */ + function buildSubOrders() { + if (currentOptMainId === undefined || currentOptMainId === null) { + message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员'); + return; + } + + let cloneSubOrders = []; + + //如果没有传当前操作的子订单id,说明是操作主订单 + if (curretnOptSubId === undefined || curretnOptSubId === null) { + //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象 + 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 { + 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.uid && ( + <span className="text-[#f44e4e] cursor-pointer"> + (商城订单) + </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.invoiceConfirmStatusText !== null && ( + <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis"> + <Tag color={'success'} style={{ marginRight: '4px' }}> + {optRecord.invoiceConfirmStatusText} + </Tag> + </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 () => { + let body = [optRecord.id]; + const data = await postServiceOrderConfirmInvoice({ + data: body, + }); + 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('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('confirmInvoice') ? ( + <ButtonConfirm + className="p-0" + title="已和客户确认发票?" + text="确认发票" + onConfirm={async () => { + let body = [ + ...record.subOrderInformationLists.map( + (subOrder) => subOrder.id, + ), + ]; + const data = await postServiceOrderConfirmInvoice({ + data: body, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + refreshTable(); + } + }} + /> + ) : ( + '' + )} + + {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 (roles.includes('PROCURE') && item.dataIndex === 'orderStatus') { + item.valueEnum = enumToProTableEnumValue( + PROCURE_PRIMARY_ORDER_STATUS_OPTIONS, + ); + } + return item; + }, + ); + + /** + * 采购可以筛选供应商备注 + */ + if ( + (roleCode === 'procure' || + roles.includes('PROCURE') || + roleCode === 'admin') && + !isSupplier() + ) { + mainOrdersColumns.push({ + title: '供应商备注', + width: 120, + dataIndex: 'supplierNotes', + valueType: 'text', + hideInTable: true, + }); + } + + /** + * 采购可以筛选其他采购 + */ + if ( + (roleCode === 'procure' || + roles.includes('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' || + roles.includes('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' || + roles.includes('PROCURE') || + roleCode === 'admin' + ) { + mainOrdersColumns.push({ + title: isSupplier() ? '下单状态' : '采购下单状态', + dataIndex: 'procureOrderStatus', + valueType: 'select', + hideInTable: true, + valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS), + }); + } + + function toolBarRender() { + let toolBtns = []; + let radios: any[] = []; + + radios.push(<Radio value={0}>全部</Radio>); + + if ( + roleCode === 'admin' || + roleCode === 'salesManager' || + roles.includes('PROCURE') || + roleCode === 'salesRepresentative' + ) { + radios.push(<Radio value={70}>只看作废</Radio>); + } + + if (roleCode === 'warehouseKeeper') { + radios.push(<Radio value={40}>待处理</Radio>); + } + + //采购可以筛选出需要处理的订单 + if (roles.includes('PROCURE') && !isSupplier()) { + radios.push(<Radio value={60}>其他采购</Radio>); + radios.push(<Radio value={10}>待处理</Radio>); + } + + //财务可以将需要处理的订单排序到前面 + if (roleCode === 'finance') { + radios.push(<Radio value={50}>加急</Radio>); + + radios.push(<Radio value={40}>待处理</Radio>); + + radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>); + } + + if (roleCode === 'salesRepresentative' || roleCode === 'salesManager') { + radios.push(<Radio value={30}>只看我创建</Radio>); + + radios.push(<Radio value={40}>待审核</Radio>); + } + + if (roleCode === 'admin') { + radios.push(<Radio value={10}>待处理</Radio>); + radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>); + } + + //筛选按钮配置 + let radioGroup = ( + <Radio.Group + onChange={(e: any) => { + setFilterCondition(e.target.value); + refreshTable(); + }} + defaultValue={0} + > + {radios} + </Radio.Group> + ); + + toolBtns.push(radioGroup); + + toolBtns.push(<ImportExpressBillModal></ImportExpressBillModal>); + + //导出按钮配置 + const exportItems: MenuProps['items'] = [ + { + label: '导出查询结果订单', + key: '2', + onClick: async () => { + let body = { flag: 50, ...searchParams }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + { + label: '导出已选中订单', + key: '1', + onClick: async () => { + if (mainOrderSelectedMap.size === 0) { + message.error('请选择订单'); + return; + } + let body = { flag: 30, id: Array.from(mainOrderSelectedMap.keys()) }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + { + label: '导出当天订单', + key: '4', + onClick: async () => { + let body = { flag: 40, ids: [] }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + { + label: '导出所有订单', + key: '3', + onClick: async () => { + let body = { flag: 10, ids: [] }; + exportLoading(); + downloadFile( + '/api/service/order/export', + '订单导出结果.xls', + 'POST', + body, + exportLoadingDestory, + ); + }, + }, + ]; + + const exportMenuProps = { + items: exportItems, + onClick: () => {}, + }; + + //一键审核按钮配置 + const auditItems: MenuProps['items'] = [ + { + label: '后置审核', + key: '1', + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT); + }, + }, + { + label: '加急开票审核(旧)', + key: '2', + disabled: true, + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD); + }, + }, + { + label: '领导审核', + key: '3', + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.LEADER_AUDIT); + }, + }, + { + label: '修改申请审核', + key: '4', + onClick: async () => { + setIsMainOrder(true); + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT); + }, + }, + ]; + + const auditProps = { + items: auditItems, + onClick: () => {}, + }; + + if (rolePath?.includes('leaderMergeAudit')) { + toolBtns.push( + <Dropdown + disabled={selectedSubOrderKeys.length === 0} + menu={auditProps} + > + <Button> + <Space> + 一键审核 + <DownOutlined /> + </Space> + </Button> + </Dropdown>, + ); + } + + if (rolePath?.includes('mergeAudit')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setIsMainOrder(true); + if (roles.includes('PROCURE')) { + setProcureCheckModalVisible(true); + } + + if (roleCode === 'warehouseKeeper') { + setCheckVisible(true); + setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER); + } + }} + disabled={selectedSubOrderKeys?.length === 0} + > + 一键审核 + </Button>, + ); + } + + if (rolePath?.includes('mergeProcureOrder')) { + toolBtns.push( + <Button + key="mergeProcureOrder" + type="primary" + disabled={selectedSubOrderKeys.length === 0} + onClick={() => { + Modal.confirm({ + title: '一键下单', + content: '选中的订单是否都已下单?', + onOk: async () => { + let res = await postServiceOrderProcureOrder({ + data: { subIds: [...selectedSubOrderKeys.values()].flat() }, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + refreshTable(); + return true; + } + }, + }); + }} + > + 一键下单 + </Button>, + ); + } + + if (rolePath?.includes('mergeApplyInvoicing')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setIsEdit(false); + setIsMainOrder(true); + setApplyForInvoicingVisible(true); + }} + disabled={!canMergeInvoicing} /*{selectedSubOrderKeys?.length === 0}*/ + > + {roleCode === 'admin' ? '合并(销售)' : '合并开票'} + </Button>, + ); + } + + <Button + type="primary" + key="out" + onClick={() => { + setIsEdit(false); + setIsMainOrder(true); + setInvoicingDrawerFormVisible(true); + }} + disabled={selectedSubOrderKeys?.length === 0} + > + 申请开票(旧) + </Button>; + + if (rolePath?.includes('mergeInvoicing')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + //检查订单状态是否正确 + // 遍历Map中的键值对 + let errorIds = new Set(); + [...subOrderSelectedMap.values()].flat().forEach((subOrder) => { + if ( + subOrder.afterInvoicingStatus !== 'APPLY_FOR_INVOICING' && + subOrder.afterInvoicingStatus !== 'PARTIAL_INVOICING' + ) { + errorIds.add(subOrder.mainOrderId); + return; + } + }); + if (errorIds.size > 0) { + message.error( + '订单号为:' + + [...errorIds.values()].join(',') + + '的订单存在不是[申请开票]或者[部分开票]状态的子订单,请检查!', + ); + return; + } + setIsMainOrder(true); + setFinancialVisible(true); + }} + disabled={selectedSubOrderKeys?.length === 0} + > + {roleCode === 'admin' ? '合并(财务)' : '合并开票'} + </Button>, + ); + } + + toolBtns.push( + <Button + type="primary" + key="inv" + onClick={() => { + setIsMainOrder(true); + let flat = [...subOrderSelectedMap.values()].flat(); + //遍历flat,判断afterInvoicingStatusList存在于canApplyAfterInvoicingStatus + flat.forEach((item) => { + if ( + item.invoicingStatus === 'UN_INVOICE' || + (item.afterInvoicingStatus !== null && + !canApplyAfterInvoicingStatus.includes( + item.afterInvoicingStatus, + )) + ) { + message.error('存在不能进行开票的订单'); + return; + } + }); + //遍历afterInvoicingStatusList + setInvoicingDrawerFormVisible(true); + }} + disabled={selectedSubOrderKeys?.length === 0} + > + 申请开票 + </Button>, + ); + + if (rolePath?.includes('addOrder')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setOrderDrawerVisible(true); + setOrderOptType('add'); + }} + > + 新增 + </Button>, + ); + } + + if (rolePath?.includes('importExcel')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setImportModalVisible(true); + }} + > + 批量发货 + </Button>, + ); + } + + if (rolePath?.includes('export')) { + toolBtns.push( + <Dropdown menu={exportMenuProps}> + <Button> + <Space> + 导出 + <DownOutlined /> + </Space> + </Button> + </Dropdown>, + ); + } + + return toolBtns; + } + // 监听 params 变化并重新获取数据 + useEffect(() => { + if (paramsNew) { + setNewParams(paramsNew); + } + refreshTable(); + console.log(paramsNew, '5656paramsNewc', newParams); + }, [paramsNew]); + return ( + <div className="order-page-container"> + <div id="resizeDiv"></div> + <div id="resizeDiv"></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={ + searchShow + ? { + labelWidth: 'auto', + // onCollapse: resize, + } + : 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.condition = filterCondifion; + + //排序 + params.sorted = sorted; + //是否只查看已作废 + params.isDeleteQueryOrder = filterCondifion === 70; + if (paramsNew.isDeleteQueryOrderNow === false) { + params.isDeleteQueryOrder = false; + } + //保存这个搜索条件 + setSearchParam(params); + console.log(paramsNew, '5656paramsNew'); + const { data } = await postServiceOrderQueryServiceOrder({ + // ...params, + // FIXME: remove @ts-ignore + // @ts-ignore + sorter, + filter, + data: { ...params, ...paramsNew }, + }); + + 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); + } + + return { + data: data?.data || [], + total: data?.total || 0, + }; + }} + toolbar={{ + multipleLine: true, + }} + toolBarRender={() => { + if (toolbarShow) { + 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 OrderList; diff --git a/src/pages/Order/OrderList/OrderNotesEditModal.tsx b/src/pages/Order/OrderList/OrderNotesEditModal.tsx new file mode 100644 index 0000000..e1da0aa --- /dev/null +++ b/src/pages/Order/OrderList/OrderNotesEditModal.tsx @@ -0,0 +1,48 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderNotesEdit } from '@/services'; +import { ModalForm, ProFormTextArea } from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +export default ({ setNotesEditVisible, notes, ids, notesType, onClose }) => { + const [form] = Form.useForm<{ name: string; company: string }>(); + return ( + <ModalForm<{ + name: string; + company: string; + }> + width={500} + open + title="修改备注" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '保存', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setNotesEditVisible(false); + }, + }} + submitTimeout={2000} + onFinish={async (values) => { + let body = { + id: ids[0], + notes: values.name, + notesType: notesType, + }; + const res = await postServiceOrderNotesEdit({ data: body }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onOpenChange={setNotesEditVisible} + > + <ProFormTextArea + width="lg" + name="name" + initialValue={notes} + placeholder="填写备注内容" + /> + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/OtherInfoModal.tsx b/src/pages/Order/OrderList/OtherInfoModal.tsx new file mode 100644 index 0000000..b6c62ea --- /dev/null +++ b/src/pages/Order/OrderList/OtherInfoModal.tsx @@ -0,0 +1,55 @@ +import { Col, Modal, Row } from 'antd'; + +const DeliverModal = ({ data, setVisible }) => { + return ( + <Modal + open + width={900} + title={'其他信息'} + onOk={async () => {}} + onCancel={() => { + setVisible(false); + }} + > + <Row gutter={[16, 24]}> + <Col span={6}> + <span className="text-[#333333]">销售申请开票附件</span> + </Col> + <Col span={18}>{data.customerName}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">联系方式</span> + </Col> + <Col span={18}>{data.customerContactNumber}</Col> + + <Col span={6}> + <span className="className='text-[#333333]'">收货地址</span> + </Col> + <Col span={18}>{data.customerShippingAddress}</Col> + + <Col span={6}> + <span className="className='text-[#333333]'">单位联系人</span> + </Col> + <Col span={18}>{data.institutionContactName}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">单位名称</span> + </Col> + <Col span={18}>{data.institution}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">开户银行</span> + </Col> + <Col span={18}>{data.bank}</Col> + + <Col span={6}> + <span className="className='text-[#333333]'">银行账号</span> + </Col> + <Col span={18}>{data.bankAccountNumber}</Col> + <Col span={6}> + <span className="className='text-[#333333]'">开票识别号</span> + </Col> + <Col span={18}>{data.invoiceIdentificationNumber}</Col> + </Row> + </Modal> + ); +}; + +export default DeliverModal; diff --git a/src/pages/Order/OrderList/ProcureCheckModal.tsx b/src/pages/Order/OrderList/ProcureCheckModal.tsx new file mode 100644 index 0000000..64f12d2 --- /dev/null +++ b/src/pages/Order/OrderList/ProcureCheckModal.tsx @@ -0,0 +1,131 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postServiceOrderProcureCheckOrder, + postServiceOrderProcureConvertWarehouseKeeper, + postServiceOrderQuerySupplier, +} from '@/services'; +import { + ModalForm, + ProFormSelect, + ProFormTextArea, +} from '@ant-design/pro-components'; +import { Button, Form, Input, Popconfirm, message } from 'antd'; +import { useState } from 'react'; +export default ({ setCheckVisible, isMainOrder, orders, onClose }) => { + const [form] = Form.useForm<{ supplier: string }>(); + const [checkNotes, setCheckNotes] = useState<string>(''); + + console.log(isMainOrder); + + let ids: any[] = orders.map((order: any) => order.id); + async function doCheck(body: object) { + const data = await postServiceOrderProcureCheckOrder({ + data: body, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + } + + return ( + <ModalForm<{ + supplier: string; + }> + width={500} + open + title="采购审核" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '确认', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setCheckVisible(false); + }, + }} + submitter={{ + render: (props, defaultDoms) => { + return [ + defaultDoms[0], + <> + <Popconfirm + title="是否转回仓库" + description={ + <div> + <div className="py-2"> + <span>转回仓库后将由仓库管理员进行打印、发货</span> + </div> + <Input.TextArea + placeholder="请填写备注" + onChange={(e: any) => { + setCheckNotes(e.target.value); + }} + rows={4} + ></Input.TextArea> + </div> + } + onConfirm={async () => { + let res = await postServiceOrderProcureConvertWarehouseKeeper( + { + data: { + subIds: ids, + checkNotes: checkNotes, + }, + }, + ); + + if (res?.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + return true; + } + }} + okText="确定" + cancelText="取消" + > + <Button type="primary">转回仓库</Button> + </Popconfirm> + </>, + defaultDoms[1], + ]; + }, + }} + submitTimeout={2000} + onFinish={async (values) => { + if (values.supplier === '0') { + message.error('选择转回仓库请点击转回仓库按钮!'); + return; + } + let procureIsPrintAndSend = true; + return doCheck({ + ...values, + subOrderIds: ids, + procureIsPrintAndSend: procureIsPrintAndSend, + }); + }} + onOpenChange={setCheckVisible} + > + <ProFormSelect + key="key" + label="采购名称" + width="lg" + name="supplier" + // options={options} + placeholder="请选择采购" + rules={[{ required: true, message: '采购名称必填' }]} + request={async () => { + const res = await postServiceOrderQuerySupplier(); + let options = res.data?.map((item) => { + return { label: item, value: item }; + }); + options.push({ label: '转回仓库', value: '0' }); + return options; + }} + /> + + <ProFormTextArea label="备注" name="procureNotes" key="procureNotes" /> + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/ProcureConvertModal.tsx b/src/pages/Order/OrderList/ProcureConvertModal.tsx new file mode 100644 index 0000000..0dba988 --- /dev/null +++ b/src/pages/Order/OrderList/ProcureConvertModal.tsx @@ -0,0 +1,98 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postServiceOrderProcureConvertProcure, + postServiceOrderProcureConvertWarehouseKeeper, + postServiceOrderProvideProcurementRoles, +} from '@/services'; +import { + ModalForm, + ProFormSelect, + ProFormTextArea, +} from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +export default ({ setVisible, subOrders, onClose }) => { + const [form] = Form.useForm<{ + procureName: string; + procureConvertNotes: string; + }>(); + + let subOrderIds: any[] = subOrders?.map((subOrder) => subOrder.id); + + return ( + <ModalForm<{ + procureName: string; + procureConvertNotes: string; + }> + width={500} + open + title="采购转发" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '确认', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + submitter={{ + render: (props, defaultDoms) => { + return defaultDoms; + }, + }} + submitTimeout={2000} + onFinish={async (values) => { + let data; + if (values.procureName === '仓库') { + //转给仓库 + data = await postServiceOrderProcureConvertWarehouseKeeper({ + data: { + subIds: subOrderIds, + checkNotes: values.procureConvertNotes, + }, + }); + } else { + data = await postServiceOrderProcureConvertProcure({ + data: { + procureName: values.procureName, + procureConvertNotes: values.procureConvertNotes, + subIds: subOrderIds, + }, + }); + } + + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + }} + onOpenChange={setVisible} + > + <ProFormSelect + key="key" + label="采购名称" + width="lg" + name="procureName" + // options={options} + placeholder="请选择采购" + rules={[{ required: true, message: '采购必填' }]} + request={async () => { + const res = await postServiceOrderProvideProcurementRoles(); + let options = res.data?.map((item) => { + return { label: item, value: item }; + }); + return options; + }} + /> + + <ProFormTextArea + key="key" + label="转发备注" + width="lg" + name="procureConvertNotes" + placeholder="请填写转发备注" + /> + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/ProcureNotesEditModal.tsx b/src/pages/Order/OrderList/ProcureNotesEditModal.tsx new file mode 100644 index 0000000..061f4c8 --- /dev/null +++ b/src/pages/Order/OrderList/ProcureNotesEditModal.tsx @@ -0,0 +1,48 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderNotesEdit } from '@/services'; +import { ModalForm, ProFormTextArea } from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +export default ({ setNotesEditVisible, notesType, data, onClose }) => { + const [form] = Form.useForm<{ procureNotes: string }>(); + return ( + <ModalForm<{ + procureNotes: string; + }> + width={500} + open + title="修改备注" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '保存', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setNotesEditVisible(false); + }, + }} + submitTimeout={2000} + onFinish={async (values) => { + let body = { + id: data.id, + notes: values.procureNotes, + notesType: notesType, + }; + const res = await postServiceOrderNotesEdit({ data: body }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onOpenChange={setNotesEditVisible} + > + <ProFormTextArea + width="lg" + key="procureNotes" + name="procureNotes" + initialValue={data.procureNotes} + placeholder="填写备注内容" + /> + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/ProductionTimeModal.tsx b/src/pages/Order/OrderList/ProductionTimeModal.tsx new file mode 100644 index 0000000..deac1a9 --- /dev/null +++ b/src/pages/Order/OrderList/ProductionTimeModal.tsx @@ -0,0 +1,81 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderEditProductionTime } from '@/services'; +import { ModalForm, ProFormDatePicker } from '@ant-design/pro-components'; +import { Form, message } from 'antd'; + +// import { cloneDeep } from 'lodash'; +export default ({ setVisible, subOrders, onClose }) => { + const [form] = Form.useForm<{ + productionStartTime: string; + productionEndTime: string; + }>(); + let ids = subOrders?.map((item: { id: any }) => { + return item.id; + }); + let defaultValue = {}; + if (subOrders && subOrders.length > 0) { + defaultValue = subOrders[0]; + } + return ( + <> + <ModalForm<{ + productionStartTime: string; + productionEndTime: string; + }> + width={500} + open + title="生产时间" + form={form} + autoFocusFirstInput + initialValues={defaultValue} + modalProps={{ + okText: '保存', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + onFinish={async (values) => { + if (values.productionStartTime > values.productionEndTime) { + message.error('开始时间不能大于结束时间'); + return; + } + let res = await postServiceOrderEditProductionTime({ + data: { + ...values, + ids: ids, + }, + }); + + if (res && res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } + }} + onOpenChange={setVisible} + > + <span className="text-[red] leading-8"> + 如果选中多个子订单,将默认回显第一个子订单的生产时间 + </span> + <ProFormDatePicker + width="lg" + key="productionStartTime" + name="productionStartTime" + label="开始时间" + placeholder="请输入开始时间" + rules={[{ required: true, message: '开始时间必填' }]} + /> + + <ProFormDatePicker + width="lg" + key="productionEndTime" + name="productionEndTime" + label="结束时间" + placeholder="请输入结束时间" + rules={[{ required: true, message: '结束时间必填' }]} + /> + </ModalForm> + </> + ); +}; diff --git a/src/pages/Order/OrderList/ReissueModal.tsx b/src/pages/Order/OrderList/ReissueModal.tsx new file mode 100644 index 0000000..3b2eba8 --- /dev/null +++ b/src/pages/Order/OrderList/ReissueModal.tsx @@ -0,0 +1,122 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postServiceInvoiceFindInvoice, + postServiceInvoiceReissue, + postServiceOrderFindServiceOrder, +} from '@/services'; +import { + ModalForm, + ProFormSelect, + ProFormText, + ProFormTextArea, +} from '@ant-design/pro-components'; +import { Form } from 'antd'; +import { useEffect, useState } from 'react'; + +export default ({ setVisible, subOrders, onClose }) => { + const [invoiceSelectList, setInvoiceSelectList] = useState([]); + const [mainOrders, setMainOrders] = useState(''); + const [submitting, setSubmitting] = useState(false); + + const [form] = Form.useForm<{ invoiceId: string; notes: string }>(); + + let getInvoiceSelectList = async () => { + const res = await postServiceInvoiceFindInvoice({ + data: { + subOrderIdIn: subOrders.map((item) => item.id), + }, + }); + setInvoiceSelectList([]); + if (res && res.result === RESPONSE_CODE.SUCCESS) { + let temInvoiceSelectList = []; + res.data.forEach((item) => { + temInvoiceSelectList.push({ + label: item.invoiceNumber, + value: item.id, + }); + }); + setInvoiceSelectList(temInvoiceSelectList); + } + }; + useEffect(() => { + getInvoiceSelectList(); + }, []); + return ( + <ModalForm<{ + invoiceId: string; + notes: string; + }> + title="重新开票" + form={form} + width={500} + open + autoFocusFirstInput + initialValues={{}} + modalProps={{ + okText: '确认', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + submitting={submitting} + onFinish={async (values) => { + setSubmitting(true); + postServiceInvoiceReissue({ + data: values, + }); + setVisible(false); + onClose(); + }} + submitTimeout={2000} + > + <ProFormSelect + width="lg" + name="invoiceId" + label="选择要重新开的发票" + options={invoiceSelectList} + onChange={async (value) => { + console.log(value); + let result = await postServiceOrderFindServiceOrder({ + data: { + invoiceId: value, + }, + }); + if (result && result.result === RESPONSE_CODE.SUCCESS) { + //对data里面每个元素的id用,进行拼接 + let map = result.data.map((item) => item.id); + let str = map.join(','); + setMainOrders(str); + } + }} + /> + <ProFormText + width="lg" + name="purchaser" + label="抬头名称" + key="purchaser" + placeholder="请输入抬头名称" + rules={[{ required: true, message: '抬头名称必填' }]} + /> + <ProFormText + width="md" + name="关联订单" + label="发票关联订单号" + readonly={true} + value={mainOrders} + /> + <ProFormTextArea + width="lg" + name="notes" + rules={[ + { + required: true, // 设置为必填 + message: '必须填写重新开票原因', // 当未填写时显示的提示信息 + }, + ]} + placeholder="请填写订单重新开票的原因" + /> + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/ReissueModal_old.tsx b/src/pages/Order/OrderList/ReissueModal_old.tsx new file mode 100644 index 0000000..48b3978 --- /dev/null +++ b/src/pages/Order/OrderList/ReissueModal_old.tsx @@ -0,0 +1,120 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postServiceInvoiceFindInvoiceOld, + postServiceInvoiceReissueOld, + postServiceOrderFindServiceOrder, +} from '@/services'; +import { + ModalForm, + ProFormSelect, + ProFormText, + ProFormTextArea, +} from '@ant-design/pro-components'; +import { Form } from 'antd'; +import { useEffect, useState } from 'react'; + +export default ({ setVisible, mainOrder, onClose }) => { + const [invoiceSelectList, setInvoiceSelectList] = useState([]); + const [mainOrders, setMainOrders] = useState(''); + const [submitting, setSubmitting] = useState(false); + + const [form] = Form.useForm<{ invoiceId: string; notes: string }>(); + + let getInvoiceSelectList = async () => { + console.log(mainOrder); + const res = await postServiceInvoiceFindInvoiceOld({ + data: { + mainOrderId: mainOrder.id, + }, + }); + setInvoiceSelectList([]); + if (res && res.result === RESPONSE_CODE.SUCCESS) { + let temInvoiceSelectList = []; + res.data.forEach((item) => { + temInvoiceSelectList.push({ + label: item.invoiceNumber, + value: item.id, + }); + }); + setInvoiceSelectList(temInvoiceSelectList); + } + }; + useEffect(() => { + getInvoiceSelectList(); + }, []); + return ( + <ModalForm + title="重新开票(旧)" + form={form} + width={500} + open + autoFocusFirstInput + initialValues={{}} + modalProps={{ + okText: '确认', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + submitting={submitting} + onFinish={async (values) => { + setSubmitting(true); + postServiceInvoiceReissueOld({ + data: values, + }); + setVisible(false); + onClose(); + }} + submitTimeout={2000} + > + <ProFormSelect + width="lg" + name="invoiceId" + label="选择要重新开的发票" + options={invoiceSelectList} + onChange={async (value) => { + console.log(value); + let result = await postServiceOrderFindServiceOrder({ + data: { + invoiceId: value, + }, + }); + if (result && result.result === RESPONSE_CODE.SUCCESS) { + //对data里面每个元素的id用,进行拼接 + let map = result.data.map((item) => item.id); + let str = map.join(','); + setMainOrders(str); + } + }} + /> + <ProFormText + width="lg" + name="purchaser" + label="抬头名称" + key="purchaser" + placeholder="请输入抬头名称" + rules={[{ required: true, message: '抬头名称必填' }]} + /> + <ProFormText + width="md" + name="关联订单" + label="发票关联订单号" + readonly={true} + value={mainOrders} + /> + <ProFormTextArea + width="lg" + name="notes" + rules={[ + { + required: true, // 设置为必填 + message: '必须填写重新开票原因', // 当未填写时显示的提示信息 + }, + ]} + placeholder="请填写订单重新开票的原因" + /> + </ModalForm> + ); +}; diff --git a/src/pages/Order/OrderList/ShippingWarehouseChangeModal.tsx b/src/pages/Order/OrderList/ShippingWarehouseChangeModal.tsx new file mode 100644 index 0000000..380eb95 --- /dev/null +++ b/src/pages/Order/OrderList/ShippingWarehouseChangeModal.tsx @@ -0,0 +1,70 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { postServiceOrderShippingWarehouseChange } from '@/services'; +import { enumToSelect } from '@/utils'; +import { ModalForm, ProFormSelect } from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +import { SHIPPING_WAREHOUSE_OPTIONS } from '../constant'; + +export default ({ + setVisible, + subOrderIds, + originShippingWarehouse, + onClose, +}) => { + const [form] = Form.useForm<{ shippingWarehouse: string }>(); + + let newOriginShippingWarehouse = originShippingWarehouse; + if ( + originShippingWarehouse === null || + originShippingWarehouse === undefined + ) { + newOriginShippingWarehouse = 'DALANG_WAREHOUSE'; + } + return ( + <> + <ModalForm<{ + shippingWarehouse: string; + }> + width={500} + open + title="修改发货仓库" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '保存', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + onFinish={async (values) => { + let res = await postServiceOrderShippingWarehouseChange({ + data: { + ...values, + ids: subOrderIds, + }, + }); + + if (res && res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + } + onClose(); + }} + onOpenChange={setVisible} + > + <ProFormSelect + key={'shippingWarehouse'} + placeholder="请选择发货仓库" + name="shippingWarehouse" + width="lg" + label="发货仓库" + rules={[{ required: true, message: '发货仓库必填' }]} + initialValue={newOriginShippingWarehouse} + options={enumToSelect(SHIPPING_WAREHOUSE_OPTIONS)} + /> + , + </ModalForm> + </> + ); +}; diff --git a/src/pages/Order/OrderList/UploadPayBillModal.tsx b/src/pages/Order/OrderList/UploadPayBillModal.tsx new file mode 100644 index 0000000..7f27269 --- /dev/null +++ b/src/pages/Order/OrderList/UploadPayBillModal.tsx @@ -0,0 +1,235 @@ +import { RESPONSE_CODE } from '@/constants/enum'; +import { + postServiceOrderFileProcess, + postServiceOrderUploadPaymentReceipt, +} from '@/services'; +import { transImageFile } from '@/utils'; +import { PlusOutlined } from '@ant-design/icons'; +import { ModalForm } from '@ant-design/pro-components'; +import { Form, Modal, Upload, UploadFile, UploadProps, message } from 'antd'; +import { RcFile } from 'antd/lib/upload'; +import { cloneDeep } from 'lodash'; +import { useEffect, useRef, useState } from 'react'; +import { COMFIR_RECEIPT_IMAGES_NUMBER } from '../constant'; + +// import { cloneDeep } from 'lodash'; +export default ({ setVisible, subOrders, mainOrder, onClose }) => { + const [form] = Form.useForm(); + const [previewOpen, setPreviewOpen] = useState(false); + const [previewImage, setPreviewImage] = useState(''); + const [previewTitle, setPreviewTitle] = useState(''); + const handleCancel = () => setPreviewOpen(false); + const [fileList, setFileList] = useState<UploadFile[]>([]); + const getBase64 = (file: RcFile): Promise<string> => + new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result as string); + reader.onerror = (error) => reject(error); + }); + + const subOrderIds = subOrders?.map((item: any) => { + return item.id; + }); + const fileListObj = useRef<UploadFile[]>([]); //使用引用类型,使得在useEffect里面设置监听事件后,不用更新监听事件也能保持obj与外界一致 + const handleBeforeUpload = (file: any) => { + setFileList([...fileList, file]); + return false; + }; + const uploadButton = ( + <div> + <PlusOutlined /> + <div style={{ marginTop: 8 }}>上传凭证</div> + </div> + ); + /** 粘贴快捷键的回调 */ + const onPaste = async (e: any) => { + /** 获取剪切板的数据clipboardData */ + let clipboardData = e.clipboardData, + i = 0, + items, + item, + types; + + /** 为空判断 */ + if (clipboardData) { + items = clipboardData.items; + if (!items) { + message.info('您的剪贴板中没有照片'); + return; + } + + item = items[0]; + types = clipboardData.types || []; + /** 遍历剪切板的数据 */ + for (; i < types.length; i++) { + if (types[i] === 'Files') { + item = items[i]; + break; + } + } + + /** 判断文件是否为图片 */ + if (item && item.kind === 'file' && item.type.match(/^image\//i)) { + const imgItem = item.getAsFile(); + const newFileList = cloneDeep(fileListObj.current); + let filteredArray = newFileList.filter( + (obj) => obj.status !== 'removed', + ); //过滤掉状态为已删除的照片 + const listItem = { + ...imgItem, + status: 'done', + url: await getBase64(imgItem), + originFileObj: imgItem, + }; + + if (filteredArray.length >= COMFIR_RECEIPT_IMAGES_NUMBER) { + message.info('发货照片数量不能超过3'); + console.log(mainOrder); + return; + } + fileListObj.current = filteredArray; + filteredArray.push(listItem); + setFileList(filteredArray); + return; + } + } + + message.info('您的剪贴板中没有照片'); + }; + const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { + //fileListObj得在change里变化,change的参数是已经处理过的file数组 + //beforeUpload中的参数file是未处理过,还需要Base64拿到文件数据处理 + fileListObj.current = newFileList; + setFileList(newFileList); + }; + const handlePreview = async (file: UploadFile) => { + if (!file.url && !file.preview) { + file.preview = await getBase64(file.originFileObj as RcFile); + } + setPreviewImage(file.url || (file.preview as string)); + setPreviewOpen(true); + setPreviewTitle( + file.name || + file.originFileObj?.name || + file.url!.substring(file.url!.lastIndexOf('/') + 1), + ); + }; + const props: UploadProps = { + onRemove: (file) => { + const index = fileList.indexOf(file); + const newFileList = fileList.slice(); + newFileList.splice(index, 1); + setFileList(newFileList); + }, + beforeUpload: handleBeforeUpload, + listType: 'picture-card', + onPreview: handlePreview, + fileList, + onChange: handleChange, + accept: 'image/png, image/jpeg, image/png', + // action: '/api/service/order/fileProcess', + name: 'files', + headers: { Authorization: localStorage.getItem('token') }, + }; + + useEffect(() => { + document.addEventListener('paste', onPaste); + return () => { + document.removeEventListener('paste', onPaste); + }; + }, []); + return ( + <> + <ModalForm<{ + filePaths: any; + }> + width={500} + open + title="回款凭证上传" + form={form} + autoFocusFirstInput + modalProps={{ + okText: '提交', + cancelText: '取消', + destroyOnClose: true, + onCancel: () => { + setVisible(false); + }, + }} + onFinish={async () => { + if (fileList.length <= 0) { + message.error('请上传至少一张凭证'); + return; + } + message.open({ + type: 'loading', + content: '正在上传凭证...', + duration: 0, + }); + //附件处理 + let formData = new FormData(); + //附件处理 + for (let file of fileList) { + if (file.originFileObj) { + formData.append('files', file.originFileObj as RcFile); + } else { + //有url的话取url(源文件),没url取thumbUrl。有url的时候thumbUrl是略缩图 + if (file?.url === undefined || file?.url === null) { + formData.append( + 'files', + transImageFile(file?.thumbUrl), + file?.originFileObj?.name, + ); + } else { + formData.append( + 'files', + transImageFile(file?.url), + file?.originFileObj?.name, + ); + } + } + } + let res = await postServiceOrderFileProcess({ + data: formData, + }); + message.destroy(); + if (res.result === RESPONSE_CODE.SUCCESS) { + let fileUrls = res?.data?.map((item) => { + return { url: item }; + }); + //财务审核 + const data = await postServiceOrderUploadPaymentReceipt({ + data: { + subOrderIds: subOrderIds, + filePaths: fileUrls, + }, + }); + if (data.result === RESPONSE_CODE.SUCCESS) { + message.success(data.message); + onClose(); + } + } else { + message.success('上传失败'); + } + onClose(); + }} + onOpenChange={setVisible} + > + <div className="pb-4 text-xs decoration-gray-50">可复制照片粘贴</div> + <Upload {...props}> + {fileList.length < COMFIR_RECEIPT_IMAGES_NUMBER ? uploadButton : ''} + </Upload> + </ModalForm> + + <Modal + open={previewOpen} + title={previewTitle} + footer={null} + onCancel={handleCancel} + > + <img alt="图片预览" style={{ width: '100%' }} src={previewImage} /> + </Modal> + </> + ); +}; diff --git a/src/pages/Order/OrderList/hooks.ts b/src/pages/Order/OrderList/hooks.ts new file mode 100644 index 0000000..cd94f6c --- /dev/null +++ b/src/pages/Order/OrderList/hooks.ts @@ -0,0 +1,67 @@ +import { useModel } from 'umi'; +import { OPERATION_TYPE, ROLE } from './type.d'; + +function setAllValuesToTrue(obj: Record<string, boolean | object>) { + return Object.keys(obj).reduce( + (result, key) => { + if (typeof obj[key] === 'object') { + result[key] = setAllValuesToTrue(obj[key] as Record<string, object>); + } else { + result[key] = true; + } + return result; + }, + {} as Record<string, boolean | object>, + ); +} + +// 获取用户可编辑字段 +export const useFieldAuth = ({ operation }: { operation: OPERATION_TYPE }) => { + const { role } = useModel('user'); + + let authFields = { + bank: false, + bankAccountNumber: false, + createTime: false, + customerContactNumber: false, + customerName: false, + customerShippingAddress: false, + id: false, + institution: false, + institutionContactName: false, + invoiceIdentificationNumber: false, + notes: false, + salesCode: false, + subOrderInformationLists: { + id: false, + invoicingStatus: false, + mainOrderId: false, + orderStatus: false, + parameters: false, + paymentChannel: false, + productCode: false, + productName: false, + quantity: false, + subOrderPayment: false, + }, + } as Record<string, boolean | object>; + + console.log(role); + + if (operation === OPERATION_TYPE.CREATE) { + return authFields; + } else if (operation === OPERATION_TYPE.EDIT) { + if (role === ROLE.ADMIN) { + return authFields; + } else if (role === ROLE.SALESMAN) { + // 将所有的字段设置为没有权限编辑 + authFields = setAllValuesToTrue(authFields); + // 筛选字段为可编辑 + authFields = { + ...authFields, + invoiceInformation: false, + }; + } + } + return { authFields }; +}; diff --git a/src/pages/Order/OrderList/index.css b/src/pages/Order/OrderList/index.css new file mode 100644 index 0000000..8e57350 --- /dev/null +++ b/src/pages/Order/OrderList/index.css @@ -0,0 +1,100 @@ +.order-page-container .ant-table .ant-table-middle { + margin-inline: 0 !important; +} + +.order-page-container td { + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', + 'WenQuanYi Micro Hei', sans-serif; + font-size: 13px; +} + +#total-payment .ant-input-number-group-addon { + padding: 0 !important; +} + +.order-page-container table:hover, +.order-page-container tr:hover, +.order-page-container thead:hover { + background: none !important; +} + +#main-table .ant-table-tbody > tr.ant-table-row:hover > td { + background: none !important; +} + +.order-page-container .ant-pro-card { + background-color: transparent; +} + +#main-table .ant-table-tbody .ant-table-cell { + padding: 10px 0 0; +} + +.order-page-container .ant-pagination { + background-color: #fff !important; + padding: 10px; + border-radius: 8px; +} + +.order-page-container .ant-pro-table .ant-form { + background-color: #fff; + border-radius: 8px; +} + +#main-table .ant-table-tbody { + background-color: #f5f5f5; +} + +.order-page-container .ant-pro-card-body { + padding: 0 !important; +} + +.order-page-container .ant-table-thead .ant-table-cell { + background-color: #fff !important; + border-radius: 8px !important; +} + +#sub-table tbody td { + padding: 10px 0 !important; +} + +#sub-table tbody tr:first-child td:first-child { + border-top-left-radius: 8px; +} + +#sub-table tbody tr:first-child td:nth-child(2) { + border-top-right-radius: 8px; +} + +#sub-table tbody tr:last-child td:first-child { + border-bottom-left-radius: 8px; +} + +#sub-table tbody tr:last-child td:nth-child(2) { + border-bottom-right-radius: 8px; +} + +#sub-table tbody tr td:first-child { + border-top: 1px solid #d7d6d6; + + /* 设置行与行之间分割线的颜色 */ + border-bottom: 1px solid #d7d6d6; + + /* 设置行与行之间分割线的颜色 */ + border-left: 1px solid #d7d6d6; + + /* 设置行与行之间分割线的颜色 */ +} + +#sub-table tbody tr td:nth-child(2) { + border-top: 1px solid #d7d6d6; + + /* 设置行与行之间分割线的颜色 */ + border-bottom: 1px solid #d7d6d6; + + /* 设置行与行之间分割线的颜色 */ + border-right: 1px solid #d7d6d6; + + /* 设置行与行之间分割线的颜色 */ +} diff --git a/src/pages/Order/OrderList/index.less b/src/pages/Order/OrderList/index.less new file mode 100644 index 0000000..6898958 --- /dev/null +++ b/src/pages/Order/OrderList/index.less @@ -0,0 +1,97 @@ +// 嵌套表格去掉左方多余部分 +.order-page-container .ant-table .ant-table-middle { + margin-inline: 0 !important; +} + +.order-page-container td { + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', + 'WenQuanYi Micro Hei', sans-serif; + font-size: 13px; +} +//订单编辑抽屉中,订单总额addonAfter的padding去除 +#total-payment .ant-input-number-group-addon { + padding: 0 !important; +} + +.order-page-container table:hover, +.order-page-container tr:hover, +.order-page-container thead:hover { + background: none !important; +} + +#main-table .ant-table-tbody > tr.ant-table-row:hover > td { + background: none !important; +} + +.order-page-container .ant-pro-card { + background-color: transparent; +} + +#main-table .ant-table-tbody .ant-table-cell { + padding: 10px 0 0; +} + +.order-page-container .ant-pagination { + background-color: #fff !important; + padding: 10px; + border-radius: 8px; +} + +.order-page-container .ant-pro-table .ant-form { + background-color: #fff; + border-radius: 8px; +} + +#main-table .ant-table-tbody { + background-color: #f5f5f5; +} + +.order-page-container .ant-pro-card-body { + padding: 0 !important; +} + +.order-page-container .ant-table-thead .ant-table-cell { + background-color: #fff !important; + border-radius: 8px !important; +} + +#sub-table tbody td { + padding: 10px 0 !important; +} + +// 子订单第一行的上边两个角为圆角 +#sub-table tbody tr:first-child td:first-child { + border-top-left-radius: 8px; +} + +#sub-table tbody tr:first-child td:nth-child(2) { + border-top-right-radius: 8px; +} + +//子订单最后一行的下边两个角为圆角 +#sub-table tbody tr:last-child td:first-child { + border-bottom-left-radius: 8px; +} + +#sub-table tbody tr:last-child td:nth-child(2) { + border-bottom-right-radius: 8px; +} + +//子订单边线颜色 +#sub-table tbody tr td:first-child { + border-top: 1px solid #d7d6d6; /* 设置行与行之间分割线的颜色 */ + border-bottom: 1px solid #d7d6d6; /* 设置行与行之间分割线的颜色 */ + border-left: 1px solid #d7d6d6; /* 设置行与行之间分割线的颜色 */ +} + +#sub-table tbody tr td:nth-child(2) { + border-top: 1px solid #d7d6d6; /* 设置行与行之间分割线的颜色 */ + border-bottom: 1px solid #d7d6d6; /* 设置行与行之间分割线的颜色 */ + border-right: 1px solid #d7d6d6; /* 设置行与行之间分割线的颜色 */ +} + +//tooltip字体颜色自定义 +// .order-tooltip .ant-tooltip-inner{ +// color: black !important; +// } diff --git a/src/pages/Order/OrderList/index.tsx b/src/pages/Order/OrderList/index.tsx new file mode 100644 index 0000000..60779c0 --- /dev/null +++ b/src/pages/Order/OrderList/index.tsx @@ -0,0 +1,14 @@ +import OrderList from './OrderList'; +import './index.less'; + +const OrderPage = () => { + return ( + <div className="order-page-container"> + <div id="resizeDiv"></div> + <div id="resizeDiv"></div> + <OrderList params={{}} searchShow={true} toolbarShow={true} /> + </div> + ); +}; + +export default OrderPage; diff --git a/src/pages/Order/OrderList/table.less b/src/pages/Order/OrderList/table.less new file mode 100644 index 0000000..d5b36d8 --- /dev/null +++ b/src/pages/Order/OrderList/table.less @@ -0,0 +1,6 @@ +.myTable td { + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', + 'WenQuanYi Micro Hei', sans-serif; + font-size: 13px; +} diff --git a/src/pages/Order/OrderList/type.d.ts b/src/pages/Order/OrderList/type.d.ts new file mode 100644 index 0000000..4abf104 --- /dev/null +++ b/src/pages/Order/OrderList/type.d.ts @@ -0,0 +1,70 @@ +export enum ROLE { + ADMIN = 'admin', // 管理 + SALESMAN = 'salesman', //销售 + FINANCE = 'finance', // 财务 +} + +export enum OPERATION_TYPE { + CREATE = 'create', + EDIT = 'edit', + READ = 'read', +} + +export interface OrderType { + id: string; +} + +export interface OrderListItemType { + goodsVolume: any; + goodsWeight: any; + receivingCompany: any; + modified: any; + paths: any; + totalPayment: ReactNode; + notes: ReactNode; + invoiceIdentificationNumber: ReactNode; + bankAccountNumber: ReactNode; + bank: ReactNode; + id: undefined; + subOrderInformationLists: any; + createTime: ReactNode; + mainOrderId: number; + salesCode: string; + customerName: string; + customerContactNumber: string; + customerShippingAddress: string; + institutionContactName: string; + institution: string; + mainOrderCreateTime: string; + mainOrderUpdateTime: string; + mainOrderCreateByName: string; + mainOrderUpdateByName: any; + subOrders: { + subOrderId: number; + productCode: number; + productName: string; + quantity: number; + productPrice: number; + unit: string; + parameters: any; + totalPayment: number; + subOrderPayment: number; + isCancel: number; + logisticsStatus: string; + paymentStatus: string; + paymentMethod: string; + paymentChannel: string; + paymentTransactionId: any; + invoiceInformation: any; + invoicingStatus: string; + productBelongDepartment: string; + waybillNumber: any; + notes: any; + examineNotes: any; + orderStatus: string; + subOrderCreateTime: string; + subOrderUpdateTime: string; + subOrderCreateByName: string; + subOrderUpdateByName: any; + }[]; +} diff --git a/src/pages/Order/OrderWarning/index copy.tsx b/src/pages/Order/OrderWarning/index copy.tsx new file mode 100644 index 0000000..46a9827 --- /dev/null +++ b/src/pages/Order/OrderWarning/index copy.tsx @@ -0,0 +1,5128 @@ +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: '超过7天', + value: 7, + }, + { + label: '超过10天', + value: 10, + }, + ]; + const options2 = [ + { + label: '超过20天', + value: 20, + }, + { + label: '超过45天', + value: 45, + }, + ]; + const options3 = [ + { + label: '超过5天', + value: 5, + }, + { + label: '超过15天', + value: 15, + }, + ]; + 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); + }; + function setOriginTime(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'); + return formattedDate; + } + 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, + waitConfirmReiceptStatusDateTimeLe: setOriginTime(options1[0].value), + waitFeedbackStatusDateTimeLe: setOriginTime(options2[0].value), + waitConfirmInvoiceStatusDateTimeLe: setOriginTime(options3[0].value), + waitConfirmPaymentStatusDateTimeLe: setOriginTime(options4[0].value), + }, + }); + 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 作为依赖 + + useEffect(() => { + // 根据 activeTabKey 设置 value1 为当前选项组的第一个 value + let options; + switch (activeTabKey) { + case 1: + options = options1; + break; + case 2: + options = options2; + break; + case 3: + options = options3; + break; + case 4: + options = options4; + break; + default: + options = []; // 如果没有匹配的选项组,默认为空 + } + + const firstOptionValue = options[0]?.value || 0; // 获取第一个值 + setValue1(firstOptionValue); + const currentDate = new Date(); + // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 + const newDate = new Date(currentDate); + newDate.setDate(currentDate.getDate() - firstOptionValue); + const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss'); + setCalDate(formattedDate); + }, [activeTabKey]); + //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; // 强制查询非作废订单 + params.salesCode = userInfo.username; + params.warningStatus = 'waitConfirmReicept'; + 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'; // 用于回款预警 + params.salesCode = userInfo.username; + if (salesCodeSelect !== undefined && salesCodeSelect !== null) { + params.salesCode = salesCodeSelect; + } + params.isDeleteQueryOrder = false; // 强制查询非作废订单 + params.paymentNotReceipt = true; // 在回款预警中标记未支付订单 + finalParams = { + ...params, + applyTimeLe: calDate, + }; + } + //保存这个搜索条件 + 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; diff --git a/src/pages/Order/OrderWarning/index.tsx b/src/pages/Order/OrderWarning/index.tsx index 46a9827..0a9a136 100644 --- a/src/pages/Order/OrderWarning/index.tsx +++ b/src/pages/Order/OrderWarning/index.tsx @@ -1,4120 +1,34 @@ -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, + // postServiceOrderQueryServiceOrder, 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, - }); - } +import { downloadFile } from '@/services/order'; +import { getSalesCodeOptions } from '@/utils/order'; +import { getUserInfo } from '@/utils/user'; +import { + ActionType, + ProFormInstance, + ProFormSelect, +} from '@ant-design/pro-components'; +import { Badge, Button, Radio, message } from 'antd'; +import { format } from 'date-fns'; +import React, { useEffect, useRef, useState } from 'react'; +import OrderList from '../OrderList/OrderList'; +import './index.less'; +// import { useParams } from '@umijs/max'; - /** - * 仓库可以筛选发货仓库 - */ - if (roleCode === 'warehouseKeeper' || roleCode === 'admin') { - mainOrdersColumns.push({ - title: '发货仓库', - width: 120, - dataIndex: 'shippingWarehouse', - valueType: 'select', - valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS), - hideInTable: true, - }); - } +const OrderPage = () => { + const [salesCodeOptions, setSalesCodeOptions] = useState([]); + const [salesCodeSelect, setSalesCodeSelect] = useState(); + const userInfo = getUserInfo(); - //判断是否是采购,是的话新增一个筛选条件 - if (roleCode === 'procure' || roleCode === 'admin') { - mainOrdersColumns.push({ - title: isSupplier() ? '下单状态' : '采购下单状态', - dataIndex: 'procureOrderStatus', - valueType: 'select', - hideInTable: true, - valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS), - }); - } + const mainTableRef = useRef<ActionType>(); + const mainTableFormRef = useRef<ProFormInstance>(); + let [searchParams] = useState(Object); //表格的查询条件存储 + console.log(searchParams); + const [messageApi] = message.useMessage(); + console.log(messageApi); + const [activeTabKey, setActiveTabKey] = useState(1); // **新增状态** //选择天数1 const options1 = [ @@ -4129,6 +43,16 @@ const OrderPage = () => { ]; const options2 = [ { + label: '超过21天', + value: 21, + }, + { + label: '超过40天', + value: 40, + }, + ]; + const options3 = [ + { label: '超过20天', value: 20, }, @@ -4137,7 +61,7 @@ const OrderPage = () => { value: 45, }, ]; - const options3 = [ + const options4 = [ { label: '超过5天', value: 5, @@ -4147,7 +71,7 @@ const OrderPage = () => { value: 15, }, ]; - const options4 = [ + const options5 = [ { label: '超过30天', value: 30, @@ -4186,6 +110,7 @@ const OrderPage = () => { return formattedDate; } const [invoiceWarningNum, setInvoiceWarningNum] = useState(0); + const [invoiceCreateWarningNum, setInvoiceCreateWarningNum] = useState(0); const [invoiceRefundWarningNum, setInvoiceRefundWarningNum] = useState(0); const [waitConfirmPayment, setWaitConfirmPayment] = useState(0); const [waitFeedback, setWaitFeedback] = useState(0); @@ -4214,12 +139,17 @@ const OrderPage = () => { data: { salesCode: staticSalesCode, waitConfirmReiceptStatusDateTimeLe: setOriginTime(options1[0].value), - waitFeedbackStatusDateTimeLe: setOriginTime(options2[0].value), - waitConfirmInvoiceStatusDateTimeLe: setOriginTime(options3[0].value), - waitConfirmPaymentStatusDateTimeLe: setOriginTime(options4[0].value), + waitConfirmPaymentOrderCreatedDateTimeGe: setOriginTime( + options2[0].value, + ), + waitFeedbackStatusDateTimeLe: setOriginTime(options3[0].value), + waitConfirmInvoiceStatusDateTimeLe: setOriginTime(options4[0].value), + waitConfirmPaymentStatusDateTimeLe: setOriginTime(options5[0].value), }, }); + console.log(res, '5656565656'); setInvoiceWarningNum(res.data.waitConfirmInvoice); + setInvoiceCreateWarningNum(res.data.waitInvoicing); setInvoiceRefundWarningNum(res.data.waitConfirmReceipt); setWaitConfirmPayment(res.data.waitConfirmPayment); setWaitFeedback(res.data.waitFeedback); @@ -4239,7 +169,8 @@ const OrderPage = () => { activeTabKey === 1 || activeTabKey === 2 || activeTabKey === 3 || - activeTabKey === 4 + activeTabKey === 4 || + activeTabKey === 5 ) { setValue1(0); // 清空 value1 } @@ -4270,6 +201,9 @@ const OrderPage = () => { case 4: options = options4; break; + case 5: + options = options5; + break; default: options = []; // 如果没有匹配的选项组,默认为空 } @@ -4305,13 +239,22 @@ const OrderPage = () => { value: 2, label: ( <span> + 开票预警 + <Badge count={invoiceCreateWarningNum} style={{ marginLeft: 8 }} /> + </span> + ), + }, + { + value: 3, + label: ( + <span> 回访登记预警 <Badge count={waitFeedback} style={{ marginLeft: 8 }} /> </span> ), }, { - value: 3, + value: 4, label: ( <span> 确认发票预警 @@ -4320,7 +263,7 @@ const OrderPage = () => { ), }, { - value: 4, + value: 5, label: ( <span> 订单回款预警 @@ -4329,7 +272,6 @@ const OrderPage = () => { ), }, ]; - return ( <div className="order-page-container"> <div id="resizeDiv"></div> @@ -4418,709 +360,154 @@ const OrderPage = () => { /> )} </span> + {/* 右边的 ProFormSelect */} + <span style={{ width: '100px', marginLeft: '' }}> + {' '} + <Button + key="out" + onClick={() => { + let initialParams = {}; + initialParams.isDeleteQueryOrder = false; + initialParams.flag = 50; + initialParams.current = 1; + initialParams.pageSize = 10; + initialParams.condition = 0; + initialParams.sorted = false; + // 根据activeTabKey动态扩展参数 + if (activeTabKey === 1) { + initialParams = { + ...initialParams, + orderStatus: 'SHIPPED', + statusDatetimeLe: calDate, + }; + } else if (activeTabKey === 2) { + initialParams = { + ...initialParams, + warningStatus: 'invoicingWarning', + confirmReceiptDatetimeLe: calDate, + }; + } else if (activeTabKey === 3) { + initialParams = { + ...initialParams, + warningStatus: 'waitFeedbackWarning', + confirmReceiptDatetimeLe: calDate, + }; + } else if (activeTabKey === 4) { + initialParams = { + ...initialParams, + warningStatus: 'invoiceConfirmWarning', + invoicingEndTime: calDate, + }; + } else if (activeTabKey === 5) { + initialParams = { + ...initialParams, + warningStatus: 'paymentReceiptStatusWarning', + paymentNotReceipt: true, + applyTimeLe: calDate, + }; + } + messageApi.open({ + type: 'loading', + content: '导出中...', + duration: 0, + }); + downloadFile( + '/api/service/order/export', + '预警订单.xlsx', + 'POST', + initialParams, + () => { + messageApi.destroy(); + }, + ); + }} + > + 导出 + </Button> + </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> - </> - ); - }, + {/* <OrderList + params={{ + ...(salesCodePermission && { + salesCode: salesCodeSelect !== + undefined && salesCodeSelect !== null ? salesCodeSelect : userInfo.username + }), + ...(activeTabKey === 1 && { + orderStatus: 'SHIPPED', + warningStatus: 'waitConfirmReicept', + statusDatetimeLe: calDate, + }), + ...(activeTabKey === 2 && { + warningStatus: 'waitFeedbackWarning', + confirmReceiptDatetimeLe: calDate, + }), + ...(activeTabKey === 3 && { + warningStatus: 'invoiceConfirmWarning', + invoicingEndTime: calDate, + }), + ...(activeTabKey === 4 && { + warningStatus: 'paymentReceiptStatusWarning', + paymentNotReceipt: true, + applyTimeLe: calDate, + }), }} - // 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 !== ''; - }); + searchShow={false} + toolbarShow={false} /> */} + <OrderList + paramsNew={(function () { + // 初始化参数 + let initialParams = {}; + initialParams.isDeleteQueryOrderNow = false; + if (salesCodePermission) { + if (salesCodeSelect !== undefined && salesCodeSelect !== null) { + initialParams.salesCode = salesCodeSelect; + } else { + initialParams.salesCode = userInfo.username; } } - 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(); - } + // 根据activeTabKey动态扩展参数 if (activeTabKey === 1) { - // // 第一段代码 - // if (calDate === 'null') { - // params.applyTimeLe = null; - // } else { - // params.applyTimeLe = calDate; - // } - // params.applyTimeIsNotNull = true; // 要求申请时间非空 - params.orderStatus = 'SHIPPED'; // 发票确认预警 - params.isDeleteQueryOrder = false; // 强制查询非作废订单 - params.salesCode = userInfo.username; - params.warningStatus = 'waitConfirmReicept'; - if (salesCodeSelect !== undefined && salesCodeSelect !== null) { - params.salesCode = salesCodeSelect; - } - // params.paymentMethod = 'UNPAID'; - finalParams = { - ...params, + initialParams = { + ...initialParams, + orderStatus: 'SHIPPED', + warningStatus: 'waitConfirmReicept', 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, + initialParams = { + ...initialParams, + warningStatus: 'invoicingWarning', 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, + initialParams = { + ...initialParams, + warningStatus: 'waitFeedbackWarning', + confirmReceiptDatetimeLe: calDate, }; } else if (activeTabKey === 4) { - params.warningStatus = 'paymentReceiptStatusWarning'; // 用于回款预警 - params.salesCode = userInfo.username; - if (salesCodeSelect !== undefined && salesCodeSelect !== null) { - params.salesCode = salesCodeSelect; - } - params.isDeleteQueryOrder = false; // 强制查询非作废订单 - params.paymentNotReceipt = true; // 在回款预警中标记未支付订单 - finalParams = { - ...params, + initialParams = { + ...initialParams, + warningStatus: 'invoiceConfirmWarning', + invoicingEndTime: calDate, + }; + } else if (activeTabKey === 5) { + initialParams = { + ...initialParams, + warningStatus: 'paymentReceiptStatusWarning', + paymentNotReceipt: true, applyTimeLe: calDate, }; } - //保存这个搜索条件 - 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(); - // }} + console.log(initialParams, '5656initialParams'); + // 返回完整的参数对象 + return initialParams; + })()} + searchShow={false} + toolbarShow={false} /> - - {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> ); };