amis 1.8.0-beta.3 → 1.8.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/AssociatedSelection.js +9 -2
- package/lib/components/AssociatedSelection.js.map +2 -2
- package/lib/components/Checkbox.d.ts +24 -23
- package/lib/components/Checkbox.js +6 -2
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/DateRangePicker.d.ts +2 -0
- package/lib/components/DateRangePicker.js +61 -2
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/Radios.d.ts +21 -21
- package/lib/components/calendar/Calendar.js +2 -14
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/factory.js +4 -1
- package/lib/factory.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/renderers/CRUD.d.ts +8 -0
- package/lib/renderers/CRUD.js +11 -4
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Form/Checkbox.d.ts +5 -2
- package/lib/renderers/Form/Checkbox.js +2 -2
- package/lib/renderers/Form/Checkbox.js.map +2 -2
- package/lib/renderers/Form/Checkboxes.d.ts +5 -0
- package/lib/renderers/Form/Checkboxes.js +99 -6
- package/lib/renderers/Form/Checkboxes.js.map +2 -2
- package/lib/renderers/Form/Item.js +3 -1
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/index.d.ts +1 -0
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +1 -0
- package/lib/renderers/Table/index.js +3 -2
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/store/crud.d.ts +1 -0
- package/lib/store/crud.js +33 -7
- package/lib/store/crud.js.map +2 -2
- package/lib/store/formItem.js +1 -1
- package/lib/store/formItem.js.map +2 -2
- package/lib/themes/ang-ie11.css +120 -3
- package/lib/themes/ang.css +127 -2
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +120 -3
- package/lib/themes/antd.css +127 -2
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +120 -3
- package/lib/themes/cxd.css +127 -2
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +120 -3
- package/lib/themes/dark.css +127 -2
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +120 -3
- package/lib/themes/default.css +127 -2
- package/lib/themes/default.css.map +1 -1
- package/package.json +1 -1
- package/schema.json +76 -7
- package/scss/_properties.scss +10 -1
- package/scss/components/form/_checks.scss +122 -1
- package/scss/components/form/_form.scss +16 -0
- package/sdk/ang-ie11.css +143 -3
- package/sdk/ang.css +150 -2
- package/sdk/antd-ie11.css +143 -3
- package/sdk/antd.css +150 -2
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +143 -3
- package/sdk/cxd.css +150 -2
- package/sdk/dark-ie11.css +143 -3
- package/sdk/dark.css +150 -2
- package/sdk/exceljs.js +1 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +143 -3
- package/sdk/sdk.css +150 -2
- package/sdk/sdk.js +1247 -1247
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/components/AssociatedSelection.tsx +9 -3
- package/src/components/Checkbox.tsx +11 -5
- package/src/components/DateRangePicker.tsx +97 -2
- package/src/components/calendar/Calendar.tsx +2 -15
- package/src/factory.tsx +4 -1
- package/src/renderers/CRUD.tsx +22 -4
- package/src/renderers/Form/Checkbox.tsx +11 -2
- package/src/renderers/Form/Checkboxes.tsx +101 -5
- package/src/renderers/Form/Item.tsx +1 -0
- package/src/renderers/Form/index.tsx +1 -0
- package/src/renderers/Table/index.tsx +4 -2
- package/src/store/crud.ts +40 -5
- package/src/store/formItem.ts +1 -2
@@ -88,9 +88,15 @@ export class AssociatedSelection extends BaseSelection<
|
|
88
88
|
|
89
89
|
@autobind
|
90
90
|
handleLeftDeferLoad(option: Option) {
|
91
|
-
const {leftOptions, onLeftDeferLoad} = this.props;
|
92
|
-
|
93
|
-
|
91
|
+
const {leftOptions, onLeftDeferLoad, onDeferLoad} = this.props;
|
92
|
+
|
93
|
+
if (typeof onLeftDeferLoad === 'function') {
|
94
|
+
// TabsTransfer
|
95
|
+
return onLeftDeferLoad?.(option, leftOptions);
|
96
|
+
} else if (typeof onDeferLoad === 'function') {
|
97
|
+
// Select
|
98
|
+
return onDeferLoad?.(option);
|
99
|
+
}
|
94
100
|
}
|
95
101
|
|
96
102
|
handleRetry(option: Option) {
|
@@ -16,10 +16,10 @@ interface CheckboxProps {
|
|
16
16
|
labelClassName?: string;
|
17
17
|
className?: string;
|
18
18
|
onChange?: (value: any, shift?: boolean) => void;
|
19
|
-
value?:
|
19
|
+
value?: boolean | string | number;
|
20
20
|
inline?: boolean;
|
21
|
-
trueValue?:
|
22
|
-
falseValue?:
|
21
|
+
trueValue?: boolean | string | number;
|
22
|
+
falseValue?: boolean | string | number;
|
23
23
|
disabled?: boolean;
|
24
24
|
readOnly?: boolean;
|
25
25
|
checked?: boolean;
|
@@ -28,6 +28,7 @@ interface CheckboxProps {
|
|
28
28
|
classPrefix: string;
|
29
29
|
classnames: ClassNamesFn;
|
30
30
|
partial?: boolean;
|
31
|
+
optionType?: 'default' | 'button';
|
31
32
|
}
|
32
33
|
|
33
34
|
export class Checkbox extends React.Component<CheckboxProps, any> {
|
@@ -70,14 +71,19 @@ export class Checkbox extends React.Component<CheckboxProps, any> {
|
|
70
71
|
checked,
|
71
72
|
type,
|
72
73
|
name,
|
73
|
-
labelClassName
|
74
|
+
labelClassName,
|
75
|
+
optionType
|
74
76
|
} = this.props;
|
75
77
|
|
76
78
|
return (
|
77
79
|
<label
|
78
80
|
className={cx(`Checkbox Checkbox--${type}`, className, {
|
79
81
|
'Checkbox--full': !partial,
|
80
|
-
|
82
|
+
'Checkbox--partial': partial,
|
83
|
+
[`Checkbox--${size}`]: size,
|
84
|
+
'Checkbox--button': optionType === 'button',
|
85
|
+
'Checkbox--button--checked': optionType === 'button' && checked,
|
86
|
+
'Checkbox--button--disabled--unchecked': disabled && !checked
|
81
87
|
})}
|
82
88
|
>
|
83
89
|
<input
|
@@ -462,6 +462,8 @@ export class DateRangePicker extends React.Component<
|
|
462
462
|
this.open = this.open.bind(this);
|
463
463
|
this.close = this.close.bind(this);
|
464
464
|
this.handleSelectChange = this.handleSelectChange.bind(this);
|
465
|
+
this.handleTimeStartChange = this.handleTimeStartChange.bind(this);
|
466
|
+
this.handleTimeEndChange = this.handleTimeEndChange.bind(this);
|
465
467
|
this.handleFocus = this.handleFocus.bind(this);
|
466
468
|
this.handleBlur = this.handleBlur.bind(this);
|
467
469
|
this.checkStartIsValidDate = this.checkStartIsValidDate.bind(this);
|
@@ -661,6 +663,88 @@ export class DateRangePicker extends React.Component<
|
|
661
663
|
this.isFirstClick = !this.isFirstClick;
|
662
664
|
}
|
663
665
|
|
666
|
+
// 主要用于处理时间的情况
|
667
|
+
handleTimeStartChange(newValue: moment.Moment) {
|
668
|
+
const {embed, timeFormat, minDuration, maxDuration, minDate} = this.props;
|
669
|
+
const {startDate, endDate} = this.state;
|
670
|
+
|
671
|
+
if (
|
672
|
+
startDate &&
|
673
|
+
(!endDate || (endDate && newValue.isSame(startDate))) && // 没有结束时间,或者新的时间也是开始时间,这时都会将新值当成结束时间
|
674
|
+
newValue.isSameOrAfter(startDate) &&
|
675
|
+
(!minDuration || newValue.isAfter(startDate.clone().add(minDuration))) &&
|
676
|
+
(!maxDuration || newValue.isBefore(startDate.clone().add(maxDuration)))
|
677
|
+
) {
|
678
|
+
return this.setState(
|
679
|
+
{
|
680
|
+
endDate: this.filterDate(newValue, endDate, timeFormat, 'end')
|
681
|
+
},
|
682
|
+
() => {
|
683
|
+
embed && this.confirm();
|
684
|
+
}
|
685
|
+
);
|
686
|
+
}
|
687
|
+
|
688
|
+
if (minDate && newValue && newValue.isBefore(minDate, 'second')) {
|
689
|
+
newValue = minDate;
|
690
|
+
}
|
691
|
+
|
692
|
+
this.setState(
|
693
|
+
{
|
694
|
+
startDate: this.filterDate(
|
695
|
+
newValue,
|
696
|
+
startDate || minDate,
|
697
|
+
timeFormat,
|
698
|
+
'start'
|
699
|
+
)
|
700
|
+
},
|
701
|
+
() => {
|
702
|
+
embed && this.confirm();
|
703
|
+
}
|
704
|
+
);
|
705
|
+
}
|
706
|
+
|
707
|
+
handleTimeEndChange(newValue: moment.Moment) {
|
708
|
+
const {embed, timeFormat, minDuration, maxDuration, maxDate} = this.props;
|
709
|
+
const {startDate, endDate} = this.state;
|
710
|
+
|
711
|
+
if (
|
712
|
+
endDate &&
|
713
|
+
!startDate &&
|
714
|
+
newValue.isSameOrBefore(endDate) &&
|
715
|
+
(!minDuration ||
|
716
|
+
newValue.isBefore(endDate.clone().subtract(minDuration))) &&
|
717
|
+
(!maxDuration || newValue.isAfter(endDate.clone().subtract(maxDuration)))
|
718
|
+
) {
|
719
|
+
return this.setState(
|
720
|
+
{
|
721
|
+
startDate: this.filterDate(newValue, startDate, timeFormat, 'start')
|
722
|
+
},
|
723
|
+
() => {
|
724
|
+
embed && this.confirm();
|
725
|
+
}
|
726
|
+
);
|
727
|
+
}
|
728
|
+
|
729
|
+
if (maxDate && newValue && newValue.isAfter(maxDate, 'second')) {
|
730
|
+
newValue = maxDate;
|
731
|
+
}
|
732
|
+
|
733
|
+
this.setState(
|
734
|
+
{
|
735
|
+
endDate: this.filterDate(
|
736
|
+
newValue,
|
737
|
+
endDate || maxDate,
|
738
|
+
timeFormat,
|
739
|
+
'end'
|
740
|
+
)
|
741
|
+
},
|
742
|
+
() => {
|
743
|
+
embed && this.confirm();
|
744
|
+
}
|
745
|
+
);
|
746
|
+
}
|
747
|
+
|
664
748
|
handleMobileChange(data: any, callback?: () => void) {
|
665
749
|
this.setState(
|
666
750
|
{
|
@@ -871,6 +955,7 @@ export class DateRangePicker extends React.Component<
|
|
871
955
|
const __ = this.props.translate;
|
872
956
|
|
873
957
|
const {startDate, endDate} = this.state;
|
958
|
+
|
874
959
|
return (
|
875
960
|
<div className={`${ns}DateRangePicker-wrap`}>
|
876
961
|
{this.renderRanges(ranges)}
|
@@ -878,7 +963,13 @@ export class DateRangePicker extends React.Component<
|
|
878
963
|
<Calendar
|
879
964
|
className={`${ns}DateRangePicker-start`}
|
880
965
|
value={startDate}
|
881
|
-
|
966
|
+
// 区分的原因是 time-range 左侧就只能选起始时间,而其它都能在左侧同时同时选择起始和结束
|
967
|
+
// TODO: 后续得把 time-range 代码拆分出来
|
968
|
+
onChange={
|
969
|
+
viewMode === 'time'
|
970
|
+
? this.handleTimeStartChange
|
971
|
+
: this.handleSelectChange
|
972
|
+
}
|
882
973
|
requiredConfirm={false}
|
883
974
|
dateFormat={dateFormat}
|
884
975
|
inputFormat={inputFormat}
|
@@ -895,7 +986,11 @@ export class DateRangePicker extends React.Component<
|
|
895
986
|
<Calendar
|
896
987
|
className={`${ns}DateRangePicker-end`}
|
897
988
|
value={endDate}
|
898
|
-
onChange={
|
989
|
+
onChange={
|
990
|
+
viewMode === 'time'
|
991
|
+
? this.handleTimeEndChange
|
992
|
+
: this.handleSelectChange
|
993
|
+
}
|
899
994
|
requiredConfirm={false}
|
900
995
|
dateFormat={dateFormat}
|
901
996
|
inputFormat={inputFormat}
|
@@ -161,20 +161,6 @@ class BaseDatePicker extends React.Component<
|
|
161
161
|
updatedState = this.getStateFromProps(props);
|
162
162
|
}
|
163
163
|
|
164
|
-
// open 是外部控制了
|
165
|
-
// if (updatedState.open === undefined) {
|
166
|
-
// if (typeof props.open !== 'undefined') {
|
167
|
-
// updatedState.open = props.open;
|
168
|
-
// } else if (
|
169
|
-
// prevProps.closeOnSelect &&
|
170
|
-
// this.state.currentView !== viewModes.TIME
|
171
|
-
// ) {
|
172
|
-
// updatedState.open = false;
|
173
|
-
// } else {
|
174
|
-
// updatedState.open = this.state.open;
|
175
|
-
// }
|
176
|
-
// }
|
177
|
-
|
178
164
|
if (props.viewMode !== prevProps.viewMode) {
|
179
165
|
updatedState.currentView = props.viewMode;
|
180
166
|
}
|
@@ -237,7 +223,8 @@ class BaseDatePicker extends React.Component<
|
|
237
223
|
updatedState.viewDate = moment(props.viewDate);
|
238
224
|
}
|
239
225
|
|
240
|
-
|
226
|
+
// time-range 下会有问题,先不支持
|
227
|
+
if (Object.keys(updatedState).length && props.viewMode !== 'time') {
|
241
228
|
this.setState(updatedState);
|
242
229
|
}
|
243
230
|
|
package/src/factory.tsx
CHANGED
package/src/renderers/CRUD.tsx
CHANGED
@@ -105,6 +105,16 @@ export interface CRUDCommonSchema extends BaseSchema {
|
|
105
105
|
*/
|
106
106
|
perPage?: number;
|
107
107
|
|
108
|
+
/**
|
109
|
+
* 默认排序字段
|
110
|
+
*/
|
111
|
+
orderBy?: string;
|
112
|
+
|
113
|
+
/**
|
114
|
+
* 默认排序方向
|
115
|
+
*/
|
116
|
+
orderDir?: 'asc' | 'desc';
|
117
|
+
|
108
118
|
/**
|
109
119
|
* 可以默认给定初始参数如: {\"perPage\": 24}
|
110
120
|
*/
|
@@ -772,11 +782,17 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
772
782
|
}
|
773
783
|
|
774
784
|
handleFilterInit(values: object) {
|
775
|
-
const {defaultParams, data, store} = this.props;
|
785
|
+
const {defaultParams, data, store, orderBy, orderDir} = this.props;
|
786
|
+
const params = {...defaultParams};
|
787
|
+
|
788
|
+
if (orderBy) {
|
789
|
+
params['orderBy'] = orderBy;
|
790
|
+
params['orderDir'] = orderDir || 'asc';
|
791
|
+
}
|
776
792
|
|
777
793
|
this.handleFilterSubmit(
|
778
794
|
{
|
779
|
-
...
|
795
|
+
...params,
|
780
796
|
...values,
|
781
797
|
...store.query
|
782
798
|
},
|
@@ -1025,7 +1041,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1025
1041
|
env,
|
1026
1042
|
loadDataOnce,
|
1027
1043
|
loadDataOnceFetchOnFilter,
|
1028
|
-
source
|
1044
|
+
source,
|
1045
|
+
columns
|
1029
1046
|
} = this.props;
|
1030
1047
|
|
1031
1048
|
// reload 需要清空用户选择。
|
@@ -1066,7 +1083,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1066
1083
|
pageField,
|
1067
1084
|
perPageField,
|
1068
1085
|
loadDataMode,
|
1069
|
-
syncResponse2Query
|
1086
|
+
syncResponse2Query,
|
1087
|
+
columns: store.columns ?? columns
|
1070
1088
|
})
|
1071
1089
|
.then(value => {
|
1072
1090
|
interval &&
|
@@ -19,12 +19,12 @@ export interface CheckboxControlSchema extends FormBaseControl {
|
|
19
19
|
/**
|
20
20
|
* 勾选值
|
21
21
|
*/
|
22
|
-
trueValue?:
|
22
|
+
trueValue?: boolean | string | number;
|
23
23
|
|
24
24
|
/**
|
25
25
|
* 未勾选值
|
26
26
|
*/
|
27
|
-
falseValue?:
|
27
|
+
falseValue?: boolean | string | number;
|
28
28
|
|
29
29
|
/**
|
30
30
|
* 选项说明
|
@@ -35,6 +35,9 @@ export interface CheckboxControlSchema extends FormBaseControl {
|
|
35
35
|
* 角标
|
36
36
|
*/
|
37
37
|
badge?: BadgeSchema;
|
38
|
+
partial?: boolean;
|
39
|
+
optionType?: 'default' | 'button';
|
40
|
+
checked?: boolean;
|
38
41
|
}
|
39
42
|
|
40
43
|
export interface CheckboxProps
|
@@ -89,6 +92,9 @@ export default class CheckboxControl extends React.Component<
|
|
89
92
|
onChange,
|
90
93
|
disabled,
|
91
94
|
render,
|
95
|
+
partial,
|
96
|
+
optionType,
|
97
|
+
checked,
|
92
98
|
classPrefix: ns
|
93
99
|
} = this.props;
|
94
100
|
|
@@ -101,6 +107,9 @@ export default class CheckboxControl extends React.Component<
|
|
101
107
|
falseValue={falseValue}
|
102
108
|
disabled={disabled}
|
103
109
|
onChange={(value: any) => this.dispatchChangeEvent(value)}
|
110
|
+
partial={partial}
|
111
|
+
optionType={optionType}
|
112
|
+
checked={checked}
|
104
113
|
>
|
105
114
|
{option ? render('option', option) : null}
|
106
115
|
</Checkbox>
|
@@ -56,6 +56,7 @@ export interface CheckboxesProps
|
|
56
56
|
createBtnLabel: string;
|
57
57
|
editable?: boolean;
|
58
58
|
removable?: boolean;
|
59
|
+
optionType?: 'default' | 'button'
|
59
60
|
}
|
60
61
|
|
61
62
|
export default class CheckboxesControl extends React.Component<
|
@@ -68,7 +69,8 @@ export default class CheckboxesControl extends React.Component<
|
|
68
69
|
placeholder: 'placeholder.noOption',
|
69
70
|
creatable: false,
|
70
71
|
inline: true,
|
71
|
-
createBtnLabel: 'Select.createLabel'
|
72
|
+
createBtnLabel: 'Select.createLabel',
|
73
|
+
optionType: 'default'
|
72
74
|
};
|
73
75
|
|
74
76
|
reload() {
|
@@ -98,6 +100,97 @@ export default class CheckboxesControl extends React.Component<
|
|
98
100
|
onDelete && onDelete(item);
|
99
101
|
}
|
100
102
|
|
103
|
+
componentDidMount() {
|
104
|
+
this.updateBorderStyle();
|
105
|
+
window.addEventListener('resize', this.updateBorderStyle);
|
106
|
+
}
|
107
|
+
|
108
|
+
componentWillMount() {
|
109
|
+
window.removeEventListener('resize', this.updateBorderStyle);
|
110
|
+
}
|
111
|
+
|
112
|
+
@autobind
|
113
|
+
updateBorderStyle() {
|
114
|
+
if (this.props.optionType !== 'button') {
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
const wrapDom = this.refs.checkboxRef as HTMLElement;
|
118
|
+
const wrapWidth = wrapDom.clientWidth;
|
119
|
+
const childs = Array.from(wrapDom.children) as HTMLElement[];
|
120
|
+
|
121
|
+
childs.forEach(child => {
|
122
|
+
child.style.borderRadius = '0';
|
123
|
+
child.style.borderLeftWidth = '1px';
|
124
|
+
child.style.borderTopWidth = '1px';
|
125
|
+
});
|
126
|
+
const childTotalWidth = childs.reduce((pre, next) =>
|
127
|
+
pre + next.clientWidth, 0);
|
128
|
+
if (childTotalWidth <= wrapWidth) {
|
129
|
+
if (childs.length === 1) {
|
130
|
+
childs[0].style.borderRadius = "4px";
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
childs[0].style.borderRadius = "4px 0 0 4px";
|
134
|
+
childs[childs.length - 1].style.borderRadius = "0 4px 4px 0";
|
135
|
+
childs.forEach((child, idx) => {
|
136
|
+
idx !== 0 && (child.style.borderLeftWidth = '0');
|
137
|
+
});
|
138
|
+
}
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
let curRowWidth = 0;
|
142
|
+
let curRow = 0;
|
143
|
+
const rowNum = Math.floor(childTotalWidth / wrapWidth);
|
144
|
+
const rowColArr: any[] = [];
|
145
|
+
for (let i = 0; i <= rowNum; i++) {
|
146
|
+
const arr: HTMLElement[] = [];
|
147
|
+
rowColArr[i] = arr;
|
148
|
+
}
|
149
|
+
childs.forEach((child: HTMLElement, idx: number) => {
|
150
|
+
curRowWidth += child.clientWidth;
|
151
|
+
if (curRowWidth > wrapWidth) {
|
152
|
+
curRowWidth = child.clientWidth;
|
153
|
+
curRow++;
|
154
|
+
}
|
155
|
+
if (curRow > rowNum) {
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
rowColArr[curRow].push(child);
|
159
|
+
});
|
160
|
+
|
161
|
+
rowColArr.forEach((row: HTMLElement[], rowIdx: number) => {
|
162
|
+
if (rowIdx === 0) {
|
163
|
+
row.forEach((r: HTMLElement, colIdx: number) => {
|
164
|
+
r.style.borderRadius = '0';
|
165
|
+
colIdx !== 0 && (r.style.borderLeftWidth = '0');
|
166
|
+
row.length > rowColArr[rowIdx + 1].length
|
167
|
+
&& (row[row.length - 1].style.borderBottomRightRadius = "4px");
|
168
|
+
});
|
169
|
+
row[0].style.borderTopLeftRadius = "4px";
|
170
|
+
row[row.length - 1].style.borderTopRightRadius = "4px";
|
171
|
+
}
|
172
|
+
else if (rowIdx === rowNum) {
|
173
|
+
row.forEach((r: HTMLElement, colIdx: number) => {
|
174
|
+
r.style.borderRadius = '0';
|
175
|
+
colIdx !== 0 && (r.style.borderLeftWidth = '0');
|
176
|
+
r.style.borderTopWidth = '0';
|
177
|
+
row[0].style.borderBottomLeftRadius = "4px";
|
178
|
+
row[row.length - 1].style.borderBottomRightRadius = "4px";
|
179
|
+
});
|
180
|
+
}
|
181
|
+
else {
|
182
|
+
row.forEach((r: HTMLElement, colIdx: number) => {
|
183
|
+
r.style.borderRadius = '0';
|
184
|
+
colIdx !== 0 && (r.style.borderLeftWidth = '0');
|
185
|
+
r.style.borderTopWidth = '0';
|
186
|
+
row.length > rowColArr[rowIdx + 1].length
|
187
|
+
&& (row[row.length - 1].style.borderBottomRightRadius = "4px");
|
188
|
+
});
|
189
|
+
}
|
190
|
+
});
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
101
194
|
renderGroup(option: Option, index: number) {
|
102
195
|
const {classnames: cx, labelField} = this.props;
|
103
196
|
|
@@ -136,7 +229,8 @@ export default class CheckboxesControl extends React.Component<
|
|
136
229
|
labelField,
|
137
230
|
removable,
|
138
231
|
editable,
|
139
|
-
translate: __
|
232
|
+
translate: __,
|
233
|
+
optionType
|
140
234
|
} = this.props;
|
141
235
|
|
142
236
|
return (
|
@@ -149,6 +243,7 @@ export default class CheckboxesControl extends React.Component<
|
|
149
243
|
inline={inline}
|
150
244
|
labelClassName={labelClassName}
|
151
245
|
description={option.description}
|
246
|
+
optionType={optionType}
|
152
247
|
>
|
153
248
|
{String(option[labelField || 'label'])}
|
154
249
|
{removable && hasAbility(option, 'removable') ? (
|
@@ -191,7 +286,8 @@ export default class CheckboxesControl extends React.Component<
|
|
191
286
|
creatable,
|
192
287
|
addApi,
|
193
288
|
createBtnLabel,
|
194
|
-
translate: __
|
289
|
+
translate: __,
|
290
|
+
optionType
|
195
291
|
} = this.props;
|
196
292
|
|
197
293
|
let body: Array<React.ReactNode> = [];
|
@@ -200,7 +296,7 @@ export default class CheckboxesControl extends React.Component<
|
|
200
296
|
body = options.map((option, key) => this.renderItem(option, key));
|
201
297
|
}
|
202
298
|
|
203
|
-
if (checkAll && body.length) {
|
299
|
+
if (checkAll && body.length && optionType === 'default') {
|
204
300
|
body.unshift(
|
205
301
|
<Checkbox
|
206
302
|
key="checkall"
|
@@ -225,7 +321,7 @@ export default class CheckboxesControl extends React.Component<
|
|
225
321
|
body = columnsSplit(body, cx, columnsCount);
|
226
322
|
|
227
323
|
return (
|
228
|
-
<div className={cx(`CheckboxesControl`, className)}>
|
324
|
+
<div className={cx(`CheckboxesControl`, className)} ref="checkboxRef">
|
229
325
|
{body && body.length ? (
|
230
326
|
body
|
231
327
|
) : (
|
@@ -552,6 +552,7 @@ export class FormItemWrap extends React.Component<FormItemProps> {
|
|
552
552
|
`Form-item Form-item--horizontal`,
|
553
553
|
className,
|
554
554
|
{
|
555
|
+
'Form-item--horizontal-justify': horizontal.justify,
|
555
556
|
[`is-error`]: model && !model.valid,
|
556
557
|
[`is-required`]: required
|
557
558
|
},
|
@@ -472,6 +472,7 @@ export default class Table extends React.Component<TableProps, object> {
|
|
472
472
|
} = {};
|
473
473
|
renderedToolbars: Array<string> = [];
|
474
474
|
subForms: any = {};
|
475
|
+
timer: ReturnType<typeof setTimeout>;
|
475
476
|
|
476
477
|
constructor(props: TableProps) {
|
477
478
|
super(props);
|
@@ -659,7 +660,7 @@ export default class Table extends React.Component<TableProps, object> {
|
|
659
660
|
const footToolbarHeight = footToolbar ? offset(footToolbar).height : 0;
|
660
661
|
// 有时候会拿不到 footToolbar,等一下在执行
|
661
662
|
if (!footToolbarHeight && footerToolbar && footerToolbar.length) {
|
662
|
-
setTimeout(() => {
|
663
|
+
this.timer = setTimeout(() => {
|
663
664
|
this.updateAutoFillHeight();
|
664
665
|
}, 100);
|
665
666
|
return;
|
@@ -777,6 +778,7 @@ export default class Table extends React.Component<TableProps, object> {
|
|
777
778
|
this.unSensor && this.unSensor();
|
778
779
|
|
779
780
|
formItem && isAlive(formItem) && formItem.setSubStore(null);
|
781
|
+
clearTimeout(this.timer);
|
780
782
|
}
|
781
783
|
|
782
784
|
subFormRef(form: any, x: number, y: number) {
|
@@ -1662,7 +1664,7 @@ export default class Table extends React.Component<TableProps, object> {
|
|
1662
1664
|
{store.rows.length && multiple ? (
|
1663
1665
|
<Checkbox
|
1664
1666
|
classPrefix={ns}
|
1665
|
-
partial={!store.allChecked}
|
1667
|
+
partial={store.someChecked && !store.allChecked}
|
1666
1668
|
checked={store.someChecked}
|
1667
1669
|
disabled={store.disabledHeadCheckbox}
|
1668
1670
|
onChange={this.handleCheckAll}
|
package/src/store/crud.ts
CHANGED
@@ -16,12 +16,14 @@ import {
|
|
16
16
|
isObjectShallowModified,
|
17
17
|
sortArray,
|
18
18
|
isEmpty,
|
19
|
-
qsstringify
|
19
|
+
qsstringify,
|
20
|
+
getVariable
|
20
21
|
} from '../utils/helper';
|
21
22
|
import {Api, Payload, fetchOptions, Action, ApiObject} from '../types';
|
22
23
|
import pick from 'lodash/pick';
|
23
24
|
import {resolveVariableAndFilter} from '../utils/tpl-builtin';
|
24
25
|
import {normalizeApiResponseData} from '../utils/api';
|
26
|
+
import {matchSorter} from 'match-sorter';
|
25
27
|
|
26
28
|
class ServerError extends Error {
|
27
29
|
type = 'ServerError';
|
@@ -139,6 +141,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
139
141
|
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
|
140
142
|
loadDataMode?: boolean;
|
141
143
|
syncResponse2Query?: boolean;
|
144
|
+
columns?: Array<any>;
|
142
145
|
}
|
143
146
|
) => Promise<any> = flow(function* getInitData(
|
144
147
|
api: Api,
|
@@ -150,6 +153,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
150
153
|
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
|
151
154
|
loadDataMode?: boolean;
|
152
155
|
syncResponse2Query?: boolean;
|
156
|
+
columns?: Array<any>;
|
153
157
|
} = {}
|
154
158
|
) {
|
155
159
|
try {
|
@@ -165,6 +169,21 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
165
169
|
)
|
166
170
|
: self.items.concat();
|
167
171
|
|
172
|
+
if (Array.isArray(options.columns)) {
|
173
|
+
options.columns.forEach((column: any) => {
|
174
|
+
let value: any;
|
175
|
+
if (
|
176
|
+
column.searchable &&
|
177
|
+
column.name &&
|
178
|
+
(value = getVariable(self.query, column.name))
|
179
|
+
) {
|
180
|
+
items = matchSorter(items, value, {
|
181
|
+
keys: [column.name]
|
182
|
+
});
|
183
|
+
}
|
184
|
+
});
|
185
|
+
}
|
186
|
+
|
168
187
|
if (self.query.orderBy) {
|
169
188
|
const dir = /desc/i.test(self.query.orderDir) ? -1 : 1;
|
170
189
|
items = sortArray(items, self.query.orderBy, dir);
|
@@ -263,7 +282,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
263
282
|
}
|
264
283
|
|
265
284
|
// 点击加载更多数据
|
266
|
-
let rowsData = [];
|
285
|
+
let rowsData: Array<any> = [];
|
267
286
|
if (options.loadDataMode && Array.isArray(self.data.items)) {
|
268
287
|
rowsData = self.data.items.concat(items);
|
269
288
|
} else {
|
@@ -282,16 +301,32 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
282
301
|
if (options.loadDataOnce) {
|
283
302
|
// 记录原始集合,后续可能基于原始数据做排序查找。
|
284
303
|
data.itemsRaw = oItems || oRows;
|
304
|
+
let filteredItems = rowsData.concat();
|
305
|
+
|
306
|
+
if (Array.isArray(options.columns)) {
|
307
|
+
options.columns.forEach((column: any) => {
|
308
|
+
let value: any;
|
309
|
+
if (
|
310
|
+
column.searchable &&
|
311
|
+
column.name &&
|
312
|
+
(value = getVariable(self.query, column.name))
|
313
|
+
) {
|
314
|
+
filteredItems = matchSorter(filteredItems, value, {
|
315
|
+
keys: [column.name]
|
316
|
+
});
|
317
|
+
}
|
318
|
+
});
|
319
|
+
}
|
285
320
|
|
286
321
|
if (self.query.orderBy) {
|
287
322
|
const dir = /desc/i.test(self.query.orderDir) ? -1 : 1;
|
288
|
-
|
323
|
+
filteredItems = sortArray(filteredItems, self.query.orderBy, dir);
|
289
324
|
}
|
290
|
-
data.items =
|
325
|
+
data.items = filteredItems.slice(
|
291
326
|
(self.page - 1) * self.perPage,
|
292
327
|
self.page * self.perPage
|
293
328
|
);
|
294
|
-
data.count = data.total =
|
329
|
+
data.count = data.total = filteredItems.length;
|
295
330
|
}
|
296
331
|
|
297
332
|
if (Array.isArray(columns)) {
|
package/src/store/formItem.ts
CHANGED
@@ -723,8 +723,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
|
|
723
723
|
// 插入新的子节点,用于之后BaseSelection.resolveSelected查找
|
724
724
|
if (Array.isArray(topOption.children)) {
|
725
725
|
const children = topOption.children.concat();
|
726
|
-
|
727
|
-
flattenTree(topOption.leftOptions).forEach(item => {
|
726
|
+
flattenTree(newLeftOptions).forEach(item => {
|
728
727
|
if (!findTree(topOption.children, node => node.ref === item.value)) {
|
729
728
|
children.push({ref: item.value, defer: true});
|
730
729
|
}
|