@@ -38,7 +38,7 @@ import {
38
38
Tag ,
39
39
Typography ,
40
40
} from 'antd' ;
41
- import React , { useEffect , useState } from 'react' ;
41
+ import React , { useEffect , useMemo , useState } from 'react' ;
42
42
import { TaskPartitionStrategyMap } from '../../const' ;
43
43
import { ITableConfig } from '../../PartitionTask/CreateModal' ;
44
44
import { START_DATE } from './const' ;
@@ -207,6 +207,7 @@ const ConfigDrawer: React.FC<IProps> = (props) => {
207
207
const [ form ] = Form . useForm ( ) ;
208
208
const strategies = Form . useWatch ( 'strategies' , form ) ;
209
209
const nameRuleType = Form . useWatch ( 'nameRuleType' , form ) ;
210
+ const generateCount = Form . useWatch ( 'generateCount' , form ) ;
210
211
const partitionKeyOptions =
211
212
configs ?. [ 0 ] ?. option ?. partitionKeyConfigs
212
213
?. filter ( ( item ) => item ?. type ?. localizedMessage )
@@ -415,6 +416,88 @@ const ConfigDrawer: React.FC<IProps> = (props) => {
415
416
}
416
417
} , [ configs , visible ] ) ;
417
418
419
+ const submitBtn = useMemo ( ( ) => {
420
+ const isSingleGenerateCount = generateCount === 1 ;
421
+ const isSingleGenerateCountMessage =
422
+ '当前预创建分区数量过小,若调度失败恐影响业务运行,建议调整预创建分区数量至2个及以上。' ;
423
+ const isBatchMessage = formatMessage ( {
424
+ id : 'odc.components.PartitionPolicyTable.configModal.BatchSettingWillOverwriteThe' ,
425
+ defaultMessage : '批量设置将覆盖原有的策略,是否确定设置?' ,
426
+ } ) ;
427
+ if ( isBatch ) {
428
+ return (
429
+ < Popconfirm
430
+ overlayStyle = { { width : '216px' } }
431
+ title = {
432
+ isSingleGenerateCount ? (
433
+ < >
434
+ < div > { isSingleGenerateCountMessage } </ div >
435
+ < div > { isBatchMessage } </ div >
436
+ </ >
437
+ ) : (
438
+ isBatchMessage
439
+ )
440
+ } /*批量设置将覆盖原有的策略,是否确定设置?*/
441
+ onConfirm = { handleOk }
442
+ okText = { formatMessage ( {
443
+ id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
444
+ defaultMessage : '确定' ,
445
+ } ) } /*确定*/
446
+ cancelText = { formatMessage ( {
447
+ id : 'odc.components.PartitionPolicyTable.configModal.Return' ,
448
+ defaultMessage : '返回' ,
449
+ } ) } /*返回*/
450
+ >
451
+ < Button type = "primary" >
452
+ {
453
+ formatMessage ( {
454
+ id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
455
+ defaultMessage : '确定' ,
456
+ } ) /*确定*/
457
+ }
458
+ </ Button >
459
+ </ Popconfirm >
460
+ ) ;
461
+ }
462
+ if ( isSingleGenerateCount ) {
463
+ return (
464
+ < Popconfirm
465
+ overlayStyle = { { width : '216px' } }
466
+ title = { isSingleGenerateCountMessage }
467
+ onConfirm = { handleOk }
468
+ okText = { formatMessage ( {
469
+ id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
470
+ defaultMessage : '确定' ,
471
+ } ) } /*确定*/
472
+ cancelText = { formatMessage ( {
473
+ id : 'odc.components.PartitionPolicyTable.configModal.Return' ,
474
+ defaultMessage : '返回' ,
475
+ } ) } /*返回*/
476
+ placement = "topRight"
477
+ >
478
+ < Button type = "primary" >
479
+ {
480
+ formatMessage ( {
481
+ id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
482
+ defaultMessage : '确定' ,
483
+ } ) /*确定*/
484
+ }
485
+ </ Button >
486
+ </ Popconfirm >
487
+ ) ;
488
+ }
489
+ return (
490
+ < Button type = "primary" onClick = { handleOk } >
491
+ {
492
+ formatMessage ( {
493
+ id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
494
+ defaultMessage : '确定' ,
495
+ } ) /*确定*/
496
+ }
497
+ </ Button >
498
+ ) ;
499
+ } , [ isBatch , generateCount ] ) ;
500
+
418
501
return (
419
502
< Drawer
420
503
title = {
@@ -455,42 +538,7 @@ const ConfigDrawer: React.FC<IProps> = (props) => {
455
538
} ) /* 预览 SQL */
456
539
}
457
540
</ Button >
458
- { isBatch ? (
459
- < Popconfirm
460
- overlayStyle = { { width : '216px' } }
461
- title = { formatMessage ( {
462
- id : 'odc.components.PartitionPolicyTable.configModal.BatchSettingWillOverwriteThe' ,
463
- defaultMessage : '批量设置将覆盖原有的策略,是否确定设置?' ,
464
- } ) } /*批量设置将覆盖原有的策略,是否确定设置?*/
465
- onConfirm = { handleOk }
466
- okText = { formatMessage ( {
467
- id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
468
- defaultMessage : '确定' ,
469
- } ) } /*确定*/
470
- cancelText = { formatMessage ( {
471
- id : 'odc.components.PartitionPolicyTable.configModal.Return' ,
472
- defaultMessage : '返回' ,
473
- } ) } /*返回*/
474
- >
475
- < Button type = "primary" >
476
- {
477
- formatMessage ( {
478
- id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
479
- defaultMessage : '确定' ,
480
- } ) /*确定*/
481
- }
482
- </ Button >
483
- </ Popconfirm >
484
- ) : (
485
- < Button type = "primary" onClick = { handleOk } >
486
- {
487
- formatMessage ( {
488
- id : 'odc.components.PartitionPolicyTable.configModal.Ok' ,
489
- defaultMessage : '确定' ,
490
- } ) /*确定*/
491
- }
492
- </ Button >
493
- ) }
541
+ { submitBtn }
494
542
</ Space >
495
543
}
496
544
>
0 commit comments