Merge remote-tracking branch 'origin/master'

This commit is contained in:
wangchengjun
2022-03-23 19:02:42 +08:00
2 changed files with 49 additions and 34 deletions
@@ -376,8 +376,16 @@
}, },
IntegrateData() { IntegrateData() {
this.isFormInline = false this.isFormInline = false
let ruleList = []
this.ruleList.forEach(res => {
Object.keys(res).forEach(val => {
res[val].forEach(ol => {
ruleList.push(ol)
})
})
})
let rules = {} let rules = {}
this.ruleList.forEach((res, index) => { ruleList.forEach((res, index) => {
const rule = [] const rule = []
if (res.field_must_input == 1) { if (res.field_must_input == 1) {
if (res.field_show_type === '1') { if (res.field_show_type === '1') {
@@ -400,7 +408,7 @@
message: res.db_field_txt + this.$t('cannotEmpty'), message: res.db_field_txt + this.$t('cannotEmpty'),
trigger: 'blur' 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({ rule.push({
required: true, required: true,
message: res.db_field_txt + this.$t('cannotEmpty'), message: res.db_field_txt + this.$t('cannotEmpty'),
@@ -428,6 +436,7 @@
} }
}) })
this.$set(this, 'rules', rules) this.$set(this, 'rules', rules)
console.log(this.rules)
this.isFormInline = true this.isFormInline = true
this.confirmLoading = false this.confirmLoading = false
}, },
+24 -18
View File
@@ -77,24 +77,25 @@
return parseInt(this.msg1Count) return parseInt(this.msg1Count)
} }
}, },
mounted() { created() {
this.loadData() this.loadData()
// this.timerFun();
this.initWebSocket() this.initWebSocket()
this.heartCheckFun() },
mounted() {
// this.loadData()
// this.timerFun();
// this.initWebSocket()
// this.heartCheckFun()
}, },
beforeDestroy() { beforeDestroy() {
if(this.timer){
clearInterval(this.timer)
}
}, },
destroyed: function() { // 离开页面生命周期函数 destroyed: function() { // 离开页面生命周期函数
this.websocketOnclose() this.websocketOnclose()
clearInterval(this.timer)
}, },
methods: { methods: {
loadData() { loadData() {
try {
// 获取系统消息
getAction(this.url.listCementByUser).then((res) => { getAction(this.url.listCementByUser).then((res) => {
if (res.success) { if (res.success) {
this.announcement1 = res.result this.announcement1 = res.result
@@ -104,9 +105,6 @@
}).catch(error => { }).catch(error => {
this.stopTimer = true this.stopTimer = true
}) })
} catch (err) {
this.stopTimer = true
}
}, },
fetchNotice() { fetchNotice() {
if (this.loadding) { if (this.loadding) {
@@ -146,7 +144,17 @@
this.websock.onclose = this.websocketOnclose this.websock.onclose = this.websocketOnclose
}, },
websocketOnopen: function() { 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) { websocketOnerror: function(e) {
console.log('WebSocket连接发生错误') console.log('WebSocket连接发生错误')
@@ -158,13 +166,11 @@
this.loadData() this.loadData()
}, },
websocketOnclose: function(e) { websocketOnclose: function(e) {
console.log('connection closed (' + e + ')') console.log(e)
if (e) { this.websock.close()
console.log('connection closed (' + e.code + ')')
}
this.reconnect()
}, },
websocketSend(text) { // 数据发送 websocketSend(text) { // 数据发送
console.log(text)
try { try {
this.websock.send(text) this.websock.send(text)
} catch (err) { } catch (err) {
@@ -178,7 +184,6 @@
that.lockReconnect = true that.lockReconnect = true
//没连接上会一直重连,设置延迟避免请求过多 //没连接上会一直重连,设置延迟避免请求过多
setTimeout(function() { setTimeout(function() {
console.info('尝试重连...')
that.initWebSocket() that.initWebSocket()
that.lockReconnect = false that.lockReconnect = false
}, 5000) }, 5000)
@@ -218,6 +223,7 @@
.header-notice-wrapper { .header-notice-wrapper {
top: 50px !important; top: 50px !important;
} }
.tabs .ant-tabs-nav .ant-tabs-tab-active { .tabs .ant-tabs-nav .ant-tabs-tab-active {
color: #000F16 !important; color: #000F16 !important;
} }