@bit-sun/business-component 2.0.37 → 2.0.39-alpha.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 (153) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -4
  3. package/.gitlab-ci.yml +174 -174
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +77 -74
  7. package/README.md +27 -27
  8. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +4 -0
  9. package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +4 -0
  10. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +4 -0
  11. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +17 -0
  12. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +30 -0
  13. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +3 -0
  14. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +2 -0
  15. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +4 -0
  16. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +4 -0
  17. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +2 -0
  18. package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +8 -0
  19. package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +8 -0
  20. package/dist/components/Business/BsLayouts/index.d.ts +18 -0
  21. package/dist/components/Business/BsLayouts/service.d.ts +1 -0
  22. package/dist/components/Business/BsLayouts/utils.d.ts +22 -0
  23. package/dist/components/Business/DetailPageWrapper/utils.d.ts +1 -2
  24. package/dist/index.d.ts +4 -0
  25. package/dist/index.esm.js +11703 -44
  26. package/dist/index.js +11678 -11
  27. package/dist/utils/enumConfig.d.ts +10 -0
  28. package/dist/utils/utils.d.ts +2 -1
  29. package/docs/index.md +21 -21
  30. package/lib/assets/drag.svg +17 -17
  31. package/lib/assets/exportFail.svg +37 -37
  32. package/lib/assets/exportProcessing.svg +28 -28
  33. package/lib/assets/exportSuccess.svg +34 -34
  34. package/lib/assets/label_icon_bottom.svg +25 -25
  35. package/lib/assets/upExport.svg +22 -22
  36. package/package.json +70 -66
  37. package/src/assets/32.svg +28 -0
  38. package/src/assets/addIcon.svg +18 -0
  39. package/src/assets/allfunc.svg +28 -0
  40. package/src/assets/arrowRight.svg +25 -0
  41. package/src/assets/btn-delete.svg +29 -29
  42. package/src/assets/btn-edit.svg +19 -19
  43. package/src/assets/btn-more.svg +17 -17
  44. package/src/assets/btn-submit.svg +19 -19
  45. package/src/assets/caidan.svg +12 -0
  46. package/src/assets/close.svg +26 -26
  47. package/src/assets/closeicon.png +0 -0
  48. package/src/assets/drag.svg +17 -17
  49. package/src/assets/exportFail.svg +37 -37
  50. package/src/assets/exportProcessing.svg +28 -28
  51. package/src/assets/exportSuccess.svg +34 -34
  52. package/src/assets/fixed-left-active.svg +11 -11
  53. package/src/assets/fixed-left.svg +15 -15
  54. package/src/assets/fixed-right-active.svg +11 -11
  55. package/src/assets/fixed-right.svg +15 -15
  56. package/src/assets/guanbi.svg +16 -0
  57. package/src/assets/icon-quanping.svg +15 -15
  58. package/src/assets/icon-shezhi.svg +17 -17
  59. package/src/assets/label_icon_bottom.svg +25 -25
  60. package/src/assets/morentouxiang-32.svg +24 -0
  61. package/src/assets/right.png +0 -0
  62. package/src/assets/scanning.svg +24 -24
  63. package/src/assets/upExport.svg +22 -22
  64. package/src/assets/xinglan-icon-out.png +0 -0
  65. package/src/components/Business/AddSelectBusiness/index.md +41 -41
  66. package/src/components/Business/AddSelectBusiness/index.tsx +290 -290
  67. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -0
  68. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -0
  69. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -0
  70. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -0
  71. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +38 -0
  72. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +243 -0
  73. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +385 -0
  74. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +286 -0
  75. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +75 -0
  76. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +171 -0
  77. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +65 -0
  78. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +154 -0
  79. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +73 -0
  80. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +158 -0
  81. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -0
  82. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -0
  83. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -0
  84. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +162 -0
  85. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +76 -0
  86. package/src/components/Business/BsLayouts/index.less +80 -0
  87. package/src/components/Business/BsLayouts/index.tsx +1495 -0
  88. package/src/components/Business/BsLayouts/service.ts +11 -0
  89. package/src/components/Business/BsLayouts/utils.tsx +350 -0
  90. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  91. package/src/components/Business/BsSulaQueryTable/index.tsx +535 -534
  92. package/src/components/Business/BsSulaQueryTable/setting.tsx +818 -817
  93. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  94. package/src/components/Business/BsSulaQueryTable/utils.tsx +691 -690
  95. package/src/components/Business/CommodityEntry/index.md +70 -70
  96. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  97. package/src/components/Business/CommonAlert/index.tsx +23 -23
  98. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  99. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  100. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  101. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  102. package/src/components/Business/DetailPageWrapper/index.tsx +335 -324
  103. package/src/components/Business/DetailPageWrapper/utils.tsx +101 -111
  104. package/src/components/Business/HomePageWrapper/index.less +33 -33
  105. package/src/components/Business/HomePageWrapper/index.md +45 -45
  106. package/src/components/Business/HomePageWrapper/index.tsx +162 -150
  107. package/src/components/Business/SearchSelect/BusinessUtils.ts +1458 -1457
  108. package/src/components/Business/SearchSelect/common.ts +53 -53
  109. package/src/components/Business/SearchSelect/index.md +1137 -1137
  110. package/src/components/Business/SearchSelect/index.tsx +51 -51
  111. package/src/components/Business/SearchSelect/utils.ts +100 -99
  112. package/src/components/Business/StateFlow/index.less +130 -130
  113. package/src/components/Business/StateFlow/index.md +60 -60
  114. package/src/components/Business/StateFlow/index.tsx +29 -29
  115. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  116. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  117. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  118. package/src/components/Business/columnSettingTable/columnSetting.tsx +763 -762
  119. package/src/components/Business/columnSettingTable/index.less +247 -247
  120. package/src/components/Business/columnSettingTable/index.md +357 -357
  121. package/src/components/Business/columnSettingTable/index.tsx +226 -225
  122. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +234 -233
  123. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  124. package/src/components/Functional/AddSelect/index.less +367 -367
  125. package/src/components/Functional/AddSelect/index.md +122 -122
  126. package/src/components/Functional/AddSelect/index.tsx +962 -962
  127. package/src/components/Functional/BillEntry/index.less +371 -371
  128. package/src/components/Functional/BillEntry/index.md +39 -39
  129. package/src/components/Functional/BillEntry/index.tsx +613 -607
  130. package/src/components/Functional/DataImport/index.less +63 -63
  131. package/src/components/Functional/DataImport/index.md +44 -44
  132. package/src/components/Functional/DataImport/index.tsx +689 -689
  133. package/src/components/Functional/DataValidation/index.less +63 -63
  134. package/src/components/Functional/DataValidation/index.md +38 -38
  135. package/src/components/Functional/DataValidation/index.tsx +681 -681
  136. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  137. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  138. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  139. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  140. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  141. package/src/components/Functional/SearchSelect/index.less +115 -115
  142. package/src/components/Functional/SearchSelect/index.md +141 -141
  143. package/src/components/Functional/SearchSelect/index.tsx +812 -812
  144. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  145. package/src/components/Functional/TreeSearchSelect/index.tsx +149 -149
  146. package/src/index.ts +31 -30
  147. package/src/utils/CheckOneUser/index.md +39 -39
  148. package/src/utils/CheckOneUser/index.ts +51 -51
  149. package/src/utils/enumConfig.ts +10 -0
  150. package/src/utils/requestUtils.ts +33 -32
  151. package/src/utils/utils.ts +52 -22
  152. package/tsconfig.json +29 -29
  153. package/typings.d.ts +4 -4
@@ -0,0 +1,112 @@
1
+ // @ts-nocheck
2
+ import { List, Tooltip } from 'antd';
3
+ import React, { useEffect, useState, } from 'react';
4
+ import { Link, formatMessage } from 'umi';
5
+ import './index.less';
6
+ import classNames from 'classnames';
7
+ import right from '../../../../../assets/right.png';
8
+ import ENUM from '@/utils/enumConfig';
9
+ export type SiderTheme = 'light' | 'dark';
10
+
11
+ const DrawContent = ({onClose, itemPath}: any) => {
12
+ const routes = JSON.parse(localStorage.getItem(`customerMenu_${itemPath}_front`) || '[]');
13
+ const btnAuth = JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES) || '[]');
14
+ const [homepageData, sethomepageData]: any = useState([]);
15
+ const [routesData, setroutesData]: any = useState([]);
16
+
17
+ useEffect(() => {
18
+ const homepageDataList: any[] = []; //不含子集的菜单
19
+ const routesDataList: any[] = []; //含子集的菜单
20
+ routes.forEach(item => {
21
+ if (btnAuth.find((d: any) => d === item.code)) {
22
+ }
23
+ if (item.children) {
24
+ routesDataList.push(item);
25
+ } else {
26
+ homepageDataList.push(item);
27
+ }
28
+ })
29
+ sethomepageData(homepageDataList)
30
+ setroutesData(routesDataList)
31
+ }, []);
32
+
33
+ const renderChildItem = (child) => {
34
+ if (!child.hideInMenu && child.children) {
35
+ return (
36
+ <>
37
+ <List.Item style={{color: '#000', fontWeight: 'bold' }}>
38
+ {formatMessage({ id: `${child.locale}` })}
39
+ </List.Item>
40
+ {child.children.map((menuItem: any) => {
41
+ return renderChildItem(menuItem)
42
+ })}
43
+ </>
44
+ );
45
+ } else if (!child.hideInMenu && child.path) {
46
+ return (
47
+ <List.Item style={{ fontSize: '12px' }} className="allFuncOnMouserover">
48
+ <Link to={child.path} onClick={onClose}>
49
+ <Tooltip
50
+ title={formatMessage({ id: `${child.locale}` })}
51
+ >
52
+ {formatMessage({ id: `${child.locale}` }).length > 10
53
+ ? `${formatMessage({
54
+ id: `${child.name}`,
55
+ }).slice(0, 10)}...`
56
+ : formatMessage({ id: `${child.locale}` })}
57
+ </Tooltip>
58
+ <img className="allFuncOnMouseroverImg" src={right}></img>
59
+ </Link>
60
+ </List.Item>
61
+ );
62
+ }
63
+ }
64
+
65
+
66
+ return (
67
+ <div className='allfunc_drawcontent'>
68
+ <p className={'drawerWarp_p'}>您的当前权限可以使用以下功能:</p>
69
+ <div className={'drawerWarp'}>
70
+ {homepageData && homepageData.filter((d) => !d.hideInMenu).length > 0 && (
71
+ <List
72
+ className={classNames('allFunsList', 'allFunsListWarp')}
73
+ dataSource={homepageData}
74
+ renderItem={(child: any) => {
75
+ if (!child.hideInMenu && child.path) {
76
+ return (
77
+ <div className={classNames('allFunsListWarp')}>
78
+ <List.Item
79
+ className={classNames('allFuncOnMouserover')}
80
+ style={{ padding: '12px 24px' }}
81
+ >
82
+ <Link to={child.path} onClick={onClose}>
83
+ {formatMessage({ id: `${child.name}` })}
84
+ <img className="allFuncOnMouseroverImg" src={right}></img>
85
+ </Link>
86
+ </List.Item>
87
+ </div>
88
+ );
89
+ }
90
+ }}
91
+ />
92
+ )}
93
+ {routesData.map((item, index) => {
94
+ return (
95
+ <List
96
+ className={classNames('allFunsList', 'allFunsListWarp')}
97
+ style={{color: '#005CFF'}}
98
+ header={<b>{formatMessage({ id: `${item.name}` })}</b>}
99
+ bordered
100
+ dataSource={item.children}
101
+ renderItem={(child: any) => {
102
+ return renderChildItem(child)
103
+ }}
104
+ />
105
+ );
106
+ })}
107
+ </div>
108
+ </div>
109
+ )
110
+ }
111
+
112
+ export default DrawContent;
@@ -0,0 +1,153 @@
1
+
2
+
3
+ .menu {
4
+ .anticon {
5
+ margin-right: 8px;
6
+ }
7
+ .ant-dropdown-menu-item {
8
+ min-width: 160px;
9
+ }
10
+ }
11
+
12
+ .right {
13
+ display: flex;
14
+ float: right;
15
+ height: 48px;
16
+ margin-left: auto;
17
+ overflow: hidden;
18
+ .action {
19
+ display: flex;
20
+ align-items: center;
21
+ height: 48px;
22
+ padding: 0 12px;
23
+ cursor: pointer;
24
+ transition: all 0.3s;
25
+ > span {
26
+ vertical-align: middle;
27
+ }
28
+ &:hover {
29
+ background: rgba(0, 0, 0, 0.025);
30
+ }
31
+ .opened {
32
+ background: rgba(0, 0, 0, 0.025);
33
+ }
34
+ }
35
+ .search {
36
+ padding: 0 12px;
37
+ &:hover {
38
+ background: transparent;
39
+ }
40
+ }
41
+ .account {
42
+ .avatar {
43
+ margin-right: 8px;
44
+ color: #1890ff;
45
+ vertical-align: top;
46
+ background: rgba(255, 255, 255, 0.85);
47
+ }
48
+ }
49
+ }
50
+
51
+ .dark {
52
+ .action {
53
+ &:hover {
54
+ background: #252a3d;
55
+ }
56
+ .opened {
57
+ background: #252a3d;
58
+ }
59
+ }
60
+ }
61
+
62
+ .warp_allfunc {
63
+ z-index: 100;
64
+
65
+
66
+ .drawerWarp {
67
+ column-count: 4;
68
+ }
69
+
70
+ .drawer_header_warp {
71
+ .ant-list-header {
72
+ padding: 0 0 0 10px !important;
73
+ line-height: 40px;
74
+ border: 0px !important;
75
+ b {
76
+ width: 100%;
77
+ display: inline-block;
78
+ border-bottom: 1px solid #f0f0f0;
79
+ }
80
+ }
81
+ .ant-list-item {
82
+ padding: 0 0 0 10px !important;
83
+ line-height: 30px !important;
84
+ }
85
+
86
+ .ant-drawer-close {
87
+ position: absolute;
88
+ right: 0;
89
+ }
90
+ }
91
+
92
+
93
+
94
+ .p {
95
+ color: #b1bad4;
96
+ font-weight: 400;
97
+ font-size: 12px;
98
+ margin-bottom: 10px;
99
+ font-family: PingFangSC, PingFangSC-Regular;
100
+ line-height: 16px;
101
+ text-align: left;
102
+ opacity: 0.8;
103
+ user-select: none;
104
+ text-align: center;
105
+ margin-left: 8px;
106
+ }
107
+
108
+ .btn {
109
+ display: flex;
110
+ align-items: center;
111
+ height: 44px;
112
+ color: #b1bad4;
113
+ background: #10234c;
114
+ border-radius: 8px;
115
+ width: 130px;
116
+ user-select: none;
117
+ }
118
+ .btn:hover,
119
+ .btnSpan1:hover,
120
+ .btnSpan2:hover {
121
+ cursor: pointer;
122
+ color: #b1bad4;
123
+ }
124
+
125
+ .btnSpan1 {
126
+ margin: 0 7px;
127
+ }
128
+ }
129
+
130
+ .allfunc_drawcontent {
131
+ .allFunsList {
132
+ margin-bottom: 10px;
133
+ }
134
+
135
+ .allFunsListWarp {
136
+ width: 200px;
137
+ margin-right: 10px;
138
+ border-radius: 4px;
139
+
140
+ break-inside: avoid;
141
+ }
142
+
143
+ .drawerWarp_p {
144
+ color: #8c8c8c;
145
+ font-weight: 400;
146
+ font-size: 14px;
147
+ font-family: PingFangSC, PingFangSC-Regular;
148
+ line-height: 20px;
149
+ text-align: left;
150
+ }
151
+ }
152
+
153
+
@@ -0,0 +1,70 @@
1
+
2
+ // @ts-nocheck
3
+ import { Drawer } from 'antd';
4
+ import React, { useEffect, useState, forwardRef, useImperativeHandle } from 'react';
5
+ import './index.less';
6
+ import allfunc from '../../../../../assets/allfunc.svg';
7
+ import DrawContent from './drawContent';
8
+ export type SiderTheme = 'light' | 'dark';
9
+
10
+ const AllFunc: any = forwardRef(({ isCollapse, handleClose, itemPath }: any, ref) => {
11
+ const [isDrawer, setIsDrawer]: any = useState(false);
12
+ useImperativeHandle(ref, () => ({
13
+ close: () => {
14
+ setIsDrawer(false)
15
+ }
16
+ }));
17
+
18
+ useEffect(() => {
19
+ if (isCollapse) {
20
+ setIsDrawer(false);
21
+ }
22
+ }, [isCollapse]);
23
+ const showDrawer = (e) => {
24
+ if (isCollapse) {
25
+ return;
26
+ }
27
+ handleClose()
28
+ e.stopPropagation();
29
+ setIsDrawer(!isDrawer);
30
+ };
31
+ const onClose = () => {
32
+ setIsDrawer(!isDrawer);
33
+ };
34
+
35
+
36
+ return (
37
+ <div
38
+ className={'warp_allfunc'}
39
+ onClick={(e: any) => {
40
+ e.stopPropagation();
41
+ }}
42
+ style={{ opacity: isCollapse ? '0' : '1' }}
43
+ >
44
+ <p className={'p'}>没有找到想要的功能?</p>
45
+
46
+ <p className={'btn'} onClick={showDrawer}>
47
+ <span className={'btnSpan1'}>
48
+ <img style={{marginTop: '-2px'}} width={18} src={allfunc} />
49
+ </span>
50
+ <span className={'btnSpan2'}>查看全部功能</span>
51
+ </p>
52
+ {!isCollapse && (
53
+ <Drawer
54
+ style={{ left: isDrawer ? 140 : 0, top:50 }}
55
+ destroyOnClose
56
+ title={<span style={{ fontWeight: 'bold', fontSize: 18 }}>全部功能</span>}
57
+ zIndex={19}
58
+ width={850}
59
+ className={'drawer_header_warp'}
60
+ placement="left"
61
+ onClose={onClose}
62
+ visible={isDrawer}
63
+ >
64
+ <DrawContent itemPath={itemPath} onClose={onClose} />
65
+ </Drawer>
66
+ )}
67
+ </div>
68
+ );
69
+ });
70
+ export default AllFunc;
@@ -0,0 +1,90 @@
1
+ .setting_content>div {
2
+ width: 50%;
3
+ box-sizing: border-box;
4
+ // float: left;
5
+ margin: 0 10px;
6
+ }
7
+
8
+ .setting_content {
9
+ display: flex;
10
+ }
11
+
12
+
13
+ .tree_title {
14
+ height: 50px;
15
+ }
16
+
17
+ .tree_content {
18
+ height: 400px;
19
+ overflow: auto;
20
+ border: 1px solid #d9d9d9;
21
+ padding: 5px;
22
+ }
23
+
24
+ .setting_content::after {
25
+ clear: both;
26
+ display: block;
27
+ content: '';
28
+ }
29
+
30
+ .choosed_label_color {
31
+ color: #f50;
32
+ }
33
+
34
+ .left_tree_content {
35
+ .ant-tree .ant-tree-node-content-wrapper {
36
+ flex-grow: 1;
37
+ .ant-tree-title {
38
+ width: 100%;
39
+ }
40
+ }
41
+ .ant-tree .ant-tree-treenode {
42
+ width: 100%;
43
+ }
44
+ }
45
+
46
+ .right_tree_content, .left_tree_content {
47
+ .ant-tree .ant-tree-node-content-wrapper {
48
+ display: flex;
49
+ margin-left: -3px;
50
+ }
51
+ .ant-tree-checkbox {
52
+ top: auto;
53
+ top: initial;
54
+ // margin: 4px 3px 0 0 !important;
55
+ }
56
+ }
57
+
58
+ .node_title_content:hover {
59
+ .right_arrow {
60
+ display: block !important;
61
+ }
62
+ }
63
+
64
+ .right_arrow {
65
+ float: right;
66
+ display: none;
67
+ color: #999999;
68
+ margin-right: 10px;
69
+ }
70
+
71
+
72
+
73
+ .right_tree_content {
74
+ .ant-tree-title {
75
+ width: 100%;
76
+ display: inline-block;
77
+ padding-right: 10px;
78
+ }
79
+ .ant-dropdown-trigger {
80
+ color: gray !important;
81
+ }
82
+ .tree_node_title {
83
+ font-size: 20px;
84
+ color: #d9d9d9;
85
+ float: right;
86
+ span {
87
+ margin-right: 5px;
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,38 @@
1
+ import React, {
2
+ useState,
3
+ forwardRef,
4
+ useImperativeHandle
5
+ } from "react";
6
+ import './index.less';
7
+ import LeftTree from "./leftTree";
8
+ import RightTree from "./rightTree";
9
+
10
+ const MenuSetting = forwardRef(({actionRef, originRoutes, itemPath}: any, ref) => {
11
+
12
+ const [customerMenuData, setCustomerMenuData] = useState(
13
+ JSON.parse( localStorage.getItem(`customerMenu_${itemPath}_front`) || '[]')
14
+ );
15
+
16
+ useImperativeHandle(ref, () => ({
17
+ saveMenuData: () => {
18
+ localStorage.setItem(`customerMenu_${itemPath}_front`, JSON.stringify(customerMenuData));
19
+ actionRef.current?.reload();
20
+ },
21
+ }));
22
+
23
+ return (
24
+ <div className={'setting_content'}>
25
+ <LeftTree
26
+ originRoutes={originRoutes}
27
+ customerMenuData={customerMenuData}
28
+ setCustomerMenuData={setCustomerMenuData}
29
+ />
30
+ <RightTree
31
+ customerMenuData={customerMenuData}
32
+ setCustomerMenuData={setCustomerMenuData}
33
+ />
34
+ </div>
35
+ )
36
+ })
37
+
38
+ export default MenuSetting;
@@ -0,0 +1,243 @@
1
+ // @ts-nocheck
2
+ import { Tree, Input, Tooltip, message } from 'antd';
3
+ import React from 'react';
4
+ import './index.less';
5
+ import {
6
+ SearchOutlined,
7
+ FolderOutlined,
8
+ } from '@ant-design/icons';
9
+ import arrowRight from '../../../../../../assets/arrowRight.svg';
10
+ import {
11
+ setMenuTreeData,
12
+ } from '../../../utils';
13
+ import { memoizeOneFormatter } from '@/utils/utils';
14
+
15
+
16
+ const { TreeNode } = Tree;
17
+ const { Search } = Input;
18
+
19
+ const dataList: any[] = [];
20
+ const generateList = data => {
21
+ for (let i = 0; i < data.length; i++) {
22
+ const node = data[i];
23
+ const { path, name } = node;
24
+ dataList.push({ path, name });
25
+ if (node.children) {
26
+ generateList(node.children);
27
+ }
28
+ }
29
+ };
30
+
31
+
32
+ const getParentKey = (path, tree) => {
33
+ let parentKey;
34
+ for (let i = 0; i < tree.length; i++) {
35
+ const node = tree[i];
36
+ if (node.children) {
37
+ if (node.children.some(item => item.path === path)) {
38
+ parentKey = node.path;
39
+ } else if (getParentKey(path, node.children)) {
40
+ parentKey = getParentKey(path, node.children);
41
+ }
42
+ }
43
+ }
44
+ return parentKey;
45
+ };
46
+
47
+ class LeftTree extends React.Component<any> {
48
+ state = {
49
+ treeData: [],
50
+ expandedKeys: [],
51
+ searchValue: '',
52
+ autoExpandParent: true,
53
+ };
54
+
55
+
56
+ componentDidMount() {
57
+ const {originRoutes = [] } = this.props;
58
+ const showMenu = originRoutes.find(item => item.path === '/')?.routes || [];
59
+ let routesData = JSON.parse(JSON.stringify(memoizeOneFormatter(showMenu, '')));
60
+ setMenuTreeData(routesData);
61
+ generateList(routesData);
62
+
63
+ this.setState({
64
+ treeData: routesData
65
+ })
66
+
67
+ }
68
+
69
+ onExpand = expandedKeys => {
70
+ this.setState({
71
+ expandedKeys,
72
+ autoExpandParent: false,
73
+ });
74
+ };
75
+
76
+ onChange = e => {
77
+ const { value } = e.target;
78
+ const { treeData } = this.state;
79
+ const expandedKeys = dataList
80
+ .map(item => {
81
+ if (item.name.indexOf(value) > -1) {
82
+ return getParentKey(item.path, treeData);
83
+ }
84
+ return null;
85
+ })
86
+ .filter((item, i, self) => item && self.indexOf(item) === i);
87
+ this.setState({
88
+ expandedKeys,
89
+ searchValue: value,
90
+ autoExpandParent: true,
91
+ });
92
+ };
93
+
94
+ getPathList = (originData: any): Array<any> => {
95
+ let pathList: Array<any> = [];
96
+ const getList = (data) => {
97
+ if (Array.isArray(data)) {
98
+ data.forEach(item => {
99
+ pathList.push(item.path);
100
+ if (item.children) {
101
+ getList(item.children)
102
+ }
103
+ })
104
+ } else {
105
+ pathList.push(data.path);
106
+ if (data.children) {
107
+ getList(data.children);
108
+ }
109
+ }
110
+ }
111
+ getList(originData);
112
+ return pathList;
113
+ }
114
+
115
+
116
+ handleAdd2Menu = (path: string) => {
117
+ const { treeData } = this.state;
118
+ const { customerMenuData, setCustomerMenuData } = this.props;
119
+ let filterItem;
120
+ const filterMenuItem = (menuData: Array<any>) => {
121
+ menuData.forEach(item => {
122
+ if (item.path === path) {
123
+ filterItem = { ...item };
124
+ return;
125
+ }
126
+ if (item.children) {
127
+ filterMenuItem(item.children);
128
+ }
129
+ })
130
+ }
131
+ filterMenuItem(treeData);
132
+ let addPathList = this.getPathList(filterItem);
133
+ let oldPathList = this.getPathList(customerMenuData);
134
+ let isRepet = false;
135
+ oldPathList.forEach(oldPath => {
136
+ if (addPathList.find(newPath => newPath === oldPath)) {
137
+ isRepet = true;
138
+ }
139
+ })
140
+ if (isRepet) {
141
+ message.warning('存在已经添加的菜单,请检查!');
142
+ return;
143
+ }
144
+ setCustomerMenuData([
145
+ ...customerMenuData,
146
+ filterItem
147
+ ])
148
+ }
149
+
150
+
151
+ render() {
152
+ const { searchValue, expandedKeys, autoExpandParent, treeData } = this.state;
153
+ const loop = data =>
154
+ data.map(item => {
155
+ const index = item.name.indexOf(searchValue);
156
+ const beforeStr = item.name.substr(0, index);
157
+ const afterStr = item.name.substr(index + searchValue.length);
158
+ const name =
159
+ index > -1 ? (
160
+ <span>
161
+ {beforeStr}
162
+ <span style={{ color: '#f50' }}>{searchValue}</span>
163
+ {afterStr}
164
+ </span>
165
+ ) : (
166
+ <span>{item.name}</span>
167
+ );
168
+ if (item.children && item.children.length) {
169
+ return (
170
+ <TreeNode
171
+ path={item.path}
172
+ icon={<FolderOutlined />}
173
+ name={<div className={'node_title_content'}>
174
+ <span>{name}</span>
175
+ <div
176
+ className={'right_arrow'}
177
+ onClick={() => {
178
+ this.handleAdd2Menu(item.path);
179
+ }}
180
+ >
181
+ <Tooltip placement="topRight" title={'单击加入自定义菜单'}>
182
+ <img style={{ marginTop: '-3px' }} width={18} src={arrowRight} />
183
+ </Tooltip>
184
+ </div>
185
+ </div>}
186
+ >
187
+ {loop(item.children)}
188
+ </TreeNode>
189
+ );
190
+ }
191
+ return <TreeNode
192
+ path={item.path}
193
+ // icon={<FileOutlined />}
194
+ name={<div className={'node_title_content'}>
195
+ <span>{name}</span>
196
+ <div
197
+ className={'right_arrow'}
198
+ onClick={() => {
199
+ this.handleAdd2Menu(item.path);
200
+ }}
201
+ >
202
+ <Tooltip placement="topRight" title={'单击加入自定义菜单'}>
203
+ <img style={{ marginTop: '-3px' }} width={18} src={arrowRight} />
204
+ </Tooltip>
205
+ </div>
206
+ </div>}
207
+ />;
208
+ });
209
+ return (
210
+ <div className={'left_tree_content'}>
211
+ <div className={'tree_title'}>
212
+ <div>菜单列表(选中菜单,可快速设置)</div>
213
+ <Input
214
+ style={{ marginBottom: 8 }}
215
+ placeholder="请搜索"
216
+ allowClear
217
+
218
+ prefix={<SearchOutlined />}
219
+ onChange={this.onChange}
220
+ />
221
+ </div>
222
+ <div className={'tree_content'}>
223
+ <Tree
224
+ showIcon
225
+ showLine={true}
226
+ fieldNames={{
227
+ title: 'name',
228
+ key: 'path',
229
+ children: 'children'
230
+ }}
231
+ onExpand={this.onExpand}
232
+ expandedKeys={expandedKeys}
233
+ autoExpandParent={autoExpandParent}
234
+ >
235
+ {loop(treeData)}
236
+ </Tree>
237
+ </div>
238
+ </div>
239
+ );
240
+ }
241
+ }
242
+
243
+ export default LeftTree;