修改bug
This commit is contained in:
@@ -85,14 +85,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { axios } from '@/utils/request'
|
|
||||||
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
|
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
|
||||||
import search from '@/components/search/index'
|
import search from '@/components/search/index'
|
||||||
import tableData from '@/components/ocrTable/index'
|
import tableData from '@/components/ocrTable/index'
|
||||||
import addForm from '@/components/ocrAddForm/index'
|
import addForm from '@/components/ocrAddForm/index'
|
||||||
import docTable from './modules/docTable'
|
import docTable from './modules/docTable'
|
||||||
import ocrUpload from '@/components/ocrUpload/index'
|
import ocrUpload from '@/components/ocrUpload/index'
|
||||||
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
import store from '@/store/'
|
||||||
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import eventBUs from '../../../common/event'
|
import eventBUs from '../../../common/event'
|
||||||
export default {
|
export default {
|
||||||
@@ -163,6 +163,7 @@
|
|||||||
// this.loadData()
|
// this.loadData()
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.initWebSocket()
|
||||||
// this.refresh()
|
// this.refresh()
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
@@ -176,20 +177,68 @@
|
|||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
// 定时刷新页面
|
initWebSocket: function () {
|
||||||
refresh(){
|
let token = Vue.ls.get(ACCESS_TOKEN)
|
||||||
const date = new Date(),
|
console.log("------------WebSocket连接成功");
|
||||||
year = date.getFullYear(),
|
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
||||||
month = date.getMonth()+1,
|
let userId = store.getters.userInfo.id;
|
||||||
myDate = date.getDate()
|
let url = window._CONFIG['domianWebSocketURL'].replace("https://","wss://").replace("http://","ws://") + '/websocket/' + userId;
|
||||||
this.today = `${year}/${month < 10 ? '0'+month : month}/${myDate < 10 ? '0'+myDate : myDate}`
|
this.websock = new WebSocket(url);
|
||||||
if(this.timer){
|
this.websock.onopen = this.websocketOnopen;
|
||||||
clearInterval(this.timer)
|
this.websock.onerror = this.websocketOnerror;
|
||||||
}else{
|
this.websock.onmessage = this.websocketOnmessage;
|
||||||
eventBUs.$emit('searchReset')
|
this.websock.onclose = this.websocketOnclose;
|
||||||
this.initSetTimeout(this.today)//调用每隔10秒刷新数据
|
},
|
||||||
|
websocketOnopen: function (e) {
|
||||||
|
console.log("WebSocket连接成功");
|
||||||
|
// console.log('eee',e)
|
||||||
|
},
|
||||||
|
websocketOnerror: function (e) {
|
||||||
|
console.log("WebSocket连接发生错误");
|
||||||
|
this.reconnect();
|
||||||
|
},
|
||||||
|
websocketOnmessage: function (e) {
|
||||||
|
console.log("WebSocket连接数据");
|
||||||
|
|
||||||
|
},
|
||||||
|
websocketOnclose: function (e) {
|
||||||
|
this.reconnect();
|
||||||
|
},
|
||||||
|
websocketSend(text) {
|
||||||
|
// 数据发送
|
||||||
|
try {
|
||||||
|
this.websock.send(text);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("send failed (" + err.code + ")");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
reconnect() {
|
||||||
|
let that = this;
|
||||||
|
if(that.lockReconnect) return;
|
||||||
|
that.lockReconnect = true;
|
||||||
|
//没连接上会一直重连,设置延迟避免请求过多
|
||||||
|
setTimeout(function () {
|
||||||
|
console.info("尝试重连...");
|
||||||
|
that.initWebSocket();
|
||||||
|
that.lockReconnect = false;
|
||||||
|
}, 5000);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// 定时刷新页面
|
||||||
|
// refresh(){
|
||||||
|
// const date = new Date(),
|
||||||
|
// year = date.getFullYear(),
|
||||||
|
// month = date.getMonth()+1,
|
||||||
|
// myDate = date.getDate()
|
||||||
|
// this.today = `${year}/${month < 10 ? '0'+month : month}/${myDate < 10 ? '0'+myDate : myDate}`
|
||||||
|
// if(this.timer){
|
||||||
|
// clearInterval(this.timer)
|
||||||
|
// }else{
|
||||||
|
// eventBUs.$emit('searchReset')
|
||||||
|
// this.initSetTimeout(this.today)//调用每隔10秒刷新数据
|
||||||
|
// }
|
||||||
|
// },
|
||||||
//上传
|
//上传
|
||||||
handleUpload(){
|
handleUpload(){
|
||||||
// if(this.timer){
|
// if(this.timer){
|
||||||
@@ -346,15 +395,19 @@
|
|||||||
this.fileVisible = false
|
this.fileVisible = false
|
||||||
},
|
},
|
||||||
//10秒刷新页面
|
//10秒刷新页面
|
||||||
initSetTimeout(today) {//每隔10秒刷新数据,也就是每隔10秒向后台请求一次数据
|
// initSetTimeout(today) {//每隔10秒刷新数据,也就是每隔10秒向后台请求一次数据
|
||||||
this.timer=setInterval( () => {
|
// this.timer=setInterval( () => {
|
||||||
eventBUs.$emit('searchReset')
|
// eventBUs.$emit('searchReset')
|
||||||
}, 10000)
|
// }, 10000)
|
||||||
},
|
// },
|
||||||
},
|
|
||||||
beforeDestroy(){
|
|
||||||
clearInterval(this.timer)
|
|
||||||
},
|
},
|
||||||
|
// beforeDestroy(){
|
||||||
|
// clearInterval(this.timer)
|
||||||
|
// },
|
||||||
|
destroyed() {
|
||||||
|
// 离开页面生命周期函数
|
||||||
|
this.websocketOnclose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="diolag-area">
|
<div class="diolag-area">
|
||||||
<div class="table-operator">
|
<div class="table-operator">
|
||||||
<div class="operator-text" @click="showModal">
|
<div class="operator-text" @click="showModal" v-has="'area:add'">
|
||||||
<a-icon type="plus" />
|
<a-icon type="plus" />
|
||||||
{{$t('add')}}
|
{{$t('add')}}
|
||||||
</div>
|
</div>
|
||||||
@@ -69,9 +69,8 @@
|
|||||||
@change="handleTableChange">
|
@change="handleTableChange">
|
||||||
<a slot="name" slot-scope="text">{{ text }}</a>
|
<a slot="name" slot-scope="text">{{ text }}</a>
|
||||||
<span slot="action" slot-scope="text, record">
|
<span slot="action" slot-scope="text, record">
|
||||||
<a @click="editArea(record.id)">{{$t('edit')}}</a>
|
<a class="action-edit" @click="editArea(record.id)" v-has="'area:edit'" >{{$t('edit')}}</a>
|
||||||
<a-divider type="vertical" />
|
<a style="color:red" href="javascript:;" @click=" deleteArea(record.id)" v-has="'area:delete'">{{$t('delete')}}</a>
|
||||||
<a style="color:red" href="javascript:;" @click=" deleteArea(record.id)">{{$t('delete')}}</a>
|
|
||||||
</span>
|
</span>
|
||||||
</a-table>
|
</a-table>
|
||||||
<div class="page" v-if="areaTable.length > 0">
|
<div class="page" v-if="areaTable.length > 0">
|
||||||
@@ -323,6 +322,9 @@
|
|||||||
.diolag-area{
|
.diolag-area{
|
||||||
.table-area{
|
.table-area{
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
|
.action-edit{
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.table-del{
|
.table-del{
|
||||||
color: red;
|
color: red;
|
||||||
|
|||||||
@@ -11,9 +11,8 @@
|
|||||||
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
||||||
@change="handleTableChange">
|
@change="handleTableChange">
|
||||||
<span slot="action" slot-scope="text, record">
|
<span slot="action" slot-scope="text, record">
|
||||||
<a @click="editVisible(record.id)" v-if="record.isReadOnly==0">{{$t('edit')}}</a>
|
<a class="action-edit" @click="editVisible(record.id)" v-if="record.isReadOnly==0" v-has="'tag:edit'">{{$t('edit')}}</a>
|
||||||
<a-divider type="vertical" v-if="record.isReadOnly==0" />
|
<a class="table-del" v-if="record.isReadOnly==2||record.isReadOnly==0" @click="deleteVisible(record.id)" v-has="'tag:delete'">{{$t('delete')}}</a>
|
||||||
<a class="table-del" v-if="record.isReadOnly==2||record.isReadOnly==0" @click="deleteVisible(record.id)">{{$t('delete')}}</a>
|
|
||||||
</span>
|
</span>
|
||||||
</a-table>
|
</a-table>
|
||||||
<div class="page" v-if="tableData.length > 0">
|
<div class="page" v-if="tableData.length > 0">
|
||||||
@@ -91,6 +90,9 @@
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.tab-table{
|
.tab-table{
|
||||||
|
.action-edit{
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
.table-del{
|
.table-del{
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,8 @@
|
|||||||
|
|
||||||
<template slot="action" slot-scope="text, record">
|
<template slot="action" slot-scope="text, record">
|
||||||
<a class="action-dict" @click="handleDicPop(record)">{{$t('DictionaryConfiguration')}}</a>
|
<a class="action-dict" @click="handleDicPop(record)">{{$t('DictionaryConfiguration')}}</a>
|
||||||
<a class="action-edit" @click="actionEdit(record)">{{$t('edit')}}</a>
|
<a class="action-edit" @click="actionEdit(record)" v-has="'dict:edit'">{{$t('edit')}}</a>
|
||||||
<a class="action-delete" href="javascript:;" @click="onDelete(record)">{{$t('delete')}}</a>
|
<a class="action-delete" href="javascript:;" @click="onDelete(record)" v-has="'dict:logicDelete'">{{$t('delete')}}</a>
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
<div class="page" v-if="tableData.length > 0">
|
<div class="page" v-if="tableData.length > 0">
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</a-form>
|
</a-form>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-operator">
|
<div class="table-operator">
|
||||||
<div class="operator-text" @click="handleAddPop">
|
<div class="operator-text" @click="handleAddPop" v-has="'tag:add'">
|
||||||
<a-icon type="plus" />
|
<a-icon type="plus" />
|
||||||
{{$t('add')}}
|
{{$t('add')}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user