Procházet zdrojové kódy

集成weboffice, 修改,保存文件

xiao-xx před 4 roky
rodič
revize
94c633a027

+ 43 - 42
src/views/system/actform/fawen/iWebOffice.vue

@@ -61,7 +61,7 @@
           this.webOfficeObj.UserName = this.fileData.user;
           this.webOfficeObj.FileName = this.fileData.filePath;
           this.webOfficeObj.getResultJson = {};
-          this.webOfficeObj.SaveServlet = "/common/upload";
+          this.webOfficeObj.SaveServlet = "/content/upload";
           this.webOfficeObj.FileType = "."+this.fileData.filePath.split(".")[ this.fileData.filePath.split(".").length-1]; //FileType:文档类型  .doc  .xls
           this.webOfficeObj.ShowWindow = false; //显示/隐藏进度条
           this.webOfficeObj.EditType = "1"; //设置加载文档类型 0 锁定文档,1无痕迹模式,2带痕迹模式
@@ -92,48 +92,7 @@
           console.log(e.description);
         }
       },
-      //服务端Servlet方式打开文档
-      LoadServlet() {
-        this.webOfficeObj = new WebOffice2015();
-        try {
-          this.webOfficeObj.ServerUrl = "http://localhost/dev-api/";               // 用来保存文件的Server
-          var downloadLink = "profile/doc/web.docx";
-          this.webOfficeObj.ShowMenu = 1;
-          this.webOfficeObj.ShowToolBar = 0;
-          this.SetGraySkin();			//设置控件皮肤
-          if (this.webOfficeObj.WebOpen3(downloadLink))  // 文件在服务器上的相对路径 FileName
-          {
-            this.StatusMsg(this.webOfficeObj.Status);
-          }
-        } catch (e) {
-          this.StatusMsg(e.description);
-        }
-      },
-      //URL地址打开文档
-      LoadURL() {
 
-        try {
-          this.webOfficeObj.ServerUrl = "http://localhost/dev-api/"; //服务器地址
-          this.webOfficeObj.ShowMenu = 1;
-          this.webOfficeObj.ShowToolBar = 0;
-          this.webOfficeObj.UserName = "xqx";
-          this.webOfficeObj.FileName = "web.docx";
-          this.webOfficeObj.FileType = ".docx"; //FileType:文档类型  .doc  .xls
-          this.webOfficeObj.ShowWindow = true; //显示/隐藏进度条
-          this.webOfficeObj.EditType = "1"; //设置加载文档类型 0 锁定文档,1无痕迹模式,2带痕迹模式
-          this.webOfficeObj.setObj(document.getElementById('WebOffice'));
-          if (!this.webOfficeObj.WebSetSkin(0xdbdbdb, 0xeaeaea, 0xeaeaea, 0xdbdbdb, 0xdbdbdb, 0xdbdbdb, 0x000000)) {
-            alert(this.webOfficeObj.Status);
-          }    //设置控件皮肤		//设置控件皮肤
-          alert("1")
-          if (this.webOfficeObj.WebOpen2("/profile/doc/web.docx"))  // 文件在服务器上的相对路径 FileName
-          {
-            this.StatusMsg(this.webOfficeObj.Status);
-          }
-        } catch (e) {
-          this.StatusMsg(e.description);
-        }
-      },
       //设置页面中的状态值
       StatusMsg(mValue) {
         try {
@@ -178,6 +137,48 @@
       default:;return;
     }
   },
+      //服务端Servlet方式打开文档
+      LoadServlet() {
+        this.webOfficeObj = new WebOffice2015();
+        try {
+          this.webOfficeObj.ServerUrl = "http://localhost/dev-api/";               // 用来保存文件的Server
+          var downloadLink = "profile/doc/web.docx";
+          this.webOfficeObj.ShowMenu = 1;
+          this.webOfficeObj.ShowToolBar = 0;
+          this.SetGraySkin();			//设置控件皮肤
+          if (this.webOfficeObj.WebOpen3(downloadLink))  // 文件在服务器上的相对路径 FileName
+          {
+            this.StatusMsg(this.webOfficeObj.Status);
+          }
+        } catch (e) {
+          this.StatusMsg(e.description);
+        }
+      },
+      //URL地址打开文档
+      LoadURL() {
+
+        try {
+          this.webOfficeObj.ServerUrl = "http://localhost/dev-api/"; //服务器地址
+          this.webOfficeObj.ShowMenu = 1;
+          this.webOfficeObj.ShowToolBar = 0;
+          this.webOfficeObj.UserName = "xqx";
+          this.webOfficeObj.FileName = "web.docx";
+          this.webOfficeObj.FileType = ".docx"; //FileType:文档类型  .doc  .xls
+          this.webOfficeObj.ShowWindow = true; //显示/隐藏进度条
+          this.webOfficeObj.EditType = "1"; //设置加载文档类型 0 锁定文档,1无痕迹模式,2带痕迹模式
+          this.webOfficeObj.setObj(document.getElementById('WebOffice'));
+          if (!this.webOfficeObj.WebSetSkin(0xdbdbdb, 0xeaeaea, 0xeaeaea, 0xdbdbdb, 0xdbdbdb, 0xdbdbdb, 0x000000)) {
+            alert(this.webOfficeObj.Status);
+          }    //设置控件皮肤		//设置控件皮肤
+          alert("1")
+          if (this.webOfficeObj.WebOpen2("/profile/doc/web.docx"))  // 文件在服务器上的相对路径 FileName
+          {
+            this.StatusMsg(this.webOfficeObj.Status);
+          }
+        } catch (e) {
+          this.StatusMsg(e.description);
+        }
+      },
       //烟枪灰皮肤
        SetGraySkin(){
     //参数顺序依次为:控件标题栏颜色、自定义菜单开始颜色、自定义工具栏按钮开始颜色、自定义工具栏按钮结束颜色、

+ 2 - 2
src/views/system/actform/fawen/write1.vue

@@ -153,8 +153,8 @@
       <el-button @click="cancel">取 消</el-button>
     </div>
     <el-dialog id="content" title="正文修改" :visible.sync="contentOpen" :before-close="cancel" append-to-body
-               width="1500px"
-               top="10" height="300px">
+               width="80%"
+               top="10" height="800px">
       <!-- 动态引入组件-->
       <i-web-office @func="getcontent" :fileData="fileData"></i-web-office>
     </el-dialog>

+ 4 - 0
static/iweboffice/WebOffice.js

@@ -613,6 +613,7 @@ function WebOffice2015() {
 	/* 保存文件 */		//(该功能已完整实现)
 	this.WebSave = function(header)
 	{
+	  debugger
 		this.Status = "";
 		var httpclient = this.obj.Http; // 设置http对象
 		httpclient.Clear();
@@ -2740,6 +2741,9 @@ function WebOffice2015() {
 				this.Status = httpclient.status;
         this.getResultJson=JSON.parse(httpclient.responseText)
         console.log(this.getResultJson)
+        if(this.getResultJson.code=="302"){
+          return false
+        }
 				return true;
 			}
 		} else {