cfel-base-components 2.5.22 → 2.5.24

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfel-base-components",
3
- "version": "2.5.22",
3
+ "version": "2.5.24",
4
4
  "description": "cfel-base-components",
5
5
  "main": "/src/index.tsx",
6
6
  "types": "src/index.d.ts",
@@ -52,6 +52,7 @@
52
52
  "antd": "^5.5.2"
53
53
  },
54
54
  "dependencies": {
55
- "dayjs": "^1.11.9"
55
+ "dayjs": "^1.11.9",
56
+ "html2canvas": "^1.4.1"
56
57
  }
57
58
  }
@@ -8,7 +8,7 @@ interface propsType {
8
8
  rolelistRoleData: any;
9
9
  roleCheckData: any;
10
10
  }
11
- export default function index({
11
+ export default function Index({
12
12
  open,
13
13
  editOpenStatus,
14
14
  isBoundRolesFunc,
@@ -0,0 +1,85 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import QRCode from 'qrcode.react'
3
+
4
+ import { Button, Modal, Form, Input } from 'antd'
5
+ import dayjs from 'dayjs'
6
+ import html2canvas from 'html2canvas'
7
+
8
+ export default function Index({
9
+ ModalOpen, //弹框状态
10
+ editOpenStatus, //关闭弹框
11
+ editingData //编辑数据
12
+ }: any) {
13
+ useEffect(() => {
14
+ if (!ModalOpen) return
15
+ }, [ModalOpen])
16
+
17
+ const closeModel = () => {
18
+ editOpenStatus(false)
19
+ }
20
+
21
+ const qrcodeFunc = () => {
22
+ const { tenant, productCode } = (window as any)?.g_config
23
+ let ts = dayjs(dayjs().format()).valueOf()
24
+ return `${location?.origin}/h5/sub-registry?tenantId=${tenant?.id}&roleCode=${editingData?.roleCode}&productCode=${productCode}&expire=${ts}`
25
+ }
26
+ const onDownload = () => {
27
+ let img: any = document.getElementById('down')
28
+ html2canvas(img).then(canvas => {
29
+ const link = document.createElement('a')
30
+ link.href = canvas.toDataURL()
31
+ link.setAttribute('download', `${editingData?.roleName}邀请码.png`)
32
+ link.style.display = 'none'
33
+ document.body.appendChild(link)
34
+ link.click()
35
+ })
36
+ }
37
+
38
+ return (
39
+ <Modal
40
+ title={''}
41
+ destroyOnClose={true}
42
+ open={ModalOpen}
43
+ width={450}
44
+ onCancel={() => {
45
+ closeModel()
46
+ }}
47
+ footer={null}
48
+ >
49
+ <div
50
+ id='down'
51
+ style={{
52
+ width: '400px',
53
+ textAlign: 'center'
54
+ }}
55
+ >
56
+ <div
57
+ style={{
58
+ fontSize: '20px',
59
+ marginBottom: '10px'
60
+ }}
61
+ >
62
+ {editingData?.roleName}邀请码
63
+ </div>
64
+ <div>
65
+ <QRCode value={qrcodeFunc()} size={200} />
66
+ </div>
67
+ <div>
68
+ 有效期截止:
69
+ {dayjs(dayjs().format()).add(7, 'day').format('YYYY-MM-DD HH:mm:ss')}
70
+ </div>
71
+ </div>
72
+ <div style={{ textAlign: 'center', marginTop: '10px' }}>
73
+ <Button
74
+ key='submit'
75
+ type='primary'
76
+ onClick={() => {
77
+ onDownload()
78
+ }}
79
+ >
80
+ 下载
81
+ </Button>
82
+ </div>
83
+ </Modal>
84
+ )
85
+ }
@@ -5,8 +5,8 @@ import QueryFilter from '../../base-component/QueryFilter';
5
5
  import ProTable from '../../base-component/ProTable';
6
6
  import Pagination from '../../base-component/Pagination';
7
7
  import useTableHooks from "../../../hooks/useTableHooks"
8
-
9
8
  import { timeFormatter, getUrlParams } from '../../../utils';
9
+
10
10
  import { get } from 'lodash'
11
11
  import { Space, Button, message, Modal, Popover } from 'antd'
12
12
  import { pageRequest, create, remove, update } from './api'
@@ -14,6 +14,7 @@ import { pageRequest, create, remove, update } from './api'
14
14
  import { ProFormText } from '@ant-design/pro-components'
15
15
 
16
16
  import AddModal from './AddModal'
17
+ import QrCodeModal from './QrCodeModal'
17
18
  import './index.scss'
18
19
  export interface RoleProps {
19
20
  historyAction: any
@@ -23,6 +24,9 @@ export default function Role({ historyAction }: RoleProps) {
23
24
 
24
25
  const [ModalOpen, setModalOpen] = useState(false)
25
26
  const [editingData, setEditingData] = useState(null) //编辑数据
27
+ const [qrCodeModalOpen, setQrCodeModalOpen] = useState(false)
28
+ const [qrCodeModalData, setQrCodeModalData] = useState(null)
29
+
26
30
  useEffect(() => {
27
31
  init()
28
32
  execute()
@@ -133,6 +137,14 @@ export default function Role({ historyAction }: RoleProps) {
133
137
  >
134
138
  配置
135
139
  </a>
140
+ <a
141
+ onClick={() => {
142
+ setQrCodeModalOpen(true)
143
+ setQrCodeModalData(rowdata)
144
+ }}
145
+ >
146
+ 邀请码
147
+ </a>
136
148
  {rowdata.source !== 'system' && (
137
149
  <a
138
150
  onClick={() => {
@@ -250,6 +262,14 @@ export default function Role({ historyAction }: RoleProps) {
250
262
  editingData={editingData} //当前数据
251
263
  actionFunc={actionFunc} //事件
252
264
  />
265
+ <QrCodeModal
266
+ ModalOpen={qrCodeModalOpen}
267
+ editOpenStatus={(type: boolean) => {
268
+ setQrCodeModalOpen(type)
269
+ setQrCodeModalData(null)
270
+ }}
271
+ editingData={qrCodeModalData} //当前数据
272
+ />
253
273
  </PageContainer>
254
274
  )
255
275
  }
@@ -9,14 +9,14 @@ interface propsType {
9
9
  queryByKeywordFunc: Function;
10
10
  }
11
11
 
12
- export default function index({
12
+ export default function Index({
13
13
  open,
14
14
  editOpenStatus,
15
15
  roleBoundAccountsFunc,
16
16
  queryByKeywordFunc
17
17
  }: propsType) {
18
18
  const [form] = Form.useForm();
19
- const [selectOptions, useSelectOptions] = useState([])
19
+ const [selectOptions, setSelectOptions] = useState([])
20
20
 
21
21
  useEffect(() => {
22
22
  form.resetFields()
@@ -50,8 +50,7 @@ export default function index({
50
50
  queryByKeywordFunc({
51
51
  keyword
52
52
  }).then((res: any) => {
53
- useSelectOptions(res)
54
- }).catch((err) => {
53
+ setSelectOptions(res)
55
54
  })
56
55
  }, 500)
57
56
 
@@ -563,7 +563,7 @@ export default function RoleInfo({
563
563
  rowSelection={
564
564
  isResourceAction && roleCode !== 'admin'
565
565
  ? {
566
- checkStrictly: false,
566
+ checkStrictly: true,
567
567
  selectedRowKeys: selectedRowKeys,
568
568
  onChange: (selectedRowKeys: any, selectedRows: any) => {
569
569
  setselectedRowKeys(selectedRowKeys)