|
@@ -1,8 +1,14 @@
|
|
<template>
|
|
<template>
|
|
- <div style="width:100%;height:700px;" >
|
|
|
|
|
|
+ <div style="width:100%;height:600px; bottom:20px;">
|
|
|
|
+ <el-button type="success" value="保存文档到服务器" @click="SaveDocument()">保存文档到服务器</el-button>
|
|
|
|
+ <el-button type="primary" value="打开本地文档(有窗口)" @click="OnUnLoad(),openlocal()">打开本地文档(有窗口)</el-button>
|
|
|
|
+ <el-button type="info" value="锁定文档" @click="WebSetProtect(true, '123456')">锁定文档</el-button>
|
|
|
|
+ <el-button type="warning" value="解锁文档" @click="WebSetProtect(false, '123456')">解锁文档</el-button>
|
|
|
|
+ <el-button type="danger" value="添加区域保护" @click="WebAreaProtect()">添加区域保护</el-button>
|
|
|
|
+ <el-button type="info" style="background:#6E30B4;" value="解除区域保护" @click="WebAreaUnProtect()">解除区域保护</el-button>
|
|
|
|
+ <el-button type="info" style="background:#303133" value="禁止拷贝" @click="WebEnableCopy()">禁止拷贝</el-button>
|
|
|
|
+ <el-button type="info" style="background:#19868E"value="允许拷贝" @click="WebEnableCopy()">允许拷贝</el-button>
|
|
<div id="office"></div>
|
|
<div id="office"></div>
|
|
- <input style="color:Red;" type=button value="打开本地文档(有窗口)" @click="OnUnLoad(),openlocal()">
|
|
|
|
- <input style="color:Red;" type=button value="保存文档到服务器" @click="SaveDocument()">
|
|
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
@@ -27,6 +33,7 @@
|
|
|
|
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
|
|
+
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.initWebOffice();
|
|
this.initWebOffice();
|
|
this.initWebOfficeObject();
|
|
this.initWebOfficeObject();
|
|
@@ -52,25 +59,35 @@
|
|
},
|
|
},
|
|
initWebOfficeObject() {
|
|
initWebOfficeObject() {
|
|
this.webOfficeObj = new WebOffice2015();
|
|
this.webOfficeObj = new WebOffice2015();
|
|
|
|
+ this.webOfficeObj.setObj(document.getElementById('WebOffice'));
|
|
try {
|
|
try {
|
|
|
|
+
|
|
this.webOfficeObj.ServerUrl = "http://localhost/dev-api";
|
|
this.webOfficeObj.ServerUrl = "http://localhost/dev-api";
|
|
// this.webOfficeObj.RecordID = "web"; //RecordID:本文档记录编号
|
|
// this.webOfficeObj.RecordID = "web"; //RecordID:本文档记录编号
|
|
- this.webOfficeObj.setObj(document.getElementById('WebOffice'));
|
|
|
|
this.webOfficeObj.UserName = this.fileData.user;
|
|
this.webOfficeObj.UserName = this.fileData.user;
|
|
this.webOfficeObj.FileName = this.fileData.filePath;
|
|
this.webOfficeObj.FileName = this.fileData.filePath;
|
|
this.webOfficeObj.getResultJson = {};
|
|
this.webOfficeObj.getResultJson = {};
|
|
this.webOfficeObj.SaveServlet = "/content/upload";
|
|
this.webOfficeObj.SaveServlet = "/content/upload";
|
|
this.webOfficeObj.FileType = "." + this.fileData.filePath.split(".")[this.fileData.filePath.split(".").length - 1]; //FileType:文档类型 .doc .xls
|
|
this.webOfficeObj.FileType = "." + this.fileData.filePath.split(".")[this.fileData.filePath.split(".").length - 1]; //FileType:文档类型 .doc .xls
|
|
this.webOfficeObj.ShowWindow = false; //显示/隐藏进度条
|
|
this.webOfficeObj.ShowWindow = false; //显示/隐藏进度条
|
|
- this.webOfficeObj.EditType = "1"; //设置加载文档类型 0 锁定文档,1无痕迹模式,2带痕迹模式
|
|
|
|
|
|
+ this.webOfficeObj.EditType = this.fileData.EditType; //设置加载文档类型 0 锁定文档,1无痕迹模式,2带痕迹模式
|
|
this.webOfficeObj.ShowMenu = 1;
|
|
this.webOfficeObj.ShowMenu = 1;
|
|
this.webOfficeObj.ShowToolBar = 0;
|
|
this.webOfficeObj.ShowToolBar = 0;
|
|
this.webOfficeObj.SetCaption(this.webOfficeObj.UserName + "正在编辑文档"); // 设置控件标题栏标题文本信息
|
|
this.webOfficeObj.SetCaption(this.webOfficeObj.UserName + "正在编辑文档"); // 设置控件标题栏标题文本信息
|
|
//参数顺序依次为:控件标题栏颜色、自定义菜单开始颜色、自定义工具栏按钮开始颜色、自定义工具栏按钮结束颜色、
|
|
//参数顺序依次为:控件标题栏颜色、自定义菜单开始颜色、自定义工具栏按钮开始颜色、自定义工具栏按钮结束颜色、
|
|
//自定义工具栏按钮边框颜色、自定义工具栏开始颜色、控件标题栏文本颜色(默认值为:0x000000)
|
|
//自定义工具栏按钮边框颜色、自定义工具栏开始颜色、控件标题栏文本颜色(默认值为:0x000000)
|
|
- if (!this.webOfficeObj.WebSetSkin(0xdbdbdb, 0xeaeaea, 0xeaeaea, 0xdbdbdb, 0xdbdbdb, 0xdbdbdb, 0x000000)) {
|
|
|
|
- this.msgSuccess(this.webOfficeObj.Status);
|
|
|
|
|
|
+
|
|
|
|
+ if (!this.webOfficeObj.WebSetSkin(0xdbdbdb,
|
|
|
|
+ 0xeaeaea,
|
|
|
|
+ 0xeaeaea,
|
|
|
|
+ 0xdbdbdb,
|
|
|
|
+ 0xdbdbdb,
|
|
|
|
+ 0xdbdbdb,
|
|
|
|
+ 0x000000)) {
|
|
|
|
+ this.msgError("插件发生错误,该浏览器不支持office");
|
|
|
|
+ // this.msgSuccess(this.webOfficeObj.Status);
|
|
} //设置控件皮肤
|
|
} //设置控件皮肤
|
|
|
|
+
|
|
if (this.webOfficeObj.WebOpen()) {
|
|
if (this.webOfficeObj.WebOpen()) {
|
|
this.msgSuccess(this.webOfficeObj.Status);
|
|
this.msgSuccess(this.webOfficeObj.Status);
|
|
}
|
|
}
|
|
@@ -114,6 +131,41 @@
|
|
this.StatusMsg(this.webOfficeObj.Status);
|
|
this.StatusMsg(this.webOfficeObj.Status);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ //锁定/解锁文档
|
|
|
|
+ WebSetProtect(Boolean, PassWord) {
|
|
|
|
+ this.webOfficeObj.WebSetProtect(Boolean, PassWord);
|
|
|
|
+ this.msgSuccess(this.webOfficeObj.Status);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ //允许/禁止拷贝文档
|
|
|
|
+ WebEnableCopy(Boolean) {
|
|
|
|
+ this.webOfficeObj.WebEnableCopy(Boolean);
|
|
|
|
+ this.msgSuccess(this.webOfficeObj.Status);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ //添加区域保护
|
|
|
|
+ WebAreaProtect() {
|
|
|
|
+ //如果非ie浏览器调用HidePlugin隐藏插件避免窗体被遮挡
|
|
|
|
+ this.webOfficeObj.HidePlugin(0);
|
|
|
|
+ var mText = window.prompt("文档里需要先设置保护的书签,示例文档默认添加了KingGrid的书签,请输入书签名称", "KingGrid", "");
|
|
|
|
+ if (mText != null) {
|
|
|
|
+ this.webOfficeObj.WebAreaProtect(mText)
|
|
|
|
+ }
|
|
|
|
+ ;
|
|
|
|
+ this.webOfficeObj.HidePlugin(1);
|
|
|
|
+ },
|
|
|
|
+ //取消区域保护
|
|
|
|
+ WebAreaUnProtect() {
|
|
|
|
+ //如果非ie浏览器调用HidePlugin隐藏插件避免窗体被遮挡
|
|
|
|
+ this.webOfficeObj.HidePlugin(0);
|
|
|
|
+ var mText = window.prompt("需要和保护的书签对应,示例文档默认添加了KingGrid的书签,请输入书签名称", "KingGrid", "");
|
|
|
|
+ //显示HidePlugin隐藏的插件
|
|
|
|
+ if (mText != null) {
|
|
|
|
+ this.webOfficeObj.WebAreaUnprotect(mText)
|
|
|
|
+ }
|
|
|
|
+ ;
|
|
|
|
+ this.webOfficeObj.HidePlugin(1);
|
|
|
|
+ },
|
|
OnCommand(ID, Caption, bCancel) {
|
|
OnCommand(ID, Caption, bCancel) {
|
|
switch (ID) {
|
|
switch (ID) {
|
|
case 1:
|
|
case 1:
|