ソースを参照

修复代码生成模板文件上传组件缺少ctx的问题

RuoYi 4 年 前
コミット
5332756526

+ 9 - 9
ruoyi-generator/src/main/resources/vm/html/add.html.vm

@@ -243,26 +243,26 @@
                         $("input[name='" + this.id + "']").val(contents);
                     },
                     onImageUpload: function(files) {
-                    	var obj = this;
+                        var obj = this;
                     	var data = new FormData();
                     	data.append("file", files[0]);
                     	$.ajax({
-                    		type: "post",
-                    		url: ctx + "common/upload",
+                            type: "post",
+                            url: ctx + "common/upload",
                     		data: data,
                     		cache: false,
                     		contentType: false,
                     		processData: false,
                     		dataType: 'json',
                     		success: function(result) {
-                    			if (result.code == web_status.SUCCESS) {
-                    				$('#' + obj.id).summernote('insertImage', result.url);
-                    			} else {
-                    				$.modal.alertError(result.msg);
-                    			}
+                    		    if (result.code == web_status.SUCCESS) {
+                    		        $('#' + obj.id).summernote('insertImage', result.url);
+                    		    } else {
+                    		        $.modal.alertError(result.msg);
+                    		    }
                     		},
                     		error: function(error) {
-                    			$.modal.alertWarning("图片上传失败。");
+                    		    $.modal.alertWarning("图片上传失败。");
                     		}
                     	});
                     }

+ 24 - 24
ruoyi-generator/src/main/resources/vm/html/edit.html.vm

@@ -223,7 +223,7 @@
         $(".file-upload").each(function (i) {
             var val = $("input[name='" + this.id + "']").val()
             $(this).fileinput({
-                'uploadUrl': '/common/upload',
+                'uploadUrl': ctx + 'common/upload',
                 initialPreviewAsData: true,
                 initialPreview: [val],
                 maxFileCount: 1,
@@ -250,29 +250,29 @@
                             $("input[name='" + this.id + "']").val(contents);
                         },
                         onImageUpload: function(files) {
-							var obj = this;
-							var data = new FormData();
-							data.append("file", files[0]);
-							$.ajax({
-								type: "post",
-								url: ctx + "common/upload",
-								data: data,
-								cache: false,
-								contentType: false,
-								processData: false,
-								dataType: 'json',
-								success: function(result) {
-									if (result.code == web_status.SUCCESS) {
-										$('#' + obj.id).summernote('insertImage', result.url);
-									} else {
-										$.modal.alertError(result.msg);
-									}
-								},
-								error: function(error) {
-									$.modal.alertWarning("图片上传失败。");
-								}
-							});
-						}
+                            var obj = this;
+                            var data = new FormData();
+                            data.append("file", files[0]);
+                            $.ajax({
+                                type: "post",
+                                url: ctx + "common/upload",
+                                data: data,
+                                cache: false,
+                                contentType: false,
+                                processData: false,
+                                dataType: 'json',
+                                success: function(result) {
+                                    if (result.code == web_status.SUCCESS) {
+                                        $('#' + obj.id).summernote('insertImage', result.url);
+                                    } else {
+                                        $.modal.alertError(result.msg);
+                                    }
+                                },
+                                error: function(error) {
+                                    $.modal.alertWarning("图片上传失败。");
+                                }
+                            });
+                        }
                     }
                 });
                 var content = $("input[name='" + this.id + "']").val();