xh-lab-rc 0.0.4 → 0.0.5

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.
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import './style.less';
3
+ interface ILabDGTreeSelectProps {
4
+ defaultValue?: string;
5
+ placeholder?: string;
6
+ style?: object;
7
+ treeData: object[];
8
+ dropdownStyle?: object;
9
+ onSelect?: (value: any, node: any) => void;
10
+ }
11
+ declare const LabDGTreeSelect: ({ defaultValue, placeholder, style, treeData, dropdownStyle, onSelect, }: ILabDGTreeSelectProps) => React.JSX.Element;
12
+ export default LabDGTreeSelect;
@@ -0,0 +1,117 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ /*
8
+ * @Author: zy
9
+ * @Date: 2024-04-08 11:49:50
10
+ * @LastEditors:
11
+ * @LastEditTime:
12
+ * @Description: 科室/专业组树形下拉
13
+ */
14
+ import React, { useMemo, useState, useEffect } from 'react';
15
+ import { TreeSelect } from 'antd';
16
+ import { Iconfont } from "../components";
17
+ import "./style.less";
18
+ // 图标类型
19
+ var IconTypes = {
20
+ '1': 'icon-jian',
21
+ // 检验专业组
22
+ '2': 'icon-guan',
23
+ // 管理专业组
24
+ '4': 'icon-ke' // 科室
25
+ };
26
+
27
+ // Lab Department Group TreeSelect 实验室科室专业组树形下拉
28
+ var LabDGTreeSelect = function LabDGTreeSelect(_ref) {
29
+ var defaultValue = _ref.defaultValue,
30
+ _ref$placeholder = _ref.placeholder,
31
+ placeholder = _ref$placeholder === void 0 ? '科室/专业组' : _ref$placeholder,
32
+ _ref$style = _ref.style,
33
+ style = _ref$style === void 0 ? {
34
+ width: '100%'
35
+ } : _ref$style,
36
+ _ref$treeData = _ref.treeData,
37
+ treeData = _ref$treeData === void 0 ? [] : _ref$treeData,
38
+ _ref$dropdownStyle = _ref.dropdownStyle,
39
+ dropdownStyle = _ref$dropdownStyle === void 0 ? {
40
+ maxHeight: 400,
41
+ overflow: 'auto'
42
+ } : _ref$dropdownStyle,
43
+ onSelect = _ref.onSelect;
44
+ var _useState = useState(defaultValue || undefined),
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ value = _useState2[0],
47
+ setValue = _useState2[1];
48
+
49
+ // 切换选择时
50
+ var handleSelect = function handleSelect(value, node) {
51
+ setValue(value);
52
+ onSelect === null || onSelect === void 0 || onSelect(value, node);
53
+ };
54
+
55
+ // 清空时
56
+ var handClear = function handClear(val) {
57
+ if (!val) {
58
+ setValue(val);
59
+ onSelect === null || onSelect === void 0 || onSelect(val, '');
60
+ }
61
+ };
62
+ var getNewTreeData = function getNewTreeData(data) {
63
+ return data.map(function (item) {
64
+ // NODE_TYPE:'1'检验专业组,'2'管理专业组,'4'科室
65
+ // 如果子节点非科室、专业组,就清空
66
+ var clearChild = item.CHILDREN && item.CHILDREN.length > 0 && ['1', '2', '4'].indexOf(item.CHILDREN[0].NODE_TYPE) < 0;
67
+ var SOURCE_ID = item.SOURCE_ID,
68
+ NAME = item.NAME,
69
+ NODE_TYPE = item.NODE_TYPE,
70
+ NODE_TYPE_NAME = item.NODE_TYPE_NAME,
71
+ CHILDREN = item.CHILDREN,
72
+ NUM = item.NUM;
73
+ return {
74
+ key: SOURCE_ID,
75
+ title: NAME,
76
+ value: SOURCE_ID,
77
+ NODE_TYPE: NODE_TYPE,
78
+ NODE_TYPE_NAME: NODE_TYPE_NAME,
79
+ NUM: NUM,
80
+ icon: /*#__PURE__*/React.createElement(Iconfont, {
81
+ type: IconTypes[NODE_TYPE],
82
+ style: {
83
+ fontSize: '16px',
84
+ marginRight: '4px'
85
+ }
86
+ }),
87
+ children: clearChild ? [] : getNewTreeData(CHILDREN)
88
+ };
89
+ });
90
+ };
91
+
92
+ // 将得到的树数据,处理成需要的数据
93
+ var newTreeData = useMemo(function () {
94
+ return getNewTreeData(treeData);
95
+ }, [treeData]);
96
+ useEffect(function () {
97
+ if (defaultValue) {
98
+ setValue(defaultValue);
99
+ }
100
+ }, [defaultValue]);
101
+ return /*#__PURE__*/React.createElement(TreeSelect, {
102
+ showSearch: true,
103
+ allowClear: true,
104
+ treeIcon: true,
105
+ value: value,
106
+ style: style,
107
+ dropdownStyle: dropdownStyle,
108
+ treeData: newTreeData,
109
+ treeDefaultExpandAll: true,
110
+ onSelect: handleSelect,
111
+ onChange: handClear,
112
+ placeholder: placeholder,
113
+ treeNodeFilterProp: "title",
114
+ popupClassName: "lab-group-tree-select"
115
+ });
116
+ };
117
+ export default LabDGTreeSelect;
@@ -0,0 +1,16 @@
1
+ .lab-group-tree-select {
2
+ .ant-select-tree-list-holder-inner
3
+ .ant-select-tree-treenode
4
+ .ant-select-tree-node-content-wrapper {
5
+ width: 80% !important;
6
+ white-space: nowrap !important;
7
+ overflow: hidden !important;
8
+ text-overflow: ellipsis !important;
9
+ font-size: 12px !important;
10
+ }
11
+
12
+ .ant-select-tree-indent-unit {
13
+ width: 13px !important;
14
+ }
15
+ }
16
+
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as LabGTreeSelect } from './LabGTreeSelect';
2
2
  export { default as LabGroupTree } from './LabGroupTree';
3
+ export { default as LabDGTreeSelect } from './LabDGTreeSelect';
3
4
  export * from './LabGroupTree/typing';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as LabGTreeSelect } from "./LabGTreeSelect";
2
2
  export { default as LabGroupTree } from "./LabGroupTree";
3
+ export { default as LabDGTreeSelect } from "./LabDGTreeSelect";
3
4
  export * from "./LabGroupTree/typing";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xh-lab-rc",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": " A react library for xinhelab",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",