feat: 账号角色管理增加中文;统一 userId;

perf/export-docx
Jimmy Liow 1 year ago
parent 6f446d852a
commit fcef4c486b

@ -8,5 +8,24 @@
"CurrentPassword": "请输入密码。", "CurrentPassword": "请输入密码。",
"NewPassword": "请输入新密码。", "NewPassword": "请输入新密码。",
"ReenterPassword": "请重复输入密码。" "ReenterPassword": "请重复输入密码。"
} },
"createdOn": "创建时间",
"action": "操作",
"action.edit": "编辑",
"action.disable": "禁用",
"action.resetPassword": "重置密码",
"accountList": "管理账号",
"newAccount": "新增账号",
"detail": "详细信息",
"username": "用户名",
"realname": "姓名",
"travelAgencyName": "供应商名称",
"email": "邮箱地址",
"lastLogin": "最后登陆时间",
"roleList": "管理角色",
"newRole": "新增角色",
"roleName": "角色名称",
"permission": "权限"
} }

@ -85,7 +85,7 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({
const { startTokenInterval, loadUserPermission } = get() const { startTokenInterval, loadUserPermission } = get()
const { setStorage } = usingStorage() 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) const userDetail = await fetchUserDetail(loginToken)
await loadUserPermission(userId) await loadUserPermission(userId)
@ -95,7 +95,7 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({
})) }))
setStorage(KEY_LOGIN_TOKEN, loginToken) 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) setStorage(KEY_TRAVEL_AGENCY_ID, userDetail.LMI_VEI_SN)
appendRequestParams('token', loginToken) appendRequestParams('token', loginToken)
// loadPageSpy(`${json.Result.VName}-${json.Result.LoginName}`) // loadPageSpy(`${json.Result.VName}-${json.Result.LoginName}`)

@ -160,8 +160,9 @@ function App() {
items: [...[ items: [...[
{ label: <Link to='/account/change-password'>{t('ChangePassword')}</Link>, key: '0' }, { label: <Link to='/account/change-password'>{t('ChangePassword')}</Link>, key: '0' },
{ label: <Link to='/account/profile'>{t('Profile')}</Link>, key: '1' }, { label: <Link to='/account/profile'>{t('Profile')}</Link>, key: '1' },
isPermitted(PERM_ACCOUNT_MANAGEMENT) ? { label: <Link to='/account/management'>{t('account:management.tile')}</Link>, key: '3' } : null, { type: 'divider' },
isPermitted(PERM_ROLE_NEW) ? { label: <Link to='/account/role-list'>{t('account:management.roleList')}</Link>, key: '4' } : null, isPermitted(PERM_ACCOUNT_MANAGEMENT) ? { label: <Link to='/account/management'>{t('account:accountList')}</Link>, key: '3' } : null,
isPermitted(PERM_ROLE_NEW) ? { label: <Link to='/account/role-list'>{t('account:roleList')}</Link>, key: '4' } : null,
{ type: 'divider' }, { type: 'divider' },
{ label: <Link to='/logout'>{t('Logout')}</Link>, key: '99' }, { label: <Link to='/logout'>{t('Logout')}</Link>, key: '99' },
] ]

@ -1,14 +1,12 @@
import { useState, useEffect } from 'react' import SearchForm from '@/components/SearchForm'
import { Row, Col, Space, Button, Table, Select, TreeSelect, Typography, Modal, App, Form, Input } from 'antd' import useAccountStore, { fetchRoleList, fetchTravelAgencyByName } from '@/stores/Account'
import useFormStore from '@/stores/Form'
import { isEmpty } from '@/utils/commons'
import { ExclamationCircleFilled } from '@ant-design/icons' import { ExclamationCircleFilled } from '@ant-design/icons'
import { useTranslation } from 'react-i18next' import { App, Button, Col, Form, Input, Modal, Row, Select, Space, Table, Typography } from 'antd'
import { fetchTravelAgencyByName } from '@/stores/Account'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { isEmpty } from '@/utils/commons' import { useEffect, useState } from 'react'
import useAccountStore from '@/stores/Account' import { useTranslation } from 'react-i18next'
import useFormStore from '@/stores/Form'
import { fetchRoleList } from '@/stores/Account'
import SearchForm from '@/components/SearchForm'
const { Title } = Typography const { Title } = Typography
@ -26,7 +24,7 @@ function Management() {
dataIndex: 'realname', dataIndex: 'realname',
}, },
{ {
title: t('account:travelAgency'), title: t('account:travelAgencyName'),
dataIndex: 'travelAgencyName', dataIndex: 'travelAgencyName',
}, },
{ {
@ -34,7 +32,7 @@ function Management() {
dataIndex: 'email', dataIndex: 'email',
}, },
{ {
title: t('account:role'), title: t('account:roleName'),
dataIndex: 'role' dataIndex: 'role'
}, },
{ {
@ -43,7 +41,7 @@ function Management() {
render: (text) => (isEmpty(text) ? '' : dayjs(text).format('YYYY-MM-DD HH:mm:ss')) 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', dataIndex: 'account:action',
render: actionRender render: actionRender
}, },
@ -78,7 +76,7 @@ function Management() {
const formValues = useFormStore(state => state.formValues) const formValues = useFormStore(state => state.formValues)
const { notification, modal } = App.useApp() const { notification, modal } = App.useApp()
useEffect (() => { useEffect(() => {
fetchRoleList() fetchRoleList()
.then((roleList) => { .then((roleList) => {
setRoleAllList(roleList.map(r => { setRoleAllList(roleList.map(r => {
@ -189,7 +187,6 @@ function Management() {
duration: 60, duration: 60,
}) })
}) })
console.log('ResetPassword')
}, },
onCancel() { onCancel() {
}, },
@ -204,7 +201,7 @@ function Management() {
autoFocus: true, autoFocus: true,
htmlType: 'submit', htmlType: 'submit',
}} }}
title={t('account:management.newAccount')} title={t('account:detail')}
open={isAccountModalOpen} onOk={() => setAccountModalOpen(false)} onCancel={() => setAccountModalOpen(false)} open={isAccountModalOpen} onOk={() => setAccountModalOpen(false)} onCancel={() => setAccountModalOpen(false)}
destroyOnClose={true} destroyOnClose={true}
clearOnDestroy={true} clearOnDestroy={true}
@ -229,7 +226,7 @@ function Management() {
<Form.Item name='lmi_sn' className='hidden' ><Input /></Form.Item> <Form.Item name='lmi_sn' className='hidden' ><Input /></Form.Item>
<Form.Item name='lmi2_sn' className='hidden' ><Input /></Form.Item> <Form.Item name='lmi2_sn' className='hidden' ><Input /></Form.Item>
<Form.Item <Form.Item
label={t('account:management.username')} label={t('account:username')}
name='username' name='username'
rules={[ rules={[
{ {
@ -241,7 +238,7 @@ function Management() {
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={t('account:management.realname')} label={t('account:realname')}
name='realname' name='realname'
rules={[ rules={[
{ {
@ -253,7 +250,7 @@ function Management() {
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={t('account:management.email')} label={t('account:email')}
name='email' name='email'
rules={[ rules={[
{ {
@ -265,7 +262,7 @@ function Management() {
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={t('account:management.travelAgency')} label={t('account:travelAgencyName')}
name='travelAgencyId' name='travelAgencyId'
rules={[ rules={[
{ {
@ -287,7 +284,7 @@ function Management() {
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={t('account:management.role')} label={t('account:roleName')}
name='roleId' name='roleId'
rules={[ rules={[
{ {
@ -296,17 +293,22 @@ function Management() {
}, },
]} ]}
> >
<Select options={roleAllList}> <Select
options={roleAllList}
filterOption={false}
notFoundContent={null}
>
</Select> </Select>
</Form.Item> </Form.Item>
</Modal> </Modal>
<Space direction='vertical' style={{ width: '100%' }}> <Space direction='vertical' style={{ width: '100%' }}>
<Title level={3}>{t('account:management.tile')}</Title> <Title level={3}>{t('account:accountList')}</Title>
<SearchForm <SearchForm
fieldsConfig={{ fieldsConfig={{
shows: ['username', 'realname', 'dates'], shows: ['username', 'realname'],
fieldProps: { fieldProps: {
dates: { label: t('group:ArrivalDate') }, username: { label: t('account:username') },
realname: { label: t('account:realname') },
}, },
}} }}
onSubmit={() => { onSubmit={() => {
@ -316,7 +318,7 @@ function Management() {
<Row> <Row>
<Col span={24}> <Col span={24}>
<Space> <Space>
<Button onClick={() => setAccountModalOpen(true)}>{t('account:management.newAccount')}</Button> <Button onClick={() => setAccountModalOpen(true)}>{t('account:newAccount')}</Button>
</Space> </Space>
</Col> </Col>
</Row> </Row>

@ -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 RequireAuth from '@/components/RequireAuth'
import { PERM_ROLE_NEW } from '@/config' 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 const { Title } = Typography
@ -15,7 +17,7 @@ function RoleList() {
const roleListColumns = [ const roleListColumns = [
{ {
title: t('account:rolename'), title: t('account:roleName'),
dataIndex: 'role_name', dataIndex: 'role_name',
}, },
{ {
@ -30,8 +32,10 @@ function RoleList() {
}, },
] ]
function actionRender(text, role) { function actionRender(_, role) {
if (role.role_id > 1) { if (role.role_id == 1) {
return (<Tag icon={<SyncOutlined spin />} color='warning'>不能修改</Tag>)
} else {
return ( return (
<Button type='link' key='edit' onClick={() => onRoleSeleted(role)}>{t('account:action.edit')}</Button> <Button type='link' key='edit' onClick={() => onRoleSeleted(role)}>{t('account:action.edit')}</Button>
) )
@ -49,7 +53,7 @@ function RoleList() {
}, {}) }, {})
} }
useEffect (() => { useEffect(() => {
setDataLoading(true) setDataLoading(true)
fetchRoleList() fetchRoleList()
.then(r => { .then(r => {
@ -110,7 +114,7 @@ function RoleList() {
const { notification, modal } = App.useApp() const { notification, modal } = App.useApp()
const onRoleSeleted = (role) => { const onRoleSeleted = (role) => {
fetchPermissionListByRoleId({role_id: role.role_id}) fetchPermissionListByRoleId({ role_id: role.role_id })
.then(result => { .then(result => {
role.res_array = result.map(r => r.res_id) role.res_array = result.map(r => r.res_id)
roleForm.setFieldsValue(role) roleForm.setFieldsValue(role)
@ -154,7 +158,7 @@ function RoleList() {
autoFocus: true, autoFocus: true,
htmlType: 'submit', htmlType: 'submit',
}} }}
title={t('account:management.newRole')} title={t('account:detail')}
open={isRoleModalOpen} onOk={() => setRoleModalOpen(false)} onCancel={() => setRoleModalOpen(false)} open={isRoleModalOpen} onOk={() => setRoleModalOpen(false)} onCancel={() => setRoleModalOpen(false)}
destroyOnClose={true} destroyOnClose={true}
clearOnDestroy={true} clearOnDestroy={true}
@ -177,7 +181,7 @@ function RoleList() {
> >
<Form.Item name='role_id' className='hidden' ><Input /></Form.Item> <Form.Item name='role_id' className='hidden' ><Input /></Form.Item>
<Form.Item <Form.Item
label={t('account:management.roleName')} label={t('account:roleName')}
name='role_name' name='role_name'
rules={[ rules={[
{ {
@ -189,7 +193,7 @@ function RoleList() {
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={t('account:management.permission')} label={t('account:permission')}
name='res_array' name='res_array'
> >
<TreeSelect treeData={permissionTreeData} value={permissionValue} <TreeSelect treeData={permissionTreeData} value={permissionValue}
@ -213,12 +217,12 @@ function RoleList() {
</Form.Item> </Form.Item>
</Modal> </Modal>
<Space direction='vertical' style={{ width: '100%' }}> <Space direction='vertical' style={{ width: '100%' }}>
<Title level={3}>{t('account:management.roleList')}</Title> <Title level={3}>{t('account:roleList')}</Title>
<Row> <Row>
<Col span={24}> <Col span={24}>
<Space> <Space>
<RequireAuth subject={PERM_ROLE_NEW}> <RequireAuth subject={PERM_ROLE_NEW}>
<Button onClick={() => onNewRole()}>{t('account:management.newRole')}</Button> <Button onClick={() => onNewRole()}>{t('account:newRole')}</Button>
</RequireAuth> </RequireAuth>
</Space> </Space>
</Col> </Col>
@ -230,6 +234,7 @@ function RoleList() {
loading={dataLoading} loading={dataLoading}
rowKey='role_id' rowKey='role_id'
pagination={{ pagination={{
pageSize: 20,
showQuickJumper: true, showQuickJumper: true,
showLessItems: true, showLessItems: true,
showSizeChanger: true, showSizeChanger: true,

Loading…
Cancel
Save