|
|
|
@ -4,7 +4,8 @@ import { ExclamationCircleFilled } from '@ant-design/icons'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import useFormStore from '@/stores/Form'
|
|
|
|
|
import useAuthStore from '@/stores/Auth'
|
|
|
|
|
import useReservationStore from '@/stores/Reservation'
|
|
|
|
|
import useAccountStore from '@/stores/Account'
|
|
|
|
|
import { fetchRoleList } from '@/stores/Account'
|
|
|
|
|
import SearchForm from '@/components/SearchForm'
|
|
|
|
|
import RequireAuth from '@/components/RequireAuth'
|
|
|
|
|
import { PERM_ROLE_NEW } from '@/config'
|
|
|
|
@ -12,6 +13,18 @@ import { PERM_ROLE_NEW } from '@/config'
|
|
|
|
|
const { Title } = Typography
|
|
|
|
|
|
|
|
|
|
const permissionData = [
|
|
|
|
|
{
|
|
|
|
|
title: '海外供应商',
|
|
|
|
|
value: 'oversea-0',
|
|
|
|
|
key: 'oversea-0',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: '所有海外功能',
|
|
|
|
|
value: 'oversea-0-0',
|
|
|
|
|
key: 'oversea-0-0',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '机票管理',
|
|
|
|
|
value: '0-0',
|
|
|
|
@ -29,6 +42,11 @@ const permissionData = [
|
|
|
|
|
value: '0-1',
|
|
|
|
|
key: '0-1',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: '搜索供应商产品',
|
|
|
|
|
value: 'B-1-0',
|
|
|
|
|
key: 'B-1-0',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '录入产品价格',
|
|
|
|
|
value: '0-1-0',
|
|
|
|
@ -52,19 +70,29 @@ const permissionData = [
|
|
|
|
|
key: '2-1',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: '重置账号密码',
|
|
|
|
|
value: '2-1-0',
|
|
|
|
|
key: '2-1-0',
|
|
|
|
|
title: '搜索账号',
|
|
|
|
|
value: '2-1-01',
|
|
|
|
|
key: '2-1-01',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '新增账号',
|
|
|
|
|
value: '2-1-11',
|
|
|
|
|
key: '2-1-11',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '禁用账号',
|
|
|
|
|
value: '2-1-1',
|
|
|
|
|
key: '2-1-1',
|
|
|
|
|
value: '2-1-21',
|
|
|
|
|
key: '2-1-21',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '重置账号密码',
|
|
|
|
|
value: '2-1-31',
|
|
|
|
|
key: '2-1-31',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '分配账号角色',
|
|
|
|
|
value: '2-1-2',
|
|
|
|
|
key: '2-1-2',
|
|
|
|
|
title: '新增角色',
|
|
|
|
|
value: '2-1-41',
|
|
|
|
|
key: '2-1-41',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
@ -83,6 +111,10 @@ function Management() {
|
|
|
|
|
title: t('account:realname'),
|
|
|
|
|
dataIndex: 'realname',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: t('account:travelAgency'),
|
|
|
|
|
dataIndex: 'travelAgency',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: t('account:email'),
|
|
|
|
|
dataIndex: 'email',
|
|
|
|
@ -103,9 +135,9 @@ function Management() {
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
function accountRender(text) {
|
|
|
|
|
function accountRender(text, account) {
|
|
|
|
|
return (
|
|
|
|
|
<Button type='link' onClick={() => setAccountModalOpen(true)}>{text}</Button>
|
|
|
|
|
<Button type='link' onClick={() => onAccountSeleted(account)}>{text}</Button>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -115,11 +147,11 @@ function Management() {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function actionRender() {
|
|
|
|
|
function actionRender(text, account) {
|
|
|
|
|
return (
|
|
|
|
|
<Space key='actionRenderSpace' size='middle'>
|
|
|
|
|
<Button type='link' key='disable' onClick={() => showDisableConfirm()}>{t('account:action.disable')}</Button>
|
|
|
|
|
<Button type='link' key='resetPassword' onClick={() => showResetPasswordConfirm()}>{t('account:action.resetPassword')}</Button>
|
|
|
|
|
<Button type='link' key='disable' onClick={() => showDisableConfirm(account)}>{t('account:action.disable')}</Button>
|
|
|
|
|
<Button type='link' key='resetPassword' onClick={() => showResetPasswordConfirm(account)}>{t('account:action.resetPassword')}</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
@ -133,112 +165,71 @@ function Management() {
|
|
|
|
|
const [isAccountModalOpen, setAccountModalOpen] = useState(false)
|
|
|
|
|
const [isRoleModalOpen, setRoleModalOpen] = useState(false)
|
|
|
|
|
const [dataLoading, setDataLoading] = useState(false)
|
|
|
|
|
const [accountList, setaccountList] = useState([
|
|
|
|
|
{
|
|
|
|
|
key: 1,
|
|
|
|
|
username: 'bjyiran',
|
|
|
|
|
realname: '怡小芳',
|
|
|
|
|
email: 'xiaofang@yiran.com',
|
|
|
|
|
role: '国内供应商',
|
|
|
|
|
lastLogin: '2024-06-12 13:53'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 2,
|
|
|
|
|
username: 'int-robin',
|
|
|
|
|
realname: 'Robin',
|
|
|
|
|
email: 'robin@int.com',
|
|
|
|
|
role: '海外供应商',
|
|
|
|
|
lastLogin: '2024-06-12 13:53'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 3,
|
|
|
|
|
username: 'betty-wu',
|
|
|
|
|
realname: '吴雪',
|
|
|
|
|
email: 'betty@hainatravel.com',
|
|
|
|
|
role: '客服组',
|
|
|
|
|
lastLogin: '2024-06-12 13:53'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 4,
|
|
|
|
|
username: 'lancy',
|
|
|
|
|
realname: '吴金倩',
|
|
|
|
|
email: 'lancy@hainatravel.com',
|
|
|
|
|
role: '产品组',
|
|
|
|
|
lastLogin: '2024-06-12 13:53'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 5,
|
|
|
|
|
username: 'LYJ',
|
|
|
|
|
realname: '廖一军',
|
|
|
|
|
email: 'lyj@hainatravel.com',
|
|
|
|
|
role: 'Web 开发组,海外测试供应商',
|
|
|
|
|
lastLogin: '2024-06-12 13:53'
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const formValuesToSub = useFormStore((state) => state.formValuesToSub)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted)
|
|
|
|
|
const [roleAllList, setRoleAllList] = useState([])
|
|
|
|
|
|
|
|
|
|
const [editAccountForm, editRoleForm] = Form.useForm()
|
|
|
|
|
const [fetchReservationList] =
|
|
|
|
|
useReservationStore((state) =>
|
|
|
|
|
[state.fetchAllGuideList, state.fetchReservationList, state.reservationList, state.reservationPage, state.cityList, state.selectReservation, state.getCityListByReservationId])
|
|
|
|
|
const [accountForm] = Form.useForm()
|
|
|
|
|
const [searchAccountByCriteria, accountList, disableAccount, selectedAccount, saveOrUpdateAccount, selectAccount] =
|
|
|
|
|
useAccountStore((state) =>
|
|
|
|
|
[state.searchAccountByCriteria, state.accountList, state.disableAccount, state.selectedAccount, state.saveOrUpdateAccount, state.selectAccount])
|
|
|
|
|
|
|
|
|
|
const { notification, modal } = App.useApp()
|
|
|
|
|
|
|
|
|
|
const handleAccountOk = () => {
|
|
|
|
|
const onAccountSeleted = async (account) => {
|
|
|
|
|
accountForm.setFieldsValue(account)
|
|
|
|
|
selectAccount(account)
|
|
|
|
|
console.info(account)
|
|
|
|
|
const roleList = await fetchRoleList()
|
|
|
|
|
setRoleAllList(roleList.map(r => {
|
|
|
|
|
return {
|
|
|
|
|
value: r.role_id,
|
|
|
|
|
label: r.role_name,
|
|
|
|
|
disabled: r.role_id === 1
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
setAccountModalOpen(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleAccountCancel = () => {
|
|
|
|
|
setAccountModalOpen(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleRoleOk = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleRoleCancel = () => {
|
|
|
|
|
setRoleModalOpen(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onFinish = (values) => {
|
|
|
|
|
const onAccountFinish = (values) => {
|
|
|
|
|
console.log(values)
|
|
|
|
|
saveOrUpdateAccount(values)
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
console.info(ex.message)
|
|
|
|
|
notification.error({
|
|
|
|
|
message: 'Notification',
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onFinishFailed = (error) => {
|
|
|
|
|
const onAccountFailed = (error) => {
|
|
|
|
|
console.log('Failed:', error)
|
|
|
|
|
// form.resetFields()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 默认重新搜索第一页,所有状态的计划
|
|
|
|
|
const onSearchClick = (current = 1, status = null) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const showDisableConfirm = () => {
|
|
|
|
|
const showDisableConfirm = (account) => {
|
|
|
|
|
modal.confirm({
|
|
|
|
|
title: 'Do you want to disable this account?',
|
|
|
|
|
icon: <ExclamationCircleFilled />,
|
|
|
|
|
content: 'Username: Ivy, Realname: 怡小芳',
|
|
|
|
|
content: `Username: ${account.username}, Realname: ${account.realname}`,
|
|
|
|
|
onOk() {
|
|
|
|
|
console.log('OK')
|
|
|
|
|
disableAccount(account.userId)
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
console.log('Cancel')
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const showResetPasswordConfirm = () => {
|
|
|
|
|
const showResetPasswordConfirm = (account) => {
|
|
|
|
|
modal.confirm({
|
|
|
|
|
title: 'Do you want to reset password?',
|
|
|
|
|
icon: <ExclamationCircleFilled />,
|
|
|
|
|
content: 'Username: Ivy, Realname: 怡小芳',
|
|
|
|
|
content: `Username: ${account.username}, Realname: ${account.realname}`,
|
|
|
|
|
onOk() {
|
|
|
|
|
console.log('OK')
|
|
|
|
|
console.log('ResetPassword')
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
console.log('Cancel')
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -247,137 +238,106 @@ function Management() {
|
|
|
|
|
<>
|
|
|
|
|
<Modal
|
|
|
|
|
centered
|
|
|
|
|
open={isAccountModalOpen} onOk={handleAccountOk} onCancel={handleAccountCancel}
|
|
|
|
|
>
|
|
|
|
|
<Form
|
|
|
|
|
name='basic'
|
|
|
|
|
form={editAccountForm}
|
|
|
|
|
okButtonProps={{
|
|
|
|
|
autoFocus: true,
|
|
|
|
|
htmlType: 'submit',
|
|
|
|
|
}}
|
|
|
|
|
title={t('account:management.newAccount')}
|
|
|
|
|
open={isAccountModalOpen} onOk={() => setAccountModalOpen(false)} onCancel={() => setAccountModalOpen(false)}
|
|
|
|
|
destroyOnClose={true}
|
|
|
|
|
clearOnDestroy={true}
|
|
|
|
|
modalRender={(dom) => (
|
|
|
|
|
<Form
|
|
|
|
|
name='AccountForm'
|
|
|
|
|
form={accountForm}
|
|
|
|
|
layout='vertical'
|
|
|
|
|
size='large'
|
|
|
|
|
style={{
|
|
|
|
|
maxWidth: 600,
|
|
|
|
|
}}
|
|
|
|
|
onFinish={onFinish}
|
|
|
|
|
onFinishFailed={onFinishFailed}
|
|
|
|
|
onFinish={onAccountFinish}
|
|
|
|
|
onFinishFailed={onAccountFailed}
|
|
|
|
|
autoComplete='off'
|
|
|
|
|
>
|
|
|
|
|
<Form.Item><Title level={2}>{t('account:management.newAccount')}</Title></Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.username')}
|
|
|
|
|
name='username'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.username'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.realname')}
|
|
|
|
|
name='realname'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.realname'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.email')}
|
|
|
|
|
name='email'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.email'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item label={t('account:management.role')}>
|
|
|
|
|
<Select>
|
|
|
|
|
<Select.Option value='1'>客服组</Select.Option>
|
|
|
|
|
<Select.Option value='2'>产品组</Select.Option>
|
|
|
|
|
<Select.Option value='3'>国内供应商</Select.Option>
|
|
|
|
|
<Select.Option value='4'>海外供应商</Select.Option>
|
|
|
|
|
<Select.Option value='5'>技术研发部</Select.Option>
|
|
|
|
|
<Select.Option value='0' disabled>系统管理员</Select.Option>
|
|
|
|
|
</Select>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
</Modal>
|
|
|
|
|
{/* Role Edit */}
|
|
|
|
|
<Modal
|
|
|
|
|
centered
|
|
|
|
|
open={isRoleModalOpen} onOk={handleRoleOk} onCancel={handleRoleCancel}
|
|
|
|
|
{dom}
|
|
|
|
|
</Form>
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<Form
|
|
|
|
|
name='basic'
|
|
|
|
|
form={editRoleForm}
|
|
|
|
|
layout='vertical'
|
|
|
|
|
size='large'
|
|
|
|
|
style={{
|
|
|
|
|
maxWidth: 600,
|
|
|
|
|
}}
|
|
|
|
|
onFinish={onFinish}
|
|
|
|
|
onFinishFailed={onFinishFailed}
|
|
|
|
|
autoComplete='off'
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.username')}
|
|
|
|
|
name='username'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.username'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Form.Item><Title level={2}>{t('account:management.newRole')}</Title></Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.roleName')}
|
|
|
|
|
name='roleName'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.roleName'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item label={t('account:management.permission')}>
|
|
|
|
|
<TreeSelect treeData={permissionData} value={permissionValue}
|
|
|
|
|
dropdownStyle={{
|
|
|
|
|
maxHeight: 500,
|
|
|
|
|
overflow: 'auto',
|
|
|
|
|
}}
|
|
|
|
|
placement='bottomLeft'
|
|
|
|
|
showSearch
|
|
|
|
|
allowClear
|
|
|
|
|
multiple
|
|
|
|
|
treeDefaultExpandAll
|
|
|
|
|
treeLine={true}
|
|
|
|
|
onChange={onPermissionChange}
|
|
|
|
|
treeCheckable={true}
|
|
|
|
|
showCheckedStrategy={TreeSelect.SHOW_CHILD}
|
|
|
|
|
placeholder={'Please select'}
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
}} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.realname')}
|
|
|
|
|
name='realname'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.realname'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.email')}
|
|
|
|
|
name='email'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.email'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.travelAgency')}
|
|
|
|
|
name='travelAgencyId'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.travelAgency'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Select options={[{ value: 33032, label: 'test海外地接B' }]}></Select>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.role')}
|
|
|
|
|
name='roleId'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: t('account:Validation.role'),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Select options={roleAllList}>
|
|
|
|
|
</Select>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Modal>
|
|
|
|
|
<Space direction='vertical' style={{ width: '100%' }}>
|
|
|
|
|
<Title level={3}>{t('account:management.tile')}</Title>
|
|
|
|
|
<SearchForm
|
|
|
|
|
// initialValue={
|
|
|
|
|
// {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
fieldsConfig={{
|
|
|
|
|
shows: ['username', 'referenceNo', 'dates'],
|
|
|
|
|
shows: ['username', 'realname', 'dates'],
|
|
|
|
|
fieldProps: {
|
|
|
|
|
dates: { label: t('group:ArrivalDate') },
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
onSubmit={(err, formVal, filedsVal) => {
|
|
|
|
|
onSubmit={(err, formValues, filedsVal) => {
|
|
|
|
|
console.info(formValues)
|
|
|
|
|
setDataLoading(true)
|
|
|
|
|
fetchReservationList(formVal)
|
|
|
|
|
searchAccountByCriteria(formValues)
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: 'Notification',
|
|
|
|
@ -395,9 +355,6 @@ function Management() {
|
|
|
|
|
<Col span={24}>
|
|
|
|
|
<Space>
|
|
|
|
|
<Button onClick={() => setAccountModalOpen(true)}>{t('account:management.newAccount')}</Button>
|
|
|
|
|
<RequireAuth subject={PERM_ROLE_NEW}>
|
|
|
|
|
<Button onClick={() => setRoleModalOpen(true)}>{t('account:management.newRole')}</Button>
|
|
|
|
|
</RequireAuth>
|
|
|
|
|
</Space>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
@ -406,6 +363,7 @@ function Management() {
|
|
|
|
|
<Table
|
|
|
|
|
bordered
|
|
|
|
|
loading={dataLoading}
|
|
|
|
|
rowKey='username'
|
|
|
|
|
pagination={{
|
|
|
|
|
showQuickJumper: true,
|
|
|
|
|
showLessItems: true,
|
|
|
|
|