import { useState } 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 useReservationStore from '@/stores/Reservation'
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 Management() {
const { t } = useTranslation()
const accountListColumns = [
{
title: t('account:username'),
dataIndex: 'username',
render: accountRender
},
{
title: t('account:realname'),
dataIndex: 'realname',
},
{
title: t('account:travelAgency'),
dataIndex: 'travelAgency',
},
{
title: t('account:email'),
dataIndex: 'email',
},
{
title: t('account:role'),
dataIndex: 'role',
render: roleRender
},
{
title: t('account:lastLogin'),
dataIndex: 'lastLogin',
},
{
title: t('account:action'),
dataIndex: 'account:action',
render: actionRender
},
]
function accountRender(text) {
return (
)
}
function roleRender(text) {
return (
)
}
function actionRender() {
return (
)
}
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 [accountList, setaccountList] = useState([
{
key: 1,
username: 'bjyiran',
realname: '怡小芳',
travelAgency: '三千界',
email: 'xiaofang@yiran.com',
role: '国内供应商',
lastLogin: '2024-06-12 13:53'
},
{
key: 2,
username: 'int-robin',
realname: 'Robin',
travelAgency: 'IAT',
email: 'robin@int.com',
role: '海外供应商',
lastLogin: '2024-06-12 13:53'
},
{
key: 3,
username: 'betty-wu',
realname: '吴雪',
travelAgency: '桂林国旅',
email: 'betty@hainatravel.com',
role: '客服组',
lastLogin: '2024-06-12 13:53'
},
{
key: 4,
username: 'lancy',
realname: '吴金倩',
travelAgency: '海纳国旅',
email: 'lancy@hainatravel.com',
role: '产品组',
lastLogin: '2024-06-12 13:53'
},
{
key: 5,
username: 'LYJ',
realname: '廖一军',
travelAgency: '海纳国际旅行社',
email: 'lyj@hainatravel.com',
role: 'Web 开发组,海外测试供应商',
lastLogin: '2024-06-12 13:53'
}
])
const formValuesToSub = useFormStore((state) => state.formValuesToSub)
const [editAccountForm, editRoleForm] = Form.useForm()
const [fetchReservationList] =
useReservationStore((state) =>
[state.fetchAllGuideList, state.fetchReservationList, state.reservationList, state.reservationPage, state.cityList, state.selectReservation, state.getCityListByReservationId])
const { notification, modal } = App.useApp()
const handleAccountOk = () => {
}
const handleAccountCancel = () => {
setAccountModalOpen(false)
}
const handleRoleOk = () => {
}
const handleRoleCancel = () => {
setRoleModalOpen(false)
}
const onFinish = (values) => {
console.log(values)
}
const onFinishFailed = (error) => {
console.log('Failed:', error)
// form.resetFields()
}
// 默认重新搜索第一页,所有状态的计划
const onSearchClick = (current = 1, status = null) => {
}
const showDisableConfirm = () => {
modal.confirm({
title: 'Do you want to disable this account?',
icon: ,
content: 'Username: Ivy, Realname: 怡小芳',
onOk() {
console.log('OK')
},
onCancel() {
console.log('Cancel')
},
})
}
const showResetPasswordConfirm = () => {
modal.confirm({
title: 'Do you want to reset password?',
icon: ,
content: 'Username: Ivy, Realname: 怡小芳',
onOk() {
console.log('OK')
},
onCancel() {
console.log('Cancel')
},
})
}
return (
<>
{t('account:management.newAccount')}
{/* Role Edit */}
{t('account:management.newRole')}
{t('account:management.tile')}
{
console.info(formValues)
// setDataLoading(true)
// fetchReservationList(formVal)
// .catch(ex => {
// notification.error({
// message: 'Notification',
// description: ex.message,
// placement: 'top',
// duration: 4,
// })
// })
// .finally(() => {
// setDataLoading(false)
// })
}}
/>
{ return t('Total') + `:${total}` }
}}
onChange={(pagination) => { onSearchClick(pagination.current) }}
columns={accountListColumns} dataSource={accountList}
/>
>
)
}
export default Management