cfel-base-components 2.5.25 → 2.5.27

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.25",
3
+ "version": "2.5.27",
4
4
  "description": "cfel-base-components",
5
5
  "main": "/src/index.tsx",
6
6
  "types": "src/index.d.ts",
@@ -53,6 +53,7 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "dayjs": "^1.11.9",
56
- "html2canvas": "^1.4.1"
56
+ "html2canvas": "^1.4.1",
57
+ "qrcode.react": "^3.1.0"
57
58
  }
58
59
  }
@@ -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
+ }
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef } from 'react';
1
+ import React, { useEffect, useRef,useState } from 'react';
2
2
  import useTableHooks from "../../../hooks/useTableHooks"
3
3
 
4
4
  import PageContainer from '../../base-component/PageContainer';
@@ -11,6 +11,7 @@ import { pageRequest, } from "./api"
11
11
 
12
12
  import { ProFormText, } from '@ant-design/pro-components';
13
13
  import { timeFormatter } from '../../../utils';
14
+ import QrCodeModal from './QrCodeModal'
14
15
 
15
16
  import "./index.scss"
16
17
  export interface RoleProps {
@@ -21,6 +22,8 @@ export default function Role({
21
22
  historyAction
22
23
  }: RoleProps) {
23
24
  const searchFormRef: any = useRef()
25
+ const [qrCodeModalOpen, setQrCodeModalOpen] = useState(false)
26
+ const [qrCodeModalData, setQrCodeModalData] = useState(null)
24
27
 
25
28
  useEffect(() => {
26
29
  init()
@@ -64,7 +67,7 @@ export default function Role({
64
67
  },
65
68
  {
66
69
  title: '操作',
67
- width: 80,
70
+ width: 140,
68
71
  fixed: "right",
69
72
  render: (rowdata: any,) => <Space>
70
73
  <a onClick={() => {
@@ -72,7 +75,15 @@ export default function Role({
72
75
  pathname: `/role-info`,
73
76
  search: `?roleCode=${rowdata.roleCode}`,
74
77
  });
75
- }}>赋予账号</a>
78
+ }}>赋予账号</a>,
79
+ <a
80
+ onClick={() => {
81
+ setQrCodeModalOpen(true)
82
+ setQrCodeModalData(rowdata)
83
+ }}
84
+ >
85
+ 邀请码
86
+ </a>
76
87
  </Space>
77
88
  },
78
89
  ];
@@ -140,7 +151,14 @@ export default function Role({
140
151
  }}
141
152
  />
142
153
  <Pagination {...pagination} />
143
-
154
+ <QrCodeModal
155
+ ModalOpen={qrCodeModalOpen}
156
+ editOpenStatus={(type: boolean) => {
157
+ setQrCodeModalOpen(type)
158
+ setQrCodeModalData(null)
159
+ }}
160
+ editingData={qrCodeModalData} //当前数据
161
+ />
144
162
  </PageContainer >
145
163
  )
146
164
  };