This commit is contained in:
iqudoo
2026-06-13 02:28:03 +08:00
parent 6c314f9808
commit 932ea4cc39
3 changed files with 23 additions and 21 deletions

View File

@@ -64,6 +64,8 @@ interface DataImporterProps {
templateName: string; templateName: string;
templateVariables: string[]; templateVariables: string[];
variant?: 'default' | 'ps' | 'mobile'; variant?: 'default' | 'ps' | 'mobile';
/** 由外部提供下载入口时隐藏内置按钮 */
hideDownloadTemplate?: boolean;
} }
export const DataImporter: React.FC<DataImporterProps> = ({ export const DataImporter: React.FC<DataImporterProps> = ({
@@ -73,6 +75,7 @@ export const DataImporter: React.FC<DataImporterProps> = ({
templateName, templateName,
templateVariables, templateVariables,
variant = 'default', variant = 'default',
hideDownloadTemplate = false,
}) => { }) => {
const { showAlert } = useAppDialog(); const { showAlert } = useAppDialog();
const isPs = variant === 'ps'; const isPs = variant === 'ps';
@@ -184,21 +187,21 @@ export const DataImporter: React.FC<DataImporterProps> = ({
return ( return (
<div className={wrapperClass}> <div className={wrapperClass}>
{!isMobile && ( {!isMobile && !hideDownloadTemplate && (
<div className={`flex flex-wrap gap-2 ${isPs ? '' : 'justify-end'}`}> <div className="flex justify-end">
<button <button
type="button" type="button"
onClick={() => downloadDataTemplate(templateName, templateVariables)} onClick={() => downloadDataTemplate(templateName, templateVariables)}
className={ className={
isMobile isPs
? 'mobile-secondary-btn w-full' ? 'inline-flex items-center justify-center w-14 h-7 text-[#ccc] hover:text-white hover:bg-[#444] rounded transition cursor-pointer shrink-0'
: isPs : 'inline-flex items-center justify-center w-18 h-9 border border-gray-200 text-gray-600 hover:bg-gray-50 rounded-lg cursor-pointer shrink-0'
? 'ps-btn text-[10px] w-full justify-center'
: 'inline-flex items-center gap-1.5 px-3 py-1.5 border border-gray-200 text-gray-600 hover:bg-gray-50 rounded-lg text-xs font-semibold cursor-pointer'
} }
aria-label="下载数据模板"
title="下载数据模板"
> >
<Download className="w-3.5 h-3.5" /> <Download className="w-3.5 h-3.5" />
<span className="text-[12px] ml-1"></span>
</button> </button>
</div> </div>
)} )}

View File

@@ -29,9 +29,9 @@ const MOBILE_EXPORT_MODULES: {
label: string; label: string;
icon: React.ReactNode; icon: React.ReactNode;
}[] = [ }[] = [
{ id: 'data', label: '数据源', icon: <Database className="w-4 h-4" /> }, { id: 'data', label: '数据源', icon: <Database className="w-4 h-4" /> },
{ id: 'layout', label: '排版', icon: <Layout className="w-4 h-4" /> }, { id: 'layout', label: '排版', icon: <Layout className="w-4 h-4" /> },
]; ];
interface MobileExportViewProps { interface MobileExportViewProps {
template: LabelTemplate; template: LabelTemplate;
@@ -141,11 +141,10 @@ export const MobileExportView: React.FC<MobileExportViewProps> = ({
type="button" type="button"
onClick={onExportPdf} onClick={onExportPdf}
disabled={exportDisabled} disabled={exportDisabled}
className={`inline-flex items-center gap-1 ml-1 px-2.5 py-1.5 text-[11px] font-semibold rounded-lg shrink-0 ${ className={`inline-flex items-center gap-1 ml-1 px-2.5 py-1.5 text-[11px] font-semibold rounded-lg shrink-0 ${exportDisabled
exportDisabled
? 'bg-[#444] text-[#888] cursor-not-allowed' ? 'bg-[#444] text-[#888] cursor-not-allowed'
: 'bg-indigo-600 hover:bg-indigo-700 active:bg-indigo-800 text-white' : 'bg-indigo-600 hover:bg-indigo-700 active:bg-indigo-800 text-white'
}`} }`}
> >
{pdfGenerating ? ( {pdfGenerating ? (
<Loader2 className="w-3.5 h-3.5 animate-spin" /> <Loader2 className="w-3.5 h-3.5 animate-spin" />
@@ -186,9 +185,8 @@ export const MobileExportView: React.FC<MobileExportViewProps> = ({
key={item.id} key={item.id}
type="button" type="button"
onClick={() => setMobileModule(item.id)} onClick={() => setMobileModule(item.id)}
className={`mobile-design-props-nav-btn mobile-export-props-nav-btn ${ className={`mobile-design-props-nav-btn mobile-export-props-nav-btn ${mobileModule === item.id ? 'active' : ''
mobileModule === item.id ? 'active' : '' }`}
}`}
> >
{item.icon} {item.icon}
<span>{item.label}</span> <span>{item.label}</span>
@@ -216,6 +214,7 @@ export const MobileExportView: React.FC<MobileExportViewProps> = ({
</div> </div>
<DataImporter <DataImporter
variant="ps" variant="ps"
hideDownloadTemplate
importData={importData} importData={importData}
onDataLoaded={onDataLoaded} onDataLoaded={onDataLoaded}
onClear={onClear} onClear={onClear}
@@ -245,9 +244,9 @@ export const MobileExportView: React.FC<MobileExportViewProps> = ({
/> />
</> </>
)} )}
{exportBlockedReason && !pdfGenerating && ( {/* {exportBlockedReason && !pdfGenerating && (
<p className="text-[10px] text-amber-500/90 text-center">{exportBlockedReason}</p> <p className="text-[10px] text-amber-500/90 text-center">{exportBlockedReason}</p>
)} )} */}
</div> </div>
)} )}
{mobileModule === 'layout' && ( {mobileModule === 'layout' && (

View File

@@ -577,8 +577,8 @@ export const LayoutPreview: React.FC<LayoutPreviewProps> = ({
<p className="text-sm text-[#aaa]"></p> <p className="text-sm text-[#aaa]"></p>
<p className="text-xs text-[#666] max-w-[280px] leading-relaxed"> <p className="text-xs text-[#666] max-w-[280px] leading-relaxed">
{isMobileVariant {isMobileVariant
? '在下方「数据源与变量绑定」中上传 Excel预览将自动更新' ? '在下方「数据源」中上传 Excel预览将自动更新'
: '在右侧「数据源与变量绑定」中点击「应用数据」生成排版预览;纸张排版变更会自动更新'} : '在右侧「数据源」中点击「应用数据」生成排版预览;纸张排版变更会自动更新'}
</p> </p>
</div> </div>
) : ( ) : (