Procházet zdrojové kódy

评卷需求坐标使用相对百分比

zhangjie před 2 roky
rodič
revize
94e4d805fd

+ 0 - 20
README.md

@@ -91,26 +91,6 @@ yarn run lint
 - vue.config.js             # 项目开发环境配置文件
 ```
 
-## 第一次创建项目
-
-- 配置 config.js 文件
-
-  - 将 config.copy.js 文件在当前路径中复制一份,保存为 config.js 文件。
-  - 修改 config 文件中 domain 值,domain 为全局请求公用 domain 信息。
-
-- 配置开发端口
-
-```bash
-#修改vue.config.js文件中如下信息:
-{
-  port: 8056  # 默认时8056端口
-}
-```
-
-- dev 模式推荐使用 proxy
-
-  - 具体配置请查看`dev-proxy.copy.js`
-
 ## TODO
 
 - 暂无

+ 13 - 26
src/modules/stmms/components/markParam/areaCropper/AreaCropper.vue

@@ -86,8 +86,8 @@ export default {
     getMax(arr) {
       return Math.max.apply(null, arr);
     },
-    toFixed(num) {
-      return num.toFixed(2) * 1;
+    toFixed(num, precision = 2) {
+      return num.toFixed(precision) * 1;
     },
     imgLoad() {
       this.transformPicConfig(this.paper.areas);
@@ -123,14 +123,8 @@ export default {
       }
     },
     transformPicConfig(areas) {
-      const {
-        naturalWidth,
-        naturalHeight,
-        clientWidth,
-        clientHeight
-      } = this.$refs.imgDom;
-      const hRate = clientHeight / naturalHeight;
-      const wRate = clientWidth / naturalWidth;
+      const { clientWidth, clientHeight } = this.$refs.imgDom;
+
       this.areas = areas.map((area, index) => {
         let narea = {
           id: `id-${randomCode()}`,
@@ -148,10 +142,10 @@ export default {
         } else {
           narea = {
             ...narea,
-            x: area.x * wRate,
-            y: area.y * hRate,
-            w: area.w * wRate,
-            h: area.h * hRate
+            x: area.x * clientWidth,
+            y: area.y * clientHeight,
+            w: area.w * clientWidth,
+            h: area.h * clientHeight
           };
         }
         return narea;
@@ -191,22 +185,15 @@ export default {
       if (area.id !== this.curArea.id) this.curArea = {};
     },
     emitChange() {
-      const {
-        naturalWidth,
-        naturalHeight,
-        clientWidth,
-        clientHeight
-      } = this.$refs.imgDom;
-      const hRate = naturalHeight / clientHeight;
-      const wRate = naturalWidth / clientWidth;
+      const { clientWidth, clientHeight } = this.$refs.imgDom;
 
       const areas = this.areas.map(item => {
         return {
           id: item.id,
-          x: this.toFixed(item.x * wRate),
-          y: this.toFixed(item.y * hRate),
-          w: this.toFixed(item.w * wRate),
-          h: this.toFixed(item.h * hRate),
+          x: this.toFixed(item.x / clientWidth, 4),
+          y: this.toFixed(item.y / clientHeight),
+          w: this.toFixed(item.w / clientWidth, 4),
+          h: this.toFixed(item.h / clientHeight),
           // 是否覆盖整个页面,允许2px的误差
           isFull:
             item.x <= 2 &&