产品管理: 附加项目 添加/删除接口

feature/price_manager
Lei OT 1 year ago
parent 07b196fc66
commit 80c1b98671

@ -27,18 +27,18 @@ export const getAgencyProductsAction = async (param) => {
};
/**
* todo:
*
*/
export const addProductExtraAction = async (body) => {
const { errcode, result } = await postJSON(`${HT_HOST}/products/extras`, body);
const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/products_extras_add`, body);
return errcode === 0 ? true : false;
};
/**
* todo:
*
*/
export const delProductExtrasAction = async (body) => {
const { errcode, result } = await postJSON(`${HT_HOST}/products/extras/del`, body);
const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/products_extras_del`, body);
return errcode === 0 ? true : false;
};

@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { App, Table, Button, Modal, Popconfirm } from 'antd';
import { getAgencyProductExtrasAction, getAgencyProductsAction, addProductExtraAction, delProductExtrasAction } from '@/stores/Products/Index';
import { cloneDeep } from '@/utils/commons';
import { cloneDeep, pick } from '@/utils/commons';
import SearchForm from '@/components/SearchForm';
import RequireAuth from '@/components/RequireAuth';
@ -46,7 +46,7 @@ const NewAddonModal = ({ onPick, ...props }) => {
title: t('products:price'),
dataIndex: ['quotation', '0', 'adult_cost'],
width: '10rem',
render: (_, { quotation }) => `${quotation[0].adult_cost} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo:
render: (_, { quotation }) => `${quotation[0].adult_cost} ${quotation[0].currency} / ${quotation[0].unit_name}`,
},
{
key: 'action',
@ -120,15 +120,15 @@ const Extras = ({ productId, onChange, ...props }) => {
const handleNewAddOn = async (item) => {
setExtrasData(prev => [].concat(prev, [item]));
// todo: ;
const newSuccess = await addProductExtraAction({ travel_agency_id, id: productId, extras: [2] });
newSuccess ? message.success(t('Action')+t('Success')) : message.error(t('Action')+t('Failed'));
const _item = pick(item.info, ['id', 'title', 'code']);
const newSuccess = await addProductExtraAction({ travel_agency_id, id: productId, extras: [_item] });
newSuccess ? message.success(`${t('Success')}`) : message.error(`${t('Failed')}`);
await handleGetAgencyProductExtras();
}
const handleDelAddon = async (item) => {
// todo:
const delSuccess = await delProductExtrasAction({ travel_agency_id, id: productId, extras: [2] });
delSuccess ? message.success(t('Action')+t('Success')) : message.error(t('Action')+t('Failed'));
const delSuccess = await delProductExtrasAction({ travel_agency_id, id: productId, extras: [item.info.id] });
delSuccess ? message.success(`${t('Success')}`) : message.error(`${t('Failed')}`);
await handleGetAgencyProductExtras();
};

Loading…
Cancel
Save