vap1 0.2.1 → 0.2.3
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/components/Box/SelectBar.d.ts +2 -2
- package/components/Lists/SList.d.ts +4 -2
- package/components/Lists/SList.js +16 -13
- package/components/Tables/STable.js +5 -1
- package/components/UForm/FormWrapper.js +16 -16
- package/components/UForm/index.d.ts +1 -1
- package/components/_adapt/Menu.js +3 -3
- package/components/_common/DateRange.d.ts +10 -2
- package/components/_common/DateRange.js +41 -61
- package/components/_setup/SearchField/SearchFieldDate.js +2 -2
- package/components/_setup/SearchField/SearchFieldSelect.js +0 -20
- package/components/_setup/UForm/UFormDate.js +2 -2
- package/components/_setup/UForm/UFormInput.js +8 -4
- package/components/_setup/UForm/UFormSelect.js +14 -11
- package/deps/echarts.js +7 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/utils/PageUtil.js +3 -1
- package/utils/StringUtil.d.ts +1 -0
- package/utils/StringUtil.js +7 -1
|
@@ -4,7 +4,7 @@ import type { Key, BaseItem, PlainObject } from '../../basetype';
|
|
|
4
4
|
import type { STreeProps } from '../Trees/STree';
|
|
5
5
|
import type { DTreeProps } from '../Trees/DTree';
|
|
6
6
|
import type { FTreeProps } from '../Trees/FTree';
|
|
7
|
-
import type {
|
|
7
|
+
import type { SListProps } from '../Lists/SList';
|
|
8
8
|
type SelectBarAction = BaseItem & {
|
|
9
9
|
/**
|
|
10
10
|
* action 图标
|
|
@@ -74,7 +74,7 @@ type ExtendSelectProps = {
|
|
|
74
74
|
config: Omit<FTreeProps, 'searchValue' | 'onSelect'>;
|
|
75
75
|
} | {
|
|
76
76
|
type: 'slist';
|
|
77
|
-
config: Omit<
|
|
77
|
+
config: Omit<SListProps, 'searchValue' | 'onSelect'>;
|
|
78
78
|
} | {
|
|
79
79
|
type: 'custom';
|
|
80
80
|
config?: any;
|
|
@@ -3,7 +3,9 @@ import type { PlainObject, Key } from '../../basetype';
|
|
|
3
3
|
import type { ReactNode } from 'react';
|
|
4
4
|
import type { IconProps } from '../_adapt/Icon';
|
|
5
5
|
type ItemRenderFunction = (record: PlainObject, searchValue?: string) => ReactNode;
|
|
6
|
-
export type
|
|
6
|
+
export type SListProps = {
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
className?: string;
|
|
7
9
|
/**
|
|
8
10
|
* key 字段,默认为ID
|
|
9
11
|
*/
|
|
@@ -54,5 +56,5 @@ export type SListPorps = {
|
|
|
54
56
|
*/
|
|
55
57
|
mustSelect?: true | ((list: PlainObject[]) => PlainObject);
|
|
56
58
|
};
|
|
57
|
-
export declare const SList: React.FC<
|
|
59
|
+
export declare const SList: React.FC<SListProps>;
|
|
58
60
|
export {};
|
|
@@ -134,23 +134,26 @@ exports.SList = (0, react_1.memo)((props) => {
|
|
|
134
134
|
setSelected(item[keyField]);
|
|
135
135
|
onSelect(item[keyField], item);
|
|
136
136
|
}, [list]);
|
|
137
|
-
const listProps = {
|
|
138
|
-
|
|
139
|
-
size: "small",
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
listProps.
|
|
137
|
+
const listProps = (0, react_1.useMemo)(() => {
|
|
138
|
+
const clazz = ['c-selectbar-list'];
|
|
139
|
+
let listProps = { size: "small", style: props.style };
|
|
140
|
+
if (lodash_1.default.isFunction(props.onSelect))
|
|
141
|
+
clazz.push('c-selectbar-list-canselect');
|
|
142
|
+
if (props.className)
|
|
143
|
+
clazz.push(props.className);
|
|
144
|
+
listProps.className = clazz.join(' ');
|
|
145
|
+
return listProps;
|
|
146
|
+
}, [props.className]);
|
|
147
|
+
const renderItem = item => {
|
|
148
|
+
if (!lodash_1.default.isFunction(props.onSelect))
|
|
149
|
+
return react_1.default.createElement(antd_1.List.Item, null, render(item, searchValue));
|
|
150
|
+
return react_1.default.createElement(antd_1.List.Item, { className: item[keyField] == selected ? 'c-selectbar-list-selected' : '', onClick: evt => {
|
|
145
151
|
utils_1.PageUtil.stopEvent(evt);
|
|
146
152
|
setSelected(item[keyField]);
|
|
147
153
|
onSelect(item[keyField], item);
|
|
148
154
|
} }, render(item, searchValue));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
listProps.renderItem = (item) => react_1.default.createElement(antd_1.List.Item, null, render(item, searchValue));
|
|
152
|
-
}
|
|
153
|
-
return react_1.default.createElement(antd_1.List, Object.assign({}, listProps));
|
|
155
|
+
};
|
|
156
|
+
return react_1.default.createElement(antd_1.List, Object.assign({}, listProps, { dataSource: list, renderItem: renderItem }));
|
|
154
157
|
}, (prev, next) => {
|
|
155
158
|
if (prev.searchValue != next.searchValue)
|
|
156
159
|
return false;
|
|
@@ -46,7 +46,11 @@ const STable = (props) => {
|
|
|
46
46
|
arrOption.pageSize = 0;
|
|
47
47
|
}
|
|
48
48
|
const model = (0, useArray_1.useArray)(arrOption);
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
49
|
+
(0, react_1.useEffect)(() => {
|
|
50
|
+
if (lodash_1.default.isArray(props.list)) {
|
|
51
|
+
model.setList(props.list);
|
|
52
|
+
}
|
|
53
|
+
}, [props.list]);
|
|
50
54
|
return react_1.default.createElement(VTable_1.VTable, Object.assign({}, props, { pagination: arrOption.pageSize == 0 ? false : { hideOnSinglePage: true }, model: model }));
|
|
51
55
|
};
|
|
52
56
|
exports.STable = STable;
|
|
@@ -79,10 +79,10 @@ const getFormLayout = (props, root) => {
|
|
|
79
79
|
width = totalWidth;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
let isInfo = false, isEdit = false,
|
|
82
|
+
let isInfo = false, isEdit = false, isAdd = false;
|
|
83
83
|
switch (props.mode) {
|
|
84
84
|
case 'ADD':
|
|
85
|
-
|
|
85
|
+
isAdd = true;
|
|
86
86
|
break;
|
|
87
87
|
case 'EDIT':
|
|
88
88
|
isEdit = true;
|
|
@@ -99,14 +99,14 @@ const getFormLayout = (props, root) => {
|
|
|
99
99
|
isEdit = true;
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
isAdd = true;
|
|
103
103
|
// if (props.data != null || _.keys(props.data).length == 0) {
|
|
104
104
|
// isInfo = true;
|
|
105
105
|
// break;
|
|
106
106
|
// }
|
|
107
107
|
// isInfo = true;
|
|
108
108
|
}
|
|
109
|
-
return [isGroup, cols, width, colMax, isInfo, isEdit,
|
|
109
|
+
return [isGroup, cols, width, colMax, isInfo, isEdit, isAdd];
|
|
110
110
|
};
|
|
111
111
|
const getMaxTitleWidth = (field) => {
|
|
112
112
|
if (field.type && (0, _register_1.getUFormInput)(field.type).breakTitle)
|
|
@@ -128,7 +128,7 @@ const getMaxTitleWidth = (field) => {
|
|
|
128
128
|
return Math.ceil(sum);
|
|
129
129
|
};
|
|
130
130
|
// 遍历字段,计算表单属性
|
|
131
|
-
const _LOOP = (fs, maxLabel, isInfo, isEdit,
|
|
131
|
+
const _LOOP = (fs, maxLabel, isInfo, isEdit, isAdd, hiddFields, disableFields) => {
|
|
132
132
|
fs.map(field => {
|
|
133
133
|
// @ts-ignore // 兼容 && 写法
|
|
134
134
|
if (field == null || field === false)
|
|
@@ -144,22 +144,22 @@ const _LOOP = (fs, maxLabel, isInfo, isEdit, isCreate, hiddFields, disableFields
|
|
|
144
144
|
else if (field.show) {
|
|
145
145
|
switch (field.show) {
|
|
146
146
|
case 'A':
|
|
147
|
-
show =
|
|
148
|
-
break;
|
|
149
|
-
case 'AE':
|
|
150
|
-
show = !isInfo;
|
|
147
|
+
show = isAdd;
|
|
151
148
|
break;
|
|
152
149
|
case 'I':
|
|
153
150
|
show = isInfo;
|
|
154
151
|
break;
|
|
155
|
-
case '
|
|
156
|
-
show =
|
|
152
|
+
case 'E':
|
|
153
|
+
show = isEdit;
|
|
154
|
+
break;
|
|
155
|
+
case 'AE':
|
|
156
|
+
show = isAdd || isEdit;
|
|
157
157
|
break;
|
|
158
158
|
case 'IE':
|
|
159
159
|
show = isInfo || isEdit;
|
|
160
160
|
break;
|
|
161
|
-
case '
|
|
162
|
-
show =
|
|
161
|
+
case 'IA':
|
|
162
|
+
show = isAdd || isEdit;
|
|
163
163
|
break;
|
|
164
164
|
case 'IAE':
|
|
165
165
|
show = true;
|
|
@@ -222,14 +222,14 @@ const FormWrapper = (props) => {
|
|
|
222
222
|
const { fields } = props;
|
|
223
223
|
if (fields == null || fields.length == 0)
|
|
224
224
|
throw new Error('Must Have Fields');
|
|
225
|
-
const [isGroup, cols, width, colMax, isInfo, isEdit,
|
|
225
|
+
const [isGroup, cols, width, colMax, isInfo, isEdit, isAdd] = getFormLayout(props, formContainer.current);
|
|
226
226
|
let colSpan = 24 / cols;
|
|
227
227
|
// const MAX_LABEL_SPAN = COLMAX[cols];
|
|
228
228
|
if (isGroup) {
|
|
229
|
-
fields.map(group => _LOOP(group.fields, maxLabelRef, isInfo, isEdit,
|
|
229
|
+
fields.map(group => _LOOP(group.fields, maxLabelRef, isInfo, isEdit, isAdd, HiddenFieldRef.current, DisableFieldRef.current));
|
|
230
230
|
}
|
|
231
231
|
else {
|
|
232
|
-
_LOOP(fields, maxLabelRef, isInfo, isEdit,
|
|
232
|
+
_LOOP(fields, maxLabelRef, isInfo, isEdit, isAdd, HiddenFieldRef.current, DisableFieldRef.current);
|
|
233
233
|
}
|
|
234
234
|
let fieldWidth = width / cols;
|
|
235
235
|
var percent = (maxLabelRef.current * FONT_SIZE + 20) / fieldWidth;
|
|
@@ -85,7 +85,7 @@ export type Link = {
|
|
|
85
85
|
* 1. 传 **data** = Update ,
|
|
86
86
|
* 2. 不传= Add
|
|
87
87
|
*/
|
|
88
|
-
export type APPEAR_MODE = 'I' | 'A' | 'E' | 'IE' | '
|
|
88
|
+
export type APPEAR_MODE = 'I' | 'A' | 'E' | 'IE' | 'IA' | 'AE' | 'IAE' | false | true;
|
|
89
89
|
/**
|
|
90
90
|
* 表单的字段定义
|
|
91
91
|
*/
|
|
@@ -33,17 +33,17 @@ const renderGroup = (props) => {
|
|
|
33
33
|
return renderGroup(item);
|
|
34
34
|
}
|
|
35
35
|
const itemProps = getMenuProps(item);
|
|
36
|
-
return react_1.default.createElement(antd_1.Menu.Item, Object.assign({ key: item.key }, itemProps), itemProps.title);
|
|
36
|
+
return react_1.default.createElement(antd_1.Menu.Item, Object.assign({ key: item.key }, lodash_1.default.omit(itemProps, ['title'])), itemProps.title);
|
|
37
37
|
}));
|
|
38
38
|
};
|
|
39
39
|
const _Menu = props => {
|
|
40
40
|
if (lodash_1.default.isArray(props.items) && props.items.length) {
|
|
41
|
-
return react_1.default.createElement(antd_1.Menu, Object.assign({}, lodash_1.default.omit(props, 'children')), props.items.map(item => {
|
|
41
|
+
return react_1.default.createElement(antd_1.Menu, Object.assign({}, lodash_1.default.omit(props, ['children', 'items'])), props.items.map(item => {
|
|
42
42
|
if (lodash_1.default.isArray(item.children)) {
|
|
43
43
|
return renderGroup(item);
|
|
44
44
|
}
|
|
45
45
|
const itemProps = getMenuProps(item);
|
|
46
|
-
return react_1.default.createElement(antd_1.Menu.Item, Object.assign({ key: item.key }, itemProps), itemProps.title);
|
|
46
|
+
return react_1.default.createElement(antd_1.Menu.Item, Object.assign({ key: item.key }, lodash_1.default.omit(itemProps, ['title'])), itemProps.title);
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
49
|
return react_1.default.createElement(antd_1.Menu, Object.assign({}, props));
|
|
@@ -20,11 +20,11 @@ export type DateRangeProps = {
|
|
|
20
20
|
/**
|
|
21
21
|
* 默认开始时间
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
start?: string | Dayjs;
|
|
24
24
|
/**
|
|
25
25
|
* 默认结束时间
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
end?: string | Dayjs;
|
|
28
28
|
/**
|
|
29
29
|
* 响应事件,自取参数
|
|
30
30
|
* 第一个参数为 string 类型
|
|
@@ -45,6 +45,14 @@ export type DateRangeProps = {
|
|
|
45
45
|
* 宽度
|
|
46
46
|
*/
|
|
47
47
|
width?: number;
|
|
48
|
+
/**
|
|
49
|
+
* 开始时间提示
|
|
50
|
+
*/
|
|
51
|
+
startPlaceholder?: string;
|
|
52
|
+
/**
|
|
53
|
+
* 结束时间提示
|
|
54
|
+
*/
|
|
55
|
+
endPlaceholder?: string;
|
|
48
56
|
};
|
|
49
57
|
/**
|
|
50
58
|
* 日期区间选择
|
|
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.DateRange = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
32
31
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
33
32
|
const antd_1 = require("antd");
|
|
34
33
|
const hooks_1 = require("../../hooks");
|
|
@@ -38,71 +37,52 @@ const Const_1 = require("../_setup/Const");
|
|
|
38
37
|
* 日期区间选择
|
|
39
38
|
*/
|
|
40
39
|
const DateRange = (props) => {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return startValue.valueOf() > props.minDate.valueOf();
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
40
|
+
const [start, setStart] = (0, react_1.useState)(props.start ? (0, dayjs_1.default)(props.start) : undefined);
|
|
41
|
+
const [end, setEnd] = (0, react_1.useState)(props.end ? (0, dayjs_1.default)(props.end) : undefined);
|
|
42
|
+
const isFirstMounted = (0, hooks_1.useFirstMountState)();
|
|
43
|
+
// 时间格式,提示
|
|
44
|
+
const [FORMAT, startPlaceholder, endPlaceholder] = (0, react_1.useMemo)(() => {
|
|
45
|
+
const FORMAT = props.showTime === false ? utils_1.GLOBAL.CONFIG.DATE.DATE_FORMAT : utils_1.GLOBAL.CONFIG.DATE.DATE_TIME_FORMAT;
|
|
46
|
+
const startPlaceholder = props.startPlaceholder ? props.startPlaceholder : (props.showTime ? utils_1.i18n.getText(Const_1.V.DATETIME_START) : utils_1.i18n.getText(Const_1.V.DATE_START));
|
|
47
|
+
const endPlaceholder = props.endPlaceholder ? props.endPlaceholder : (props.showTime ? utils_1.i18n.getText(Const_1.V.DATETIME_END) : utils_1.i18n.getText(Const_1.V.DATE_END));
|
|
48
|
+
return [FORMAT, startPlaceholder, endPlaceholder];
|
|
49
|
+
}, [props.showTime, props.startPlaceholder, props.endPlaceholder]);
|
|
50
|
+
// 是否在范围内
|
|
51
|
+
const inRange = (0, react_1.useCallback)((value) => {
|
|
52
|
+
if (props.minDate) {
|
|
53
|
+
if (value.isBefore(props.minDate))
|
|
54
|
+
return false;
|
|
59
55
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const startValue = state.current.start;
|
|
64
|
-
if (!endValue || !startValue) {
|
|
65
|
-
if (props.maxDate) {
|
|
66
|
-
return endValue.valueOf() < props.maxDate.valueOf();
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
56
|
+
if (props.maxDate) {
|
|
57
|
+
if (value.isAfter(props.maxDate))
|
|
58
|
+
return false;
|
|
69
59
|
}
|
|
70
|
-
return
|
|
71
|
-
};
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
const handleStartOpenChange = (open) => {
|
|
92
|
-
state.current.startOpen = open;
|
|
93
|
-
state.current.endOpen = !open;
|
|
94
|
-
update();
|
|
95
|
-
};
|
|
96
|
-
const handleEndOpenChange = (open) => {
|
|
97
|
-
state.current.startOpen = false;
|
|
98
|
-
state.current.endOpen = open;
|
|
99
|
-
update();
|
|
100
|
-
};
|
|
60
|
+
return true;
|
|
61
|
+
}, [props.minDate, props.maxDate]);
|
|
62
|
+
const disabledStartDate = (0, react_1.useCallback)((value) => {
|
|
63
|
+
if (!inRange(value))
|
|
64
|
+
return true;
|
|
65
|
+
if (end != null && value.isAfter(end))
|
|
66
|
+
return true;
|
|
67
|
+
return false;
|
|
68
|
+
}, [end, inRange]);
|
|
69
|
+
const disabledEndDate = (0, react_1.useCallback)((value) => {
|
|
70
|
+
if (!inRange(value))
|
|
71
|
+
return true;
|
|
72
|
+
if (start != null && value.isBefore(start))
|
|
73
|
+
return true;
|
|
74
|
+
return false;
|
|
75
|
+
}, [start, inRange]);
|
|
76
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
77
|
+
if (isFirstMounted)
|
|
78
|
+
return;
|
|
79
|
+
props.onChange([start ? start.format(FORMAT) : null, end ? end.format(FORMAT) : null,], [start ? start : null, end ? end : null,]);
|
|
80
|
+
}, [start, end]);
|
|
101
81
|
let style = {};
|
|
102
82
|
if (props.width)
|
|
103
83
|
style.width = props.width;
|
|
104
84
|
return react_1.default.createElement("div", { className: utils_1.StringUtil.className(['c-daterange'], props.className), style: style },
|
|
105
|
-
react_1.default.createElement(antd_1.DatePicker, { value:
|
|
106
|
-
react_1.default.createElement(antd_1.DatePicker, { value:
|
|
85
|
+
react_1.default.createElement(antd_1.DatePicker, { value: start, allowClear: props.allowClear, disabled: props.disabled, disabledDate: disabledStartDate, showTime: props.showTime, format: FORMAT, placeholder: startPlaceholder, onChange: setStart }),
|
|
86
|
+
react_1.default.createElement(antd_1.DatePicker, { value: end, allowClear: props.allowClear, disabled: props.disabled, disabledDate: disabledEndDate, showTime: props.showTime, format: FORMAT, placeholder: endPlaceholder, onChange: setEnd }));
|
|
107
87
|
};
|
|
108
88
|
exports.DateRange = DateRange;
|
|
@@ -87,9 +87,9 @@ const Range = (props) => {
|
|
|
87
87
|
})
|
|
88
88
|
};
|
|
89
89
|
if (data[startField])
|
|
90
|
-
params.
|
|
90
|
+
params.start = data[startField];
|
|
91
91
|
if (data[endField])
|
|
92
|
-
params.
|
|
92
|
+
params.end = data[endField];
|
|
93
93
|
return react_1.default.createElement(DateRange_1.DateRange, Object.assign({}, params));
|
|
94
94
|
};
|
|
95
95
|
const AntdRnage = (props) => {
|
|
@@ -70,26 +70,6 @@ const SearchFieldInput_1 = require("./SearchFieldInput");
|
|
|
70
70
|
let options = utils_1.PageUtil.getOptions(props.field.options);
|
|
71
71
|
return react_1.default.createElement(antd_1.Checkbox.Group, Object.assign({}, config, { className: "i-checkbox", disabled: disabled, onChange: val => onChange(val.join(',')), value: (lodash_1.default.has(data, field) && data[field]) ? data[field].split(',') : [] }), options.map(option => react_1.default.createElement(antd_1.Checkbox, { value: option.value + '' }, option.label)));
|
|
72
72
|
}, { outside: true });
|
|
73
|
-
// registerSearchField('checkbox-button', (props: SearchFieldProps) => {
|
|
74
|
-
// const { field: { field, config, placeholder, allowClear, }, disabled, onChange, data, width } = props;
|
|
75
|
-
// if (!_.isArray(props.field.options)) {
|
|
76
|
-
// console.error('field type : select must have a options field')
|
|
77
|
-
// return <TEXT {...props} />
|
|
78
|
-
// }
|
|
79
|
-
// let options = PageUtil.getOptions(props.field.options);
|
|
80
|
-
// return <Checkbox.Group
|
|
81
|
-
// {...config}
|
|
82
|
-
// style={{ width }}
|
|
83
|
-
// optionType="button"
|
|
84
|
-
// buttonStyle="solid"
|
|
85
|
-
// disabled={disabled}
|
|
86
|
-
// onChange={val => onChange(val.join(','))}
|
|
87
|
-
// value={(_.has(data, field) && data[field].split(',')) ? data[field] : undefined}
|
|
88
|
-
// options={options}
|
|
89
|
-
// >
|
|
90
|
-
// {/* {options.map(option => <Checkbox value={option.value + ''}>{option.label}</Checkbox>)} */}
|
|
91
|
-
// </Checkbox.Group>
|
|
92
|
-
// });
|
|
93
73
|
(0, _register_1.registerSearchField)('switch', (props) => {
|
|
94
74
|
const { field: { field, config, placeholder, allowClear, }, disabled, onChange, data, width } = props;
|
|
95
75
|
if (!lodash_1.default.isArray(props.field.options) || (props.field.options.length <= 1)) {
|
|
@@ -376,12 +376,12 @@ const DateRangePick = (props) => {
|
|
|
376
376
|
if (value[startField]) {
|
|
377
377
|
let day = (0, dayjs_1.default)(value[startField]);
|
|
378
378
|
if (day.isValid())
|
|
379
|
-
params.
|
|
379
|
+
params.start = day;
|
|
380
380
|
}
|
|
381
381
|
if (value[endField]) {
|
|
382
382
|
let day = (0, dayjs_1.default)(value[endField]);
|
|
383
383
|
if (day.isValid())
|
|
384
|
-
params.
|
|
384
|
+
params.end = day;
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
return react_1.default.createElement(DateRange_1.DateRange, Object.assign({}, field.config, params));
|
|
@@ -78,14 +78,18 @@ const _utils_1 = require("./_utils");
|
|
|
78
78
|
config.valueFormat(value),
|
|
79
79
|
" "));
|
|
80
80
|
});
|
|
81
|
+
const formatRange = (value) => {
|
|
82
|
+
if (value == undefined)
|
|
83
|
+
return utils_1.Const.NONE;
|
|
84
|
+
let start = value[0] === undefined ? '?' : value[0];
|
|
85
|
+
let end = value[1] === undefined ? '?' : value[1];
|
|
86
|
+
return `${start} - ${end}`;
|
|
87
|
+
};
|
|
81
88
|
(0, _register_1.registerFormField)('slider-range', (props) => {
|
|
82
89
|
const { field, disabled, value, onChange } = props;
|
|
83
|
-
let config = lodash_1.default.merge({ valueWidth: 128, valueFormat:
|
|
90
|
+
let config = lodash_1.default.merge({ valueWidth: 128, valueFormat: formatRange }, field.config);
|
|
84
91
|
let params = { range: true, disabled, min: 0, max: 100, step: 1 };
|
|
85
92
|
const [fields, values] = (0, _input_1.getMultiFieldValues)(field, value);
|
|
86
|
-
if (!lodash_1.default.isFunction(config.valueFormat) || config.valueWidth == 0) {
|
|
87
|
-
return react_1.default.createElement(Slider_1.Slider, Object.assign({}, params, field.config, { range: true, value: values, onChange: ([start, end]) => onChange({ [fields[0]]: start, [fields[1]]: end }) }));
|
|
88
|
-
}
|
|
89
93
|
return react_1.default.createElement("div", { className: 'i-slider' },
|
|
90
94
|
react_1.default.createElement(Slider_1.Slider, Object.assign({}, params, field.config, { range: true, value: values, onChange: ([start, end]) => onChange({ [fields[0]]: start, [fields[1]]: end }) })),
|
|
91
95
|
react_1.default.createElement("div", { className: 'i-slider-value', style: { width: config.valueWidth } },
|
|
@@ -47,22 +47,25 @@ const Const_1 = require("../Const");
|
|
|
47
47
|
params.allowClear = false;
|
|
48
48
|
return react_1.default.createElement(Select_1.Select, Object.assign({}, params, field.config, { mode: "default", value: value === null ? undefined : value, onChange: onChange, options: options }));
|
|
49
49
|
});
|
|
50
|
-
//
|
|
50
|
+
// 多选下拉
|
|
51
51
|
(0, _register_1.registerFormField)('multi-select', (props) => {
|
|
52
52
|
const { field, disabled, value, onChange, options } = props;
|
|
53
|
+
const onValueChange = (0, react_1.useCallback)((val) => {
|
|
54
|
+
if (field.dataType == 'array') {
|
|
55
|
+
onChange(val);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
onChange(val.join(','));
|
|
59
|
+
}, [field.dataType]);
|
|
53
60
|
let params = { placeholder: (0, _input_1.getPlaceholder)(field, true), disabled, allowClear: true };
|
|
54
61
|
if (field.required || field.rules && lodash_1.default.find(field.rules, { required: true }))
|
|
55
62
|
params.allowClear = false;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
selectKey = (value || '').split(',').map(lodash_1.default.trim);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return react_1.default.createElement(Select_1.Select, Object.assign({}, params, field.config, { value: selectKey, mode: "multiple", onChange: (val) => onChange(val.join(',')) }), options.map(item => react_1.default.createElement(Select_1.Select.Option, { value: item.value + '' }, item.label)));
|
|
63
|
+
const selectKey = (0, react_1.useMemo)(() => {
|
|
64
|
+
if (lodash_1.default.isArray(value))
|
|
65
|
+
return value;
|
|
66
|
+
return (value || '').split(',').map(lodash_1.default.trim);
|
|
67
|
+
}, [value]);
|
|
68
|
+
return react_1.default.createElement(Select_1.Select, Object.assign({}, params, field.config, { value: selectKey, mode: "multiple", onChange: onValueChange }), options.map(item => react_1.default.createElement(Select_1.Select.Option, { value: item.value + '' }, item.label)));
|
|
66
69
|
}, {
|
|
67
70
|
render: _utils_1.MULTI_CHOOSE_SHOW
|
|
68
71
|
});
|
package/deps/echarts.js
CHANGED
|
@@ -40,7 +40,7 @@ const EChart = props => {
|
|
|
40
40
|
window.clearTimeout(resizePid.current);
|
|
41
41
|
resizePid.current = setTimeout(() => {
|
|
42
42
|
graphRef.current.resize();
|
|
43
|
-
},
|
|
43
|
+
}, 33);
|
|
44
44
|
};
|
|
45
45
|
(0, react_1.useEffect)(() => {
|
|
46
46
|
graphRef.current = echarts.init(rootRef.current);
|
|
@@ -64,6 +64,12 @@ const EChart = props => {
|
|
|
64
64
|
(0, react_1.useEffect)(() => {
|
|
65
65
|
if (graphRef.current == null)
|
|
66
66
|
return;
|
|
67
|
+
if (props.data == null)
|
|
68
|
+
return;
|
|
69
|
+
if (graphRef.current.setOption == null) {
|
|
70
|
+
console.error('尚未引入 ECharts,需要在package.json里面声明');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
67
73
|
graphRef.current.setOption(props.data);
|
|
68
74
|
}, [props.data]);
|
|
69
75
|
return react_1.default.createElement("div", { ref: rootRef, className: utils_1.StringUtil.className(['_ev'], props.className) });
|
package/index.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export { UForm, UFormModal, UInfo, UInfoModal, UModal, UDescriptions } from './c
|
|
|
134
134
|
export { VTable, ApiTable, ApiTableModal, STable, TopTable, TopTableModal } from './components/Tables';
|
|
135
135
|
export { STree, DTree, FTree } from './components/Trees';
|
|
136
136
|
export { UploadFile, UploadImage, UploadModal } from './components/Upload';
|
|
137
|
-
export { SList } from './components/Lists/SList';
|
|
137
|
+
export { SList, type SListProps } from './components/Lists/SList';
|
|
138
138
|
export type { UFromProps, UModalProps, UFormField, UFormFieldGroup, LinkResult, UDescriptionsProps, UFormRef, Link, LinkValue } from './components/UForm';
|
|
139
139
|
export type { TableColumn } from './components/Tables/index';
|
|
140
140
|
export type { VTableProps, VTableRef } from './components/Tables/VTable';
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"vap1","version":"0.2.
|
|
1
|
+
{"name":"vap1","version":"0.2.3","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
|
package/utils/PageUtil.js
CHANGED
|
@@ -68,7 +68,9 @@ exports.clearURL = (len == 0) ? (val => val) : (url) => {
|
|
|
68
68
|
/**
|
|
69
69
|
* 判断是否有权限
|
|
70
70
|
*/
|
|
71
|
-
const hasRole = (roleCode) =>
|
|
71
|
+
const hasRole = (roleCode) => {
|
|
72
|
+
return Global_1.CONFIG.PROMISSION.ROLE.has(roleCode) || Global_1.CONFIG.PROMISSION.ROLE.has((0, StringUtil_1.trimLower)(roleCode));
|
|
73
|
+
};
|
|
72
74
|
exports.hasRole = hasRole;
|
|
73
75
|
// export const hasRole = (roleCode: string): boolean => true; // 测试中,总返回有权限
|
|
74
76
|
const GLOBAL_APPS = new Map();
|
package/utils/StringUtil.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ export declare const searchText: (sentence: string, keyword: string) => MatchPat
|
|
|
91
91
|
* 拼 className
|
|
92
92
|
*/
|
|
93
93
|
export declare const className: (base: string[], classNameProps?: string) => string;
|
|
94
|
+
export declare const replaceAll: (text: string, keyword: string | RegExp, replaceText: string) => string;
|
|
94
95
|
/**
|
|
95
96
|
* 试图转px的值
|
|
96
97
|
* 300px -> 300
|
package/utils/StringUtil.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getFileType = exports.getFloat = exports.getInteger = exports.getBoolean = exports.getString = exports.copy = exports.px = exports.className = exports.searchText = exports.trimLower = exports.isBoolean = exports.isBTCAddress = exports.uuid = exports.genKey = exports.isId = exports.isId15 = exports.isId18 = exports.REG_ID_15 = exports.REG_ID_18 = exports.isIP = exports.isIP6 = exports.isIP4 = exports.isPhone = exports.isMAC = exports.isURL = exports.isEmail = exports.isTelePhone = exports.isMobilePhone = exports.REG_PORT = exports.REG_URL = exports.REG_IPV6 = exports.REG_IPV4 = exports.REG_TELEPHONE = exports.REG_PHONE = exports.REG_EMAIL = void 0;
|
|
6
|
+
exports.getFileType = exports.getFloat = exports.getInteger = exports.getBoolean = exports.getString = exports.copy = exports.px = exports.replaceAll = exports.className = exports.searchText = exports.trimLower = exports.isBoolean = exports.isBTCAddress = exports.uuid = exports.genKey = exports.isId = exports.isId15 = exports.isId18 = exports.REG_ID_15 = exports.REG_ID_18 = exports.isIP = exports.isIP6 = exports.isIP4 = exports.isPhone = exports.isMAC = exports.isURL = exports.isEmail = exports.isTelePhone = exports.isMobilePhone = exports.REG_PORT = exports.REG_URL = exports.REG_IPV6 = exports.REG_IPV4 = exports.REG_TELEPHONE = exports.REG_PHONE = exports.REG_EMAIL = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const _Support_1 = require("./_Support");
|
|
9
9
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
@@ -205,6 +205,12 @@ const className = (base, classNameProps) => {
|
|
|
205
205
|
return base.join(' ');
|
|
206
206
|
};
|
|
207
207
|
exports.className = className;
|
|
208
|
+
const replaceAll = (text, keyword, replaceText) => {
|
|
209
|
+
let reg = lodash_1.default.isRegExp(keyword) ? new RegExp(keyword, 'g') : new RegExp(keyword, "g");
|
|
210
|
+
return lodash_1.default.replace(text, reg, replaceText);
|
|
211
|
+
;
|
|
212
|
+
};
|
|
213
|
+
exports.replaceAll = replaceAll;
|
|
208
214
|
/**
|
|
209
215
|
* 试图转px的值
|
|
210
216
|
* 300px -> 300
|