diff --git a/public/locales/zh/account.json b/public/locales/zh/account.json
index 35c0dc0..3849f07 100644
--- a/public/locales/zh/account.json
+++ b/public/locales/zh/account.json
@@ -12,7 +12,10 @@
"createdOn": "创建时间",
"action": "操作",
"action.edit": "编辑",
+ "action.enable": "启用",
"action.disable": "禁用",
+ "action.enable.title": "确定启用该账号吗?",
+ "action.disable.title": "确定禁用该账号吗?",
"action.resetPassword": "重置密码",
"accountList": "管理账号",
diff --git a/src/stores/Account.js b/src/stores/Account.js
index 01010d8..ee3daca 100644
--- a/src/stores/Account.js
+++ b/src/stores/Account.js
@@ -70,16 +70,15 @@ const useAccountStore = create((set, get) => ({
accountList: [],
- disableAccount: async (userId) => {
+ toggleAccountStatus: async (userId, status) => {
+
+ const statusValue = status ? 'enable' : 'disable'
const formData = new FormData()
formData.append('lmi_sn', userId)
- // enable | disable
- formData.append('account_status', 'disable')
-
- const result = await postAccountStatus(formData)
+ formData.append('account_status', statusValue)
- console.info(result)
+ return postAccountStatus(formData)
},
resetAccountPassword: async (userId, password) => {
@@ -147,6 +146,7 @@ const useAccountStore = create((set, get) => ({
lastLogin: r.wu_lastlogindate,
travelAgencyName: r.travel_agency_name,
travelAgencyId: r.travel_agency_id,
+ disabled: r.wu_limitsign,
// 数据库支持逗号分隔多角色(5,6,7),目前界面只需单个。
roleId: parseInt(r.roles),
role: r.roles_name,
diff --git a/src/views/account/Management.jsx b/src/views/account/Management.jsx
index 676ed9a..5496997 100644
--- a/src/views/account/Management.jsx
+++ b/src/views/account/Management.jsx
@@ -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 (
-
+ {
+ showDisableConfirm(account, checked)
+ }} />
)
@@ -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: ,
- 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() {
},