diff --git a/src/components/DataPreview/plaza/components/market/calendar/index.tsx b/src/components/DataPreview/plaza/components/market/calendar/index.tsx index 13729d6e70d245a79f243584382dc5e9cfb79e6e..ca057a05a3f49588d399a7c2242e2be5a6cb0bc4 100644 --- a/src/components/DataPreview/plaza/components/market/calendar/index.tsx +++ b/src/components/DataPreview/plaza/components/market/calendar/index.tsx @@ -1,8 +1,9 @@ import React, { useMemo, useState, useRef, useEffect } from 'react'; -import { Calendar, Empty, Tag, Tooltip } from 'antd'; +import { Calendar, DatePicker, Empty, Tag, Tooltip } from 'antd'; import dayjs from 'dayjs'; import isBetween from 'dayjs/plugin/isBetween'; import { TimeSlotRule, PriceMode } from '../timeSlotConfig'; +import moment from 'moment'; dayjs.extend(isBetween); @@ -778,10 +779,61 @@ const SelectableCalendarTab: React.FC = ({ ); }; +// 共享周期 下单选择 时间段 +const CycleTimeTab: React.FC = ({ product, value, onChange }) => { + return ( +
+
+ 预约共享周期 +
+ { + return ( + current && + (current < moment(product!.useStartTime, 'YYYY-MM-DD').startOf('day') || + current > moment(product!.useEndTime, 'YYYY-MM-DD').endOf('day')) + ); + }} + onChange={(vals) => { + if (Array.isArray(vals) && vals.length > 1) { + const startTime = vals[0]!.format('YYYY-MM-DD'); + const endTime = vals[1]!.format('YYYY-MM-DD'); + const bookingPersons: BookingPerson[] = Array.from({ length: 1 }, (_, i) => ({ + name: value?.bookingPersons[i]?.name || '', + phone: value?.bookingPersons[i]?.phone || '', + email: value?.bookingPersons[i]?.email, + organization: value?.bookingPersons[i]?.organization, + purpose: value?.bookingPersons[i]?.purpose, + isContact: i === 0, + })); + onChange && + onChange({ + ruleId: product!.id, + date: '', + startTime, + endTime, + durationMinutes: 0, + slotCount: 1, + maxConcurrent: 1, + personCount: 1, + bookingPersons, + totalPrice: product!.price, + priceMode: 'package', + unitPrice: product!.price, + }); + } + }} + /> +
+ ); +}; // ===== 统一导出 ===== const CalendarTab: React.FC = (props) => { if (props.onChange) { - return ; + if (props.product?.useTimeRules?.length) { + return ; + } + return ; } return ; }; diff --git a/src/components/DataPreview/plaza/components/market/productDetailModal/index.tsx b/src/components/DataPreview/plaza/components/market/productDetailModal/index.tsx index f29e1a9f9b4290267fbe2304ab26ded89da241d9..c7123f50302d94176d492c4291fd4dfb7a473deb 100644 --- a/src/components/DataPreview/plaza/components/market/productDetailModal/index.tsx +++ b/src/components/DataPreview/plaza/components/market/productDetailModal/index.tsx @@ -315,7 +315,13 @@ export const ProductDetailModal: React.FC = ({ ? '套餐/打包售卖' : currentProduct.sellType == 'single' ? '分规格售卖' - : '单件直售'} + : currentProduct.sellType == 'direct' + ? '单件直售' + : currentProduct.sellType == 'time' + ? '预约时段共享' + : currentProduct.sellType == 'cycle' + ? '预约周期共享' + : '暂无'}
@@ -484,12 +490,16 @@ export const ProductDetailModal: React.FC = ({ 已选择预约时段
- {selectedBookingInfo.date} + {selectedBookingInfo.date && ( + {selectedBookingInfo.date} + )} {selectedBookingInfo.startTime} - {selectedBookingInfo.endTime} {selectedBookingInfo.personCount}人 - {selectedBookingInfo.durationMinutes}分钟 + {selectedBookingInfo.durationMinutes > 0 && ( + {selectedBookingInfo.durationMinutes}分钟 + )}
{ goods.sellTarget = e.target.value; + if (e.target.value == 'use') { + goods.sellType = 'time'; + } else { + goods.sellType = 'package'; + } setRefreshFlag((prev) => prev + 1); }}> @@ -1438,43 +1444,75 @@ export const GoodsForm: React.FC<{ - {goods.sellTarget !== 'use' && ( - - { - if (goods) { - goods.sellType = e.target.value; - setRefreshFlag((prev) => prev + 1); - } - }}> - 套餐/打包售卖 - 分规格售卖 - 单件直售 - - - )} + + { + if (goods) { + goods.sellType = e.target.value; + console.log(999, goods); + + setRefreshFlag((prev) => prev + 1); + } + }}> + {goods.sellTarget !== 'use' ? ( + <> + 套餐/打包售卖 + 分规格售卖 + 单件直售 + + ) : ( + <> + 预约时段共享 + 预约周期共享 + + )} + + {goods.sellTarget === 'use' && ( - - { - (goods as any).useTimeRules = rules; - // 同时保留向后兼容的总人次:所有时段最大人次之和 - const total = rules.reduce((s, r) => s + (r.maxUsers || 0), 0); - goods.maxUsers = total > 0 ? total : undefined; - setRefreshFlag((prev) => prev + 1); - }} - /> - + {goods.sellType === 'time' ? ( + + { + (goods as any).useTimeRules = rules; + // 同时保留向后兼容的总人次:所有时段最大人次之和 + const total = rules.reduce((s, r) => s + (r.maxUsers || 0), 0); + goods.maxUsers = total > 0 ? total : undefined; + setRefreshFlag((prev) => prev + 1); + }} + /> + + ) : ( + + { + goods.useStartTime = vals?.[0] + ? vals[0].format('YYYY-MM-DD') + : undefined; + goods.useEndTime = vals?.[1] + ? vals[1].format('YYYY-MM-DD') + : undefined; + setRefreshFlag((prev) => prev + 1); + }} + /> + + )} )} {service && !readonly && (