vap1 0.1.8 → 0.2.0
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/Box.js +1 -2
- package/components/SearchBar/ActionButtons.js +1 -1
- package/components/SearchBar/_FieldType.d.ts +1 -1
- package/components/SearchBar/_FieldType.js +6 -0
- package/components/Tables/Components/ActionBar.js +20 -17
- package/components/Tables/STable.d.ts +3 -3
- package/components/Tables/VTable.js +1 -2
- package/components/TreeSelect/BaseTreeSelect.js +0 -1
- package/components/_setup/SearchField/SearchFieldTree.js +149 -189
- package/components/_setup/UForm/UFormTree.js +9 -9
- package/package.json +1 -1
- package/utils/Renders/DictRender.d.ts +3 -0
- package/utils/Renders/DictRender.js +22 -30
package/components/Box/Box.js
CHANGED
|
@@ -76,8 +76,7 @@ exports.Box = (0, react_1.forwardRef)((props, ref) => {
|
|
|
76
76
|
if (props.nobg)
|
|
77
77
|
className.push('c-box-nobg');
|
|
78
78
|
const style = Object.assign({}, props.style);
|
|
79
|
-
|
|
80
|
-
className.push('c-box-' + props.mode);
|
|
79
|
+
className.push(props.mode ? ('c-box-' + props.mode) : 'c-box-common');
|
|
81
80
|
if (props.mode == 'inner') {
|
|
82
81
|
if (rootRef.current == null) {
|
|
83
82
|
// style.height = 0;
|
|
@@ -64,7 +64,7 @@ const ActionButton = (props) => {
|
|
|
64
64
|
if (props.danger)
|
|
65
65
|
btnParam.danger = true;
|
|
66
66
|
if (props.confirm && props.disabled !== true) {
|
|
67
|
-
return react_1.default.createElement(Popconfirm_1.Popconfirm, { trigger: "click", placement: "bottomLeft", onConfirm: props.onClick, title: lodash_1.default.isString(props.confirm) ? props.confirm : props.confirm() },
|
|
67
|
+
return react_1.default.createElement(Popconfirm_1.Popconfirm, { key: Math.floor(lodash_1.default.random() * 1000000) + '', trigger: "click", placement: "bottomLeft", onConfirm: props.onClick, title: lodash_1.default.isString(props.confirm) ? props.confirm : props.confirm() },
|
|
68
68
|
react_1.default.createElement(Button_1.Button, Object.assign({}, props.config, btnParam), props.label));
|
|
69
69
|
}
|
|
70
70
|
btnParam.onClick = (evt) => utils_1.PageUtil.stopEvent(evt, props.onClick);
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
| text ||
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export declare const _FieldType: readonly ["text", "number", "select", "multi-select", "radio", "radio-button", "checkbox", "switch", "date", "daterange", "daterange-single", "datetime", "datetimerange", "datetimerange-single", "month", "monthrange", "autocomplete"];
|
|
8
|
+
export declare const _FieldType: readonly ["text", "number", "select", "multi-select", "radio", "radio-button", "checkbox", "switch", "date", "daterange", "daterange-single", "datetime", "datetimerange", "datetimerange-single", "month", "monthrange", "stree-select", "dtree-select", "ftree-select", "multi-stree-select", "multi-dtree-select", "multi-ftree-select", "autocomplete"];
|
|
@@ -25,6 +25,12 @@ exports._FieldType = [
|
|
|
25
25
|
'datetimerange-single',
|
|
26
26
|
'month',
|
|
27
27
|
'monthrange',
|
|
28
|
+
'stree-select',
|
|
29
|
+
'dtree-select',
|
|
30
|
+
'ftree-select',
|
|
31
|
+
'multi-stree-select',
|
|
32
|
+
'multi-dtree-select',
|
|
33
|
+
'multi-ftree-select',
|
|
28
34
|
'autocomplete',
|
|
29
35
|
];
|
|
30
36
|
// * text 文本输入(默认)
|
|
@@ -48,24 +48,27 @@ const ActionBar = props => {
|
|
|
48
48
|
update();
|
|
49
49
|
};
|
|
50
50
|
}, []);
|
|
51
|
-
let buttons = [];
|
|
52
51
|
const [selectedRowKeys, selectedObjects] = props.selectedRef.current.selected;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
sub
|
|
63
|
-
btn.children.
|
|
64
|
-
sub.children
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
const buttons = (0, react_1.useMemo)(() => {
|
|
53
|
+
const btns = [];
|
|
54
|
+
(props.buttons || []).map(btn => {
|
|
55
|
+
if (btn === false)
|
|
56
|
+
return;
|
|
57
|
+
if (btn === null) {
|
|
58
|
+
btns.push(null);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let sub = convertButton(btn, selectedRowKeys, selectedObjects, props.queryParam);
|
|
62
|
+
if (lodash_1.default.isArray(btn.children) && btn.children.length > 0) {
|
|
63
|
+
sub.children = [];
|
|
64
|
+
btn.children.map(item => {
|
|
65
|
+
sub.children.push(convertButton(item, selectedRowKeys, selectedObjects, props.queryParam));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
btns.push(sub);
|
|
69
|
+
});
|
|
70
|
+
return btns;
|
|
71
|
+
}, [selectedRowKeys, props.buttons, props.queryParam]);
|
|
69
72
|
return react_1.default.createElement(ActionButtons_1.ActionButtons, { buttons: buttons });
|
|
70
73
|
};
|
|
71
74
|
exports.ActionBar = ActionBar;
|
|
@@ -3,10 +3,10 @@ import { ListInit } from '../../hooks/_list';
|
|
|
3
3
|
import type { BaseTableProps } from './index';
|
|
4
4
|
export type STableProps = BaseTableProps & ListInit & {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* 说明 pageSize : 默认为 false : 不分页。
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* 为 true 时,以系统默认分页数进行分页
|
|
9
|
+
* 为 数字 时, 以指定的分页大小进行分页
|
|
10
10
|
*/
|
|
11
11
|
pageSize?: true | number;
|
|
12
12
|
};
|
|
@@ -201,7 +201,6 @@ const _VTable = (0, react_1.forwardRef)((props, ref) => {
|
|
|
201
201
|
} }));
|
|
202
202
|
});
|
|
203
203
|
exports.VTable = (0, react_1.forwardRef)((props, ref) => {
|
|
204
|
-
var _a;
|
|
205
204
|
const { isQuerying, pageNo, pageSize, total, totalAcc, param, pageTo, query, cost } = props.model;
|
|
206
205
|
// 通过 ref 方式交互,后续扩展方法实现定制联页选择
|
|
207
206
|
const selectedRef = (0, react_1.useRef)({ selected: [[], []], onSelected: () => { }, });
|
|
@@ -215,7 +214,7 @@ exports.VTable = (0, react_1.forwardRef)((props, ref) => {
|
|
|
215
214
|
return props.model.param;
|
|
216
215
|
}
|
|
217
216
|
};
|
|
218
|
-
}, [
|
|
217
|
+
}, [param]);
|
|
219
218
|
let boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
|
|
220
219
|
if (props.searchBar) {
|
|
221
220
|
boxProps.searchBar = Object.assign(Object.assign({}, props.searchBar), { disabled: isQuerying, onSearch: (data) => {
|
|
@@ -27,7 +27,6 @@ exports.renderRoot = exports.getNodeParam = exports.BaseTreeSelect = exports.use
|
|
|
27
27
|
const lodash_1 = __importStar(require("lodash"));
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
29
|
const antd_1 = require("antd");
|
|
30
|
-
// import { HighLight, Icon } from '';
|
|
31
30
|
const HighLight_1 = require("../_common/HighLight");
|
|
32
31
|
;
|
|
33
32
|
const Icon_1 = require("../_adapt/Icon");
|
|
@@ -1,191 +1,151 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// } else if (_.isArray(node.children) && node.children.length) {
|
|
127
|
-
// return this.setChidren(node.children, key, children);
|
|
128
|
-
// }
|
|
129
|
-
// }
|
|
130
|
-
// return false;
|
|
131
|
-
// }
|
|
132
|
-
// async onLoadData(node) {
|
|
133
|
-
// const children = await this.getChildren(node.props.eventKey);
|
|
134
|
-
// if (children.length == 0) {
|
|
135
|
-
// return;
|
|
136
|
-
// }
|
|
137
|
-
// const treeData = _.concat([], this.state.treeData);
|
|
138
|
-
// this.setChidren(treeData, node.props.eventKey, children)
|
|
139
|
-
// this.setState({ treeData })
|
|
140
|
-
// };
|
|
141
|
-
// renderNode(data: any) {
|
|
142
|
-
// let isLeaf = false;
|
|
143
|
-
// if (_.has(data, 'children') && _.isArray(data.children)) {
|
|
144
|
-
// if (data.children.length) {
|
|
145
|
-
// isLeaf = false;
|
|
146
|
-
// } else {
|
|
147
|
-
// isLeaf = true;
|
|
148
|
-
// }
|
|
149
|
-
// } else if (this.fields.checkField) {
|
|
150
|
-
// if (!data[this.fields.checkField]) {
|
|
151
|
-
// isLeaf = true;
|
|
152
|
-
// }
|
|
153
|
-
// }
|
|
154
|
-
// if (isLeaf) {
|
|
155
|
-
// return <TreeSelect.TreeNode value={data[this.fields.keyField]} key={data[this.fields.keyField]} title={data[this.fields.titleField]} isLeaf> </TreeSelect.TreeNode>
|
|
156
|
-
// }
|
|
157
|
-
// if (_.isArray(data.children) && data.children.length) {
|
|
158
|
-
// return <TreeSelect.TreeNode value={data[this.fields.keyField]} key={data[this.fields.keyField]} title={data[this.fields.titleField]}>
|
|
159
|
-
// {data.children.map(item => this.renderNode(item))}
|
|
160
|
-
// </TreeSelect.TreeNode>
|
|
161
|
-
// }
|
|
162
|
-
// return <TreeSelect.TreeNode value={data[this.fields.keyField]} key={data[this.fields.keyField]} title={data[this.fields.titleField]}> </TreeSelect.TreeNode>
|
|
163
|
-
// }
|
|
164
|
-
// render() {
|
|
165
|
-
// const { field, onChange, data } = this.props;
|
|
166
|
-
// const { treeData } = this.state;
|
|
167
|
-
// let param: any = {
|
|
168
|
-
// allowClear: true,
|
|
169
|
-
// placeholder: _.has(field.config, 'placeholder') ? field.config.placeholder : null || field.placeholder || `请选择 ${field.label}`,
|
|
170
|
-
// }
|
|
171
|
-
// if (field.allowClear === false) {
|
|
172
|
-
// param.allowClear = false;
|
|
173
|
-
// }
|
|
174
|
-
// if (_.has(data, field.field)) {
|
|
175
|
-
// param.value = data[field.field];
|
|
176
|
-
// }
|
|
177
|
-
// if (_.has(this.props, 'width')) {
|
|
178
|
-
// param.style = { width: this.props.width }
|
|
179
|
-
// }
|
|
180
|
-
// return <TreeSelect
|
|
181
|
-
// {...param}
|
|
182
|
-
// onChange={(value, label, extra) => {
|
|
183
|
-
// onChange(value)
|
|
184
|
-
// }}
|
|
185
|
-
// loadData={(node) => this.onLoadData(node)}
|
|
186
|
-
// >
|
|
187
|
-
// {treeData.map(item => this.renderNode(item))}
|
|
188
|
-
// </TreeSelect>
|
|
189
|
-
// }
|
|
190
|
-
// }
|
|
191
|
-
// registerSearchField('dynamic-tree-select', DynamicTreeSelect);
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
+
const _register_1 = require("../../SearchBar/_register");
|
|
32
|
+
const STreeSelect_1 = require("../../TreeSelect/STreeSelect");
|
|
33
|
+
const DTreeSelect_1 = require("../../TreeSelect/DTreeSelect");
|
|
34
|
+
const FTreeSelect_1 = require("../../TreeSelect/FTreeSelect");
|
|
35
|
+
const SearchFieldInput_1 = require("./SearchFieldInput");
|
|
36
|
+
const toArr = (value) => (0, react_1.useMemo)(() => {
|
|
37
|
+
if (value == undefined)
|
|
38
|
+
return [];
|
|
39
|
+
if (lodash_1.default.isArray(value))
|
|
40
|
+
return value;
|
|
41
|
+
if (lodash_1.default.isString(value))
|
|
42
|
+
return value.split(',');
|
|
43
|
+
return [];
|
|
44
|
+
}, [value]);
|
|
45
|
+
(0, _register_1.registerSearchField)('stree-select', (props) => {
|
|
46
|
+
const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
|
|
47
|
+
if (!lodash_1.default.has(config, 'titleField')) {
|
|
48
|
+
console.error('field type : STree select must have a config with titleField');
|
|
49
|
+
return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
|
|
50
|
+
}
|
|
51
|
+
let treeData = lodash_1.default.has(config, 'treeData') ? config.treeData : options;
|
|
52
|
+
let params = {
|
|
53
|
+
titleField: config.titleFField,
|
|
54
|
+
disabled: disabled,
|
|
55
|
+
treeData,
|
|
56
|
+
multiple: false,
|
|
57
|
+
allowClear: typeof allowClear == 'boolean' ? allowClear : true,
|
|
58
|
+
placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
|
|
59
|
+
style: { width },
|
|
60
|
+
};
|
|
61
|
+
return react_1.default.createElement(STreeSelect_1.STreeSelect, Object.assign({}, params, config, { multiple: false, value: (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined, onChange: onChange }));
|
|
62
|
+
});
|
|
63
|
+
(0, _register_1.registerSearchField)('dtree-select', (props) => {
|
|
64
|
+
const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
|
|
65
|
+
if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'childApi')) {
|
|
66
|
+
console.error('field type : DTree select must have a config with titleField and childApi');
|
|
67
|
+
return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
|
|
68
|
+
}
|
|
69
|
+
let params = {
|
|
70
|
+
titleField: config.titleFField,
|
|
71
|
+
childApi: config.childApi,
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
multiple: false,
|
|
74
|
+
allowClear: typeof allowClear == 'boolean' ? allowClear : true,
|
|
75
|
+
placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
|
|
76
|
+
style: { width },
|
|
77
|
+
};
|
|
78
|
+
return react_1.default.createElement(DTreeSelect_1.DTreeSelect, Object.assign({}, params, config, { multiple: false, value: (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined, onChange: onChange }));
|
|
79
|
+
});
|
|
80
|
+
(0, _register_1.registerSearchField)('ftree-select', (props) => {
|
|
81
|
+
const { field: { field, config, placeholder, allowClear }, disabled, onChange, data, width } = props;
|
|
82
|
+
if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'fetchApi')) {
|
|
83
|
+
console.error('field type : FTree select must have a config with titleField and fetchApi');
|
|
84
|
+
return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
|
|
85
|
+
}
|
|
86
|
+
let params = {
|
|
87
|
+
titleField: config.titleFField,
|
|
88
|
+
fetchApi: config.fetchApi,
|
|
89
|
+
disabled: disabled,
|
|
90
|
+
multiple: false,
|
|
91
|
+
allowClear: typeof allowClear == 'boolean' ? allowClear : true,
|
|
92
|
+
placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
|
|
93
|
+
style: { width },
|
|
94
|
+
};
|
|
95
|
+
return react_1.default.createElement(FTreeSelect_1.FTreeSelect, Object.assign({}, params, config, { multiple: false, value: (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined, onChange: onChange }));
|
|
96
|
+
});
|
|
97
|
+
(0, _register_1.registerSearchField)('multi-stree-select', (props) => {
|
|
98
|
+
const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
|
|
99
|
+
if (!lodash_1.default.has(config, 'titleField')) {
|
|
100
|
+
console.error('field type : tree-select must have a config with title field');
|
|
101
|
+
return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
|
|
102
|
+
}
|
|
103
|
+
let treeData = lodash_1.default.has(config, 'treeData') ? config.treeData : options;
|
|
104
|
+
let params = {
|
|
105
|
+
titleField: config.titleFField,
|
|
106
|
+
disabled: disabled,
|
|
107
|
+
treeData,
|
|
108
|
+
multiple: true,
|
|
109
|
+
allowClear: typeof allowClear == 'boolean' ? allowClear : true,
|
|
110
|
+
placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
|
|
111
|
+
style: { width },
|
|
112
|
+
};
|
|
113
|
+
const value = (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined;
|
|
114
|
+
return react_1.default.createElement(STreeSelect_1.STreeSelect, Object.assign({}, params, config, { multiple: true, value: toArr(value), onChange: (ids) => onChange(ids.join(',')) }));
|
|
115
|
+
});
|
|
116
|
+
(0, _register_1.registerSearchField)('multi-dtree-select', (props) => {
|
|
117
|
+
const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
|
|
118
|
+
if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'childApi')) {
|
|
119
|
+
console.error('field type : DTree select must have a config with titleField and childApi');
|
|
120
|
+
return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
|
|
121
|
+
}
|
|
122
|
+
let params = {
|
|
123
|
+
titleField: config.titleFField,
|
|
124
|
+
childApi: config.childApi,
|
|
125
|
+
disabled: disabled,
|
|
126
|
+
multiple: false,
|
|
127
|
+
allowClear: typeof allowClear == 'boolean' ? allowClear : true,
|
|
128
|
+
placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
|
|
129
|
+
style: { width },
|
|
130
|
+
};
|
|
131
|
+
const value = (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined;
|
|
132
|
+
return react_1.default.createElement(DTreeSelect_1.DTreeSelect, Object.assign({}, params, config, { multiple: true, value: toArr(value), onChange: (ids) => onChange(ids.join(',')) }));
|
|
133
|
+
});
|
|
134
|
+
(0, _register_1.registerSearchField)('multi-ftree-select', (props) => {
|
|
135
|
+
const { field: { field, config, placeholder, allowClear }, disabled, onChange, data, width } = props;
|
|
136
|
+
if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'fetchApi')) {
|
|
137
|
+
console.error('field type : FTree select must have a config with titleField and fetchApi');
|
|
138
|
+
return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
|
|
139
|
+
}
|
|
140
|
+
let params = {
|
|
141
|
+
titleField: config.titleFField,
|
|
142
|
+
fetchApi: config.fetchApi,
|
|
143
|
+
disabled: disabled,
|
|
144
|
+
multiple: false,
|
|
145
|
+
allowClear: typeof allowClear == 'boolean' ? allowClear : true,
|
|
146
|
+
placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
|
|
147
|
+
style: { width },
|
|
148
|
+
};
|
|
149
|
+
const value = (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined;
|
|
150
|
+
return react_1.default.createElement(FTreeSelect_1.FTreeSelect, Object.assign({}, params, config, { multiple: true, value: toArr(value), onChange: (ids) => onChange(ids.join(',')) }));
|
|
151
|
+
});
|
|
@@ -33,6 +33,15 @@ const _input_1 = require("../../UForm/_input");
|
|
|
33
33
|
const STreeSelect_1 = require("../../TreeSelect/STreeSelect");
|
|
34
34
|
const DTreeSelect_1 = require("../../TreeSelect/DTreeSelect");
|
|
35
35
|
const FTreeSelect_1 = require("../../TreeSelect/FTreeSelect");
|
|
36
|
+
const toArr = (value) => (0, react_1.useMemo)(() => {
|
|
37
|
+
if (value == undefined)
|
|
38
|
+
return [];
|
|
39
|
+
if (lodash_1.default.isArray(value))
|
|
40
|
+
return value;
|
|
41
|
+
if (lodash_1.default.isString(value))
|
|
42
|
+
return value.split(',');
|
|
43
|
+
return [];
|
|
44
|
+
}, [value]);
|
|
36
45
|
(0, _register_1.registerFormField)('stree-select', (props) => {
|
|
37
46
|
const { field, disabled, value, onChange } = props;
|
|
38
47
|
let params = { placeholder: (0, _input_1.getPlaceholder)(field, true), disabled, allowClear: true };
|
|
@@ -54,15 +63,6 @@ const FTreeSelect_1 = require("../../TreeSelect/FTreeSelect");
|
|
|
54
63
|
params.allowClear = false;
|
|
55
64
|
return react_1.default.createElement(FTreeSelect_1.FTreeSelect, Object.assign({}, params, field.config, { multiple: false, value: value === null ? undefined : value, onChange: onChange }));
|
|
56
65
|
});
|
|
57
|
-
const toArr = (value) => (0, react_1.useMemo)(() => {
|
|
58
|
-
if (value == undefined)
|
|
59
|
-
return [];
|
|
60
|
-
if (lodash_1.default.isArray(value))
|
|
61
|
-
return value;
|
|
62
|
-
if (lodash_1.default.isString(value))
|
|
63
|
-
return value.split(',');
|
|
64
|
-
return [];
|
|
65
|
-
}, [value]);
|
|
66
66
|
const treeChange = (onChange, dataType) => (0, react_1.useCallback)((value) => {
|
|
67
67
|
if (dataType == 'array') {
|
|
68
68
|
onChange(value);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"vap1","version":"0.
|
|
1
|
+
{"name":"vap1","version":"0.2.0","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
|
|
@@ -19,5 +19,8 @@ interface DictRender extends Render {
|
|
|
19
19
|
options: (config?: OptionConvertConfig) => BaseOption[];
|
|
20
20
|
}
|
|
21
21
|
export declare const DictRender: (options: string | DictRenderOptions) => DictRender;
|
|
22
|
+
/**
|
|
23
|
+
* 初始化字典,将字典接口的响应数组传入
|
|
24
|
+
*/
|
|
22
25
|
export declare const initDict: (dict: PlainObject[]) => void;
|
|
23
26
|
export { _V_DICT as DICT };
|
|
@@ -166,22 +166,6 @@ const _DictRender = (props) => {
|
|
|
166
166
|
return props.default || Const_2.NONE;
|
|
167
167
|
return renderDictValue(dictInfo, dictInfo.nodes[idx]);
|
|
168
168
|
};
|
|
169
|
-
// if (config.valueFormat) {
|
|
170
|
-
// switch (config.valueFormat) {
|
|
171
|
-
// case 'string':
|
|
172
|
-
// format = val => val + '';
|
|
173
|
-
// break;
|
|
174
|
-
// case 'number':
|
|
175
|
-
// format = val => {
|
|
176
|
-
// if (_.isNumber(val)) return val;
|
|
177
|
-
// try {
|
|
178
|
-
// return parseInt(val);
|
|
179
|
-
// } catch {
|
|
180
|
-
// return val;
|
|
181
|
-
// }
|
|
182
|
-
// }
|
|
183
|
-
// }
|
|
184
|
-
// }
|
|
185
169
|
const putOptions = (arr, config) => {
|
|
186
170
|
if (config === undefined)
|
|
187
171
|
return arr;
|
|
@@ -221,14 +205,14 @@ const DictRender = (options) => {
|
|
|
221
205
|
};
|
|
222
206
|
fn.getText = (key, def) => {
|
|
223
207
|
if (key === null)
|
|
224
|
-
return def
|
|
208
|
+
return lodash_1.default.isString(def) ? def : '';
|
|
225
209
|
const dictInfo = DICT.get(props.dictType);
|
|
226
210
|
if (dictInfo == null)
|
|
227
|
-
return def
|
|
211
|
+
return lodash_1.default.isString(def) ? def : '';
|
|
228
212
|
const dictKey = key + '';
|
|
229
213
|
let idx = lodash_1.default.findIndex(dictInfo.nodes, (item) => dictKey == item.value);
|
|
230
214
|
if (idx < 0)
|
|
231
|
-
return def
|
|
215
|
+
return lodash_1.default.isString(def) ? def : '';
|
|
232
216
|
return dictInfo.nodes[idx].label;
|
|
233
217
|
};
|
|
234
218
|
if (lodash_1.default.isString(options))
|
|
@@ -236,22 +220,30 @@ const DictRender = (options) => {
|
|
|
236
220
|
return fn;
|
|
237
221
|
};
|
|
238
222
|
exports.DictRender = DictRender;
|
|
239
|
-
|
|
223
|
+
const initNodes = (parentType, dict, nodes) => {
|
|
224
|
+
let childs = lodash_1.default.filter(dict, item => item.parentType == parentType);
|
|
225
|
+
childs.map(item => {
|
|
226
|
+
let value = lodash_1.default.trim(item.code);
|
|
227
|
+
if (value.length > 0)
|
|
228
|
+
nodes.push({ label: item.codeValue, value });
|
|
229
|
+
let subChildren = lodash_1.default.filter(dict, sub => sub.parentType == item.type);
|
|
230
|
+
if (subChildren.length > 0) {
|
|
231
|
+
initNodes(item.type, dict, nodes);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* 初始化字典,将字典接口的响应数组传入
|
|
237
|
+
*/
|
|
240
238
|
const initDict = (dict) => {
|
|
241
239
|
const roots = lodash_1.default.filter(dict, item => item['parentType'] == '0' || item['parentType'] == '');
|
|
242
240
|
_V_DICT.DICTS = [];
|
|
243
241
|
roots.map(root => {
|
|
244
|
-
|
|
245
|
-
if (root.format && VALIDATE_FORMAT.has(root.format)) {
|
|
246
|
-
info.format = root.format;
|
|
247
|
-
}
|
|
242
|
+
const info = { code: root.type, nodes: [] };
|
|
248
243
|
_V_DICT.DICTS.push({ label: root.codeValue, value: root.type });
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (value.length > 0)
|
|
253
|
-
info.nodes.push({ label: item.codeValue, value });
|
|
254
|
-
});
|
|
244
|
+
if (root.format && VALIDATE_FORMAT.has(root.format))
|
|
245
|
+
info.format = root.format;
|
|
246
|
+
initNodes(root.type, dict, info.nodes);
|
|
255
247
|
DICT.set(root.type, info);
|
|
256
248
|
});
|
|
257
249
|
};
|