kn-cli 1.0.97 → 1.0.98

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 (127) hide show
  1. package/package.json +1 -1
  2. package/templates/template_admin/cli.config.js +4 -1
  3. package/templates/template_admin/package.json +7 -1
  4. package/templates/template_admin/public/favicon.png +0 -0
  5. package/templates/template_admin/public/index.html +6 -4
  6. package/templates/template_admin/public/src/_antd.less +30 -3
  7. package/templates/template_admin/public/src/_mixin.less +41 -0
  8. package/templates/template_admin/public/src/_reset.less +28 -20
  9. package/templates/template_admin/public/src/_variable.less +11 -6
  10. package/templates/template_admin/public/src/assets/iconfont/iconfont.eot +0 -0
  11. package/templates/template_admin/public/src/assets/iconfont/iconfont.less +60 -8
  12. package/templates/template_admin/public/src/assets/iconfont/iconfont.svg +57 -18
  13. package/templates/template_admin/public/src/assets/iconfont/iconfont.ttf +0 -0
  14. package/templates/template_admin/public/src/assets/iconfont/iconfont.woff +0 -0
  15. package/templates/template_admin/public/src/assets/iconfont/iconfont.woff2 +0 -0
  16. package/templates/template_admin/public/src/assets/images/arrow.png +0 -0
  17. package/templates/template_admin/public/src/assets/images/icon-notice.png +0 -0
  18. package/templates/template_admin/public/src/assets/images/icon-user.png +0 -0
  19. package/templates/template_admin/public/src/assets/images/loadFail.png +0 -0
  20. package/templates/template_admin/public/src/assets/images/login/bg.png +0 -0
  21. package/templates/template_admin/public/src/assets/images/login/logo.png +0 -0
  22. package/templates/template_admin/public/src/assets/images/login/slogan.png +0 -0
  23. package/templates/template_admin/public/src/assets/images/nav/icon-dep-active.png +0 -0
  24. package/templates/template_admin/public/src/assets/images/nav/icon-dep.png +0 -0
  25. package/templates/template_admin/public/src/assets/images/nav/icon-log-active.png +0 -0
  26. package/templates/template_admin/public/src/assets/images/nav/icon-log.png +0 -0
  27. package/templates/template_admin/public/src/assets/images/nav/icon-loginlog-active.png +0 -0
  28. package/templates/template_admin/public/src/assets/images/nav/icon-loginlog.png +0 -0
  29. package/templates/template_admin/public/src/assets/images/nav/icon-role-active.png +0 -0
  30. package/templates/template_admin/public/src/assets/images/nav/icon-role.png +0 -0
  31. package/templates/template_admin/public/src/assets/images/nav/icon-user-active.png +0 -0
  32. package/templates/template_admin/public/src/assets/images/nav/icon-user.png +0 -0
  33. package/templates/template_admin/public/src/assets/images/nav/nav-toggle.png +0 -0
  34. package/templates/template_admin/public/src/assets/images/nav/slogan.png +0 -0
  35. package/templates/template_admin/public/src/assets/images/noData.png +0 -0
  36. package/templates/template_admin/public/src/assets/images/noSelect.png +0 -0
  37. package/templates/template_admin/public/src/components/auth/index.jsx +7 -3
  38. package/templates/template_admin/public/src/components/auth/index.less +7 -0
  39. package/templates/template_admin/public/src/components/badge/index.jsx +47 -0
  40. package/templates/template_admin/public/src/components/badge/index.less +44 -0
  41. package/templates/template_admin/public/src/components/debug/index.jsx +27 -0
  42. package/templates/template_admin/public/src/components/debug/index.less +9 -0
  43. package/templates/template_admin/public/src/components/empty/index.jsx +28 -0
  44. package/templates/template_admin/public/src/components/empty/index.less +20 -0
  45. package/templates/template_admin/public/src/components/image/index.jsx +73 -0
  46. package/templates/template_admin/public/src/components/image/index.less +117 -0
  47. package/templates/template_admin/public/src/components/image/preview.jsx +85 -0
  48. package/templates/template_admin/public/src/components/layout/basic/index.jsx +24 -11
  49. package/templates/template_admin/public/src/components/layout/basic/index.less +58 -19
  50. package/templates/template_admin/public/src/components/layout/index.jsx +20 -17
  51. package/templates/template_admin/public/src/components/layout/index.less +4 -4
  52. package/templates/template_admin/public/src/components/layout/provider/index.jsx +19 -6
  53. package/templates/template_admin/public/src/components/{menu → leftMenu}/index.jsx +20 -28
  54. package/templates/template_admin/public/src/components/leftMenu/index.less +42 -0
  55. package/templates/template_admin/public/src/components/popup/index.jsx +25 -0
  56. package/templates/template_admin/public/src/components/table/column.jsx +47 -0
  57. package/templates/template_admin/public/src/components/table/column.less +12 -0
  58. package/templates/template_admin/public/src/components/table/index.jsx +22 -13
  59. package/templates/template_admin/public/src/components/table/index.less +15 -0
  60. package/templates/template_admin/public/src/components/text/index.jsx +98 -0
  61. package/templates/template_admin/public/src/components/text/index.less +13 -0
  62. package/templates/template_admin/public/src/components/topMenu/index.jsx +97 -0
  63. package/templates/template_admin/public/src/components/topMenu/index.less +80 -0
  64. package/templates/template_admin/public/src/components/topMenu/topBar/index.jsx +76 -0
  65. package/templates/template_admin/public/src/components/topMenu/topBar/index.less +88 -0
  66. package/templates/template_admin/public/src/components/video/index.jsx +96 -0
  67. package/templates/template_admin/public/src/components/video/index.less +132 -0
  68. package/templates/template_admin/public/src/components/video/preview.jsx +38 -0
  69. package/templates/template_admin/public/src/dictionary/index.js +108 -39
  70. package/templates/template_admin/public/src/enum.js +41 -0
  71. package/templates/template_admin/public/src/hooks/index.jsx +8 -6
  72. package/templates/template_admin/public/src/hooks/useDebounceFn.jsx +33 -0
  73. package/templates/template_admin/public/src/hooks/useInToView.jsx +58 -0
  74. package/templates/template_admin/public/src/hooks/useRouteMenu.jsx +37 -28
  75. package/templates/template_admin/public/src/hooks/useTimer.jsx +42 -0
  76. package/templates/template_admin/public/src/index.jsx +10 -7
  77. package/templates/template_admin/public/src/mock/auth.js +33 -0
  78. package/templates/template_admin/public/src/mock/demo.js +12 -74
  79. package/templates/template_admin/public/src/mock/index.js +1 -0
  80. package/templates/template_admin/public/src/pages/auth/user/create/index.jsx +55 -0
  81. package/templates/template_admin/public/src/pages/auth/user/create/index.less +6 -0
  82. package/templates/template_admin/public/src/pages/auth/user/dialog/index.jsx +96 -0
  83. package/templates/template_admin/public/src/pages/auth/user/index.jsx +271 -0
  84. package/templates/template_admin/public/src/pages/components/layout/index.jsx +75 -0
  85. package/templates/template_admin/public/src/pages/components/layout/index.less +78 -0
  86. package/templates/template_admin/public/src/pages/components/layout/titleBar/index.jsx +28 -0
  87. package/templates/template_admin/public/src/pages/components/layout/titleBar/index.less +44 -0
  88. package/templates/template_admin/public/src/pages/components/select/account/index.jsx +114 -0
  89. package/templates/template_admin/public/src/pages/components/select/device/index.jsx +83 -0
  90. package/templates/template_admin/public/src/pages/components/select/groupUser/index.jsx +172 -0
  91. package/templates/template_admin/public/src/pages/components/select/user/index.jsx +119 -0
  92. package/templates/template_admin/public/src/pages/home.jsx +79 -0
  93. package/templates/template_admin/public/src/pages/home.less +6 -0
  94. package/templates/template_admin/public/src/pages/login/index.jsx +90 -6
  95. package/templates/template_admin/public/src/pages/login/index.less +133 -24
  96. package/templates/template_admin/public/src/provider/app.jsx +72 -66
  97. package/templates/template_admin/public/src/provider/loading.jsx +47 -0
  98. package/templates/template_admin/public/src/provider/menu.jsx +117 -83
  99. package/templates/template_admin/public/src/provider/menu.less +35 -0
  100. package/templates/template_admin/public/src/route.jsx +41 -40
  101. package/templates/template_admin/public/src/services/auth.js +39 -0
  102. package/templates/template_admin/public/src/services/demo.js +3 -37
  103. package/templates/template_admin/public/src/services/index.js +139 -13
  104. package/templates/template_admin/public/src/services/login.js +37 -0
  105. package/templates/template_admin/public/src/services/socket/index.jsx +100 -0
  106. package/templates/template_admin/public/src/type.js +36 -19
  107. package/templates/template_admin/public/src/utils/event.js +58 -0
  108. package/templates/template_admin/public/src/utils/format.js +84 -0
  109. package/templates/template_admin/public/src/utils/index.js +214 -2
  110. package/templates/template_admin/public/src/utils/rule.js +3 -0
  111. package/templates/template_admin/public/static/kssoLogin.html +1 -1
  112. package/templates/template_admin/webpack.api.js +11 -3
  113. package/templates/template_admin/public/favicon.ico +0 -0
  114. package/templates/template_admin/public/src/assets/images/avatars/1.png +0 -0
  115. package/templates/template_admin/public/src/assets/images/avatars/2.png +0 -0
  116. package/templates/template_admin/public/src/assets/images/avatars/3.png +0 -0
  117. package/templates/template_admin/public/src/components/layout/centerBody/index.jsx +0 -25
  118. package/templates/template_admin/public/src/components/layout/centerBody/index.less +0 -30
  119. package/templates/template_admin/public/src/components/menu/index.less +0 -19
  120. package/templates/template_admin/public/src/components/menu/topMenu/index.jsx +0 -132
  121. package/templates/template_admin/public/src/components/menu/topMenu/index.less +0 -105
  122. package/templates/template_admin/public/src/pages/demo/detail/index.jsx +0 -27
  123. package/templates/template_admin/public/src/pages/demo/edit/index.jsx +0 -109
  124. package/templates/template_admin/public/src/pages/demo/index.less +0 -9
  125. package/templates/template_admin/public/src/pages/demo/page1.jsx +0 -161
  126. package/templates/template_admin/public/src/pages/superAdminLogin/index.jsx +0 -64
  127. package/templates/template_admin/public/src/pages/superAdminLogin/index.less +0 -44
@@ -0,0 +1,271 @@
1
+ import React from 'react';
2
+ import {
3
+ Space,
4
+ Form,
5
+ Button,
6
+ Input,
7
+ Select,
8
+ Tabs,
9
+ Badge
10
+ // @ts-ignore
11
+ } from 'antd';
12
+ // @ts-ignore
13
+ import {useNavigate,} from 'react-router-dom';
14
+ // @ts-ignore
15
+ import {PlusOutlined} from '@ant-design/icons';
16
+
17
+ import ruler from '@/utils/rule';
18
+ import {px2rem} from '@/utils';
19
+ import {Layout,SearchBar,TitleBar,Content,Panel} from '@/pages/components/layout'
20
+ import {emUserState} from '@/dictionary';
21
+ import Table from '@/components/table';
22
+ import { usePaginationWithForm } from '@/hooks';
23
+ import Link from '@/components/link';
24
+ import {FormatTableService,FormatGetRequest} from '@/services'
25
+ import {
26
+ GET_LIST,
27
+ } from '@/services/demo';
28
+
29
+
30
+ import ShowEdit from './dialog';
31
+
32
+
33
+ const AuthUser = () => {
34
+ const navigator = useNavigate();
35
+
36
+ const [form] = Form.useForm();
37
+
38
+ const page = usePaginationWithForm({
39
+ afterService: [FormatTableService],
40
+ beforeService:[FormatGetRequest],
41
+ service: GET_LIST,
42
+ pagination: { pageSize: 15 },
43
+ form
44
+ });
45
+
46
+ const onSearch=()=>{
47
+ page.update({ pagination: { current: 1 }, clear: true });
48
+ }
49
+ const onReset=()=>{}
50
+
51
+ const onPageChange = (current, pageSize) => {
52
+ page.update({ pagination: { current, pageSize }, clear: true });
53
+ };
54
+
55
+ const onCreate=()=>{
56
+ navigator('/auth/user/create')
57
+ }
58
+ const onEdit=async (record)=>{
59
+ const req = await ShowEdit({id:record.id})
60
+ }
61
+
62
+ const columnsInternalUsers = [
63
+ {
64
+ title: '姓名',
65
+ dataIndex: 'name',
66
+ render:(text,record)=>(<Table.Column minWidth={60} maxWidth={88}>{text}</Table.Column>)
67
+ },
68
+ {
69
+ title: '用户名',
70
+ dataIndex: 'name',
71
+ render:(text,record)=>(<Table.Column minWidth={60} maxWidth={80}>{text}</Table.Column>)
72
+ },
73
+ {
74
+ title: '职位',
75
+ dataIndex: 'name',
76
+ render:(text,record)=>(<Table.Column minWidth={60} maxWidth={94}>{text}</Table.Column>)
77
+ },
78
+ {
79
+ title: '所在部门',
80
+ dataIndex: 'longName',
81
+ render:(text,record)=>(<Table.Column minWidth={100} maxWidth={224}>{text}</Table.Column>)
82
+ },
83
+ {
84
+ title: '角色',
85
+ dataIndex: 'name',
86
+ render:(text,record)=>(<Table.Column minWidth={80} maxWidth={111}>{text}</Table.Column>)
87
+ },
88
+ {
89
+ title: '模块权限(补充)',
90
+ dataIndex: 'longName',
91
+ render:(text,record)=>(<Table.Column minWidth={120} maxWidth={187}>{text}</Table.Column>)
92
+ },
93
+ {
94
+ title: '产品权限(补充)',
95
+ dataIndex: 'longName',
96
+ render:(text,record)=>(<Table.Column minWidth={129} maxWidth={211}>{text}</Table.Column>)
97
+ },
98
+ {
99
+ title: '状态',
100
+ dataIndex: 'select',
101
+ width:70,
102
+ fixed:'right',
103
+ render:(state)=>{
104
+ const stateLabel = emUserState.getLabel(`${state}`);
105
+ if(!stateLabel)return '-'
106
+ const colors={
107
+ '1':'green',
108
+ '0':'red',
109
+ '2':'#FAAD14',
110
+ }
111
+ return <Badge
112
+ color={colors[`${state}`]}
113
+ text={stateLabel}
114
+ />
115
+ }
116
+ },
117
+ {
118
+ title: '操作',
119
+ key: 'option',
120
+ width:104,
121
+ fixed:'right',
122
+ align:'center',
123
+ render: (_, record) => {
124
+ return <Link onClick={onEdit.bind(this,record)} >编辑</Link>
125
+
126
+ }
127
+ },
128
+ ];
129
+ const columnsExternalUsers = [
130
+ {
131
+ title: '姓名',
132
+ dataIndex: 'name',
133
+ fixed:'left',
134
+ render:(text,record)=>(<Table.Column minWidth={60} maxWidth={88} item={record}>{text}</Table.Column>)
135
+
136
+ },
137
+ {
138
+ title: '公司',
139
+ dataIndex: 'name',
140
+ render:(text,record)=>(<Table.Column minWidth={80} maxWidth={224}>{text}</Table.Column>)
141
+ },
142
+ {
143
+ title: '所在部门',
144
+ dataIndex: 'name',
145
+ render:(text,record)=>(<Table.Column minWidth={80} maxWidth={224}>{text}</Table.Column>)
146
+ },
147
+ {
148
+ title: '角色',
149
+ dataIndex: 'name',
150
+ render:(text,record)=>(<Table.Column minWidth={60} maxWidth={110}>{text}</Table.Column>)
151
+ },
152
+ {
153
+ title: '模块权限(补充)',
154
+ dataIndex: 'longName',
155
+ render:(text,record)=>(<Table.Column minWidth={120} maxWidth={187}>{text}</Table.Column>)
156
+ },
157
+ {
158
+ title: '产品权限(补充)',
159
+ dataIndex: 'longName',
160
+ render:(text,record)=>(<Table.Column minWidth={129} maxWidth={211}>{text}</Table.Column>)
161
+ },
162
+ {
163
+ title: '状态',
164
+ dataIndex: 'select',
165
+ width:70,
166
+ fixed:'right',
167
+ render:(state)=>{
168
+ const stateLabel = emUserState.getLabel(`${state}`);
169
+ if(!stateLabel)return '-'
170
+ const colors={
171
+ '1':'green',
172
+ '0':'red',
173
+ '2':'#FAAD14',
174
+ }
175
+ return <Badge
176
+ color={colors[`${state}`]}
177
+ text={stateLabel}
178
+ />
179
+ }
180
+ },
181
+ {
182
+ title: '操作',
183
+ key: 'option',
184
+ width:104,
185
+ fixed:'right',
186
+ align:'center',
187
+ render: (_, record) => {
188
+ return <Link onClick={onEdit.bind(this,record)} >编辑</Link>
189
+ }
190
+ },
191
+ ];
192
+ const tabs = [
193
+ {
194
+ key: '1',
195
+ label: '内部用户',
196
+ children: <Table page={page}
197
+ columns={columnsInternalUsers}
198
+ pagination={{
199
+ onChange: onPageChange,
200
+ }}
201
+ />,
202
+ },
203
+ {
204
+ key: '2',
205
+ label: '外部用户',
206
+ children: <Table page={page}
207
+ columns={columnsExternalUsers}
208
+ pagination={{
209
+ onChange: onPageChange,
210
+ }}
211
+ />,
212
+
213
+ },
214
+ ];
215
+
216
+ const onTab=()=>{}
217
+ return (
218
+ <Layout>
219
+ <SearchBar>
220
+ <TitleBar label='用户管理' />
221
+ <Form form={form} layout="inline" initialValues={{status:'',keyword:'',dep:'',role:''}}>
222
+ <Form.Item label="关键字" name={'keyword'} rules={ruler.KEYWORDS}>
223
+ <Input placeholder="请输入用户名/姓名" onPressEnter={onSearch} />
224
+ </Form.Item>
225
+ <Form.Item label="状态" name={'status'} style={{width:px2rem(150)}}>
226
+ <Select>
227
+ <Select.Option value=''>全部</Select.Option>
228
+ {emUserState.selectOptions}
229
+ </Select>
230
+ </Form.Item>
231
+
232
+ <Form.Item label="部门" name={'dep'} style={{width:px2rem(150)}}>
233
+ <Select>
234
+ <Select.Option value=''>全部</Select.Option>
235
+ {emUserState.selectOptions}
236
+ </Select>
237
+ </Form.Item>
238
+
239
+ <Form.Item label="角色" name={'role'} style={{width:px2rem(150)}}>
240
+ <Select>
241
+ <Select.Option value=''>全部</Select.Option>
242
+ {emUserState.selectOptions}
243
+ </Select>
244
+ </Form.Item>
245
+
246
+ <Space size='middle'>
247
+ <Button onClick={onSearch} type="primary">
248
+ 搜索
249
+ </Button>
250
+ <Button onClick={onReset}>
251
+ 重置
252
+ </Button>
253
+ </Space>
254
+ </Form>
255
+ </SearchBar>
256
+
257
+ <Content>
258
+ <Panel>
259
+ <Tabs defaultActiveKey="1" items={tabs} onChange={onTab}
260
+ tabBarExtraContent={
261
+ {right:<Button icon={<PlusOutlined />} type='primary' onClick={onCreate}>新建用户</Button>}
262
+ }
263
+ />
264
+ </Panel>
265
+ </Content>
266
+
267
+ </Layout>
268
+ )
269
+ }
270
+
271
+ export default AuthUser;
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ // @ts-ignore
3
+ import { useNavigate } from 'react-router-dom';
4
+ import _TitleBar from './titleBar';
5
+ // @ts-ignore
6
+ import styles from './index.less';
7
+
8
+
9
+
10
+ export const Layout = (props) => {
11
+ const { children,className='' } = props;
12
+ return (
13
+ <section className={`${styles.layout} ${className}`}>
14
+ {children}
15
+ </section>
16
+ )
17
+ };
18
+
19
+ export const Content = (props) => {
20
+ const { children,className='' } = props;
21
+ return (
22
+ <section className={`${styles.contentPadding} ${className}`}>
23
+ {children}
24
+ </section>
25
+ )
26
+ };
27
+
28
+ export const Panel = (props) => {
29
+ const { children,className='', title='' } = props;
30
+ return (
31
+ <section className={`${styles.panel} ${className}`}>
32
+ {title&&<label className={styles.panelTitle}>{title}</label>}
33
+ {children}
34
+ </section>
35
+ )
36
+ };
37
+
38
+
39
+
40
+ export const SearchBar = (props) => {
41
+ const { children } = props;
42
+ return <section className={styles.search}>{children}</section>;
43
+ };
44
+
45
+ /**
46
+ * 二级子页面的头部返回导航栏
47
+ * @param {object} props
48
+ * @param {()=>void} [props.onClick] - 监听点击返回按钮,如果没有onClick则触发默认回退操作
49
+ * @param {string|JSX.Element} [props.children] - 展示在返回按钮右侧区域的元素
50
+ *
51
+ * @returns {JSX.Element}
52
+ */
53
+ export const NavBackTitle=(props)=>{
54
+ const {children,onClick:_onClick}= props;
55
+ const navigate = useNavigate()
56
+ const onClick=()=>{
57
+ if(_onClick){
58
+ _onClick();
59
+ return;
60
+ }
61
+ navigate(-1);
62
+
63
+ }
64
+ return (
65
+ <div className={styles.navBack}>
66
+ <div className={styles.backWrap} onClick={onClick}>
67
+ <div className={styles.arrowBack}></div>
68
+ </div>
69
+ <span className={styles.navLabel}>{children||''}</span>
70
+ </div>
71
+ )
72
+ }
73
+
74
+ export const TitleBar = _TitleBar
75
+ export default { Layout, Content, Panel, SearchBar, TitleBar };
@@ -0,0 +1,78 @@
1
+ @import '~@/_mixin.less';
2
+
3
+ .layout{
4
+ position: relative;
5
+ width: 100%;
6
+ height: 100%;
7
+ overflow: hidden;
8
+ display: flex;
9
+ flex-direction: column;
10
+ }
11
+ .contentPadding{
12
+ position: relative;
13
+ margin-top: 16px;
14
+ padding:16px;
15
+ padding-top: 0;
16
+ width: 100%;
17
+ flex:1;
18
+ overflow: auto;
19
+ }
20
+
21
+ .panel {
22
+ padding: 24px;
23
+ border-radius: 8px;
24
+ background-color: white;
25
+ &:not(:last-child){
26
+ margin-bottom: 16px;
27
+ }
28
+ .panelTitle{
29
+ font-size: 16px;
30
+ color:#1F2329;
31
+ font-weight: bold;
32
+ }
33
+ }
34
+ .search {
35
+ background-color: #fff;
36
+ padding: 14px 16px;
37
+ min-height: 48px;
38
+ display: flex;
39
+ flex-direction: column;
40
+ row-gap: 12px;
41
+ }
42
+
43
+
44
+ .navBack{
45
+ display: flex;
46
+ align-items: center;
47
+ column-gap: 14px;
48
+ .backWrap{
49
+ width: 28px;
50
+ height: 28px;
51
+ border-radius: 4px;
52
+ border:1px solid #BBBFC4;
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: center;
56
+ cursor: pointer;
57
+ &:hover{
58
+ border-color: #a6adb8;
59
+ .arrowBack{
60
+ border-color: #a6adb8;
61
+ }
62
+ }
63
+ .arrowBack{
64
+ width: 8px;
65
+ height: 8px;
66
+ border:1px solid #BBBFC4;
67
+ border-right: 0;
68
+ border-bottom: 0;
69
+ transform: translateX(25%) rotateZ(-45deg);
70
+ }
71
+ }
72
+ .navLabel{
73
+ font-weight: 600;
74
+ font-size: 20px;
75
+ color: #1F2329;
76
+ line-height: 23px;
77
+ }
78
+ }
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ // @ts-ignore
3
+ import { useNavigate } from 'react-router-dom';
4
+
5
+ // @ts-ignore
6
+ import imgArrow from '@/assets/images/arrow.png';
7
+ // @ts-ignore
8
+ import styles from './index.less';
9
+
10
+ const TitleBar = (props) => {
11
+ const { optionLeft, optionRight,label,showBack,className='' } = props;
12
+
13
+ const navigate = useNavigate();
14
+ const onBack=()=>{
15
+ navigate(-1);
16
+ }
17
+ return (
18
+ <section className={`${styles.title} ${className}`}>
19
+ <hgroup className={styles.left}>
20
+ {showBack&&<div className={styles.iconBack} onClick={onBack}><img src={imgArrow} /></div>}
21
+ {label&&<span className={styles.label}>{label}</span>}
22
+ <div className={styles.left}>{optionLeft || ''}</div>
23
+ </hgroup>
24
+ <div className={styles.right}>{optionRight || ''}</div>
25
+ </section>
26
+ );
27
+ };
28
+ export default TitleBar;
@@ -0,0 +1,44 @@
1
+ @import '~@/_mixin.less';
2
+
3
+
4
+ .title {
5
+ display: flex;
6
+ justify-content: space-between;
7
+ align-items: center;
8
+ min-height: 36px;
9
+
10
+ .iconBack{
11
+ margin-right: 8px;
12
+ width: 24px;
13
+ height: 24px;
14
+ background-color: #F5F8FF;
15
+ border-radius: 4px;
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ cursor: pointer;
20
+ img{
21
+ width: 16px;
22
+ height: 16px;
23
+ transform: rotateY(180deg);
24
+ }
25
+ }
26
+ .label{
27
+ font-weight: bold;
28
+ font-size: 18px;
29
+ color:#000;
30
+
31
+ }
32
+ .right,
33
+ .left {
34
+ display: flex;
35
+ align-items: center;
36
+ .no-select;
37
+
38
+ }
39
+ .right{
40
+ column-gap: 16px;
41
+ }
42
+ }
43
+
44
+
@@ -0,0 +1,114 @@
1
+
2
+ import React, { useEffect, useState } from 'react';
3
+ // @ts-ignore
4
+ import { Select } from 'antd';
5
+ import {GET_LIST} from '@/services/demo';
6
+
7
+
8
+ /**
9
+ * 账号选择
10
+ * 数据来源:服务设置-账号管理-所有枚举
11
+ * @param {object} props
12
+ * @param {'single'|'multiple'} [props.mode='single'] - 单选/多选模式
13
+ * @param {(value:string|string[],items:object[])=>void} [props.onChange] - 选择发生变化时的回调
14
+ * @param {string|string[]} [props.value] - 选择发生变化时的回调
15
+ * @param {boolean} [props.withData=false] - 返回的数据是否包含原始用户数据
16
+ * @param {object} [props.style={}] - 样式
17
+ * @param {string} [props.placeholder] - 提示
18
+ * @param {boolean} [props.allowClear=falsse] - 一键删除按钮
19
+ *
20
+ *
21
+ *
22
+ * @returns {JSX.Element}
23
+ */
24
+ const SelectAccount=(props)=>{
25
+ const {mode='single',value:_value,onChange,withData=false,style:_style={},placeholder='',allowClear=false} = props;
26
+ const [list,setList]= useState([]);
27
+
28
+ const [value,setValue]=useState(mode=='single'?'':[]);
29
+
30
+ const init = async ()=>{
31
+ const req = await GET_LIST();
32
+ if(req?.code==0){
33
+ let users= req.data.map(user=>{
34
+ const {id,name} = user;
35
+
36
+ // return <Select.Option value={`${id}`} data={user}>{`${name}(${account})`}</Select.Option>
37
+ return {
38
+ label:`${name}`,
39
+ value:`${id}`,
40
+ data:user
41
+ }
42
+ })
43
+ setList(users);
44
+ }else{setList([])}
45
+ }
46
+
47
+
48
+ const onUserChange=(newValue,options)=>{
49
+ if(onChange)onChange(newValue,options);
50
+ }
51
+
52
+ const onFilter=(input,option)=>{
53
+ const {label,value}= option;
54
+ if( `${label}`.toLocaleLowerCase().indexOf(input.toLocaleLowerCase()) >=0 ){
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+
60
+ // useEffect(()=>{
61
+ // if(list&&list.length>0){
62
+ // if(mode=='single'){
63
+ // let find = list.filter(user=>user.value == value);
64
+ // if(!find || !find[0]){
65
+ // if(onChange)onChange(undefined);
66
+ // }
67
+ // }else{
68
+ // let newValue=[];
69
+ // value.forEach(id=>{
70
+ // let find = list.filter(user=>user.value == id);
71
+ // if(find && find[0]){
72
+ // newValue.push(id);
73
+ // }
74
+ // })
75
+ // if(onChange)onChange(newValue);
76
+
77
+ // }
78
+ // }
79
+ // },[list])
80
+
81
+ useEffect(()=>{
82
+ init();
83
+ },[])
84
+ useEffect(()=>{
85
+ if(!_value){
86
+ setValue(undefined);
87
+ return;
88
+ }
89
+ let req;
90
+ if(mode=='multiple' && Array.isArray(_value)){
91
+ req= _value.map(id=>`${id}`)
92
+ }else{
93
+ req = `${_value}`
94
+ }
95
+ setValue(req)
96
+ },[_value]);
97
+
98
+ return (
99
+ <Select
100
+ style={{..._style}}
101
+ placeholder={placeholder}
102
+ allowClear={allowClear?true:false}
103
+ // @ts-ignore
104
+ mode={mode}
105
+ showSearch
106
+ value={value}
107
+ options={list}
108
+ onChange={onUserChange}
109
+ filterOption={onFilter}
110
+ />
111
+ );
112
+ }
113
+
114
+ export default SelectAccount;
@@ -0,0 +1,83 @@
1
+
2
+ import React, { useEffect, useState } from 'react';
3
+ // @ts-ignore
4
+ import { Select } from 'antd';
5
+ import {DEVICE_ENUM} from '@/services/device';
6
+
7
+
8
+
9
+ /**
10
+ * 设备选择框
11
+ * 数据来源:手机管理-所有枚举
12
+ * @param {object} props
13
+ * @param {'single'|'multiple'} [props.mode='single'] - 单选/多选模式
14
+ * @param {(value:string|string[])=>void} [props.onChange] - 选择发生变化时的回调
15
+ * @param {string|string[]} [props.value] - 选择发生变化时的回调
16
+ * @param {object} [props.deviceType={}] - 调用枚举接口可用的传参
17
+ *
18
+ * @returns {JSX.Element}
19
+ */
20
+ const SelectDevice=(props)=>{
21
+ const {mode='single',value:_value,deviceType={},onChange} = props;
22
+ const [list,setList]= useState([]);
23
+
24
+ const [value,setValue]=useState(mode=='single'?'':[]);
25
+
26
+ const init = async ()=>{
27
+ const req = await DEVICE_ENUM(deviceType);
28
+ if(req?.code==0){
29
+ let devices= req.data.map(device=>{
30
+ const {id,title} = device;
31
+ let strId = `${id}`.padStart(2,'0');
32
+ return {
33
+ label:`[${strId}]${title}`,
34
+ value:`${id}`,
35
+ data:device
36
+ }
37
+ })
38
+ setList(devices);
39
+ }else{setList([])}
40
+ }
41
+ const onDeviceChange=(newValue)=>{
42
+ if(onChange)onChange(newValue);
43
+ }
44
+
45
+ const onFilter=(input,option)=>{
46
+ const {label,value}= option;
47
+ if( `${label}`.indexOf(input) >=0 ||
48
+ `${value}`.indexOf(input) >=0
49
+ ){
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ useEffect(()=>{
56
+ init();
57
+ },[])
58
+ useEffect(()=>{
59
+ if(!_value){
60
+ setValue(mode=='multiple'?[]:'');
61
+ return;
62
+ }
63
+ let req;
64
+ if(mode=='multiple' && Array.isArray(_value) ){
65
+ req= _value.map(id=>`${id}`)
66
+ }else{
67
+ req = `${_value}`
68
+ }
69
+ setValue(req)
70
+ },[_value]);
71
+ return (
72
+ <Select
73
+ mode={mode}
74
+ showSearch
75
+ value={value}
76
+ options={list}
77
+ onChange={onDeviceChange}
78
+ filterOption={onFilter}
79
+ />
80
+ );
81
+ }
82
+
83
+ export default SelectDevice;