From 52c17cc9efa1f8d1dda29faa9e1d2de7094682ed Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 21 十月 2025 20:19:43 +0800
Subject: [PATCH] fix: saveContractTemplateValues

---
 src/fabric-editor/constants/index.ts |    2 ++
 src/fabric-editor/hooks/context.ts   |    5 +++--
 src/fabric-editor/index.vue          |    5 +++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/fabric-editor/constants/index.ts b/src/fabric-editor/constants/index.ts
new file mode 100644
index 0000000..29eaa86
--- /dev/null
+++ b/src/fabric-editor/constants/index.ts
@@ -0,0 +1,2 @@
+export const CanvasWidth = 595;
+export const CanvasHeight = 842;
diff --git a/src/fabric-editor/hooks/context.ts b/src/fabric-editor/hooks/context.ts
index 9909450..21a9a99 100644
--- a/src/fabric-editor/hooks/context.ts
+++ b/src/fabric-editor/hooks/context.ts
@@ -12,6 +12,7 @@
   checkTemplateParamObjectListNotNull,
   convertJsonMapToTemplateParamObjectList,
 } from '../utils';
+import { CanvasHeight, CanvasWidth } from '../constants';
 
 export interface TemplateDetailContext {
   templateDetail: Ref<API.GetContractTemplateQueryResult>;
@@ -186,8 +187,8 @@
               recorder: x.recorder,
               userType: x.userType,
               bindProperty: x.bindProperty,
-              x: x.left,
-              y: x.top,
+              x: x.left / CanvasWidth,
+              y: x.top / CanvasHeight,
               page: x.pageNum + 1,
             } as API.SaveContractTemplateValuesCommandItem)
         ),
diff --git a/src/fabric-editor/index.vue b/src/fabric-editor/index.vue
index e0b3d49..0acf7c9 100644
--- a/src/fabric-editor/index.vue
+++ b/src/fabric-editor/index.vue
@@ -72,6 +72,7 @@
 import './plugin/fabric-history';
 import { MyHistoryPlugin } from './plugin/MyHistoryPlugin';
 import { TemplateParamExtensionKey } from './customObject';
+import { CanvasHeight, CanvasWidth } from './constants';
 
 const route = useRoute();
 const id = (route.params.id as string) ?? '';
@@ -109,8 +110,8 @@
     controlsAboveOverlay: true, // 瓒呭嚭clipPath鍚庝粛鐒跺睍绀烘帶鍒舵潯
     // imageSmoothingEnabled: false, // 瑙e喅鏂囧瓧瀵煎嚭鍚庝笉娓呮櫚闂
     preserveObjectStacking: true, // 褰撻�夋嫨鐢诲竷涓殑瀵硅薄鏃讹紝璁╁璞′笉鍦ㄩ《灞傘��
-    width: 595,
-    height: 842,
+    width: CanvasWidth,
+    height: CanvasHeight,
   });
   console.log('canvas: ', canvas);
 

--
Gitblit v1.9.1