rt-sim-training-client/src/views/newMap/displayNew/demon/faultChoose.vue

466 lines
16 KiB
Vue
Raw Normal View History

2019-12-30 09:00:16 +08:00
<template>
2020-06-30 14:41:22 +08:00
<div v-show="dialogShow" id="faultChoose">
<div class="falutChooseTitle">{{ title }}</div>
<div class="closeFalutChoose" @click="closeFaultChoose">
<span class="el-icon-close closeFalutChooseIn" />
</div>
2020-07-03 17:13:24 +08:00
<el-card class="triggerFaultInfo">
<div class="triggerFaultTitle">待触发故障信息</div>
<div v-if="simulationFault.id" class="triggerFaultList">
2020-07-03 18:39:24 +08:00
<div class="triggerFaultListLeft">
触发条件: {{ getTriangleInfo(simulationFault) }}<br>
故障设备: {{ deviceMap[simulationFault.targetDeviceType]+formatNameByCode(simulationFault.targetDeviceCode) }}<br>
故障类型: {{ covertFaultType(simulationFault) }}
</div>
<div class="triggerFaultBtn">
<el-button type="primary" size="medium" @click="cancleAutoFault">取消自动故障</el-button>
</div>
2020-07-03 17:13:24 +08:00
</div>
</el-card>
<div class="card">
2020-06-30 14:41:22 +08:00
<QueryListPage ref="pageRules" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" class="queryList" />
<addFault v-if="isAdd" ref="addFault" @closeAddRules="closeAddRules" @reload="reloadTable" />
2019-12-30 09:00:16 +08:00
</div>
2020-06-30 14:41:22 +08:00
</div>
2019-12-30 09:00:16 +08:00
</template>
<script>
2020-07-03 17:13:24 +08:00
import { getFailureRulesNew, setFailureModeNew, deleteFailureRule, getSimulationFaultRules } from '@/api/simulation';
2020-06-30 19:17:29 +08:00
// getFailureGenerateRules
import ConstConfig from '@/scripts/ConstConfig';
import { FaultStatusEnum } from '@/scripts/FaultDicNew';
2019-12-30 09:00:16 +08:00
import ModelType from '@/jmap/constant/deviceType';
2020-06-30 19:17:29 +08:00
import AddFault from './addFault';
import { deviceFaultType} from '@/scripts/cmdPlugin/Config';
2019-12-30 09:00:16 +08:00
// 故障列表
export default {
name: 'FaultChoose',
2020-06-30 19:17:29 +08:00
components:{
AddFault
},
2019-12-30 09:00:16 +08:00
props: {
group: {
type: String,
required: true
2020-06-30 14:41:22 +08:00
},
offset: {
type: Number,
required: true
2019-12-30 09:00:16 +08:00
}
},
data() {
return {
dialogShow: false,
loading: false,
2020-06-30 14:41:22 +08:00
isAdd:false,
2019-12-30 09:00:16 +08:00
deviceMap: {},
2020-07-03 17:13:24 +08:00
simulationFault:{},
2019-12-30 09:00:16 +08:00
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
reset: true,
2020-07-01 11:27:09 +08:00
leftSpan:17,
2020-06-30 19:17:29 +08:00
labelWidth: '120px',
2019-12-30 09:00:16 +08:00
queryObject: {
2020-06-30 19:17:29 +08:00
deviceType:{
type: 'select',
2020-07-02 10:10:16 +08:00
label:'故障设备类型',
2020-06-30 19:17:29 +08:00
config: {
data: ConstConfig.ConstSelect.simulationDeviceList
}
2019-12-30 09:00:16 +08:00
}
2020-06-30 19:17:29 +08:00
// faultType:{
// type:'select',
// label:'故障类型',
// config: {
// data:
// // ConstConfig.ConstSelect.simulationDeviceList
// }
// }
2019-12-30 09:00:16 +08:00
}
},
queryList: {
2020-06-30 19:17:29 +08:00
query: this.getFailureRulesNew,
2019-12-30 09:00:16 +08:00
selectCheckShow: false,
2020-07-03 17:13:24 +08:00
indexShow: true,
2019-12-30 09:00:16 +08:00
columns: [
{
2020-06-30 19:17:29 +08:00
type:'basicText',
2020-07-02 10:10:16 +08:00
title: '触发条件',
2020-06-30 19:17:29 +08:00
columnValue: (row) => {
2020-07-03 17:13:24 +08:00
return this.getTriangleInfo(row);
2020-06-30 19:17:29 +08:00
}
2019-12-30 09:00:16 +08:00
},
{
2020-06-30 19:17:29 +08:00
type:'basicText',
2020-07-02 10:10:16 +08:00
title: '故障设备',
2020-06-30 19:17:29 +08:00
columnValue: (row) => {
return `${this.deviceMap[row.targetDeviceType]}${this.formatNameByCode(row.targetDeviceCode)}`;
}
},
{
type:'basicText',
title:'故障类型',
columnValue: (row) => {
2020-07-01 09:32:01 +08:00
return this.covertFaultType(row);
2020-06-30 19:17:29 +08:00
}
},
{
type: 'button',
title: '操 作',
2020-07-03 17:13:24 +08:00
width: '150',
2020-06-30 19:17:29 +08:00
buttons: [
2020-07-03 17:13:24 +08:00
{
name: '设置',
handleClick: this.settingFailure,
type: 'primary'
},
2020-06-30 19:17:29 +08:00
{
name: '删除',
handleClick: this.deleteFailure,
2020-07-03 17:13:24 +08:00
type: 'danger'
2020-06-30 19:17:29 +08:00
}
]
2019-12-30 09:00:16 +08:00
}
2020-06-30 14:41:22 +08:00
],
actions: [
{ text: this.$t('global.add'), handler: this.handleAdd }
2019-12-30 09:00:16 +08:00
]
}
};
},
computed: {
title() {
2020-07-03 17:13:24 +08:00
return '自动故障设置';
2019-12-30 09:00:16 +08:00
},
lineCode() {
return this.$route.query.lineCode;
}
},
2020-06-30 14:41:22 +08:00
watch:{
// $store.state.config.menuBarLoadedCount
'offset': function (val) {
this.dragEvent();
2020-07-03 17:13:24 +08:00
},
'$store.state.socket.autoFaultTrigger':function(val) {
this.getSimulationFaultRules();
2020-06-30 14:41:22 +08:00
}
},
2019-12-30 09:00:16 +08:00
mounted() {
2020-06-30 19:17:29 +08:00
this.deviceMap = [];
ConstConfig.ConstSelect.simulationDeviceList.forEach(elem => {
this.deviceMap[elem.value] = elem.label;
2019-12-30 09:00:16 +08:00
});
},
methods: {
formatNameByCode(code) {
let name = '';
const device = this.$store.getters['map/getDeviceByCode'](code);
if (device) {
switch (device._type) {
case ModelType.Signal:
case ModelType.Switch:
case ModelType.Station:
case ModelType.Section: {
2020-07-01 09:32:01 +08:00
if (device.parentName) {
name += device.parentName + '-' + device.name;
} else {
name += device.name;
}
2019-12-30 09:00:16 +08:00
break;
}
}
if (device.stationCode) {
const station = this.$store.getters['map/getDeviceByCode'](device.stationCode);
if (station) {
name += '【' + station.name + '】';
}
}
}
return name;
},
2020-07-03 17:13:24 +08:00
getTriangleInfo(row) {
if (row && row.id) {
return `${this.deviceMap[row.condition.triggerDeviceType]}${this.formatNameByCode(row.condition.triggerDeviceCode)} 状态:${FaultStatusEnum[row.condition.triggerDeviceType][row.condition.triggerDeviceStatus]}`;
} else {
return '';
}
},
2020-06-30 19:17:29 +08:00
covertType(type) {
switch (type) {
case 'SECTION':return 'Section';
case 'SIGNAL':return 'Signal';
case 'SWITCH':return 'Switch';
case 'STATION':return 'Station';
2020-07-08 09:21:54 +08:00
case 'ZC':return 'ZcControl';
2020-06-30 19:17:29 +08:00
case 'STAND':return 'StationStand';
case 'TRAIN':return 'Train';
}
},
2020-07-01 09:32:01 +08:00
covertFaultType(row) {
let faultType = '';
2020-07-03 17:13:24 +08:00
if (row && row.id) {
2020-07-08 09:21:54 +08:00
const type = this.covertType(row.targetDeviceType);
const currentList = deviceFaultType[type];
2020-07-03 17:13:24 +08:00
currentList.forEach(temp=>{
if (temp.value === row.faultType) {
faultType = temp.label;
}
});
}
2020-07-01 09:32:01 +08:00
return faultType;
},
2020-06-30 14:41:22 +08:00
closeFaultChoose() {
this.dialogShow = false;
this.isAdd = false;
if (this.$refs.addFault) {
this.$refs.addFault.resetForm();
}
2020-06-30 14:41:22 +08:00
},
2020-06-30 19:17:29 +08:00
closeAddRules() {
this.isAdd = false;
},
getFailureRulesNew(params) {
params['lineCode'] = this.$route.query.lineCode;
return getFailureRulesNew(params);
2020-06-30 14:41:22 +08:00
},
2020-07-03 17:13:24 +08:00
getSimulationFaultRules() {
getSimulationFaultRules(this.group).then(res=>{
2020-07-03 18:39:24 +08:00
this.simulationFault = {};
2020-07-03 17:13:24 +08:00
if (res.data) {
this.simulationFault = res.data;
}
2020-07-03 18:39:24 +08:00
}).catch(error=>{
this.$messageBox('获取待触发故障失败:' + error.message);
2020-07-03 17:13:24 +08:00
});
},
2019-12-30 09:00:16 +08:00
doShow() {
this.dialogShow = true;
2020-07-03 17:13:24 +08:00
this.reloadTable();
this.getSimulationFaultRules();
2020-06-30 19:17:29 +08:00
// this.queryList.data = [];
// getFailureGenerateRules({ skin: this.lineCode, group: this.group }).then(response => {
// const data = response.data;
// data.forEach(elem => {
// this.queryList.data.push({
// id: elem.id,
// condition: `${this.deviceMap[elem.condition.triggerDeviceType]}${this.formatNameByCode(elem.condition.triggerDeviceCode)} 状态:${FaultStatusEnum[elem.condition.triggerDeviceType][elem.condition.triggerDeviceStatus]}`,
// target: `${this.deviceMap[elem.targetDeviceType]}${this.formatNameByCode(elem.targetDeviceCode)}`
// });
// });
// });
2020-06-30 14:41:22 +08:00
},
2019-12-30 09:00:16 +08:00
doClose() {
this.dialogShow = false;
},
2020-06-30 14:41:22 +08:00
handleAdd() {
this.isAdd = true;
},
2020-06-30 19:17:29 +08:00
deleteFailure(index, row) {
2020-07-02 10:10:16 +08:00
event.cancelBubble = true;
2020-06-30 19:17:29 +08:00
this.$confirm('删除故障规则,是否继续?', '提 示', {
confirmButtonText: '确 定',
cancelButtonText: '取 消',
type: 'warning'
}).then(() => {
deleteFailureRule(row.id).then(resp => {
this.reloadTable();
}).catch(error => {
this.$message.error(`删除故障规则失败: ${error.message}`);
});
}).catch( () => { });
},
2020-07-03 17:13:24 +08:00
settingFailure(index, row, idx) {
const faultModel = {ruleId: row.id, auto:true};
// row['loading' + idx] = true;
setFailureModeNew(faultModel, this.group).then(() => {
this.getSimulationFaultRules();
2020-07-03 18:39:24 +08:00
this.$message.success('设置自动故障成功');
2020-07-03 17:13:24 +08:00
}).catch(() => {
2020-07-03 18:39:24 +08:00
this.$messageBox('设置自动故障失败');
2019-12-30 09:00:16 +08:00
});
},
reloadTable() {
this.queryList.reload();
2020-06-30 14:41:22 +08:00
},
2020-07-03 18:39:24 +08:00
cancleAutoFault() {
const faultModel = {auto:false};
setFailureModeNew(faultModel, this.group).then(() => {
this.getSimulationFaultRules();
this.$message.success('取消自动故障成功');
}).catch(() => {
this.$messageBox('取消自动故障失败');
});
},
2020-06-30 14:41:22 +08:00
dragEvent() {
const offset = this.offset;
const dialogHeaderEl = document.querySelector('.falutChooseTitle');
const dragDom = document.querySelector('#faultChoose');
dialogHeaderEl.style.cursor = 'move';
/** 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);*/
const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null);
dialogHeaderEl.onmousedown = (e) => {
/** 鼠标按下,计算当前元素距离可视区的距离*/
const disX = e.clientX - dialogHeaderEl.offsetLeft;
const disY = e.clientY - dialogHeaderEl.offsetTop;
/** 获取到的值带px 正则匹配替换*/
let styL, styT;
/** 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px*/
if (sty.left.includes('%')) {
// eslint-disable-next-line no-useless-escape
styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100);
styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100);
} else {
// eslint-disable-next-line no-useless-escape
styL = +sty.left.replace(/\px/g, '');
// eslint-disable-next-line no-useless-escape
styT = +sty.top.replace(/\px/g, '');
}
document.onmousemove = function (e) {
/** 通过事件委托,计算移动的距离*/
const l = e.clientX - disX;
const t = e.clientY - disY;
/** 移动当前元素*/
// dragDom.style.left = `${l + styL}px`;
// dragDom.style.top = `${t + styT}px`;
/** 移动当前元素*/
if (l + styL < 0) {
dragDom.style.left = `0px`;
} else if (l + styL > document.body.clientWidth - dragDom.clientWidth - 10) {
dragDom.style.left = `${document.body.clientWidth - dragDom.clientWidth - 10}px`;
} else {
dragDom.style.left = `${l + styL}px`;
}
if (t + styT <= offset) {
dragDom.style.top = offset + `px`;
} else if (t + styT > document.body.clientHeight - dragDom.clientHeight - 10) {
dragDom.style.top = `${document.body.clientHeight - dragDom.clientHeight - 10}px`;
} else {
dragDom.style.top = `${t + styT}px`;
}
/** 将此时的位置传出去*/
// binding.value({ x: e.pageX, y: e.pageY });
};
document.onmouseup = function () {
document.onmousemove = null;
document.onmouseup = null;
};
};
2019-12-30 09:00:16 +08:00
}
}
};
</script>
2020-07-03 17:13:24 +08:00
<style lang="scss">
#faultChoose .card .queryList .el-card .el-card__body .el-table--border .el-table__body-wrapper{
height: 135px !important;
overflow-y: auto !important;
}
#faultChoose .el-button--mini {
margin-left: 5px;
}
2020-07-03 18:39:24 +08:00
.triggerFaultListLeft{
display: inline-block;
float: left;
width: 730px;
}
2020-07-03 17:13:24 +08:00
// 谷歌、safari、qq浏览器、360浏览器滚动条样式
// 定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸
#faultChoose .el-table__body-wrapper::-webkit-scrollbar {
width: 6px;
height: 6px;
// height: 110px;
background-color: #FFFFFF;
}
/*定义滚动条轨道 内阴影+圆角*/
#faultChoose .el-table__body-wrapper::-webkit-scrollbar-track {
// box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
background-color: #FFFFFF;;
}
/*定义滑块 内阴影+圆角*/
#faultChoose .el-table__body-wrapper::-webkit-scrollbar-thumb {
border-radius: 10px;
// box-shadow: inset 0 0 6px rgba(0,0,0,.3);
background-color: #eaeaea;
}
/*滑块效果*/
#faultChoose .el-table__body-wrapper::-webkit-scrollbar-thumb:hover {
border-radius: 5px;
// box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
background: rgba(0,0,0,0.4);
}
/*IE滚动条颜色*/
html {
scrollbar-face-color:#bfbfbf;/*滚动条颜色*/
scrollbar-highlight-color:#000;
scrollbar-3dlight-color:#000;
scrollbar-darkshadow-color:#000;
scrollbar-Shadow-color:#adadad;/*滑块边色*/
scrollbar-arrow-color:rgba(0,0,0,0.4);/*箭头颜色*/
scrollbar-track-color:#eeeeee;/*背景颜色*/
}
</style>
2019-12-30 09:00:16 +08:00
<style scoped rel="stylesheet/scss" lang="scss">
2020-07-03 17:13:24 +08:00
.triggerFaultInfo{
margin-bottom:10px;
padding: 10px 0px 10px 15px;
}
.triggerFaultList{
font-size: 14px;
margin-top: 10px;
line-height: 20px;
}
.triggerFaultTitle{
font-size: 15px;
font-weight: bold;
2019-12-30 09:00:16 +08:00
}
2020-06-30 14:41:22 +08:00
.falutChooseTitle{
padding: 15px;
cursor: all-scroll;
}
#faultChoose{
width: 900px;
position: absolute;
left: 30%;
top: 20%;
background: #fff;
padding:0px 0px 15px 0px;
// transform: translate3d(-50%,-50%,0);
border-radius: 6px;
z-index:999;
}
.faultChooseFoot{
display: inline-block;
float: right;
margin-right: 20px;
margin-top: 20px;
}
.closeFalutChoose{
position: absolute;
right: 0px;
top: 0px;
width: 35px;
height: 35px;
cursor: pointer;
}
.closeFalutChooseIn{
font-size: 20px;
margin-left: 5px;
margin-top: 10px;
}
2019-12-30 09:00:16 +08:00
</style>