|
|
|
@ -3,7 +3,7 @@ import useAccountStore, { fetchRoleList, fetchTravelAgencyByName } from '@/store
|
|
|
|
|
import useFormStore from '@/stores/Form'
|
|
|
|
|
import { isEmpty } from '@/utils/commons'
|
|
|
|
|
import { ExclamationCircleFilled } from '@ant-design/icons'
|
|
|
|
|
import { App, Button, Col, Form, Input, Modal, Row, Select, Space, Table, Typography } from 'antd'
|
|
|
|
|
import { App, Button, Col, Form, Input, Modal, Row, Select, Space, Table, Typography, Switch } from 'antd'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
@ -53,10 +53,12 @@ function Management() {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function actionRender(text, account) {
|
|
|
|
|
function actionRender(_, account) {
|
|
|
|
|
return (
|
|
|
|
|
<Space key='actionRenderSpace' size='middle'>
|
|
|
|
|
<Button type='link' key='disable' onClick={() => showDisableConfirm(account)}>{t('account:action.disable')}</Button>
|
|
|
|
|
<Switch checkedChildren={t('account:action.enable')} unCheckedChildren={t('account:action.disable')} checked={account.disabled==0} onChange={(checked) => {
|
|
|
|
|
showDisableConfirm(account, checked)
|
|
|
|
|
}} />
|
|
|
|
|
<Button type='link' key='resetPassword' onClick={() => showResetPasswordConfirm(account)}>{t('account:action.resetPassword')}</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
)
|
|
|
|
@ -69,9 +71,9 @@ function Management() {
|
|
|
|
|
const [currentTravelAgency, setCurrentTravelAgency] = useState(null)
|
|
|
|
|
|
|
|
|
|
const [accountForm] = Form.useForm()
|
|
|
|
|
const [searchAccountByCriteria, accountList, disableAccount, saveOrUpdateAccount, resetAccountPassword] =
|
|
|
|
|
const [searchAccountByCriteria, accountList, toggleAccountStatus, saveOrUpdateAccount, resetAccountPassword] =
|
|
|
|
|
useAccountStore((state) =>
|
|
|
|
|
[state.searchAccountByCriteria, state.accountList, state.disableAccount, state.saveOrUpdateAccount, state.resetAccountPassword])
|
|
|
|
|
[state.searchAccountByCriteria, state.accountList, state.toggleAccountStatus, state.saveOrUpdateAccount, state.resetAccountPassword])
|
|
|
|
|
|
|
|
|
|
const formValues = useFormStore(state => state.formValues)
|
|
|
|
|
const { notification, modal } = App.useApp()
|
|
|
|
@ -116,7 +118,6 @@ function Management() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onAccountFinish = (values) => {
|
|
|
|
|
console.log(values)
|
|
|
|
|
saveOrUpdateAccount(values)
|
|
|
|
|
.then(() => {
|
|
|
|
|
handelAccountSearch()
|
|
|
|
@ -156,13 +157,27 @@ function Management() {
|
|
|
|
|
setCurrentTravelAgency(newValue)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const showDisableConfirm = (account) => {
|
|
|
|
|
const showDisableConfirm = (account, status) => {
|
|
|
|
|
|
|
|
|
|
const confirmTitle = status ? t('account:action.enable.title') : t('account:action.disable.title')
|
|
|
|
|
|
|
|
|
|
modal.confirm({
|
|
|
|
|
title: 'Do you want to disable this account?',
|
|
|
|
|
title: confirmTitle,
|
|
|
|
|
icon: <ExclamationCircleFilled />,
|
|
|
|
|
content: `Username: ${account.username}, Realname: ${account.realname}`,
|
|
|
|
|
content: t('account:username') + ': ' + account.username + ', ' + t('account:realname') + ': ' + account.realname,
|
|
|
|
|
onOk() {
|
|
|
|
|
disableAccount(account.userId)
|
|
|
|
|
toggleAccountStatus(account.userId, status)
|
|
|
|
|
.then(() => {
|
|
|
|
|
handelAccountSearch()
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: 'Notification',
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
},
|
|
|
|
|