优化布局和交互
This commit is contained in:
20
src/utils.ts
20
src/utils.ts
@@ -27,6 +27,26 @@ export const VARIABLE_MAPPING_USE_ROW_INDEX = '__use_row_index__';
|
||||
|
||||
export const VARIABLE_MAPPING_ROW_INDEX_LABEL = '数据序号';
|
||||
|
||||
/** 粘贴副本时相对原位置的偏移 (mm) */
|
||||
export const PASTE_ELEMENT_OFFSET_MM = 2;
|
||||
|
||||
/** 深拷贝元素并生成新 id,用于复制/粘贴 */
|
||||
export function cloneTemplateElementsForPaste(
|
||||
elements: TemplateElement[],
|
||||
pasteRepeat: number
|
||||
): TemplateElement[] {
|
||||
const offset = PASTE_ELEMENT_OFFSET_MM * Math.max(1, pasteRepeat);
|
||||
const stamp = Date.now();
|
||||
return elements.map((element, index) => {
|
||||
const cloned = JSON.parse(JSON.stringify(element)) as TemplateElement;
|
||||
cloned.id = `${element.type}_${stamp}_${index}`;
|
||||
cloned.name = `${element.name} 副本`;
|
||||
cloned.x = Math.round((element.x + offset) * 10) / 10;
|
||||
cloned.y = Math.round((element.y + offset) * 10) / 10;
|
||||
return cloned;
|
||||
});
|
||||
}
|
||||
|
||||
export function toDataSourceMeta(data: ImportData): DataSourceMeta {
|
||||
return {
|
||||
fileName: data.fileName,
|
||||
|
||||
Reference in New Issue
Block a user