vap1 0.1.5 → 0.1.7
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/SearchBar/ByField.js +7 -1
- package/components/SearchBar/ByKeyword.js +52 -10
- package/components/Tables/STable.d.ts +9 -1
- package/components/Tables/STable.js +20 -5
- package/components/Tables/VTable.js +18 -10
- package/components/TreeSelect/DTreeSelect.js +0 -1
- package/components/Trees/ActionTree.js +0 -1
- package/components/Trees/COTree/COButton.d.ts +3 -0
- package/components/Trees/COTree/COButton.js +121 -0
- package/components/Trees/COTree/COSelect.d.ts +46 -0
- package/components/Trees/COTree/COSelect.js +103 -0
- package/components/Trees/COTree/COTree.d.ts +74 -0
- package/components/Trees/COTree/COTree.js +207 -0
- package/components/Trees/COTree/COTreeUtil.d.ts +17 -0
- package/components/Trees/COTree/COTreeUtil.js +190 -0
- package/components/UForm/UForm.js +0 -1
- package/components/UForm/UFormModal.js +1 -1
- package/components/UForm/_FieldType.d.ts +1 -1
- package/components/UForm/_FieldType.js +11 -2
- package/components/UForm/index.d.ts +10 -0
- package/components/_adapt/Drawer.js +33 -5
- package/components/_adapt/Dropdown.d.ts +12 -3
- package/components/_adapt/Dropdown.js +10 -2
- package/components/_adapt/Modal.js +1 -1
- package/components/_adapt/Radio.js +6 -6
- package/components/_common/Upagination.js +4 -4
- package/components/_setup/UForm/UFormCOTree.d.ts +1 -0
- package/components/_setup/UForm/UFormCOTree.js +23 -0
- package/components/_setup/UForm/UFormDate.js +136 -23
- package/components/_setup/UForm/UFormJSONTable.d.ts +1 -0
- package/components/_setup/UForm/UFormJSONTable.js +157 -0
- package/components/_setup/UForm/UFormSelect.js +19 -0
- package/components/_setup/index.d.ts +1 -0
- package/components/_setup/index.js +1 -0
- package/hooks/_list.js +2 -1
- package/hooks/useArray.d.ts +2 -3
- package/hooks/useArray.js +34 -67
- package/package.json +1 -1
- package/utils/ArrayUtil.js +8 -1
- package/utils/Global.d.ts +4 -1
- package/utils/Global.js +1 -0
- package/utils/index.d.ts +32 -1
- package/widget/index.d.ts +0 -4
|
@@ -55,7 +55,13 @@ const SearchBarByField = (props) => {
|
|
|
55
55
|
// })
|
|
56
56
|
// return result;
|
|
57
57
|
// }
|
|
58
|
-
const clear = () => setData({
|
|
58
|
+
const clear = () => setData(prev => {
|
|
59
|
+
let data = {};
|
|
60
|
+
lodash_1.default.keys(prev).map(item => {
|
|
61
|
+
data[item] = null;
|
|
62
|
+
});
|
|
63
|
+
return data;
|
|
64
|
+
});
|
|
59
65
|
const search = () => props.onSearch(data);
|
|
60
66
|
const setIsExpand = (isExpand) => {
|
|
61
67
|
if (isAwaysExpand)
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.SearchBarByKeyword = void 0;
|
|
7
|
-
const react_1 =
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
8
28
|
const antd_1 = require("antd");
|
|
9
29
|
const Popover_1 = require("../_adapt/Popover");
|
|
10
30
|
const ByField_1 = require("./ByField");
|
|
11
31
|
const utils_1 = require("../../utils");
|
|
12
32
|
const Const_1 = require("../_setup/Const");
|
|
13
33
|
const SearchBarByKeyword = (props) => {
|
|
34
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
35
|
+
const spanRef = (0, react_1.useRef)(null);
|
|
14
36
|
const inputProps = {
|
|
15
37
|
className: "c-searchbar-keyword",
|
|
16
38
|
placeholder: utils_1.i18n.txt(Const_1.V.INPUT_SEARCH_KEYWORD),
|
|
@@ -22,13 +44,33 @@ const SearchBarByKeyword = (props) => {
|
|
|
22
44
|
}
|
|
23
45
|
}
|
|
24
46
|
if (props.fields && props.fields.length) {
|
|
25
|
-
inputProps.suffix = react_1.default.createElement(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
47
|
+
inputProps.suffix = react_1.default.createElement(react_1.default.Fragment, null,
|
|
48
|
+
react_1.default.createElement("span", { ref: spanRef, onClick: () => setOpen(true), style: { pointerEvents: props.disabled ? 'none' : 'unset' }, className: 'vicon vicon-menu', title: utils_1.i18n.txt(Const_1.V.INPUT_SEARCH_ADVANCE) }, "\u00A0"),
|
|
49
|
+
react_1.default.createElement(Popover_1.Popover, { open: open,
|
|
50
|
+
// open={true}
|
|
51
|
+
onOpenChange: setOpen, trigger: "click", placement: "bottom", content: react_1.default.createElement(react_1.default.Fragment, null,
|
|
52
|
+
react_1.default.createElement("h3", null, utils_1.i18n.txt(Const_1.V.INPUT_SEARCH_ADVANCE)),
|
|
53
|
+
react_1.default.createElement("div", { className: 'c-searchbar' },
|
|
54
|
+
react_1.default.createElement(ByField_1.SearchBarByField, Object.assign({}, props, { onSearch: (param) => {
|
|
55
|
+
props.onSearch(param);
|
|
56
|
+
setOpen(false);
|
|
57
|
+
},
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
__innerExpand: true, __innerOutside: true })))),
|
|
60
|
+
// autoAdjustOverflow={false}
|
|
61
|
+
overlayClassName: 'c-searchbar-keyword-more', getPopupContainer: () => {
|
|
62
|
+
const maskEls = document.getElementsByClassName('ant-modal-mask');
|
|
63
|
+
let hasMask = false;
|
|
64
|
+
for (let i = 0, _i = maskEls.length; i < _i; i++) {
|
|
65
|
+
if (!maskEls.item(i).classList.contains('ant-modal-mask-hidden')) {
|
|
66
|
+
hasMask = true;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!hasMask)
|
|
71
|
+
return document.getElementById('vap-app-content');
|
|
72
|
+
return spanRef.current.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
|
|
73
|
+
} }));
|
|
32
74
|
}
|
|
33
75
|
return react_1.default.createElement(antd_1.Input.Search, Object.assign({}, inputProps, { onSearch: keyword => props.onSearch({ keyword_: keyword }), enterButton: utils_1.i18n.txt(Const_1.V.BTN_SEARCH) }));
|
|
34
76
|
};
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ListInit } from '../../hooks/_list';
|
|
3
3
|
import type { BaseTableProps } from './index';
|
|
4
|
-
export type STableProps = BaseTableProps & ListInit
|
|
4
|
+
export type STableProps = BaseTableProps & ListInit & {
|
|
5
|
+
/**
|
|
6
|
+
* ˵�� pageSize : Ĭ��Ϊ false �� ����ҳ��
|
|
7
|
+
*
|
|
8
|
+
* Ϊ true ʱ����ϵͳĬ�Ϸ�ҳ�����з�ҳ
|
|
9
|
+
* Ϊ ���� ʱ�� ��ָ���ķ�ҳ��С���з�ҳ
|
|
10
|
+
*/
|
|
11
|
+
pageSize?: true | number;
|
|
12
|
+
};
|
|
5
13
|
export declare const STable: (props: STableProps) => React.JSX.Element;
|
|
@@ -22,16 +22,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.STable = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
27
31
|
const react_1 = __importStar(require("react"));
|
|
28
32
|
const useArray_1 = require("../../hooks/useArray");
|
|
29
33
|
const VTable_1 = require("./VTable");
|
|
34
|
+
const utils_1 = require("../../utils");
|
|
30
35
|
const STable = (props) => {
|
|
31
|
-
const
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
const arrOption = lodash_1.default.pick(props, ['list', 'rowKey', 'list', 'api']);
|
|
37
|
+
if (props.pageSize) {
|
|
38
|
+
if (lodash_1.default.isNumber(props.pageSize)) {
|
|
39
|
+
arrOption.pageSize = props.pageSize;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
arrOption.pageSize = utils_1.GLOBAL.CONFIG.PAGINATION.SIZE_DEFAULT;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
arrOption.pageSize = 0;
|
|
47
|
+
}
|
|
48
|
+
const model = (0, useArray_1.useArray)(arrOption);
|
|
49
|
+
(0, react_1.useEffect)(() => { model.setList(props.list); }, [props.list]);
|
|
50
|
+
return react_1.default.createElement(VTable_1.VTable, Object.assign({}, props, { pagination: arrOption.pageSize == 0 ? false : { hideOnSinglePage: true }, model: model }));
|
|
36
51
|
};
|
|
37
52
|
exports.STable = STable;
|
|
@@ -65,7 +65,12 @@ const _VTable = (0, react_1.forwardRef)((props, ref) => {
|
|
|
65
65
|
}
|
|
66
66
|
}, [state.selected]);
|
|
67
67
|
// 更新页数
|
|
68
|
-
(0, react_1.
|
|
68
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
69
|
+
start.current = pageSize * (pageNo - 1);
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
if (props.model.mode == 'static')
|
|
72
|
+
update();
|
|
73
|
+
}, [pageSize, pageNo]);
|
|
69
74
|
// 计算 clolum
|
|
70
75
|
const columns = (0, react_1.useMemo)(() => {
|
|
71
76
|
let cols = [];
|
|
@@ -186,7 +191,7 @@ const _VTable = (0, react_1.forwardRef)((props, ref) => {
|
|
|
186
191
|
// scroll={scroll}
|
|
187
192
|
// tableLayout="fixed"
|
|
188
193
|
// showSorterTooltip={false}
|
|
189
|
-
size: utils_1.GLOBAL.CONFIG.TABLE.SIZE }, props, tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns,
|
|
194
|
+
size: utils_1.GLOBAL.CONFIG.TABLE.SIZE, locale: { emptyText: react_1.default.createElement(antd_1.Empty, { style: { marginTop: 24 } }) } }, props, tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns, dataSource: list, loading: isQuerying, onChange: (x, y, field) => {
|
|
190
195
|
if (field.column) {
|
|
191
196
|
orderBy(field.field, field.order == 'ascend' ? 'asc' : 'desc');
|
|
192
197
|
}
|
|
@@ -196,18 +201,21 @@ const _VTable = (0, react_1.forwardRef)((props, ref) => {
|
|
|
196
201
|
} }));
|
|
197
202
|
});
|
|
198
203
|
exports.VTable = (0, react_1.forwardRef)((props, ref) => {
|
|
204
|
+
var _a;
|
|
199
205
|
const { isQuerying, pageNo, pageSize, total, totalAcc, param, pageTo, query, cost } = props.model;
|
|
200
206
|
// 通过 ref 方式交互,后续扩展方法实现定制联页选择
|
|
201
207
|
const selectedRef = (0, react_1.useRef)({ selected: [[], []], onSelected: () => { }, });
|
|
202
208
|
// 对外提供getSelected方法获取当前选择的数据
|
|
203
|
-
(0, react_1.useImperativeHandle)(ref, () =>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
210
|
+
return {
|
|
211
|
+
getSelected() {
|
|
212
|
+
return selectedRef.current.selected;
|
|
213
|
+
},
|
|
214
|
+
getParams: () => {
|
|
215
|
+
return props.model.param;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}, [(_a = props.model) === null || _a === void 0 ? void 0 : _a.param]);
|
|
211
219
|
let boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
|
|
212
220
|
if (props.searchBar) {
|
|
213
221
|
boxProps.searchBar = Object.assign(Object.assign({}, props.searchBar), { disabled: isQuerying, onSearch: (data) => {
|
|
@@ -49,7 +49,6 @@ const _DTreeSelect = (props) => {
|
|
|
49
49
|
const { node } = dataNode.data;
|
|
50
50
|
const API = props.childApi + node[treeState.keyField];
|
|
51
51
|
const children = yield (0, BaseTreeSelect_1.getData)(API, notCache);
|
|
52
|
-
console.log('dataNode', dataNode);
|
|
53
52
|
const pathArr = dataNode.pos.split('-');
|
|
54
53
|
pathArr.splice(0, 1);
|
|
55
54
|
let nodePath = pathArr.map(i => `[${i}]`).join('.children');
|
|
@@ -500,7 +500,6 @@ const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
|
|
|
500
500
|
antd_1.message.success(txt(Const_1.V.TREE_SORT_SUCCESS));
|
|
501
501
|
});
|
|
502
502
|
const ADD_TITLE = () => {
|
|
503
|
-
// console.log(modals.modalState)
|
|
504
503
|
const { pos, node } = modals.modalState.extra || {};
|
|
505
504
|
if (!action.canSort) {
|
|
506
505
|
if (pos == INSER_POS.INNER) {
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.COButton = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
+
const index_1 = require("../../../index");
|
|
33
|
+
const COTree_1 = require("./COTree");
|
|
34
|
+
const utils_1 = require("../../../utils");
|
|
35
|
+
const COTreeUtil_1 = require("./COTreeUtil");
|
|
36
|
+
const COSelect_1 = require("./COSelect");
|
|
37
|
+
const COButton = props => {
|
|
38
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
39
|
+
const orgCodeRender = (0, react_1.useMemo)(() => utils_1.Renders.ApiPostRender({
|
|
40
|
+
api: props.api || utils_1.GLOBAL.CONFIG.BASIC.ORG_API,
|
|
41
|
+
nameField: props.titleField || utils_1.GLOBAL.CONFIG.BASIC.ORG_FIELDS[1],
|
|
42
|
+
valueFiled: props.keyField || utils_1.GLOBAL.CONFIG.BASIC.ORG_FIELDS[0],
|
|
43
|
+
render: (info) => {
|
|
44
|
+
if (info.label)
|
|
45
|
+
return react_1.default.createElement("span", { title: info.label }, info.label);
|
|
46
|
+
return react_1.default.createElement("span", { title: info.value }, info.value);
|
|
47
|
+
}
|
|
48
|
+
}), []);
|
|
49
|
+
const convert = (0, react_1.useMemo)(() => {
|
|
50
|
+
if (props.dataType)
|
|
51
|
+
return props.dataType;
|
|
52
|
+
if (lodash_1.default.has(props, 'value')) {
|
|
53
|
+
if (lodash_1.default.isString(props.value))
|
|
54
|
+
return 'string';
|
|
55
|
+
if (lodash_1.default.isArray(props.value))
|
|
56
|
+
return 'array';
|
|
57
|
+
if (lodash_1.default.isPlainObject(props.value))
|
|
58
|
+
return 'object';
|
|
59
|
+
}
|
|
60
|
+
return 'string';
|
|
61
|
+
}, [props.dataType]);
|
|
62
|
+
const value = (0, react_1.useMemo)(() => {
|
|
63
|
+
switch (convert) {
|
|
64
|
+
case 'array':
|
|
65
|
+
return (props.value || []);
|
|
66
|
+
case 'object':
|
|
67
|
+
return (0, COTreeUtil_1.convertFormObject)(props.value);
|
|
68
|
+
default:
|
|
69
|
+
return (0, COTreeUtil_1.convertFormString)(props.value);
|
|
70
|
+
}
|
|
71
|
+
}, [props.value, convert]);
|
|
72
|
+
const buttonText = (0, react_1.useMemo)(() => {
|
|
73
|
+
if (value == null || value.length == 0) {
|
|
74
|
+
return '点击选择机构';
|
|
75
|
+
}
|
|
76
|
+
if (value.length == 1) {
|
|
77
|
+
return orgCodeRender(value[0].key);
|
|
78
|
+
}
|
|
79
|
+
return react_1.default.createElement("span", null,
|
|
80
|
+
orgCodeRender(value[0].key),
|
|
81
|
+
" \u7B49 ",
|
|
82
|
+
react_1.default.createElement("b", null, value.length),
|
|
83
|
+
"\u4E2A\u673A\u6784");
|
|
84
|
+
}, [value]);
|
|
85
|
+
const [tempValue, setTempValue] = (0, react_1.useState)(value);
|
|
86
|
+
// tagRender={() => {
|
|
87
|
+
//
|
|
88
|
+
// return orgCodeRender(selectValue[0].key) as any;
|
|
89
|
+
// }
|
|
90
|
+
// }}
|
|
91
|
+
const onOk = () => {
|
|
92
|
+
setOpen(false);
|
|
93
|
+
switch (convert) {
|
|
94
|
+
case 'array':
|
|
95
|
+
props.onChange(tempValue);
|
|
96
|
+
return;
|
|
97
|
+
case 'object':
|
|
98
|
+
props.onChange((0, COTreeUtil_1.invertToObject)(tempValue));
|
|
99
|
+
return;
|
|
100
|
+
default:
|
|
101
|
+
props.onChange((0, COTreeUtil_1.invertToString)(tempValue));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return react_1.default.createElement(index_1.Button.Group, null,
|
|
106
|
+
react_1.default.createElement(index_1.Button, { disabled: props.disabled, onClick: () => setOpen(true) }, buttonText),
|
|
107
|
+
value.length > 0 && react_1.default.createElement(index_1.Popover, { style: { width: 480 }, overlayClassName: 'co-button-content', content: react_1.default.createElement(COSelect_1.SelectedTable, Object.assign({}, props, { value: value })) },
|
|
108
|
+
react_1.default.createElement(index_1.Button, { icon: "unordered-list", type: "primary", style: { paddingRight: 0, paddingLeft: 4 } })),
|
|
109
|
+
react_1.default.createElement(index_1.Modal, { open: open, title: "\u8BF7\u9009\u62E9\u673A\u6784", bodyStyle: { maxHeight: 540, overflow: 'auto' }, width: 720, onCancel: () => setOpen(false), onOk: onOk },
|
|
110
|
+
react_1.default.createElement(index_1.Alert, { message: react_1.default.createElement(react_1.default.Fragment, null,
|
|
111
|
+
"\u9009\u4E2D\u72B6\u6001\u8BF4\u660E \uFF1A ",
|
|
112
|
+
(0, COTreeUtil_1.flagRender)(0, ' :'),
|
|
113
|
+
" ",
|
|
114
|
+
react_1.default.createElement("span", { style: { color: 'rgba(0,0,0,0.2)', marginLeft: 6, marginRight: 6 } }, "|"),
|
|
115
|
+
(0, COTreeUtil_1.flagRender)(1, ' :'),
|
|
116
|
+
" ",
|
|
117
|
+
react_1.default.createElement("span", { style: { color: 'rgba(0,0,0,0.2)', marginLeft: 6, marginRight: 6 } }, "|"),
|
|
118
|
+
(0, COTreeUtil_1.flagRender)(2, ' :')), type: "info", style: { margin: '12px 12px 0 12px' } }),
|
|
119
|
+
react_1.default.createElement(COTree_1.COTree, Object.assign({}, props, { value: tempValue, onChange: values => setTempValue(values), selectTip: true }))));
|
|
120
|
+
};
|
|
121
|
+
exports.COButton = COButton;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { COTreeProps, COTreeValueItem, FLAG } from './COTree';
|
|
3
|
+
import type { FieldDataType } from '../../UForm/index';
|
|
4
|
+
/**
|
|
5
|
+
* 说明 ,CEMS 机构存储,支持3种格式
|
|
6
|
+
* COTreeValueItem[] : 数组模式 如 [{key:'xxx',flag:1},{key:'yyy',flag:0},{key:'zzz',flag:2} ]
|
|
7
|
+
* string : 以 ',',':'分隔,如 "xxx:1,yyy:0,zzz:2"
|
|
8
|
+
* object : 以 key:Flag 的对象,如 {xxx:1,yyy:0,zzz:2}
|
|
9
|
+
*/
|
|
10
|
+
type SelectedValue = COTreeValueItem[] | string | Record<string, FLAG>;
|
|
11
|
+
export type COSelectProps = Omit<COTreeProps, 'onChange' | 'value'> & {
|
|
12
|
+
/**
|
|
13
|
+
* 数据格式,判定方式:
|
|
14
|
+
* 1. 如果指定,则已指定的为准
|
|
15
|
+
* 2. 如果没有指定,则取传入的 value 对象,根据 value 的类型给值 (字串,数组,对象)
|
|
16
|
+
* 3. 如果没有传入 value 对象,则使用 'array'
|
|
17
|
+
*/
|
|
18
|
+
dataType?: FieldDataType;
|
|
19
|
+
/**
|
|
20
|
+
* 值,强行控制
|
|
21
|
+
*/
|
|
22
|
+
value?: SelectedValue;
|
|
23
|
+
/**
|
|
24
|
+
* 选中状态改变时
|
|
25
|
+
*/
|
|
26
|
+
onChange: (value: SelectedValue) => void;
|
|
27
|
+
/**
|
|
28
|
+
* 默认提示
|
|
29
|
+
*/
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 是否支持清空
|
|
33
|
+
*/
|
|
34
|
+
allowClear?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 禁用
|
|
37
|
+
*/
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 宽度
|
|
41
|
+
*/
|
|
42
|
+
width?: number;
|
|
43
|
+
};
|
|
44
|
+
export declare const SelectedTable: FC<COSelectProps>;
|
|
45
|
+
export declare const COSelect: FC<COSelectProps>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.COSelect = exports.SelectedTable = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
+
const index_1 = require("../../../index");
|
|
33
|
+
const Tables_1 = require("../../Tables");
|
|
34
|
+
const COTree_1 = require("./COTree");
|
|
35
|
+
const utils_1 = require("../../../utils");
|
|
36
|
+
const COTreeUtil_1 = require("./COTreeUtil");
|
|
37
|
+
const SelectedTable = props => {
|
|
38
|
+
const orgCodeRender = (0, react_1.useMemo)(() => utils_1.Renders.ApiPostRender({
|
|
39
|
+
api: props.api || utils_1.GLOBAL.CONFIG.BASIC.ORG_API,
|
|
40
|
+
nameField: props.titleField || utils_1.GLOBAL.CONFIG.BASIC.ORG_FIELDS[1],
|
|
41
|
+
valueFiled: props.keyField || utils_1.GLOBAL.CONFIG.BASIC.ORG_FIELDS[0],
|
|
42
|
+
render: (info) => {
|
|
43
|
+
if (info.label)
|
|
44
|
+
return react_1.default.createElement("span", { title: info.label }, info.label);
|
|
45
|
+
return react_1.default.createElement("span", { title: info.value }, info.value);
|
|
46
|
+
}
|
|
47
|
+
}), []);
|
|
48
|
+
return react_1.default.createElement(Tables_1.STable, { style: { width: 460 }, list: props.value || [], columns: [
|
|
49
|
+
{ dataIndex: 'key', title: '机构名称', render: orgCodeRender },
|
|
50
|
+
{ dataIndex: 'flag', title: '状态', render: (flag) => (0, COTreeUtil_1.flagRender)(flag), width: 100 },
|
|
51
|
+
], pagination: false });
|
|
52
|
+
};
|
|
53
|
+
exports.SelectedTable = SelectedTable;
|
|
54
|
+
const COSelect = props => {
|
|
55
|
+
const convert = (0, react_1.useMemo)(() => {
|
|
56
|
+
if (props.dataType)
|
|
57
|
+
return props.dataType;
|
|
58
|
+
if (lodash_1.default.has(props, 'value')) {
|
|
59
|
+
if (lodash_1.default.isString(props.value))
|
|
60
|
+
return 'string';
|
|
61
|
+
if (lodash_1.default.isArray(props.value))
|
|
62
|
+
return 'array';
|
|
63
|
+
if (lodash_1.default.isPlainObject(props.value))
|
|
64
|
+
return 'object';
|
|
65
|
+
}
|
|
66
|
+
return 'string';
|
|
67
|
+
}, [props.dataType]);
|
|
68
|
+
const value = (0, react_1.useMemo)(() => {
|
|
69
|
+
switch (convert) {
|
|
70
|
+
case 'array':
|
|
71
|
+
return (props.value || []);
|
|
72
|
+
case 'object':
|
|
73
|
+
return (0, COTreeUtil_1.convertFormObject)(props.value);
|
|
74
|
+
default:
|
|
75
|
+
return (0, COTreeUtil_1.convertFormString)(props.value);
|
|
76
|
+
}
|
|
77
|
+
}, [props.value, convert]);
|
|
78
|
+
const selectValue = (0, react_1.useMemo)(() => {
|
|
79
|
+
return (value || []).filter(item => item.flag != 1);
|
|
80
|
+
}, [value]);
|
|
81
|
+
const onChange = (0, react_1.useCallback)((value) => {
|
|
82
|
+
switch (convert) {
|
|
83
|
+
case 'array':
|
|
84
|
+
props.onChange(value);
|
|
85
|
+
return;
|
|
86
|
+
case 'object':
|
|
87
|
+
props.onChange((0, COTreeUtil_1.invertToObject)(value));
|
|
88
|
+
return;
|
|
89
|
+
default:
|
|
90
|
+
props.onChange((0, COTreeUtil_1.invertToString)(value));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}, [convert]);
|
|
94
|
+
return react_1.default.createElement(index_1.Input.Group, { compact: true, style: { width: props.width || '100%', display: 'flex' } },
|
|
95
|
+
react_1.default.createElement(index_1.Select, { maxTagCount: 1, mode: "tags", disabled: props.disabled, maxTagPlaceholder: react_1.default.createElement(react_1.default.Fragment, null), showSearch: false, className: 'co-select', allowClear: props.allowClear,
|
|
96
|
+
// onClear={() => props.onChange([])}
|
|
97
|
+
placeholder: props.placeholder || '请选择机构', style: { flexGrow: 1 }, showAction: ["click"], options: [], labelInValue: true, value: selectValue, dropdownStyle: { width: props.width || '100%', maxHeight: 360, overflow: 'auto' }, dropdownRender: () => react_1.default.createElement(COTree_1.COTree, Object.assign({}, props, { value: value, onChange: onChange })), getPopupContainer: (evt) => {
|
|
98
|
+
return evt.parentElement.parentElement;
|
|
99
|
+
} }),
|
|
100
|
+
react_1.default.createElement(index_1.Popover, { style: { width: 480 }, content: react_1.default.createElement(exports.SelectedTable, Object.assign({}, props, { value: value })) },
|
|
101
|
+
react_1.default.createElement(index_1.Button, { disabled: value.length == 0, type: "primary" }, "\u67E5\u770B\u5DF2\u9009")));
|
|
102
|
+
};
|
|
103
|
+
exports.COSelect = COSelect;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { FC, Key } from 'react';
|
|
2
|
+
import type { BaseTreeOpts } from '../../../utils/TreeUtil';
|
|
3
|
+
import type { PlainObject } from '../../../basetype';
|
|
4
|
+
/**
|
|
5
|
+
* 选中状态,
|
|
6
|
+
* 0 = 全选当前及子级
|
|
7
|
+
* 1 = 只选其子级,排除当前节点
|
|
8
|
+
* 2 = 仅选当前,可自选子级
|
|
9
|
+
*/
|
|
10
|
+
export type FLAG = 0 | 1 | 2;
|
|
11
|
+
/**
|
|
12
|
+
* 选择记录
|
|
13
|
+
*/
|
|
14
|
+
export type COTreeValueItem = {
|
|
15
|
+
/**
|
|
16
|
+
* 机构编码
|
|
17
|
+
*/
|
|
18
|
+
key: string;
|
|
19
|
+
/**
|
|
20
|
+
* 选中状态
|
|
21
|
+
*/
|
|
22
|
+
flag: FLAG;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* COTree = CEMS ORG Tree
|
|
26
|
+
* CEMS 以下的应用,以及使用CEMS机构策略的模块可以使用
|
|
27
|
+
*/
|
|
28
|
+
export type COTreeProps = BaseTreeOpts & {
|
|
29
|
+
/**
|
|
30
|
+
* 需要先行转换
|
|
31
|
+
*/
|
|
32
|
+
value?: COTreeValueItem[];
|
|
33
|
+
/**
|
|
34
|
+
* 选中状态改变时
|
|
35
|
+
*/
|
|
36
|
+
onChange: (value: COTreeValueItem[]) => void;
|
|
37
|
+
/**
|
|
38
|
+
* 用于查询
|
|
39
|
+
*/
|
|
40
|
+
api?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 根节点API 与rootCode 二选一
|
|
43
|
+
*/
|
|
44
|
+
rootApi?: string;
|
|
45
|
+
/**
|
|
46
|
+
* 是否存在子节点,如果有些属性,则根据此值不必多点一次加号
|
|
47
|
+
*/
|
|
48
|
+
checkField?: string;
|
|
49
|
+
/**
|
|
50
|
+
* 展开子节点:
|
|
51
|
+
*
|
|
52
|
+
* 方式一:传一个 api 接口地址,必须返回 VData<Array<Object>> 格式
|
|
53
|
+
*
|
|
54
|
+
* 方式二:传一个方法 ,接收一个父节点参数,必须返回 Promise<TreeNodeData[]> (不要返回 children, 仅返回一级)
|
|
55
|
+
*/
|
|
56
|
+
childApi?: string | ((parentId: Key) => Promise<PlainObject[]>);
|
|
57
|
+
/**
|
|
58
|
+
* 禁用选择方法
|
|
59
|
+
*/
|
|
60
|
+
disableNode?: (data: any) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 名称字段
|
|
63
|
+
*/
|
|
64
|
+
titleField?: string;
|
|
65
|
+
/**
|
|
66
|
+
* 本标题后面添加状态
|
|
67
|
+
*/
|
|
68
|
+
selectTip?: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type TreeContext = Map<string, {
|
|
71
|
+
parent: string;
|
|
72
|
+
children?: string[];
|
|
73
|
+
}>;
|
|
74
|
+
export declare const COTree: FC<COTreeProps>;
|