IDCDatasync-vue/src/views/data/dataCleansing.vue

111 lines
3.3 KiB
Vue
Raw Normal View History

2025-03-01 12:33:56 +08:00
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="30">
<a-col :md="6" :sm="10" >
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button @click="dataAdd" type="primary" v-has="'cont:btn'" icon="plus">数据清洗整编</a-button>
</span>
</a-col>
</a-row>
</a-form>
<a-progress :percent="percent" status="active" />
</div>
<!-- table区域-begin -->
<div style="height:900px;overflow-y:auto;">
<a-list bordered :data-source="contentList">
<a-list-item slot="renderItem" slot-scope="item, index">
{{ item }}
</a-list-item>
</a-list>
</div>
<!-- table区域-end -->
<!-- 表单区域 -->
</a-card>
</template>
<script>
import store from '@/store/'
import {getAction} from '@/api/manage'
export default {
name: "dataManage",
components: {
},
data () {
return {
description: '数据发布',
contentList:[],
percent:0,
websock:{},
}
},
mounted() {
//初始化websocket
this.initWebSocket()
},
computed: {
},
destroyed: function () { // 离开页面生命周期函数
var userId = store.getters.userInfo.id;
this.websock.send("close_"+userId);
this.websocketclose();
2025-03-01 12:33:56 +08:00
},
created () {
},
methods: {
initWebSocket: function () {
// WebSocket与普通的请求所用协议有所不同ws等同于httpwss等同于https
var userId = store.getters.userInfo.id;
2025-03-01 16:52:51 +08:00
var url = window._CONFIG['domianURL'].replace("https://","ws://").replace("http://","ws://")+"/websocket/"+userId+"/data_cleaning";
2025-03-01 12:33:56 +08:00
this.websock = new WebSocket(url);
this.websock.onopen = this.websocketonopen;
this.websock.onerror = this.websocketonerror;
this.websock.onmessage = this.websocketonmessage;
this.websock.onclose = this.websocketclose;
},
websocketonopen: function () {
2025-03-01 17:03:57 +08:00
this.contentList.unshift("消息服务连接成功");
2025-03-01 12:33:56 +08:00
},
websocketonerror: function (e) {
2025-03-01 17:03:57 +08:00
this.contentList.unshift("消息服务连接失败"+JSON.stringify(e));
2025-03-01 12:33:56 +08:00
},
websocketonmessage: function (e) {
var data = eval("(" + e.data + ")");
console.log(data);
//处理订阅信息
if(data.content.length >0){
2025-03-04 18:50:42 +08:00
var char = "当前同步百分比:";
2025-03-04 21:15:54 +08:00
let index = data.content.indexOf(char);
2025-03-04 18:50:42 +08:00
if (index >= 0) {
2025-03-04 21:15:54 +08:00
let result = data.content.substring(index + char.length,data.content.length - 1); // 获取 "V" 及其后所有字符
this.percent = parseInt(result) ;
2025-03-04 18:50:42 +08:00
}
2025-03-01 17:03:57 +08:00
this.contentList.unshift(data.content);
2025-03-01 12:33:56 +08:00
}
},
websocketclose: function (e) {
console.log("connection closed (" + e + ")");
},
dataAdd(){
getAction("/rawToStandard/syncMultipleSchemas?dataTaskId=123").then((res) => {
if (res.success) {
this.$message.success(res.message);
}
});
},
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>