|
|
@ -1,19 +1,22 @@
|
|
|
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { App, Table, Button, Modal, Popconfirm } from 'antd';
|
|
|
|
import { App, Table, Button, Modal, Popconfirm } from 'antd';
|
|
|
|
import useProductsStore, { getAgencyProductExtrasAction, getAgencyProductsAction, addProductExtraAction, delProductExtrasAction } from '@/stores/Products/Index';
|
|
|
|
import { getAgencyProductExtrasAction, getAgencyProductsAction, addProductExtraAction, delProductExtrasAction } from '@/stores/Products/Index';
|
|
|
|
import { isEmpty, cloneDeep } from '@/utils/commons';
|
|
|
|
import { cloneDeep } from '@/utils/commons';
|
|
|
|
import SearchForm from '@/components/SearchForm';
|
|
|
|
import SearchForm from '@/components/SearchForm';
|
|
|
|
|
|
|
|
|
|
|
|
import RequireAuth from '@/components/RequireAuth';
|
|
|
|
import RequireAuth from '@/components/RequireAuth';
|
|
|
|
import { PERM_PRODUCTS_MANAGEMENT } from '@/config';
|
|
|
|
import { PERM_PRODUCTS_MANAGEMENT } from '@/config';
|
|
|
|
|
|
|
|
import { useProductsTypesMapVal } from '@/hooks/useProductsSets';
|
|
|
|
|
|
|
|
|
|
|
|
const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
const { travel_agency_id, use_year } = useParams();
|
|
|
|
const { travel_agency_id, use_year } = useParams();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { notification, message } = App.useApp();
|
|
|
|
const { notification, message } = App.useApp();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const productsTypesMapVal = useProductsTypesMapVal();
|
|
|
|
|
|
|
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
const [loading, setLoading] = useState(false); // bind loading
|
|
|
|
const [loading, setLoading] = useState(false); // bind loading
|
|
|
|
const [searchLoading, setSearchLoading] = useState(false);
|
|
|
|
const [searchLoading, setSearchLoading] = useState(false);
|
|
|
@ -24,27 +27,26 @@ const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
const { starttime, endtime, ...param } = copyObject;
|
|
|
|
const { starttime, endtime, ...param } = copyObject;
|
|
|
|
setSearchLoading(true);
|
|
|
|
setSearchLoading(true);
|
|
|
|
setSearchResult([]);
|
|
|
|
setSearchResult([]);
|
|
|
|
const result = await getAgencyProductsAction({ ...param, audit_state: '1', travel_agency_id, use_year });
|
|
|
|
// debug: audit_state: '1',
|
|
|
|
|
|
|
|
const result = await getAgencyProductsAction({ ...param, audit_state: '0', travel_agency_id, use_year });
|
|
|
|
setSearchResult(result?.products || []);
|
|
|
|
setSearchResult(result?.products || []);
|
|
|
|
setSearchLoading(false);
|
|
|
|
setSearchLoading(false);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const handleAddExtras = async (item) => {
|
|
|
|
const handleAddExtras = async (item) => {
|
|
|
|
// const success = await fetchBindOrder({ coli_sn, conversationid: currentConversationID });
|
|
|
|
|
|
|
|
// success ? message.success('绑定成功') : message.error('绑定失败');
|
|
|
|
|
|
|
|
// setOpen(false);
|
|
|
|
|
|
|
|
if (typeof onPick === 'function') {
|
|
|
|
if (typeof onPick === 'function') {
|
|
|
|
onPick(item);
|
|
|
|
onPick(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// todo:
|
|
|
|
// todo: 如何显示价格表
|
|
|
|
const searchResultColumns = [
|
|
|
|
const searchResultColumns = [
|
|
|
|
|
|
|
|
{ key: 'ptype', dataIndex: ['info', 'product_type_id'], width: '6rem', title: t('products:ProductType'), render: (text, r) => productsTypesMapVal[text].label },
|
|
|
|
{ key: 'title', dataIndex: ['info', 'title'], width: '16rem', title: t('products:Title') },
|
|
|
|
{ key: 'title', dataIndex: ['info', 'title'], width: '16rem', title: t('products:Title') },
|
|
|
|
{
|
|
|
|
{
|
|
|
|
title: t('products:price'),
|
|
|
|
title: t('products:price'),
|
|
|
|
dataIndex: ['quotation', '0', 'value'],
|
|
|
|
dataIndex: ['quotation', '0', 'adult_cost'],
|
|
|
|
width: '10rem',
|
|
|
|
width: '10rem',
|
|
|
|
render: (_, { quotation }) => `${quotation[0].value} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童
|
|
|
|
render: (_, { quotation }) => `${quotation[0].adult_cost} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
key: 'action',
|
|
|
|
key: 'action',
|
|
|
@ -63,7 +65,7 @@ const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<Button type='primary' onClick={() => setOpen(true)} className='mt-2'>
|
|
|
|
<Button type='primary' onClick={() => setOpen(true)} className='mt-2'>
|
|
|
|
{t('New')}
|
|
|
|
{t('New')} {t('products:EditComponents.Extras')}
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
|
|
<Modal width={'95%'} style={{ top: 20 }} open={open} title={'添加附加'} footer={false} onCancel={() => setOpen(false)} destroyOnClose>
|
|
|
|
<Modal width={'95%'} style={{ top: 20 }} open={open} title={'添加附加'} footer={false} onCancel={() => setOpen(false)} destroyOnClose>
|
|
|
@ -119,14 +121,14 @@ const Extras = ({ productId, onChange, ...props }) => {
|
|
|
|
setExtrasData(prev => [].concat(prev, [item]));
|
|
|
|
setExtrasData(prev => [].concat(prev, [item]));
|
|
|
|
// todo: 提交后端; 重复绑定同一个
|
|
|
|
// todo: 提交后端; 重复绑定同一个
|
|
|
|
const newSuccess = await addProductExtraAction({ travel_agency_id, id: productId, extras: [2] });
|
|
|
|
const newSuccess = await addProductExtraAction({ travel_agency_id, id: productId, extras: [2] });
|
|
|
|
newSuccess ? message.success(t('Success')) : message.error(t('Failed'));
|
|
|
|
newSuccess ? message.success(t('Action')+t('Success')) : message.error(t('Action')+t('Failed'));
|
|
|
|
await handleGetAgencyProductExtras();
|
|
|
|
await handleGetAgencyProductExtras();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleDelAddon = async (item) => {
|
|
|
|
const handleDelAddon = async (item) => {
|
|
|
|
// todo: 提交后端
|
|
|
|
// todo: 提交后端
|
|
|
|
const delSuccess = await delProductExtrasAction({ travel_agency_id, id: productId, extras: [2] });
|
|
|
|
const delSuccess = await delProductExtrasAction({ travel_agency_id, id: productId, extras: [2] });
|
|
|
|
delSuccess ? message.success(t('Success')) : message.error(t('Failed'));
|
|
|
|
delSuccess ? message.success(t('Action')+t('Success')) : message.error(t('Action')+t('Failed'));
|
|
|
|
await handleGetAgencyProductExtras();
|
|
|
|
await handleGetAgencyProductExtras();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -143,7 +145,7 @@ const Extras = ({ productId, onChange, ...props }) => {
|
|
|
|
dataIndex: ['quotation', '0', 'value'],
|
|
|
|
dataIndex: ['quotation', '0', 'value'],
|
|
|
|
width: '10rem',
|
|
|
|
width: '10rem',
|
|
|
|
|
|
|
|
|
|
|
|
render: (_, { quotation }) => `${quotation[0].value} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童
|
|
|
|
render: (_, { quotation }) => `${quotation[0].adult_cost} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// { title: t('products:Types'), dataIndex: 'age_type', width: '40%', },
|
|
|
|
// { title: t('products:Types'), dataIndex: 'age_type', width: '40%', },
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -151,7 +153,7 @@ const Extras = ({ productId, onChange, ...props }) => {
|
|
|
|
dataIndex: 'operation',
|
|
|
|
dataIndex: 'operation',
|
|
|
|
width: '4rem',
|
|
|
|
width: '4rem',
|
|
|
|
render: (_, r) => (
|
|
|
|
render: (_, r) => (
|
|
|
|
<Popconfirm title={t('products:sureDelete')} onConfirm={(e) => handleDelAddon(r)} >
|
|
|
|
<Popconfirm title={t('sureDelete')} onConfirm={(e) => handleDelAddon(r)} okText={t('Yes')} >
|
|
|
|
<Button size='small' type='link' danger>
|
|
|
|
<Button size='small' type='link' danger>
|
|
|
|
{t('Delete')}
|
|
|
|
{t('Delete')}
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|