Commit 1db34f9955a3b59de6ea099a3364a1ac0f120151

Authored by 曾国涛
2 parents 19ca3d46 967ee14e

Too many changes to show.

To preserve performance only 2 of 3 files are displayed.

dist.zip 0 → 100644
No preview for this file type
src/pages/Order/OrderWarning/index.tsx
... ... @@ -188,7 +188,9 @@ const OrderPage = () => {
188 188 const [mainOrderSelectedMap] = useState(new Map()); //选中的主订单Map key:主订单id value:主订单数据
189 189 const [subOrderSelectedMap, setSubOrderSelectedMap] = useState(new Map()); //选中的子订单Map key:主订单id value:选中的子订单数据集合
190 190 const [currentOptMainId, setCurrentMainId] = useState<any>(undefined); //当前操作对象的主订单id
  191 + // const [currentOptMainId, setCurrentMainId] = useState<any>(undefined); //当前操作对象的主订单id
191 192 const [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id
  193 + // const [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id
192 194 const [subOrderCount, setSubOrderCount] = useState(0);
193 195 const [sorted] = useState(false);
194 196 const mainTableRef = useRef<ActionType>();
... ... @@ -206,6 +208,7 @@ const OrderPage = () =&gt; {
206 208 const [ids, setIds] = useState([]);
207 209 const [recordOptNode, setRecordOptNode] = useState(null);
208 210 const roleCode = userInfo?.roleSmallVO?.code;
  211 + const [activeTabKey, setActiveTabKey] = useState('1'); // **新增状态**
209 212  
210 213 const triggerRecordOptNode = async (id) => {
211 214 const res = await postServiceOrderGetCurrentOptNode({
... ... @@ -381,7 +384,7 @@ const OrderPage = () =&gt; {
381 384 * 返回当前操作的主订单数据
382 385 */
383 386 function buildMainOrder() {
384   - if (currentOptMainId === undefined || currentOptMainId === null) {
  387 + if (!currentOptMainId) {
385 388 message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
386 389 return;
387 390 }
... ... @@ -393,11 +396,9 @@ const OrderPage = () =&gt; {
393 396 if (matchedData.length > 0) {
394 397 mainOrderClone = cloneDeep(matchedData[0]);
395 398 }
396   -
397   - if (mainOrderClone === null) {
  399 + if (!mainOrderClone) {
398 400 message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员');
399 401 }
400   -
401 402 return mainOrderClone;
402 403 }
403 404  
... ... @@ -405,7 +406,7 @@ const OrderPage = () =&gt; {
405 406 * 返回当前操作的子订单集合
406 407 */
407 408 function buildSubOrders() {
408   - if (currentOptMainId === undefined || currentOptMainId === null) {
  409 + if (!currentOptMainId) {
409 410 message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
410 411 return;
411 412 }
... ... @@ -414,8 +415,10 @@ const OrderPage = () =&gt; {
414 415  
415 416 //如果没有传当前操作的子订单id,说明是操作主订单
416 417 if (curretnOptSubId === undefined || curretnOptSubId === null) {
  418 + // if (!curretnOptSubId) {
417 419 //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象
418 420 let currentOptSubOrders = subOrderSelectedMap.get(currentOptMainId);
  421 +
419 422 if (
420 423 currentOptSubOrders === null ||
421 424 currentOptSubOrders === undefined ||
... ... @@ -446,12 +449,10 @@ const OrderPage = () =&gt; {
446 449 }
447 450 }
448 451 }
449   -
450 452 if (cloneSubOrders.length === 0) {
451 453 message.error('页面错误:当前操作的订单数据不存在,请联系系统管理员');
452 454 return;
453 455 }
454   -
455 456 return cloneSubOrders;
456 457 }
457 458  
... ... @@ -3995,6 +3996,58 @@ const OrderPage = () =&gt; {
3995 3996 },
3996 3997 );
3997 3998  
  3999 + // 主订单列表
  4000 + const mainOrdersColumns2: ProColumns<OrderType>[] = MAIN_ORDER_COLUMNS.map(
  4001 + (item) => {
  4002 + //首能账号只能搜索订单编号
  4003 + let canSearchIndex = [
  4004 + 'id',
  4005 + 'salesCode',
  4006 + 'subNotes',
  4007 + 'orderStatus',
  4008 + 'createTime',
  4009 + 'modifiedAuditStatus',
  4010 + ];
  4011 + if (isSupplier() && !canSearchIndex.includes(item.dataIndex)) {
  4012 + item.search = false;
  4013 + }
  4014 +
  4015 + canSearchIndex = [
  4016 + 'id',
  4017 + 'salesCode',
  4018 + 'customerName',
  4019 + 'institution',
  4020 + 'productName',
  4021 + 'orderStatus',
  4022 + 'createTime',
  4023 + ];
  4024 +
  4025 + if (isExaminer() && !canSearchIndex.includes(item.dataIndex)) {
  4026 + item.search = false;
  4027 + }
  4028 +
  4029 + if (item.dataIndex === 'name') {
  4030 + return {
  4031 + ...item,
  4032 + title: <OrderTableHeader />,
  4033 + render: (text, record) => {
  4034 + return <MainOrderColumnRender record={record} />;
  4035 + },
  4036 + };
  4037 + }
  4038 +
  4039 + /**
  4040 + * 采购的订单状态筛选内容
  4041 + */
  4042 + if (roleCode === 'procure' && item.dataIndex === 'orderStatus') {
  4043 + item.valueEnum = enumToProTableEnumValue(
  4044 + PROCURE_PRIMARY_ORDER_STATUS_OPTIONS,
  4045 + );
  4046 + }
  4047 + return item;
  4048 + },
  4049 + );
  4050 +
3998 4051 /**
3999 4052 * 采购可以筛选供应商备注
4000 4053 */
... ... @@ -4006,6 +4059,13 @@ const OrderPage = () =&gt; {
4006 4059 valueType: 'text',
4007 4060 hideInTable: true,
4008 4061 });
  4062 + mainOrdersColumns2.push({
  4063 + title: '供应商备注',
  4064 + width: 120,
  4065 + dataIndex: 'supplierNotes',
  4066 + valueType: 'text',
  4067 + hideInTable: true,
  4068 + });
4009 4069 }
4010 4070  
4011 4071 /**
... ... @@ -4026,6 +4086,20 @@ const OrderPage = () =&gt; {
4026 4086 },
4027 4087 hideInTable: true,
4028 4088 });
  4089 + mainOrdersColumns2.push({
  4090 + title: '采购名称',
  4091 + width: 120,
  4092 + dataIndex: 'supplierName',
  4093 + valueType: 'select',
  4094 + request: async () => {
  4095 + const res = await postServiceOrderProvideProcurementRoles();
  4096 + let options = res.data?.map((item) => {
  4097 + return { label: item, value: item };
  4098 + });
  4099 + return options;
  4100 + },
  4101 + hideInTable: true,
  4102 + });
4029 4103 }
4030 4104  
4031 4105 /**
... ... @@ -4049,6 +4123,23 @@ const OrderPage = () =&gt; {
4049 4123 },
4050 4124 hideInTable: true,
4051 4125 });
  4126 + mainOrdersColumns2.push({
  4127 + title: '采购排除',
  4128 + width: 120,
  4129 + dataIndex: 'excludeProcureNames',
  4130 + fieldProps: {
  4131 + mode: 'multiple',
  4132 + },
  4133 + valueType: 'select',
  4134 + request: async () => {
  4135 + const res = await postServiceOrderProvideProcurementRoles();
  4136 + let options = res.data?.map((item) => {
  4137 + return { label: item, value: item };
  4138 + });
  4139 + return options;
  4140 + },
  4141 + hideInTable: true,
  4142 + });
4052 4143 }
4053 4144  
4054 4145 /**
... ... @@ -4063,6 +4154,14 @@ const OrderPage = () =&gt; {
4063 4154 valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS),
4064 4155 hideInTable: true,
4065 4156 });
  4157 + mainOrdersColumns2.push({
  4158 + title: '发货仓库',
  4159 + width: 120,
  4160 + dataIndex: 'shippingWarehouse',
  4161 + valueType: 'select',
  4162 + valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS),
  4163 + hideInTable: true,
  4164 + });
4066 4165 }
4067 4166  
4068 4167 //判断是否是采购,是的话新增一个筛选条件
... ... @@ -4074,6 +4173,13 @@ const OrderPage = () =&gt; {
4074 4173 hideInTable: true,
4075 4174 valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
4076 4175 });
  4176 + mainOrdersColumns2.push({
  4177 + title: isSupplier() ? '下单状态' : '采购下单状态',
  4178 + dataIndex: 'procureOrderStatus',
  4179 + valueType: 'select',
  4180 + hideInTable: true,
  4181 + valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
  4182 + });
4077 4183 }
4078 4184  
4079 4185 //选择天数1
... ... @@ -4184,6 +4290,7 @@ const OrderPage = () =&gt; {
4184 4290 filter,
4185 4291 data: { ...params, statusDatetimeGe: calDate },
4186 4292 });
  4293 + console.log(res.data, '5656request');
4187 4294  
4188 4295 const data = res.data;
4189 4296 setRolePath(data.specialPath);
... ... @@ -4219,6 +4326,14 @@ const OrderPage = () =&gt; {
4219 4326 mainTableSecondRef.current?.reload();
4220 4327 }
4221 4328 }, [calDate2]);
  4329 + useEffect(() => {
  4330 + if (activeTabKey === '1') {
  4331 + mainTableRef.current?.reload(); // **修改位置:在选择第二个标签时请求request2**
  4332 + }
  4333 + if (activeTabKey === '2') {
  4334 + mainTableSecondRef.current?.reload(); // **修改位置:在选择第二个标签时请求request2**
  4335 + }
  4336 + }, [activeTabKey]);
4222 4337  
4223 4338 const request2 = async (
4224 4339 // 第一个参数 params 查询表单和 params 参数的结合
... ... @@ -4274,6 +4389,7 @@ const OrderPage = () =&gt; {
4274 4389 filter,
4275 4390 data: { ...params },
4276 4391 });
  4392 + console.log(data, '5656request2');
4277 4393  
4278 4394 setRolePath(data.specialPath);
4279 4395 setSubOrderCount(data.count);
... ... @@ -4311,7 +4427,7 @@ const OrderPage = () =&gt; {
4311 4427 };
4312 4428 const tabsItems = [
4313 4429 {
4314   - key: 1,
  4430 + key: '1',
4315 4431 label: (
4316 4432 <span>
4317 4433 发票确认预警
... ... @@ -4398,7 +4514,8 @@ const OrderPage = () =&gt; {
4398 4514 search={false}
4399 4515 // labelWidth: 'auto',
4400 4516 // onCollapse: resize,
4401   - request={request}
  4517 + // request={request}
  4518 + request={activeTabKey === '1' ? request : null} // **条件请求**
4402 4519 toolbar={{
4403 4520 multipleLine: true,
4404 4521 }}
... ... @@ -4891,7 +5008,7 @@ const OrderPage = () =&gt; {
4891 5008 ),
4892 5009 },
4893 5010 {
4894   - key: 2,
  5011 + key: '2',
4895 5012 label: (
4896 5013 <span>
4897 5014 订单回款预警
... ... @@ -4929,7 +5046,7 @@ const OrderPage = () =&gt; {
4929 5046 actionRef={mainTableSecondRef}
4930 5047 formRef={mainTableSecondFormRef}
4931 5048 expandIconColumnIndex={-1}
4932   - columns={mainOrdersColumns}
  5049 + columns={mainOrdersColumns2}
4933 5050 rowKey="id"
4934 5051 pagination={{
4935 5052 showQuickJumper: true,
... ... @@ -4939,6 +5056,7 @@ const OrderPage = () =&gt; {
4939 5056 onChange: (page, size) => {
4940 5057 setPageSize(size);
4941 5058 setCurrentPage(page);
  5059 + mainTableSecondRef.current?.reload();
4942 5060 },
4943 5061 showTotal: (total, range) => {
4944 5062 return (
... ... @@ -4968,7 +5086,8 @@ const OrderPage = () =&gt; {
4968 5086 search={false}
4969 5087 // labelWidth: 'auto',
4970 5088 // onCollapse: resize,
4971   - request={request2}
  5089 + // request={request2}
  5090 + request={activeTabKey === '2' ? request2 : null} // **条件请求**
4972 5091 toolbar={{
4973 5092 multipleLine: true,
4974 5093 }}
... ... @@ -5465,7 +5584,21 @@ const OrderPage = () =&gt; {
5465 5584 return (
5466 5585 <div className="order-page-container">
5467 5586 <div id="resizeDiv"></div>
5468   - <Tabs defaultActiveKey="1" items={tabsItems} onChange={() => {}} />
  5587 + {/* <Tabs defaultActiveKey="1" items={tabsItems} onChange={() => { }} /> */}
  5588 + <Tabs
  5589 + defaultActiveKey="1"
  5590 + items={tabsItems}
  5591 + onChange={(key) => {
  5592 + setActiveTabKey(key); // **修改位置:更新 activeTabKey**
  5593 + if (key === '1') {
  5594 + setActiveTabKey(key); // **修改位置:更新 activeTabKey**
  5595 + mainTableRef.current?.reload(); // **请求主订单的 request**
  5596 + } else if (key === '2') {
  5597 + setActiveTabKey(key); // **修改位置:更新 activeTabKey**
  5598 + mainTableSecondRef.current?.reload(); // **请求订单回款的 request2**
  5599 + }
  5600 + }}
  5601 + />
5469 5602 </div>
5470 5603 );
5471 5604 };
... ...