diff --git a/src/api/Home/User/index.ts b/src/api/Home/User/index.ts index 7a8d9e0..a2d9028 100644 --- a/src/api/Home/User/index.ts +++ b/src/api/Home/User/index.ts @@ -37,4 +37,11 @@ export const GetRoleDpList = () => request({ url: `/pub/role-dp-list`, method: 'get', + }) + +export const PostUserImport = (data: any) => + request({ + url: `/user/import`, + method: 'post', + data }) \ No newline at end of file diff --git a/src/page/Home/User/index.module.scss b/src/page/Home/User/index.module.scss index 3f50d89..e0d7e8a 100644 --- a/src/page/Home/User/index.module.scss +++ b/src/page/Home/User/index.module.scss @@ -21,11 +21,14 @@ display: flex; align-items: center; + >button { + margin-right: 22px; + } + .userBtnsDel { background-color: #3A1457; box-shadow: none; color: white; - margin-left: 22px; &:hover { background-color: lighten(#3A1457, 5%) !important; diff --git a/src/page/Home/User/index.tsx b/src/page/Home/User/index.tsx index ffa9538..b3879d8 100644 --- a/src/page/Home/User/index.tsx +++ b/src/page/Home/User/index.tsx @@ -2,11 +2,16 @@ import styles from '@/page/Home/User/index.module.scss' import { useEffect, useState } from "react"; import Operation from '@/components/Operation'; import { Button, Input, Table, Pagination, Modal, message, Select } from "antd"; -import { SearchOutlined } from '@ant-design/icons'; -import { GetUserList, PostUser, PutUser, DeleteUser, PutUserPwd, GetRoleDpList } from '@/api/Home/User'; +import { ExclamationCircleFilled, SearchOutlined } from '@ant-design/icons'; +import { GetUserList, PostUser, PutUser, DeleteUser, PutUserPwd, GetRoleDpList, PostUserImport } from '@/api/Home/User'; import * as CryptoJS from 'crypto-js'; import ImageUrl from '@/utils/package/imageUrl'; +import { storage } from '@/utils'; const { Column } = Table +const { confirm } = Modal; +const { exec } = require('child_process'); +const fs = require('fs').promises; +const setting = await JSON.parse(storage.getItem('setting') as string) const User: React.FC = () => { const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [isCreateUser, setIsCreateUser] = useState(false); @@ -27,6 +32,7 @@ const User: React.FC = () => { UserName: "" }) const [changeUserPawModal, setChangeUserPawModal] = useState(false) + const [changeImportModal, setChangeImportModal] = useState(false) const [changeUserPawFrom, setChangeUserPawFrom] = useState({ Pwd: "", newPwd: '', @@ -72,6 +78,41 @@ const User: React.FC = () => { } }) } + const fileUpLoad = async (data: { url: string, content: string, fileName: string }): Promise => { + try { + const response = await fetch(data.url); + const arrayBuffer = await response.arrayBuffer(); + const buffer = Buffer.from(arrayBuffer); + await fs.writeFile(`${setting.shareFilesPath}\\${data.fileName}`, buffer, {}); + setChangeImportModal(false) + confirm({ + title: '提示', + icon: , + content: data.content, + centered: true, + okText: '打开文件夹', + cancelText: '关闭', + async onOk() { + await fs.access(setting.shareFilesPath, fs.constants.F_OK); + if (process.platform === 'win32') { + exec(`explorer "${setting.shareFilesPath}"`); + } else if (process.platform === 'darwin') { + exec(`open "${setting.shareFilesPath}"`); + } + }, + onCancel() { + } + }) + } catch (error: any) { + if (error.code === 'ENOENT') { + message.error('文件夹不存在!') + return + } else { + message.error(error) + } + } + } + return ( <>
@@ -100,6 +141,13 @@ const User: React.FC = () => { className='m-ant-btn'> 添加用户 +
+ setChangeImportModal(false)} footer={null} centered width={'300px'}> +
+
+ +
+
+ +
+
+
) }