优化导出、导入数据接收问题
This commit is contained in:
parent
8e059496a2
commit
7f1673a5d9
@ -27,6 +27,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {eventBus} from "@/utils/eventBus"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "index",
|
name: "index",
|
||||||
props:{
|
props:{
|
||||||
@ -41,10 +43,16 @@ export default {
|
|||||||
return{
|
return{
|
||||||
list:[{},{},{}],
|
list:[{},{},{}],
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setup(){
|
||||||
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// 获取新消息
|
// 获取新消息
|
||||||
// this.$socketApi.getSock(this.getWsResult);
|
eventBus.$on('sockBack', this.getWsResult);
|
||||||
|
},
|
||||||
|
unmounted() {
|
||||||
|
eventBus.$off('sockBack', this.getWsResult);
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getWsResult(res){
|
getWsResult(res){
|
||||||
@ -82,8 +90,6 @@ export default {
|
|||||||
},
|
},
|
||||||
exportClick(){
|
exportClick(){
|
||||||
this.$emit('exportData');
|
this.$emit('exportData');
|
||||||
// 获取新消息
|
|
||||||
this.$socketApi.getSock(this.getWsResult);
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,9 @@
|
|||||||
|
|
||||||
<template #tip>
|
<template #tip>
|
||||||
<div class="el-upload__tip">
|
<div class="el-upload__tip">
|
||||||
<span class="tip">如果数据导入中途业务出错,请不要刷新页面,修改后继续点击导入</span>
|
<span class="tip">
|
||||||
|
<!-- 如果数据导入中途业务出错,请不要刷新页面,修改后继续点击导入-->
|
||||||
|
</span>
|
||||||
<span class="btn">
|
<span class="btn">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</span>
|
</span>
|
||||||
@ -60,6 +62,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// import {inject} from "vue";
|
||||||
|
import {eventBus} from "@/utils/eventBus"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "import",
|
name: "import",
|
||||||
emits: ['parentParams', 'closed', "importSuccess"],
|
emits: ['parentParams', 'closed', "importSuccess"],
|
||||||
@ -86,17 +91,18 @@ export default {
|
|||||||
importInfo:{},
|
importInfo:{},
|
||||||
errorList:[]
|
errorList:[]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setup(){
|
||||||
|
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
visible(val){
|
|
||||||
if(val){
|
|
||||||
// 获取新消息
|
|
||||||
this.$socketApi.getSock(this.getWsResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
eventBus.$on('sockBack', this.getWsResult);
|
||||||
|
},
|
||||||
|
unmounted() {
|
||||||
|
eventBus.$off('sockBack', this.getWsResult);
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getWsResult(res){
|
getWsResult(res){
|
||||||
@ -155,6 +161,7 @@ export default {
|
|||||||
},
|
},
|
||||||
save(){
|
save(){
|
||||||
this.errorClick();
|
this.errorClick();
|
||||||
|
|
||||||
this.$emit('parentParams',this.params);
|
this.$emit('parentParams',this.params);
|
||||||
},
|
},
|
||||||
// 上传成功
|
// 上传成功
|
||||||
|
|||||||
@ -22,6 +22,5 @@ app.use(i18n);
|
|||||||
app.use(scui);
|
app.use(scui);
|
||||||
app.use(VideoPlayer)
|
app.use(VideoPlayer)
|
||||||
|
|
||||||
|
|
||||||
//挂载app
|
//挂载app
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
|
|||||||
25
src/utils/eventBus.js
Normal file
25
src/utils/eventBus.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// eventBus.js
|
||||||
|
export const eventBus = {
|
||||||
|
listeners: {},
|
||||||
|
|
||||||
|
$on(eventName, listener) {
|
||||||
|
if (!this.listeners[eventName]) {
|
||||||
|
this.listeners[eventName] = [];
|
||||||
|
}
|
||||||
|
this.listeners[eventName].push(listener);
|
||||||
|
},
|
||||||
|
|
||||||
|
$emit(eventName, ...args) {
|
||||||
|
const listeners = this.listeners[eventName];
|
||||||
|
if (listeners) {
|
||||||
|
listeners.forEach((listener) => listener(...args));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
$off(eventName, listener) {
|
||||||
|
const listeners = this.listeners[eventName];
|
||||||
|
if (listeners) {
|
||||||
|
this.listeners[eventName] = listeners.filter(l => l !== listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -5,6 +5,7 @@ import systemConfig from '@/config';
|
|||||||
import api from '../api';
|
import api from '../api';
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import {ElNotification} from 'element-plus';
|
import {ElNotification} from 'element-plus';
|
||||||
|
import {eventBus} from "./eventBus"
|
||||||
// import store from "../store";
|
// import store from "../store";
|
||||||
|
|
||||||
let websocket = null;
|
let websocket = null;
|
||||||
@ -153,6 +154,8 @@ function webSocketOnMessage(msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventBus.$emit('sockBack',result);
|
||||||
|
|
||||||
if(result.type == 'init'){
|
if(result.type == 'init'){
|
||||||
if(showNot && showNot.close){
|
if(showNot && showNot.close){
|
||||||
showNot.close();
|
showNot.close();
|
||||||
@ -168,7 +171,7 @@ function handleError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSock(callback) {
|
function getSock(callback) {
|
||||||
global_callback = callback
|
global_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据发送
|
// 数据发送
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user