This commit is contained in:
fan 2019-09-06 17:24:45 +08:00
commit a9ec1672ae
3 changed files with 116 additions and 207 deletions

View File

@ -13,15 +13,15 @@
</div>
</el-tab-pane>
<el-tab-pane class="view-control" :label="$t('map.bothCreate')" name="second">
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: cardHeight + 60 +'px' }">
<div class="flex_box">
<el-button type="primary" @click="create">一键生成区段</el-button>
<el-card v-if="questionList.length" class="box-card">
<div v-for="(item, index) in questionList" :key="index" class="text item">
{{ item }}
</div>
</el-card>
</div>
<div class="flex_box">
<el-button type="primary" @click="create">一键生成区段</el-button>
</div>
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: cardHeight +'px' }">
<el-card v-if="questionList.length" class="box-card">
<div v-for="(item, index) in questionList" :key="index" class="text item">
{{ item }}
</div>
</el-card>
</el-scrollbar>
</el-tab-pane>
<el-tab-pane class="view-control" :label="$t('map.splitMerge')" name="three">
@ -42,8 +42,8 @@
@click="hover('splitSection')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.splitOffset')" prop="splitOffset">
<el-input-number v-model="addModel.splitOffset" :min="20" :max="addModel.splitOffsetMax" />px
<el-form-item label="拆分数量" prop="splitNumber">
<el-input-number v-model="addModel.splitNumber" :min="1" :max="addModel.splitOffsetMax" />
</el-form-item>
<el-form-item>
<el-button-group>
@ -91,7 +91,7 @@
</el-scrollbar>
</el-tab-pane>
<el-tab-pane class="view-control" :label="$t('map.logicBlock')" name="four">
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: cardHeight +'px' }">
<el-scrollbar :style="{ height: cardHeight +'px' }">
<el-table :data="tableData" style="width: 80%; margin: 0 auto;">
<el-table-column :label="$t('map.sectionPolyline')" width="150">
<template slot-scope="scope">
@ -209,7 +209,7 @@ export default {
tableData: [],
addModel: {
code: '',
splitOffset: 0,
splitNumber: 2,
splitOffsetMax: 0
},
mergeModel: {
@ -223,9 +223,9 @@ export default {
code: [
{ required: true, message: this.$t('rules.pleaseSelectSectionName'), trigger: 'change' }
],
splitOffset: [
{ required: true, message: this.$t('rules.pleaseFillOffset'), trigger: 'blur' },
{ type: 'number', message: this.$t('rules.pleaseFillValue'), min: '20' }
splitNumber: [
{ required: true, message: '请输入拆分数量', trigger: 'blur' },
{ type: 'number', message: '请输入合理的拆分数量', min: '20' }
]
},
mergeRules: {
@ -534,8 +534,8 @@ export default {
if (!this.fieldS) { //
this.editModel.points = [];
this.$refs.dataform.clearValidate();
this.activeName = 'first';
if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase()) {
this.activeName = 'first';
this.editModel.code = selected.code;
this.editModel.name = selected.name;
this.editModel.type = selected.type;
@ -607,14 +607,16 @@ export default {
this.editModel.isCurve = selected.isCurve;
this.addModel.splitOffsetMax = Math.sqrt(new JTriangle(selected.points[0], selected.points[selected.points.length - 1]).abspowz);
this.addModel.splitOffset = this.addModel.splitOffsetMax / 2;
this.computedLogicSectionNumList(this.editModel.logicSectionNum);
if (this.field.toUpperCase() === 'splitSection'.toUpperCase()) {
this.addModel.code = selected.code;
this.activeName = 'three';
} else if (this.field.toUpperCase() === 'leftSection'.toUpperCase()) {
this.mergeModel.lsectioncode = selected.code;
this.activeName = 'three';
} else if (this.field.toUpperCase() === 'rightSection'.toUpperCase()) {
this.mergeModel.rsectioncode = selected.code;
this.activeName = 'three';
}
} else {
this.tableData = [];
@ -742,13 +744,13 @@ export default {
filterLinks(query, item) {
return item.pinyin.indexOf(query) > -1;
},
//
create() {
const models = [];
const remove = [];
this.linkList.forEach(link => {
let count = 0;
this.sectionList.forEach(setction => {
console.log(setction);
count++;
if (setction.linkCode == link.code) {
count = 0;
@ -845,7 +847,11 @@ export default {
type: 'warning'
}).then(() => {
_that.$emit('delMapModel', remove);
_that.$emit('addOrUpdateMapModel', models);
if (models.length) {
_that.$emit('addOrUpdateMapModel', models);
} else {
_that.$message.info('所有link都有相关区段所以未生成任何区段');
}
}).catch(() => {
this.$message({
type: 'info',
@ -853,82 +859,15 @@ export default {
});
});
},
// buildEditModel() {
// const pointArr = JSON.stringify(this.editModel.points);
// const model = {
// _type: 'Section',
// code: this.editModel.code,
// name: this.editModel.name,
// type: this.editModel.type,
// relStandCode: this.editModel.relStandCode,
// leftStopPointOffset: Number(this.editModel.leftStopPointOffset),
// rightStopPointOffset: Number(this.editModel.rightStopPointOffset),
// axleShow: this.editModel.axleShow,
// namePosition: {
// x: this.editModel.namePosition.x,
// y: this.editModel.namePosition.y
// },
// kmRangeRight: this.editModel.kmRangeRight,
// kmRangeLeft: this.editModel.kmRangeLeft,
// region: this.editModel.region,
// isStandTrack: this.editModel.isStandTrack,
// standTrackName: this.editModel.standTrackName,
// standTrackNamePosition: {
// x: this.editModel.standTrackNamePosition.x,
// y: this.editModel.standTrackNamePosition.y
// },
// isReentryTrack: this.editModel.isReentryTrack, //
// reentryTrackName: this.editModel.reentryTrackName,
// reentryTrackNamePosition: {
// x: this.editModel.reentryTrackNamePosition.x,
// y: this.editModel.reentryTrackNamePosition.y
// },
// isSegmentation: this.editModel.isSegmentation,
// segmentationPosition: {
// x: this.editModel.segmentationPosition.x,
// y: this.editModel.segmentationPosition.y
// },
// isTransferTrack: this.editModel.isTransferTrack, //
// transferTrackName: this.editModel.transferTrackName,
// transferTrackNamePosition: {
// x: this.editModel.transferTrackNamePosition.x,
// y: this.editModel.transferTrackNamePosition.y
// },
// logicSectionNameSort: this.editModel.logicSectionNameSort,
// isSwitchSection: this.editModel.isSwitchSection,
// relSwitchCode: this.editModel.relSwitchCode,
// points: JSON.parse(pointArr),
// logicSectionNum: this.editModel.logicSectionNum,
// logicSectionShow: this.editModel.logicSectionShow,
// sepTypeLeft: this.editModel.sepTypeLeft,
// offsetLeft: this.editModel.offsetLeft,
// sepTypeRight: this.editModel.sepTypeRight,
// offsetRight: this.editModel.offsetRight,
// stationCode: this.editModel.stationCode,
// trainPosType: this.editModel.trainPosType,
// linkCode: this.editModel.linkCode,
// isCurve: this.editModel.isCurve,
// destinationCodeShow: false
// };
// if (model.isReentryTrack || this.editModel.isTransferTrack) {
// model.destinationCode = this.editModel.destinationCode; //
// model.destinationCodePoint = { //
// x: this.editModel.destinationCodePoint.x,
// y: this.editModel.destinationCodePoint.y
// };
// model.destinationCodeShow = this.editModel.destinationCodeShow;
// }
// return model;
// },
//
edit() {
this.$refs['dataform'].validate((valid) => {
if (valid) {
const edits = [];
const model = Object.assign({_type: 'Section'}, this.editModel);
model.points = JSON.stringify(model.points);
// model.points = JSON.parse(JSON.stringify(model.points));
model.leftStopPointOffset = Number(model.leftStopPointOffset);
model.rightStopPointOffset = Number(model.rightStopPointOffset);
// const model = this.buildEditModel();
this.sectionList.forEach(section => {
if (section.parentCode == model.code) {
section.logicSectionShow = model.logicSectionShow;
@ -967,117 +906,72 @@ export default {
});
}
},
//
//
split() {
this.$refs['oprt'].validate((valid) => {
if (valid) {
const selected = this.$store.getters['map/getDeviceByCode'](this.addModel.code);
if (selected && selected._type === 'Section' && selected.type === '01') {
const triangle = new JTriangle(selected.points[0], selected.points[selected.points.length - 1]);
const remove = [];
const models = [];
const uidL = selected.name + '_l';
const uidR = selected.name + '_r';
const modelL = {
_type: 'Section',
code: getUID('Section'),
name: uidL,
type: '01',
parentCode: '',
axleShow: selected.axleShow,
isStandTrack: false,
kmRangeRight: '',
kmRangeLeft: '',
region: '',
standTrackName: '',
standTrackNamePosition: { x: 0, y: 0 },
isReentryTrack: false,
reentryTrackName: '',
reentryTrackNamePosition: { x: 0, y: 0 },
isTransferTrack: false,
transferTrackName: '',
transferTrackNamePosition: { x: 0, y: 0 },
isSwitchSection: false,
isSegmentation: false,
segmentationPosition: { x: 0, y: 0 },
relSwitchCode: '',
logicSectionNameSort: selected.logicSectionNameSort,
logicSectionNum: selected.logicSectionNum,
logicSectionShow: selected.logicSectionShow,
sepTypeLeft: selected.sepTypeLeft,
offsetLeft: selected.offsetLeft,
sepTypeRight: '01',
offsetRight: selected.offsetRight,
linkCode: selected.linkCode,
trainPosType: selected.trainPosType,
isCurve: selected.isCurve,
points: [
{
x: selected.points[0].x,
y: selected.points[0].y
},
{
x: selected.points[0].x + triangle.getCos(this.addModel.splitOffset * 10000) / 10000,
y: selected.points[0].y + triangle.getSin(this.addModel.splitOffset * 10000) / 10000
}
],
namePosition: { x: 0, y: 0 }
};
const modelR = {
_type: 'Section',
code: getUID('Section'),
name: uidR,
type: '01',
parentCode: '',
axleShow: selected.axleShow,
isStandTrack: false,
kmRangeRight: '',
kmRangeLeft: '',
region: '',
standTrackName: '',
standTrackNamePosition: { x: 0, y: 0 },
isReentryTrack: false,
reentryTrackName: '',
reentryTrackNamePosition: { x: 0, y: 0 },
isTransferTrack: false,
transferTrackName: '',
transferTrackNamePosition: { x: 0, y: 0 },
isSegmentation: false,
segmentationPosition: { x: 0, y: 0 },
isSwitchSection: false,
relSwitchCode: '',
logicSectionNameSort: selected.logicSectionNameSort,
logicSectionNum: selected.logicSectionNum,
logicSectionShow: selected.logicSectionShow,
sepTypeLeft: '01',
offsetLeft: selected.offsetLeft,
sepTypeRight: selected.sepTypeRight,
offsetRight: selected.offsetRight,
linkCode: selected.linkCode,
trainPosType: selected.trainPosType,
isCurve: selected.isCurve,
points: [
{
x: selected.points[0].x + triangle.getCos(this.addModel.splitOffset * 10000) / 10000,
y: selected.points[0].y + triangle.getSin(this.addModel.splitOffset * 10000) / 10000
},
{
x: selected.points[selected.points.length - 1].x,
y: selected.points[selected.points.length - 1].y
}
],
namePosition: { x: 0, y: 0 }
};
const modelX = (selected.points[selected.points.length - 1].x - selected.points[0].x) / this.addModel.splitNumber;
const modelY = (selected.points[selected.points.length - 1].y - selected.points[0].y) / this.addModel.splitNumber;
for (let index = 1; index <= this.addModel.splitNumber; index++) {
const model = {
_type: 'Section',
code: getUID('Section'),
name: `${selected.name}_${index}`,
type: '01',
parentCode: '',
axleShow: selected.axleShow,
isStandTrack: false,
kmRangeRight: '',
kmRangeLeft: '',
region: '',
standTrackName: '',
standTrackNamePosition: { x: 0, y: 0 },
isReentryTrack: false,
reentryTrackName: '',
reentryTrackNamePosition: { x: 0, y: 0 },
isTransferTrack: false,
transferTrackName: '',
transferTrackNamePosition: { x: 0, y: 0 },
isSwitchSection: false,
isSegmentation: false,
segmentationPosition: { x: 0, y: 0 },
relSwitchCode: '',
logicSectionNameSort: selected.logicSectionNameSort,
logicSectionNum: selected.logicSectionNum,
logicSectionShow: selected.logicSectionShow,
sepTypeLeft: index == 0 ? selected.sepTypeLeft : '01', // ( 01)
offsetLeft: selected.offsetLeft,
sepTypeRight: index == this.addModel.splitNumber ? selected.sepTypeRight : '01', // ( 01)
offsetRight: selected.offsetRight,
linkCode: selected.linkCode,
trainPosType: selected.trainPosType,
isCurve: selected.isCurve,
points: [
{
x: selected.points[0].x + ((index - 1) * modelX),
y: selected.points[0].y + ((index - 1) * modelY)
},
{
x: selected.points[0].x + (index * modelX),
y: selected.points[0].y + (index * modelY)
}
],
namePosition: { x: 0, y: 0 }
};
models.push(model);
}
remove.push(selected);
models.push(modelL);
models.push(modelR);
this.$emit('delMapModel', remove);
this.$emit('addOrUpdateMapModel', models);
this.$emit('delMapModel', remove); //
this.$emit('addOrUpdateMapModel', models); //
}
}
});
},
//
merge() {
this.$refs['oprt1'].validate((valid) => {
if (valid) {
@ -1189,6 +1083,7 @@ export default {
}
});
},
//
removeSwitchSection() {
const remove = [];
if (this.sectionList && this.sectionList.length) {
@ -1203,6 +1098,7 @@ export default {
this.$emit('delMapModel', remove);
}
},
//
createSwitchSection() {
const models = [];
@ -1341,6 +1237,19 @@ export default {
justify-content: center;
}
.box-card {
width: calc(100% - 80px);
margin: 20px auto 0;
padding: 0 20px;
.text {
font-size: 14px;
}
.item {
padding: 18px 0;
}
}
/deep/ {
.card .el-transfer-panel__filter{
margin: 5px 15px;

View File

@ -43,7 +43,7 @@ export default {
permissionType: '',
mapId: '',
lessonId: '',
mapProductCode: '',
prdCode: '',
date: '',
amount: 0,
ownerId: '',
@ -68,7 +68,7 @@ export default {
items: [
{ prop: 'permissionType', label: this.$t('permission.permissionType'), type: 'select', required: false, disabled: !this.isAdd, options: this.permissionTypeList, change: true, onChange: this.permissionTypeChange },
{ prop: 'mapId', label: this.$t('permission.mapName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMap, options: this.publishMapList, change: true, onChange: this.mapChange },
{ prop: 'mapProductCode', label: this.$t('permission.mapProductName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMapProduct, options: this.mapProductList, change: true, onChange: this.mapProductChange },
{ prop: 'prdCode', label: this.$t('permission.mapProductName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMapProduct, options: this.mapProductList, change: true, onChange: this.mapProductChange },
{ prop: 'lessonId', label: this.$t('permission.lessonName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowLesson, options: this.filterPublisLessonList },
{ prop: 'roleName', label: this.$t('permission.belonger'), type: 'complete', required: false, disabled: !this.isAdd && this.isAdministrator, show: this.isShowRole, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: '请输入昵称/名字/手机号' },
{ prop: 'date', label: this.$t('permission.selectDate'), type: 'daterange', required: false, viewFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss' },
@ -86,7 +86,7 @@ export default {
mapId: [
{ required: true, message: this.$t('rules.selectMapName'), trigger: 'change' }
],
mapProductCode: [
prdCode: [
{ required: true, message: this.$t('rules.selectMapProductName'), trigger: 'change' }
],
lessonId: [
@ -159,9 +159,9 @@ export default {
}
var validator = {};
validator[PermissionType.LESSON] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.mapProductCode; };
validator[PermissionType.EXAM] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.mapProductCode; };
validator[PermissionType.SIMULATION] = () => { return this.formModel.mapId && this.formModel.mapProductCode; };
validator[PermissionType.LESSON] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.EXAM] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.SIMULATION] = () => { return this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.SCREEN] = () => { return true; };
if (endTime && startTime && this.formModel.permissionType && validator[this.formModel.permissionType]()) {
@ -176,10 +176,10 @@ export default {
if (this.formModel.permissionType == PermissionType.LESSON || this.formModel.permissionType == PermissionType.EXAM) {
model['lessonId'] = this.formModel.lessonId;
model['mapId'] = this.formModel.mapId;
model['prdCode'] = this.formModel.mapProductCode;
model['prdCode'] = this.formModel.prdCode;
} else if (this.formModel.permissionType == PermissionType.SIMULATION) {
model['mapId'] = this.formModel.mapId;
model['prdCode'] = this.formModel.mapProductCode;
model['prdCode'] = this.formModel.prdCode;
}
getTotalRemains(model).then(response => {
@ -201,11 +201,11 @@ export default {
},
permissionTypeChange() {
this.formModel.mapId = '';
this.formModel.mapProductCode = '';
this.formModel.prdCode = '';
this.formModel.lessonId = '';
},
mapChange(mapId) {
this.formModel.mapProductCode = '';
this.formModel.prdCode = '';
this.formModel.lessonId = '';
this.mapProductList = [];
getPublishMapInfo(mapId).then(resp => {
@ -217,9 +217,9 @@ export default {
});
});
},
mapProductChange(mapProductCode) {
mapProductChange(prdCode) {
this.formModel.lessonId = '';
this.filterPublisLessonList = this.publisLessonList.filter(elem => { return elem.mapId == this.formModel.mapId && elem.prdCode == this.formModel.mapProductCode; });
this.filterPublisLessonList = this.publisLessonList.filter(elem => { return elem.mapId == this.formModel.mapId && elem.prdCode == this.formModel.prdCode; });
},
// input
async querySearchAsync(queryString, cb) {
@ -259,7 +259,7 @@ export default {
permissionType: model.permissionType,
mapId: model.mapId,
lessonId: model.lessonId,
mapProductCode: model.mapProductCode,
prdCode: model.prdCode,
date: [model.startTime, model.endTime],
amount: model.amount,
ownerId: this.formModel.ownerId,
@ -281,7 +281,7 @@ export default {
permissionType: this.formModel.permissionType,
mapId: this.isShowMap ? this.formModel.mapId : '',
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
mapProductCode: this.isShowMapProduct ? this.formModel.mapProductCode : '',
prdCode: this.isShowMapProduct ? this.formModel.prdCode : '',
startTime: this.formModel.date[0],
endTime: this.formModel.date[1],
amount: this.formModel.amount,
@ -294,7 +294,7 @@ export default {
permissionType: this.formModel.permissionType,
mapId: this.isShowMap ? this.formModel.mapId : '',
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
mapProductCode: this.isShowMapProduct ? this.formModel.mapProductCode : '',
prdCode: this.isShowMapProduct ? this.formModel.prdCode : '',
startTime: this.formModel.date[0],
endTime: this.formModel.date[1],
amount: this.formModel.amount,

View File

@ -140,8 +140,8 @@ export default {
this.$message.success('创建空运行图成功!');
this.jump(resp.data, this.newModel.name);
this.doClose();
}).catch(() => {
this.$messageBox('创建运行图失败');
}).catch((error) => {
this.$messageBox('创建运行图失败:' + error.message);
this.doClose();
});
}
@ -155,8 +155,8 @@ export default {
this.$message.success('创建运行图成功!');
this.jump(resp.data, this.pullModel.name);
this.doClose();
}).catch(() => {
this.$messageBox('创建运行图失败');
}).catch((error) => {
this.$messageBox('创建运行图失败:' + error.message);
this.doClose();
});
}