|
|
|
@ -2,15 +2,13 @@ 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 { fetchTravelAgencyByName } from '@/stores/Account'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import { isEmpty } from '@/utils/commons'
|
|
|
|
|
import useAccountStore from '@/stores/Account'
|
|
|
|
|
import useFormStore from '@/stores/Form'
|
|
|
|
|
import { fetchRoleList } from '@/stores/Account'
|
|
|
|
|
import SearchForm from '@/components/SearchForm'
|
|
|
|
|
import RequireAuth from '@/components/RequireAuth'
|
|
|
|
|
import { PERM_ROLE_NEW } from '@/config'
|
|
|
|
|
|
|
|
|
|
const { Title } = Typography
|
|
|
|
|
|
|
|
|
@ -29,7 +27,7 @@ function Management() {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: t('account:travelAgency'),
|
|
|
|
|
dataIndex: 'travelAgency',
|
|
|
|
|
dataIndex: 'travelAgencyName',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: t('account:email'),
|
|
|
|
@ -69,12 +67,15 @@ function Management() {
|
|
|
|
|
const [isAccountModalOpen, setAccountModalOpen] = useState(false)
|
|
|
|
|
const [dataLoading, setDataLoading] = useState(false)
|
|
|
|
|
const [roleAllList, setRoleAllList] = useState([])
|
|
|
|
|
const [travelAgencyList, setTravelAgencyList] = useState([])
|
|
|
|
|
const [currentTravelAgency, setCurrentTravelAgency] = useState(null)
|
|
|
|
|
|
|
|
|
|
const [accountForm] = Form.useForm()
|
|
|
|
|
const [searchAccountByCriteria, accountList, disableAccount, saveOrUpdateAccount, resetAccountPassword] =
|
|
|
|
|
useAccountStore((state) =>
|
|
|
|
|
[state.searchAccountByCriteria, state.accountList, state.disableAccount, state.saveOrUpdateAccount, state.resetAccountPassword])
|
|
|
|
|
|
|
|
|
|
const formValues = useFormStore(state => state.formValues)
|
|
|
|
|
const { notification, modal } = App.useApp()
|
|
|
|
|
|
|
|
|
|
useEffect (() => {
|
|
|
|
@ -90,14 +91,39 @@ function Management() {
|
|
|
|
|
})
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
const handelAccountSearch = () => {
|
|
|
|
|
setDataLoading(true)
|
|
|
|
|
searchAccountByCriteria(formValues)
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: 'Notification',
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setDataLoading(false)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onAccountSeleted = async (account) => {
|
|
|
|
|
console.info(account)
|
|
|
|
|
setTravelAgencyList([{
|
|
|
|
|
label: account.travelAgencyName,
|
|
|
|
|
value: account.travelAgencyId
|
|
|
|
|
}])
|
|
|
|
|
accountForm.setFieldsValue(account)
|
|
|
|
|
setCurrentTravelAgency(account.travelAgencyId)
|
|
|
|
|
setAccountModalOpen(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onAccountFinish = (values) => {
|
|
|
|
|
console.log(values)
|
|
|
|
|
saveOrUpdateAccount(values)
|
|
|
|
|
.then(() => {
|
|
|
|
|
handelAccountSearch()
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: 'Notification',
|
|
|
|
@ -113,6 +139,24 @@ function Management() {
|
|
|
|
|
// form.resetFields()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// [{ value: 33032, label: 'test海外地接B' }]
|
|
|
|
|
const handleTravelAgencySearch = (newValue) => {
|
|
|
|
|
fetchTravelAgencyByName(newValue)
|
|
|
|
|
.then(result => {
|
|
|
|
|
setTravelAgencyList(result.map(r => {
|
|
|
|
|
return {
|
|
|
|
|
label: r.travel_agency_name,
|
|
|
|
|
value: r.travel_agency_id
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleTravelAgencyChange = (newValue) => {
|
|
|
|
|
console.info(newValue)
|
|
|
|
|
setCurrentTravelAgency(newValue)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const showDisableConfirm = (account) => {
|
|
|
|
|
modal.confirm({
|
|
|
|
|
title: 'Do you want to disable this account?',
|
|
|
|
@ -227,7 +271,16 @@ function Management() {
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Select options={[{ value: 33032, label: 'test海外地接B' }]}></Select>
|
|
|
|
|
<Select
|
|
|
|
|
options={travelAgencyList}
|
|
|
|
|
value={currentTravelAgency}
|
|
|
|
|
onChange={handleTravelAgencyChange}
|
|
|
|
|
showSearch
|
|
|
|
|
filterOption={false}
|
|
|
|
|
onSearch={handleTravelAgencySearch}
|
|
|
|
|
notFoundContent={null}
|
|
|
|
|
>
|
|
|
|
|
</Select>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={t('account:management.role')}
|
|
|
|
@ -252,21 +305,8 @@ function Management() {
|
|
|
|
|
dates: { label: t('group:ArrivalDate') },
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
onSubmit={(err, formValues, filedsVal) => {
|
|
|
|
|
console.info(formValues)
|
|
|
|
|
setDataLoading(true)
|
|
|
|
|
searchAccountByCriteria(formValues)
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: 'Notification',
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setDataLoading(false)
|
|
|
|
|
})
|
|
|
|
|
onSubmit={() => {
|
|
|
|
|
handelAccountSearch()
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Row>
|
|
|
|
|