fan-standard-comp 3.1.9 → 3.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/Readme.md +35 -0
- package/dist/fan-standard-comp.umd.js +15 -10
- package/es/ButtonGroup/ButtonList.js +0 -3
- package/es/ButtonGroup/ButtonMenu.js +0 -3
- package/es/ButtonGroup/PopConfirmTitle.js +5 -15
- package/es/ButtonGroup/index.d.ts +2 -0
- package/es/ButtonGroup/index.js +223 -193
- package/es/ButtonGroup/style/index.less +1 -1
- package/es/DragContent/DragBar.js +2 -6
- package/es/DragContent/index.js +44 -75
- package/es/FormComp/ChunkUploader/api.js +6 -10
- package/es/FormComp/ChunkUploader/index.js +105 -171
- package/es/FormComp/ChunkUploader/lib.js +4 -17
- package/es/FormComp/ChunkUploader/upload-queue.class.js +10 -45
- package/es/FormComp/ChunkUploader/worker.js +0 -3
- package/es/FormComp/EditButton/index.js +24 -49
- package/es/FormComp/FieldComponent/ReUpload.js +18 -38
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +37 -75
- package/es/FormComp/FieldComponent/TitleNode.js +1 -3
- package/es/FormComp/FieldComponent/index.js +38 -74
- package/es/FormComp/FieldComponent/setReadonlyValues.js +34 -63
- package/es/FormComp/FieldComponent/style/index.less +6 -0
- package/es/FormComp/RenderItemGroup/index.js +46 -74
- package/es/FormComp/Uploader/index.js +36 -77
- package/es/FormComp/Uploader/util.js +0 -6
- package/es/FormComp/VarTemplate/index.js +58 -96
- package/es/NavLeafScroll/index.js +172 -154
- package/es/NavLeafScroll/style/index.less +33 -1
- package/es/RefactorTree/index.js +36 -53
- package/es/RefactorTree/indexTreeNode.js +35 -68
- package/es/RefactorTree/util.js +9 -43
- package/es/SpecIcon/fonts/iconfont.js +7 -12
- package/es/SpecIcon/index.js +16 -25
- package/es/SplitterLayout/Pane.js +2 -5
- package/es/SplitterLayout/index.js +20 -70
- package/es/StandardContent/SplitterLayout/Pane.js +6 -10
- package/es/StandardContent/SplitterLayout/index.js +12 -63
- package/es/StandardContent/SubfieldContent.js +12 -14
- package/es/StandardContent/WrapperContent.js +8 -10
- package/es/StandardDragModal/ChangeStandardModal.d.ts +44 -0
- package/es/StandardDragModal/ChangeStandardModal.js +493 -0
- package/es/StandardDragModal/DraggableModal.d.ts +7 -0
- package/es/StandardDragModal/DraggableModal.js +31 -0
- package/es/StandardDragModal/DraggableModalContext.d.ts +9 -0
- package/es/StandardDragModal/DraggableModalContext.js +5 -0
- package/es/StandardDragModal/DraggableModalInner.d.ts +16 -0
- package/es/StandardDragModal/DraggableModalInner.js +114 -0
- package/es/StandardDragModal/DraggableModalProvider.d.ts +4 -0
- package/es/StandardDragModal/DraggableModalProvider.js +40 -0
- package/es/StandardDragModal/Modal.d.ts +11 -0
- package/es/StandardDragModal/Modal.js +24 -0
- package/es/StandardDragModal/ResizeHandle.d.ts +2 -0
- package/es/StandardDragModal/ResizeHandle.js +8 -0
- package/es/StandardDragModal/clamp.d.ts +1 -0
- package/es/StandardDragModal/clamp.js +3 -0
- package/es/StandardDragModal/draggableModalReducer.d.ts +66 -0
- package/es/StandardDragModal/draggableModalReducer.js +157 -0
- package/es/StandardDragModal/getWindowSize.d.ts +4 -0
- package/es/StandardDragModal/getWindowSize.js +6 -0
- package/es/StandardDragModal/index.d.ts +3 -11
- package/es/StandardDragModal/index.js +3 -30
- package/es/StandardDragModal/index.less +65 -0
- package/es/StandardDragModal/useDrag.d.ts +5 -0
- package/es/StandardDragModal/useDrag.js +66 -0
- package/es/StandardDragModal/usePrevious.d.ts +1 -0
- package/es/StandardDragModal/usePrevious.js +8 -0
- package/es/StandardDragModal/useResize.d.ts +7 -0
- package/es/StandardDragModal/useResize.js +74 -0
- package/es/StandardFilter/index.d.ts +1 -0
- package/es/StandardFilter/index.js +32 -70
- package/es/StandardForm/ActionList.js +5 -7
- package/es/StandardForm/StepForm.js +50 -71
- package/es/StandardForm/TabForm.js +58 -70
- package/es/StandardForm/index.js +37 -56
- package/es/StandardModal/UpdateFormRef.js +1 -4
- package/es/StandardModal/index.d.ts +0 -1
- package/es/StandardModal/index.js +115 -159
- package/es/StandardPanel/index.js +19 -35
- package/es/StandardTable/index.js +20 -30
- package/es/components/IconNode/index.js +0 -4
- package/es/index.d.ts +1 -0
- package/es/index.js +15 -14
- package/es/utils/ValueFormat.js +0 -9
- package/es/utils/dictSelectUtil.js +153 -0
- package/es/utils/filterPermission.js +16 -34
- package/es/utils/getParentNodes.js +24 -47
- package/es/utils/index.js +2 -1
- package/lib/ButtonGroup/ButtonList.js +1 -13
- package/lib/ButtonGroup/ButtonMenu.js +1 -8
- package/lib/ButtonGroup/PopConfirmTitle.js +3 -16
- package/lib/ButtonGroup/index.d.ts +2 -0
- package/lib/ButtonGroup/index.js +226 -216
- package/lib/ButtonGroup/style/index.less +1 -1
- package/lib/DragContent/DragBar.js +2 -10
- package/lib/DragContent/index.js +47 -85
- package/lib/FormComp/ChunkUploader/api.js +6 -15
- package/lib/FormComp/ChunkUploader/index.js +107 -185
- package/lib/FormComp/ChunkUploader/lib.js +8 -27
- package/lib/FormComp/ChunkUploader/upload-queue.class.js +10 -46
- package/lib/FormComp/ChunkUploader/worker.js +1 -5
- package/lib/FormComp/EditButton/index.js +26 -60
- package/lib/FormComp/FieldComponent/ReUpload.js +21 -50
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +39 -90
- package/lib/FormComp/FieldComponent/TitleNode.js +1 -5
- package/lib/FormComp/FieldComponent/index.js +38 -110
- package/lib/FormComp/FieldComponent/setReadonlyValues.js +37 -79
- package/lib/FormComp/FieldComponent/style/index.less +6 -0
- package/lib/FormComp/RenderItemGroup/index.js +46 -87
- package/lib/FormComp/Uploader/index.js +38 -95
- package/lib/FormComp/Uploader/util.js +1 -9
- package/lib/FormComp/VarTemplate/index.js +62 -106
- package/lib/FormComp/index.js +0 -2
- package/lib/NavLeafScroll/index.js +174 -165
- package/lib/NavLeafScroll/style/index.less +33 -1
- package/lib/RefactorTree/index.js +36 -67
- package/lib/RefactorTree/indexTreeNode.js +37 -83
- package/lib/RefactorTree/util.js +11 -45
- package/lib/SpecIcon/fonts/iconfont.js +7 -12
- package/lib/SpecIcon/index.js +16 -30
- package/lib/SplitterLayout/Pane.js +0 -7
- package/lib/SplitterLayout/index.js +18 -72
- package/lib/StandardContent/SplitterLayout/Pane.js +6 -14
- package/lib/StandardContent/SplitterLayout/index.js +12 -68
- package/lib/StandardContent/SubfieldContent.js +12 -21
- package/lib/StandardContent/WrapperContent.js +8 -16
- package/lib/StandardDragModal/ChangeStandardModal.d.ts +44 -0
- package/lib/StandardDragModal/ChangeStandardModal.js +502 -0
- package/lib/StandardDragModal/DraggableModal.d.ts +7 -0
- package/lib/StandardDragModal/DraggableModal.js +40 -0
- package/lib/StandardDragModal/DraggableModalContext.d.ts +9 -0
- package/lib/StandardDragModal/DraggableModalContext.js +15 -0
- package/lib/StandardDragModal/DraggableModalInner.d.ts +16 -0
- package/lib/StandardDragModal/DraggableModalInner.js +124 -0
- package/lib/StandardDragModal/DraggableModalProvider.d.ts +4 -0
- package/lib/StandardDragModal/DraggableModalProvider.js +48 -0
- package/lib/StandardDragModal/Modal.d.ts +11 -0
- package/lib/StandardDragModal/Modal.js +32 -0
- package/lib/StandardDragModal/ResizeHandle.d.ts +2 -0
- package/lib/StandardDragModal/ResizeHandle.js +18 -0
- package/lib/StandardDragModal/clamp.d.ts +1 -0
- package/lib/StandardDragModal/clamp.js +10 -0
- package/lib/StandardDragModal/draggableModalReducer.d.ts +66 -0
- package/lib/StandardDragModal/draggableModalReducer.js +167 -0
- package/lib/StandardDragModal/getWindowSize.d.ts +4 -0
- package/lib/StandardDragModal/getWindowSize.js +13 -0
- package/lib/StandardDragModal/index.d.ts +3 -11
- package/lib/StandardDragModal/index.js +33 -38
- package/lib/StandardDragModal/index.less +65 -0
- package/lib/StandardDragModal/useDrag.d.ts +5 -0
- package/lib/StandardDragModal/useDrag.js +73 -0
- package/lib/StandardDragModal/usePrevious.d.ts +1 -0
- package/lib/StandardDragModal/usePrevious.js +15 -0
- package/lib/StandardDragModal/useResize.d.ts +7 -0
- package/lib/StandardDragModal/useResize.js +81 -0
- package/lib/StandardFilter/index.d.ts +1 -0
- package/lib/StandardFilter/index.js +30 -78
- package/lib/StandardForm/ActionList.js +5 -12
- package/lib/StandardForm/StepForm.js +52 -90
- package/lib/StandardForm/TabForm.js +61 -88
- package/lib/StandardForm/index.js +40 -75
- package/lib/StandardModal/UpdateFormRef.js +4 -12
- package/lib/StandardModal/index.d.ts +0 -1
- package/lib/StandardModal/index.js +117 -184
- package/lib/StandardPanel/index.js +22 -48
- package/lib/StandardTable/index.js +20 -39
- package/lib/components/IconNode/index.js +0 -7
- package/lib/components/index.js +0 -2
- package/lib/data/index.js +4 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +50 -68
- package/lib/utils/ValueFormat.js +0 -10
- package/lib/utils/dictSelectUtil.js +161 -0
- package/lib/utils/filterPermission.js +15 -39
- package/lib/utils/getParentNodes.js +25 -52
- package/lib/utils/index.js +24 -9
- package/package.json +6 -5
|
@@ -1,131 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
require("antd/es/tree/style");
|
|
11
|
-
|
|
12
8
|
var _tree = _interopRequireDefault(require("antd/es/tree"));
|
|
13
|
-
|
|
14
9
|
require("antd/es/empty/style");
|
|
15
|
-
|
|
16
10
|
var _empty = _interopRequireDefault(require("antd/es/empty"));
|
|
17
|
-
|
|
18
11
|
require("antd/es/popconfirm/style");
|
|
19
|
-
|
|
20
12
|
var _popconfirm = _interopRequireDefault(require("antd/es/popconfirm"));
|
|
21
|
-
|
|
22
13
|
var _tslib = require("tslib");
|
|
23
|
-
|
|
24
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
25
|
-
|
|
26
15
|
var _index = _interopRequireDefault(require("../SpecIcon/index"));
|
|
27
|
-
|
|
28
16
|
var _util = require("./util");
|
|
29
|
-
|
|
30
17
|
require("./style/index.less");
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
-
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
36
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
-
|
|
38
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
|
-
|
|
21
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
22
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
24
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // 重构树控件,可直接配置数据
|
|
40
25
|
var RefactorTree = function RefactorTree(props) {
|
|
41
26
|
var treeData = props.treeData,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
27
|
+
rootName = props.rootName,
|
|
28
|
+
rootKey = props.rootKey,
|
|
29
|
+
emptyDescription = props.emptyDescription,
|
|
30
|
+
_props$optionName = props.optionName,
|
|
31
|
+
optionName = _props$optionName === void 0 ? {
|
|
32
|
+
value: 'value',
|
|
33
|
+
title: 'title',
|
|
34
|
+
children: 'children',
|
|
35
|
+
disabled: 'disabled'
|
|
36
|
+
} : _props$optionName,
|
|
37
|
+
defaultSelectedKeys = props.defaultSelectedKeys,
|
|
38
|
+
nodeExtra = props.nodeExtra,
|
|
39
|
+
_props$selectable = props.selectable,
|
|
40
|
+
selectable = _props$selectable === void 0 ? true : _props$selectable,
|
|
41
|
+
nodeControl = props.nodeControl,
|
|
42
|
+
limitKey = props.limitKey,
|
|
43
|
+
checkedKeys = props.checkedKeys,
|
|
44
|
+
checkStrictly = props.checkStrictly,
|
|
45
|
+
onSelect = props.onSelect,
|
|
46
|
+
onCheck = props.onCheck,
|
|
47
|
+
titleRender = props.titleRender,
|
|
48
|
+
disabledFields = props.disabledFields,
|
|
49
|
+
otherProps = (0, _tslib.__rest)(props, ["treeData", "rootName", "rootKey", "emptyDescription", "optionName", "defaultSelectedKeys", "nodeExtra", "selectable", "nodeControl", "limitKey", "checkedKeys", "checkStrictly", "onSelect", "onCheck", "titleRender", "disabledFields"]); // const { title, value, children, disabled } = { value: 'value', title: 'title', children: 'children', disabled: 'disabled', ...optionName }
|
|
65
50
|
// 重新组合指定数据源字段
|
|
66
|
-
|
|
67
51
|
var transTreeData = (0, _react.useMemo)(function () {
|
|
68
52
|
var _ref;
|
|
69
|
-
|
|
70
53
|
var afterTransData = (0, _util.transDataParam)(treeData, optionName); // 通过转换后的数据
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
var resultData;
|
|
55
|
+
// 如果有配置根节点,则添加 一个根节点数据
|
|
56
|
+
resultData = rootName ? [(_ref = {}, _defineProperty(_ref, optionName.title || 'title', rootName), _defineProperty(_ref, optionName.key || 'key', rootKey || '0'), _defineProperty(_ref, 'children', afterTransData), _ref)] : afterTransData;
|
|
57
|
+
// 有配置limitKey指定限制同级节点时,添加判断节点选择限制(在父子节点不相关联条件下使用checkStrictly=true)
|
|
76
58
|
if (checkStrictly && limitKey && checkedKeys) {
|
|
77
59
|
if (Array.isArray(checkedKeys) && checkedKeys.length > 0 || checkedKeys && Array.isArray(checkedKeys.checked) && checkedKeys.checked.length > 0) {
|
|
78
60
|
resultData = (0, _util.resetDataWithLimit)(Array.isArray(checkedKeys) ? checkedKeys : checkedKeys.checked, resultData, optionName, limitKey);
|
|
79
61
|
}
|
|
80
62
|
}
|
|
81
|
-
|
|
82
63
|
if (disabledFields && Array.isArray(disabledFields)) {
|
|
83
64
|
resultData = (0, _util.resetDataWithDisabled)(resultData, optionName, disabledFields);
|
|
84
65
|
}
|
|
85
|
-
|
|
86
66
|
return resultData;
|
|
87
|
-
}, [treeData, optionName, checkStrictly, limitKey, checkedKeys, disabledFields]);
|
|
88
|
-
|
|
67
|
+
}, [treeData, optionName, checkStrictly, limitKey, checkedKeys, disabledFields]);
|
|
68
|
+
// console.log('重置后的数据', transTreeData)
|
|
89
69
|
var handleToSelectTreeNode = function handleToSelectTreeNode(key, e) {
|
|
90
70
|
var currentData = e.node;
|
|
91
71
|
var multiSelectedData = [];
|
|
92
72
|
e.selectedNodes.map(function (item) {
|
|
93
73
|
return multiSelectedData.push(item);
|
|
94
74
|
}); // 多选条件下,当前选中所有节点数据
|
|
95
|
-
|
|
96
75
|
onSelect && onSelect(key, {
|
|
97
76
|
currentData: currentData,
|
|
98
77
|
multiData: multiSelectedData
|
|
99
78
|
}, e);
|
|
100
79
|
};
|
|
101
|
-
|
|
102
80
|
var handleToCheckTreeNode = function handleToCheckTreeNode(keys, e) {
|
|
103
81
|
var currentData = e.node;
|
|
104
82
|
var multiCheckedData = [];
|
|
105
83
|
e.checkedNodes.map(function (item) {
|
|
106
84
|
return multiCheckedData.push(item);
|
|
107
85
|
}); // 多选条件下,当前选中所有节点数据
|
|
108
|
-
|
|
109
86
|
onCheck && onCheck(keys, {
|
|
110
87
|
currentData: currentData,
|
|
111
88
|
multiData: multiCheckedData
|
|
112
89
|
}, e);
|
|
113
90
|
};
|
|
114
|
-
|
|
115
91
|
var handleNodeControl = function handleNodeControl(e, type, nodeData) {
|
|
116
92
|
e.stopPropagation();
|
|
117
93
|
var onEdit = nodeControl.onEdit,
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
onDelete = nodeControl.onDelete;
|
|
120
95
|
if (type === 'edit') {
|
|
121
96
|
onEdit && onEdit(nodeData);
|
|
122
97
|
}
|
|
123
|
-
|
|
124
98
|
if (type === 'delete') {
|
|
125
99
|
onDelete && onDelete(nodeData);
|
|
126
100
|
}
|
|
127
101
|
};
|
|
128
|
-
|
|
129
102
|
var renderNodeTitle = function renderNodeTitle(item) {
|
|
130
103
|
if (titleRender) return titleRender(item);
|
|
131
104
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, item[optionName.title || 'title'], nodeControl ? /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -153,7 +126,6 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
153
126
|
name: 'delete'
|
|
154
127
|
})))) : null, nodeExtra && nodeExtra(item));
|
|
155
128
|
};
|
|
156
|
-
|
|
157
129
|
if (transTreeData.length == 0) {
|
|
158
130
|
return /*#__PURE__*/_react.default.createElement(_empty.default, {
|
|
159
131
|
image: _empty.default.PRESENTED_IMAGE_SIMPLE,
|
|
@@ -161,13 +133,11 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
161
133
|
});
|
|
162
134
|
} else {
|
|
163
135
|
var defExpand = [];
|
|
164
|
-
|
|
165
136
|
if (defaultSelectedKeys && defaultSelectedKeys.length > 0) {
|
|
166
137
|
defExpand = defaultSelectedKeys;
|
|
167
138
|
} else {
|
|
168
139
|
defExpand = rootKey ? [rootKey] : ['0'];
|
|
169
140
|
}
|
|
170
|
-
|
|
171
141
|
return /*#__PURE__*/_react.default.createElement(_tree.default, Object.assign({}, otherProps, {
|
|
172
142
|
onSelect: function onSelect(keys, e) {
|
|
173
143
|
return handleToSelectTreeNode(keys, e);
|
|
@@ -185,6 +155,5 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
185
155
|
}));
|
|
186
156
|
}
|
|
187
157
|
};
|
|
188
|
-
|
|
189
158
|
var _default = RefactorTree;
|
|
190
159
|
exports.default = _default;
|
|
@@ -1,85 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
require("antd/es/empty/style");
|
|
11
|
-
|
|
12
9
|
var _empty = _interopRequireDefault(require("antd/es/empty"));
|
|
13
|
-
|
|
14
10
|
require("antd/es/popconfirm/style");
|
|
15
|
-
|
|
16
11
|
var _popconfirm = _interopRequireDefault(require("antd/es/popconfirm"));
|
|
17
|
-
|
|
18
12
|
require("antd/es/tree/style");
|
|
19
|
-
|
|
20
13
|
var _tree = _interopRequireDefault(require("antd/es/tree"));
|
|
21
|
-
|
|
22
14
|
var _tslib = require("tslib");
|
|
23
|
-
|
|
24
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
25
|
-
|
|
26
16
|
var _index = _interopRequireDefault(require("../SpecIcon/index"));
|
|
27
|
-
|
|
28
17
|
require("./style/index.less");
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
21
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
37
|
-
|
|
38
22
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
39
|
-
|
|
40
23
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
41
|
-
|
|
42
24
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
47
|
-
|
|
25
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // 重构树控件,可直接配置数据
|
|
48
27
|
var TreeNode = _tree.default.TreeNode;
|
|
49
|
-
|
|
50
28
|
var RefactorTree = function RefactorTree(props) {
|
|
51
29
|
var treeData = props.treeData,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
30
|
+
rootName = props.rootName,
|
|
31
|
+
rootKey = props.rootKey,
|
|
32
|
+
rootIcon = props.rootIcon,
|
|
33
|
+
emptyDescription = props.emptyDescription,
|
|
34
|
+
_props$optionName = props.optionName,
|
|
35
|
+
optionName = _props$optionName === void 0 ? {
|
|
36
|
+
value: 'value',
|
|
37
|
+
title: 'title',
|
|
38
|
+
children: 'children',
|
|
39
|
+
disabled: 'disabled'
|
|
40
|
+
} : _props$optionName,
|
|
41
|
+
defaultSelectedKeys = props.defaultSelectedKeys,
|
|
42
|
+
nodeItemReset = props.nodeItemReset,
|
|
43
|
+
nodeExtra = props.nodeExtra,
|
|
44
|
+
_props$selectable = props.selectable,
|
|
45
|
+
selectable = _props$selectable === void 0 ? true : _props$selectable,
|
|
46
|
+
nodeControl = props.nodeControl,
|
|
47
|
+
limitKey = props.limitKey,
|
|
48
|
+
checkedKeys = props.checkedKeys,
|
|
49
|
+
checkStrictly = props.checkStrictly,
|
|
50
|
+
onSelect = props.onSelect,
|
|
51
|
+
onCheck = props.onCheck,
|
|
52
|
+
otherProps = (0, _tslib.__rest)(props, ["treeData", "rootName", "rootKey", "rootIcon", "emptyDescription", "optionName", "defaultSelectedKeys", "nodeItemReset", "nodeExtra", "selectable", "nodeControl", "limitKey", "checkedKeys", "checkStrictly", "onSelect", "onCheck"]); // 重新组合指定数据源字段 (limitKey:用于限制只能选择指定同一层级的数据)
|
|
75
53
|
// const { title, value, children, disabled } = { value: 'value', title: 'title', children: 'children', disabled: 'disabled', ...optionName }
|
|
76
|
-
|
|
77
54
|
var _useState = (0, _react.useState)([]),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
55
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
56
|
+
dataList = _useState2[0],
|
|
57
|
+
setDataList = _useState2[1]; // 限制节点选中条件下更新列表数据
|
|
83
58
|
var resetDataWithLimit = function resetDataWithLimit(hasKeys, list, resultList) {
|
|
84
59
|
// 利用ID匹配对应选中的完整节点数据
|
|
85
60
|
var filterCheckedNode = function filterCheckedNode(ids, preList, matchList) {
|
|
@@ -88,34 +63,28 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
88
63
|
if (ids.includes(item[optionName.value])) {
|
|
89
64
|
matchList.push(Object.assign({}, item));
|
|
90
65
|
}
|
|
91
|
-
|
|
92
66
|
filterCheckedNode(ids, item[optionName.children || 'children'], matchList);
|
|
93
67
|
});
|
|
94
68
|
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
|
|
69
|
+
};
|
|
70
|
+
// 筛选同一层级可选择,其他层级数据不可选择(限制按指定字段名的层级数据)
|
|
98
71
|
var filterResetSameLevel = function filterResetSameLevel(preList, resData, matchData) {
|
|
99
72
|
if (Array.isArray(preList) && preList.length > 0) {
|
|
100
73
|
preList.forEach(function (item, i) {
|
|
101
74
|
resData[i] = Object.assign({}, item);
|
|
102
75
|
resData[i].isLimit = item[limitKey] !== matchData; // [limitKey];
|
|
103
|
-
|
|
104
76
|
var newDeepArr = [];
|
|
105
77
|
filterResetSameLevel(item[optionName.children || 'children'], newDeepArr, matchData);
|
|
106
78
|
resData[i][optionName.children || 'children'] = newDeepArr;
|
|
107
79
|
});
|
|
108
80
|
}
|
|
109
81
|
};
|
|
110
|
-
|
|
111
82
|
var matchItems = [];
|
|
112
83
|
filterCheckedNode(hasKeys, list, matchItems); // 先筛选出来选中节点的数据,取其中的 level 层级的值(数据必须保证同级类型值一致)
|
|
113
|
-
|
|
114
84
|
if (matchItems.length > 0) {
|
|
115
85
|
filterResetSameLevel(list, resultList, matchItems[0][limitKey]);
|
|
116
86
|
}
|
|
117
87
|
};
|
|
118
|
-
|
|
119
88
|
(0, _react.useEffect)(function () {
|
|
120
89
|
// 有配置limitKey指定限制同级节点时,添加判断节点选择限制(在父子节点不相关联条件下使用checkStrictly=true)
|
|
121
90
|
if (checkStrictly && limitKey && checkedKeys) {
|
|
@@ -130,48 +99,40 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
130
99
|
setDataList(treeData || []); // 默认状态直接赋值传进来的数据
|
|
131
100
|
}
|
|
132
101
|
}, [treeData, checkedKeys]);
|
|
133
|
-
|
|
134
102
|
var handleToSelectTreeNode = function handleToSelectTreeNode(key, e) {
|
|
135
103
|
var currentData = e.node.dataRef;
|
|
136
104
|
var multiSelectedData = [];
|
|
137
105
|
e.selectedNodes.map(function (item) {
|
|
138
106
|
return multiSelectedData.push(item.dataRef);
|
|
139
107
|
}); // 多选条件下,当前选中所有节点数据
|
|
140
|
-
|
|
141
108
|
onSelect && onSelect(key, {
|
|
142
109
|
currentData: currentData,
|
|
143
110
|
multiData: multiSelectedData
|
|
144
111
|
}, e);
|
|
145
112
|
};
|
|
146
|
-
|
|
147
113
|
var handleToCheckTreeNode = function handleToCheckTreeNode(keys, e) {
|
|
148
114
|
var currentData = e.node.dataRef;
|
|
149
115
|
var multiCheckedData = [];
|
|
150
116
|
e.checkedNodes.map(function (item) {
|
|
151
117
|
return multiCheckedData.push(item.dataRef);
|
|
152
118
|
}); // 多选条件下,当前选中所有节点数据
|
|
153
|
-
|
|
154
119
|
onCheck && onCheck(keys, {
|
|
155
120
|
currentData: currentData,
|
|
156
121
|
multiData: multiCheckedData
|
|
157
122
|
}, e);
|
|
158
123
|
};
|
|
159
|
-
|
|
160
124
|
var handleNodeControl = function handleNodeControl(e, type, nodeData) {
|
|
161
125
|
e.stopPropagation();
|
|
162
126
|
var onEdit = nodeControl.onEdit,
|
|
163
|
-
|
|
164
|
-
|
|
127
|
+
onDelete = nodeControl.onDelete;
|
|
165
128
|
if (type === 'edit') {
|
|
166
129
|
onEdit && onEdit(nodeData);
|
|
167
130
|
}
|
|
168
|
-
|
|
169
131
|
if (type === 'delete') {
|
|
170
132
|
onDelete && onDelete(nodeData);
|
|
171
133
|
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
|
|
134
|
+
};
|
|
135
|
+
// const <Icon type={selected ? 'frown' : 'frown-o'} />
|
|
175
136
|
var renderNodeTitle = function renderNodeTitle(item) {
|
|
176
137
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, nodeItemReset && nodeItemReset(item).icon || (item.icon ? /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
177
138
|
name: item.icon
|
|
@@ -200,7 +161,6 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
200
161
|
name: 'delete'
|
|
201
162
|
})))) : null, nodeExtra && nodeExtra);
|
|
202
163
|
};
|
|
203
|
-
|
|
204
164
|
var renderTreeNodes = function renderTreeNodes(data) {
|
|
205
165
|
return data.map(function (item) {
|
|
206
166
|
if (item[optionName.children || 'children']) {
|
|
@@ -212,7 +172,6 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
212
172
|
dataRef: item
|
|
213
173
|
}), renderTreeNodes(item[optionName.children || 'children']));
|
|
214
174
|
}
|
|
215
|
-
|
|
216
175
|
return /*#__PURE__*/_react.default.createElement(TreeNode, Object.assign({}, item, {
|
|
217
176
|
title: renderNodeTitle(item),
|
|
218
177
|
key: item[optionName.value || 'value'],
|
|
@@ -222,21 +181,17 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
222
181
|
}));
|
|
223
182
|
});
|
|
224
183
|
};
|
|
225
|
-
|
|
226
184
|
if (dataList.length == 0 && !rootName) return /*#__PURE__*/_react.default.createElement(_empty.default, {
|
|
227
185
|
image: _empty.default.PRESENTED_IMAGE_SIMPLE,
|
|
228
186
|
description: emptyDescription
|
|
229
187
|
});
|
|
230
188
|
var defExpand = [];
|
|
231
|
-
|
|
232
189
|
if (defaultSelectedKeys && defaultSelectedKeys.length > 0) {
|
|
233
190
|
defExpand = defaultSelectedKeys;
|
|
234
191
|
} else {
|
|
235
192
|
defExpand = rootKey ? [rootKey] : ['0'];
|
|
236
193
|
}
|
|
237
|
-
|
|
238
|
-
return /*#__PURE__*/_react.default.createElement(_tree.default, // switcherIcon={<Icon type="down" />}
|
|
239
|
-
Object.assign({}, otherProps, {
|
|
194
|
+
return /*#__PURE__*/_react.default.createElement(_tree.default, Object.assign({}, otherProps, {
|
|
240
195
|
onSelect: function onSelect(keys, e) {
|
|
241
196
|
return handleToSelectTreeNode(keys, e);
|
|
242
197
|
},
|
|
@@ -255,6 +210,5 @@ var RefactorTree = function RefactorTree(props) {
|
|
|
255
210
|
icon: rootIcon || null
|
|
256
211
|
}, renderTreeNodes(dataList)) : renderTreeNodes(dataList));
|
|
257
212
|
};
|
|
258
|
-
|
|
259
213
|
var _default = RefactorTree;
|
|
260
214
|
exports.default = _default;
|
package/lib/RefactorTree/util.js
CHANGED
|
@@ -3,24 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.transDataParam = transDataParam;
|
|
7
|
-
exports.resetDataWithLimit = resetDataWithLimit;
|
|
8
6
|
exports.resetDataWithDisabled = resetDataWithDisabled;
|
|
9
|
-
|
|
7
|
+
exports.resetDataWithLimit = resetDataWithLimit;
|
|
8
|
+
exports.transDataParam = transDataParam;
|
|
10
9
|
var _tslib = require("tslib");
|
|
11
|
-
|
|
12
10
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
-
|
|
14
11
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
-
|
|
16
12
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
-
|
|
18
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
19
|
-
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
14
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
21
|
-
|
|
22
15
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
-
|
|
24
16
|
/**
|
|
25
17
|
* transDataParam 根据指定选项字段名重组数据
|
|
26
18
|
*
|
|
@@ -37,29 +29,24 @@ function transDataParam(array) {
|
|
|
37
29
|
disabled: 'disabled',
|
|
38
30
|
selectable: 'selectable'
|
|
39
31
|
};
|
|
40
|
-
|
|
41
32
|
var trans = function trans(list) {
|
|
42
33
|
if (!list) return null;
|
|
43
34
|
return list.map(function (item) {
|
|
44
35
|
if (item.hasOwnProperty(optionName.disabled || 'disabled')) {
|
|
45
36
|
item.disabled = item[optionName.disabled || 'disabled'];
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
if (item.hasOwnProperty(optionName.selectable || 'selectable')) {
|
|
49
39
|
item.selectable = item[optionName.selectable || 'selectable'];
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
if (item.hasOwnProperty(optionName.children || 'children')) {
|
|
53
42
|
item.children = item[optionName.children || 'children'] ? trans(item[optionName.children || 'children']) : [];
|
|
54
43
|
}
|
|
55
|
-
|
|
56
44
|
return Object.assign(Object.assign({}, item), {
|
|
57
45
|
key: item[optionName.value || optionName.key || 'key'],
|
|
58
46
|
title: item[optionName.title || 'title']
|
|
59
47
|
});
|
|
60
48
|
});
|
|
61
49
|
};
|
|
62
|
-
|
|
63
50
|
return trans(array);
|
|
64
51
|
}
|
|
65
52
|
/**
|
|
@@ -73,8 +60,6 @@ function transDataParam(array) {
|
|
|
73
60
|
* @Return {array} 返回结果数据
|
|
74
61
|
*
|
|
75
62
|
* */
|
|
76
|
-
|
|
77
|
-
|
|
78
63
|
function resetDataWithLimit(hasKeys, list) {
|
|
79
64
|
var optionName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
80
65
|
key: 'key',
|
|
@@ -85,56 +70,45 @@ function resetDataWithLimit(hasKeys, list) {
|
|
|
85
70
|
selectable: 'selectable'
|
|
86
71
|
};
|
|
87
72
|
var limitKey = arguments.length > 3 ? arguments[3] : undefined;
|
|
88
|
-
|
|
89
73
|
// 利用ID匹配对应选中的完整节点数据
|
|
90
74
|
var filterCheckedNode = function filterCheckedNode(ids, preList) {
|
|
91
75
|
var matchList = [];
|
|
92
|
-
|
|
93
76
|
if (Array.isArray(preList) && preList.length > 0) {
|
|
94
77
|
preList.forEach(function (item, i) {
|
|
95
78
|
if (ids.includes(item[optionName.value || 'value'])) {
|
|
96
79
|
matchList.push(Object.assign({}, item));
|
|
97
80
|
}
|
|
98
|
-
|
|
99
81
|
if (item[optionName.children || 'children']) {
|
|
100
82
|
matchList = matchList.concat(filterCheckedNode(ids, item[optionName.children || 'children']));
|
|
101
83
|
}
|
|
102
84
|
});
|
|
103
85
|
}
|
|
104
|
-
|
|
105
86
|
return matchList;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
};
|
|
88
|
+
// 筛选同一层级可选择,其他层级数据不可选择(限制按指定字段名的层级数据)
|
|
109
89
|
var filterResetSameLevel = function filterResetSameLevel(preList, matchDataValue) {
|
|
110
90
|
if (!preList) return [];
|
|
111
91
|
if (!matchDataValue) return preList;
|
|
112
92
|
return preList === null || preList === void 0 ? void 0 : preList.map(function (preItem) {
|
|
113
93
|
var oldItem = Object.assign({}, preItem);
|
|
114
94
|
var item = (0, _tslib.__rest)(oldItem, []);
|
|
115
|
-
|
|
116
95
|
if (item[limitKey] !== matchDataValue) {
|
|
117
96
|
item.disabled = true;
|
|
118
97
|
} else if (item.hasOwnProperty(optionName.disabled || 'disabled')) {
|
|
119
98
|
item.disabled = item[optionName.disabled || 'disabled'];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
99
|
+
}
|
|
100
|
+
// item.disabled = item[limitKey] !== matchDataValue || item[optionName.disabled || 'disabled']
|
|
123
101
|
item.isLimit = item[limitKey] !== matchDataValue;
|
|
124
102
|
item.children = filterResetSameLevel(item['children'], matchDataValue);
|
|
125
103
|
item[optionName.children || 'children'] = filterResetSameLevel(item[optionName.children || 'children'], matchDataValue);
|
|
126
104
|
return Object.assign({}, item);
|
|
127
105
|
});
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
|
|
106
|
+
};
|
|
107
|
+
// 先筛选出来选中节点的数据,取其中的 level 层级的值(数据必须保证同级类型值一致)
|
|
131
108
|
var prevList = list && Array.isArray(list) ? _toConsumableArray(list) : [];
|
|
132
|
-
|
|
133
109
|
var _ref = _toConsumableArray(prevList),
|
|
134
|
-
|
|
135
|
-
|
|
110
|
+
newList = _ref.slice(0);
|
|
136
111
|
var filterLimitData = filterCheckedNode(hasKeys, newList);
|
|
137
|
-
|
|
138
112
|
if (filterLimitData.length > 0) {
|
|
139
113
|
return filterResetSameLevel(newList, filterLimitData[0][limitKey]);
|
|
140
114
|
} else {
|
|
@@ -153,8 +127,6 @@ function resetDataWithLimit(hasKeys, list) {
|
|
|
153
127
|
* @Return {array} 返回结果数据
|
|
154
128
|
*
|
|
155
129
|
* */
|
|
156
|
-
|
|
157
|
-
|
|
158
130
|
function resetDataWithDisabled(list, optionName, disabledFields) {
|
|
159
131
|
// 筛选与禁用字段内值相同的节点进行禁用
|
|
160
132
|
var filterResetTargetFields = function filterResetTargetFields(preList, fields) {
|
|
@@ -164,11 +136,9 @@ function resetDataWithDisabled(list, optionName, disabledFields) {
|
|
|
164
136
|
var item = (0, _tslib.__rest)(oldItem, []);
|
|
165
137
|
Object.keys(item).forEach(function (itemKeyName) {
|
|
166
138
|
var _a;
|
|
167
|
-
|
|
168
139
|
var isMatch = fields.find(function (fItem) {
|
|
169
140
|
return fItem.key === itemKeyName;
|
|
170
141
|
});
|
|
171
|
-
|
|
172
142
|
if (isMatch) {
|
|
173
143
|
// 确认是否匹配数据,进行设置 disabled
|
|
174
144
|
if ((_a = isMatch.value.split(',')) === null || _a === void 0 ? void 0 : _a.includes(item[itemKeyName])) {
|
|
@@ -177,7 +147,6 @@ function resetDataWithDisabled(list, optionName, disabledFields) {
|
|
|
177
147
|
item.disabled = item[optionName.disabled || 'disabled'];
|
|
178
148
|
}
|
|
179
149
|
}
|
|
180
|
-
|
|
181
150
|
if (itemKeyName === 'children') {
|
|
182
151
|
item.children = filterResetTargetFields(item[itemKeyName], fields);
|
|
183
152
|
}
|
|
@@ -185,11 +154,8 @@ function resetDataWithDisabled(list, optionName, disabledFields) {
|
|
|
185
154
|
return Object.assign({}, item);
|
|
186
155
|
});
|
|
187
156
|
};
|
|
188
|
-
|
|
189
157
|
var prevList = list && Array.isArray(list) ? _toConsumableArray(list) : [];
|
|
190
|
-
|
|
191
158
|
var _ref2 = _toConsumableArray(prevList),
|
|
192
|
-
|
|
193
|
-
|
|
159
|
+
newList = _ref2.slice(0);
|
|
194
160
|
return filterResetTargetFields(newList, disabledFields);
|
|
195
161
|
}
|