#I5MD1F 增加导出为word文档支持
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
ENV = 'development'
|
ENV = 'development'
|
||||||
|
|
||||||
# base api
|
# base api
|
||||||
# VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
|
VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
|
||||||
VUE_APP_BASE_API = 'http://doc.zyplayer.com'
|
# VUE_APP_BASE_API = 'http://doc.zyplayer.com'
|
||||||
|
|
||||||
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,37 @@
|
|||||||
import GlobalLayout from './components/layouts/GlobalLayout'
|
import GlobalLayout from './components/layouts/GlobalLayout.vue'
|
||||||
import ShareLayout from './components/layouts/ShareLayout'
|
import ShareLayout from './components/layouts/ShareLayout.vue'
|
||||||
import ShareMobileLayout from './components/layouts/ShareMobileLayout'
|
import ShareMobileLayout from './components/layouts/ShareMobileLayout.vue'
|
||||||
|
|
||||||
|
import Search from './views/page/Search.vue'
|
||||||
|
import EditorTest from './views/page/EditorTest.vue'
|
||||||
|
import NoAuth from './views/common/NoAuth.vue'
|
||||||
|
|
||||||
|
import Home from './views/home/Home.vue'
|
||||||
|
import MyInfo from './views/user/MyInfo.vue'
|
||||||
|
import Show from './views/page/Show.vue'
|
||||||
|
import Edit from './views/page/Edit.vue'
|
||||||
|
|
||||||
|
import spaceManage from './views/space/Manage.vue'
|
||||||
|
|
||||||
|
import sharePcHome from './views/page/share/pc/Home.vue'
|
||||||
|
import sharePcView from './views/page/share/pc/View.vue'
|
||||||
|
import shareMobileView from './views/page/share/mobile/View.vue'
|
||||||
|
|
||||||
let routes = [
|
let routes = [
|
||||||
{path: '/', redirect: '/home'},
|
{path: '/', redirect: '/home'},
|
||||||
{path: '/page/search', name: 'WIKI-全局搜索', component: () => import('@/views/page/Search')},
|
{path: '/page/search', name: 'WIKI-全局搜索', component: Search},
|
||||||
{path: '/common/noAuth', name: 'WIKI-没有权限', component: () => import('@/views/common/NoAuth')},
|
{path: '/common/noAuth', name: 'WIKI-没有权限', component: NoAuth},
|
||||||
{path: '/page/editorTest', name: '编辑内容', component: () => import('@/views/page/EditorTest')},
|
{path: '/page/editorTest', name: '编辑内容', component: EditorTest},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: '页面管理',
|
name: '页面管理',
|
||||||
component: GlobalLayout,
|
component: GlobalLayout,
|
||||||
children: [
|
children: [
|
||||||
{path: '/home', name: 'WIKI文档管理', component: () => import('@/views/home/Home')},
|
{path: '/home', name: 'WIKI文档管理', component: Home},
|
||||||
{path: '/user/myInfo', name: 'WIKI-我的信息', component: () => import('@/views/user/MyInfo')},
|
{path: '/user/myInfo', name: 'WIKI-我的信息', component: MyInfo},
|
||||||
{path: '/page/show', name: 'WIKI-内容展示', component: () => import('@/views/page/Show')},
|
{path: '/page/show', name: 'WIKI-内容展示', component: Show},
|
||||||
{path: '/page/edit', name: 'WIKI-编辑内容', component: () => import('@/views/page/Edit')},
|
{path: '/page/edit', name: 'WIKI-编辑内容', component: Edit},
|
||||||
{path: '/space/manage', name: 'WIKI-空间管理', component: () => import('@/views/space/Manage')},
|
{path: '/space/manage', name: 'WIKI-空间管理', component: spaceManage},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -24,8 +39,8 @@ let routes = [
|
|||||||
name: '页面管理',
|
name: '页面管理',
|
||||||
component: ShareLayout,
|
component: ShareLayout,
|
||||||
children: [
|
children: [
|
||||||
{path: '/page/share/home', name: 'WIKI-开放文档', component: () => import('@/views/page/share/pc/Home')},
|
{path: '/page/share/home', name: 'WIKI-开放文档', component: sharePcHome},
|
||||||
{path: '/page/share/view', name: 'WIKI-内容展示', component: () => import('@/views/page/share/pc/View')},
|
{path: '/page/share/view', name: 'WIKI-内容展示', component: sharePcView},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -33,7 +48,7 @@ let routes = [
|
|||||||
name: '页面管理',
|
name: '页面管理',
|
||||||
component: ShareMobileLayout,
|
component: ShareMobileLayout,
|
||||||
children: [
|
children: [
|
||||||
{path: '/page/share/mobile/view', name: 'WIKI-开放文档', component: () => import('@/views/page/share/mobile/View')},
|
{path: '/page/share/mobile/view', name: 'WIKI-开放文档', component: shareMobileView},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
<el-row type="border-card" style="height: 100%;">
|
<el-row type="border-card" style="height: 100%;">
|
||||||
<el-col :span="actionTabVisible?18:24" style="padding: 20px;border-right: 1px solid #f1f1f1;height: 100%;overflow: auto;">
|
<el-col :span="actionTabVisible?18:24" style="padding: 20px;border-right: 1px solid #f1f1f1;height: 100%;overflow: auto;">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :xs="0" :sm="4" :md="4" :lg="6" :xl="6" v-if="navigationList.length > 0">
|
|
||||||
<Navigation ref="navigation" :heading="navigationList"></Navigation>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="navigationList.length > 0?20:24" :md="navigationList.length > 0?20:24" :lg="navigationList.length > 0?18:24" :xl="navigationList.length > 0?18:24">
|
<el-col :xs="24" :sm="navigationList.length > 0?20:24" :md="navigationList.length > 0?20:24" :lg="navigationList.length > 0?18:24" :xl="navigationList.length > 0?18:24">
|
||||||
<div style="max-width: 1000px;margin: 0 auto;padding-left: 10px;">
|
<div style="max-width: 1000px;margin: 0 auto;padding-left: 10px;">
|
||||||
<div class="wiki-title" ref="wikiTitle">{{wikiPage.name}}</div>
|
<div class="wiki-title" ref="wikiTitle">{{wikiPage.name}}</div>
|
||||||
@@ -33,6 +30,7 @@
|
|||||||
<el-dropdown-item command="editAuth" v-if="wikiPageAuth.canConfigAuth==1" icon="el-icon-s-check">权限设置</el-dropdown-item>
|
<el-dropdown-item command="editAuth" v-if="wikiPageAuth.canConfigAuth==1" icon="el-icon-s-check">权限设置</el-dropdown-item>
|
||||||
<el-dropdown-item command="showOpenPage" v-if="spaceInfo.openDoc == 1" icon="el-icon-share">查看开放文档</el-dropdown-item>
|
<el-dropdown-item command="showOpenPage" v-if="spaceInfo.openDoc == 1" icon="el-icon-share">查看开放文档</el-dropdown-item>
|
||||||
<el-dropdown-item command="showMobileView" v-if="spaceInfo.openDoc == 1" icon="el-icon-mobile-phone">手机端查看</el-dropdown-item>
|
<el-dropdown-item command="showMobileView" v-if="spaceInfo.openDoc == 1" icon="el-icon-mobile-phone">手机端查看</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="exportWord" v-if="spaceInfo.openDoc == 1" icon="el-icon-download">导出为Word文档</el-dropdown-item>
|
||||||
<el-dropdown-item command="deletePage" v-if="wikiPageAuth.canDelete==1" icon="el-icon-delete">删除</el-dropdown-item>
|
<el-dropdown-item command="deletePage" v-if="wikiPageAuth.canDelete==1" icon="el-icon-delete">删除</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
@@ -84,6 +82,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :xs="0" :sm="4" :md="4" :lg="6" :xl="6" v-if="navigationList.length > 0">
|
||||||
|
<Navigation ref="navigation" :heading="navigationList"></Navigation>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6" style="height: 100%;" v-show="actionTabVisible">
|
<el-col :span="6" style="height: 100%;" v-show="actionTabVisible">
|
||||||
@@ -187,6 +188,9 @@
|
|||||||
<div ref="imagePreview">
|
<div ref="imagePreview">
|
||||||
<el-image-viewer v-if="showImagePreview" :url-list="showImagePreviewList" :on-close="closeImagePreview" :initial-index="previewInitialIndex"/>
|
<el-image-viewer v-if="showImagePreview" :url-list="showImagePreviewList" :on-close="closeImagePreview" :initial-index="previewInitialIndex"/>
|
||||||
</div>
|
</div>
|
||||||
|
<form method="post" ref="downloadForm" :action="downloadFormParam.url" target="_blank">
|
||||||
|
<input type="hidden" :name="key" :value="val" v-for="(val,key) in downloadFormParam.param">
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -255,6 +259,11 @@ var page = {
|
|||||||
fullscreen: true,
|
fullscreen: true,
|
||||||
readmodel: true,
|
readmodel: true,
|
||||||
},
|
},
|
||||||
|
// 下载为Word
|
||||||
|
downloadFormParam: {
|
||||||
|
url: 'zyplayer-doc-wiki/page/download',
|
||||||
|
param: {}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
beforeRouteUpdate(to, from, next) {
|
||||||
@@ -287,38 +296,52 @@ var page = {
|
|||||||
} else if (val == 'showPageHistory') {
|
} else if (val == 'showPageHistory') {
|
||||||
this.showPageHistory();
|
this.showPageHistory();
|
||||||
} else if (val == 'showOpenPage') {
|
} else if (val == 'showOpenPage') {
|
||||||
if (this.spaceInfo.openDoc != 1) {
|
this.showOpenPage();
|
||||||
this.$message.warning("该空间未开放,无法查看开放文档地址");
|
|
||||||
} else {
|
|
||||||
let routeUrl = this.$router.resolve({
|
|
||||||
path: '/page/share/view',
|
|
||||||
query: {pageId: this.wikiPage.id, space: this.spaceInfo.uuid}
|
|
||||||
});
|
|
||||||
window.open(routeUrl.href, '_blank');
|
|
||||||
}
|
|
||||||
} else if (val == 'showMobileView') {
|
} else if (val == 'showMobileView') {
|
||||||
if (this.spaceInfo.openDoc != 1) {
|
this.showMobileView();
|
||||||
this.$message.warning("该空间未开放,无法查看开放文档地址");
|
} else if (val == 'exportWord') {
|
||||||
} else {
|
this.exportWord();
|
||||||
let routeUrl = this.$router.resolve({
|
}
|
||||||
path: '/page/share/mobile/view',
|
},
|
||||||
query: {pageId: this.wikiPage.id, space: this.spaceInfo.uuid}
|
exportWord() {
|
||||||
|
this.downloadFormParam.param = {
|
||||||
|
pageId: this.wikiPage.id
|
||||||
|
};
|
||||||
|
setTimeout(() => this.$refs.downloadForm.submit(), 0);
|
||||||
|
},
|
||||||
|
showOpenPage() {
|
||||||
|
if (this.spaceInfo.openDoc != 1) {
|
||||||
|
this.$message.warning("该空间未开放,无法查看开放文档地址");
|
||||||
|
} else {
|
||||||
|
let routeUrl = this.$router.resolve({
|
||||||
|
path: '/page/share/view',
|
||||||
|
query: {pageId: this.wikiPage.id, space: this.spaceInfo.uuid}
|
||||||
|
});
|
||||||
|
window.open(routeUrl.href, '_blank');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showMobileView() {
|
||||||
|
if (this.spaceInfo.openDoc != 1) {
|
||||||
|
this.$message.warning("该空间未开放,无法查看开放文档地址");
|
||||||
|
} else {
|
||||||
|
let routeUrl = this.$router.resolve({
|
||||||
|
path: '/page/share/mobile/view',
|
||||||
|
query: {pageId: this.wikiPage.id, space: this.spaceInfo.uuid}
|
||||||
|
});
|
||||||
|
this.mobileScanDialogVisible = true;
|
||||||
|
let hostPath = window.location.href.split("#")[0];
|
||||||
|
setTimeout(() => {
|
||||||
|
this.qrCodeUrl = hostPath + routeUrl.href;
|
||||||
|
this.$refs.qrCodeDiv.innerHTML = "";
|
||||||
|
new QRCode(this.$refs.qrCodeDiv, {
|
||||||
|
text: this.qrCodeUrl,
|
||||||
|
width: 250,
|
||||||
|
height: 250,
|
||||||
|
colorDark: "#333333", //二维码颜色
|
||||||
|
colorLight: "#ffffff", //二维码背景色
|
||||||
|
correctLevel: QRCode.CorrectLevel.M//容错率,L/M/H
|
||||||
});
|
});
|
||||||
this.mobileScanDialogVisible = true;
|
}, 0);
|
||||||
let hostPath = window.location.href.split("#")[0];
|
|
||||||
setTimeout(() => {
|
|
||||||
this.qrCodeUrl = hostPath + routeUrl.href;
|
|
||||||
this.$refs.qrCodeDiv.innerHTML = "";
|
|
||||||
new QRCode(this.$refs.qrCodeDiv, {
|
|
||||||
text: this.qrCodeUrl,
|
|
||||||
width: 250,
|
|
||||||
height: 250,
|
|
||||||
colorDark: "#333333", //二维码颜色
|
|
||||||
colorLight: "#ffffff", //二维码背景色
|
|
||||||
correctLevel: QRCode.CorrectLevel.M//容错率,L/M/H
|
|
||||||
});
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addPageAuthUser() {
|
addPageAuthUser() {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
top: 150px;
|
top: 150px;
|
||||||
height: calc(100vh - 250px);
|
max-height: calc(100vh - 250px);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-left: 16px;
|
padding-left: 16px;
|
||||||
|
|||||||
@@ -53,6 +53,32 @@
|
|||||||
<groupId>org.eclipse.jgit</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>org.eclipse.jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>4.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>4.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml-schemas</artifactId>
|
||||||
|
<version>4.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
|
<version>4.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>ooxml-schemas</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ import com.zyplayer.doc.wiki.service.git.GitService;
|
|||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import com.github.dozermapper.core.Mapper;
|
import com.github.dozermapper.core.Mapper;
|
||||||
|
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||||
|
import org.apache.poi.poifs.filesystem.DocumentEntry;
|
||||||
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -35,6 +38,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -323,6 +331,47 @@ public class WikiPageController {
|
|||||||
return this.news(param);
|
return this.news(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/download")
|
||||||
|
public ResponseJson<Object> download(Long pageId, HttpServletResponse response) {
|
||||||
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
|
WikiPage wikiPageSel = wikiPageService.getById(pageId);
|
||||||
|
// 页面已删除
|
||||||
|
if (wikiPageSel == null || Objects.equals(wikiPageSel.getDelFlag(), 1)) {
|
||||||
|
return DocResponseJson.warn("该页面不存在或已删除!");
|
||||||
|
}
|
||||||
|
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||||
|
// 空间已删除
|
||||||
|
if (wikiSpaceSel == null || Objects.equals(wikiSpaceSel.getDelFlag(), 1)) {
|
||||||
|
return DocResponseJson.warn("该页面不存在或已删除!");
|
||||||
|
}
|
||||||
|
// 私人空间
|
||||||
|
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||||
|
return DocResponseJson.warn("您没有权限查看该空间的文章详情!");
|
||||||
|
}
|
||||||
|
UpdateWrapper<WikiPageContent> wrapper = new UpdateWrapper<>();
|
||||||
|
wrapper.eq("page_id", pageId);
|
||||||
|
WikiPageContent pageContent = wikiPageContentService.getOne(wrapper);
|
||||||
|
try {
|
||||||
|
ByteArrayInputStream bais = new ByteArrayInputStream(pageContent.getContent().getBytes("GBK"));
|
||||||
|
POIFSFileSystem poifs = new POIFSFileSystem();
|
||||||
|
DirectoryEntry directory = poifs.getRoot();
|
||||||
|
directory.createDocument("WordDocument", bais);
|
||||||
|
// 写入流
|
||||||
|
response.setContentType("application/vnd.ms-excel");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
String fileName = URLEncoder.encode(wikiPageSel.getName(), "UTF-8");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".docx");
|
||||||
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
|
poifs.writeFilesystem(outputStream);
|
||||||
|
bais.close();
|
||||||
|
outputStream.close();
|
||||||
|
return DocResponseJson.ok();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return DocResponseJson.warn("导出失败");
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/news")
|
@PostMapping("/news")
|
||||||
public ResponseJson<Object> news(SearchByEsParam param) {
|
public ResponseJson<Object> news(SearchByEsParam param) {
|
||||||
// 空间不是自己的
|
// 空间不是自己的
|
||||||
|
|||||||
Reference in New Issue
Block a user