vap1 0.1.0 → 0.1.2
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 +9 -2
- package/components/SearchBar/index.js +4 -0
- package/components/Tables/ApiTable.d.ts +2 -2
- package/components/Tables/ApiTableModal.d.ts +1 -1
- package/components/Tables/TopTable.js +14 -15
- package/components/Tables/VTable.d.ts +21 -2
- package/components/Tables/VTable.js +19 -6
- package/components/Tables/index.d.ts +4 -4
- package/components/Trees/ActionTree.js +1 -1
- package/components/Trees/BaseTree.d.ts +2 -6
- package/components/Trees/BaseTree.js +2 -1
- package/components/Trees/DTree.js +2 -9
- package/components/Trees/FTree.js +6 -1
- package/components/Trees/STree.js +6 -1
- package/components/UForm/UForm.d.ts +1 -17
- package/components/UForm/UForm.js +27 -59
- package/components/UForm/UInfoModal.js +0 -3
- package/components/UForm/index.d.ts +16 -0
- package/components/Upload/UploadFile.js +0 -1
- package/components/_adapt/Button.js +7 -4
- package/components/_adapt/ColorPicker.d.ts +23 -4
- package/components/_adapt/ColorPicker.js +103 -39
- package/components/_adapt/InputNumber.d.ts +2 -2
- package/components/_adapt/InputNumber.js +8 -29
- package/components/_adapt/Layout.js +3 -2
- package/components/_adapt/Row.js +1 -3
- package/components/_adapt/Table.js +5 -8
- package/components/_common/AutoComplete.js +1 -1
- package/components/_setup/SearchField/SearchFieldSelect.js +6 -4
- package/components/_setup/UForm/UFormAdvanceInput.js +59 -34
- package/components/_setup/UForm/UFormInput.js +20 -23
- package/components/_setup/UForm/UFormJSON.js +2 -2
- package/components/_setup/UForm/UFormSelect.js +2 -2
- package/hooks/_list.d.ts +5 -2
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -1
- package/hooks/useApi.d.ts +2 -68
- package/hooks/useApi.js +5 -333
- package/hooks/useApiBase.d.ts +68 -0
- package/hooks/useApiBase.js +331 -0
- package/hooks/useApiGlobal.d.ts +11 -0
- package/hooks/useApiGlobal.js +39 -5
- package/index.d.ts +1 -2
- package/index.js +1 -1
- package/login/jit/pnxclient.d.ts +1 -0
- package/package.json +1 -1
- package/utils/PageUtil.d.ts +8 -0
- package/utils/PageUtil.js +20 -1
package/components/Box/Box.js
CHANGED
|
@@ -67,7 +67,8 @@ exports.useBox = useBox;
|
|
|
67
67
|
exports.Box = react_1.default.forwardRef((props, ref) => {
|
|
68
68
|
const app = (0, hooks_1.useApp)();
|
|
69
69
|
const [state, setState] = (0, hooks_1.useSetState)(null);
|
|
70
|
-
const _layoutRef = (0, react_1.useRef)(null);
|
|
70
|
+
const _layoutRef = (0, react_1.useRef)(null); // 向下兼容
|
|
71
|
+
const domId = (0, react_1.useMemo)(() => utils_1.StringUtil.genKey(), []); // 向下兼容
|
|
71
72
|
const rootRef = (0, react_1.useRef)(null);
|
|
72
73
|
const contextRef = (0, react_1.useRef)(null);
|
|
73
74
|
const selectRef = (0, react_1.useRef)(null);
|
|
@@ -134,9 +135,15 @@ exports.Box = react_1.default.forwardRef((props, ref) => {
|
|
|
134
135
|
// if (props.pagination && props.mode == 'inner') {
|
|
135
136
|
// paginationProps.hideOnSinglePage = true;
|
|
136
137
|
// }
|
|
137
|
-
return react_1.default.createElement(Layout_1.Layout, { className: utils_1.StringUtil.className(className, props.className), style: style, ref: _layoutRef },
|
|
138
|
+
return react_1.default.createElement(Layout_1.Layout, { id: domId, className: utils_1.StringUtil.className(className, props.className), style: style, ref: _layoutRef },
|
|
138
139
|
props.selectBar && (0, _register_1.getSelectBar)(props.selectBar.type) != null && react_1.default.createElement(SelectBar_1.SelectBar, Object.assign({}, props.selectBar, { ref: selectRef, onSelect: (...args) => setState({ selected: args }) })),
|
|
139
140
|
react_1.default.createElement(Layout_1.Layout.Content, { style: { overflow: props.overflowAuto ? 'auto' : 'hidden' }, ref: () => {
|
|
141
|
+
if (_layoutRef.current == null) {
|
|
142
|
+
let layout = document.getElementById(domId);
|
|
143
|
+
if (layout) {
|
|
144
|
+
_layoutRef.current = layout;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
140
147
|
if (_layoutRef.current != null) {
|
|
141
148
|
let el = lodash_1.default.find(_layoutRef.current.children, (item) => lodash_1.default.toLower(item.tagName) == 'main');
|
|
142
149
|
if (el != null)
|
|
@@ -15,6 +15,10 @@ const _SearchBar = props => {
|
|
|
15
15
|
if (utils_1.GLOBAL.CONFIG.SEARCHBAR.REVERSE)
|
|
16
16
|
clazz.push('c-searchbar-reverse');
|
|
17
17
|
if (!lodash_1.default.isArray(props.fields) || props.fields.length == 0) {
|
|
18
|
+
if (lodash_1.default.has(props, 'keyword'))
|
|
19
|
+
return react_1.default.createElement("div", { className: utils_1.StringUtil.className(clazz, props.className) },
|
|
20
|
+
react_1.default.createElement(ByKeyword_1.SearchBarByKeyword, Object.assign({}, props)),
|
|
21
|
+
react_1.default.createElement("div", { className: 'c-searchbar-actions' }, props.children));
|
|
18
22
|
if (!lodash_1.default.has(props, 'children'))
|
|
19
23
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
20
24
|
return react_1.default.createElement("div", { className: utils_1.StringUtil.className(clazz, props.className) },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseTableProps } from './index';
|
|
3
3
|
import type { ApiModel } from '../../hooks/_list';
|
|
4
|
-
import type { ApiOption } from '../../hooks/
|
|
4
|
+
import type { ApiOption } from '../../hooks/useApiBase';
|
|
5
5
|
export type ApiTableProps = BaseTableProps & Pick<ApiOption, 'api' | 'aop' | 'tipDisabled' | 'tipField'>;
|
|
6
6
|
export declare const ApiTable: React.ForwardRefExoticComponent<import("./index").TableDefine & {
|
|
7
7
|
mode?: import("../Box/Box").BoxMode;
|
|
@@ -15,4 +15,4 @@ export declare const ApiTable: React.ForwardRefExoticComponent<import("./index")
|
|
|
15
15
|
searchBar?: Omit<import("../SearchBar").SearchBarProps, "onChange" | "onSearch">;
|
|
16
16
|
default?: import("../..").PlainObject;
|
|
17
17
|
autoLoad?: false;
|
|
18
|
-
} & Pick<ApiOption, "api" | "
|
|
18
|
+
} & Pick<ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & React.RefAttributes<ApiModel>>;
|
|
@@ -15,7 +15,7 @@ export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").
|
|
|
15
15
|
searchBar?: Omit<import("../SearchBar").SearchBarProps, "onChange" | "onSearch">;
|
|
16
16
|
default?: import("../..").PlainObject;
|
|
17
17
|
autoLoad?: false;
|
|
18
|
-
} & Pick<import("../../hooks/
|
|
18
|
+
} & Pick<import("../../hooks/useApiBase").ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & Omit<import("antd/es/modal").ModalProps, "visible" | "onCancel" | "onOk"> & {
|
|
19
19
|
open?: boolean;
|
|
20
20
|
onOk?: (data?: import("../..").PlainObject) => void;
|
|
21
21
|
onCancel?: () => void;
|
|
@@ -137,21 +137,20 @@ const TopTable = props => {
|
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
return react_1.default.createElement(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
return react_1.default.createElement("div", { ref: tableRef, className: 'c-table-top-container' },
|
|
141
|
+
react_1.default.createElement(Table_1.Table, Object.assign({}, tableProps, props, { rowClassName: (record, i) => {
|
|
142
|
+
let clazz = [];
|
|
143
|
+
if (i <= 3)
|
|
144
|
+
clazz.push('c-table-top-' + i);
|
|
145
|
+
if (lodash_1.default.isFunction(props.onRowSelect)) {
|
|
146
|
+
if (selected && selected[rowKey] == record[rowKey]) {
|
|
147
|
+
clazz.push('ant-table-row-selected');
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
clazz.push('c-table-top-cursor');
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return clazz.join(' ');
|
|
155
|
-
}, scroll: scroll, className: utils_1.StringUtil.className(['c-table', 'c-table-top'], props.className), columns: columns, dataSource: list, loading: isQuerying }));
|
|
153
|
+
return clazz.join(' ');
|
|
154
|
+
}, scroll: scroll, className: utils_1.StringUtil.className(['c-table', 'c-table-top'], props.className), columns: columns, dataSource: list, loading: isQuerying })));
|
|
156
155
|
};
|
|
157
156
|
exports.TopTable = TopTable;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { BaseTableProps } from './index';
|
|
2
|
+
import type { BaseTableProps, TableColumn } from './index';
|
|
3
3
|
import type { ListModel } from '../../hooks/_list';
|
|
4
|
+
import type { PlainObject, Key } from '../../basetype';
|
|
5
|
+
export type VTableRef = {
|
|
6
|
+
getSelected: () => [Key[], PlainObject[]];
|
|
7
|
+
getParams: () => PlainObject;
|
|
8
|
+
};
|
|
4
9
|
export declare const getHeightByTagName: (root: HTMLElement, tagName: string) => number;
|
|
5
10
|
/**
|
|
6
11
|
* VTable 支持多种模型,内置模型有 API/DATA/STATIC,也支持模型规范的自定义模型
|
|
@@ -8,4 +13,18 @@ export declare const getHeightByTagName: (root: HTMLElement, tagName: string) =>
|
|
|
8
13
|
export type VTableProps = BaseTableProps & {
|
|
9
14
|
model: ListModel;
|
|
10
15
|
};
|
|
11
|
-
export declare const VTable: React.
|
|
16
|
+
export declare const VTable: React.ForwardRefExoticComponent<import("./index").TableDefine & {
|
|
17
|
+
mode?: import("../Box/Box").BoxMode;
|
|
18
|
+
columns: TableColumn[];
|
|
19
|
+
showIndex?: string | false;
|
|
20
|
+
rowKey?: string;
|
|
21
|
+
select?: true | "DEFAULT" | "QUERY";
|
|
22
|
+
selectDisabled?: (record: any) => boolean;
|
|
23
|
+
actionBar?: React.ReactNode | import("./Components/ActionBar").TableActionButton[];
|
|
24
|
+
selectBar?: import("../Box/SelectBar").SelectBarProps;
|
|
25
|
+
searchBar?: Omit<import("../SearchBar").SearchBarProps, "onChange" | "onSearch">;
|
|
26
|
+
default?: PlainObject;
|
|
27
|
+
autoLoad?: false;
|
|
28
|
+
} & {
|
|
29
|
+
model: ListModel;
|
|
30
|
+
} & React.RefAttributes<VTableRef>>;
|
|
@@ -37,6 +37,7 @@ const Util_1 = require("./Util");
|
|
|
37
37
|
const HighLight_1 = require("../_common/HighLight");
|
|
38
38
|
const hooks_1 = require("../../hooks");
|
|
39
39
|
const Box_1 = require("../Box/Box");
|
|
40
|
+
;
|
|
40
41
|
const getHeightByTagName = (root, tagName) => {
|
|
41
42
|
if (root == null)
|
|
42
43
|
return 0;
|
|
@@ -51,7 +52,7 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
|
|
|
51
52
|
const update = (0, hooks_1.useUpdate)();
|
|
52
53
|
const { state, root, resize } = (0, Box_1.useBox)();
|
|
53
54
|
const [scroll, setScroll] = (0, react_1.useState)(undefined);
|
|
54
|
-
const { rowKey, list, isQuerying, pageNo, pageSize, orderBy, query } = props.model;
|
|
55
|
+
const { rowKey, list, isQuerying, pageNo, pageSize, orderBy, query, total } = props.model;
|
|
55
56
|
let start = (0, react_1.useRef)(0);
|
|
56
57
|
const tableProps = {};
|
|
57
58
|
(0, react_1.useEffect)(() => {
|
|
@@ -123,6 +124,9 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
|
|
|
123
124
|
if (props.autoLoad === false)
|
|
124
125
|
return;
|
|
125
126
|
// @ts-ignore
|
|
127
|
+
if (props.model.mode == 'api-global' && total > 0)
|
|
128
|
+
return;
|
|
129
|
+
// @ts-ignore
|
|
126
130
|
if (lodash_1.default.has(props.selectBar, 'config.mustSelect') && props.selectBar.config['mustSelect'])
|
|
127
131
|
return;
|
|
128
132
|
query(props.default || {});
|
|
@@ -179,8 +183,7 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
|
|
|
179
183
|
},
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
|
-
return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey:
|
|
183
|
-
// scroll={scroll}
|
|
186
|
+
return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey: props.rowKey || rowKey, scroll: scroll,
|
|
184
187
|
// tableLayout="fixed"
|
|
185
188
|
// showSorterTooltip={false}
|
|
186
189
|
size: utils_1.GLOBAL.CONFIG.TABLE.SIZE }, props, tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns, locale: { emptyText: react_1.default.createElement(antd_1.Empty, { style: { marginTop: 24 } }) }, dataSource: list, loading: isQuerying, onChange: (x, y, field) => {
|
|
@@ -192,10 +195,21 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
|
|
|
192
195
|
}
|
|
193
196
|
} }));
|
|
194
197
|
});
|
|
195
|
-
|
|
198
|
+
exports.VTable = react_1.default.forwardRef((props, ref) => {
|
|
196
199
|
const { isQuerying, pageNo, pageSize, total, totalAcc, param, pageTo, query, cost } = props.model;
|
|
197
200
|
// 通过 ref 方式交互,后续扩展方法实现定制联页选择
|
|
198
201
|
const selectedRef = (0, react_1.useRef)({ selected: [[], []], onSelected: () => { }, });
|
|
202
|
+
// 对外提供getSelected方法获取当前选择的数据
|
|
203
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
204
|
+
return {
|
|
205
|
+
getSelected() {
|
|
206
|
+
return selectedRef.current.selected;
|
|
207
|
+
},
|
|
208
|
+
getParams: () => {
|
|
209
|
+
return props.model.param;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
});
|
|
199
213
|
let boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
|
|
200
214
|
if (props.searchBar) {
|
|
201
215
|
boxProps.searchBar = Object.assign(Object.assign({}, props.searchBar), { disabled: isQuerying, onSearch: (data) => {
|
|
@@ -236,5 +250,4 @@ const VTable = (props) => {
|
|
|
236
250
|
}
|
|
237
251
|
return react_1.default.createElement(Box_1.Box, Object.assign({}, boxProps),
|
|
238
252
|
react_1.default.createElement(_VTable, Object.assign({}, lodash_1.default.omit(props, ['className', 'style']), { ref: selectedRef })));
|
|
239
|
-
};
|
|
240
|
-
exports.VTable = VTable;
|
|
253
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TableDefined } from './Components';
|
|
3
|
-
import type { ForwardRefExoticComponent, ExoticComponent } from 'react';
|
|
3
|
+
import type { ForwardRefExoticComponent, ExoticComponent, RefAttributes } from 'react';
|
|
4
4
|
import type { TableProps } from '../_adapt/Table';
|
|
5
5
|
import type { ColumnProps } from 'antd/es/table/interface';
|
|
6
6
|
import type { SearchBarProps } from '../SearchBar/index';
|
|
@@ -66,10 +66,10 @@ export type BaseTableProps = TableDefine & {
|
|
|
66
66
|
autoLoad?: false;
|
|
67
67
|
};
|
|
68
68
|
import type { ApiTableProps } from './ApiTable';
|
|
69
|
-
export type ApiTable = ForwardRefExoticComponent<ApiTableProps &
|
|
69
|
+
export type ApiTable = ForwardRefExoticComponent<ApiTableProps & RefAttributes<ApiModel>> & TableDefined;
|
|
70
70
|
export declare const ApiTable: ApiTable;
|
|
71
|
-
import type { VTableProps } from './VTable';
|
|
72
|
-
export type VTable =
|
|
71
|
+
import type { VTableProps, VTableRef } from './VTable';
|
|
72
|
+
export type VTable = ForwardRefExoticComponent<VTableProps & RefAttributes<VTableRef>> & TableDefined;
|
|
73
73
|
export declare const VTable: VTable;
|
|
74
74
|
import type { STableProps } from './STable';
|
|
75
75
|
export type STable = ExoticComponent<STableProps> & TableDefined;
|
|
@@ -647,7 +647,7 @@ const renderNode = (props, node, position, state, search, context, parentLen) =>
|
|
|
647
647
|
};
|
|
648
648
|
const renderNodes = (props, state, data, position, search, context) => data.map((item, idx) => renderNode(props, item, [...position, idx], state, search, context, data.length));
|
|
649
649
|
const renderRoot = (props, state, context) => {
|
|
650
|
-
const { search, treeData
|
|
650
|
+
const { search, treeData } = state;
|
|
651
651
|
if (search.keyword) {
|
|
652
652
|
if (search.match.size == 0)
|
|
653
653
|
return react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, title: react_1.default.createElement(antd_1.Empty, { description: txt(Const_1.V.TXT_FIND_NULL, search.word) }), selectable: false, className: "c-tree-empty" });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Language } from '../../utils/_Support';
|
|
3
3
|
import type { BaseTreeOpts, SearchResult, TreeNodeData } from '../../utils/TreeUtil';
|
|
4
|
-
import type { AntTreeNodeProps, TreeProps } from 'antd/es/tree';
|
|
4
|
+
import type { AntTreeNodeProps, AntTreeNodeSelectedEvent, TreeProps } from 'antd/es/tree';
|
|
5
5
|
import type { PropsWithChildren, ReactNode } from 'react';
|
|
6
6
|
import type { BaseTreeProps } from './index';
|
|
7
7
|
import type { Key, PlainObject } from '../../basetype';
|
|
@@ -19,11 +19,7 @@ export type BaseTreeState = Required<BaseTreeOpts> & {
|
|
|
19
19
|
field: string;
|
|
20
20
|
}[];
|
|
21
21
|
};
|
|
22
|
-
type OnSelectFunction = (selectedKeys: Key[], info:
|
|
23
|
-
selected?: boolean;
|
|
24
|
-
selectedNodes: any[];
|
|
25
|
-
nativeEvent?: MouseEvent;
|
|
26
|
-
}, tree?: PlainObject[]) => void;
|
|
22
|
+
type OnSelectFunction = (selectedKeys: Key[], info: AntTreeNodeSelectedEvent, tree?: PlainObject[]) => void;
|
|
27
23
|
type BaseTreeContext = {
|
|
28
24
|
treeState: BaseTreeState;
|
|
29
25
|
onSelect: OnSelectFunction;
|
|
@@ -120,7 +120,8 @@ const BaseTree = (props) => {
|
|
|
120
120
|
const setTreeData = (treeData) => setState({ treeData: [...treeData] });
|
|
121
121
|
(0, react_1.useEffect)(() => searchByKeyWord(props.searchValue), [props.searchValue]);
|
|
122
122
|
const onSelect = (0, react_1.useCallback)((selectedKeys, evt, tree) => {
|
|
123
|
-
|
|
123
|
+
if (evt.nativeEvent)
|
|
124
|
+
utils_1.PageUtil.stopEvent(evt.nativeEvent);
|
|
124
125
|
if (props.mustSelect && selectedKeys.length == 0)
|
|
125
126
|
return;
|
|
126
127
|
if (selectedKeys.length == 0) {
|
|
@@ -105,6 +105,7 @@ const _Dtree = (props) => {
|
|
|
105
105
|
onSelect([
|
|
106
106
|
tree[0][treeState.keyField]
|
|
107
107
|
], {
|
|
108
|
+
selected: true,
|
|
108
109
|
selectedNodes: [
|
|
109
110
|
// @ts-ignore
|
|
110
111
|
{ props: { data: { node: tree[0], position: [0] } } }
|
|
@@ -124,7 +125,6 @@ const _Dtree = (props) => {
|
|
|
124
125
|
// 如果根节点只有一个,则自动展开这个根结点
|
|
125
126
|
treeProps.defaultExpandedKeys = [treeState.treeData[0][treeState.keyField]];
|
|
126
127
|
}
|
|
127
|
-
// loadData?: (node: AntTreeNode) => PromiseLike<void>;
|
|
128
128
|
const loadData = (evt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
129
|
const { node, position } = evt.props.data;
|
|
130
130
|
const children = yield props.getChildren(node[treeState.keyField]);
|
|
@@ -134,12 +134,5 @@ const _Dtree = (props) => {
|
|
|
134
134
|
data.children = children;
|
|
135
135
|
setTreeData(tree);
|
|
136
136
|
});
|
|
137
|
-
return react_1.default.createElement(antd_1.Tree, Object.assign({}, treeState.baseProps, treeProps, { className: treeState.className, loadData: loadData,
|
|
138
|
-
// disabled={props.disabled}
|
|
139
|
-
onSelect: (keys, evt) => {
|
|
140
|
-
console.log(keys, evt);
|
|
141
|
-
},
|
|
142
|
-
// onSelect={onSelect}
|
|
143
|
-
// selectedKeys={treeState.selectedKeys}
|
|
144
|
-
selectedKeys: treeState.selectedKeys }), (0, ActionTree_1.renderRoot)(props, treeState, actionContext));
|
|
137
|
+
return react_1.default.createElement(antd_1.Tree, Object.assign({}, treeState.baseProps, treeProps, { className: treeState.className, loadData: loadData, disabled: props.disabled, onSelect: onSelect, selectedKeys: treeState.selectedKeys }), (0, ActionTree_1.renderRoot)(props, treeState, actionContext));
|
|
145
138
|
};
|
|
@@ -59,7 +59,12 @@ const _Ftree = (props) => {
|
|
|
59
59
|
const tree = utils_1.TreeUtil.buildFlatTree(treeState, (0, ActionTree_1.getResponseList)(rootResp));
|
|
60
60
|
setTreeData(tree);
|
|
61
61
|
if (props.mustSelect && tree.length > 0) {
|
|
62
|
-
onSelect([tree[0][treeState.keyField]], {
|
|
62
|
+
onSelect([tree[0][treeState.keyField]], {
|
|
63
|
+
selectedNodes: [
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
{ props: { data: { node: tree[0], position: [0] } } },
|
|
66
|
+
]
|
|
67
|
+
}, tree);
|
|
63
68
|
}
|
|
64
69
|
setInit(true);
|
|
65
70
|
}));
|
|
@@ -56,7 +56,12 @@ const _Stree = (props) => {
|
|
|
56
56
|
}
|
|
57
57
|
setTreeData(tree);
|
|
58
58
|
if (props.mustSelect && tree.length > 0) {
|
|
59
|
-
onSelect([tree[0][treeState.keyField]], {
|
|
59
|
+
onSelect([tree[0][treeState.keyField]], {
|
|
60
|
+
selectedNodes: [
|
|
61
|
+
//@ts-ignore
|
|
62
|
+
{ props: { data: { node: tree[0], position: [0] } } }
|
|
63
|
+
]
|
|
64
|
+
}, tree);
|
|
60
65
|
}
|
|
61
66
|
setInit(true);
|
|
62
67
|
}, [props.treeData]);
|
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { UFromProps } from './index';
|
|
2
|
+
import type { UFromProps, UFormFunctions } from './index';
|
|
3
3
|
import type { FormState } from './FormWrapper';
|
|
4
|
-
import type { PlainObject } from '../../basetype';
|
|
5
|
-
export type UFormFunctions = {
|
|
6
|
-
/**
|
|
7
|
-
* 获取当前表单数据
|
|
8
|
-
*/
|
|
9
|
-
data: () => PlainObject;
|
|
10
|
-
/**
|
|
11
|
-
* 获取当前表单数据
|
|
12
|
-
* 会先进行验证表单有效性,验证不通过则不返回
|
|
13
|
-
*/
|
|
14
|
-
validate: () => Promise<PlainObject>;
|
|
15
|
-
/**
|
|
16
|
-
* 重置表单
|
|
17
|
-
*/
|
|
18
|
-
reset: () => void;
|
|
19
|
-
};
|
|
20
4
|
export declare const initValue: (props: UFromProps & {
|
|
21
5
|
state: FormState;
|
|
22
6
|
}) => {
|
|
@@ -43,13 +43,13 @@ const antd_1 = require("antd");
|
|
|
43
43
|
const Row_1 = require("../_adapt/Row");
|
|
44
44
|
const Col_1 = require("../_adapt/Col");
|
|
45
45
|
const Popconfirm_1 = require("../_adapt/Popconfirm");
|
|
46
|
+
const Popover_1 = require("../_adapt/Popover");
|
|
46
47
|
const Button_1 = require("../_adapt/Button");
|
|
47
48
|
const FormWrapper_1 = require("./FormWrapper");
|
|
48
49
|
const useUpdate_1 = require("../../hooks/useUpdate");
|
|
49
50
|
const Icon_1 = require("../_adapt/Icon");
|
|
50
51
|
const _FormUtils_1 = require("./_FormUtils");
|
|
51
52
|
const _register_1 = require("./_register");
|
|
52
|
-
const Popover_1 = require("../_adapt/Popover");
|
|
53
53
|
const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
54
54
|
const { multipleFields, requireFields, disableFields, hiddenFields, optionFields, } = state;
|
|
55
55
|
if (!lodash_1.default.isArray(field.link) || field.link.length == 0)
|
|
@@ -58,21 +58,25 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
58
58
|
let size = 0;
|
|
59
59
|
let needUpdate = false;
|
|
60
60
|
const pushBus = (targetField, result) => {
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
if (result === null) {
|
|
62
|
+
value[targetField] = undefined;
|
|
63
|
+
}
|
|
64
|
+
else if (lodash_1.default.isPlainObject(result)) {
|
|
65
|
+
const data = result;
|
|
66
|
+
if (lodash_1.default.has(data, 'value'))
|
|
67
|
+
value[targetField] = data.value;
|
|
68
|
+
if (lodash_1.default.has(data, 'required')) {
|
|
65
69
|
if (!requireFields.current.has(targetField)) {
|
|
66
70
|
needUpdate = true;
|
|
67
|
-
requireFields.current.set(targetField,
|
|
71
|
+
requireFields.current.set(targetField, data.required);
|
|
68
72
|
}
|
|
69
|
-
else if (requireFields.current.get(targetField) !=
|
|
73
|
+
else if (requireFields.current.get(targetField) != data.required) {
|
|
70
74
|
needUpdate = true;
|
|
71
|
-
requireFields.current.set(targetField,
|
|
75
|
+
requireFields.current.set(targetField, data.required);
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
|
-
if (lodash_1.default.has(
|
|
75
|
-
if (
|
|
78
|
+
if (lodash_1.default.has(data, 'disabled')) {
|
|
79
|
+
if (data.disabled) {
|
|
76
80
|
if (!disableFields.current.has(targetField)) {
|
|
77
81
|
needUpdate = true;
|
|
78
82
|
disableFields.current.add(targetField);
|
|
@@ -83,8 +87,8 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
83
87
|
disableFields.current.delete(targetField);
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
|
-
if (lodash_1.default.has(
|
|
87
|
-
if (
|
|
90
|
+
if (lodash_1.default.has(data, 'show')) {
|
|
91
|
+
if (data.show) {
|
|
88
92
|
if (hiddenFields.current.has(targetField)) {
|
|
89
93
|
needUpdate = true;
|
|
90
94
|
hiddenFields.current.delete(targetField);
|
|
@@ -95,16 +99,16 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
95
99
|
hiddenFields.current.add(targetField);
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
|
-
if (lodash_1.default.has(
|
|
99
|
-
if (
|
|
102
|
+
if (lodash_1.default.has(data, 'options')) {
|
|
103
|
+
if (data.options === null) {
|
|
100
104
|
if (optionFields.current.has(targetField)) {
|
|
101
105
|
needUpdate = true;
|
|
102
106
|
optionFields.current.delete(targetField);
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
|
-
else if (optionFields.current.get(targetField) !=
|
|
109
|
+
else if (optionFields.current.get(targetField) != data.options) {
|
|
106
110
|
needUpdate = true;
|
|
107
|
-
optionFields.current.set(targetField,
|
|
111
|
+
optionFields.current.set(targetField, data.options);
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
}
|
|
@@ -121,9 +125,10 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
121
125
|
};
|
|
122
126
|
field.link.map(link => {
|
|
123
127
|
const resp = link.call(values, getValue(multipleFields.current, form.getFieldsValue()), extra);
|
|
124
|
-
if (resp === null)
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
if (resp === null) {
|
|
129
|
+
pushBus(link.field, null);
|
|
130
|
+
}
|
|
131
|
+
else if (resp instanceof Promise) {
|
|
127
132
|
resp.then(result => pushBus(link.field, result));
|
|
128
133
|
}
|
|
129
134
|
else {
|
|
@@ -132,15 +137,6 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
132
137
|
});
|
|
133
138
|
return values;
|
|
134
139
|
};
|
|
135
|
-
// const FieldContent = (component: InputComponent, field: UFormField)=>{
|
|
136
|
-
// React.createElement(component.element, {
|
|
137
|
-
// form: this.props.form,
|
|
138
|
-
// field,
|
|
139
|
-
// disabled: this.disableFields.has(field.field),
|
|
140
|
-
// options: (this.reOptions.has(field.field) ? this.reOptions.get(field.field) : undefined)
|
|
141
|
-
// })
|
|
142
|
-
// }
|
|
143
|
-
// export type FormFieldComponent = ComponentType<FormFieldProps>;
|
|
144
140
|
const renderFormField = (state, field, form, update, data) => {
|
|
145
141
|
const input = (0, _register_1.getUFormInput)(field.type || 'text');
|
|
146
142
|
const { labelSpan, inputSpan, colSpan, cols, disableFields, hiddenFields, requireFields, optionFields, } = state;
|
|
@@ -347,11 +343,9 @@ const _FormField = (props) => {
|
|
|
347
343
|
const { form } = props;
|
|
348
344
|
const update = (0, useUpdate_1.useUpdate)();
|
|
349
345
|
(0, react_1.useEffect)(() => {
|
|
350
|
-
// console.log('dfdsaupdate')
|
|
351
346
|
const values = (0, exports.initValue)(props);
|
|
352
347
|
props.initRef.current = values;
|
|
353
|
-
|
|
354
|
-
form.setFieldsValue(props.initRef.current);
|
|
348
|
+
form.setFieldsValue(values);
|
|
355
349
|
props.fields.map(field => {
|
|
356
350
|
if (field == null || field == false)
|
|
357
351
|
return;
|
|
@@ -361,12 +355,9 @@ const _FormField = (props) => {
|
|
|
361
355
|
if (lodash_1.default.isArray(field.link) && field.link.length > 0)
|
|
362
356
|
setTimeout(() => onChangeEvent(props.state, field, form, update, values[field.field]), 2);
|
|
363
357
|
});
|
|
364
|
-
// console.log('google')
|
|
365
358
|
update();
|
|
366
359
|
}, []);
|
|
367
|
-
//
|
|
368
|
-
// return Const.NONE
|
|
369
|
-
// if (props.initRef.current === null) return Const.NONE;
|
|
360
|
+
// if (props.initRef.current === null) return Const.NONE; 1.5 版本必须注释此行
|
|
370
361
|
const data = form.getFieldsValue();
|
|
371
362
|
return props.fields.map(field => {
|
|
372
363
|
if (field == null || field === false)
|
|
@@ -397,7 +388,7 @@ const _FormGroup = (props) => {
|
|
|
397
388
|
});
|
|
398
389
|
update();
|
|
399
390
|
}, []);
|
|
400
|
-
// if (props.initRef.current === null) return Const.NONE;
|
|
391
|
+
// if (props.initRef.current === null) return Const.NONE; 1.5 版本必须注释此行
|
|
401
392
|
const data = form.getFieldsValue();
|
|
402
393
|
return props.fields.map(group => {
|
|
403
394
|
if (group == null || group === false)
|
|
@@ -453,33 +444,10 @@ const _UForm = (0, react_1.forwardRef)((props, ref) => {
|
|
|
453
444
|
checkMultiple(item);
|
|
454
445
|
}
|
|
455
446
|
});
|
|
456
|
-
// initRef.current = initValue({ ...props, state })
|
|
457
|
-
// if (state.isGroup) {
|
|
458
|
-
// props.fields.map(group => {
|
|
459
|
-
// if (group == null || group == false) return;
|
|
460
|
-
// (group as UFormFieldGroup).fields.map(field => {
|
|
461
|
-
// // @ts-ignore
|
|
462
|
-
// if (field == null || field == false) return;
|
|
463
|
-
// if (!_.has(initRef.current, field.field) || initRef.current[field.field] === null || initRef.current[field.field] === undefined) return;
|
|
464
|
-
// // setFieldsValue 要 render 后才能get ,延时执行 link事件
|
|
465
|
-
// // if (_.isArray(field.link) && field.link.length > 0) setTimeout(() => onChangeEvent(state, field, form, update, values[field.field]), 2);
|
|
466
|
-
// })
|
|
467
|
-
// })
|
|
468
|
-
// } else {
|
|
469
|
-
// props.fields.map(field => {
|
|
470
|
-
// if (field == null || field == false) return;
|
|
471
|
-
// if (!_.has(initRef.current, field.field) || initRef.current[field.field] === null || initRef.current[field.field] === undefined) return;
|
|
472
|
-
// // setFieldsValue 要 render 后才能get ,延时执行 link事件
|
|
473
|
-
// // if (_.isArray(field.link) && field.link.length > 0) setTimeout(() => onChangeEvent(props.state, field, form, update, values[field.field]), 2);
|
|
474
|
-
// })
|
|
475
|
-
// }
|
|
476
|
-
// form.setFieldsValue(initRef.current, () => setChecked(true))
|
|
477
447
|
setChecked(true);
|
|
478
448
|
}, []);
|
|
479
449
|
if (!checked)
|
|
480
450
|
return utils_1.Const.NONE;
|
|
481
|
-
// console.log(initRef)
|
|
482
|
-
// console.log('fdsafd')
|
|
483
451
|
return react_1.default.createElement(antd_1.Form
|
|
484
452
|
// defaultValue={initRef.current}
|
|
485
453
|
// initialValues={props.default}
|
|
@@ -13,9 +13,6 @@ const Const_1 = require("../_setup/Const");
|
|
|
13
13
|
const FormWrapper_1 = require("./FormWrapper");
|
|
14
14
|
const FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'hideBorder', 'theme'];
|
|
15
15
|
const UInfoModal = (props) => {
|
|
16
|
-
const [open, afterClose] = (0, Modal_1.useDestoryModal)(props);
|
|
17
|
-
if (!open)
|
|
18
|
-
return utils_1.Const.NONE;
|
|
19
16
|
const param = lodash_1.default.omit(props, FORM_FIELDS);
|
|
20
17
|
if (!lodash_1.default.has(props, 'title') && lodash_1.default.has(props, 'autoTitle')) {
|
|
21
18
|
let name = null;
|
|
@@ -270,6 +270,7 @@ export type UFromAction = ButtonProps & {
|
|
|
270
270
|
/**
|
|
271
271
|
* icon
|
|
272
272
|
*/
|
|
273
|
+
icon?: string;
|
|
273
274
|
/**
|
|
274
275
|
* 1. submit 点击时会触发验证,不通过不回调 onClick
|
|
275
276
|
* 2. button 不会触发验证
|
|
@@ -390,3 +391,18 @@ export type UDescriptionsItemProps = BaseItem & {
|
|
|
390
391
|
*/
|
|
391
392
|
children: React.ReactNode;
|
|
392
393
|
};
|
|
394
|
+
export type UFormFunctions = {
|
|
395
|
+
/**
|
|
396
|
+
* 获取当前表单数据
|
|
397
|
+
*/
|
|
398
|
+
data: () => PlainObject;
|
|
399
|
+
/**
|
|
400
|
+
* 获取当前表单数据
|
|
401
|
+
* 会先进行验证表单有效性,验证不通过则不返回
|
|
402
|
+
*/
|
|
403
|
+
validate: () => Promise<PlainObject>;
|
|
404
|
+
/**
|
|
405
|
+
* 重置表单
|
|
406
|
+
*/
|
|
407
|
+
reset: () => void;
|
|
408
|
+
};
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.UploadFile = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
|
-
// import { Icon } from '../../components/_adapt/Icon';
|
|
10
9
|
const useUpload_1 = require("./useUpload");
|
|
11
10
|
const antd_1 = require("antd");
|
|
12
11
|
const Button_1 = require("../_adapt/Button");
|
|
@@ -28,10 +28,13 @@ const _Button = props => {
|
|
|
28
28
|
icon,
|
|
29
29
|
" ",
|
|
30
30
|
react_1.default.createElement("span", null, utils_1.i18n.txt(props.ik)));
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
if (props.children) {
|
|
32
|
+
return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps),
|
|
33
|
+
icon,
|
|
34
|
+
" ",
|
|
35
|
+
react_1.default.createElement("span", null, props.children));
|
|
36
|
+
}
|
|
37
|
+
return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps), icon);
|
|
35
38
|
}
|
|
36
39
|
if (props.ik)
|
|
37
40
|
return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps), utils_1.i18n.txt(props.ik));
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
1
|
+
import type { FC, ReactNode, PropsWithChildren } from 'react';
|
|
2
|
+
import type { PopoverProps } from './Popover';
|
|
3
|
+
interface PresetsItem {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
colors: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 说明1.5版本仅支持HEX
|
|
9
|
+
*/
|
|
10
|
+
type ColorFormat = 'hex';
|
|
2
11
|
export type ColorPickerProps = {
|
|
12
|
+
allowClear?: boolean;
|
|
13
|
+
arrow?: boolean;
|
|
14
|
+
size?: 'large' | 'middle' | 'small';
|
|
15
|
+
placement?: PopoverProps['placement'];
|
|
3
16
|
value?: string;
|
|
4
17
|
defaultValue?: string;
|
|
5
|
-
|
|
18
|
+
defaultFormat?: ColorFormat;
|
|
19
|
+
format?: ColorFormat;
|
|
6
20
|
disabled?: boolean;
|
|
7
|
-
|
|
21
|
+
disabledAlpha?: boolean;
|
|
22
|
+
destroyTooltipOnHide?: boolean;
|
|
23
|
+
onChange?: (value: any, hex: string) => void;
|
|
24
|
+
presets?: PresetsItem[];
|
|
25
|
+
showText?: boolean;
|
|
8
26
|
};
|
|
9
|
-
export declare const ColorPicker: FC<ColorPickerProps
|
|
27
|
+
export declare const ColorPicker: FC<PropsWithChildren<ColorPickerProps>>;
|
|
28
|
+
export {};
|