xh-lab-rc 0.20.1 → 0.21.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/dist/LabClassifyTree/index.d.ts +1 -1
- package/dist/LabClassifyTree/index.js +76 -175
- package/dist/LabClassifyTree/style.less +1 -3
- package/dist/LabClassifyTree/type.d.ts +11 -33
- package/dist/LabOperateTree/index.d.ts +2 -1
- package/dist/LabOperateTree/index.js +115 -95
- package/dist/index.d.ts +1 -1
- package/package.json +3 -2
- package/src/LabAltimeter/KemiAlt/index.tsx +1055 -0
- package/src/LabAltimeter/KemiAlt/style.less +6 -0
- package/src/LabAltimeter/SetupModal/index.tsx +41 -0
- package/src/LabAltimeter/demos/demo.tsx +24 -0
- package/src/LabAltimeter/index.md +10 -0
- package/src/LabAltimeter/index.tsx +789 -0
- package/src/LabAltimeter/style.less +213 -0
- package/src/LabAttachmentPreview/demos/demo.tsx +45 -0
- package/src/LabAttachmentPreview/index.md +10 -0
- package/src/LabAttachmentPreview/index.tsx +479 -0
- package/src/LabAttachmentPreview/style.less +201 -0
- package/src/LabClassifyTree/demos/demo.tsx +543 -0
- package/src/LabClassifyTree/index.md +12 -0
- package/src/LabClassifyTree/index.tsx +223 -0
- package/src/LabClassifyTree/style.less +227 -0
- package/src/LabClassifyTree/type.ts +40 -0
- package/src/LabDGTreeSelect/demos/demo.tsx +94 -0
- package/src/LabDGTreeSelect/index.md +10 -0
- package/src/LabDGTreeSelect/index.tsx +132 -0
- package/src/LabDGTreeSelect/style.less +79 -0
- package/src/LabFilePreview/demos/demo.tsx +49 -0
- package/src/LabFilePreview/index.md +10 -0
- package/src/LabFilePreview/index.tsx +404 -0
- package/src/LabFilePreview/style.less +78 -0
- package/src/LabGTreeSelect/demos/demo.tsx +53 -0
- package/src/LabGTreeSelect/index.md +10 -0
- package/src/LabGTreeSelect/index.tsx +82 -0
- package/src/LabGTreeSelect/style.less +15 -0
- package/src/LabGroupTree/demos/demo.tsx +280 -0
- package/src/LabGroupTree/index.md +10 -0
- package/src/LabGroupTree/index.tsx +185 -0
- package/src/LabGroupTree/style.less +105 -0
- package/src/LabGroupTree/typing.ts +46 -0
- package/src/LabIconFont/data.tsx +45 -0
- package/src/LabIconFont/demos/demo.tsx +59 -0
- package/src/LabIconFont/index.md +10 -0
- package/src/LabIconFont/index.tsx +20 -0
- package/src/LabIconFont/style.less +23 -0
- package/src/LabMultipleSelect/demos/demo.tsx +49 -0
- package/src/LabMultipleSelect/index.md +10 -0
- package/src/LabMultipleSelect/index.tsx +129 -0
- package/src/LabMultipleSelect/style.less +27 -0
- package/src/LabOffice/demos/demo.tsx +730 -0
- package/src/LabOffice/index.md +10 -0
- package/src/LabOffice/index.tsx +217 -0
- package/src/LabOffice/style.less +10 -0
- package/src/LabOffice/tying.d.ts +101 -0
- package/src/LabOperateTree/demos/data.tsx +2180 -0
- package/src/LabOperateTree/demos/demo.tsx +308 -0
- package/src/LabOperateTree/index.md +10 -0
- package/src/LabOperateTree/index.tsx +613 -0
- package/src/LabOperateTree/style.less +140 -0
- package/src/LabPSwitchPreview/demos/demo.tsx +42 -0
- package/src/LabPSwitchPreview/index.md +10 -0
- package/src/LabPSwitchPreview/index.tsx +248 -0
- package/src/LabPSwitchPreview/style.less +111 -0
- package/src/LabPdf/data.ts +2 -0
- package/src/LabPdf/demos/demo.tsx +39 -0
- package/src/LabPdf/index.md +10 -0
- package/src/LabPdf/index.tsx +83 -0
- package/src/LabPdf/style.less +10 -0
- package/src/LabPdfPrint/demos/demo.tsx +126 -0
- package/src/LabPdfPrint/index.md +10 -0
- package/src/LabPdfPrint/index.tsx +108 -0
- package/src/LabPdfPrint/style.less +10 -0
- package/src/LabPdfView/demos/demo.tsx +90 -0
- package/src/LabPdfView/index.md +10 -0
- package/src/LabPdfView/index.tsx +172 -0
- package/src/LabPdfView/style.less +75 -0
- package/src/LabPdfViewMobile/demos/demo.tsx +57 -0
- package/src/LabPdfViewMobile/index.md +10 -0
- package/src/LabPdfViewMobile/index.tsx +461 -0
- package/src/LabPdfViewMobile/style.less +172 -0
- package/src/LabPictureCarousel/demos/demo.tsx +94 -0
- package/src/LabPictureCarousel/index.md +10 -0
- package/src/LabPictureCarousel/index.tsx +148 -0
- package/src/LabPictureCarousel/style.less +150 -0
- package/src/components/Iconfont/iconfont.js +1 -0
- package/src/components/Iconfont/index.tsx +19 -0
- package/src/components/index.ts +3 -0
- package/src/constants/index.ts +34 -0
- package/src/global.d.ts +37 -0
- package/src/index.ts +19 -0
- package/src/utils/utils.ts +238 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './style.less';
|
|
3
3
|
import type { LabClassifyTreeProps } from './type';
|
|
4
|
-
export type {
|
|
4
|
+
export type { LabClassifyTreeProps } from './type';
|
|
5
5
|
export default function LabClassifyTree(props: LabClassifyTreeProps): React.JSX.Element;
|
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
2
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
8
|
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; }
|
|
5
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
-
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); }
|
|
9
|
-
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; }
|
|
10
11
|
/*
|
|
11
12
|
* @Author: xqy
|
|
12
13
|
* @Date: 2026-04-18 09:57:37
|
|
13
14
|
* @LastEditors: xqy
|
|
14
|
-
* @LastEditTime: 2026-
|
|
15
|
+
* @LastEditTime: 2026-05-21 14:20:34
|
|
15
16
|
* @Description:分类树 — 一级分类并入 Tree;同级拖拽
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
import { Iconfont } from "../components";
|
|
19
|
-
import {
|
|
20
|
-
import { Dropdown, Tree } from 'antd';
|
|
20
|
+
import { Tree } from 'antd';
|
|
21
21
|
import React, { useCallback, useMemo } from 'react';
|
|
22
22
|
import "./style.less";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}];
|
|
36
|
-
function getNodeMetaValue(node, keys) {
|
|
37
|
-
var record = node;
|
|
38
|
-
var _iterator = _createForOfIteratorHelper(keys),
|
|
23
|
+
function cloneTree(nodes) {
|
|
24
|
+
return nodes.map(function (n) {
|
|
25
|
+
var _n$CHILDREN;
|
|
26
|
+
return _objectSpread(_objectSpread({}, n), {}, {
|
|
27
|
+
CHILDREN: (_n$CHILDREN = n.CHILDREN) !== null && _n$CHILDREN !== void 0 && _n$CHILDREN.length ? cloneTree(n.CHILDREN) : undefined
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function buildParentMap(nodes) {
|
|
32
|
+
var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
33
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Map();
|
|
34
|
+
var _iterator = _createForOfIteratorHelper(nodes),
|
|
39
35
|
_step;
|
|
40
36
|
try {
|
|
41
37
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
var _n$CHILDREN2;
|
|
39
|
+
var n = _step.value;
|
|
40
|
+
map.set(String(n.SOURCE_PATH), parentKey);
|
|
41
|
+
if ((_n$CHILDREN2 = n.CHILDREN) !== null && _n$CHILDREN2 !== void 0 && _n$CHILDREN2.length) {
|
|
42
|
+
buildParentMap(n.CHILDREN, n.SOURCE_PATH, map);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
} catch (err) {
|
|
@@ -50,89 +47,37 @@ function getNodeMetaValue(node, keys) {
|
|
|
50
47
|
} finally {
|
|
51
48
|
_iterator.f();
|
|
52
49
|
}
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
function getNodeKey(node, fieldNames) {
|
|
56
|
-
var keyValue = getNodeMetaValue(node, [fieldNames.key]);
|
|
57
|
-
return keyValue;
|
|
58
|
-
}
|
|
59
|
-
function getNodeChildren(node, fieldNames) {
|
|
60
|
-
return getNodeMetaValue(node, [fieldNames.children]);
|
|
61
|
-
}
|
|
62
|
-
function renderNodeTitle(n, fieldNames) {
|
|
63
|
-
var t = getNodeMetaValue(n, [fieldNames.title]);
|
|
64
|
-
if (typeof t === 'function') {
|
|
65
|
-
return t(n);
|
|
66
|
-
}
|
|
67
|
-
return t;
|
|
68
|
-
}
|
|
69
|
-
function cloneTree(nodes, fieldNames) {
|
|
70
|
-
return nodes.map(function (n) {
|
|
71
|
-
var _getNodeChildren;
|
|
72
|
-
return _objectSpread(_objectSpread({}, n), {}, _defineProperty({}, fieldNames.children, (_getNodeChildren = getNodeChildren(n, fieldNames)) !== null && _getNodeChildren !== void 0 && _getNodeChildren.length ? cloneTree(getNodeChildren(n, fieldNames), fieldNames) : undefined));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** 每个 key 的父 key;根节点父为 null */
|
|
77
|
-
function buildParentMap(nodes, fieldNames) {
|
|
78
|
-
var parentKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
79
|
-
var map = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Map();
|
|
80
|
-
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
81
|
-
_step2;
|
|
82
|
-
try {
|
|
83
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
84
|
-
var n = _step2.value;
|
|
85
|
-
var nKey = getNodeKey(n, fieldNames);
|
|
86
|
-
var k = String(nKey);
|
|
87
|
-
map.set(k, parentKey);
|
|
88
|
-
var children = getNodeChildren(n, fieldNames);
|
|
89
|
-
if (children !== null && children !== void 0 && children.length) {
|
|
90
|
-
buildParentMap(children, fieldNames, nKey, map);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
} catch (err) {
|
|
94
|
-
_iterator2.e(err);
|
|
95
|
-
} finally {
|
|
96
|
-
_iterator2.f();
|
|
97
|
-
}
|
|
98
50
|
return map;
|
|
99
51
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
function injectSectionClassName(nodes, fieldNames) {
|
|
103
|
-
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
52
|
+
function injectSectionClassName(nodes) {
|
|
53
|
+
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
104
54
|
return nodes.map(function (n, index) {
|
|
105
|
-
var _n$level;
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var levelClass = "cit-node-level-".concat(normalizedLevel);
|
|
109
|
-
var children = getNodeChildren(n, fieldNames);
|
|
110
|
-
var nodeKindClass = children !== null && children !== void 0 && children.length ? 'cit-node-parent' : 'cit-node-leaf';
|
|
111
|
-
var siblingClass = index === nodes.length - 1 ? 'cit-node-last-sibling' : 'cit-node-not-last';
|
|
112
|
-
var className = [n.className, extra, levelClass, nodeKindClass, siblingClass].filter(Boolean).join(' ').trim();
|
|
55
|
+
var _n$level, _n$CHILDREN3, _n$CHILDREN4;
|
|
56
|
+
var level = (_n$level = n.level) !== null && _n$level !== void 0 ? _n$level : depth;
|
|
57
|
+
var classes = [n.className, level === 1 ? 'cit-node-section' : '', "cit-node-level-".concat(level), (_n$CHILDREN3 = n.CHILDREN) !== null && _n$CHILDREN3 !== void 0 && _n$CHILDREN3.length ? 'cit-node-parent' : 'cit-node-leaf', index === nodes.length - 1 ? 'cit-node-last-sibling' : 'cit-node-not-last'].filter(Boolean).join(' ').trim();
|
|
113
58
|
return _objectSpread(_objectSpread(_objectSpread({}, n), {}, {
|
|
114
|
-
level:
|
|
115
|
-
},
|
|
116
|
-
className:
|
|
117
|
-
} : {}), {},
|
|
59
|
+
level: level
|
|
60
|
+
}, classes ? {
|
|
61
|
+
className: classes
|
|
62
|
+
} : {}), {}, {
|
|
63
|
+
CHILDREN: (_n$CHILDREN4 = n.CHILDREN) !== null && _n$CHILDREN4 !== void 0 && _n$CHILDREN4.length ? injectSectionClassName(n.CHILDREN, depth + 1) : undefined
|
|
64
|
+
});
|
|
118
65
|
});
|
|
119
66
|
}
|
|
120
|
-
function findNodeAndParentList(list, key
|
|
67
|
+
function findNodeAndParentList(list, key) {
|
|
121
68
|
for (var i = 0; i < list.length; i += 1) {
|
|
122
|
-
var _node
|
|
123
|
-
|
|
69
|
+
var _node$CHILDREN;
|
|
70
|
+
var node = list[i];
|
|
71
|
+
if (String(node.SOURCE_PATH) === String(key)) {
|
|
124
72
|
return {
|
|
125
|
-
node:
|
|
73
|
+
node: node,
|
|
126
74
|
parentList: list,
|
|
127
75
|
index: i
|
|
128
76
|
};
|
|
129
77
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (found) {
|
|
134
|
-
return found;
|
|
135
|
-
}
|
|
78
|
+
if ((_node$CHILDREN = node.CHILDREN) !== null && _node$CHILDREN !== void 0 && _node$CHILDREN.length) {
|
|
79
|
+
var found = findNodeAndParentList(node.CHILDREN, key);
|
|
80
|
+
if (found) return found;
|
|
136
81
|
}
|
|
137
82
|
}
|
|
138
83
|
return null;
|
|
@@ -141,50 +86,28 @@ export default function LabClassifyTree(props) {
|
|
|
141
86
|
var treeData = props.treeData,
|
|
142
87
|
expandedKeys = props.expandedKeys,
|
|
143
88
|
selectedKeys = props.selectedKeys,
|
|
144
|
-
|
|
145
|
-
defaultSelectedKeys = props.defaultSelectedKeys,
|
|
146
|
-
_onExpand = props.onExpand,
|
|
89
|
+
onExpand = props.onExpand,
|
|
147
90
|
_onSelect = props.onSelect,
|
|
148
91
|
onDrop = props.onDrop,
|
|
149
92
|
onSortedDataChange = props.onSortedDataChange,
|
|
150
93
|
_props$siblingDragOnl = props.siblingDragOnly,
|
|
151
94
|
siblingDragOnly = _props$siblingDragOnl === void 0 ? true : _props$siblingDragOnl,
|
|
152
95
|
allowDropProp = props.allowDrop,
|
|
153
|
-
fieldNames = props.fieldNames,
|
|
154
96
|
firstLevelIcon = props.firstLevelIcon,
|
|
155
|
-
contextMenuItems = props.contextMenuItems,
|
|
156
|
-
onContextMenuClick = props.onContextMenuClick,
|
|
157
|
-
_props$nodeTypes = props.nodeTypes,
|
|
158
|
-
nodeTypes = _props$nodeTypes === void 0 ? [] : _props$nodeTypes,
|
|
159
97
|
_props$isShowNum = props.isShowNum,
|
|
160
|
-
isShowNum = _props$isShowNum === void 0 ? true : _props$isShowNum
|
|
161
|
-
|
|
162
|
-
var _fieldNames$title, _fieldNames$key, _fieldNames$children;
|
|
163
|
-
return {
|
|
164
|
-
title: (_fieldNames$title = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.title) !== null && _fieldNames$title !== void 0 ? _fieldNames$title : 'NAME',
|
|
165
|
-
key: (_fieldNames$key = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.key) !== null && _fieldNames$key !== void 0 ? _fieldNames$key : 'SOURCE_PATH',
|
|
166
|
-
children: (_fieldNames$children = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) !== null && _fieldNames$children !== void 0 ? _fieldNames$children : 'CHILDREN'
|
|
167
|
-
};
|
|
168
|
-
}, [fieldNames]);
|
|
169
|
-
|
|
170
|
-
/** 拖拽校验索引:记录每个节点的父节点 key,用于判断是否同级 */
|
|
98
|
+
isShowNum = _props$isShowNum === void 0 ? true : _props$isShowNum,
|
|
99
|
+
treeProperties = props.treeProperties;
|
|
171
100
|
var parentMap = useMemo(function () {
|
|
172
|
-
return buildParentMap(treeData
|
|
173
|
-
}, [treeData
|
|
101
|
+
return buildParentMap(treeData);
|
|
102
|
+
}, [treeData]);
|
|
174
103
|
var treeDataResolved = useMemo(function () {
|
|
175
|
-
return injectSectionClassName(treeData
|
|
176
|
-
}, [treeData
|
|
177
|
-
|
|
178
|
-
/** 仅允许同父级节点互拖;允许落到节点前/节点本体/节点后(用于支持拖到同级最前) */
|
|
104
|
+
return injectSectionClassName(treeData);
|
|
105
|
+
}, [treeData]);
|
|
179
106
|
var allowDropSibling = useCallback(function (_ref) {
|
|
180
107
|
var dragNode = _ref.dragNode,
|
|
181
108
|
dropNode = _ref.dropNode;
|
|
182
|
-
|
|
183
|
-
var dropKey = String(dropNode.key);
|
|
184
|
-
return parentMap.get(dragKey) === parentMap.get(dropKey);
|
|
109
|
+
return parentMap.get(String(dragNode.key)) === parentMap.get(String(dropNode.key));
|
|
185
110
|
}, [parentMap]);
|
|
186
|
-
|
|
187
|
-
// allowDropProp 传入时,覆盖默认同级规则
|
|
188
111
|
var mergedAllowDrop = allowDropProp !== null && allowDropProp !== void 0 ? allowDropProp : siblingDragOnly ? allowDropSibling : undefined;
|
|
189
112
|
var enableDrag = Boolean(onDrop || onSortedDataChange);
|
|
190
113
|
var handleDrop = useCallback(function (info) {
|
|
@@ -194,101 +117,79 @@ export default function LabClassifyTree(props) {
|
|
|
194
117
|
onDrop === null || onDrop === void 0 || onDrop(info);
|
|
195
118
|
return;
|
|
196
119
|
}
|
|
197
|
-
var nextTreeData = cloneTree(treeData
|
|
198
|
-
var dragFound = findNodeAndParentList(nextTreeData, dragKey
|
|
199
|
-
var dropFound = findNodeAndParentList(nextTreeData, dropKey
|
|
120
|
+
var nextTreeData = cloneTree(treeData);
|
|
121
|
+
var dragFound = findNodeAndParentList(nextTreeData, dragKey);
|
|
122
|
+
var dropFound = findNodeAndParentList(nextTreeData, dropKey);
|
|
200
123
|
if (!dragFound || !dropFound) {
|
|
201
124
|
onDrop === null || onDrop === void 0 || onDrop(info);
|
|
202
125
|
return;
|
|
203
126
|
}
|
|
204
|
-
|
|
205
|
-
// 仅处理同级排序,避免跨父级拖拽带来结构变化。
|
|
206
127
|
if (dragFound.parentList !== dropFound.parentList) {
|
|
207
128
|
onDrop === null || onDrop === void 0 || onDrop(info);
|
|
208
129
|
return;
|
|
209
130
|
}
|
|
210
131
|
var siblingList = dragFound.parentList;
|
|
211
132
|
siblingList.splice(dragFound.index, 1);
|
|
212
|
-
|
|
213
|
-
// 支持落到节点本体:按“插入到该节点之前”处理。
|
|
214
133
|
var insertIndex = dropFound.index;
|
|
215
134
|
if (info.dropToGap) {
|
|
216
135
|
var dropPos = info.node.pos.split('-');
|
|
217
136
|
var relativeDropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
|
|
218
137
|
insertIndex = relativeDropPosition === -1 ? dropFound.index : dropFound.index + 1;
|
|
219
138
|
}
|
|
220
|
-
|
|
221
|
-
// 处理“后面的节点拖到前面节点”时的索引偏移。
|
|
222
139
|
if (dragFound.index < insertIndex) {
|
|
223
140
|
insertIndex -= 1;
|
|
224
141
|
}
|
|
225
142
|
siblingList.splice(insertIndex, 0, dragFound.node);
|
|
226
143
|
onSortedDataChange === null || onSortedDataChange === void 0 || onSortedDataChange(nextTreeData, info);
|
|
227
144
|
onDrop === null || onDrop === void 0 || onDrop(info);
|
|
228
|
-
}, [onDrop, onSortedDataChange,
|
|
145
|
+
}, [onDrop, onSortedDataChange, treeData]);
|
|
229
146
|
return /*#__PURE__*/React.createElement("div", {
|
|
230
147
|
className: "cit-content"
|
|
231
|
-
}, /*#__PURE__*/React.createElement(Tree, {
|
|
148
|
+
}, /*#__PURE__*/React.createElement(Tree, _extends({}, treeProperties, {
|
|
232
149
|
blockNode: true,
|
|
233
150
|
draggable: enableDrag ? {
|
|
234
151
|
icon: false
|
|
235
152
|
} : false,
|
|
236
153
|
allowDrop: enableDrag ? mergedAllowDrop : undefined,
|
|
237
|
-
fieldNames:
|
|
154
|
+
fieldNames: {
|
|
155
|
+
title: 'NAME',
|
|
156
|
+
key: 'SOURCE_PATH',
|
|
157
|
+
children: 'CHILDREN'
|
|
158
|
+
},
|
|
238
159
|
treeData: treeDataResolved,
|
|
239
160
|
expandedKeys: expandedKeys,
|
|
240
161
|
selectedKeys: selectedKeys,
|
|
241
|
-
|
|
242
|
-
defaultSelectedKeys: defaultSelectedKeys,
|
|
243
|
-
onExpand: function onExpand(keys) {
|
|
244
|
-
return _onExpand(keys);
|
|
245
|
-
},
|
|
162
|
+
onExpand: onExpand,
|
|
246
163
|
onSelect: function onSelect(keys, info) {
|
|
247
164
|
return _onSelect(keys, info);
|
|
248
165
|
},
|
|
249
166
|
onDrop: enableDrag ? handleDrop : undefined,
|
|
250
167
|
titleRender: function titleRender(nodeData) {
|
|
251
|
-
var
|
|
252
|
-
var
|
|
253
|
-
var
|
|
254
|
-
var
|
|
255
|
-
|
|
256
|
-
var isLeaf = !((_getNodeChildren2 = getNodeChildren(n, resolvedFieldNames)) !== null && _getNodeChildren2 !== void 0 && _getNodeChildren2.length);
|
|
257
|
-
var nodeType = getNodeMetaValue(nodeMeta, ['NODE_TYPE']);
|
|
258
|
-
var countValue = getNodeMetaValue(nodeMeta, ['NUM']);
|
|
259
|
-
var levelIcon = isFirstLevel && firstLevelIcon !== undefined ? typeof firstLevelIcon === 'function' ? firstLevelIcon(nodeMeta) : firstLevelIcon : null;
|
|
168
|
+
var _node$CHILDREN2, _node$SOURCE;
|
|
169
|
+
var node = nodeData;
|
|
170
|
+
var isFirstLevel = node.level === 1;
|
|
171
|
+
var isLeaf = !((_node$CHILDREN2 = node.CHILDREN) !== null && _node$CHILDREN2 !== void 0 && _node$CHILDREN2.length);
|
|
172
|
+
var hasBullet = ((_node$SOURCE = node.SOURCE) === null || _node$SOURCE === void 0 ? void 0 : _node$SOURCE.TYPE) === 'childTemplate';
|
|
260
173
|
return /*#__PURE__*/React.createElement("span", {
|
|
261
174
|
className: "cit-tree-title-row"
|
|
262
|
-
},
|
|
175
|
+
}, isFirstLevel && firstLevelIcon && isLeaf && /*#__PURE__*/React.createElement("span", {
|
|
263
176
|
className: "cit-first-level-icon"
|
|
264
|
-
},
|
|
177
|
+
}, firstLevelIcon), hasBullet && /*#__PURE__*/React.createElement("span", {
|
|
265
178
|
className: "cit-leaf-bullet",
|
|
266
179
|
"aria-hidden": true
|
|
267
180
|
}), /*#__PURE__*/React.createElement("span", {
|
|
268
|
-
className:
|
|
269
|
-
},
|
|
181
|
+
className: 'cit-tree-title-text'
|
|
182
|
+
}, node.NAME), /*#__PURE__*/React.createElement("span", {
|
|
270
183
|
className: "cit-tree-title-tail"
|
|
271
|
-
},
|
|
272
|
-
trigger: ['contextMenu'],
|
|
273
|
-
menu: {
|
|
274
|
-
items: contextMenuItems !== null && contextMenuItems !== void 0 ? contextMenuItems : DEFAULT_CONTEXT_MENU_ITEMS,
|
|
275
|
-
onClick: function onClick(_ref3) {
|
|
276
|
-
var key = _ref3.key;
|
|
277
|
-
return onContextMenuClick === null || onContextMenuClick === void 0 ? void 0 : onContextMenuClick(String(key), nodeMeta);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
281
|
-
className: "cit-section-menu",
|
|
282
|
-
role: "button",
|
|
283
|
-
title: "\u53F3\u952E\u6253\u5F00\u83DC\u5355"
|
|
284
|
-
}, /*#__PURE__*/React.createElement(UnorderedListOutlined, null))), countValue !== undefined && countValue !== null && isShowNum && /*#__PURE__*/React.createElement("span", {
|
|
184
|
+
}, node.NUM != null && isShowNum ? /*#__PURE__*/React.createElement("span", {
|
|
285
185
|
className: "cit-count-badge"
|
|
286
|
-
},
|
|
186
|
+
}, node.NUM) : null));
|
|
287
187
|
},
|
|
288
188
|
switcherIcon: function switcherIcon(p) {
|
|
289
|
-
var
|
|
189
|
+
var _selectedKeys$some;
|
|
190
|
+
var isSelected = (_selectedKeys$some = selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.some(function (k) {
|
|
290
191
|
return String(k) === String(p.eventKey);
|
|
291
|
-
});
|
|
192
|
+
})) !== null && _selectedKeys$some !== void 0 ? _selectedKeys$some : false;
|
|
292
193
|
return /*#__PURE__*/React.createElement(Iconfont, {
|
|
293
194
|
type: "icon-zhankai",
|
|
294
195
|
style: {
|
|
@@ -298,5 +199,5 @@ export default function LabClassifyTree(props) {
|
|
|
298
199
|
}
|
|
299
200
|
});
|
|
300
201
|
}
|
|
301
|
-
}));
|
|
202
|
+
})));
|
|
302
203
|
}
|
|
@@ -1,48 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { DataNode } from 'antd/es/tree';
|
|
1
|
+
import type { TreeProps } from 'antd';
|
|
3
2
|
import type { Key, ReactNode } from 'react';
|
|
4
|
-
/** 分类树节点(含右侧计数);一级节点设 `level: 1` */
|
|
5
|
-
export type LabClassifyTreeNode = DataNode & {
|
|
6
|
-
NAME?: ReactNode;
|
|
7
|
-
SOURCE_PATH?: Key;
|
|
8
|
-
CHILDREN?: LabClassifyTreeNode[];
|
|
9
|
-
NUM?: number;
|
|
10
|
-
NODE_TYPE?: string;
|
|
11
|
-
/** 节点层级;一级节点为 1 */
|
|
12
|
-
level?: number;
|
|
13
|
-
SOURCE?: Record<string, any>;
|
|
14
|
-
};
|
|
15
3
|
export interface LabClassifyTreeProps {
|
|
16
|
-
treeData:
|
|
17
|
-
expandedKeys
|
|
18
|
-
selectedKeys
|
|
19
|
-
|
|
20
|
-
defaultSelectedKeys?: Key[];
|
|
21
|
-
onExpand: (expandedKeys: Key[]) => void;
|
|
4
|
+
treeData: any[];
|
|
5
|
+
expandedKeys?: Key[];
|
|
6
|
+
selectedKeys?: Key[];
|
|
7
|
+
onExpand?: (expandedKeys: Key[]) => void;
|
|
22
8
|
onSelect: (selectedKeys: Key[], info: Parameters<NonNullable<TreeProps['onSelect']>>[1]) => void;
|
|
23
9
|
/** 拖拽完成回调(原始事件);传入时开启拖拽(无抓手图标) */
|
|
24
10
|
onDrop?: TreeProps['onDrop'];
|
|
25
11
|
/** 同级排序完成后返回最新树数据(建议用于调接口或更新外层状态) */
|
|
26
|
-
onSortedDataChange?: (nextTreeData:
|
|
12
|
+
onSortedDataChange?: (nextTreeData: any[], info: Parameters<NonNullable<TreeProps['onDrop']>>[0]) => void;
|
|
27
13
|
/**
|
|
28
|
-
*
|
|
14
|
+
* 仅允许同级(同父节点下)排序;可落在节点前后或节点本体(可用于”插到该同级之前”)
|
|
29
15
|
* @default true
|
|
30
16
|
*/
|
|
31
17
|
siblingDragOnly?: boolean;
|
|
32
18
|
/** 完全自定义投放规则;传入时覆盖 siblingDragOnly 的默认 allowDrop */
|
|
33
19
|
allowDrop?: TreeProps['allowDrop'];
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 一级(level=1)节点标题前的图标插槽,默认不渲染;传入函数时可按节点定制
|
|
38
|
-
*/
|
|
39
|
-
firstLevelIcon?: ReactNode | ((node: LabClassifyTreeNode) => ReactNode);
|
|
40
|
-
/** 一级节点右键菜单项(默认:新增/编辑/删除) */
|
|
41
|
-
contextMenuItems?: MenuProps['items'];
|
|
42
|
-
/** 一级节点右键菜单点击回调 */
|
|
43
|
-
onContextMenuClick?: (menuKey: string, node: LabClassifyTreeNode) => void;
|
|
44
|
-
/** 节点类型,设置是否显示小圆点方块 */
|
|
45
|
-
nodeTypes?: string[];
|
|
20
|
+
/** 一级(level=1)节点标题前的图标插槽 */
|
|
21
|
+
firstLevelIcon?: ReactNode;
|
|
46
22
|
/** 是否显示计数 */
|
|
47
23
|
isShowNum?: boolean;
|
|
24
|
+
/** 透传 antd Tree 属性 */
|
|
25
|
+
treeProperties?: TreeProps;
|
|
48
26
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { TreeProps } from 'antd';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import './style.less';
|
|
3
|
-
export interface ILabOperateTree {
|
|
4
|
+
export interface ILabOperateTree extends Omit<TreeProps<any>, 'onSelect'> {
|
|
4
5
|
operateType: 'title' | 'icon' | 'null';
|
|
5
6
|
showLine?: boolean;
|
|
6
7
|
checkedKeys?: string[];
|