From c6a8502b79c59b6cdabf4cd455a62eea2b98c833 Mon Sep 17 00:00:00 2001 From: bai_xin123 <1813467895@qq.com> Date: Wed, 11 Mar 2026 01:53:39 +0000 Subject: [PATCH 1/2] update src/executor/open/spaceTemplate/components/dataDetails/index.tsx. Signed-off-by: bai_xin123 <1813467895@qq.com> --- .../components/dataDetails/index.tsx | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/executor/open/spaceTemplate/components/dataDetails/index.tsx b/src/executor/open/spaceTemplate/components/dataDetails/index.tsx index 7875f4325..87bc2bbf0 100644 --- a/src/executor/open/spaceTemplate/components/dataDetails/index.tsx +++ b/src/executor/open/spaceTemplate/components/dataDetails/index.tsx @@ -4,18 +4,38 @@ import type { schema, model } from '@/ts/base'; import { IMallTemplate } from '@/ts/core/thing/standard/page/spaceTemplate'; import cls from './index.module.less'; +/** + * 数据详情组件的属性接口 + * @interface IDataDetails + * @property {schema.XProduct} data - 商品数据对象 + * @property {IMallTemplate} current - 当前商城模板实例 + * @property {() => void} onCancel - 取消回调函数 + */ interface IDataDetails { data: schema.XProduct; current: IMallTemplate; onCancel: () => void; } +/** + * 商品详情展示组件 + * @param {IDataDetails} props - 组件属性 + * @returns {JSX.Element} 商品详情模态框 + */ const DataDetails = ({ current, data, onCancel }: IDataDetails) => { + // 状态:商品是否已在购物车中 const [staging, setStaging] = useState( current.shoppingCar.products.some((a) => a.id == data.id), ); - const getImage = useCallback((type: string, num?: number,fieldType:boolean) => { + /** + * 获取商品图片的辅助函数 + * @param {string} type - 图片类型字段名 + * @param {number} [num] - 返回图片数量限制 + * @param {boolean} fieldType - 是否从field对象中获取数据 + * @returns {model.FileItemShare[]} 图片数组 + */ + const getImage = useCallback((type: string, num?: number, fieldType:boolean) => { if (fieldType){ let images: model.FileItemShare[] = []; images = JSON.parse(data[type] || '[]'); @@ -27,7 +47,7 @@ const DataDetails = ({ current, data, onCancel }: IDataDetails) => { } }, []); - + // 监听购物车状态变化 useEffect(() => { const id = current.shoppingCar.subscribe(() => { setStaging(current.shoppingCar.products.some((a) => a.id == data.id)); @@ -35,6 +55,7 @@ const DataDetails = ({ current, data, onCancel }: IDataDetails) => { return () => current.shoppingCar.unsubscribe(id); }, []); + // 标签页配置 const tabs = [ { key: '1', @@ -121,10 +142,14 @@ const DataDetails = ({ current, data, onCancel }: IDataDetails) => { ), }, ]; + + // 标签页切换回调 const onChange = useCallback(() => {}, []); + return (
+ {/* 根据模板类型显示不同的图片展示方式 */} {current.metadata.template === 'dataTemplate' ? ( { }}>
{data.field.title || '[未设置名称]'}
+ {/* 非共享模式显示价格 */} {current.metadata.mode !== 'sharing' && (
¥{data.price || 0}
@@ -163,12 +189,14 @@ const DataDetails = ({ current, data, onCancel }: IDataDetails) => { )}
- {/*
+ {/* 暂时注释掉的立即预定功能 */} + {/*
{}}>立即预定
*/}
{ + // 根据购物车状态执行添加或移除操作 if (staging) { current.shoppingCar.remove(data); } else { @@ -185,4 +213,5 @@ const DataDetails = ({ current, data, onCancel }: IDataDetails) => { ); }; +// 使用memo优化组件性能 export default memo(DataDetails); -- Gitee From 5e09f248c54f3287109e4392d18c0fa00b347722 Mon Sep 17 00:00:00 2001 From: bai_xin123 <1813467895@qq.com> Date: Wed, 11 Mar 2026 01:54:35 +0000 Subject: [PATCH 2/2] update src/executor/open/reconfirm/index.tsx. Signed-off-by: bai_xin123 <1813467895@qq.com> --- src/executor/open/reconfirm/index.tsx | 39 ++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/executor/open/reconfirm/index.tsx b/src/executor/open/reconfirm/index.tsx index 4567975a7..097f76e67 100644 --- a/src/executor/open/reconfirm/index.tsx +++ b/src/executor/open/reconfirm/index.tsx @@ -1,46 +1,71 @@ import { Modal, message, Radio, Space } from 'antd'; import React, { useState, useEffect, useRef } from 'react'; +/** + * 组件属性接口定义 + * @interface IProps + */ interface IProps { - open: boolean; - onOk: Function; - onCancel?: () => void; - typeName?: string; + open: boolean; // 控制弹窗显示/隐藏 + onOk: Function; // 确认按钮回调函数 + onCancel?: () => void; // 取消按钮回调函数 + typeName?: string; // 类型名称,用于判断是否显示版本选择 } +/** + * 确认弹窗组件 + * @param {IProps} props - 组件属性 + * @returns {React.FC} 返回确认弹窗组件 + */ const Confirm: React.FC = ({ open, onOk, onCancel, typeName }) => { + // 使用ref保存提交状态,防止重复提交 const saveStatus = useRef(false); + // 类型值数组,用于判断是否显示版本选择 const typeValues = ['表单', '视图']; + // 版本类型状态,默认为'default' const [versionType, setVersionType] = useState('default'); + // 组件挂载时重置提交状态 useEffect(() => { saveStatus.current = false; }, []); + + // 加载状态,用于控制确认按钮的loading效果 const [loading, setLoading] = useState(false); + return ( { + // 防止重复提交 if (saveStatus.current) { message.warn('请勿重复提交单据!稍后可重试'); return false; } + // 设置提交状态为true saveStatus.current = true; setLoading(true); + + // 判断是否需要传递版本类型 const versionStatus = typeName && typeValues.includes(typeName) && versionType == 'default'; + + // 调用确认回调,传递版本状态 await onOk(versionStatus ? versionType : undefined); setLoading(false); }} - confirmLoading={loading} + confirmLoading={loading} // 确认按钮loading状态 onCancel={() => { + // 取消时调用回调并重置提交状态 onCancel && onCancel(); saveStatus.current = false; }}>

您确认进行当前操作吗?

+ + {/* 当typeName在typeValues中时显示版本选择 */} {typeName && typeValues.includes(typeName) && (