bee-front-components 1.0.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.
Files changed (92) hide show
  1. package/config/config.ts +28 -0
  2. package/lib/assets/images/empty.png +0 -0
  3. package/lib/components/BaseModal/index.d.ts +41 -0
  4. package/lib/components/BaseModal/index.js +133 -0
  5. package/lib/components/BaseModal/index.module.less +66 -0
  6. package/lib/components/Buttons/Button.d.ts +17 -0
  7. package/lib/components/Buttons/Button.js +34 -0
  8. package/lib/components/Buttons/ButtonPermission.d.ts +18 -0
  9. package/lib/components/Buttons/ButtonPermission.js +34 -0
  10. package/lib/components/Buttons/index.d.ts +3 -0
  11. package/lib/components/Buttons/index.js +3 -0
  12. package/lib/components/Buttons/index.module.less +21 -0
  13. package/lib/components/ContentHeader/index.d.ts +17 -0
  14. package/lib/components/ContentHeader/index.js +22 -0
  15. package/lib/components/ContentHeader/index.module.less +14 -0
  16. package/lib/components/Empty/index.d.ts +17 -0
  17. package/lib/components/Empty/index.js +23 -0
  18. package/lib/components/Empty/index.module.less +15 -0
  19. package/lib/components/ExcelExport/index.d.ts +28 -0
  20. package/lib/components/ExcelExport/index.js +60 -0
  21. package/lib/components/ExcelExport/index.module.less +61 -0
  22. package/lib/components/Modal/index.d.ts +26 -0
  23. package/lib/components/Modal/index.js +191 -0
  24. package/lib/components/Modal/index.module.less +79 -0
  25. package/lib/components/PageHeader/index.d.ts +43 -0
  26. package/lib/components/PageHeader/index.js +72 -0
  27. package/lib/components/PageHeader/index.module.less +38 -0
  28. package/lib/components/PdfViewer/index.d.ts +49 -0
  29. package/lib/components/PdfViewer/index.js +699 -0
  30. package/lib/components/QueryBar/TableQueryBar.d.ts +32 -0
  31. package/lib/components/QueryBar/TableQueryBar.js +115 -0
  32. package/lib/components/QueryBar/index.d.ts +25 -0
  33. package/lib/components/QueryBar/index.js +102 -0
  34. package/lib/components/QueryBar/index.module.less +58 -0
  35. package/lib/components/RemainDay/index.d.ts +22 -0
  36. package/lib/components/RemainDay/index.js +47 -0
  37. package/lib/components/RemainDay/index.module.less +42 -0
  38. package/lib/components/Scanner/hooks/useKeyboardScanner.d.ts +14 -0
  39. package/lib/components/Scanner/hooks/useKeyboardScanner.js +95 -0
  40. package/lib/components/Scanner/index.d.ts +60 -0
  41. package/lib/components/Scanner/index.js +318 -0
  42. package/lib/components/Scanner/index.module.less +264 -0
  43. package/lib/components/Scanner/utils/device.d.ts +2 -0
  44. package/lib/components/Scanner/utils/device.js +18 -0
  45. package/lib/components/StatusTab/index.d.ts +36 -0
  46. package/lib/components/StatusTab/index.js +118 -0
  47. package/lib/components/StatusTab/index.module.less +20 -0
  48. package/lib/components/StatusTag/index.d.ts +32 -0
  49. package/lib/components/StatusTag/index.js +142 -0
  50. package/lib/components/StatusTag/index.module.less +37 -0
  51. package/lib/components/StepProgress/index.d.ts +36 -0
  52. package/lib/components/StepProgress/index.js +84 -0
  53. package/lib/components/StepProgress/index.module.less +180 -0
  54. package/lib/components/Table/index.d.ts +44 -0
  55. package/lib/components/Table/index.js +135 -0
  56. package/lib/components/Table/index.module.less +24 -0
  57. package/lib/components/TableOperationColumn/index.d.ts +45 -0
  58. package/lib/components/TableOperationColumn/index.js +205 -0
  59. package/lib/components/TableOperationColumn/index.module.less +22 -0
  60. package/lib/components/Tabs/TabGroup.d.ts +9 -0
  61. package/lib/components/Tabs/TabGroup.js +12 -0
  62. package/lib/components/Tabs/TabPane.d.ts +9 -0
  63. package/lib/components/Tabs/TabPane.js +12 -0
  64. package/lib/components/Tabs/Tabs.d.ts +23 -0
  65. package/lib/components/Tabs/Tabs.js +42 -0
  66. package/lib/components/Tabs/index.d.ts +4 -0
  67. package/lib/components/Tabs/index.js +4 -0
  68. package/lib/components/Tabs/index.module.less +20 -0
  69. package/lib/components/Upload/BatchUpload/index.d.ts +42 -0
  70. package/lib/components/Upload/BatchUpload/index.js +140 -0
  71. package/lib/components/Upload/BatchUpload/index.module.less +10 -0
  72. package/lib/components/Upload/DraggerUpload/index.d.ts +42 -0
  73. package/lib/components/Upload/DraggerUpload/index.js +142 -0
  74. package/lib/components/Upload/DraggerUpload/index.module.less +30 -0
  75. package/lib/components/Upload/FileUpload.d.ts +36 -0
  76. package/lib/components/Upload/FileUpload.js +122 -0
  77. package/lib/components/Upload/index.d.ts +4 -0
  78. package/lib/components/Upload/index.js +4 -0
  79. package/lib/components/VipFlag/index.d.ts +10 -0
  80. package/lib/components/VipFlag/index.js +23 -0
  81. package/lib/components/VipFlag/index.module.less +20 -0
  82. package/lib/typings/blank.d.ts +0 -0
  83. package/lib/typings.d.ts +3 -0
  84. package/lib/utils/const.d.ts +21 -0
  85. package/lib/utils/const.js +22 -0
  86. package/lib/utils/index.d.ts +95 -0
  87. package/lib/utils/index.js +319 -0
  88. package/lib/utils/menuTab.d.ts +60 -0
  89. package/lib/utils/menuTab.js +122 -0
  90. package/lib/utils/utils.d.ts +61 -0
  91. package/lib/utils/utils.js +270 -0
  92. package/package.json +41 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @name 表格搜索栏
3
+ * @description 用于通用性表格进行筛选搜索
4
+ * @param {TableQueryBarHookProps & TableQueryBarHookCustomProps} 该组件所用参数与choerodon UI组件中Table的queryBar参数一致
5
+ * @param {React.ReactNode} extra 表格头部额外内容(默认置于右侧)
6
+ * @param {boolean} isShowDivider 是否显示分割线
7
+ * @param {string} dividerClass 分割线自定义样式
8
+ * @param {React.ReactNode} customHeader 自定义表格头部操作区域
9
+ * @author czy
10
+ */
11
+ import React from "react";
12
+ import { LabelAlign } from "choerodon-ui/pro/lib/form/enum";
13
+ import type { TableQueryBarHookProps, TableQueryBarHookCustomProps } from "choerodon-ui/pro/lib/table/Table";
14
+ type ITableQueryBarProps = TableQueryBarHookProps & TableQueryBarHookCustomProps;
15
+ export interface IProps extends ITableQueryBarProps {
16
+ /** 表格头部额外内容(默认置于右侧) */
17
+ extra?: React.ReactNode;
18
+ /** 自定义表格头部操作区域 */
19
+ customHeader?: React.ReactNode;
20
+ /** 是否显示分割线 */
21
+ isShowDivider?: boolean;
22
+ /** 分割线自定义样式 */
23
+ dividerClass?: string;
24
+ /** 是否显示展开收起按钮 */
25
+ isShowCollapseBtn?: boolean;
26
+ /** 标签对齐方式 */
27
+ labelAlign?: LabelAlign;
28
+ /** 查询按钮样式 */
29
+ queryButtonStyle?: React.CSSProperties;
30
+ }
31
+ declare const TableQueryBar: (props: IProps) => React.JSX.Element;
32
+ export default TableQueryBar;
@@ -0,0 +1,115 @@
1
+ import _Form from "@hzero-front-ui/c7n-ui/lib/FormPro";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ /**
4
+ * @name 表格搜索栏
5
+ * @description 用于通用性表格进行筛选搜索
6
+ * @param {TableQueryBarHookProps & TableQueryBarHookCustomProps} 该组件所用参数与choerodon UI组件中Table的queryBar参数一致
7
+ * @param {React.ReactNode} extra 表格头部额外内容(默认置于右侧)
8
+ * @param {boolean} isShowDivider 是否显示分割线
9
+ * @param {string} dividerClass 分割线自定义样式
10
+ * @param {React.ReactNode} customHeader 自定义表格头部操作区域
11
+ * @author czy
12
+ */
13
+ import React, { useMemo, useState } from "react";
14
+ import classNames from "classnames";
15
+ import { LabelAlign, LabelLayout } from "choerodon-ui/pro/lib/form/enum";
16
+ import { ButtonColor, FuncType } from "choerodon-ui/pro/lib/button/enum";
17
+ import { Button } from "../Buttons";
18
+ import styles from "./index.module.less?modules";
19
+ const TableQueryBar = props => {
20
+ var _ref;
21
+ const extra = props.extra,
22
+ customHeader = props.customHeader,
23
+ isShowDivider = props.isShowDivider,
24
+ dividerClass = props.dividerClass,
25
+ queryFields = props.queryFields,
26
+ queryDataSet = props.queryDataSet,
27
+ _props$queryFieldsLim = props.queryFieldsLimit,
28
+ queryFieldsLimit = _props$queryFieldsLim === void 0 ? 3 : _props$queryFieldsLim,
29
+ dataSet = props.dataSet,
30
+ buttons = props.buttons,
31
+ _props$labelLayout = props.labelLayout,
32
+ labelLayout = _props$labelLayout === void 0 ? "horizontal" : _props$labelLayout,
33
+ _props$isShowCollapse = props.isShowCollapseBtn,
34
+ isShowCollapseBtn = _props$isShowCollapse === void 0 ? true : _props$isShowCollapse,
35
+ _props$labelAlign = props.labelAlign,
36
+ labelAlign = _props$labelAlign === void 0 ? "left" : _props$labelAlign,
37
+ _props$queryButtonSty = props.queryButtonStyle,
38
+ queryButtonStyle = _props$queryButtonSty === void 0 ? {} : _props$queryButtonSty;
39
+ const isShowOptBox = useMemo(() => !!customHeader || (buttons === null || buttons === void 0 ? void 0 : buttons.length) > 0 || !!extra, [customHeader, buttons, extra]); // 是否显示表格顶部操作区域
40
+ const _useState = useState(false),
41
+ _useState2 = _slicedToArray(_useState, 2),
42
+ showMore = _useState2[0],
43
+ setShowMore = _useState2[1]; // 是否显示更多
44
+
45
+ // 表格查询
46
+ function handleQuery() {
47
+ dataSet === null || dataSet === void 0 ? void 0 : dataSet.unSelectAll();
48
+ dataSet === null || dataSet === void 0 ? void 0 : dataSet.query();
49
+ }
50
+
51
+ // 查询重置
52
+ function handleReset() {
53
+ queryDataSet === null || queryDataSet === void 0 ? void 0 : queryDataSet.reset();
54
+ handleQuery();
55
+ }
56
+
57
+ // 点击展开或收起按钮
58
+
59
+ return /*#__PURE__*/React.createElement("div", {
60
+ className: styles.tableQueryBar
61
+ }, ((_ref = queryFields || []) === null || _ref === void 0 ? void 0 : _ref.length) > 0 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
62
+ className: styles.formContainer
63
+ }, /*#__PURE__*/React.createElement(_Form, {
64
+ className: styles.searchForm,
65
+ columns: queryFieldsLimit,
66
+ dataSet: queryDataSet,
67
+ labelLayout: labelLayout,
68
+ labelAlign: labelAlign,
69
+ useColon: false
70
+ }, !showMore && isShowCollapseBtn ? queryFields === null || queryFields === void 0 ? void 0 : queryFields.slice(0, queryFieldsLimit) : queryFields), /*#__PURE__*/React.createElement("div", {
71
+ className: styles.buttonContainer,
72
+ style: queryButtonStyle
73
+ }, /*#__PURE__*/React.createElement(Button, {
74
+ icon: "icon-biaogechaxun",
75
+ funcType: "raised",
76
+ className: styles.queryBtn,
77
+ dataSet: dataSet,
78
+ color: "primary",
79
+ onClick: handleQuery
80
+ }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
81
+ icon: "icon-biaogechongzhi",
82
+ funcType: "raised",
83
+ className: styles.resetBtn,
84
+ color: "default",
85
+ onClick: handleReset
86
+ }, "\u91CD\u7F6E"), isShowCollapseBtn && (queryFields === null || queryFields === void 0 ? void 0 : queryFields.length) > queryFieldsLimit && /*#__PURE__*/React.createElement(Button, {
87
+ className: styles.collapseBtn,
88
+ funcType: "link",
89
+ onClick: () => {
90
+ setShowMore(!showMore);
91
+ dataSet === null || dataSet === void 0 ? void 0 : dataSet.reset();
92
+ }
93
+ }, showMore ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "\u6536\u8D77"), /*#__PURE__*/React.createElement("i", {
94
+ className: "iconfont icon-shouqi",
95
+ style: {
96
+ marginLeft: 4,
97
+ fontSize: 12
98
+ }
99
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "\u5C55\u5F00"), /*#__PURE__*/React.createElement("i", {
100
+ className: "iconfont icon-gengduo",
101
+ style: {
102
+ marginLeft: 4,
103
+ fontSize: 12
104
+ }
105
+ }))))), isShowDivider && /*#__PURE__*/React.createElement("div", {
106
+ className: classNames(styles.divider, dividerClass)
107
+ })), isShowOptBox && /*#__PURE__*/React.createElement("div", {
108
+ className: styles.optBox
109
+ }, customHeader || /*#__PURE__*/React.createElement(React.Fragment, null, buttons && /*#__PURE__*/React.createElement("div", {
110
+ className: styles.btns
111
+ }, buttons), extra && /*#__PURE__*/React.createElement("div", {
112
+ className: styles.extra
113
+ }, extra))));
114
+ };
115
+ export default TableQueryBar;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @name 表格搜索栏
3
+ * @description 用于通用性表格进行筛选搜索
4
+ * @param {TableQueryBarHookProps & TableQueryBarHookCustomProps} 该组件所用参数与choerodon UI组件中Table的queryBar参数一致
5
+ * @param {React.ReactNode} extra 表格头部额外内容(默认置于右侧)
6
+ * @param {boolean} isShowDivider 是否显示分割线
7
+ * @param {string} dividerClass 分割线自定义样式
8
+ * @param {React.ReactNode} customHeader 自定义表格头部操作区域
9
+ * @author czy
10
+ */
11
+ import React from "react";
12
+ import type { TableQueryBarHookProps, TableQueryBarHookCustomProps } from "choerodon-ui/pro/lib/table/Table";
13
+ type ITableQueryBarProps = TableQueryBarHookProps & TableQueryBarHookCustomProps;
14
+ interface IProps extends ITableQueryBarProps {
15
+ /** 表格头部额外内容(默认置于右侧) */
16
+ extra?: React.ReactNode;
17
+ /** 自定义表格头部操作区域 */
18
+ customHeader?: React.ReactNode;
19
+ /** 是否显示分割线 */
20
+ isShowDivider?: boolean;
21
+ /** 分割线自定义样式 */
22
+ dividerClass?: string;
23
+ }
24
+ declare const TableQueryBar: (props: IProps) => React.JSX.Element;
25
+ export default TableQueryBar;
@@ -0,0 +1,102 @@
1
+ import _Button from "@hzero-front-ui/c7n-ui/lib/ButtonPro";
2
+ import _Form from "@hzero-front-ui/c7n-ui/lib/FormPro";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ /**
5
+ * @name 表格搜索栏
6
+ * @description 用于通用性表格进行筛选搜索
7
+ * @param {TableQueryBarHookProps & TableQueryBarHookCustomProps} 该组件所用参数与choerodon UI组件中Table的queryBar参数一致
8
+ * @param {React.ReactNode} extra 表格头部额外内容(默认置于右侧)
9
+ * @param {boolean} isShowDivider 是否显示分割线
10
+ * @param {string} dividerClass 分割线自定义样式
11
+ * @param {React.ReactNode} customHeader 自定义表格头部操作区域
12
+ * @author czy
13
+ */
14
+ import React, { useMemo, useState } from "react";
15
+ import classNames from "classnames";
16
+ import { LabelLayout } from "choerodon-ui/pro/lib/form/enum";
17
+ import { ButtonColor, FuncType } from "choerodon-ui/pro/lib/button/enum";
18
+ import styles from "./index.module.less?modules";
19
+ const TableQueryBar = props => {
20
+ var _ref;
21
+ const extra = props.extra,
22
+ customHeader = props.customHeader,
23
+ isShowDivider = props.isShowDivider,
24
+ dividerClass = props.dividerClass,
25
+ queryFields = props.queryFields,
26
+ queryDataSet = props.queryDataSet,
27
+ _props$queryFieldsLim = props.queryFieldsLimit,
28
+ queryFieldsLimit = _props$queryFieldsLim === void 0 ? 3 : _props$queryFieldsLim,
29
+ dataSet = props.dataSet,
30
+ buttons = props.buttons,
31
+ _props$labelLayout = props.labelLayout,
32
+ labelLayout = _props$labelLayout === void 0 ? "horizontal" : _props$labelLayout;
33
+ const isShowOptBox = useMemo(() => !!customHeader || (buttons === null || buttons === void 0 ? void 0 : buttons.length) > 0 || !!extra, [customHeader, buttons, extra]); // 是否显示表格顶部操作区域
34
+ const _useState = useState(false),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ showMore = _useState2[0],
37
+ setShowMore = _useState2[1]; // 是否显示更多
38
+
39
+ // 表格查询
40
+ function handleQuery() {
41
+ dataSet === null || dataSet === void 0 ? void 0 : dataSet.unSelectAll();
42
+ dataSet === null || dataSet === void 0 ? void 0 : dataSet.query();
43
+ }
44
+
45
+ // 查询重置
46
+ function handleReset() {
47
+ queryDataSet === null || queryDataSet === void 0 ? void 0 : queryDataSet.reset();
48
+ handleQuery();
49
+ }
50
+
51
+ // 点击展开或收起按钮
52
+
53
+ return /*#__PURE__*/React.createElement("div", {
54
+ className: styles.tableQueryBar
55
+ }, ((_ref = queryFields || []) === null || _ref === void 0 ? void 0 : _ref.length) > 0 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
56
+ className: styles.formContainer
57
+ }, /*#__PURE__*/React.createElement(_Form, {
58
+ className: styles.searchForm,
59
+ columns: queryFieldsLimit,
60
+ dataSet: queryDataSet,
61
+ labelLayout: labelLayout,
62
+ useColon: false
63
+ }, showMore ? queryFields : queryFields === null || queryFields === void 0 ? void 0 : queryFields.slice(0, queryFieldsLimit)), /*#__PURE__*/React.createElement("div", {
64
+ className: styles.buttonContainer
65
+ }, /*#__PURE__*/React.createElement(_Button, {
66
+ className: styles.queryBtn,
67
+ dataSet: dataSet,
68
+ color: "primary",
69
+ onClick: handleQuery
70
+ }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
71
+ className: styles.resetBtn,
72
+ onClick: handleReset
73
+ }, "\u91CD\u7F6E"), (queryFields === null || queryFields === void 0 ? void 0 : queryFields.length) > queryFieldsLimit && /*#__PURE__*/React.createElement(_Button, {
74
+ className: styles.collapseBtn,
75
+ funcType: "link",
76
+ onClick: () => {
77
+ setShowMore(!showMore);
78
+ dataSet === null || dataSet === void 0 ? void 0 : dataSet.reset();
79
+ }
80
+ }, showMore ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "\u6536\u8D77"), /*#__PURE__*/React.createElement("i", {
81
+ className: "iconfont icon-shouqi",
82
+ style: {
83
+ marginLeft: 4,
84
+ fontSize: 12
85
+ }
86
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "\u5C55\u5F00"), /*#__PURE__*/React.createElement("i", {
87
+ className: "iconfont icon-gengduo",
88
+ style: {
89
+ marginLeft: 4,
90
+ fontSize: 12
91
+ }
92
+ }))))), isShowDivider && /*#__PURE__*/React.createElement("div", {
93
+ className: classNames(styles.divider, dividerClass)
94
+ })), isShowOptBox && /*#__PURE__*/React.createElement("div", {
95
+ className: styles.optBox
96
+ }, customHeader || /*#__PURE__*/React.createElement(React.Fragment, null, buttons && /*#__PURE__*/React.createElement("div", {
97
+ className: styles.btns
98
+ }, buttons), extra && /*#__PURE__*/React.createElement("div", {
99
+ className: styles.extra
100
+ }, extra))));
101
+ };
102
+ export default TableQueryBar;
@@ -0,0 +1,58 @@
1
+ // 表格搜索框
2
+ .tableQueryBar {
3
+ :global {
4
+ .c7n-pro-field-label.c7n-pro-field-label.c7n-pro-field-label {
5
+ & > label,
6
+ & + td .c7n-pro-field-wrapper {
7
+ padding: 0 0.16rem 0.12rem 0 !important;
8
+ }
9
+ }
10
+ }
11
+ // 搜索框表单
12
+ .formContainer {
13
+ overflow-y: auto;
14
+ .flex(@align: flex-start, @wrap: nowrap);
15
+ width: 100%;
16
+ max-height: 1.36rem;
17
+ margin-bottom: 0.04rem; // 补齐距离下边框的16px间隔
18
+
19
+ .searchForm {
20
+ flex: 1;
21
+ }
22
+
23
+ .buttonContainer {
24
+ .flex(@justify: flex-end);
25
+ flex-shrink: 0;
26
+ // 内部按钮排列默认存在margin-left: var(--btn-group-spacing); 默认值0.1rem = 10px
27
+ gap: 0.06rem;
28
+ margin: 0 0 0.12rem 0.56rem;
29
+ padding: 0;
30
+ position: sticky;
31
+ top: 0px;
32
+ .queryBtn,
33
+ .resetBtn {
34
+ .flex;
35
+ width: 0.88rem;
36
+ height: 0.36rem;
37
+ }
38
+ .collapseBtn {
39
+ .flex;
40
+ }
41
+ }
42
+ }
43
+ .divider {
44
+ width: 100%;
45
+ height: 0.01rem;
46
+ background-color: @borderColor;
47
+ margin-bottom: 0.16rem;
48
+ }
49
+ // 表格顶部操作区域
50
+ .optBox {
51
+ .flex(@justify: space-between);
52
+ width: 100%;
53
+ margin-bottom: 0.16rem;
54
+ .btns {
55
+ .flex(@justify: flex-start, @wrap: nowrap);
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @name 显示剩余时间
3
+ * @description 用于自定义标识显示某项任务的剩余天数
4
+ * @param { string } className 自定义外层类名
5
+ * @param { 'text' | 'tag' } mode 展示形式 'text'以纯文本形式展示 'tag'以标签形式展示于表格中
6
+ * @param { number | string } value 剩余时间
7
+ * @param { boolean } isShowZero 是否显示剩余0天
8
+ * @author lichen
9
+ */
10
+ import React from "react";
11
+ interface IProps {
12
+ /** 自定义外层类名 */
13
+ className?: string;
14
+ /** 展示形式 'text'以纯文本形式展示 'tag'以标签形式展示于表格中 */
15
+ mode?: "text" | "tag";
16
+ /** 剩余时间 */
17
+ value: number | string;
18
+ /** 是否显示剩余0天 */
19
+ isShowZero?: boolean;
20
+ }
21
+ declare const RemainDay: React.FC<IProps>;
22
+ export default RemainDay;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @name 显示剩余时间
3
+ * @description 用于自定义标识显示某项任务的剩余天数
4
+ * @param { string } className 自定义外层类名
5
+ * @param { 'text' | 'tag' } mode 展示形式 'text'以纯文本形式展示 'tag'以标签形式展示于表格中
6
+ * @param { number | string } value 剩余时间
7
+ * @param { boolean } isShowZero 是否显示剩余0天
8
+ * @author lichen
9
+ */
10
+ import React, { useCallback } from "react";
11
+ import classNames from "classnames";
12
+ import styles from "./index.module.less?modules";
13
+ const RemainDay = props => {
14
+ const className = props.className,
15
+ _props$mode = props.mode,
16
+ mode = _props$mode === void 0 ? "tag" : _props$mode,
17
+ _props$value = props.value,
18
+ value = _props$value === void 0 ? 0 : _props$value,
19
+ isShowZero = props.isShowZero;
20
+ const RemainTag = useCallback(() => {
21
+ if (!isShowZero) {
22
+ return null;
23
+ }
24
+ const remainDay = Number(value) || 0;
25
+ // 表格中标签显示
26
+ if (mode === "tag") {
27
+ if (remainDay < 0) {
28
+ return /*#__PURE__*/React.createElement("span", {
29
+ className: styles.delayTag
30
+ }, "\u8D85\u671F", -remainDay, "\u5929");
31
+ }
32
+ return /*#__PURE__*/React.createElement("span", {
33
+ className: remainDay <= 5 ? styles.warnTag : styles.normalTag
34
+ }, "\u5269", remainDay, "\u5929");
35
+ }
36
+ // 普通文字显示
37
+ return remainDay < 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, "\u8D85\u671F", /*#__PURE__*/React.createElement("span", {
38
+ className: styles.delayText
39
+ }, -remainDay), "\u5929") : /*#__PURE__*/React.createElement(React.Fragment, null, "\u8FD8\u5269", /*#__PURE__*/React.createElement("span", {
40
+ className: remainDay <= 5 ? styles.warnText : styles.normalText
41
+ }, remainDay), "\u5929");
42
+ }, [value, mode]);
43
+ return /*#__PURE__*/React.createElement("div", {
44
+ className: classNames(styles.remainDayWrap, className)
45
+ }, /*#__PURE__*/React.createElement(RemainTag, null));
46
+ };
47
+ export default RemainDay;
@@ -0,0 +1,42 @@
1
+ // 剩余时间组件样式
2
+ .remainTag() {
3
+ padding: 2px 8px;
4
+ border-radius: 4px;
5
+ }
6
+
7
+ .remainDayWrap {
8
+ color: @primaryWord;
9
+ }
10
+
11
+ // 逾期标签
12
+ .delayTag {
13
+ .remainTag;
14
+ color: @errorColor;
15
+ background-color: @errorLightColor;
16
+ }
17
+ .delayText {
18
+ font-weight: bold;
19
+ color: @errorColor;
20
+ }
21
+
22
+ // 警示标签
23
+ .warnTag {
24
+ .remainTag;
25
+ color: @warnColor;
26
+ background-color: @warnLightColor;
27
+ }
28
+ .warnText {
29
+ font-weight: bold;
30
+ color: @warnColor;
31
+ }
32
+
33
+ // 正常标签
34
+ .normalTag {
35
+ .remainTag;
36
+ color: @primaryColor;
37
+ background-color: @primaryLightColor;
38
+ }
39
+ .normalText {
40
+ font-weight: bold;
41
+ color: @successColor;
42
+ }
@@ -0,0 +1,14 @@
1
+ interface IUseKeyboardScannerOptions {
2
+ /** 是否启用扫码 该参数设置false后不会监听键盘 */
3
+ enabled?: boolean;
4
+ /** 单字符最大间隔 扫码枪通常输入较快 以此来区分是普通人工输入还是扫码枪输入 */
5
+ maxInterval?: number;
6
+ /** 最小扫码长度 */
7
+ minLength?: number;
8
+ /** 扫码结束键 */
9
+ endKey?: string;
10
+ /** 扫码成功的回调 */
11
+ onScan: (value: string) => void;
12
+ }
13
+ export declare function useKeyboardScanner(props: IUseKeyboardScannerOptions): void;
14
+ export {};
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @name 扫码枪扫码相关逻辑操作
3
+ */
4
+ import { useEffect, useRef } from "react";
5
+ // 扫码枪扫码逻辑
6
+ export function useKeyboardScanner(props) {
7
+ const _props$enabled = props.enabled,
8
+ enabled = _props$enabled === void 0 ? true : _props$enabled,
9
+ _props$maxInterval = props.maxInterval,
10
+ maxInterval = _props$maxInterval === void 0 ? 50 : _props$maxInterval,
11
+ _props$minLength = props.minLength,
12
+ minLength = _props$minLength === void 0 ? 1 : _props$minLength,
13
+ _props$endKey = props.endKey,
14
+ endKey = _props$endKey === void 0 ? "Enter" : _props$endKey,
15
+ onScan = props.onScan;
16
+ const bufferRef = useRef(""); // 字符缓冲区 存放扫码枪正在输入的字符串信息
17
+ const lastKeyTimeRef = useRef(null); // 记录上一次按键的时间戳,用来计算两次按键间隔
18
+ const timerRef = useRef(null); // 超时计时器 超时后没继续输入则清空缓冲区
19
+
20
+ // 状态重置 当识别完成、超时、关闭hook或组件卸载时清空全部状态与计时器
21
+ function reset() {
22
+ bufferRef.current = "";
23
+ lastKeyTimeRef.current = null;
24
+ if ((timerRef === null || timerRef === void 0 ? void 0 : timerRef.current) !== null) {
25
+ var _window;
26
+ (_window = window) === null || _window === void 0 ? void 0 : _window.clearTimeout(timerRef.current);
27
+ timerRef.current = null;
28
+ }
29
+ }
30
+ useEffect(() => {
31
+ // 关闭扫码监听,清空缓存,不绑定事件
32
+ if (!enabled) {
33
+ reset();
34
+ return;
35
+ }
36
+
37
+ // handleKeyDown 键盘按下事件
38
+ function handleKeyDown(event) {
39
+ var _window3;
40
+ const now = Date.now();
41
+ const currentKey = (event === null || event === void 0 ? void 0 : event.key) || "";
42
+ // 判断扫码结束(默认 Enter键)
43
+ if (currentKey === endKey) {
44
+ var _bufferRef$current;
45
+ const value = (_bufferRef$current = bufferRef.current) === null || _bufferRef$current === void 0 ? void 0 : _bufferRef$current.trim();
46
+ // 扫描识别到的字符长度大于最小长度则
47
+ if (value.length >= minLength) {
48
+ onScan(value);
49
+ }
50
+ reset();
51
+ return;
52
+ }
53
+
54
+ // 除此之外过滤掉Shift、Ctrl等功能类按键
55
+ if ((currentKey === null || currentKey === void 0 ? void 0 : currentKey.length) !== 1) {
56
+ return;
57
+ }
58
+
59
+ // 如果用户正在 Input/Textarea/Select 中手工输入默认不拦截
60
+ const target = event === null || event === void 0 ? void 0 : event.target;
61
+ if (target) {
62
+ var _target$tagName, _ref;
63
+ const tagName = target === null || target === void 0 ? void 0 : (_target$tagName = target.tagName) === null || _target$tagName === void 0 ? void 0 : _target$tagName.toLowerCase();
64
+ if ((_ref = ["input", "textarea", "select"]) !== null && _ref !== void 0 && _ref.includes(tagName) || target !== null && target !== void 0 && target.isContentEditable) {
65
+ return;
66
+ }
67
+ }
68
+
69
+ // 判断是不是连续快速输入
70
+ if ((lastKeyTimeRef === null || lastKeyTimeRef === void 0 ? void 0 : lastKeyTimeRef.current) !== null) {
71
+ const interval = now - (lastKeyTimeRef === null || lastKeyTimeRef === void 0 ? void 0 : lastKeyTimeRef.current);
72
+ // 如果间隔超过阈值则认为非扫码枪连续输入
73
+ if (interval > maxInterval) {
74
+ reset();
75
+ }
76
+ }
77
+ bufferRef.current += currentKey;
78
+ lastKeyTimeRef.current = now;
79
+
80
+ // 如果一定时间内没有继续输入则清空本次缓存
81
+ if (timerRef.current !== null) {
82
+ var _window2;
83
+ (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.clearTimeout(timerRef === null || timerRef === void 0 ? void 0 : timerRef.current);
84
+ }
85
+ timerRef.current = (_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.setTimeout(() => {
86
+ reset();
87
+ }, maxInterval + 30);
88
+ }
89
+ document.addEventListener("keydown", handleKeyDown);
90
+ return () => {
91
+ document.removeEventListener("keydown", handleKeyDown);
92
+ reset();
93
+ };
94
+ }, [props]);
95
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @name 扫码工具
3
+ * @description 用于通过扫码枪或摄像头识别二维码中的相关信息
4
+ * @param {ScannerMode} mode 扫码识别类型
5
+ * @param {boolean} enabled 是否启用扫码组件功能
6
+ * @param {boolean} closeAfterScan 是否在扫码成功后自动关闭摄像头 默认true
7
+ * @param {number} keyboardInterval 扫码枪单次输入最大间隔,单位ms 默认 50ms
8
+ * @param {number} minLength 扫码枪最小字符长度 默认为1
9
+ * @param {string} cameraTitle 摄像头标题
10
+ * @param {boolean} showScanArea 是否显示扫码框
11
+ * @param {boolean} continuous 扫码成功后是否允许继续扫描
12
+ * @param {boolean} showButton 是否显示扫码按钮 仅camera或auto模式有效
13
+ * @param {string} buttonText 扫码按钮文字
14
+ * @param {string} scanerTip 扫码提示文字
15
+ * @param {function} onScan 扫码成功回调
16
+ * @param {function} onError 扫码异常回调
17
+ * @param {function} onClose 摄像头关闭回调
18
+ * @author lichen
19
+ */
20
+ import React from "react";
21
+ export declare enum ScannerMode {
22
+ /** 自动扫码 识别当前如果为PC端则启用keyboard 如果Pad/手机则启用camera */
23
+ auto = "auto",
24
+ /** 使用扫码枪扫码 */
25
+ keyboard = "keyboard",
26
+ /** 使用摄像头扫码 */
27
+ camera = "camera"
28
+ }
29
+ interface IScannerProps {
30
+ /** 扫码模式 */
31
+ mode?: ScannerMode;
32
+ /** 是否启用扫码组件功能 */
33
+ enabled?: boolean;
34
+ /** 是否在扫码成功后自动关闭摄像头 默认true */
35
+ closeAfterScan?: boolean;
36
+ /** 扫码枪单次输入最大间隔,单位ms 默认 50ms */
37
+ keyboardInterval?: number;
38
+ /** 扫码枪最小字符长度 默认3 */
39
+ minLength?: number;
40
+ /** 摄像头标题 */
41
+ cameraTitle?: string;
42
+ /** 是否显示扫码框 */
43
+ showScanArea?: boolean;
44
+ /** 扫码成功后是否允许继续扫描 */
45
+ continuous?: boolean;
46
+ /** 是否显示扫码按钮 仅camera或auto模式有效 */
47
+ showButton?: boolean;
48
+ /** 扫码按钮文字 */
49
+ buttonText?: string;
50
+ /** 扫码提示文字 */
51
+ scanerTip?: string;
52
+ /** 扫码成功回调 */
53
+ onScan?: (value: string) => void;
54
+ /** 扫码异常回调 */
55
+ onError?: (error: Error) => void;
56
+ /** 摄像头关闭回调 */
57
+ onClose?: () => void;
58
+ }
59
+ declare const Scanner: React.FC<IScannerProps>;
60
+ export default Scanner;