ソースを参照

部分bug修改

luoshi 5 年 前
コミット
0eb08628e6

+ 10 - 7
stmms-web/src/main/webapp/WEB-INF/views/modules/mark/picConfig.jsp

@@ -203,15 +203,18 @@ function addPreviewImage() {
 
 function addPreviewByConfig(config){
     var container = $('#pic-config-preview');
-    if(config.w==0 && config.h==0){
-        jcrop_canvas.width=image_array[config.i-1].width;
-        jcrop_canvas.height=image_array[config.i-1].height;
-    }else{
-        jcrop_canvas.width=config.w;
-        jcrop_canvas.height=config.h;
+    var width = config.w;
+    var height = config.h;
+    if(width==0){
+        width = image_array[config.i-1].width;
     }
+    if(height==0){
+        height = image_array[config.i-1].height;
+    }
+    jcrop_canvas.width = width
+    jcrop_canvas.height = height
     
-    jcrop_canvas.getContext("2d").drawImage(image_array[config.i-1], config.x, config.y, config.w, config.h,0,0,config.w, config.h);
+    jcrop_canvas.getContext("2d").drawImage(image_array[config.i-1], config.x, config.y, width, height,0,0,width, height);
     
     var dom = $('<li><span class="order">'+config.i+'</span><div class="m"><img src=""/></div><span class="close">&times;</span></li>').appendTo(container);
     dom.attr('data-config', JSON.stringify(config));

+ 11 - 10
stmms-web/src/main/webapp/static/mark-new/js/modules/sheet-view.js

@@ -8,7 +8,11 @@ var sheet_view = function(option, success) {
 function SheetView(option) {
     this.markControl = option.markControl;
     this.server = option.server;
-    this.sheetConfig = option.sheetConfig;
+    if (option.sheetConfig) {
+        this.sheetConfig = JSON.parse(option.sheetConfig);
+    } else {
+        this.sheetConfig = [];
+    }
     this.init();
     this.markControl.on('task.get.success', this, function(event, context, eventObject) {
         this.render(context.task.sheetUrls);
@@ -98,15 +102,12 @@ SheetView.prototype.renderContent = function(content, sheetId) {
     image.canvas = document.getElementById('sheet-canvas');
     image.content = content;
     var self = this;
-    if (self.sheetConfig) {
-        self.sheetConfig = JSON.parse(self.sheetConfig);
-    };
     image.onload = function() {
-        var ctx = self.canvas.getContext("2d");
-        self.canvas.width = Math.min(image.width, self.content.width());
-        var scale = self.canvas.width / image.width;
-        self.canvas.height = image.height * scale;
-        ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, self.canvas.width, self.canvas.height);
+        var ctx = image.canvas.getContext("2d");
+        image.canvas.width = Math.min(image.width, image.content.width());
+        var scale = image.canvas.width / image.width;
+        image.canvas.height = image.height * scale;
+        ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, image.canvas.width, image.canvas.height);
         ctx.fillStyle = "#FFFFFF";
         //      if(show){
         //          ctx.fillRect(0, 0, this.canvas.width/2, this.canvas.height*3.7/10);
@@ -114,7 +115,7 @@ SheetView.prototype.renderContent = function(content, sheetId) {
         for (var j = 0; j < self.sheetConfig.length; j++) {
             var config = self.sheetConfig[j];
             if (config.i == (i + 1)) {
-                ctx.fillRect(config.x * sacle, config.y * scale, config.w * scale, config.h * scale);
+                ctx.fillRect(config.x * scale, config.y * scale, config.w * scale, config.h * scale);
             }
         }
         //this.canvas.toDataURL("image/jpeg");