调整列车创建

This commit is contained in:
zyy 2019-12-17 15:37:11 +08:00
parent fce5242e06
commit b05d71667e
3 changed files with 30 additions and 40 deletions

View File

@ -45,6 +45,7 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
import { getUID } from '@/jmapNew/utils/Uid'; import { getUID } from '@/jmapNew/utils/Uid';
export default { export default {
@ -70,6 +71,9 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters('map', [
'trainList'
]),
rules() { rules() {
return { return {
range: [ range: [

View File

@ -102,7 +102,7 @@ export default {
} }
}, },
create(list) { create(list) {
this.$emit('addOrUpdateMapModel', list); this.$emit('updateMapModel', list);
}, },
// //
edit(elem) { edit(elem) {

View File

@ -118,8 +118,8 @@ export default {
field: '', field: '',
addModel: { addModel: {
pointY: '', pointY: '',
width: '', width: 40,
height: '', height: 15,
modelList: [] modelList: []
}, },
mergeRules: { mergeRules: {
@ -289,6 +289,13 @@ export default {
_dispose: true _dispose: true
}); });
}); });
this.sectionList.forEach(elem => {
if (elem.trainWindowCode) {
const section = deepAssign({}, elem);
section.trainWindowCode = '';
remove.push(section);
}
});
this.$emit('updateMapModel', remove); this.$emit('updateMapModel', remove);
} }
}).catch(() => { }).catch(() => {
@ -298,24 +305,10 @@ export default {
// //
createTrainWindow() { createTrainWindow() {
const models = []; const models = [];
const switchSectionList = []; this.addList = []; // codelist
// const PhysicalSectionList = [];
this.addList = [];
const remove = []; //
if (this.trainWindowList && this.trainWindowList.length) {
this.trainWindowList.forEach(elem => {
remove.push({
_type: 'TrainWindow',
code: elem.code,
_dispose: true
});
});
this.$emit('updateMapModel', remove);
}
if (this.sectionList && this.sectionList.length) { if (this.sectionList && this.sectionList.length) {
this.sectionList.forEach(elem => { this.sectionList.forEach(elem => {
if (elem.type !== '04' && !elem.isSwitchSection && (elem.logicSectionNum.length == 0 || elem.logicSectionNum.length == 1 && elem.logicSectionNum[0] == 0)) { if (elem.type !== '04' && !elem.isSwitchSection && !elem.trainWindowCode && (elem.logicSectionNum.length == 0 || elem.logicSectionNum.length == 1 && elem.logicSectionNum[0] == 0)) {
const triangle = new JTriangle(elem.points[0], elem.points[elem.points.length - 1]); const triangle = new JTriangle(elem.points[0], elem.points[elem.points.length - 1]);
const param = this.createModel({ const param = this.createModel({
triangle: triangle, triangle: triangle,
@ -323,36 +316,19 @@ export default {
}); });
models.push(param); models.push(param);
const section = deepAssign(elem, { trainWindowCode: param.code }); const section = deepAssign(elem, { trainWindowCode: param.code });
// if (section.type == '02') { models.push(section);
// if (!switchSectionList.find(ele => { return ele.code == section.parentCode; })) {
// const sectionParent = deepAssign({}, this.$store.getters['map/getDeviceByCode'](section.parentCode));
// sectionParent['trainWindowCode'] = section.trainWindowCode;
// switchSectionList.push(sectionParent);
// }
// }
switchSectionList.push(section);
this.addList.push(param); this.addList.push(param);
} else if (elem.type === '04') { } else if (elem.type === '04' && !elem.trainWindowCode) {
const param = this.createModel({ const param = this.createModel({
section: elem section: elem
}); });
models.push(param); models.push(param);
const section = deepAssign(elem, { trainWindowCode: param.code }); const section = deepAssign(elem, { trainWindowCode: param.code });
switchSectionList.push(section); models.push(section);
this.addList.push(param); this.addList.push(param);
} }
}); });
} }
switchSectionList.forEach(elem => {
if (elem.type === '04') {
elem.relevanceSectionList.forEach(item => {
const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item));
section['trainWindowCode'] = elem.trainWindowCode;
models.push(section);
});
}
models.push(elem);
});
this.$emit('updateMapModel', models); this.$emit('updateMapModel', models);
}, },
@ -375,7 +351,17 @@ export default {
cancelButtonText: this.$t('tip.cancel'), cancelButtonText: this.$t('tip.cancel'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
_that.$emit('updateMapModel', {...selected, _dispose: true}); const models = [];
this.sectionList.forEach(elem => {
if (elem.trainWindowCode == selected.code) {
const section = deepAssign({}, elem);
section.trainWindowCode = '';
models.push(section);
}
});
models.push(deepAssign(selected, { _dispose: true }));
console.log(models);
_that.$emit('updateMapModel', models);
_that.deviceSelect(); _that.deviceSelect();
}).catch(() => { }).catch(() => {
_that.$message.info(this.$t('tip.cancelledDelete')); _that.$message.info(this.$t('tip.cancelledDelete'));