xh-lab-rc 0.0.3 → 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
+
@@ -0,0 +1,43 @@
1
+ window._iconfont_svg_string_4487114 = '<svg><symbol id="icon-ke" viewBox="0 0 1024 1024"><path d="M212.0192 631.2448a671.6416 671.6416 0 0 0 103.168-204.8H220.416V384h98.3552V295.8336q-46.08 4.7616-87.04 8.3968a310.3232 310.3232 0 0 0-11.9808-44.3904q116.3776-8.3968 231.0144-26.4192l15.36 44.3904q-54.016 7.2192-102.4 12.5952V384h95.488v42.5984H363.776v67.84l26.4192-24.0128q43.264 37.1712 79.8208 72.6016l-33.6384 34.2016q-38.4-43.1616-72.6016-75.008v293.9904h-45.0048v-270.592q-35.328 92.16-83.968 156.6208c-6.8096-16.384-14.3872-33.4336-22.784-50.9952z m216.576-31.7952l235.2128-20.8896V207.616h46.08v366.592l94.8224-8.96 3.584 43.1616-98.4064 9.0112v178.7904h-46.08v-174.592l-230.4 20.992z m35.84-154.2144l28.8256-30.72q68.352 53.4528 103.168 85.1968l-31.1808 36.608Q537.2416 506.88 464.5888 445.44z m35.4304-144.0256l27.7504-29.8496q66.56 51.2 107.9808 89.4464l-31.1808 35.3792a1328.5376 1328.5376 0 0 0-104.3968-94.976z" fill="#FF7D00" ></path><path d="M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m0 962.56a450.56 450.56 0 1 1 450.56-450.56 450.56 450.56 0 0 1-450.56 450.56z" fill="#FF7D00" ></path></symbol><symbol id="icon-guan" viewBox="0 0 1024 1024"><path d="M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m0 962.56a450.56 450.56 0 1 1 450.56-450.56 450.56 450.56 0 0 1-450.56 450.56z" fill="#3491FA" ></path><path d="M395.6224 375.6544q-22.784-30.0544-49.8176-61.44l26.9824-19.2H321.1776a465.92 465.92 0 0 1-76.8 77.4144q-11.9808-14.0288-29.952-33.3824a427.3664 427.3664 0 0 0 114.5856-137.4208h51.6096A565.8624 565.8624 0 0 1 348.16 258.048h176.0768v37.1712H380.0064q26.9824 26.112 51.2 53.4016zM239.0016 378.88h256.512q-10.5472-18.8928-25.6-41.984l41.3696-18.0224a567.2448 567.2448 0 0 1 35.84 60.0064h237.2608v92.7744h-46.08V417.6384H285.184v54.5792h-46.08z m67.7888 83.1488h369.6128v144.5888h-45.6192v-15.0016H353.28v45.6192h373.76v156.6208h-45.568v-22.8352H353.28v23.3984h-46.08z m323.9936 35.84H353.28v57.6h277.504z m50.432 175.2064H353.28V732.16h328.192z m-11.4176-298.1888a746.752 746.752 0 0 0-48.5888-61.44l26.112-18.6368h-50.7392a509.5424 509.5424 0 0 1-36.5568 51.6096 272.2816 272.2816 0 0 0-36.608-28.9792 395.3152 395.3152 0 0 0 70.1952-115.8144H645.12q-12.9024 29.7472-27.3408 56.32h191.744v37.1712h-153.6A670.1056 670.1056 0 0 1 705.1776 348.16z" fill="#3491FA" ></path></symbol><symbol id="icon-jian" viewBox="0 0 1024 1024"><path d="M212.5824 582.656q56.9856-91.136 87.04-213.0432H218.624v-39.5776h86.3744V209.408h41.984v120.6272h80.4352v39.5776H346.9824v88.832l26.4192-19.2q32.4096 39.5264 56.9856 74.3936l-32.9728 25.6a764.7232 764.7232 0 0 0-50.432-73.8304v330.24h-41.984V460.8q-30.72 106.752-73.216 174.592a340.1216 340.1216 0 0 0-19.2-52.736z m427.8272-368.64l-7.7824 12.032A483.4816 483.4816 0 0 0 814.08 411.0336q-16.1792 17.9712-33.024 40.96Q663.8592 369.0496 606.208 266.24q-71.68 115.8144-163.84 192.5632a299.0592 299.0592 0 0 0-34.2016-37.7856A610.048 610.048 0 0 0 583.68 214.2208zM412.416 726.6304h228.608q32.3072-87.6032 67.1744-223.1808l48.5888 13.7728Q716.8 643.8912 686.08 726.6304h112.64v42.5984H412.416z m29.3888-198.6048l41.4208-11.9808q22.7328 66.56 46.7968 162.6112l-44.4416 13.1584q-19.6608-89.3952-43.776-163.7888z m41.4208-98.4064h245.76v42.0352h-245.76z m72.6016 74.3936l41.984-10.24q23.4496 82.7904 39.0144 165.632l-45.0048 11.3152a1408 1408 0 0 0-35.9936-166.7072z" fill="#0CC6C2" ></path><path d="M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m0 962.56a450.56 450.56 0 1 1 450.56-450.56 450.56 450.56 0 0 1-450.56 450.56z" fill="#0CC6C2" ></path></symbol></svg>', function (n) {
2
+ var t = (t = document.getElementsByTagName("script"))[t.length - 1],
3
+ e = t.getAttribute("data-injectcss"),
4
+ t = t.getAttribute("data-disable-injectsvg");
5
+ if (!t) {
6
+ var i,
7
+ _l,
8
+ a,
9
+ o,
10
+ h,
11
+ d = function d(t, e) {
12
+ e.parentNode.insertBefore(t, e);
13
+ };
14
+ if (e && !n.__iconfont__svg__cssinject__) {
15
+ n.__iconfont__svg__cssinject__ = !0;
16
+ try {
17
+ document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>");
18
+ } catch (t) {
19
+ console && console.log(t);
20
+ }
21
+ }
22
+ i = function i() {
23
+ var t,
24
+ e = document.createElement("div");
25
+ e.innerHTML = n._iconfont_svg_string_4487114, (e = e.getElementsByTagName("svg")[0]) && (e.setAttribute("aria-hidden", "true"), e.style.position = "absolute", e.style.width = 0, e.style.height = 0, e.style.overflow = "hidden", e = e, (t = document.body).firstChild ? d(e, t.firstChild) : t.appendChild(e));
26
+ }, document.addEventListener ? ~["complete", "loaded", "interactive"].indexOf(document.readyState) ? setTimeout(i, 0) : (_l = function l() {
27
+ document.removeEventListener("DOMContentLoaded", _l, !1), i();
28
+ }, document.addEventListener("DOMContentLoaded", _l, !1)) : document.attachEvent && (a = i, o = n.document, h = !1, s(), o.onreadystatechange = function () {
29
+ "complete" == o.readyState && (o.onreadystatechange = null, c());
30
+ });
31
+ }
32
+ function c() {
33
+ h || (h = !0, a());
34
+ }
35
+ function s() {
36
+ try {
37
+ o.documentElement.doScroll("left");
38
+ } catch (t) {
39
+ return void setTimeout(s, 50);
40
+ }
41
+ c();
42
+ }
43
+ }(window);
@@ -1,6 +1,6 @@
1
1
  import { createFromIconfontCN } from '@ant-design/icons';
2
2
  var ICONFONT_URL = '//at.alicdn.com/t/c/font_4487114_zaprhqekg7s.js';
3
- // 生产环境使用public中的文件,开发环境使用线上环境以方便开发
3
+ // 生产环境使用本地的iconfont.js,开发环境使用线上环境以方便开发
4
4
  var Iconfont = createFromIconfontCN({
5
5
  scriptUrl: process.env.NODE_ENV === 'development' ? ICONFONT_URL : require("./iconfont.js") // 在 iconfont.cn 上生成
6
6
  });
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.3",
3
+ "version": "0.0.5",
4
4
  "description": " A react library for xinhelab",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",