Merge branch 'feature-Alarm-renpy' into master-dev
This commit is contained in:
commit
79e9a3abaa
|
@ -6,7 +6,8 @@
|
|||
:arrowPointAtCenter="true"
|
||||
overlayClassName="header-notice-wrapper"
|
||||
@visibleChange="handleHoverChange"
|
||||
:overlayStyle="{ width: '300px', top: '50px' }">
|
||||
:overlayStyle="{ width: '300px', top: '50px' }"
|
||||
>
|
||||
<template slot="content">
|
||||
<a-spin :spinning="loadding">
|
||||
<a-tabs>
|
||||
|
@ -31,12 +32,16 @@
|
|||
<a-list>
|
||||
<a-list-item :key="index" v-for="(record, index) in announcement1">
|
||||
<div style="margin-left: 5%; width: 80%">
|
||||
<p><a @click="showAnnouncement(record)">{{ record.titile }}</a></p>
|
||||
<p style="color: rgba(0,0,0,.45);margin-bottom: 0px">{{ record.createTime }} 发布</p>
|
||||
<p>
|
||||
<a @click="showAnnouncement(record)">{{ record.titile }}</a>
|
||||
</p>
|
||||
<p style="color: #c9f6f6; margin-bottom: 0px">{{ record.createTime }} 发布</p>
|
||||
</div>
|
||||
<div style="text-align: right">
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'L'" color="blue">一般消息</a-tag>
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'M'" color="orange">重要消息</a-tag>
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'M'" color="orange"
|
||||
>重要消息</a-tag
|
||||
>
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'H'" color="red">紧急消息</a-tag>
|
||||
</div>
|
||||
</a-list-item>
|
||||
|
@ -49,12 +54,16 @@
|
|||
<a-list>
|
||||
<a-list-item :key="index" v-for="(record, index) in announcement2">
|
||||
<div style="margin-left: 5%; width: 80%">
|
||||
<p><a @click="showAnnouncement(record)">{{ record.titile }}</a></p>
|
||||
<p style="color: rgba(0,0,0,.45);margin-bottom: 0px">{{ record.createTime }} 发布</p>
|
||||
<p>
|
||||
<a @click="showAnnouncement(record)">{{ record.titile }}</a>
|
||||
</p>
|
||||
<p style="color: #c9f6f6; margin-bottom: 0px">{{ record.createTime }} 发布</p>
|
||||
</div>
|
||||
<div style="text-align: right">
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'L'" color="blue">一般消息</a-tag>
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'M'" color="orange">重要消息</a-tag>
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'M'" color="orange"
|
||||
>重要消息</a-tag
|
||||
>
|
||||
<a-tag @click="showAnnouncement(record)" v-if="record.priority === 'H'" color="red">紧急消息</a-tag>
|
||||
</div>
|
||||
</a-list-item>
|
||||
|
@ -68,7 +77,7 @@
|
|||
</template>
|
||||
<span @click="fetchNotice" class="header-notice">
|
||||
<a-badge :count="msgTotal">
|
||||
<img src="@/assets/images/header/notice.png" alt="">
|
||||
<img src="@/assets/images/header/notice.png" alt="" />
|
||||
</a-badge>
|
||||
</span>
|
||||
<show-announcement ref="ShowAnnouncement" @ok="modalFormOk"></show-announcement>
|
||||
|
@ -85,7 +94,7 @@
|
|||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
|
||||
export default {
|
||||
name: "HeaderNotice",
|
||||
name: 'HeaderNotice',
|
||||
components: {
|
||||
DynamicNotice,
|
||||
ShowAnnouncement,
|
||||
|
@ -94,17 +103,17 @@
|
|||
return {
|
||||
loadding: false,
|
||||
url: {
|
||||
listCementByUser:"/sys/annountCement/listByUser",
|
||||
editCementSend:"/sys/sysAnnouncementSend/editByAnntIdAndUserId",
|
||||
queryById:"/sys/annountCement/queryById",
|
||||
listCementByUser: '/sys/annountCement/listByUser',
|
||||
editCementSend: '/sys/sysAnnouncementSend/editByAnntIdAndUserId',
|
||||
queryById: '/sys/annountCement/queryById',
|
||||
},
|
||||
hovered: false,
|
||||
announcement1: [],
|
||||
announcement2: [],
|
||||
msg1Count:"0",
|
||||
msg2Count:"0",
|
||||
msg1Title:"通知(0)",
|
||||
msg2Title:"",
|
||||
msg1Count: '0',
|
||||
msg2Count: '0',
|
||||
msg1Title: '通知(0)',
|
||||
msg2Title: '',
|
||||
stopTimer: false,
|
||||
websock: null,
|
||||
lockReconnect: false,
|
||||
|
@ -112,31 +121,32 @@
|
|||
wsConnectErrorTime: 1,
|
||||
heartCheck: null,
|
||||
formData: {},
|
||||
openPath:''
|
||||
openPath: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
msgTotal() {
|
||||
return parseInt(this.msg1Count)+parseInt(this.msg2Count);
|
||||
}
|
||||
return parseInt(this.msg1Count) + parseInt(this.msg2Count)
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.loadData();
|
||||
this.loadData()
|
||||
//this.timerFun();
|
||||
this.initWebSocket();
|
||||
this.initWebSocket()
|
||||
// this.heartCheckFun();
|
||||
},
|
||||
destroyed: function () { // 离开页面生命周期函数
|
||||
this.websocketOnclose();
|
||||
destroyed: function () {
|
||||
// 离开页面生命周期函数
|
||||
this.websocketOnclose()
|
||||
},
|
||||
methods: {
|
||||
timerFun() {
|
||||
this.stopTimer = false;
|
||||
this.stopTimer = false
|
||||
let myTimer = setInterval(() => {
|
||||
// 停止定时器
|
||||
if (this.stopTimer == true) {
|
||||
clearInterval(myTimer);
|
||||
return;
|
||||
clearInterval(myTimer)
|
||||
return
|
||||
}
|
||||
this.loadData()
|
||||
}, 6000)
|
||||
|
@ -144,23 +154,25 @@
|
|||
loadData() {
|
||||
try {
|
||||
// 获取系统消息
|
||||
getAction(this.url.listCementByUser).then((res) => {
|
||||
getAction(this.url.listCementByUser)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
this.announcement1 = res.result.anntMsgList;
|
||||
this.msg1Count = res.result.anntMsgTotal;
|
||||
this.msg1Title = "通知(" + res.result.anntMsgTotal + ")";
|
||||
this.announcement2 = res.result.sysMsgList;
|
||||
this.msg2Count = res.result.sysMsgTotal;
|
||||
this.msg2Title = "系统消息(" + res.result.sysMsgTotal + ")";
|
||||
this.announcement1 = res.result.anntMsgList
|
||||
this.msg1Count = res.result.anntMsgTotal
|
||||
this.msg1Title = '通知(' + res.result.anntMsgTotal + ')'
|
||||
this.announcement2 = res.result.sysMsgList
|
||||
this.msg2Count = res.result.sysMsgTotal
|
||||
this.msg2Title = '系统消息(' + res.result.sysMsgTotal + ')'
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log("系统消息通知异常",error);//这行打印permissionName is undefined
|
||||
this.stopTimer = true;
|
||||
console.log("清理timer");
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('系统消息通知异常', error) //这行打印permissionName is undefined
|
||||
this.stopTimer = true
|
||||
console.log('清理timer')
|
||||
})
|
||||
} catch (err) {
|
||||
this.stopTimer = true;
|
||||
console.log("通知异常",err);
|
||||
this.stopTimer = true
|
||||
console.log('通知异常', err)
|
||||
}
|
||||
},
|
||||
fetchNotice() {
|
||||
|
@ -176,168 +188,171 @@
|
|||
showAnnouncement(record) {
|
||||
putAction(this.url.editCementSend, { anntId: record.id }).then((res) => {
|
||||
if (res.success) {
|
||||
this.loadData();
|
||||
this.loadData()
|
||||
}
|
||||
});
|
||||
this.hovered = false;
|
||||
})
|
||||
this.hovered = false
|
||||
if (record.openType === 'component') {
|
||||
this.openPath = record.openPage;
|
||||
this.formData = {id:record.busId};
|
||||
this.$refs.showDynamNotice.detail(record.openPage);
|
||||
this.openPath = record.openPage
|
||||
this.formData = { id: record.busId }
|
||||
this.$refs.showDynamNotice.detail(record.openPage)
|
||||
} else {
|
||||
this.$refs.ShowAnnouncement.detail(record);
|
||||
this.$refs.ShowAnnouncement.detail(record)
|
||||
}
|
||||
},
|
||||
toMyAnnouncement() {
|
||||
this.$router.push({
|
||||
path: '/isps/userAnnouncement'
|
||||
});
|
||||
},
|
||||
modalFormOk(){
|
||||
path: '/isps/userAnnouncement',
|
||||
})
|
||||
},
|
||||
modalFormOk() {},
|
||||
handleHoverChange(visible) {
|
||||
this.hovered = visible;
|
||||
this.hovered = visible
|
||||
},
|
||||
|
||||
initWebSocket: function () {
|
||||
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
||||
var userId = store.getters.userInfo.id;
|
||||
var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://")+"/websocket/"+userId;
|
||||
var userId = store.getters.userInfo.id
|
||||
var url =
|
||||
window._CONFIG['domianURL'].replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId
|
||||
//console.log(url);
|
||||
//update-begin-author:taoyan date:2022-4-22 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278
|
||||
let token = Vue.ls.get(ACCESS_TOKEN)
|
||||
this.websock = new WebSocket(url, [token]);
|
||||
this.websock = new WebSocket(url, [token])
|
||||
//update-end-author:taoyan date:2022-4-22 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278
|
||||
this.websock.onopen = this.websocketOnopen;
|
||||
this.websock.onerror = this.websocketOnerror;
|
||||
this.websock.onmessage = this.websocketOnmessage;
|
||||
this.websock.onclose = this.websocketOnclose;
|
||||
this.websock.onopen = this.websocketOnopen
|
||||
this.websock.onerror = this.websocketOnerror
|
||||
this.websock.onmessage = this.websocketOnmessage
|
||||
this.websock.onclose = this.websocketOnclose
|
||||
},
|
||||
websocketOnopen: function () {
|
||||
console.log("WebSocket连接成功");
|
||||
console.log('WebSocket连接成功')
|
||||
//心跳检测重置
|
||||
//this.heartCheck.reset().start();
|
||||
},
|
||||
websocketOnerror: function (e) {
|
||||
console.log("WebSocket连接发生错误,第%s次",this.wsConnectErrorTime);
|
||||
console.log('WebSocket连接发生错误,第%s次', this.wsConnectErrorTime)
|
||||
|
||||
this.wsConnectErrorTime = this.wsConnectErrorTime + 1;
|
||||
this.wsConnectErrorTime = this.wsConnectErrorTime + 1
|
||||
if (this.wsConnectErrorTime > 5) {
|
||||
console.log("WebSocket连接错误超过5次,就不再重新连了!");
|
||||
console.log('WebSocket连接错误超过5次,就不再重新连了!')
|
||||
this.lockReconnect = true
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
this.reconnect();
|
||||
this.reconnect()
|
||||
},
|
||||
websocketOnmessage: function (e) {
|
||||
console.log("-----接收消息-------",e.data);
|
||||
var data = eval("(" + e.data + ")"); //解析对象
|
||||
console.log('-----接收消息-------', e.data)
|
||||
var data = eval('(' + e.data + ')') //解析对象
|
||||
this.voiceBroadcast(data.msgTxt)
|
||||
if(data.cmd == "topic"){
|
||||
if (data.cmd == 'topic') {
|
||||
//系统通知
|
||||
this.loadData();
|
||||
}else if(data.cmd == "user"){
|
||||
this.loadData()
|
||||
} else if (data.cmd == 'user') {
|
||||
//用户消息
|
||||
this.loadData();
|
||||
this.loadData()
|
||||
}
|
||||
//心跳检测重置
|
||||
//this.heartCheck.reset().start();
|
||||
},
|
||||
websocketOnclose: function (e) {
|
||||
console.log("connection closed (" + e + ")");
|
||||
console.log('connection closed (' + e + ')')
|
||||
if (e) {
|
||||
console.log("connection closed (" + e.code + ")");
|
||||
console.log('connection closed (' + e.code + ')')
|
||||
}
|
||||
this.reconnect();
|
||||
this.reconnect()
|
||||
},
|
||||
websocketSend(text) { // 数据发送
|
||||
websocketSend(text) {
|
||||
// 数据发送
|
||||
try {
|
||||
this.websock.send(text);
|
||||
this.websock.send(text)
|
||||
} catch (err) {
|
||||
console.log("send failed (" + err.code + ")");
|
||||
console.log('send failed (' + err.code + ')')
|
||||
}
|
||||
},
|
||||
//语音播报系统通知
|
||||
voiceBroadcast(text) {
|
||||
var url = "http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=" + encodeURI(text); // baidu文字转语音
|
||||
var voiceContent = new Audio(url);
|
||||
voiceContent.src = url;
|
||||
voiceContent.play();
|
||||
var url = 'http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=' + encodeURI(text) // baidu文字转语音
|
||||
var voiceContent = new Audio(url)
|
||||
voiceContent.src = url
|
||||
voiceContent.play()
|
||||
},
|
||||
openNotification(data) {
|
||||
var text = data.msgTxt;
|
||||
const key = `open${Date.now()}`;
|
||||
var text = data.msgTxt
|
||||
const key = `open${Date.now()}`
|
||||
this.$notification.open({
|
||||
message: '消息提醒',
|
||||
placement: 'bottomRight',
|
||||
description: text,
|
||||
key,
|
||||
btn: (h) => {
|
||||
return h('a-button', {
|
||||
return h(
|
||||
'a-button',
|
||||
{
|
||||
props: {
|
||||
type: 'primary',
|
||||
size: 'small',
|
||||
},
|
||||
on: {
|
||||
click: () => this.showDetail(key,data)
|
||||
}
|
||||
}, '查看详情')
|
||||
click: () => this.showDetail(key, data),
|
||||
},
|
||||
});
|
||||
},
|
||||
'查看详情'
|
||||
)
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
reconnect() {
|
||||
var that = this;
|
||||
if(that.lockReconnect) return;
|
||||
that.lockReconnect = true;
|
||||
var that = this
|
||||
if (that.lockReconnect) return
|
||||
that.lockReconnect = true
|
||||
//没连接上会一直重连,设置延迟避免请求过多
|
||||
setTimeout(function () {
|
||||
console.info("尝试重连...");
|
||||
that.initWebSocket();
|
||||
that.lockReconnect = false;
|
||||
}, 20000);
|
||||
console.info('尝试重连...')
|
||||
that.initWebSocket()
|
||||
that.lockReconnect = false
|
||||
}, 20000)
|
||||
},
|
||||
heartCheckFun() {
|
||||
var that = this;
|
||||
var that = this
|
||||
//心跳检测,每20s心跳一次
|
||||
that.heartCheck = {
|
||||
timeout: 20000,
|
||||
timeoutObj: null,
|
||||
serverTimeoutObj: null,
|
||||
reset: function () {
|
||||
clearTimeout(this.timeoutObj);
|
||||
clearTimeout(this.timeoutObj)
|
||||
//clearTimeout(this.serverTimeoutObj);
|
||||
return this;
|
||||
return this
|
||||
},
|
||||
start: function () {
|
||||
var self = this;
|
||||
var self = this
|
||||
this.timeoutObj = setTimeout(function () {
|
||||
//这里发送一个心跳,后端收到后,返回一个心跳消息,
|
||||
//onmessage拿到返回的心跳就说明连接正常
|
||||
that.websocketSend("HeartBeat");
|
||||
console.info("客户端发送心跳");
|
||||
that.websocketSend('HeartBeat')
|
||||
console.info('客户端发送心跳')
|
||||
//self.serverTimeoutObj = setTimeout(function(){//如果超过一定时间还没重置,说明后端主动断开了
|
||||
// that.websock.close();//如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
|
||||
//}, self.timeout)
|
||||
}, this.timeout)
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
showDetail(key, data) {
|
||||
this.$notification.close(key);
|
||||
var id = data.msgId;
|
||||
this.$notification.close(key)
|
||||
var id = data.msgId
|
||||
getAction(this.url.queryById, { id: id }).then((res) => {
|
||||
if (res.success) {
|
||||
var record = res.result;
|
||||
this.showAnnouncement(record);
|
||||
var record = res.result
|
||||
this.showAnnouncement(record)
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -231,7 +231,6 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
getTheData() {
|
||||
console.log(this.serverOptions)
|
||||
let hostId = this.serverOptions.find((item) => {
|
||||
return item.value == this.currId
|
||||
}).hostId
|
||||
|
@ -278,7 +277,6 @@ export default {
|
|||
totalCpu.push(item)
|
||||
}
|
||||
})
|
||||
console.log(totalCpu)
|
||||
this.cpuDiff_xData = totalCpu[0].list.map((item) => {
|
||||
return dateFormat(new Date(item.date * 1000), 'hh:mm')
|
||||
})
|
||||
|
@ -357,14 +355,17 @@ export default {
|
|||
onServerChange(val) {
|
||||
this.currId = val.key
|
||||
this.currLabel = val.label
|
||||
this.getTheData()
|
||||
},
|
||||
onTimeChange(val) {
|
||||
this.getBeforeHours(val)
|
||||
this.getTheData()
|
||||
},
|
||||
onRangeDateChange(date, dateString) {
|
||||
this.queryParams.timer = 0
|
||||
this.queryParams.startDate = dateString[0]
|
||||
this.queryParams.endDate = dateString[1]
|
||||
this.getTheData()
|
||||
},
|
||||
drawChart1() {
|
||||
let myLine = echarts.init(document.getElementById('chart1'))
|
||||
|
@ -754,6 +755,11 @@ export default {
|
|||
data: item.data,
|
||||
}
|
||||
})
|
||||
option.legend.type = 'scroll'
|
||||
option.legend.pageIconColor = '#9ab1bc'
|
||||
option.legend.pageTextStyle = {
|
||||
color: '#9ab1bc',
|
||||
}
|
||||
this.drawLine(option)
|
||||
} else {
|
||||
this.drawLine(option)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
:class="{ 'ant-list-item-active': index === currIndex }"
|
||||
slot="renderItem"
|
||||
slot-scope="item, index"
|
||||
@click="handleBasicItem(index)"
|
||||
@click="handleBasicItem(index, item)"
|
||||
>
|
||||
<div>{{ item.sourceName }}</div>
|
||||
</a-list-item>
|
||||
|
@ -512,7 +512,6 @@ export default {
|
|||
methods: {
|
||||
// Echarts (时间线)
|
||||
EchartsTimeline() {
|
||||
console.log(3456789)
|
||||
const params = {
|
||||
itemId: '37550',
|
||||
itemType: 0,
|
||||
|
@ -647,7 +646,6 @@ export default {
|
|||
}
|
||||
getAction('/systemMonitor/queryItemHistoryData', params).then((res) => {
|
||||
const arr = res.result.map((x) => x.value)
|
||||
console.log(Math.max(...arr), Math.min(...arr))
|
||||
this.cpuData.max = Math.max(...arr).toFixed(2)
|
||||
this.cpuData.min = Math.min(...arr).toFixed(2)
|
||||
let sum = arr.reduce((tatal, num) => tatal + num, 0)
|
||||
|
@ -743,8 +741,12 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
handleBasicItem(i) {
|
||||
handleBasicItem(i, item) {
|
||||
this.currIndex = i
|
||||
this.currItemId = item.cpuUsedItemId
|
||||
this.getBasiclnfo(item.hostId)
|
||||
this.getCpuUtilizationData()
|
||||
this.getTimeLineData()
|
||||
},
|
||||
getServerAlarmHistory(callBack) {
|
||||
this.loading = true
|
||||
|
|
|
@ -333,7 +333,6 @@ export default {
|
|||
let oneHourAgo = moment().subtract(num, 'hours')
|
||||
this.queryParams.startDate = oneHourAgo.format('YYYY-MM-DD HH:mm:ss')
|
||||
this.queryParams.endDate = currentTime.format('YYYY-MM-DD HH:mm:ss')
|
||||
console.log(this.queryParams)
|
||||
},
|
||||
moment,
|
||||
onRangeDateChange(date, dateString) {
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
:width="drawerWidth"
|
||||
@close="handleCancel"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading">
|
||||
|
||||
<div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
|
||||
:confirmLoading="confirmLoading"
|
||||
>
|
||||
<div :style="{ width: '100%', border: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff' }">
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form-model ref="form" :model="model" :rules="validatorRules">
|
||||
|
||||
<a-form-model-item label="Menu Type" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-radio-group @change="onChangeMenuType" v-model="model.menuType">
|
||||
<a-radio :value="0">First Level Menu</a-radio>
|
||||
|
@ -18,16 +17,10 @@
|
|||
</a-radio-group>
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
:label="menuLabel"
|
||||
prop="name"
|
||||
hasFeedback >
|
||||
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="menuLabel" prop="name" hasFeedback>
|
||||
<a-input v-model="model.name" :readOnly="disableSubmit" />
|
||||
</a-form-model-item>
|
||||
|
||||
|
||||
<a-form-model-item
|
||||
v-show="model.menuType != 0"
|
||||
label="Parent Menu"
|
||||
|
@ -35,7 +28,8 @@
|
|||
:wrapperCol="wrapperCol"
|
||||
:validate-status="validateStatus"
|
||||
:hasFeedback="true"
|
||||
:required="true">
|
||||
:required="true"
|
||||
>
|
||||
<span slot="help">{{ validateStatus == 'error' ? 'Please Select Parent Menu' : ' ' }}</span>
|
||||
<a-tree-select
|
||||
style="width: 100%"
|
||||
|
@ -44,15 +38,12 @@
|
|||
v-model="model.parentId"
|
||||
placeholder="Please Select Parent Menu"
|
||||
:disabled="disableSubmit"
|
||||
@change="handleParentIdChange">
|
||||
@change="handleParentIdChange"
|
||||
>
|
||||
</a-tree-select>
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
prop="url"
|
||||
label="Menu Route">
|
||||
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="url" label="Menu Route">
|
||||
<a-input v-model="model.url" :readOnly="disableSubmit" />
|
||||
</a-form-model-item>
|
||||
|
||||
|
@ -61,7 +52,8 @@
|
|||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
prop="component"
|
||||
label="Component">
|
||||
label="Component"
|
||||
>
|
||||
<a-input v-model="model.component" :readOnly="disableSubmit" />
|
||||
</a-form-model-item>
|
||||
|
||||
|
@ -69,106 +61,58 @@
|
|||
v-show="model.menuType == 0"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Redirect Params">
|
||||
label="Redirect Params"
|
||||
>
|
||||
<a-input v-model="model.redirect" :readOnly="disableSubmit" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="!show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
prop="perms"
|
||||
label="Perms">
|
||||
<a-form-model-item v-show="!show" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="perms" label="Perms">
|
||||
<a-input placeholder="Enter Perms, like: user:list" v-model="model.perms" :readOnly="disableSubmit" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="!show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Auth Category">
|
||||
<a-form-model-item v-show="!show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Auth Category">
|
||||
<j-dict-select-tag v-model="model.permsType" :type="'radio'" dictCode="global_perms_type" />
|
||||
|
||||
|
||||
</a-form-model-item>
|
||||
<a-form-model-item
|
||||
v-show="!show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Status">
|
||||
<a-form-model-item v-show="!show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Status">
|
||||
<j-dict-select-tag v-model="model.status" :type="'radio'" dictCode="valid_status" />
|
||||
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Icon">
|
||||
<a-form-model-item v-show="show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Icon">
|
||||
<a-input placeholder="Click Select Icon" v-model="model.icon" :readOnly="disableSubmit">
|
||||
<a-icon slot="addonAfter" type="setting" @click="selectIcons" />
|
||||
</a-input>
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
prop="sortNo"
|
||||
label="Sort">
|
||||
<a-form-model-item v-show="show" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sortNo" label="Sort">
|
||||
<a-input-number v-model="model.sortNo" style="width: 200px" :readOnly="disableSubmit" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Is Route Menu">
|
||||
<a-form-model-item v-show="show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Is Route Menu">
|
||||
<a-switch checkedChildren="Yes" unCheckedChildren="No" v-model="model.route" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Hidden">
|
||||
<a-form-model-item v-show="show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Hidden">
|
||||
<a-switch checkedChildren="Yes" unCheckedChildren="No" v-model="model.hidden" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Keep Alive">
|
||||
<a-form-model-item v-show="show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Keep Alive">
|
||||
<a-switch checkedChildren="Yes" unCheckedChildren="No" v-model="model.keepAlive" />
|
||||
</a-form-model-item>
|
||||
|
||||
|
||||
<a-form-model-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Combine Route">
|
||||
<a-form-model-item v-show="show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Combine Route">
|
||||
<a-switch checkedChildren="Yes" unCheckedChildren="No" v-model="model.alwaysShow" />
|
||||
</a-form-model-item>
|
||||
|
||||
<a-form-model-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="Open Type">
|
||||
<a-form-model-item v-show="show" :labelCol="labelCol" :wrapperCol="wrapperCol" label="Open Type">
|
||||
<a-switch checkedChildren="External" unCheckedChildren="Internal" v-model="model.internalOrExternal" />
|
||||
</a-form-model-item>
|
||||
|
||||
</a-form-model>
|
||||
|
||||
<!-- 选择图标 -->
|
||||
<icons @choose="handleIconChoose" @close="handleIconCancel" :iconChooseVisible="iconChooseVisible"></icons>
|
||||
</a-spin>
|
||||
<a-row :style="{ textAlign: 'right' }">
|
||||
<a-button :style="{marginRight: '8px'}" @click="handleCancel" type="warn">
|
||||
Cancel
|
||||
</a-button>
|
||||
<a-button :style="{ marginRight: '8px' }" @click="handleCancel" type="warn"> Cancel </a-button>
|
||||
<a-button :disabled="disableSubmit" @click="handleOk" type="primary">Ok</a-button>
|
||||
</a-row>
|
||||
</div>
|
||||
|
@ -180,13 +124,13 @@
|
|||
import Icons from './icon/Icons'
|
||||
|
||||
export default {
|
||||
name: "PermissionModal",
|
||||
name: 'PermissionModal',
|
||||
components: { Icons },
|
||||
data() {
|
||||
return {
|
||||
drawerWidth: 700,
|
||||
treeData: [],
|
||||
title:"操作",
|
||||
title: '操作',
|
||||
visible: false,
|
||||
disableSubmit: false,
|
||||
model: {},
|
||||
|
@ -202,7 +146,7 @@
|
|||
},
|
||||
confirmLoading: false,
|
||||
iconChooseVisible: false,
|
||||
validateStatus:""
|
||||
validateStatus: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -212,82 +156,83 @@
|
|||
component: [{ required: this.show, message: 'Please Enter Component' }],
|
||||
url: [{ required: this.show, message: 'Plaase Enter Route Path' }],
|
||||
permsType: [{ required: true, message: 'Please Enter Auth Category' }],
|
||||
perms:[{ required: false, message: 'Please Enter Perms' },{validator: this.validatePerms }]
|
||||
}
|
||||
perms: [{ required: false, message: 'Please Enter Perms' }, { validator: this.validatePerms }],
|
||||
}
|
||||
},
|
||||
created () {
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
loadTree() {
|
||||
var that = this;
|
||||
var that = this
|
||||
queryTreeList().then((res) => {
|
||||
if (res.success) {
|
||||
console.log(res)
|
||||
that.treeData = [];
|
||||
that.treeData = []
|
||||
let treeList = res.result.treeList
|
||||
for (let a = 0; a < treeList.length; a++) {
|
||||
let temp = treeList[a];
|
||||
temp.isLeaf = temp.leaf;
|
||||
that.treeData.push(temp);
|
||||
let temp = treeList[a]
|
||||
temp.isLeaf = temp.leaf
|
||||
that.treeData.push(temp)
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
add() {
|
||||
//初始化默认值
|
||||
this.edit({status:'1', permsType:'1', sortNo:1.0, route:true, menuType:0,component:'layouts/RouteView' });
|
||||
this.edit({ status: '1', permsType: '1', sortNo: 1.0, route: true, menuType: 0, component: 'layouts/RouteView' })
|
||||
},
|
||||
edit(record) {
|
||||
this.resetScreenSize(); // 调用此方法,根据屏幕宽度自适应调整抽屉的宽度
|
||||
this.model = Object.assign({}, record);
|
||||
this.resetScreenSize() // 调用此方法,根据屏幕宽度自适应调整抽屉的宽度
|
||||
this.model = Object.assign({}, record)
|
||||
|
||||
//根据菜单类型,动态展示页面字段
|
||||
console.log('record: ', record)
|
||||
this.show = record.menuType==2?false:true;
|
||||
this.menuLabel = record.menuType==2?'Button/Permission':'Menu Name';
|
||||
this.show = record.menuType == 2 ? false : true
|
||||
this.menuLabel = record.menuType == 2 ? 'Button/Permission' : 'Menu Name'
|
||||
|
||||
this.visible = true;
|
||||
this.loadTree();
|
||||
this.visible = true
|
||||
this.loadTree()
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
this.disableSubmit = false;
|
||||
this.visible = false;
|
||||
this.$refs.form.resetFields();
|
||||
this.$emit('close')
|
||||
this.disableSubmit = false
|
||||
this.visible = false
|
||||
this.$refs.form.resetFields()
|
||||
},
|
||||
handleOk() {
|
||||
const that = this;
|
||||
const that = this
|
||||
// 触发表单验证
|
||||
this.$refs.form.validate(valid => {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
if ((this.model.menuType == 1 || this.model.menuType == 2) && !this.model.parentId) {
|
||||
that.validateStatus = 'error';
|
||||
that.$message.error("Please Check The Form");
|
||||
return;
|
||||
that.validateStatus = 'error'
|
||||
that.$message.error('Please Check The Form')
|
||||
return
|
||||
} else {
|
||||
that.validateStatus = 'success';
|
||||
that.validateStatus = 'success'
|
||||
}
|
||||
that.confirmLoading = true;
|
||||
let obj;
|
||||
that.confirmLoading = true
|
||||
let obj
|
||||
if (!this.model.id) {
|
||||
obj = addPermission(this.model);
|
||||
obj = addPermission(this.model)
|
||||
} else {
|
||||
obj = editPermission(this.model);
|
||||
obj = editPermission(this.model)
|
||||
}
|
||||
obj.then((res) => {
|
||||
obj
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
that.$message.success(res.message);
|
||||
that.$emit('ok');
|
||||
that.$message.success(res.message)
|
||||
that.$emit('ok')
|
||||
} else {
|
||||
that.$message.warning(res.message);
|
||||
that.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.close();
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
that.confirmLoading = false
|
||||
that.close()
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -296,9 +241,9 @@
|
|||
},
|
||||
validateNumber(rule, value, callback) {
|
||||
if (!value || new RegExp(/^[0-9]*[1-9][0-9]*$/).test(value)) {
|
||||
callback();
|
||||
callback()
|
||||
} else {
|
||||
callback("Please Enter Positive Integer");
|
||||
callback('Please Enter Positive Integer')
|
||||
}
|
||||
},
|
||||
validatePerms(rule, value, callback) {
|
||||
|
@ -308,13 +253,13 @@
|
|||
tableName: 'sys_permission',
|
||||
fieldName: 'perms',
|
||||
fieldVal: value,
|
||||
dataId: this.model.id
|
||||
};
|
||||
dataId: this.model.id,
|
||||
}
|
||||
duplicateCheck(params).then((res) => {
|
||||
if (res.success) {
|
||||
callback()
|
||||
} else {
|
||||
callback("Perms Already Exist")
|
||||
callback('Perms Already Exist')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
@ -323,24 +268,24 @@
|
|||
},
|
||||
onChangeMenuType(e) {
|
||||
if (this.model.menuType == 2) {
|
||||
this.show = false;
|
||||
this.menuLabel = 'Menu/Permission';
|
||||
this.show = false
|
||||
this.menuLabel = 'Menu/Permission'
|
||||
} else {
|
||||
this.show = true;
|
||||
this.menuLabel = 'Menu Name';
|
||||
this.show = true
|
||||
this.menuLabel = 'Menu Name'
|
||||
}
|
||||
|
||||
//update-begin---author:wangshuai ---date:20220729 for:[VUEN-1834]只有一级菜单,才默认值,子菜单的时候,清空------------
|
||||
if (!this.model.id) {
|
||||
if (this.model.menuType === 1 && this.model.component === 'layouts/RouteView') {
|
||||
this.model.component = ""
|
||||
this.model.component = ''
|
||||
}
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20220729 for:[VUEN-1834]只有一级菜单,才默认值,子菜单的时候,清空--------------
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$refs.form.validateField(['url','component']);
|
||||
});
|
||||
this.$refs.form.validateField(['url', 'component'])
|
||||
})
|
||||
},
|
||||
selectIcons() {
|
||||
this.iconChooseVisible = true
|
||||
|
@ -355,24 +300,26 @@
|
|||
},
|
||||
// 根据屏幕变化,设置抽屉尺寸
|
||||
resetScreenSize() {
|
||||
let screenWidth = document.body.clientWidth;
|
||||
let screenWidth = document.body.clientWidth
|
||||
if (screenWidth < 500) {
|
||||
this.drawerWidth = screenWidth;
|
||||
this.drawerWidth = screenWidth
|
||||
} else {
|
||||
this.drawerWidth = 700;
|
||||
this.drawerWidth = 700
|
||||
}
|
||||
},
|
||||
handleParentIdChange(value) {
|
||||
if (!value) {
|
||||
this.validateStatus="error"
|
||||
this.validateStatus = 'error'
|
||||
} else {
|
||||
this.validateStatus="success"
|
||||
}
|
||||
}
|
||||
this.validateStatus = 'success'
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
<style>
|
||||
.ant-select-dropdown {
|
||||
background-color: #03353f !important;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user