|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
import { App, Table, Button, Modal, Popconfirm } from 'antd';
|
|
|
|
|
import useProductsStore, { getAgencyProductExtrasAction, getAgencyProductsAction, addProductExtraAction, delProductExtrasAction } from '@/stores/Products/Index';
|
|
|
|
|
import { isEmpty, cloneDeep } from '@/utils/commons';
|
|
|
|
|
import { getAgencyProductExtrasAction, getAgencyProductsAction, addProductExtraAction, delProductExtrasAction } from '@/stores/Products/Index';
|
|
|
|
|
import { cloneDeep } from '@/utils/commons';
|
|
|
|
|
import SearchForm from '@/components/SearchForm';
|
|
|
|
|
|
|
|
|
|
import RequireAuth from '@/components/RequireAuth';
|
|
|
|
@ -63,7 +63,7 @@ const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Button type='primary' onClick={() => setOpen(true)} className='mt-2'>
|
|
|
|
|
{t('New')}
|
|
|
|
|
{t('New')} {t('products:EditComponents.Extras')}
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
<Modal width={'95%'} style={{ top: 20 }} open={open} title={'添加附加'} footer={false} onCancel={() => setOpen(false)} destroyOnClose>
|
|
|
|
@ -119,14 +119,14 @@ const Extras = ({ productId, onChange, ...props }) => {
|
|
|
|
|
setExtrasData(prev => [].concat(prev, [item]));
|
|
|
|
|
// todo: 提交后端; 重复绑定同一个
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDelAddon = async (item) => {
|
|
|
|
|
// todo: 提交后端
|
|
|
|
|
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();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -151,7 +151,7 @@ const Extras = ({ productId, onChange, ...props }) => {
|
|
|
|
|
dataIndex: 'operation',
|
|
|
|
|
width: '4rem',
|
|
|
|
|
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>
|
|
|
|
|
{t('Delete')}
|
|
|
|
|
</Button>
|
|
|
|
|