From aae952f5e33d9fe29c12f55b7012eb13a05a3049 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 5 Aug 2024 10:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=AE=A1=E7=90=86:=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91:=20=E4=BB=85=E4=BF=A1=E6=81=AF,=20=E5=A4=9A?= =?UTF-8?q?=E8=AF=AD=E7=A7=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/products/Detail/ProductInfo.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/views/products/Detail/ProductInfo.jsx b/src/views/products/Detail/ProductInfo.jsx index 79f0eb0..be29df2 100644 --- a/src/views/products/Detail/ProductInfo.jsx +++ b/src/views/products/Detail/ProductInfo.jsx @@ -53,7 +53,7 @@ const ProductInfo = ({ ...props }) => { const copyFields = pick(editingProduct.info, ['product_type_id']); // 'title', const readyToSubInfo = { ...copyNewProduct.info, ...editingProduct.info, ...values.info, ...copyFields, type: copyFields.product_type_id, ...poster }; // console.log('onSave', editingProduct.info, readyToSubInfo); - const prevLgcDetailsMapped = editingProduct.lgc_details.reduce((r, c) => ({ ...r, [c.lgc]: { ...c, description: c.descriptions } }), {}); // todo: description字段不一致 + const prevLgcDetailsMapped = editingProduct.lgc_details.reduce((r, c) => ({ ...r, [c.lgc]: { ...c, description: c.descriptions } }), {}); const mergedLgc = { ...prevLgcDetailsMapped, ...values.lgc_details_mapped }; /** quotation */ @@ -67,13 +67,18 @@ const ProductInfo = ({ ...props }) => { travel_agency_id: activeAgency.travel_agency_id, info: readyToSubInfo, lgc_details: Object.values(mergedLgc), + // 新增: 需要默认年份数据一条; 编辑: 仅提交信息数据 + // ...(isEmpty(readyToSubInfo.id) ? { quotation: Object.values(mergedQ) } : {}), quotation: Object.values(mergedQ), }); setLoading(false); success ? message.success(t('Success')) : message.error(t('Failed')); // 保存后更新数据 - appendNewProduct(result); - setEditingProduct(result); + const _result = structuredClone(result); + // _result.quotation = editingProduct.quotation; + // const title = result.info.title || result.lgc_details?.['2']?.title || result.lgc_details?.['1']?.title || ''; + appendNewProduct(_result); + setEditingProduct(_result); }; return ( <>