Commit dc1c6630 authored by 涂伟's avatar 涂伟

fix: '运维用户批量导入导出功能优化'

parent 072ee41e
Pipeline #93827 passed with stages
...@@ -19,12 +19,15 @@ import { ...@@ -19,12 +19,15 @@ import {
Form, Form,
Radio, Radio,
Pagination, Pagination,
Upload Upload,
Alert
} from 'antd'; } from 'antd';
import { import {
UserOutlined, UserOutlined,
UserAddOutlined, UserAddOutlined,
UsergroupAddOutlined, UsergroupAddOutlined,
SnippetsOutlined,
UserSwitchOutlined,
EditOutlined, EditOutlined,
EditTwoTone, EditTwoTone,
DeleteOutlined, DeleteOutlined,
...@@ -44,6 +47,7 @@ import { ...@@ -44,6 +47,7 @@ import {
SyncOutlined, SyncOutlined,
ClusterOutlined, ClusterOutlined,
MessageOutlined, MessageOutlined,
UploadOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import PageContainer from '@/components/BasePageContainer'; import PageContainer from '@/components/BasePageContainer';
import { encipher } from '@wisdom-utils/utils/lib/helpers'; import { encipher } from '@wisdom-utils/utils/lib/helpers';
...@@ -75,7 +79,7 @@ import { ...@@ -75,7 +79,7 @@ import {
ChangeSMSState, ChangeSMSState,
AddUserAppBindWhiteList, AddUserAppBindWhiteList,
ExportUserData, ExportUserData,
ImportAccountData, ImportUserData,
GetPasswordRegularization, GetPasswordRegularization,
SysConfiguration SysConfiguration
} from '@/services/userManage/api'; } from '@/services/userManage/api';
...@@ -192,7 +196,8 @@ const UserManage = () => { ...@@ -192,7 +196,8 @@ const UserManage = () => {
const [rules, setRules] = useState(); const [rules, setRules] = useState();
const [btnDisabled, setBtnDisabled] = useState(true); const [btnDisabled, setBtnDisabled] = useState(true);
const [pasType, setPasType] = useState(''); const [pasType, setPasType] = useState('');
const [file, setFile] = useState(''); // 上传文件信息
const [alertTxt, setAlertTxt] = useState(''); // 上传文件信息
const [importUserForm] = Form.useForm(); // 添加用户 const [importUserForm] = Form.useForm(); // 添加用户
const getPasswordRule = () => { const getPasswordRule = () => {
...@@ -941,20 +946,19 @@ const UserManage = () => { ...@@ -941,20 +946,19 @@ const UserManage = () => {
/** ***其他操作*** */ /** ***其他操作*** */
// 导出用户 // 导出用户
const exportRoles = async () => { const exportRoles = async (data) => {
// menuID // menuID
// searchWord // searchWord
// pageSize // pageSize
// currentPage // currentPage
console.log(menuID, 'menuIDmenuIDmenuID');
ExportUserData({ ExportUserData({
groupId: menuID ? menuID : 0, groupId: data.all ? 0 : menuID ? menuID : 0,
key: searchWord, key: data.all ? '' : searchWord,
isModel: false, isModel: data.isModal ? true : false,
}).then(res => { }).then(res => {
// window.open(`${window.origin}/${res.data}`) // window.open(`http:192.168.10.167:8088/${res.data}`)
window.open(`${window.origin}/${res.data}`) window.open(`${window.origin}/${res.data}`)
console.log(res, 'resssssssssssssssssss'); console.log(res, 'resssssssssssssssssss');
}) })
...@@ -1575,6 +1579,39 @@ const UserManage = () => { ...@@ -1575,6 +1579,39 @@ const UserManage = () => {
</Menu> </Menu>
); );
// 本地上传文件
const beforeUpload = val => {
console.log(val);
importUserForm.setFieldsValue({ fileName: val.name });
setFile(val);
return false;
};
const handleOk = () => {
// if(!file) {
// message.error('请上传文件!')
// return false
// }
importUserForm.validateFields().then(res => {
console.log(res, 'resssssssssssss');
const formData = new FormData();
formData.append('file', file);
const params = { query: encipher((res.password), pasType ? pasType : '').toUpperCase(), data: formData }
console.log(params, 'paramssssssssssssssss');
ImportUserData(params).then(res => {
console.log(res, 'ressssssssssssssss');
if (res.code === 0 && res.data.includes('成功')) {
message.success('导入成功!')
setImportAccountVisible(false);
// setAlertTxt('1116666')
} else {
setAlertTxt(res.data)
}
})
})
}
// 校验文件名字不为空 // 校验文件名字不为空
const filenameVerification = (file, special) => { const filenameVerification = (file, special) => {
// 文件名含有特殊字符 提示不能上传 {+,:/?#[]@!$&\\*+;=} // 文件名含有特殊字符 提示不能上传 {+,:/?#[]@!$&\\*+;=}
...@@ -1628,15 +1665,21 @@ const UserManage = () => { ...@@ -1628,15 +1665,21 @@ const UserManage = () => {
const otherButtonMenu = ( const otherButtonMenu = (
<Menu> <Menu>
{/* <Upload {...props}> */} {/* <Upload {...props}> */}
<Menu.Item key="11" onClick={importRoles} icon={<IdcardOutlined />}> <Menu.Item key="11" onClick={importRoles} icon={<UsergroupAddOutlined />}>
批量导入角色 导入用户
</Menu.Item> </Menu.Item>
{/* </Upload> */} {/* </Upload> */}
{/* <Menu.Item key="11" onClick={importRoles} icon={<IdcardOutlined />}> {/* <Menu.Item key="11" onClick={importRoles} icon={<IdcardOutlined />}>
批量导入角色 批量导入角色
</Menu.Item> */} </Menu.Item> */}
<Menu.Item key="22" onClick={exportRoles} icon={<ApartmentOutlined />}> <Menu.Item key="22" onClick={() => { exportRoles({ isModal: true }) }} icon={<SnippetsOutlined />}>
批量导出角色 导出模板
</Menu.Item>
<Menu.Item key="33" onClick={() => {exportRoles({ all: true })}} icon={<UserSwitchOutlined />}>
导出全部用户
</Menu.Item>
<Menu.Item key="44" onClick={exportRoles} icon={<UserSwitchOutlined />}>
导出用户
</Menu.Item> </Menu.Item>
</Menu> </Menu>
); );
...@@ -2030,27 +2073,30 @@ const UserManage = () => { ...@@ -2030,27 +2073,30 @@ const UserManage = () => {
destroyOnClose destroyOnClose
onCancel={() => { onCancel={() => {
setImportAccountVisible(false); setImportAccountVisible(false);
setAlertTxt('')
}} }}
afterClose={() => { afterClose={() => {
importUserForm.resetFields(); importUserForm.resetFields();
setPasswordLevel(''); setPasswordLevel('');
setAlertTxt('')
}} }}
width={520}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
footer={[ footer={[
<Button key="back" onClick={() => setImportAccountVisible(false)} style={{ 'marginRight': '5px' }}> <Button key="back" onClick={() => setImportAccountVisible(false)} style={{ 'marginRight': '5px' }}>
取消 取消
</Button>, </Button>,
<Upload {...uploadProps}> // <Upload {...uploadProps}>
<Button key="submit" <Button key="submit"
type="primary" type="primary"
// loading={loading} // loading={loading}
// onClick={handleOk} onClick={handleOk}
disabled={btnDisabled} // disabled={btnDisabled}
> >
确认 确认
</Button> </Button>
</Upload>, // </Upload>,
]} ]}
> >
<div className={styles.modalContent}> <div className={styles.modalContent}>
...@@ -2084,6 +2130,64 @@ const UserManage = () => { ...@@ -2084,6 +2130,64 @@ const UserManage = () => {
}} }}
/> />
</Form.Item> </Form.Item>
<Form.Item
hasFeedback
name="password2"
label="确认密码"
rules={[
({ getFieldValue }) => ({
validator(_, value) {
if (!value || getFieldValue('password') === value) {
return Promise.resolve();
}
return Promise.reject(new Error('两次输入的密码不一致!'));
},
}),
{ required: true },
]}
>
<Input.Password
placeholder={'请确认密码'}
maxLength="16"
onCopy={e => {
e.preventDefault();
}}
onPaste={e => {
// 禁止粘贴
e.preventDefault();
}}
/>
</Form.Item>
<Form.Item label="本地导入">
<div style={{ display: 'flex' }}>
<Form.Item
name="fileName"
style={{ marginBottom: '0' }}
rules={[
{ required: true, message: '请上传文件!' },
]}>
<Input disabled />
</Form.Item>
<Upload beforeUpload={beforeUpload} showUploadList={false}>
<Button
type="primary"
style={{ marginLeft: '10px' }}
icon={<UploadOutlined />}
shape="circle"
/>
</Upload>
</div>
</Form.Item>
{alertTxt ? <Alert
message="错误信息"
description={
<div dangerouslySetInnerHTML={{__html: alertTxt}} />
}
type="error"
closable
// onClose={onClose}
/> : null}
<div <div
style={{ right: '70px' }} style={{ right: '70px' }}
className={classnames(styles.tipsText, { className={classnames(styles.tipsText, {
......
...@@ -206,7 +206,14 @@ export const AddUserAppBindWhiteList = params => ...@@ -206,7 +206,14 @@ export const AddUserAppBindWhiteList = params =>
export const ExportUserData = params => get(`${PUBLISH_SERVICE}/UserCenter/ExportUserData`, params); export const ExportUserData = params => get(`${PUBLISH_SERVICE}/UserCenter/ExportUserData`, params);
// 导入用户 // 导入用户
export const ImportAccountData = params => // export const ImportUserData = params =>
post(`${PUBLISH_SERVICE}/UserCenter/ImportAccountData`, params); // post(`${PUBLISH_SERVICE}/UserCenter/ImportUserData`, params);
export const ImportUserData = params =>
post(`${PUBLISH_SERVICE}/UserCenter/ImportUserData?password=${params.query}`, params.data, {
headers: {
'Content-Type': 'multipart/form-data;charset=UTF-8',
},
});
// export const DeleteOUNew = params => // export const DeleteOUNew = params =>
// get(`${PUBLISH_SERVICE}/UserCenter/DeleteOU`, params) // get(`${PUBLISH_SERVICE}/UserCenter/DeleteOU`, params)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment