Commit 6e61e86c45855a540039dd6594322f2dec364aa2

Authored by boyang
1 parent 0567bf0b

fix: 修改回款bug

src/pages/Order/OrderWarning/index.tsx
... ... @@ -197,10 +197,8 @@ const OrderPage = () => {
197 197 const mainTableSecondRef = useRef<ActionType>();
198 198 const mainTableFormRef = useRef<ProFormInstance>();
199 199 const mainTableSecondFormRef = useRef<ProFormInstance>();
200   - let [searchParams, setSearchParam] = useState(Object); //表格的查询条件存储
201   - console.log(searchParams);
202   - const [messageApi, contextHolder] = message.useMessage();
203   - console.log(messageApi);
  200 + let [setSearchParam] = useState(Object); //表格的查询条件存储
  201 + const [contextHolder] = message.useMessage();
204 202 const [
205 203 shippingWarehouseChangeModalVisible,
206 204 setShippingWarehouseChangeModalVisible,
... ... @@ -208,6 +206,7 @@ const OrderPage = () =&gt; {
208 206 const [ids, setIds] = useState([]);
209 207 const [recordOptNode, setRecordOptNode] = useState(null);
210 208 const roleCode = userInfo?.roleSmallVO?.code;
  209 + const [activeTabKey, setActiveTabKey] = useState('1'); // **新增状态**
211 210  
212 211 const triggerRecordOptNode = async (id) => {
213 212 const res = await postServiceOrderGetCurrentOptNode({
... ... @@ -333,10 +332,8 @@ const OrderPage = () =&gt; {
333 332 * @param mainId
334 333 */
335 334 function createOptObject(subId: any, mainId: any) {
336   - console.log(currentOptMainId, '5656createOptObject1', curretnOptSubId);
337 335 setCurrentMainId(mainId);
338 336 setCurretnOptSubId(subId);
339   - console.log(currentOptMainId, '5656createOptObject2', curretnOptSubId);
340 337 }
341 338  
342 339 /**
... ... @@ -385,11 +382,6 @@ const OrderPage = () =&gt; {
385 382 * 返回当前操作的主订单数据
386 383 */
387 384 function buildMainOrder() {
388   - console.log(
389   - currentOptMainId,
390   - '5656buildMainOrder currentOptMainId/curretnOptSubId',
391   - curretnOptSubId,
392   - );
393 385 if (!currentOptMainId) {
394 386 message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
395 387 return;
... ... @@ -399,11 +391,9 @@ const OrderPage = () =&gt; {
399 391 let matchedData = data.filter((item) => {
400 392 return item.id === currentOptMainId;
401 393 });
402   - console.log(data, '5656buildMainOrder2 data/matchedData', matchedData);
403 394 if (matchedData.length > 0) {
404 395 mainOrderClone = cloneDeep(matchedData[0]);
405 396 }
406   - console.log(mainOrderClone, '5656buildMainOrder mainOrderClone');
407 397 if (!mainOrderClone) {
408 398 message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员');
409 399 }
... ... @@ -414,11 +404,6 @@ const OrderPage = () =&gt; {
414 404 * 返回当前操作的子订单集合
415 405 */
416 406 function buildSubOrders() {
417   - console.log(
418   - curretnOptSubId,
419   - '5656buildSubOrders currentOptMainId/currentOptMainId',
420   - currentOptMainId,
421   - );
422 407 if (!currentOptMainId) {
423 408 message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
424 409 return;
... ... @@ -431,11 +416,6 @@ const OrderPage = () =&gt; {
431 416 // if (!curretnOptSubId) {
432 417 //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象
433 418 let currentOptSubOrders = subOrderSelectedMap.get(currentOptMainId);
434   - console.log(
435   - subOrderSelectedMap,
436   - '5656buildSubOrders subOrderSelectedMap/currentOptSubOrders',
437   - currentOptSubOrders,
438   - );
439 419 if (
440 420 currentOptSubOrders === null ||
441 421 currentOptSubOrders === undefined ||
... ... @@ -455,11 +435,6 @@ const OrderPage = () =&gt; {
455 435 }
456 436 } else {
457 437 //操作的是子订单
458   - console.log(
459   - subOrderSelectedMap,
460   - '5656buildSubOrders2 subOrderSelectedMap/data',
461   - data,
462   - );
463 438 for (let item of data) {
464 439 if (item.id === currentOptMainId) {
465 440 for (let subOrder of item?.subOrderInformationLists) {
... ... @@ -471,11 +446,6 @@ const OrderPage = () =&gt; {
471 446 }
472 447 }
473 448 }
474   - console.log(
475   - cloneSubOrders,
476   - '5656cloneSubOrders/length',
477   - cloneSubOrders.length,
478   - );
479 449 if (cloneSubOrders.length === 0) {
480 450 message.error('页面错误:当前操作的订单数据不存在,请联系系统管理员');
481 451 return;
... ... @@ -670,8 +640,6 @@ const OrderPage = () =&gt; {
670 640 * @param optRecord
671 641 */
672 642 function getOrderStatusTag(optRecord: any): import('react').ReactNode {
673   - console.log(optRecord);
674   -
675 643 const orderStatus = optRecord.orderStatus;
676 644 const paymentMethod = optRecord.paymentMethod;
677 645 let orderStatusTagText = enumValueToLabel(
... ... @@ -1362,11 +1330,6 @@ const OrderPage = () =&gt; {
1362 1330 className="p-0"
1363 1331 type="link"
1364 1332 onClick={() => {
1365   - console.log(
1366   - optRecord.id,
1367   - '5656optRecord.id, record.id',
1368   - record.id,
1369   - );
1370 1333 createOptObject(optRecord.id, record.id);
1371 1334 setUploadPayBillModalVisible(true);
1372 1335 }}
... ... @@ -2873,7 +2836,6 @@ const OrderPage = () =&gt; {
2873 2836 onClick={() => {
2874 2837 setCurrentMainId(record.id);
2875 2838 setReissueVisibleOld(true);
2876   - console.log(reissueVisible);
2877 2839 }}
2878 2840 >
2879 2841 重新开票(旧)
... ... @@ -4028,6 +3990,58 @@ const OrderPage = () =&gt; {
4028 3990 },
4029 3991 );
4030 3992  
  3993 + // 主订单列表
  3994 + const mainOrdersColumns2: ProColumns<OrderType>[] = MAIN_ORDER_COLUMNS.map(
  3995 + (item) => {
  3996 + //首能账号只能搜索订单编号
  3997 + let canSearchIndex = [
  3998 + 'id',
  3999 + 'salesCode',
  4000 + 'subNotes',
  4001 + 'orderStatus',
  4002 + 'createTime',
  4003 + 'modifiedAuditStatus',
  4004 + ];
  4005 + if (isSupplier() && !canSearchIndex.includes(item.dataIndex)) {
  4006 + item.search = false;
  4007 + }
  4008 +
  4009 + canSearchIndex = [
  4010 + 'id',
  4011 + 'salesCode',
  4012 + 'customerName',
  4013 + 'institution',
  4014 + 'productName',
  4015 + 'orderStatus',
  4016 + 'createTime',
  4017 + ];
  4018 +
  4019 + if (isExaminer() && !canSearchIndex.includes(item.dataIndex)) {
  4020 + item.search = false;
  4021 + }
  4022 +
  4023 + if (item.dataIndex === 'name') {
  4024 + return {
  4025 + ...item,
  4026 + title: <OrderTableHeader />,
  4027 + render: (text, record) => {
  4028 + return <MainOrderColumnRender record={record} />;
  4029 + },
  4030 + };
  4031 + }
  4032 +
  4033 + /**
  4034 + * 采购的订单状态筛选内容
  4035 + */
  4036 + if (roleCode === 'procure' && item.dataIndex === 'orderStatus') {
  4037 + item.valueEnum = enumToProTableEnumValue(
  4038 + PROCURE_PRIMARY_ORDER_STATUS_OPTIONS,
  4039 + );
  4040 + }
  4041 + return item;
  4042 + },
  4043 + );
  4044 +
4031 4045 /**
4032 4046 * 采购可以筛选供应商备注
4033 4047 */
... ... @@ -4039,6 +4053,13 @@ const OrderPage = () =&gt; {
4039 4053 valueType: 'text',
4040 4054 hideInTable: true,
4041 4055 });
  4056 + mainOrdersColumns2.push({
  4057 + title: '供应商备注',
  4058 + width: 120,
  4059 + dataIndex: 'supplierNotes',
  4060 + valueType: 'text',
  4061 + hideInTable: true,
  4062 + });
4042 4063 }
4043 4064  
4044 4065 /**
... ... @@ -4059,6 +4080,20 @@ const OrderPage = () =&gt; {
4059 4080 },
4060 4081 hideInTable: true,
4061 4082 });
  4083 + mainOrdersColumns2.push({
  4084 + title: '采购名称',
  4085 + width: 120,
  4086 + dataIndex: 'supplierName',
  4087 + valueType: 'select',
  4088 + request: async () => {
  4089 + const res = await postServiceOrderProvideProcurementRoles();
  4090 + let options = res.data?.map((item) => {
  4091 + return { label: item, value: item };
  4092 + });
  4093 + return options;
  4094 + },
  4095 + hideInTable: true,
  4096 + });
4062 4097 }
4063 4098  
4064 4099 /**
... ... @@ -4082,6 +4117,23 @@ const OrderPage = () =&gt; {
4082 4117 },
4083 4118 hideInTable: true,
4084 4119 });
  4120 + mainOrdersColumns2.push({
  4121 + title: '采购排除',
  4122 + width: 120,
  4123 + dataIndex: 'excludeProcureNames',
  4124 + fieldProps: {
  4125 + mode: 'multiple',
  4126 + },
  4127 + valueType: 'select',
  4128 + request: async () => {
  4129 + const res = await postServiceOrderProvideProcurementRoles();
  4130 + let options = res.data?.map((item) => {
  4131 + return { label: item, value: item };
  4132 + });
  4133 + return options;
  4134 + },
  4135 + hideInTable: true,
  4136 + });
4085 4137 }
4086 4138  
4087 4139 /**
... ... @@ -4096,6 +4148,14 @@ const OrderPage = () =&gt; {
4096 4148 valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS),
4097 4149 hideInTable: true,
4098 4150 });
  4151 + mainOrdersColumns2.push({
  4152 + title: '发货仓库',
  4153 + width: 120,
  4154 + dataIndex: 'shippingWarehouse',
  4155 + valueType: 'select',
  4156 + valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS),
  4157 + hideInTable: true,
  4158 + });
4099 4159 }
4100 4160  
4101 4161 //判断是否是采购,是的话新增一个筛选条件
... ... @@ -4107,6 +4167,13 @@ const OrderPage = () =&gt; {
4107 4167 hideInTable: true,
4108 4168 valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
4109 4169 });
  4170 + mainOrdersColumns2.push({
  4171 + title: isSupplier() ? '下单状态' : '采购下单状态',
  4172 + dataIndex: 'procureOrderStatus',
  4173 + valueType: 'select',
  4174 + hideInTable: true,
  4175 + valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
  4176 + });
4110 4177 }
4111 4178  
4112 4179 //选择天数1
... ... @@ -4217,6 +4284,7 @@ const OrderPage = () =&gt; {
4217 4284 filter,
4218 4285 data: { ...params, statusDatetimeGe: calDate },
4219 4286 });
  4287 + console.log(res.data, '5656request');
4220 4288  
4221 4289 const data = res.data;
4222 4290 setRolePath(data.specialPath);
... ... @@ -4252,6 +4320,14 @@ const OrderPage = () =&gt; {
4252 4320 mainTableSecondRef.current?.reload();
4253 4321 }
4254 4322 }, [calDate2]);
  4323 + useEffect(() => {
  4324 + if (activeTabKey === '1') {
  4325 + mainTableRef.current?.reload(); // **修改位置:在选择第二个标签时请求request2**
  4326 + }
  4327 + if (activeTabKey === '2') {
  4328 + mainTableSecondRef.current?.reload(); // **修改位置:在选择第二个标签时请求request2**
  4329 + }
  4330 + }, [activeTabKey]);
4255 4331  
4256 4332 const request2 = async (
4257 4333 // 第一个参数 params 查询表单和 params 参数的结合
... ... @@ -4307,6 +4383,7 @@ const OrderPage = () =&gt; {
4307 4383 filter,
4308 4384 data: { ...params },
4309 4385 });
  4386 + console.log(data, '5656request2');
4310 4387  
4311 4388 setRolePath(data.specialPath);
4312 4389 setSubOrderCount(data.count);
... ... @@ -4344,7 +4421,7 @@ const OrderPage = () =&gt; {
4344 4421 };
4345 4422 const tabsItems = [
4346 4423 {
4347   - key: 1,
  4424 + key: '1',
4348 4425 label: (
4349 4426 <span>
4350 4427 发票确认预警
... ... @@ -4431,7 +4508,8 @@ const OrderPage = () =&gt; {
4431 4508 search={false}
4432 4509 // labelWidth: 'auto',
4433 4510 // onCollapse: resize,
4434   - request={request}
  4511 + // request={request}
  4512 + request={activeTabKey === '1' ? request : null} // **条件请求**
4435 4513 toolbar={{
4436 4514 multipleLine: true,
4437 4515 }}
... ... @@ -4924,7 +5002,7 @@ const OrderPage = () =&gt; {
4924 5002 ),
4925 5003 },
4926 5004 {
4927   - key: 2,
  5005 + key: '2',
4928 5006 label: (
4929 5007 <span>
4930 5008 订单回款预警
... ... @@ -4962,7 +5040,7 @@ const OrderPage = () =&gt; {
4962 5040 actionRef={mainTableSecondRef}
4963 5041 formRef={mainTableSecondFormRef}
4964 5042 expandIconColumnIndex={-1}
4965   - columns={mainOrdersColumns}
  5043 + columns={mainOrdersColumns2}
4966 5044 rowKey="id"
4967 5045 pagination={{
4968 5046 showQuickJumper: true,
... ... @@ -4972,6 +5050,7 @@ const OrderPage = () =&gt; {
4972 5050 onChange: (page, size) => {
4973 5051 setPageSize(size);
4974 5052 setCurrentPage(page);
  5053 + mainTableSecondRef.current?.reload();
4975 5054 },
4976 5055 showTotal: (total, range) => {
4977 5056 return (
... ... @@ -5001,7 +5080,8 @@ const OrderPage = () =&gt; {
5001 5080 search={false}
5002 5081 // labelWidth: 'auto',
5003 5082 // onCollapse: resize,
5004   - request={request2}
  5083 + // request={request2}
  5084 + request={activeTabKey === '2' ? request2 : null} // **条件请求**
5005 5085 toolbar={{
5006 5086 multipleLine: true,
5007 5087 }}
... ... @@ -5498,7 +5578,21 @@ const OrderPage = () =&gt; {
5498 5578 return (
5499 5579 <div className="order-page-container">
5500 5580 <div id="resizeDiv"></div>
5501   - <Tabs defaultActiveKey="1" items={tabsItems} onChange={() => {}} />
  5581 + {/* <Tabs defaultActiveKey="1" items={tabsItems} onChange={() => { }} /> */}
  5582 + <Tabs
  5583 + defaultActiveKey="1"
  5584 + items={tabsItems}
  5585 + onChange={(key) => {
  5586 + setActiveTabKey(key); // **修改位置:更新 activeTabKey**
  5587 + if (key === '1') {
  5588 + setActiveTabKey(key); // **修改位置:更新 activeTabKey**
  5589 + mainTableRef.current?.reload(); // **请求主订单的 request**
  5590 + } else if (key === '2') {
  5591 + setActiveTabKey(key); // **修改位置:更新 activeTabKey**
  5592 + mainTableSecondRef.current?.reload(); // **请求订单回款的 request2**
  5593 + }
  5594 + }}
  5595 + />
5502 5596 </div>
5503 5597 );
5504 5598 };
... ...