diff --git a/doc/价格管理平台.bmpr b/doc/价格管理平台.bmpr index a33839a..e1065f7 100644 Binary files a/doc/价格管理平台.bmpr and b/doc/价格管理平台.bmpr differ diff --git a/src/main.jsx b/src/main.jsx index 2782a85..9114460 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -18,6 +18,7 @@ import ReservationDetail from "@/views/reservation/Detail"; import ChangePassword from "@/views/account/ChangePassword"; import AccountProfile from "@/views/account/Profile"; import AccountManagement from "@/views/account/Management"; +import RoleList from "@/views/account/RoleList"; import FeedbackIndex from "@/views/feedback/Index"; import FeedbackDetail from "@/views/feedback/Detail"; import FeedbackCustomerDetail from "@/views/feedback/CustomerDetail"; @@ -32,7 +33,7 @@ import Airticket from "@/views/airticket/Index"; import AirticketPlan from "@/views/airticket/Plan"; import { ThemeContext } from '@/stores/ThemeContext' -import { PERM_ACCOUNT_MANAGEMENT, PERM_OVERSEA, PERM_AIR_TICKET } from '@/config' +import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA, PERM_AIR_TICKET } from '@/config' import './i18n'; @@ -55,6 +56,7 @@ const router = createBrowserRouter([ { path: "account/change-password", element: }, { path: "account/profile", element: }, { path: "account/management", element: }, + { path: "account/role-list", element: }, { path: "reservation/newest", element: }, { path: "reservation/:reservationId", element: }, { path: "feedback", element: }, diff --git a/src/stores/Account.js b/src/stores/Account.js index 6ab625f..a2391be 100644 --- a/src/stores/Account.js +++ b/src/stores/Account.js @@ -24,6 +24,13 @@ export const postAccountForm = async (formData) => { return errcode !== 0 ? {} : result } +export const postRoleForm = async (formData) => { + + const { errcode, result } = await postForm( + `${HT_HOST}/service-CooperateSOA/new_or_update_role`, formData) + return errcode !== 0 ? {} : result +} + export const fetchRoleList = async () => { const { errcode, result } = await fetchJSON( @@ -54,6 +61,15 @@ const useAccountStore = create((set, get) => ({ console.info(result) }, + saveOrUpdateRole: async (formValues) => { + const formData = new FormData() + formData.append('role_id', formValues.role_id) + formData.append('role_name', formValues.role_name) + formData.append('res_ids', '2,3') + + return postRoleForm(formData) + }, + saveOrUpdateAccount: async (formValues) => { const { selectedAccount } = get() const { userId } = usingStorage() diff --git a/src/views/App.jsx b/src/views/App.jsx index dd2dec6..779993c 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -149,8 +149,9 @@ function App() { { label: {t('ChangePassword')}, key: '0' }, { label: {t('Profile')}, key: '1' }, { label: {t('account:management.tile')}, key: '3' }, + { label: {t('account:management.roleList')}, key: '4' }, { type: 'divider' }, - { label: {t('Logout')}, key: '4' }, + { label: {t('Logout')}, key: '99' }, ], { type: 'divider' }, { label: <>v{BUILD_VERSION}, key: 'BUILD_VERSION' }, diff --git a/src/views/account/Management.jsx b/src/views/account/Management.jsx index e05eaa1..f0e7b9f 100644 --- a/src/views/account/Management.jsx +++ b/src/views/account/Management.jsx @@ -161,48 +161,32 @@ function Management() { setPermissionValue(newValue) } - const onAccountSeleted = async (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 [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 [editAccountForm, editRoleForm] = Form.useForm() + 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 = () => { - console.info('handleAccountOk') - console.info(editAccountForm) - } - - const handleAccountCancel = () => { - setAccountModalOpen(false) - } - - const handleRoleOk = () => { - console.info('handleRoleOk') - } - - const handleRoleCancel = () => { - setRoleModalOpen(false) + 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 onAccountFinish = (values) => { @@ -219,7 +203,7 @@ function Management() { }) } - const onAccountFinishFailed = (error) => { + const onAccountFailed = (error) => { console.log('Failed:', error) // form.resetFields() } @@ -259,20 +243,20 @@ function Management() { htmlType: 'submit', }} title={t('account:management.newAccount')} - open={isAccountModalOpen} onOk={handleAccountOk} onCancel={handleAccountCancel} - destroyOnClose + open={isAccountModalOpen} onOk={() => setAccountModalOpen(false)} onCancel={() => setAccountModalOpen(false)} + destroyOnClose={true} + clearOnDestroy={true} modalRender={(dom) => (
{dom} @@ -341,58 +325,6 @@ function Management() { - {/* Role Edit */} - - - {t('account:management.newRole')} - - - - - - - -
{t('account:management.tile')} - - - diff --git a/src/views/account/RoleList.jsx b/src/views/account/RoleList.jsx new file mode 100644 index 0000000..923d43e --- /dev/null +++ b/src/views/account/RoleList.jsx @@ -0,0 +1,286 @@ +import { useState, useEffect } from 'react' +import { Row, Col, Space, Button, Table, Select, TreeSelect, Typography, Modal, App, Form, Input } from 'antd' +import { ExclamationCircleFilled } from '@ant-design/icons' +import { useTranslation } from 'react-i18next' +import useFormStore from '@/stores/Form' +import useAuthStore from '@/stores/Auth' +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' + +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 RoleList() { + const { t } = useTranslation() + + const roleListColumns = [ + { + title: t('account:rolename'), + dataIndex: 'role_name', + render: roleRender + }, + { + title: t('account:createdOn'), + dataIndex: 'created_on', + }, + { + title: t('account:action'), + dataIndex: 'account:action', + render: actionRender + }, + ] + + function roleRender(text, role) { + return ( + + ) + } + + function actionRender(text, account) { + return ( + + + + + ) + } + + const onPermissionChange = (newValue) => { + console.log('onChange ', newValue) + setPermissionValue(newValue) + } + + useEffect (() => { + fetchRoleList() + .then(r => { + setRoleAllList(r) + }) + }, []) + + const [permissionValue, setPermissionValue] = useState(['0-0-0']) + const [isRoleModalOpen, setRoleModalOpen] = useState(false) + const [dataLoading, setDataLoading] = useState(false) + const [roleAllList, setRoleAllList] = useState([]) + + const [roleForm] = Form.useForm() + const [saveOrUpdateRole] = + useAccountStore((state) => + [state.saveOrUpdateRole]) + + const { notification, modal } = App.useApp() + + const onRoleSeleted = async (role) => { + roleForm.setFieldsValue(role) + // selectAccount(account) + // console.info(account) + setRoleModalOpen(true) + } + + const onRoleFinish = (values) => { + console.log(values) + saveOrUpdateRole(values) + .catch(ex => { + console.info(ex.message) + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + }) + }) + } + + const onRoleFailed = (error) => { + console.log('Failed:', error) + // form.resetFields() + } + + return ( + <> + setRoleModalOpen(false)} onCancel={() => setRoleModalOpen(false)} + destroyOnClose={true} + clearOnDestroy={true} + modalRender={(dom) => ( +
+ {dom} +
+ )} + > + + + + + + + + + +
+ + {t('account:management.roleList')} + + + + + + + + + + + + { return t('Total') + `:${total}` } + }} + onChange={(pagination) => { onSearchClick(pagination.current) }} + columns={roleListColumns} dataSource={roleAllList} + /> + + + + + ) +} + +export default RoleList