增加应答器 创建时必须选择信号机以及校验

This commit is contained in:
lVAL 2021-01-15 17:23:27 +08:00
parent 89dacd7deb
commit 0ee148437b
6 changed files with 71 additions and 38 deletions

View File

@ -2,9 +2,9 @@ export function getBaseUrl() {
let BASE_API;
if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://api.joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.8.107:9000'; // 袁琪
// BASE_API = 'http://192.168.8.129:9000'; // 旭强
BASE_API = 'http://192.168.8.129:9000'; // 旭强
// BASE_API = 'http://192.168.8.119:9000'; // 张赛
// BASE_API = 'http://192.168.8.140:9000'; // 杜康
// BASE_API = 'http://b29z135112.zicp.vip';

View File

@ -125,7 +125,18 @@ export default {
this.$emit('deviceSelect', '');
} else {
this.$message.error('请选择物理区段');
}
}
} else if (selected && selected._type.toUpperCase() === 'Signal'.toUpperCase() && this.field.toUpperCase() === 'RelModelSignalCode'.toUpperCase()) {
this.$refs.respModel.setModelProp(selected, 'signalCode');
this.activeName = 'first';
this.field = '';
this.$emit('deviceSelect', '');
} else if (selected && selected._type.toUpperCase() === 'Signal'.toUpperCase() && this.field.toUpperCase() === 'RelSignalCode'.toUpperCase()) {
this.$refs.respCreate.setModelProp(selected, 'signalCode');
this.activeName = 'second';
this.field = '';
this.$emit('deviceSelect', '');
} else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'RelSectionCode'.toUpperCase()) {
if (['01', '03'].includes(selected.type)) {
this.$refs.respCreate.setModelProp(selected, 'sectionCode');
@ -135,14 +146,13 @@ export default {
} else {
this.$message.error('请选择物理区段');
}
} else if (selected && selected._type.toUpperCase() === 'Signal'.toUpperCase() && this.field.toUpperCase() === 'RelModelSignalCode'.toUpperCase()) {
this.$refs.respModel.setModelProp(selected, 'signalCode');
this.activeName = 'first';
} else if (selected && selected._type.toUpperCase() === 'Signal'.toUpperCase() && this.field.toUpperCase() === 'RelBatchSignalCode'.toUpperCase()) {
this.$refs.respBatch.setModelProp(selected, 'signalCode');
this.activeName = 'third';
this.field = '';
this.$emit('deviceSelect', '');
} else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'RelBatchSectionCode'.toUpperCase()) {
} else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'RelBatchSectionCode'.toUpperCase()) {
if (['01', '03'].includes(selected.type)) {
this.$refs.respBatch.setModelProp(selected, 'code');
this.$refs.respBatch.setModelProp(selected, 'sectionCode');
this.activeName = 'third';
this.field = '';
this.$emit('deviceSelect', '');

View File

@ -1,9 +1,9 @@
<template>
<el-form ref="make" label-width="140px" :model="addModel" size="mini" :rules="mergeRules">
<el-table :data="addModel.modelList" style="width: 100%">
<el-table-column label="区段" prop="code" width="200">
<el-table-column label="区段" prop="sectionCode">
<template slot-scope="scope">
<el-select v-model="scope.row.code" filterable size="mini" style="width:120px;" placeholder="请选择">
<el-select v-model="scope.row.sectionCode" filterable size="mini" style="width:120px;" placeholder="请选择">
<el-option
v-for="item in sectionList"
:key="item.code"
@ -11,7 +11,20 @@
:value="item.code"
/>
</el-select>
<el-button size="mini" :type="field === 'RelBatchSectionCode'&&rowData === scope.row?'danger':'primary'" @click="handleHover(scope.row)">激活</el-button>
<el-button size="mini" :type="field === 'RelBatchSectionCode'&&rowData === scope.row?'danger':'primary'" @click="handleHover(scope.row, 'RelBatchSectionCode')">激活</el-button>
</template>
</el-table-column>
<el-table-column label="信号机" prop="signalCode">
<template slot-scope="scope">
<el-select v-model="scope.row.signalCode" filterable size="mini" style="width:120px;" placeholder="请选择">
<el-option
v-for="item in signalList"
:key="item.code"
:label="item.name + '(' + item.code +')'"
:value="item.code"
/>
</el-select>
<el-button size="mini" :type="field === 'RelBatchSignalCode'&&rowData === scope.row?'danger':'primary'" @click="handleHover(scope.row, 'RelBatchSignalCode')">激活</el-button>
</template>
</el-table-column>
<el-table-column label="类型">
@ -74,7 +87,11 @@ export default {
sectionList: {
type: Array,
required: true
},
},
signalList: {
type: Array,
required: true
},
responderList: {
type: Array,
required: true
@ -99,26 +116,21 @@ export default {
handleDelete(index, row) {
this.addModel.modelList.splice(index, 1);
},
handleHover(row) {
if (this.field !== 'RelBatchSectionCode') {
this.$emit('hover', 'RelBatchSectionCode');
this.rowData = row;
} else if (this.rowData !== row) {
this.rowData = row;
} else {
this.$emit('hover', '');
}
handleHover(row, prop) {
this.rowData = row;
this.$emit('hover', prop);
},
handlePush(row) {
this.addModel.modelList.push({
code: '',
sectionCode: '',
signalCode: '',
type: '',
name: ''
});
},
doBatchCreate() {
const models = this.addModel.modelList.map(el => {
const section = this.$store.getters['map/getDeviceByCode'](el.code);
const section = this.$store.getters['map/getDeviceByCode'](el.sectionCode);
return utils.buildModelBySection(section, el, this.responderList);
});
this.$emit('updateMapModel', models);

View File

@ -34,7 +34,11 @@ export default {
sectionList: {
type: Array,
required: true
},
},
signalList: {
type: Array,
required: true
},
responderList: {
type: Array,
required: true
@ -45,7 +49,8 @@ export default {
addModel: {
type: '',
name: '',
sectionCode: ''
sectionCode: '',
signalCode: ''
},
rules: {
name: [
@ -56,14 +61,20 @@ export default {
],
sectionCode: [
{ required: true, message: '请关联物理区段', trigger: 'blur' }
]
],
signalCode: [
{ required: true, message: '请关联信号机', trigger: 'blur' }
]
}
};
},
computed: {
isButtonType() {
isSectionButtonType() {
return this.field == 'RelSectionCode';
},
},
isSignalButtonType() {
return this.field == 'RelSignalCode';
},
createForm() {
const form = {
labelWidth: '110px',
@ -73,7 +84,8 @@ export default {
item: [
{ prop: 'name', label: '应答器名称', type: 'input' },
{ prop: 'type', label: `应答器类型`, type: 'select', optionLabel: 'name', optionValue: 'value', options: this.responderTypeList },
{ prop: 'sectionCode', label: '关联区段', type: 'selectHover', optionLabel: 'code', optionValue: 'code', options: this.sectionList, buttonType: 'RelSectionCode', hover: this.hover, buttonShowType: this.isButtonType }
{ prop: 'sectionCode', label: '关联区段', type: 'selectHover', optionLabel: 'code', optionValue: 'code', options: this.sectionList, buttonType: 'RelSectionCode', hover: this.hover, buttonShowType: this.isSectionButtonType },
{ prop: 'signalCode', label: '关联信号机', type: 'selectHover', optionLabel: 'code', optionValue: 'code', options: this.signalList, buttonType: 'RelSignalCode', hover: this.hover, buttonShowType: this.isSignalButtonType },
]
}
}

View File

@ -93,7 +93,10 @@ export default {
],
sectionCode: [
{ required: true, message: '请关联物理区段', trigger: 'blur' }
],
],
signalCode: [
{ required: true, message: '请关联信号机', trigger: 'blur' }
],
'position.x': [
{ required: true, message: '请输入应答器坐标x', trigger: 'blur' }
],
@ -143,9 +146,7 @@ export default {
{ prop:'textRotate', label: '文字旋转', type: 'number' },
{ prop: 'sectionCode', label: '关联区段', type: 'selectHover', optionLabel: 'code', optionValue: 'code', options: this.sectionList, buttonType: 'RelModelSectionCode', hover: this.hover, buttonShowType: this.isSectionButtonType },
{ prop: 'signalCode', label: '关联信号机', type: 'selectHover', optionLabel: 'code', optionValue: 'code', options: this.signalList, buttonType: 'RelModelSignalCode', hover: this.hover, buttonShowType: this.isSignalButtonType },
// { prop: 'sectionCode', label: '', type: 'select', optionLabel: 'code', optionValue: 'code', options: this.sectionList},
// { prop: 'signalCode', label: '', type: 'select', optionLabel: 'code', optionValue: 'code', options: this.signalList},
{ prop: 'stationCode', label: '关联集中站' + ':', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.centralizedStationList }
{ prop: 'stationCode', label: '关联集中站' + ':', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.centralizedStationList }
]
},
map: {

View File

@ -12,8 +12,6 @@ export function buildModelBySection(section, model, list) {
return {
_type: 'Responder',
code: getUID('Responder', list),
type: model.type,
name: model.name,
rotate: rotate + 90,
textRotate: rotate + 90,
position: {
@ -24,8 +22,8 @@ export function buildModelBySection(section, model, list) {
x: 0,
y: 0
},
sectionCode: section.code,
stationCode: section.stationCode
stationCode: section.stationCode,
...model
};
}
}