This commit is contained in:
ival 2019-11-19 18:35:49 +08:00
commit 898135a61b
12 changed files with 386 additions and 194 deletions

View File

@ -24,7 +24,9 @@ import Commands from '@/scripts/plugin/Commands';
import { mapGetters } from 'vuex';
import { OperateMode } from '@/scripts/ConstDic';
import { MapDeviceType, OperationEvent, DeviceMenu } from '@/scripts/ConstDic';
//
import { MenuDisabledState, menuConvert, menuFiltration } from './utils/menuItemStatus';
// import MenuContextHandler from '@/scripts/plugin/MenuContextHandler';
export default {
name: 'SignalMenu',
@ -222,6 +224,7 @@ export default {
},
initMenu() {
//
// this.menu = MenuContextHandler.menuFiltration(this.menuNormal);
this.menu = menuFiltration(this.menuNormal);
if (this.operatemode === OperateMode.ADMIN) {
this.menu = [...this.menu, ...this.menuForce];
@ -232,6 +235,8 @@ export default {
this.menu = this.menuForce;
}
// debugger;
// this.menu = MenuContextHandler.covert(this.menu);
this.menu = menuConvert(this.menu);
},

View File

@ -876,4 +876,10 @@ router.beforeEach((to, from, next) => {
next();
});
// 兼容 vue-router在3.1.0版本以上的路由跳转使用的是 promise 的方式
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err);
};
export default router;

View File

@ -54,6 +54,10 @@ class CommandHandle {
return null;
}
checkDisabled(menu, selected) {
}
execute(command) {
return new Promise((resolve, reject) => {
const group = router.currentRoute.query.group;

View File

@ -0,0 +1,62 @@
import store from '@/store';
class MenuContextHandler {
constructor() {
this.operates = []; // 操作数据
this.command = {}; // 命令对象
}
getCurrentStateObject() {
return store.getters['menuOperation/selected'];
}
menuFiltration(menuList) {
const SystemType = {
'01': 'local', // 现地工作站
'02': 'central' // 中心调度工作站
};
const StationControlType = {
'01': 'center', // 中控
'02': 'station', // 站控
'03': 'station'
};
var selected = this.getCurrentStateObject();
let control;
var menu = [];
if (selected._type == 'StationStand') {
control = store.getters['map/getStationControlByStationCode'](selected.deviceStationCode);
} else if (selected._type == 'Station') {
control = store.getters['map/getStationControlByStationCode'](selected.code);
} else {
control = store.getters['map/getStationControlByStationCode'](selected.stationCode);
}
if (control) {
if (store.state.training.prdType != '') {
const type = SystemType[store.state.training.prdType];
const status = StationControlType[control.status];
menu = [...menuList[type]];
if (menu.constructor === Array) {
menu.forEach(elem => {
if (elem.type === 'separator') {
elem.show = true;
return;
}
if (elem.auth.constructor === Object) {
elem.show = true;
if (!elem.auth['station'] && !elem.auth['center']) { // 控制不显示
elem.show = false;
}
elem.defaultDisabled = !elem.auth[status];
}
});
}
}
}
return menu;
}
}
export default new MenuContextHandler();

View File

@ -37,12 +37,6 @@
@switchMode="switchMode"
@selectQuest="selectQuest"
/>
<!--@runPlanViewShow="runPlanViewShow"
@faultChooseShow="faultChooseShow"
@runPlanLoadShow="runPlanLoadShow"
@runAddRolesLoadShow="runAddRolesLoadShow"
@runQuestLoadShow="runQuestLoadShow"
-->
<menu-system-time ref="menuSystemTime" :offset="offset" :right="right" :group="group" />
</div>

View File

@ -13,20 +13,6 @@
<el-button type="text" class="mapEdit_box" @click="showMap">{{ $t('map.viewLayer') }}</el-button>
</div>
<el-tabs v-model="enabledTab" type="card" class="map_card" @tab-click="changePane">
<el-tab-pane label="站台屏蔽门" class="tab_pane_box" name="safetyDoor">
<safety-door-operate
ref="routeOperate"
:map-info="mapInfo"
:selected="selected"
/>
</el-tab-pane>
<el-tab-pane label="站台紧急停车按钮" class="tab_pane_box" name="park">
<park-operate
ref="routeOperate"
:map-info="mapInfo"
:selected="selected"
/>
</el-tab-pane>
<el-tab-pane :label="$t('map.routeID')" class="tab_pane_box" name="route">
<route-operate
ref="routeOperate"
@ -67,6 +53,20 @@
@setCenter="setCenter"
/>
</el-tab-pane>
<el-tab-pane label="站台屏蔽门" class="tab_pane_box" name="safetyDoor">
<safety-door-operate
ref="routeOperate"
:map-info="mapInfo"
:selected="selected"
/>
</el-tab-pane>
<el-tab-pane label="站台紧急停车按钮" class="tab_pane_box" name="park">
<park-operate
ref="routeOperate"
:map-info="mapInfo"
:selected="selected"
/>
</el-tab-pane>
</el-tabs>
</div>
</div>

View File

@ -1,13 +1,56 @@
<template>
<div style="height: 100%;">
22222
<div style="height: calc(100% - 46px);">
<template v-if="!display">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="form" :model="editModel" label-width="120px" size="mini">
<el-form-item label="code" prop="code">
<el-select v-model="editModel.code" clearable :filterable="true" @change="deviceChange">
<el-option
v-for="item in parkStandList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item label="名称" prop="name">
<el-input v-model="editModel.name" />
</el-form-item>
<el-form-item label="所属站台" prop="stationStandCode">
<el-select v-model="editModel.stationStandCode" disabled>
<el-option
v-for="item in stationStandList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
</el-form>
</el-scrollbar>
</template>
<template v-if="display">
<div style="text-align: center;padding-top: 20px;">暂无数据</div>
</template>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button type="primary" size="small" @click="create">批量创建</el-button>
<el-button type="danger" size="small" @click="editObject">修改</el-button>
</el-button-group>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { deepAssign } from '@/utils/index';
import { getUID } from '@/jmap/utils/Uid';
export default {
name: 'ParkOperate',
name: 'SafetyDoorOperate',
components: {
},
props: {
mapInfo: {
@ -25,10 +68,87 @@ export default {
},
data() {
return {
display: true,
editModel: {
code: '',
name: '',
stationCode: '',
stationStandCode: ''
}
};
},
computed: {
...mapGetters('map', [
'map',
'parkStandList',
'stationStandList'
])
},
watch: {
'$store.state.map.map': function(val) {
if (val) {
this.init();
}
}
},
mounted () {
this.init();
},
methods: {
init() {
this.display = true;
const mapObject = this.map;
if (mapObject) {
if (mapObject.parkStandList && mapObject.parkStandList.length) {
this.display = false;
} else {
mapObject.parkStandList = [];
}
}
},
deviceChange(code) {
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
this.$refs.form && this.$refs.form.resetFields();
if (selected && selected._type.toUpperCase() === 'ESP'.toUpperCase()) {
this.editModel = deepAssign(this.editModel, selected);
}
},
editObject() {
console.log(this.editModel, 111);
},
hasPSD(data) {
let falg = false;
this.map.parkStandList.forEach(item => {
if (item.stationStandCode == data.code) {
falg = true;
}
});
return falg;
},
create() {
const arr = [];
this.map.stationStandList.forEach(item => {
if (item.visible && item.hasDoor && !this.hasPSD(item)) {
arr.push({
_type: 'ESP',
code: getUID('ESP'),
name: getUID('ESP'),
stationCode: item.stationCode,
stationStandCode: item.code
});
}
});
if (arr.length) {
this.display = false;
this.$message('创建完成');
this.$store.dispatch('map/updateMapStandData', {models: arr, type: 'parkStandList'});
this.deviceSelect();
} else {
this.$message('暂无车站');
}
}
}
};
</script>

View File

@ -3,8 +3,8 @@
<div style="height: calc(100% - 46px);">
<template v-if="!display">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="form" :model="editModel" label-width="120px" size="mini">
<el-form-item label="屏蔽门code" prop="code">
<el-form ref="ruleForm" :model="editModel" label-width="120px" size="mini">
<el-form-item label="code" prop="code">
<el-select v-model="editModel.code" clearable :filterable="true" @change="deviceChange">
<el-option
v-for="item in safetyDoorList"
@ -14,7 +14,7 @@
/>
</el-select>
</el-form-item>
<el-form-item label="名" prop="name">
<el-form-item label="名" prop="name">
<el-input v-model="editModel.name" />
</el-form-item>
<el-form-item label="所属站台" prop="stationStandCode">
@ -110,7 +110,7 @@ export default {
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
this.$refs.form.resetFields();
this.$refs.ruleForm && this.$refs.ruleForm.resetFields();
if (selected && selected._type.toUpperCase() === 'PSD'.toUpperCase()) { // ESP
this.editModel = deepAssign(this.editModel, selected);
}
@ -144,6 +144,7 @@ export default {
this.display = false;
this.$message('创建完成');
this.$store.dispatch('map/updateMapStandData', {models: arr, type: 'safetyDoorList'});
this.deviceSelect();
} else {
this.$message('暂无车站');
}

View File

@ -162,84 +162,84 @@
<script>
import ElFont from '@/views/components/font/index';
export default {
name: 'ConfigList',
components: {
ElFont
},
props: {
formModel: {
type: Object,
required: true
},
form: {
type: Object,
required: true
},
rules: {
type: Object,
default: function () {
return null;
}
}
},
data () {
return {
skins: []
};
},
methods: {
handleLabel(option, label) {
if (label == 'name') {
return option.name;
} else if (label == 'code') {
return option.code;
} else if (label == 'label') {
return option.label;
} else if (label == 'name&&code') {
if (option.code) {
return option.name + ' (' + option.code+ ')';
} else {
return option.name;
}
} else if (label == 'code&&name') {
return option.code + ' (' + option.name+ ')';
} else {
return option.label;
}
},
decompose(item, prop) {
if (!prop.includes('.')) {
return prop;
}
const keyArr = prop.split('.');
return keyArr[0][keyArr[1]];
},
checkFieldType(field, type) {
if (field.hasOwnProperty('show')) {
return field.type === type && field.show;
} else {
return field.type === type;
}
},
validate(callback) {
this.$refs.form.validate((valid) => {
if (valid) {
callback(true);
} else {
callback(false);
}
});
},
resetForm() {
this.$refs.form.resetFields();
},
clearValidate() {
this.$refs.form.clearValidate();
},
resetFields() {
this.$refs.form.resetFields();
}
}
name: 'ConfigList',
components: {
ElFont
},
props: {
formModel: {
type: Object,
required: true
},
form: {
type: Object,
required: true
},
rules: {
type: Object,
default: function () {
return null;
}
}
},
data () {
return {
skins: []
};
},
methods: {
handleLabel(option, label) {
if (label == 'name') {
return option.name;
} else if (label == 'code') {
return option.code;
} else if (label == 'label') {
return option.label;
} else if (label == 'name&&code') {
if (option.code) {
return option.name + ' (' + option.code + ')';
} else {
return option.name;
}
} else if (label == 'code&&name') {
return option.code + ' (' + option.name + ')';
} else {
return option.label;
}
},
decompose(item, prop) {
if (!prop.includes('.')) {
return prop;
}
const keyArr = prop.split('.');
return keyArr[0][keyArr[1]];
},
checkFieldType(field, type) {
if (field.hasOwnProperty('show')) {
return field.type === type && field.show;
} else {
return field.type === type;
}
},
validate(callback) {
this.$refs.form.validate((valid) => {
if (valid) {
callback(true);
} else {
callback(false);
}
});
},
resetForm() {
this.$refs.form.resetFields();
},
clearValidate() {
this.$refs.form.clearValidate();
},
resetFields() {
this.$refs.form.resetFields();
}
}
};
</script>

View File

@ -68,7 +68,7 @@
<template v-if="checkFieldType(item, 'number')">
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<div v-if="!item.firstLevel">
<el-input-number v-model="formModel[item.prop]" :min="item.min" :max="item.max" :label="item.label" :disabled="item.disabled" />
<el-input-number v-model="formModel[item.prop]" :min="item.min" :max="item.max" :label="item.label" :disabled="item.disabled" style="width: 140px" />
<span style="padding-left: 1px;">{{ item.placeholder }}</span>
</div>
<div v-else>
@ -177,84 +177,84 @@
<script>
import ElFont from '@/views/components/font/index';
export default {
name: 'ConfigList',
components: {
ElFont
},
props: {
formModel: {
type: Object,
required: true
},
form: {
type: Object,
required: true
},
rules: {
type: Object,
default: function () {
return null;
}
}
},
data () {
return {
skins: []
};
},
methods: {
handleLabel(option, label) {
if (label == 'name') {
return option.name;
} else if (label == 'code') {
return option.code;
} else if (label == 'label') {
return option.label;
} else if (label == 'name&&code') {
if (option.code) {
return option.name + ' (' + option.code+ ')';
} else {
return option.name;
}
} else if (label == 'code&&name') {
return option.code + ' (' + option.name+ ')';
} else {
return option.label;
}
},
decompose(item, prop) {
if (!prop.includes('.')) {
return prop;
}
const keyArr = prop.split('.');
return keyArr[0][keyArr[1]];
},
checkFieldType(field, type) {
if (field.hasOwnProperty('show')) {
return field.type === type && field.show;
} else {
return field.type === type;
}
},
validate(callback) {
this.$refs.form.validate((valid) => {
if (valid) {
callback(true);
} else {
callback(false);
}
});
},
resetForm() {
this.$refs.form.resetFields();
},
clearValidate() {
this.$refs.form.clearValidate(); //
},
resetFields() {
this.$refs.form.resetFields(); //
}
}
name: 'ConfigList',
components: {
ElFont
},
props: {
formModel: {
type: Object,
required: true
},
form: {
type: Object,
required: true
},
rules: {
type: Object,
default: function () {
return null;
}
}
},
data () {
return {
skins: []
};
},
methods: {
handleLabel(option, label) {
if (label == 'name') {
return option.name;
} else if (label == 'code') {
return option.code;
} else if (label == 'label') {
return option.label;
} else if (label == 'name&&code') {
if (option.code) {
return option.name + ' (' + option.code + ')';
} else {
return option.name;
}
} else if (label == 'code&&name') {
return option.code + ' (' + option.name + ')';
} else {
return option.label;
}
},
decompose(item, prop) {
if (!prop.includes('.')) {
return prop;
}
const keyArr = prop.split('.');
return keyArr[0][keyArr[1]];
},
checkFieldType(field, type) {
if (field.hasOwnProperty('show')) {
return field.type === type && field.show;
} else {
return field.type === type;
}
},
validate(callback) {
this.$refs.form.validate((valid) => {
if (valid) {
callback(true);
} else {
callback(false);
}
});
},
resetForm() {
this.$refs.form.resetFields();
},
clearValidate() {
this.$refs.form.clearValidate(); //
},
resetFields() {
this.$refs.form.resetFields(); //
}
}
};
</script>

View File

@ -71,7 +71,7 @@ export default {
formModel: {
id: '',
simulationRole: '',
controlMode: '',
controlMode: [],
lineCode: '',
operateObject: '',
operate: '',
@ -87,7 +87,7 @@ export default {
items: [
{ prop: 'lineCode', label: this.$t('system.lineCode'), type: 'select', options: this.taskStatusList },
{ prop: 'simulationRole', label: this.$t('system.simulationRole'), type: 'select', options: this.$ConstSelect.simulationRole },
{ prop: 'controlMode', label: this.$t('system.controlMode'), type: 'select', options: this.$ConstSelect.controlMode },
{ prop: 'controlMode', label: this.$t('system.controlMode'), type: 'select', options: this.$ConstSelect.controlMode, multiple: true },
{ prop: 'operateObject', label: this.$t('system.deviceType'), type: 'select', options: this.$ConstSelect.deviceTypeList, change: true, onChange: this.deviceChange },
{ prop: 'operate', label: this.$t('system.instructionType'), type: 'select', options: this.operateList }
]

View File

@ -56,13 +56,6 @@ export default {
columnValue: (row) => { return this.$convertField(row.lineCode, this.taskStatusList, ['code', 'name']); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('system.controlMode'), //
prop: 'controlMode',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.controlMode, this.$ConstSelect.controlMode, ['value', 'label']); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('system.simulationRole'), // 仿
prop: 'simulationRole',
@ -70,6 +63,13 @@ export default {
columnValue: (row) => { return this.$convertField(row.simulationRole, this.$ConstSelect.simulationRole, ['value', 'label']); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('system.controlMode'), //
prop: 'controlMode',
type: 'tagMore',
columnValue: (row) => { return this.$convertField(row.controlMode, this.$ConstSelect.controlMode, ['value', 'label'], true); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('system.deviceType'), //
prop: 'operateObject',
@ -149,7 +149,7 @@ export default {
return getCommandList(params);
},
convertField(fieldValue, operateObject, converFormat) {
if (Commands) {
if (Commands && Commands[operateObject]) {
const enumList = Object.values(Commands[operateObject]);
if (enumList && converFormat && converFormat.length >= 2) {
const value = converFormat[0];