Bläddra i källkod

Merge branch 'master' of http://git.zthymaoyi.com/zyw/cloudNew

achao 2 år sedan
förälder
incheckning
14b052436e

+ 26 - 0
unimall-admin/src/views/articleManagement/add.vue

@@ -112,6 +112,32 @@
     mounted() {
       window.CKEDITOR.replace('ck-editor', {height: '400px', width: '100%', toolbar: 'toolbar_Full'});
       this.editor = window.CKEDITOR.instances['ck-editor']
+      let that = this;
+		this.editor.on('fileUploadRequest', evt => {
+			const requestData = evt.data.requestData
+			const upload = requestData.upload
+			delete requestData.upload
+			requestData.file = upload
+		})
+
+		this.editor.on('fileUploadResponse', evt => {
+			evt.stop();
+			const data = evt.data
+			const fileLoader = data.fileLoader
+			const res = JSON.parse(fileLoader.xhr.responseText)
+      console.log(res)
+			if (res.errno !== 200) {
+				data.message = '上传失败'
+				evt.cancel();
+				return
+			}
+			data.fileName = fileLoader.fileName
+			data.url = res.url
+			data.message = '上传成功'
+		})
+
+
+
       listDict({ classifyType:'article_type',}).then(response => {
         this.options=response.data.data.items
       });

+ 22 - 0
unimall-admin/src/views/articleManagement/edit.vue

@@ -110,6 +110,28 @@
     var that = this
       window.CKEDITOR.replace('ck-editor', {height: '400px', width: '100%', toolbar: 'toolbar_Full'});
       this.editor = window.CKEDITOR.instances['ck-editor']
+		this.editor.on('fileUploadRequest', evt => {
+			const requestData = evt.data.requestData
+			const upload = requestData.upload
+			delete requestData.upload
+			requestData.file = upload
+		})
+
+		this.editor.on('fileUploadResponse', evt => {
+			evt.stop();
+			const data = evt.data
+			const fileLoader = data.fileLoader
+			const res = JSON.parse(fileLoader.xhr.responseText)
+      console.log(res)
+			if (res.errno !== 200) {
+				data.message = '上传失败'
+				evt.cancel();
+				return
+			}
+			data.fileName = fileLoader.fileName
+			data.url = res.url
+			data.message = '上传成功'
+		})
       listDict({ classifyType:'article_type',}).then(response => {
         this.options=response.data.data.items
       });

+ 23 - 0
unimall-admin/src/views/productManagement/add.vue

@@ -119,6 +119,29 @@
     mounted() {
       window.CKEDITOR.replace('ck-editor', {height: '400px', width: '100%', toolbar: 'toolbar_Full'});
       this.editor = window.CKEDITOR.instances['ck-editor']
+      let that = this;
+		this.editor.on('fileUploadRequest', evt => {
+			const requestData = evt.data.requestData
+			const upload = requestData.upload
+			delete requestData.upload
+			requestData.file = upload
+		})
+
+		this.editor.on('fileUploadResponse', evt => {
+			evt.stop();
+			const data = evt.data
+			const fileLoader = data.fileLoader
+			const res = JSON.parse(fileLoader.xhr.responseText)
+      console.log(res)
+			if (res.errno !== 200) {
+				data.message = '上传失败'
+				evt.cancel();
+				return
+			}
+			data.fileName = fileLoader.fileName
+			data.url = res.url
+			data.message = '上传成功'
+		})
       listDict({classifyType:'product_type',}).then(response => {
         this.options=response.data.data.items
       });

+ 23 - 0
unimall-admin/src/views/productManagement/edit.vue

@@ -123,6 +123,29 @@
     mounted() {
       window.CKEDITOR.replace('ck-editor', {height: '400px', width: '100%', toolbar: 'toolbar_Full'});
       this.editor = window.CKEDITOR.instances['ck-editor']
+      let that = this;
+		this.editor.on('fileUploadRequest', evt => {
+			const requestData = evt.data.requestData
+			const upload = requestData.upload
+			delete requestData.upload
+			requestData.file = upload
+		})
+
+		this.editor.on('fileUploadResponse', evt => {
+			evt.stop();
+			const data = evt.data
+			const fileLoader = data.fileLoader
+			const res = JSON.parse(fileLoader.xhr.responseText)
+      console.log(res)
+			if (res.errno !== 200) {
+				data.message = '上传失败'
+				evt.cancel();
+				return
+			}
+			data.fileName = fileLoader.fileName
+			data.url = res.url
+			data.message = '上传成功'
+		})
       listDict({classifyType:'product_type',}).then(response => {
         this.options=response.data.data.items
       });

+ 1 - 0
unimall-admin/static/ckeditor/config.js

@@ -40,4 +40,5 @@ CKEDITOR.editorConfig = function( config ) {
 	
 	config.extraPlugins += (config.extraPlugins ? ',lineheight' : 'lineheight');
 	config.allowedContent = true;
+	config.filebrowserUploadUrl = "http://192.168.110.138:8189/upload/admin"
 };

+ 1 - 1
unimall-admin/static/ckeditor/plugins/image/dialogs/image.js

@@ -35,7 +35,7 @@ setup:function(a,b){if(1==a){var c,d;c=b.getStyle("margin-top");d=b.getStyle("ma
 n+'" class\x3d"ImagePreviewLoader" style\x3d"display:none"\x3e\x3cdiv class\x3d"loading"\x3e\x26nbsp;\x3c/div\x3e\x3c/div\x3e\x3cdiv class\x3d"ImagePreviewBox"\x3e\x3ctable\x3e\x3ctr\x3e\x3ctd\x3e\x3ca href\x3d"javascript:void(0)" target\x3d"_blank" onclick\x3d"return false;" id\x3d"'+D+'"\x3e\x3cimg id\x3d"'+C+'" alt\x3d"" /\x3e\x3c/a\x3e'+(d.config.image_previewText||"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.")+
 "\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/div\x3e\x3c/div\x3e"}]}]}]},{id:"Link",requiredContent:"a[href]",label:d.lang.image.linkTab,padding:0,elements:[{id:"txtUrl",type:"text",label:d.lang.common.url,style:"width: 100%","default":"",setup:function(a,b){if(2==a){var c=b.data("cke-saved-href");c||(c=b.getAttribute("href"));this.setValue(c)}},commit:function(a,b){if(2==a&&(this.getValue()||this.isChanged())){var c=this.getValue();b.data("cke-saved-href",c);b.setAttribute("href",c);this.getValue()||
 !d.config.image_removeLinkByEmptyURL?this.getDialog().addLink=!0:this.getDialog().addLink=!1}}},{type:"button",id:"browse",className:"cke_dialog_image_browse",filebrowser:{action:"Browse",target:"Link:txtUrl",url:d.config.filebrowserImageBrowseLinkUrl},style:"float:right",hidden:!0,label:d.lang.common.browseServer},{id:"cmbTarget",type:"select",requiredContent:"a[target]",label:d.lang.common.target,"default":"",items:[[d.lang.common.notSet,""],[d.lang.common.targetNew,"_blank"],[d.lang.common.targetTop,
-"_top"],[d.lang.common.targetSelf,"_self"],[d.lang.common.targetParent,"_parent"]],setup:function(a,b){2==a&&this.setValue(b.getAttribute("target")||"")},commit:function(a,b){2==a&&(this.getValue()||this.isChanged())&&b.setAttribute("target",this.getValue())}}]},{id:"Upload",hidden:!0,filebrowser:"uploadButton",label:d.lang.image.upload,elements:[{type:"file",id:"upload",label:d.lang.image.btnUpload,style:"height:40px",size:38},{type:"fileButton",id:"uploadButton",filebrowser:"info:txtUrl",label:d.lang.image.btnUpload,
+"_top"],[d.lang.common.targetSelf,"_self"],[d.lang.common.targetParent,"_parent"]],setup:function(a,b){2==a&&this.setValue(b.getAttribute("target")||"")},commit:function(a,b){2==a&&(this.getValue()||this.isChanged())&&b.setAttribute("target",this.getValue())}}]},{id:"Upload",hidden:0,filebrowser:"uploadButton",label:d.lang.image.upload,elements:[{type:"file",id:"upload",label:d.lang.image.btnUpload,style:"height:40px",size:38},{type:"fileButton",id:"uploadButton",filebrowser:"info:txtUrl",label:d.lang.image.btnUpload,
 "for":["Upload","upload"]}]},{id:"advanced",label:d.lang.common.advancedTab,elements:[{type:"hbox",widths:["50%","25%","25%"],children:[{type:"text",id:"linkId",requiredContent:"img[id]",label:d.lang.common.id,setup:function(a,b){1==a&&this.setValue(b.getAttribute("id"))},commit:function(a,b){1==a&&(this.getValue()||this.isChanged())&&b.setAttribute("id",this.getValue())}},{id:"cmbLangDir",type:"select",requiredContent:"img[dir]",style:"width : 100px;",label:d.lang.common.langDir,"default":"",items:[[d.lang.common.notSet,
 ""],[d.lang.common.langDirLtr,"ltr"],[d.lang.common.langDirRtl,"rtl"]],setup:function(a,b){1==a&&this.setValue(b.getAttribute("dir"))},commit:function(a,b){1==a&&(this.getValue()||this.isChanged())&&b.setAttribute("dir",this.getValue())}},{type:"text",id:"txtLangCode",requiredContent:"img[lang]",label:d.lang.common.langCode,"default":"",setup:function(a,b){1==a&&this.setValue(b.getAttribute("lang"))},commit:function(a,b){1==a&&(this.getValue()||this.isChanged())&&b.setAttribute("lang",this.getValue())}}]},
 {type:"text",id:"txtGenLongDescr",requiredContent:"img[longdesc]",label:d.lang.common.longDescr,setup:function(a,b){1==a&&this.setValue(b.getAttribute("longDesc"))},commit:function(a,b){1==a&&(this.getValue()||this.isChanged())&&b.setAttribute("longDesc",this.getValue())}},{type:"hbox",widths:["50%","50%"],children:[{type:"text",id:"txtGenClass",requiredContent:"img(cke-xyz)",label:d.lang.common.cssClass,"default":"",setup:function(a,b){1==a&&this.setValue(b.getAttribute("class"))},commit:function(a,