<template>
|
<div class="base-container">
|
<el-row>
|
<el-col :span="4">
|
<div class="search">
|
<avue-form :option="option" v-model="form" @submit="connect">
|
<template slot-scope="{}" slot="modulesIdLabel">
|
<span></span>
|
</template>
|
</avue-form>
|
</div>
|
|
<div class="menu-list">
|
<el-menu
|
:default-active="defaultActive"
|
class="el-menu-vertical-demo"
|
@select="handleSelect"
|
background-color="#545c64"
|
text-color="#fff"
|
ref="elMenu"
|
active-text-color="#ffd04b">
|
<el-menu-item v-for="data in menuList" :index="data.id" :key="data.id">
|
<span slot="title">{{ data.name }}</span>
|
</el-menu-item>
|
</el-menu>
|
</div>
|
|
</el-col>
|
<el-col :span="20">
|
<div class="show">
|
|
<div v-if="menu.property == 1">
|
<img :src="menu.fileUrl[0].value"/>
|
</div>
|
|
<div v-if="menu.property == 2">
|
<Flipbook v-if="menu.type == 2" class="flipbook"
|
:pages="flipConfig.pages"
|
:startPage="flipConfig.pageNum"
|
v-slot="flipbook"
|
ref="flipbook">
|
<div class="action-bar">
|
<left-icon
|
class="btn left"
|
:class="{ disabled: !flipbook.canFlipLeft }"
|
@click="left"
|
/>
|
<plus-icon
|
class="btn plus"
|
:class="{ disabled: !flipbook.canZoomIn }"
|
@click="flipbook.zoomIn"
|
/>
|
<span class="page-num">
|
Page {{ flipbook.page }} of {{ flipbook.numPages }}
|
</span>
|
<minus-icon
|
class="btn minus"
|
:class="{ disabled: !flipbook.canZoomOut }"
|
@click="flipbook.zoomOut"
|
/>
|
<right-icon
|
class="btn right"
|
:class="{ disabled: !flipbook.canFlipRight }"
|
@click="right"
|
/>
|
</div>
|
</Flipbook>
|
<iframe v-if="menu.type == 3" class="view-iframe" :src="path"/>
|
</div>
|
|
<div v-if="menu.property == 3">
|
<img :src="menu.fileUrl[0].value"/>
|
</div>
|
|
</div>
|
|
</el-col>
|
</el-row>
|
</div>
|
</template>
|
|
<script>
|
import {getAll} from "@/api/modules/function";
|
import Flipbook from 'flipbook-vue/vue2'
|
import LeftIcon from 'vue-material-design-icons/ChevronLeftCircle'
|
import RightIcon from 'vue-material-design-icons/ChevronRightCircle'
|
import PlusIcon from 'vue-material-design-icons/PlusCircle'
|
import MinusIcon from 'vue-material-design-icons/MinusCircle'
|
import io from "socket.io-client";
|
import {getDetail} from "@/api/modules/modules";
|
|
export default {
|
name: "funcView",
|
components: {Flipbook, LeftIcon, RightIcon, PlusIcon, MinusIcon},
|
data() {
|
return {
|
form: {},
|
option: {
|
menuSpan: 6,
|
emptyBtn: false,
|
submitText: '连接',
|
column: [
|
{
|
label: "模块id",
|
labelWidth: 15,
|
prop: "modulesId",
|
type: "input",
|
span: 16,
|
labelslot: true,
|
rules: [{
|
required: true,
|
message: "请输入模块id",
|
trigger: "blur"
|
}],
|
},
|
]
|
},
|
defaultActive: "",
|
//菜单列表
|
menuList: [],
|
//iframe路径
|
path: "",
|
//所选菜单
|
menu: "",
|
//图册翻页配置
|
flipConfig: {
|
pages: [],
|
pagesHiRes: [],
|
hasMouse: true,
|
pageNum: null,
|
},
|
socketIoClient: null,
|
}
|
},
|
mounted() {
|
},
|
methods: {
|
handleSubmit(form, done) {
|
getAll(form).then(res => {
|
if (res.data.code == 200) {
|
let data = res.data.data
|
this.menuList = data
|
done()
|
}
|
})
|
},
|
handleSelect(index) {
|
let selectData = this.menuList.filter(e => {
|
return e.id == index
|
})
|
this.viewFile(selectData[0])
|
},
|
//文件预览
|
viewFile(data) {
|
this.menu = data
|
let url
|
if (data.property == 1) {
|
|
} else if (data.property == 2) {
|
if (data.type == 2) {
|
let fileArray = data.fileUrl
|
this.flipConfig.pages = []
|
if (fileArray.length>0 && fileArray){
|
fileArray.forEach(e => {
|
this.flipConfig.pages.push(e.value)
|
})
|
}
|
} else if (data.type == 3) {
|
if (data.fileUrl&&data.fileUrl.length>0){
|
url = data.fileUrl[0].value
|
this.path = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
|
}
|
} else if (data.type == 1) {
|
if (data.fileUrl&&data.fileUrl.length>0){
|
url = data.fileUrl[0].value
|
this.path = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
|
}
|
}
|
} else if (data.property == 3) {
|
|
}
|
},
|
|
connect(form, done) {
|
let serveUri = 'http://192.168.0.200:10246'
|
let params = {
|
modulesId: form.modulesId,
|
isView: true
|
}
|
|
this.socketIoClient = io.connect(serveUri, {
|
'force new connection': true,
|
'query': 'connectInfo=' + JSON.stringify(params)
|
});
|
|
//监听与服务器的连接状态
|
this.socketIoClient.on("connect", () => {
|
done()
|
})
|
|
//监听服务器发回的消息
|
//连接成功
|
this.socketIoClient.on("connectOk", (res) => {
|
this.menuList = res.data
|
this.$notify.success({
|
title: '连接成功',
|
});
|
});
|
|
//连接失败
|
this.socketIoClient.on("connectError", (res) => {
|
this.$notify.error({
|
title: res.msg,
|
});
|
});
|
|
this.socketIoClient.on("menuChange", (res) => {
|
console.log(res)
|
this.handleSelect(res)
|
});
|
|
//上一页
|
this.socketIoClient.on("previousPage", (res) => {
|
console.log(res)
|
this.left()
|
});
|
|
//下一页
|
this.socketIoClient.on("nextPage", (res) => {
|
console.log(res)
|
this.right()
|
});
|
|
},
|
left() {
|
this.$refs.flipbook.flipLeft()
|
},
|
right() {
|
this.$refs.flipbook.flipRight()
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.show {
|
background: #404040;
|
width: 100%;
|
height: 100vh;
|
}
|
|
.show > div {
|
width: 100%;
|
height: 100%;
|
}
|
|
img {
|
width: 100%;
|
height: 100%;
|
}
|
|
.el-select {
|
width: 100%
|
}
|
|
.el-row {
|
height: 100%;
|
}
|
|
.el-col {
|
height: 100%;
|
}
|
|
.view-iframe {
|
width: 100%;
|
height: 100%;
|
}
|
|
.flipbook {
|
width: 100%;
|
height: 100vh;
|
}
|
|
.page-num {
|
color: white;
|
}
|
|
.action-bar {
|
width: 100%;
|
height: 30px;
|
padding: 10px 0;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
}
|
|
.action-bar .btn {
|
font-size: 30px;
|
color: #999;
|
}
|
|
.action-bar .btn svg {
|
bottom: 0;
|
}
|
|
.action-bar .btn:not(:first-child) {
|
margin-left: 10px;
|
}
|
|
.has-mouse .action-bar .btn:hover {
|
color: #ccc;
|
filter: drop-shadow(1px 1px 5px #000);
|
cursor: pointer;
|
}
|
|
.action-bar .btn:active {
|
filter: none !important;
|
}
|
|
.action-bar .btn.disabled {
|
color: #666;
|
pointer-events: none;
|
}
|
|
.action-bar .page-num {
|
font-size: 12px;
|
margin-left: 10px;
|
}
|
|
.flipbook .viewport {
|
width: 90vw !important;
|
height: calc(100vh - 50px - 40px) !important;
|
}
|
|
.flipbook .bounding-box {
|
box-shadow: 0 0 20px #000;
|
}
|
|
.credit {
|
font-size: 12px;
|
line-height: 20px;
|
margin: 10px;
|
}
|
|
</style>
|