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
@@ -4,7 +4,7 @@
<div v-for="(val,index) in dataList" :key="index"> <div v-for="(val,index) in dataList" :key="index">
<div v-for="(ol,indexOne) in Object.keys(val)"> <div v-for="(ol,indexOne) in Object.keys(val)">
<div class="header-text" > <div class="header-text">
&nbsp;{{ol}} &nbsp;{{ol}}
</div> </div>
<a-row :gutter="24"> <a-row :gutter="24">
@@ -85,7 +85,7 @@
v-model="formInline[item.db_field_name]" v-model="formInline[item.db_field_name]"
:disabled="disabled" :disabled="disabled"
style="width: 100%"/> style="width: 100%"/>
<!-- :disabledDate="disabledDate"--> <!-- :disabledDate="disabledDate"-->
</a-form-model-item> </a-form-model-item>
</div> </div>
</a-col> </a-col>
@@ -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
}, },
+36 -30
View File
@@ -69,7 +69,7 @@
heartCheck: null, heartCheck: null,
formData: {}, formData: {},
openPath: '', openPath: '',
timer:'' timer: ''
} }
}, },
computed: { computed: {
@@ -77,36 +77,34 @@
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) => {
// 获取系统消息 if (res.success) {
getAction(this.url.listCementByUser).then((res) => { this.announcement1 = res.result
if (res.success) { this.msg1Count = res.result.length
this.announcement1 = res.result this.msg1Title = this.$t('MessageNotification') + '(' + res.result.length + ')'
this.msg1Count = res.result.length }
this.msg1Title = this.$t('MessageNotification') + '(' + res.result.length + ')' }).catch(error => {
}
}).catch(error => {
this.stopTimer = true
})
} catch (err) {
this.stopTimer = true this.stopTimer = true
} })
}, },
fetchNotice() { fetchNotice() {
if (this.loadding) { if (this.loadding) {
@@ -138,7 +136,7 @@
initWebSocket: function() { initWebSocket: function() {
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https // WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
var userId = store.getters.userInfo.id 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 = new WebSocket(url)
this.websock.onopen = this.websocketOnopen this.websock.onopen = this.websocketOnopen
this.websock.onerror = this.websocketOnerror this.websock.onerror = this.websocketOnerror
@@ -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,8 +223,9 @@
.header-notice-wrapper { .header-notice-wrapper {
top: 50px !important; 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;
} }
</style> </style>
<style lang="less" scoped> <style lang="less" scoped>