diff --git a/src/configs/adminConfig.ts b/src/configs/adminConfig.ts new file mode 100644 index 0000000..00a20d0 --- /dev/null +++ b/src/configs/adminConfig.ts @@ -0,0 +1,12 @@ +/** + * 管理员状态 + */ +export const statusObj: any = { + 1: '正常', + 2: '禁用', +}; + +export const statusOptions = [ + { label: '正常', value: '1' }, + { label: '禁用', value: '2' }, +]; diff --git a/src/configs/adminLogConfig.ts b/src/configs/adminLogConfig.ts new file mode 100644 index 0000000..305994b --- /dev/null +++ b/src/configs/adminLogConfig.ts @@ -0,0 +1,10 @@ +/** 状态 */ +export const statusObj: any = { + 1: '成功', + 2: '失败', +}; + +export const statusOptions: any = [ + { label: '成功', value: '1' }, + { label: '失败', value: '2' }, +]; diff --git a/src/configs/config.ts b/src/configs/config.ts index a26b2f5..c0501bd 100644 --- a/src/configs/config.ts +++ b/src/configs/config.ts @@ -13,7 +13,7 @@ export const OSSBaseUrl = 'https://cdn.fzcfkj.com/'; export const headerTabNavHeight = 32; export const DefaultERPName = (() => { - return '易宝赞普惠版后台系统'; + return '易宝赞普惠版后台管理系统'; })(); export const Colors = { diff --git a/src/configs/menuConfig.tsx b/src/configs/menuConfig.tsx index 1a66861..9983d7d 100644 --- a/src/configs/menuConfig.tsx +++ b/src/configs/menuConfig.tsx @@ -1,4 +1,4 @@ -import { DashboardOutlined, UserOutlined } from '@ant-design/icons'; +import { BarsOutlined, DashboardOutlined, TeamOutlined, UserOutlined } from '@ant-design/icons'; import type React from 'react'; /* cspell:disable */ @@ -19,20 +19,23 @@ interface MenuDataItem { const userMenu: MenuDataItem = { name: '用户管理', icon: , - children: [ - { name: '用户管理', path: '/user/list', auth: '' }, - // { name: '岗位角色', path: '/user/group', auth: 'SF_ERP_GROUP_VIEW' }, - ], + children: [{ name: '用户信息', path: '/user/list', auth: '' }], //SF_ERP_USER_VIEW }; -const staffMenu: MenuDataItem = { - name: '后台用户', - icon: , +const companyMenu: MenuDataItem = { + name: '企业管理', + icon: , + children: [{ name: '企业信息', path: '/company/list', auth: '' }], //SF_ERP_COMPANY_VIEW +}; +const authMenu: MenuDataItem = { + name: '权限管理', + icon: , children: [ - { name: '组织架构', path: '/staff/dep', auth: 'SF_ERP_DEPART_VIEW' }, - { name: '岗位角色', path: '/staff/group', auth: 'SF_ERP_GROUP_VIEW' }, - { name: '员工管理', path: '/staff/list', auth: 'SF_ERP_STAFF_VIEW' }, - { name: '我的权限', path: '/staff/my', auth: 'SF_MY_RIGHT_VIEW' }, - // { name: '日志管理', path: '/system/record', auth: 'SF_ERP_LOG_VIEW' }, + { name: '管理员信息', path: '/staff/list', auth: '' }, //SF_ERP_ADMIN_VIEW + { name: '组织架构', path: '/staff/dep', auth: '' }, //SF_ERP_DEPART_VIEW + { name: '岗位角色', path: '/staff/group', auth: '' }, //SF_ERP_GROUP_VIEW + { name: '我的权限', path: '/staff/my', auth: '' }, //SF_MY_RIGHT_VIEW + { name: '登录日志', path: '/staff/login', auth: '' }, //SF_LOGIN_LOG_VIEW + { name: '操作日志', path: '/staff/sys', auth: '' }, //SF_OPERATE_LOG_VIEW ], }; @@ -44,7 +47,8 @@ const asideMenuConfig: MenuDataItem[] = [ children: [{ name: '系统主页', path: '/home/index', auth: '' }], }, userMenu, - staffMenu, + companyMenu, + authMenu, ]; export { asideMenuConfig }; diff --git a/src/configs/routes.ts b/src/configs/routes.ts index 39f0d89..672dc52 100644 --- a/src/configs/routes.ts +++ b/src/configs/routes.ts @@ -1,10 +1,14 @@ import { lazy } from 'react'; import AppLayout from '@/layouts/AppLayout'; import EmptyLayout from '@/layouts/EmptyLayout'; +import CompanyList from '@/pages/Company/List'; import ErrorPage from '@/pages/Error'; import Index from '@/pages/Index'; +import Login from '@/pages/Record/Login'; +import Sys from '@/pages/Record/Sys'; import Dep from '@/pages/Staff/dep'; import Group from '@/pages/Staff/group'; +import StaffList from '@/pages/Staff/List'; import UserList from '@/pages/User/List'; import type { IRouteItem } from '@/router/types'; @@ -26,12 +30,23 @@ export const routes: IRouteItem[] = [ // { path: '/group', Component: lazy(() => import('@/pages/Staff/group')) }, ], }, + { + path: '/company', + Layout: AppLayout, + children: [ + { path: '/list', Component: CompanyList }, + // { path: '/group', Component: lazy(() => import('@/pages/Staff/group')) }, + ], + }, { path: '/staff', Layout: AppLayout, children: [ + { path: '/list', Component: StaffList }, { path: '/dep', Component: Dep }, { path: '/group', Component: Group }, + { path: '/login', Component: Login }, + { path: '/sys', Component: Sys }, ], }, { diff --git a/src/configs/staffsConfig.ts b/src/configs/staffsConfig.ts new file mode 100644 index 0000000..80b5e14 --- /dev/null +++ b/src/configs/staffsConfig.ts @@ -0,0 +1,14 @@ +/** 员工类型 */ +export const staffType: any = { + 1: '主账号', + 2: '子账号', + 3: '经销商主账号', + 4: '经销商子账号', +}; + +export const staffTypeOption = [ + { label: '主账号', value: '1' }, + { label: '子账号', value: '2' }, + { label: '经销商主账号', value: '3' }, + { label: '经销商子账号', value: '4' }, +]; diff --git a/src/configs/usersConfig.ts b/src/configs/usersConfig.ts new file mode 100644 index 0000000..42e907c --- /dev/null +++ b/src/configs/usersConfig.ts @@ -0,0 +1,23 @@ +/** 性别 */ +export const userSex: any = { + 1: '男', + 2: '女', +}; + +export const userSexOptions = [ + { label: '男', value: '1' }, + { label: '女', value: '2' }, +]; + +/** + * 用户状态 + */ +export const userState: any = { + 1: '正常', + 0: '禁用', +}; + +export const stateOptions = [ + { label: '正常', value: '1' }, + { label: '禁用', value: '0' }, +]; diff --git a/src/layouts/base.ts b/src/layouts/base.ts index 6638eed..195e96e 100644 --- a/src/layouts/base.ts +++ b/src/layouts/base.ts @@ -1,8 +1,9 @@ +import { AdminServices } from '@/services/AdminServices'; import { requestLite } from '@/utils/useRequest'; export const loginState = async () => { return new Promise((resolve, reject) => { - requestLite('/Users/loginState').then((res) => { + requestLite(AdminServices.loginState).then((res) => { if (res?.err_code == 0) { resolve(res); } else { diff --git a/src/pages/Company/List/components/UserEditModal.tsx b/src/pages/Company/List/components/UserEditModal.tsx new file mode 100644 index 0000000..c25fe6f --- /dev/null +++ b/src/pages/Company/List/components/UserEditModal.tsx @@ -0,0 +1,168 @@ +import { Button, Form, Input, notification, Select } from 'antd'; +import TextArea from 'antd/lib/input/TextArea'; +import { stringify } from 'qs'; +import type React from 'react'; +import { useImperativeHandle, useState } from 'react'; +import ModalPlugin from '@/components/ModalPlugin'; +import { stateOptions, userSexOptions } from '@/configs/usersConfig'; +import { UserServices } from '@/services/UserServices'; +import type { IRef } from '@/utils/type'; +import { useRequest } from '@/utils/useRequest'; + +interface IProps extends IRef { + onCallback?: () => void; +} + +export type IUserEditModalType = { + show: (data?: any) => void; +}; + +export const UserEditModal: React.FC = (props) => { + const [open, setOpen] = useState(false); + const [title, setTitle] = useState(''); + const [form] = Form.useForm(); + const [data, setData] = useState(null); + + // 请求成功回调 + const success = (res: any) => { + if (res.err_code === 0) { + notification.success({ message: '保存成功' }); + props.onCallback?.(); + setOpen(false); + form.resetFields(); // 提交成功重置表单 + } + }; + + const { loading: addLoading, request: addRequest } = useRequest(UserServices.add, { onSuccess: success }); + const { loading: editLoading, request: editRequest } = useRequest(UserServices.edit, { onSuccess: success }); + + const save = async () => { + try { + const values = await form.validateFields(); + // 编辑场景带上主键 + if (data?.user_id) { + values.user_id = data.user_id; + editRequest(stringify(values)); + } else { + addRequest(stringify(values)); + } + } catch (error) { + console.log('表单验证未通过', error); + } + }; + + useImperativeHandle(props.ref, () => ({ + show: (data?: any) => { + setTitle(data ? `${data.login_name} 编辑` : '新增'); + setOpen(true); + setData(data); + + if (data) { + // 编辑场景初始化表单 + form.setFieldsValue({ + login_name: data.login_name, + user_phone: data.user_phone, + user_mail: data.user_mail, + nick_name: data.nick_name, + password: '', // 密码编辑可选 + comments: data.comments, + user_sex: String(data.user_sex), + state: String(data.state), + }); + } else { + form.resetFields(); + form.setFieldsValue({ + user_sex: '1', + state: '1', + }); + } + }, + })); + + return ( + setOpen(false)} + title={title} + footer={[ + , + , + ]} + > +
+ + + + + + + + + + + + + + + + + + + + + {!data?.user_id && ( + + + + )} + + + + + + +