大小写
This commit is contained in:
@@ -31,7 +31,7 @@ const authMenu: MenuDataItem = {
|
||||
icon: <BarsOutlined style={iconStyle} />,
|
||||
children: [
|
||||
{ name: '管理员信息', path: '/staff/list', auth: 'SF_ADMIN_ADMIN_VIEW' },
|
||||
{ name: '组织架构', path: '/staff/dep', auth: 'SF_ADMIN_DEPART_VIEW' },
|
||||
{ name: '组织架构', path: '/staff/dept', auth: 'SF_ADMIN_DEPART_VIEW' },
|
||||
{ name: '岗位角色', path: '/staff/group', auth: 'SF_ADMIN_GROUP_VIEW' },
|
||||
{ name: '我的权限', path: '/staff/auth', auth: 'SF_ADMIN_AUTH_VIEW' },
|
||||
{ name: '登录日志', path: '/staff/login', auth: 'SF_LOGIN_LOG_VIEW' },
|
||||
|
||||
@@ -7,7 +7,7 @@ import Index from '@/pages/Index';
|
||||
import Login from '@/pages/Record/Login';
|
||||
import Sys from '@/pages/Record/Sys';
|
||||
import Auth from '@/pages/Staff/Auth';
|
||||
import Dep from '@/pages/Staff/Dep';
|
||||
import Dept from '@/pages/Staff/Dept';
|
||||
import Grp from '@/pages/Staff/Grp';
|
||||
import StaffList from '@/pages/Staff/List';
|
||||
import UserList from '@/pages/User/List';
|
||||
@@ -44,7 +44,7 @@ export const routes: IRouteItem[] = [
|
||||
Layout: AppLayout,
|
||||
children: [
|
||||
{ path: '/list', Component: StaffList },
|
||||
{ path: '/dep', Component: Dep },
|
||||
{ path: '/dept', Component: Dept },
|
||||
{ path: '/group', Component: Grp },
|
||||
{ path: '/auth', Component: Auth },
|
||||
{ path: '/login', Component: Login },
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Button, Form, Input, notification } from 'antd';
|
||||
import { stringify } from 'qs';
|
||||
import { Button, Form, Input, notification, Upload } from 'antd';
|
||||
import type React from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { AdminServices } from '@/services/AdminServices';
|
||||
import { useUserStore } from '@/store/UserStore';
|
||||
import type { IRef } from '@/utils/type';
|
||||
@@ -18,8 +17,10 @@ export type IProfileEditFormType = {
|
||||
export const ProfileEditForm: React.FC<IProps> = (props) => {
|
||||
const [form] = Form.useForm();
|
||||
const userInfo = useUserStore().user;
|
||||
const [previewUrl, setPreviewUrl] = useState<string>();
|
||||
const avatarFileRef = useRef<File | null>(null);
|
||||
|
||||
// 请求成功回调
|
||||
// 保存回调
|
||||
const success = (res: any) => {
|
||||
if (res.err_code === 0) {
|
||||
notification.success({ message: '保存成功' });
|
||||
@@ -27,28 +28,96 @@ export const ProfileEditForm: React.FC<IProps> = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const { loading: editLoading, request: editRequest } = useRequest(AdminServices.profile, { onSuccess: success });
|
||||
const { loading: editLoading, request: editRequest } = useRequest(AdminServices.profile, {
|
||||
onSuccess: success,
|
||||
});
|
||||
|
||||
// 保存方法
|
||||
const save = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
editRequest(stringify(values));
|
||||
const values = await form.getFieldsValue();
|
||||
console.log('values', values);
|
||||
// 使用 FormData
|
||||
const formData = new FormData();
|
||||
|
||||
// 避免空密码提交
|
||||
if (values.password) {
|
||||
formData.append('password', values.password);
|
||||
}
|
||||
|
||||
// 普通字段
|
||||
formData.append('nickname', values.nickname);
|
||||
formData.append('mobile', values.mobile);
|
||||
formData.append('email', values.email || '');
|
||||
|
||||
// 上传头像文件
|
||||
if (avatarFileRef.current) {
|
||||
formData.append('avatar', avatarFileRef.current);
|
||||
}
|
||||
|
||||
//console.log('formData entries:');
|
||||
// formData.forEach((value, key) => {
|
||||
// console.log(key, value);
|
||||
// });
|
||||
//console.log('formData', formData);
|
||||
// 调用 useRequest
|
||||
editRequest(formData);
|
||||
} catch (error) {
|
||||
console.log('表单验证未通过', error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const uri = `${userInfo.avatar}?v=${encodeURIComponent(userInfo.update_date)}`;
|
||||
console.log('uri', uri);
|
||||
form.setFieldsValue({
|
||||
username: userInfo.username,
|
||||
mobile: userInfo.mobile,
|
||||
email: userInfo.email,
|
||||
nickname: userInfo.nickname,
|
||||
avatar: uri, // 默认头像
|
||||
});
|
||||
setPreviewUrl(userInfo.avatar);
|
||||
}, [userInfo]);
|
||||
|
||||
return (
|
||||
<Form form={form} labelCol={{ style: { width: window?.dfConfig?.language === 'zh-cn' ? 80 : 120 } }}>
|
||||
<Form.Item style={{ marginBottom: 12, textAlign: 'center' }}>
|
||||
<Upload
|
||||
accept='.jpg,.png,.jpeg'
|
||||
showUploadList={false}
|
||||
beforeUpload={(file) => {
|
||||
// 如果有预览 URL,释放对象
|
||||
if (previewUrl) {
|
||||
URL.revokeObjectURL(previewUrl);
|
||||
}
|
||||
|
||||
avatarFileRef.current = file;
|
||||
const url = URL.createObjectURL(file);
|
||||
|
||||
setPreviewUrl(url);
|
||||
//src={`${previewUrl}?v=${encodeURIComponent(userInfo.update_date)}`}
|
||||
|
||||
// 阻止自动上传
|
||||
return false;
|
||||
}}
|
||||
>
|
||||
<div style={{ width: 104, height: 104 }}>
|
||||
<img
|
||||
src={previewUrl}
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
borderRadius: 8,
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
alt='avatar'
|
||||
/>
|
||||
</div>
|
||||
</Upload>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label='用户名' name='username'>
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
|
||||
@@ -242,9 +242,9 @@ const DepListForm: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const Dep = () => (
|
||||
const Dept = () => (
|
||||
<PageContainerPlugin breadcrumb={['权限管理', '组织架构']}>
|
||||
<DepListForm />
|
||||
</PageContainerPlugin>
|
||||
);
|
||||
export default Dep;
|
||||
export default Dept;
|
||||
@@ -14,7 +14,7 @@ import { AdminServices } from '@/services/AdminServices';
|
||||
import { useAuthStore } from '@/store/AuthStore';
|
||||
import { tableFixedByPhone, toArray } from '@/utils/common';
|
||||
import { useRequest } from '@/utils/useRequest';
|
||||
import AdminDepSelect from '../Dep/components/AdminDepSelect';
|
||||
import AdminDepSelect from '../Dept/components/AdminDepSelect';
|
||||
import AdminGrpSelect from '../Grp/components/AdminGrpSelect';
|
||||
import { AdminEditModal, type IAdminEditModalType } from './components/AdminEditModal';
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ export type UserInfo = {
|
||||
wx_nick_name?: string;
|
||||
wx_open_id?: string;
|
||||
department_id?: number;
|
||||
update_date?: any;
|
||||
};
|
||||
|
||||
export type CompanyInfo = {
|
||||
|
||||
@@ -39,7 +39,7 @@ export const pathAddApiString = (path: string): string => {
|
||||
if (`${path}`.startsWith('/')) {
|
||||
return `/api/adminrelas${path}`;
|
||||
}
|
||||
return `/api/adminrelas/${path}`;
|
||||
return `/api/adminrelas${path}`;
|
||||
}
|
||||
return path;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ export default defineConfig({
|
||||
rewrite: (path) => path.replace(/^\/api/, ''), // 不可以省略rewrite
|
||||
},
|
||||
'/static': {
|
||||
target: 'http://192.168.1.138:83',
|
||||
target: 'http://www.free.loc',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''), // 不可以省略rewrite
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user