diff --git a/src/Add-on/DrawBoard/DownloadTemplateTable.tsx b/src/Add-on/DrawBoard/DownloadTemplateTable.tsx new file mode 100644 index 000000000..cb45205d6 --- /dev/null +++ b/src/Add-on/DrawBoard/DownloadTemplateTable.tsx @@ -0,0 +1,13 @@ +import { Command } from "../../Editor/CommandMachine"; + +export class DownloadTemplateTable implements Command +{ + async exec() + { + const a = document.createElement('a'); + a.href = "https://cfcad.cn/help/UpdateLog/PHOTO/ImportTemplate1.csv"; + a.download = "数据绘制模板.csv"; // 指定下载文件名 + a.style.display = 'none'; + a.click(); + } +} diff --git a/src/Add-on/DrawBoard/DrawTemplateByImport.tsx b/src/Add-on/DrawBoard/DrawTemplateByImport.ts similarity index 96% rename from src/Add-on/DrawBoard/DrawTemplateByImport.tsx rename to src/Add-on/DrawBoard/DrawTemplateByImport.ts index 4ff5eafaa..34cd2e7be 100644 --- a/src/Add-on/DrawBoard/DrawTemplateByImport.tsx +++ b/src/Add-on/DrawBoard/DrawTemplateByImport.ts @@ -1,5 +1,4 @@ import { Intent } from "@blueprintjs/core"; -import React from "react"; import { Matrix4, Vector3 } from "three"; import { app } from "../../ApplicationServices/Application"; import { EBoardKeyList } from "../../Common/BoardKeyList"; @@ -54,23 +53,9 @@ export class DrawTemplateByImport implements Command private keyRes: PromptResult; async exec() { - const toasterKey = AppToaster.show({ - message: - <> - 可以下载 - 导入模板.csv - - , - timeout: 10000, - }); FS.ChooseFile({ filter: ".csv", multiple: false, callback: async (files: FileList) => { - AppToaster.dismiss(toasterKey); let f = files.item(0); let reader = new FileReader(); this.keyRes = await app.Editor.GetKeyWords({ @@ -188,12 +173,20 @@ export class DrawTemplateByImport implements Command remarks.push(values[i]); break; case "扩展备注": - const pairs = values[i].split(';'); - for (const pair of pairs) + let exRemarkStr = values[i]; + if (exRemarkStr.includes(';')) + exRemarkStr = exRemarkStr.replaceAll(';', ';'); + + const pairs = exRemarkStr.split(";"); + for (let pair of pairs) { - const [rK, rV] = pair.split(':'); + if (pair.includes(':')) + pair = pair.replaceAll(':', ':'); + + const [rK, rV] = pair.split(":"); rK && rV && extRemarks.push([rK, rV]); } + break; case "板材": case "板材名": bancai = values[i]; @@ -211,7 +204,9 @@ export class DrawTemplateByImport implements Command lines = linesMap.get(values[i]); break; default: - const key = keys[i]; + let key = keys[i]; + if (key.includes('备注:')) + key = key.replace("备注:", "备注:"); if (key.includes("备注:") && values[i]) extRemarks.push([key.replace("备注:", ""), values[i]]); break; @@ -367,6 +362,7 @@ export class DrawTemplateByImport implements Command }; } }); + app.Editor.Prompt('可输入命令下载模板表格: DTT'); } private handleInfo(en: Entity, info: IList) { diff --git a/src/Common/CommandNames.ts b/src/Common/CommandNames.ts index d910d92d7..265ea5100 100644 --- a/src/Common/CommandNames.ts +++ b/src/Common/CommandNames.ts @@ -305,6 +305,7 @@ export enum CommandNames CuttingFace = "CUTTINGFACE",//切割面 CuttingRectFace = "CUTTINGRECTFACE",//切割矩形面 DrawTempByImport = "DRAWTEMPBYIMPORT", + DownloadTemplateTable = "DOWNLOADTEMPLATETABLE", // 下载模板表格 CheckEdge = "CHECKEDGE",//封边检查 CheckPlaceFace = "CHECKPLACEFACE",//排版面视觉样式显示 ModelGroove = "MODELGROOVE",//造型槽 diff --git a/src/Editor/CommandRegister.ts b/src/Editor/CommandRegister.ts index 0447956d5..6adcda3c7 100644 --- a/src/Editor/CommandRegister.ts +++ b/src/Editor/CommandRegister.ts @@ -223,6 +223,7 @@ import { Command_Modeling } from "../Add-on/Command_Modeling"; import { Command_PickUp2DModelCsgs } from "../Add-on/Command_PickUp2DModelCsgs"; import { Command_TemplateGroup } from "../Add-on/Command_TemplateGroup"; import { ApplyModel2ToBoard } from "../Add-on/DrawBoard/ApplyModel2ToBoard"; +import { DownloadTemplateTable } from "../Add-on/DrawBoard/DownloadTemplateTable"; import { ParseHandle } from "../Add-on/DrawBoard/ParseHandle"; import { ParseHinge } from "../Add-on/DrawBoard/ParseHinge"; import { Command_BoardInfoDimTool } from "../Add-on/DrawDim/BoardInfoDimTool"; @@ -862,6 +863,7 @@ export function registerCommand() commandMachine.RegisterCommand(CommandNames.CuttingRectFace, new CuttingByRectFace()); commandMachine.RegisterCommand(CommandNames.DrawTempByImport, new DrawTemplateByImport()); + commandMachine.RegisterCommand(CommandNames.DownloadTemplateTable, new DownloadTemplateTable()); commandMachine.RegisterCommand(CommandNames.R2B2, new Rect2Board()); diff --git a/src/UI/Components/CommandPanel/CommandList.ts b/src/UI/Components/CommandPanel/CommandList.ts index 9fb500743..5f1491e1a 100644 --- a/src/UI/Components/CommandPanel/CommandList.ts +++ b/src/UI/Components/CommandPanel/CommandList.ts @@ -2450,6 +2450,15 @@ export const CommandList: ICommand[] = [ chName: "通过导入数据绘制模板", chDes: "通过导入数据绘制模板", }, + { + typeId: "util", + link: `${HelpUrlBase}Tool/TemplateImport`, + defaultCustom: "DTT", + command: CommandNames.DownloadTemplateTable, + type: "工具", + chName: "下载数据绘制模板表格", + chDes: "下载数据绘制模板表格", + }, { typeId: "util", link: `${HelpUrlBase}BoardEditing/SetSmoothEdge`,