diff --git a/public/locales/zh/account.json b/public/locales/zh/account.json index a7caf37..35c0dc0 100644 --- a/public/locales/zh/account.json +++ b/public/locales/zh/account.json @@ -8,5 +8,24 @@ "CurrentPassword": "请输入密码。", "NewPassword": "请输入新密码。", "ReenterPassword": "请重复输入密码。" - } + }, + "createdOn": "创建时间", + "action": "操作", + "action.edit": "编辑", + "action.disable": "禁用", + "action.resetPassword": "重置密码", + + "accountList": "管理账号", + "newAccount": "新增账号", + "detail": "详细信息", + "username": "用户名", + "realname": "姓名", + "travelAgencyName": "供应商名称", + "email": "邮箱地址", + "lastLogin": "最后登陆时间", + + "roleList": "管理角色", + "newRole": "新增角色", + "roleName": "角色名称", + "permission": "权限" } \ No newline at end of file diff --git a/src/stores/Auth.js b/src/stores/Auth.js index 18dfc3b..59c10c9 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -85,7 +85,7 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({ const { startTokenInterval, loadUserPermission } = get() const { setStorage } = usingStorage() - const { token: loginToken, WU_ID: userId } = await fetchLoginToken(usr, pwd) + const { token: loginToken } = await fetchLoginToken(usr, pwd) const userDetail = await fetchUserDetail(loginToken) await loadUserPermission(userId) @@ -95,7 +95,7 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({ })) setStorage(KEY_LOGIN_TOKEN, loginToken) - setStorage(KEY_USER_ID, userId) + setStorage(KEY_USER_ID, userDetail.LMI_SN) setStorage(KEY_TRAVEL_AGENCY_ID, userDetail.LMI_VEI_SN) appendRequestParams('token', loginToken) // loadPageSpy(`${json.Result.VName}-${json.Result.LoginName}`) diff --git a/src/views/App.jsx b/src/views/App.jsx index 2ac059d..7ac41a7 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -160,8 +160,9 @@ function App() { items: [...[ { label: {t('ChangePassword')}, key: '0' }, { label: {t('Profile')}, key: '1' }, - isPermitted(PERM_ACCOUNT_MANAGEMENT) ? { label: {t('account:management.tile')}, key: '3' } : null, - isPermitted(PERM_ROLE_NEW) ? { label: {t('account:management.roleList')}, key: '4' } : null, + { type: 'divider' }, + isPermitted(PERM_ACCOUNT_MANAGEMENT) ? { label: {t('account:accountList')}, key: '3' } : null, + isPermitted(PERM_ROLE_NEW) ? { label: {t('account:roleList')}, key: '4' } : null, { type: 'divider' }, { label: {t('Logout')}, key: '99' }, ] diff --git a/src/views/account/Management.jsx b/src/views/account/Management.jsx index 517f03f..8a498dc 100644 --- a/src/views/account/Management.jsx +++ b/src/views/account/Management.jsx @@ -1,14 +1,12 @@ -import { useState, useEffect } from 'react' -import { Row, Col, Space, Button, Table, Select, TreeSelect, Typography, Modal, App, Form, Input } from 'antd' +import SearchForm from '@/components/SearchForm' +import useAccountStore, { fetchRoleList, fetchTravelAgencyByName } from '@/stores/Account' +import useFormStore from '@/stores/Form' +import { isEmpty } from '@/utils/commons' import { ExclamationCircleFilled } from '@ant-design/icons' -import { useTranslation } from 'react-i18next' -import { fetchTravelAgencyByName } from '@/stores/Account' +import { App, Button, Col, Form, Input, Modal, Row, Select, Space, Table, Typography } from 'antd' import dayjs from 'dayjs' -import { isEmpty } from '@/utils/commons' -import useAccountStore from '@/stores/Account' -import useFormStore from '@/stores/Form' -import { fetchRoleList } from '@/stores/Account' -import SearchForm from '@/components/SearchForm' +import { useEffect, useState } from 'react' +import { useTranslation } from 'react-i18next' const { Title } = Typography @@ -26,7 +24,7 @@ function Management() { dataIndex: 'realname', }, { - title: t('account:travelAgency'), + title: t('account:travelAgencyName'), dataIndex: 'travelAgencyName', }, { @@ -34,7 +32,7 @@ function Management() { dataIndex: 'email', }, { - title: t('account:role'), + title: t('account:roleName'), dataIndex: 'role' }, { @@ -43,7 +41,7 @@ function Management() { render: (text) => (isEmpty(text) ? '' : dayjs(text).format('YYYY-MM-DD HH:mm:ss')) }, { - title: t('account:action'), + title: t('account:action.edit'), dataIndex: 'account:action', render: actionRender }, @@ -78,7 +76,7 @@ function Management() { const formValues = useFormStore(state => state.formValues) const { notification, modal } = App.useApp() - useEffect (() => { + useEffect(() => { fetchRoleList() .then((roleList) => { setRoleAllList(roleList.map(r => { @@ -189,7 +187,6 @@ function Management() { duration: 60, }) }) - console.log('ResetPassword') }, onCancel() { }, @@ -204,32 +201,32 @@ function Management() { autoFocus: true, htmlType: 'submit', }} - title={t('account:management.newAccount')} + title={t('account:detail')} open={isAccountModalOpen} onOk={() => setAccountModalOpen(false)} onCancel={() => setAccountModalOpen(false)} destroyOnClose={true} clearOnDestroy={true} modalRender={(dom) => (
+ name='AccountForm' + form={accountForm} + layout='vertical' + size='large' + style={{ + maxWidth: 600, + }} + onFinish={onAccountFinish} + onFinishFailed={onAccountFailed} + autoComplete='off' + > {dom}
)} > - - - + + + - - {t('account:management.tile')} + {t('account:accountList')} { @@ -316,7 +318,7 @@ function Management() { - + diff --git a/src/views/account/RoleList.jsx b/src/views/account/RoleList.jsx index 13a1501..71909f1 100644 --- a/src/views/account/RoleList.jsx +++ b/src/views/account/RoleList.jsx @@ -1,12 +1,14 @@ -import { useState, useEffect } from 'react' -import { Row, Col, Space, Button, Table, TreeSelect, Typography, Modal, App, Form, Input } from 'antd' -import { useTranslation } from 'react-i18next' -import useAccountStore from '@/stores/Account' -import { fetchRoleList, fetchPermissionList, fetchPermissionListByRoleId } from '@/stores/Account' -import dayjs from 'dayjs' -import { isEmpty } from '@/utils/commons' import RequireAuth from '@/components/RequireAuth' import { PERM_ROLE_NEW } from '@/config' +import useAccountStore, { fetchPermissionList, fetchPermissionListByRoleId, fetchRoleList } from '@/stores/Account' +import { isEmpty } from '@/utils/commons' +import { + SyncOutlined, +} from '@ant-design/icons' +import { App, Button, Col, Form, Input, Modal, Row, Space, Table, Tag, TreeSelect, Typography } from 'antd' +import dayjs from 'dayjs' +import { useEffect, useState } from 'react' +import { useTranslation } from 'react-i18next' const { Title } = Typography @@ -15,7 +17,7 @@ function RoleList() { const roleListColumns = [ { - title: t('account:rolename'), + title: t('account:roleName'), dataIndex: 'role_name', }, { @@ -30,8 +32,10 @@ function RoleList() { }, ] - function actionRender(text, role) { - if (role.role_id > 1) { + function actionRender(_, role) { + if (role.role_id == 1) { + return (} color='warning'>不能修改) + } else { return ( ) @@ -49,7 +53,7 @@ function RoleList() { }, {}) } - useEffect (() => { + useEffect(() => { setDataLoading(true) fetchRoleList() .then(r => { @@ -110,7 +114,7 @@ function RoleList() { const { notification, modal } = App.useApp() const onRoleSeleted = (role) => { - fetchPermissionListByRoleId({role_id: role.role_id}) + fetchPermissionListByRoleId({ role_id: role.role_id }) .then(result => { role.res_array = result.map(r => r.res_id) roleForm.setFieldsValue(role) @@ -154,71 +158,71 @@ function RoleList() { autoFocus: true, htmlType: 'submit', }} - title={t('account:management.newRole')} + title={t('account:detail')} open={isRoleModalOpen} onOk={() => setRoleModalOpen(false)} onCancel={() => setRoleModalOpen(false)} destroyOnClose={true} clearOnDestroy={true} modalRender={(dom) => (
+ name='RoleForm' + form={roleForm} + layout='vertical' + size='large' + style={{ + maxWidth: 600, + }} + onFinish={onRoleFinish} + onFinishFailed={onRoleFailed} + autoComplete='off' + > {dom}
)} > - - - - - - - + + + + + + + - {t('account:management.roleList')} + {t('account:roleList')} - + @@ -230,6 +234,7 @@ function RoleList() { loading={dataLoading} rowKey='role_id' pagination={{ + pageSize: 20, showQuickJumper: true, showLessItems: true, showSizeChanger: true,