From f03ba94b46f3f51f829b92342f4b192b936736e6 Mon Sep 17 00:00:00 2001
From: qq787203167 <787203167@qq.com>
Date: Wed, 23 Mar 2022 19:00:08 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A6=85=E9=81=93=E5=B7=B2?=
=?UTF-8?q?=E7=9F=A5bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/components/libraryAddForm/index.vue | 17 +++--
.../src/components/tools/HeaderNotice.vue | 66 ++++++++++---------
2 files changed, 49 insertions(+), 34 deletions(-)
diff --git a/jero-web/src/components/libraryAddForm/index.vue b/jero-web/src/components/libraryAddForm/index.vue
index 8aa8e933e..559d34398 100644
--- a/jero-web/src/components/libraryAddForm/index.vue
+++ b/jero-web/src/components/libraryAddForm/index.vue
@@ -4,7 +4,7 @@
-
@@ -376,8 +376,16 @@
},
IntegrateData() {
this.isFormInline = false
+ let ruleList = []
+ this.ruleList.forEach(res => {
+ Object.keys(res).forEach(val => {
+ res[val].forEach(ol => {
+ ruleList.push(ol)
+ })
+ })
+ })
let rules = {}
- this.ruleList.forEach((res, index) => {
+ ruleList.forEach((res, index) => {
const rule = []
if (res.field_must_input == 1) {
if (res.field_show_type === '1') {
@@ -400,7 +408,7 @@
message: res.db_field_txt + this.$t('cannotEmpty'),
trigger: 'blur'
})
- } else if (res.field_show_type === '8' || res.field_show_type === '9' || res.field_show_type === '10') {
+ } else if (res.field_show_type === '8' || res.field_show_type === '9' || res.field_show_type === '10' || res.field_show_type === '11') {
rule.push({
required: true,
message: res.db_field_txt + this.$t('cannotEmpty'),
@@ -428,6 +436,7 @@
}
})
this.$set(this, 'rules', rules)
+ console.log(this.rules)
this.isFormInline = true
this.confirmLoading = false
},
diff --git a/jero-web/src/components/tools/HeaderNotice.vue b/jero-web/src/components/tools/HeaderNotice.vue
index f8a157de6..d4dd5b492 100644
--- a/jero-web/src/components/tools/HeaderNotice.vue
+++ b/jero-web/src/components/tools/HeaderNotice.vue
@@ -69,7 +69,7 @@
heartCheck: null,
formData: {},
openPath: '',
- timer:''
+ timer: ''
}
},
computed: {
@@ -77,36 +77,34 @@
return parseInt(this.msg1Count)
}
},
- mounted() {
+ created() {
this.loadData()
- // this.timerFun();
this.initWebSocket()
- this.heartCheckFun()
+ },
+ mounted() {
+ // this.loadData()
+ // this.timerFun();
+ // this.initWebSocket()
+ // this.heartCheckFun()
},
beforeDestroy() {
- if(this.timer){
- clearInterval(this.timer)
- }
+
},
destroyed: function() { // 离开页面生命周期函数
this.websocketOnclose()
+ clearInterval(this.timer)
},
methods: {
loadData() {
- try {
- // 获取系统消息
- getAction(this.url.listCementByUser).then((res) => {
- if (res.success) {
- this.announcement1 = res.result
- this.msg1Count = res.result.length
- this.msg1Title = this.$t('MessageNotification') + '(' + res.result.length + ')'
- }
- }).catch(error => {
- this.stopTimer = true
- })
- } catch (err) {
+ getAction(this.url.listCementByUser).then((res) => {
+ if (res.success) {
+ this.announcement1 = res.result
+ this.msg1Count = res.result.length
+ this.msg1Title = this.$t('MessageNotification') + '(' + res.result.length + ')'
+ }
+ }).catch(error => {
this.stopTimer = true
- }
+ })
},
fetchNotice() {
if (this.loadding) {
@@ -138,7 +136,7 @@
initWebSocket: function() {
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
var userId = store.getters.userInfo.id
- var url = window._CONFIG['domianWebSocketURL'].replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId
+ var url = window._CONFIG['domianWebSocketURL'].replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/'+userId
this.websock = new WebSocket(url)
this.websock.onopen = this.websocketOnopen
this.websock.onerror = this.websocketOnerror
@@ -146,7 +144,17 @@
this.websock.onclose = this.websocketOnclose
},
websocketOnopen: function() {
- console.log('WebSocket连接成功')
+ // 添加心跳检测,每10秒发一次数据,防止连接断开(这跟服务器的设置有关,如果服务器没有设置每隔多长时间不发消息断开,可以不进行心跳设置)
+ let self = this
+ this.timer = setInterval(() => {
+ try {
+ self.websock.send('test')
+ console.log('发送消息');
+ } catch (err) {
+ console.log('断开了:' + err)
+ self.connection()
+ }
+ }, 10000)
},
websocketOnerror: function(e) {
console.log('WebSocket连接发生错误')
@@ -158,13 +166,11 @@
this.loadData()
},
websocketOnclose: function(e) {
- console.log('connection closed (' + e + ')')
- if (e) {
- console.log('connection closed (' + e.code + ')')
- }
- this.reconnect()
+ console.log(e)
+ this.websock.close()
},
websocketSend(text) { // 数据发送
+ console.log(text)
try {
this.websock.send(text)
} catch (err) {
@@ -178,7 +184,6 @@
that.lockReconnect = true
//没连接上会一直重连,设置延迟避免请求过多
setTimeout(function() {
- console.info('尝试重连...')
that.initWebSocket()
that.lockReconnect = false
}, 5000)
@@ -218,8 +223,9 @@
.header-notice-wrapper {
top: 50px !important;
}
- .tabs .ant-tabs-nav .ant-tabs-tab-active{
- color: #000F16!important;
+
+ .tabs .ant-tabs-nav .ant-tabs-tab-active {
+ color: #000F16 !important;
}