diff --git a/doc/价格管理平台.bmpr b/doc/价格管理平台.bmpr index e1065f7..eb1a8d6 100644 Binary files a/doc/价格管理平台.bmpr and b/doc/价格管理平台.bmpr differ diff --git a/src/stores/Account.js b/src/stores/Account.js index a2391be..6c6410e 100644 --- a/src/stores/Account.js +++ b/src/stores/Account.js @@ -10,6 +10,13 @@ export const postAccountStatus = async (formData) => { return errcode !== 0 ? {} : result } +export const postAccountPassword = async (formData) => { + + const { errcode, result } = await postForm( + `${HT_HOST}/service-CooperateSOA/reset_account_password`, formData) + return errcode !== 0 ? {} : result +} + export const fetchAccountList = async (params) => { const { errcode, result } = await fetchJSON( @@ -42,25 +49,35 @@ const useAccountStore = create((set, get) => ({ accountList: [], - selectedAccount: null, - - selectAccount: (account) => { - set(() => ({ - selectedAccount: account - })) - }, - disableAccount: async (accountId) => { const formData = new FormData() formData.append('wu_id', accountId) - formData.append('account_status', 'enable') + // enable disable + formData.append('account_status', 'disable') const result = await postAccountStatus(formData) console.info(result) }, + resetAccountPassword: async (accountId, password) => { + + const formData = new FormData() + formData.append('wu_id', accountId) + formData.append('newPassword', password) + + return postAccountPassword(formData) + }, + + newRole: () => { + return { + role_id: null, + role_name: '', + role_ids: '' + } + }, + saveOrUpdateRole: async (formValues) => { const formData = new FormData() formData.append('role_id', formValues.role_id) @@ -71,12 +88,11 @@ const useAccountStore = create((set, get) => ({ }, saveOrUpdateAccount: async (formValues) => { - const { selectedAccount } = get() const { userId } = usingStorage() const formData = new FormData() - formData.append('wu_id', selectedAccount.userId) - formData.append('lmi_sn', selectedAccount.lmi_sn) - formData.append('lmi2_sn', selectedAccount.lmi2_sn) + formData.append('wu_id', formValues.userId) + formData.append('lmi_sn', formValues.lmi_sn) + formData.append('lmi2_sn', formValues.lmi2_sn) formData.append('user_name', formValues.username) formData.append('real_name', formValues.realname) formData.append('email', formValues.email) @@ -110,7 +126,8 @@ const useAccountStore = create((set, get) => ({ lastLogin: r.wu_lastlogindate, travelAgency: r.travel_agency_name, travelAgencyId: r.travel_agency_id, - roleId: r.roles, + // 数据库支持逗号分隔多角色(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 f0e7b9f..6c2c323 100644 --- a/src/views/account/Management.jsx +++ b/src/views/account/Management.jsx @@ -12,92 +12,6 @@ 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', - key: '0-0', - children: [ - { - title: '录入机票价格', - value: '0-0-0', - key: '0-0-0', - }, - ], - }, - { - title: '产品管理', - value: '0-1', - key: '0-1', - children: [ - { - title: '搜索供应商产品', - value: 'B-1-0', - key: 'B-1-0', - }, - { - title: '录入产品价格', - value: '0-1-0', - key: '0-1-0', - }, - { - title: '新增产品描述', - value: '0-1-1', - key: '0-1-1', - }, - { - title: '复制供应商产品信息', - value: '0-1-2', - key: '0-1-2', - }, - ], - }, - { - title: '账号管理', - value: '2-1', - key: '2-1', - children: [ - { - title: '搜索账号', - value: '2-1-01', - key: '2-1-01', - }, - { - title: '新增账号', - value: '2-1-11', - key: '2-1-11', - }, - { - title: '禁用账号', - value: '2-1-21', - key: '2-1-21', - }, - { - title: '重置账号密码', - value: '2-1-31', - key: '2-1-31', - }, - { - title: '新增角色', - value: '2-1-41', - key: '2-1-41', - }, - ], - }, -] - function Management() { const { t } = useTranslation() @@ -121,8 +35,7 @@ function Management() { }, { title: t('account:role'), - dataIndex: 'role', - render: roleRender + dataIndex: 'role' }, { title: t('account:lastLogin'), @@ -141,12 +54,6 @@ function Management() { ) } - function roleRender(text) { - return ( - - ) - } - function actionRender(text, account) { return ( @@ -156,28 +63,19 @@ function Management() { ) } - const onPermissionChange = (newValue) => { - console.log('onChange ', newValue) - setPermissionValue(newValue) - } - - const [permissionValue, setPermissionValue] = useState(['0-0-0']) const [isAccountModalOpen, setAccountModalOpen] = useState(false) - const [isRoleModalOpen, setRoleModalOpen] = useState(false) const [dataLoading, setDataLoading] = useState(false) const [roleAllList, setRoleAllList] = useState([]) const [accountForm] = Form.useForm() - const [searchAccountByCriteria, accountList, disableAccount, selectedAccount, saveOrUpdateAccount, selectAccount] = + const [searchAccountByCriteria, accountList, disableAccount, saveOrUpdateAccount, resetAccountPassword] = useAccountStore((state) => - [state.searchAccountByCriteria, state.accountList, state.disableAccount, state.selectedAccount, state.saveOrUpdateAccount, state.selectAccount]) + [state.searchAccountByCriteria, state.accountList, state.disableAccount, state.saveOrUpdateAccount, state.resetAccountPassword]) const { notification, modal } = App.useApp() const onAccountSeleted = async (account) => { accountForm.setFieldsValue(account) - selectAccount(account) - console.info(account) const roleList = await fetchRoleList() setRoleAllList(roleList.map(r => { return { @@ -193,7 +91,6 @@ function Management() { console.log(values) saveOrUpdateAccount(values) .catch(ex => { - console.info(ex.message) notification.error({ message: 'Notification', description: ex.message, @@ -222,11 +119,21 @@ function Management() { } const showResetPasswordConfirm = (account) => { + const randomPassword = account.username + (Math.floor(Math.random() * 900) + 100) modal.confirm({ title: 'Do you want to reset password?', icon: , content: `Username: ${account.username}, Realname: ${account.realname}`, onOk() { + resetAccountPassword(account.userId, randomPassword) + .then(() => { + notification.info({ + message: '新密码:' + randomPassword, + description: `请复制密码给 [${account.realname}]`, + placement: 'top', + duration: 60, + }) + }) console.log('ResetPassword') }, onCancel() { @@ -263,6 +170,9 @@ function Management() { )} > + + + onRoleSeleted(role)}>{text} - ) - } - - function actionRender(text, account) { - return ( - - - - - ) + function actionRender(text, role) { + if (role.role_id > 1) { + return ( + + ) + } } const onPermissionChange = (newValue) => { @@ -139,10 +131,14 @@ function RoleList() { } useEffect (() => { + setDataLoading(true) fetchRoleList() .then(r => { setRoleAllList(r) }) + .finally(() => { + setDataLoading(false) + }) }, []) const [permissionValue, setPermissionValue] = useState(['0-0-0']) @@ -151,16 +147,20 @@ function RoleList() { const [roleAllList, setRoleAllList] = useState([]) const [roleForm] = Form.useForm() - const [saveOrUpdateRole] = + const [saveOrUpdateRole, newRole] = useAccountStore((state) => - [state.saveOrUpdateRole]) + [state.saveOrUpdateRole, state.newRole]) const { notification, modal } = App.useApp() - const onRoleSeleted = async (role) => { + const onRoleSeleted = (role) => { + roleForm.setFieldsValue(role) + setRoleModalOpen(true) + } + + const onNewRole = () => { + const role = newRole() roleForm.setFieldsValue(role) - // selectAccount(account) - // console.info(account) setRoleModalOpen(true) } @@ -212,11 +212,7 @@ function RoleList() { )} > - - - + - +