...
|
...
|
@@ -30,18 +30,19 @@ import React, { |
30
|
30
|
} from 'react';
|
31
|
31
|
import JSONEditor from './codeMirror';
|
32
|
32
|
import './style.less';
|
33
|
|
-// import { QxFieldSetter } from '@qx/common';
|
|
33
|
+import { QxFieldSetter } from '@qx/common';
|
34
|
34
|
import { formatEnum } from './constant';
|
35
|
|
-// import {
|
36
|
|
-// typeTranslateFieIdtype,
|
37
|
|
-// typeTranslateWidget,
|
38
|
|
-// typeTranslateGrouptype,
|
39
|
|
-// typeTranslateItemtype,
|
40
|
|
-// } from './constant';
|
|
35
|
+import {
|
|
36
|
+ typeTranslateFieIdtype,
|
|
37
|
+ typeTranslateWidget,
|
|
38
|
+ typeTranslateGrouptype,
|
|
39
|
+ typeTranslateItemtype,
|
|
40
|
+} from './constant';
|
41
|
41
|
// import { Controlled as CodeMirror } from 'react-codemirror2'
|
42
|
|
-import { cloneDeep } from 'lodash-es';
|
|
42
|
+import { cloneDeep, debounce } from 'lodash-es';
|
|
43
|
+import _ from 'lodash';
|
43
|
44
|
import moment from 'dayjs';
|
44
|
|
-import {QxBaseIcon} from '@qx/common';
|
|
45
|
+import { QxBaseIcon } from '@qx/common';
|
45
|
46
|
|
46
|
47
|
const valueOptions = [
|
47
|
48
|
{ key: 'STRING', title: '文本' },
|
...
|
...
|
@@ -87,7 +88,6 @@ const onChange = (e: React.ChangeEvent<HTMLInputElement>) => { |
87
|
88
|
e.persist();
|
88
|
89
|
const { value } = e.target;
|
89
|
90
|
console.log('onChange value', value);
|
90
|
|
-
|
91
|
91
|
// if (!value) {
|
92
|
92
|
// setExpandedKeys(undefined);
|
93
|
93
|
// setAutoExpandParent(false);
|
...
|
...
|
@@ -118,7 +118,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
118
|
118
|
handleAddtree,
|
119
|
119
|
handleDelete,
|
120
|
120
|
handleChange,
|
121
|
|
- // handleChangeField,
|
|
121
|
+ handleChangeField,
|
122
|
122
|
inputKey,
|
123
|
123
|
} = props;
|
124
|
124
|
console.log('data', data);
|
...
|
...
|
@@ -139,6 +139,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
139
|
139
|
};
|
140
|
140
|
|
141
|
141
|
const checkShowTree = (_data: any) => {
|
|
142
|
+ console.log('_data', _data)
|
142
|
143
|
if (_data.type == 'ARRAY') {
|
143
|
144
|
if (_data.child && _data.child.length > 0) {
|
144
|
145
|
return false;
|
...
|
...
|
@@ -247,8 +248,8 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
247
|
248
|
<span>
|
248
|
249
|
{record.type == 'TIME'
|
249
|
250
|
? moment(text?.min).format(
|
250
|
|
- formatEnum[text?.format] || 'YYYY-MM-DD',
|
251
|
|
- )
|
|
251
|
+ formatEnum[text?.format] || 'YYYY-MM-DD',
|
|
252
|
+ )
|
252
|
253
|
: text?.min}
|
253
|
254
|
</span>
|
254
|
255
|
{text?.min && (
|
...
|
...
|
@@ -257,8 +258,8 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
257
|
258
|
<span>
|
258
|
259
|
{record.type == 'TIME'
|
259
|
260
|
? moment(text?.max).format(
|
260
|
|
- formatEnum[text?.format] || 'YYYY-MM-DD',
|
261
|
|
- )
|
|
261
|
+ formatEnum[text?.format] || 'YYYY-MM-DD',
|
|
262
|
+ )
|
262
|
263
|
: text?.max}
|
263
|
264
|
</span>
|
264
|
265
|
</div>
|
...
|
...
|
@@ -336,8 +337,10 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
336
|
337
|
key: 'action',
|
337
|
338
|
width: '10%',
|
338
|
339
|
render: (text, record) => {
|
339
|
|
- const isShowAdd = (record && checkShowAdd(record)) || true;
|
340
|
|
- const isShowTree = (record && checkShowTree(record)) || true;
|
|
340
|
+ const isShowAdd = (record && checkShowAdd(record));
|
|
341
|
+ const isShowTree = (record && checkShowTree(record));
|
|
342
|
+ console.log('isShowTree', isShowTree)
|
|
343
|
+ console.log('isShowAdd', isShowAdd)
|
341
|
344
|
return (
|
342
|
345
|
<Space size="small">
|
343
|
346
|
{isShowAdd && (
|
...
|
...
|
@@ -407,8 +410,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
407
|
410
|
const inputRef = useRef<any>(null);
|
408
|
411
|
const form = useContext(EditableContext)!;
|
409
|
412
|
const qxProps = record?.qxProps || {};
|
410
|
|
- // const [currentNode, setCurrentNode] = useState<any>('');
|
411
|
|
- // console.log('qxProps', qxProps)
|
|
413
|
+ const [currentNode, setCurrentNode] = useState<any>('');
|
412
|
414
|
// console.log('dataIndex', dataIndex)
|
413
|
415
|
|
414
|
416
|
useEffect(() => {
|
...
|
...
|
@@ -431,17 +433,33 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
431
|
433
|
// }
|
432
|
434
|
};
|
433
|
435
|
|
434
|
|
- // const toggleEdit1 = (e) => {
|
435
|
|
- // e.persist();
|
436
|
|
- // // setCurrentNode(e.currentTarget)
|
437
|
|
- // // console.log('e-onburl', e.currentTarget.key)
|
438
|
|
- // //
|
439
|
|
- // // if (e.currentTarget == e.target) {
|
440
|
|
- // // // setEditing(!editing);
|
441
|
|
- // // }
|
442
|
|
- // // form.setFieldsValue({ [dataIndex]: record[dataIndex] });
|
443
|
|
- // };
|
|
436
|
+ const toggleEdit1 = (e) => {
|
|
437
|
+ const values = form.getFieldsValue();
|
|
438
|
+ e.persist();
|
|
439
|
+ if (e.target.tagName == 'DIV') {
|
|
440
|
+ setCurrentNode(e.target)
|
|
441
|
+ // console.log('values', values)
|
|
442
|
+ setEditing(!editing);
|
|
443
|
+ if (currentNode) {
|
|
444
|
+ props.handleChange(values?.newQxProps, record, 'qxProps')
|
|
445
|
+ }
|
|
446
|
+ }
|
|
447
|
+
|
|
448
|
+ // setCurrentNode(e.currentTarget)
|
|
449
|
+ // console.log('e-onburl', e.currentTarget.key)
|
|
450
|
+ //
|
|
451
|
+ // if (e.currentTarget == e.target) {
|
|
452
|
+ // // setEditing(!editing);
|
|
453
|
+ // }
|
|
454
|
+ // form.setFieldsValue({ [dataIndex]: record[dataIndex] });
|
|
455
|
+ };
|
444
|
456
|
|
|
457
|
+ // const onQxpropsChangen = (value) => {
|
|
458
|
+ // console.log('value', value)
|
|
459
|
+ // form.setFieldsValue({
|
|
460
|
+ // ['qxProps']: { value: value }
|
|
461
|
+ // })
|
|
462
|
+ // }
|
445
|
463
|
// const toggleEdit2 = (e) => {
|
446
|
464
|
// e.persist();
|
447
|
465
|
// // console.log('e-onforce', e.currentTarget)
|
...
|
...
|
@@ -475,7 +493,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
475
|
493
|
// message: `不能为空!`,
|
476
|
494
|
// },] : []
|
477
|
495
|
|
478
|
|
- const qxPropsRange = () => {
|
|
496
|
+ const qxPropsRange = useCallback(() => {
|
479
|
497
|
switch (record.type) {
|
480
|
498
|
case 'STRING':
|
481
|
499
|
return (
|
...
|
...
|
@@ -483,21 +501,35 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
483
|
501
|
key={record.id}
|
484
|
502
|
ref={inputRef}
|
485
|
503
|
className="editable-center-cell"
|
486
|
|
- /* onBlur={(e) => toggleEdit1(e)} onFocus={(e) => toggleEdit2(e)} */ tabIndex={
|
|
504
|
+ onBlur={(e) => toggleEdit1(e)} tabIndex={
|
487
|
505
|
0
|
488
|
506
|
}
|
489
|
507
|
>
|
490
|
|
- <InputNumber
|
491
|
|
- defaultValue={qxProps.min}
|
492
|
|
- onBlur={() => save('qxProps-min')}
|
493
|
|
- placeholder="最小长度"
|
494
|
|
- />
|
|
508
|
+ <Form.Item
|
|
509
|
+ name={['newQxProps', 'min']}
|
|
510
|
+ style={{ margin: 0 }}
|
|
511
|
+ initialValue={qxProps.min}
|
|
512
|
+ >
|
|
513
|
+ <InputNumber
|
|
514
|
+ // defaultValue={qxProps.min}
|
|
515
|
+ // onChange={onQxpropsChangen}
|
|
516
|
+ // onBlur={() => save('qxProps-min')}
|
|
517
|
+ placeholder="最小长度"
|
|
518
|
+ />
|
|
519
|
+ </Form.Item>
|
495
|
520
|
-
|
496
|
|
- <InputNumber
|
497
|
|
- defaultValue={qxProps.max}
|
498
|
|
- onBlur={() => save('qxProps-max')}
|
499
|
|
- placeholder="最大长度"
|
500
|
|
- />
|
|
521
|
+ <Form.Item
|
|
522
|
+ name={['newQxProps', 'max']}
|
|
523
|
+ style={{ margin: 0 }}
|
|
524
|
+ initialValue={qxProps.max}
|
|
525
|
+ >
|
|
526
|
+ <InputNumber
|
|
527
|
+ // dataIndex={["qxProps", "max"]}
|
|
528
|
+ // defaultValue={qxProps.max}
|
|
529
|
+ // onBlur={() => save('qxProps-max')}
|
|
530
|
+ placeholder="最大长度"
|
|
531
|
+ />
|
|
532
|
+ </Form.Item>
|
501
|
533
|
</div>
|
502
|
534
|
);
|
503
|
535
|
case 'NUMBER':
|
...
|
...
|
@@ -506,30 +538,50 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
506
|
538
|
key={record.id}
|
507
|
539
|
ref={inputRef}
|
508
|
540
|
className="editable-around-cell"
|
509
|
|
- /* onBlur={(e) => toggleEdit1(e)} onFocus={(e) => toggleEdit2(e)} */ tabIndex={
|
|
541
|
+ onBlur={(e) => toggleEdit1(e)} tabIndex={
|
510
|
542
|
0
|
511
|
543
|
}
|
512
|
544
|
>
|
513
|
|
- <div>
|
514
|
|
- <InputNumber
|
515
|
|
- defaultValue={qxProps.min}
|
516
|
|
- onBlur={() => save('qxProps-min')}
|
517
|
|
- style={{ width: '110px' }}
|
518
|
|
- placeholder="最小值"
|
519
|
|
- />
|
|
545
|
+ <div style={{ display: 'flex' }}>
|
|
546
|
+ <Form.Item
|
|
547
|
+ initialValue={qxProps.min}
|
|
548
|
+ name={['newQxProps', 'min']}
|
|
549
|
+ style={{ margin: 0 }}
|
|
550
|
+ >
|
|
551
|
+ <InputNumber
|
|
552
|
+ // defaultValue={qxProps.min}
|
|
553
|
+ // onBlur={() => save('qxProps-min')}
|
|
554
|
+ style={{ width: '110px' }}
|
|
555
|
+ placeholder="最小值"
|
|
556
|
+ />
|
|
557
|
+ </Form.Item>
|
|
558
|
+
|
520
|
559
|
-
|
|
560
|
+ <Form.Item
|
|
561
|
+ initialValue={qxProps.max}
|
|
562
|
+ style={{ margin: 0 }}
|
|
563
|
+ name={['newQxProps', 'max']}
|
|
564
|
+ >
|
|
565
|
+ <InputNumber
|
|
566
|
+ // defaultValue={qxProps.max}
|
|
567
|
+ // onBlur={() => save('qxProps-max')}
|
|
568
|
+ style={{ width: '110px' }}
|
|
569
|
+ placeholder="最大值"
|
|
570
|
+ />
|
|
571
|
+ </Form.Item>
|
|
572
|
+
|
|
573
|
+ </div>
|
|
574
|
+ <Form.Item
|
|
575
|
+ initialValue={qxProps.precision}
|
|
576
|
+ style={{ margin: 0 }}
|
|
577
|
+ name={['newQxProps', 'precision']}
|
|
578
|
+ >
|
521
|
579
|
<InputNumber
|
522
|
|
- defaultValue={qxProps.max}
|
523
|
|
- onBlur={() => save('qxProps-max')}
|
524
|
|
- style={{ width: '110px' }}
|
525
|
|
- placeholder="最大值"
|
|
580
|
+ // defaultValue={qxProps.precision}
|
|
581
|
+ // onBlur={() => save('qxProps-precision')}
|
|
582
|
+ placeholder="小数位数"
|
526
|
583
|
/>
|
527
|
|
- </div>
|
528
|
|
- <InputNumber
|
529
|
|
- defaultValue={qxProps.precision}
|
530
|
|
- onBlur={() => save('qxProps-precision')}
|
531
|
|
- placeholder="小数位数"
|
532
|
|
- />
|
|
584
|
+ </Form.Item>
|
533
|
585
|
</div>
|
534
|
586
|
);
|
535
|
587
|
case 'TIME':
|
...
|
...
|
@@ -538,7 +590,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
538
|
590
|
key={record.id}
|
539
|
591
|
ref={inputRef}
|
540
|
592
|
className="editable-around-cell"
|
541
|
|
- /* onBlur={(e) => toggleEdit1(e)} onFocus={(e) => toggleEdit2(e)} */ tabIndex={
|
|
593
|
+ onBlur={(e) => toggleEdit1(e)} tabIndex={
|
542
|
594
|
0
|
543
|
595
|
}
|
544
|
596
|
>
|
...
|
...
|
@@ -552,8 +604,9 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
552
|
604
|
format={formatEnum[qxProps?.format]}
|
553
|
605
|
// onChange={dateChange}
|
554
|
606
|
style={{ width: '130px' }}
|
555
|
|
- onBlur={() => save('qxProps-min')}
|
|
607
|
+ // onBlur={() => save('qxProps-min')}
|
556
|
608
|
showTime
|
|
609
|
+ onSelect={(e) => props.handleChange(e, record, 'qxProps-min')}
|
557
|
610
|
placeholder="开始日期"
|
558
|
611
|
/>
|
559
|
612
|
{/* <DatePicker defaultValue={moment(qxProps.min)} onBlur={() => save('qxProps-min')} placeholder='开始日期' /> */}
|
...
|
...
|
@@ -577,7 +630,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
577
|
630
|
<Select
|
578
|
631
|
style={{ width: '90px' }}
|
579
|
632
|
placeholder="格式"
|
580
|
|
- dropdownMatchSelectWidth={false}
|
|
633
|
+ popupMatchSelectWidth={false}
|
581
|
634
|
defaultValue={qxProps.format}
|
582
|
635
|
onSelect={(e) =>
|
583
|
636
|
props.handleChange(e, record, 'qxProps-format')
|
...
|
...
|
@@ -607,47 +660,67 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
607
|
660
|
</div>
|
608
|
661
|
);
|
609
|
662
|
}
|
|
663
|
+ }, [currentNode]
|
|
664
|
+ )
|
|
665
|
+
|
|
666
|
+ const getValueOptions = (item: any): ValueOptionProps[] | undefined => {
|
|
667
|
+ const widget = typeTranslateWidget(item.type);
|
|
668
|
+ if (widget === 'userSelector') {
|
|
669
|
+ return [];
|
|
670
|
+ // return [{key: 'MYSELF', value: "当前用户"}]
|
|
671
|
+ }
|
|
672
|
+ if (widget === 'orgSelector') {
|
|
673
|
+ // return [{key: 'MY_ORG', value: "当前人所在部门"}]
|
|
674
|
+ return [];
|
|
675
|
+ }
|
|
676
|
+ if (widget === 'qxDatetime') {
|
|
677
|
+ return [{ key: 'NOW', value: '当前时间' }];
|
|
678
|
+ }
|
|
679
|
+ return undefined;
|
610
|
680
|
};
|
611
|
681
|
|
612
|
|
- // const getValueOptions = (item: any): ValueOptionProps[] | undefined => {
|
613
|
|
- // const widget = typeTranslateWidget(item.type);
|
614
|
|
- // if (widget === 'userSelector') {
|
615
|
|
- // return [];
|
616
|
|
- // // return [{key: 'MYSELF', value: "当前用户"}]
|
617
|
|
- // }
|
618
|
|
- // if (widget === 'orgSelector') {
|
619
|
|
- // // return [{key: 'MY_ORG', value: "当前人所在部门"}]
|
620
|
|
- // return [];
|
621
|
|
- // }
|
622
|
|
- // if (widget === 'qxDatetime') {
|
623
|
|
- // return [{ key: 'NOW', value: '当前时间' }];
|
624
|
|
- // }
|
625
|
|
- // return undefined;
|
626
|
|
- // };
|
|
682
|
+ const handleField = (val) => {
|
|
683
|
+ if (!val || _.isEmpty(val)) {
|
|
684
|
+ return;
|
|
685
|
+ }
|
|
686
|
+ if (val[0].extVal) {
|
|
687
|
+ handleChangeField(val, record)
|
|
688
|
+ }
|
|
689
|
+ if (val[0].value === 'NOW' || val[0].value.indexOf('action_date') > -1) {
|
|
690
|
+ } else {
|
|
691
|
+ handleChangeField(val, record)
|
|
692
|
+ }
|
|
693
|
+ }
|
627
|
694
|
|
628
|
695
|
const qxPropsDefault = () => {
|
|
696
|
+ const valuesObj = [{
|
|
697
|
+ type: typeTranslateItemtype(record.type),
|
|
698
|
+ value: record?.qxProps?.default || '',
|
|
699
|
+ }]
|
|
700
|
+ record.valuesObj = valuesObj
|
629
|
701
|
return (
|
630
|
702
|
<div>
|
631
|
|
- <Input
|
|
703
|
+ {/* <Input
|
632
|
704
|
defaultValue={record?.qxProps?.default}
|
633
|
705
|
ref={inputRef}
|
634
|
706
|
onBlur={() => save('qxProps-default')}
|
|
707
|
+ /> */}
|
|
708
|
+ <QxFieldSetter
|
|
709
|
+ value={record.valuesObj || []}
|
|
710
|
+ // value={[{
|
|
711
|
+ // type: typeTranslateItemtype(record.type) || '',
|
|
712
|
+ // value: record?.qxProps?.default
|
|
713
|
+ // }]}
|
|
714
|
+ params={{ appCode: 'appCode', useId: true }}
|
|
715
|
+ valueOptions={getValueOptions(record)}
|
|
716
|
+ field={record.type}
|
|
717
|
+ widget={typeTranslateWidget(record.type)}
|
|
718
|
+ fieldType={typeTranslateFieIdtype(record.type)}
|
|
719
|
+ fieldGroupType={typeTranslateGrouptype(record.type)}
|
|
720
|
+ isMixValue={typeTranslateFieIdtype(record.type) == 'STRING' ? true : false}
|
|
721
|
+ isMultiple={false}
|
|
722
|
+ onChange={debounce((val) => handleField(val), 700)}
|
635
|
723
|
/>
|
636
|
|
- {/* <QxFieldSetter
|
637
|
|
- value={[{
|
638
|
|
- type: typeTranslateItemtype(record.type),
|
639
|
|
- value: record?.qxProps?.default
|
640
|
|
- }]}
|
641
|
|
- params={{ appCode: 'appCode', useId: true }}
|
642
|
|
- valueOptions={getValueOptions(record)}
|
643
|
|
- field={record.type}
|
644
|
|
- widget={typeTranslateWidget(record.type)}
|
645
|
|
- fieldType={typeTranslateFieIdtype(record.type)}
|
646
|
|
- fieldGroupType={typeTranslateGrouptype(record.type)}
|
647
|
|
- isMixValue={typeTranslateFieIdtype(record.type) == 'STRING' ? true : false}
|
648
|
|
- isMultiple={false}
|
649
|
|
- // onChange={(val) => handleChangeField(val, record)} //需要onblur
|
650
|
|
- /> */}
|
651
|
724
|
</div>
|
652
|
725
|
);
|
653
|
726
|
};
|
...
|
...
|
@@ -668,7 +741,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => { |
668
|
741
|
style={{ margin: 0 }}
|
669
|
742
|
// @ts-ignore
|
670
|
743
|
name={dataIndex}
|
671
|
|
- // rules={rules}
|
|
744
|
+ // rules={rules}
|
672
|
745
|
>
|
673
|
746
|
{dataIndex == 'type' ? (
|
674
|
747
|
<Select
|
...
|
...
|
|