|
|
|
|
@ -2,7 +2,7 @@ import { useEffect, useState, useSyncExternalStore } from 'react';
|
|
|
|
|
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 { getAgencyProductExtrasAction, searchPublishedProductsAction, addProductExtraAction, delProductExtrasAction } from '@/stores/Products/Index';
|
|
|
|
|
import { cloneDeep, pick } from '@/utils/commons';
|
|
|
|
|
import SearchForm from '@/components/SearchForm';
|
|
|
|
|
|
|
|
|
|
@ -27,10 +27,9 @@ const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
|
const { starttime, endtime, year, ...param } = copyObject;
|
|
|
|
|
setSearchLoading(true);
|
|
|
|
|
setSearchResult([]);
|
|
|
|
|
// debug: audit_state: '1',
|
|
|
|
|
const search_year = year || use_year;
|
|
|
|
|
const result = await getAgencyProductsAction({ ...param, travel_agency_id, use_year: search_year, audit_state: '0', });
|
|
|
|
|
setSearchResult(result?.products || []);
|
|
|
|
|
const result = await searchPublishedProductsAction({ ...param, use_year: search_year, });
|
|
|
|
|
setSearchResult(result);
|
|
|
|
|
setSearchLoading(false);
|
|
|
|
|
};
|
|
|
|
|
const handleAddExtras = async (item) => {
|
|
|
|
|
@ -39,10 +38,10 @@ const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// todo: 如何显示价格表
|
|
|
|
|
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: 'ptype', dataIndex: 'type', width: '6rem', title: t('products:ProductType'), render: (text, r) => productsTypesMapVal[text]?.label || text },
|
|
|
|
|
{ key: 'code', dataIndex: 'code', width: '6rem', title: t('products:Code') },
|
|
|
|
|
{ key: 'title', dataIndex: 'title', width: '16rem', title: t('products:Title') },
|
|
|
|
|
// {
|
|
|
|
|
// title: t('products:price'),
|
|
|
|
|
// dataIndex: ['quotation', '0', 'adult_cost'],
|
|
|
|
|
@ -72,7 +71,7 @@ const NewAddonModal = ({ onPick, ...props }) => {
|
|
|
|
|
<Modal width={'95%'} style={{ top: 20 }} open={open} title={'添加附加'} footer={false} onCancel={() => setOpen(false)} destroyOnClose>
|
|
|
|
|
<SearchForm
|
|
|
|
|
fieldsConfig={{
|
|
|
|
|
shows: [ 'year', 'keyword'], // 'dates',
|
|
|
|
|
shows: [ 'year', 'keyword', 'products_types'], // 'dates',
|
|
|
|
|
fieldProps: {
|
|
|
|
|
dates: { label: t('products:CreateDate') },
|
|
|
|
|
keyword: { label: t('products:Title'), col: 4 },
|
|
|
|
|
@ -121,14 +120,14 @@ const Extras = ({ productId, onChange, ...props }) => {
|
|
|
|
|
const handleNewAddOn = async (item) => {
|
|
|
|
|
setExtrasData(prev => [].concat(prev, [item]));
|
|
|
|
|
// todo: 提交后端; 重复绑定同一个
|
|
|
|
|
const _item = pick(item.info, ['id', 'title', 'code']);
|
|
|
|
|
const _item = pick(item, ['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) => {
|
|
|
|
|
const delSuccess = await delProductExtrasAction({ travel_agency_id, id: productId, extras: [item.info.id] });
|
|
|
|
|
const delSuccess = await delProductExtrasAction({ travel_agency_id, id: productId, extras: [item.id] });
|
|
|
|
|
delSuccess ? message.success(`${t('Success')}`) : message.error(`${t('Failed')}`);
|
|
|
|
|
await handleGetAgencyProductExtras();
|
|
|
|
|
};
|
|
|
|
|
|