This commit is contained in:
fan 2020-04-26 17:16:30 +08:00
commit ddce743683

View File

@ -3,11 +3,7 @@
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="form" :model="addModel" :rules="rules" label-width="120px" size="mini">
<div class="path-box">
<el-steps :active="display" style="display: none;">
<el-step title="生成默认" icon="el-icon-edit" />
<el-step title="保存运行等级" icon="el-icon-setting" />
</el-steps>
<div v-show="display == 1" class="definition">
<div class="rules">
<el-form-item :label="$t('map.startStationCodeColon')" prop="startStationCode">
<el-select v-model="addModel.startStationCode" clearable :filterable="true">
<el-option
@ -67,106 +63,50 @@
<el-form-item label="是否向右:" prop="right">
<el-checkbox v-model="addModel.right" />
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" size="small" style="margin-top: 10px" @click="generateLevel">生成等级</el-button>
</el-button-group>
</el-form-item>
</div>
<div v-show="display == 2" class="rule">
<el-form-item :label="$t('map.startStationCodeColon')" prop="startStationCode">
<el-select v-model="addModel.startStationCode" clearable :filterable="true">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'startStationCode' ? 'danger' : 'primary'"
@click="hover('startStationCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.startSectionColon')" prop="startSectionCode">
<el-select v-model="addModel.startSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'startSectionCode' ? 'danger' : 'primary'"
@click="hover('startSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.endStationColon')" prop="endStationCode">
<el-select v-model="addModel.endStationCode" clearable :filterable="true">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'endStationCode' ? 'danger' : 'primary'"
@click="hover('endStationCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item :label="$t('map.endSectionColon')" prop="endSectionCode">
<el-select v-model="addModel.endSectionCode" clearable :filterable="true">
<el-option
v-for="item in filterSectionList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
<el-button
:type=" field === 'endSectionCode' ? 'danger' : 'primary'"
@click="hover('endSectionCode')"
>{{ $t('map.activate') }}</el-button>
</el-form-item>
<el-form-item label="是否向右:" prop="right">
<el-checkbox v-model="addModel.right" />
</el-form-item>
<el-form-item label="站间距离:" prop="distance">
<el-input-number v-model="addModel.distance" :min="0" />
<span>m</span>
</el-form-item>
<el-form-item label="等级一时间:" prop="l1">
<el-input-number v-model="addModel.l1" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级二时间:" prop="l1">
<el-input-number v-model="addModel.l2" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级三时间:" prop="l1">
<el-input-number v-model="addModel.l3" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级四时间:" prop="l1">
<el-input-number v-model="addModel.l4" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级五时间:" prop="l1">
<el-input-number v-model="addModel.l5" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button v-if="!editShow" type="primary" size="small" style="margin-top: 10px" @click="lastStep">{{ $t('map.lastStep') }}
</el-button>
</el-button-group>
<el-button-group>
<el-button v-if="!editShow" type="primary" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.save') }}</el-button>
<el-button v-if="editShow" type="warning" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.updata') }}</el-button>
</el-button-group>
</el-form-item>
<div class="runLevelList">
<div class="runLevelListHeader">
<div class="runLevelListHeaderL">运行等级数据</div>
<div class="runLevelListHeaderR">
<el-button type="primary" size="small" @click="generateLevel">生成等级</el-button>
</div>
</div>
<div class="runLevelListContent">
<div v-if="display" style="border-top: 1px #EBEEF5 solid;padding-top: 12px;">
<el-form-item label="站间距离:" prop="distance">
<el-input-number v-model="addModel.distance" :min="0" />
<span>m</span>
</el-form-item>
<el-form-item label="等级一时间:" prop="l1">
<el-input-number v-model="addModel.l1" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级二时间:" prop="l1">
<el-input-number v-model="addModel.l2" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级三时间:" prop="l1">
<el-input-number v-model="addModel.l3" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级四时间:" prop="l1">
<el-input-number v-model="addModel.l4" :min="0" />
<span>s</span>
</el-form-item>
<el-form-item label="等级五时间:" prop="l1">
<el-input-number v-model="addModel.l5" :min="0" />
<span>s</span>
</el-form-item>
</div>
</div>
</div>
<div class="runLevelButtonGroup">
<el-form-item>
<el-button-group>
<el-button v-if="!editShow" type="primary" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.save') }}</el-button>
<el-button v-if="editShow" type="warning" size="small" :loading="loading" style="margin-top: 10px" @click="save">{{ $t('map.updata') }}</el-button>
</el-button-group>
</el-form-item>
</div>
</div>
</div>
</el-form>
@ -201,7 +141,7 @@ export default {
},
data() {
return {
display: 1, //
display:false, //
field: '',
editShow: false,
loading:false,
@ -266,7 +206,7 @@ export default {
routeData(val, old) {
if (val) {
this.addModel = val;
this.display = 2;
this.display = true;
this.editShow = true;
this.runLevelId = '';
if (val.id) {
@ -310,16 +250,20 @@ export default {
generateLevel() { //
this.$refs.form.validate(async (valid) => {
if (valid) {
const res = await postGenerateLevel(this.addModel);
if (res.code == 200) {
this.display = 2;
this.addModel.l1 = res.data.l1;
this.addModel.l2 = res.data.l2;
this.addModel.l3 = res.data.l3;
this.addModel.l4 = res.data.l4;
this.addModel.l5 = res.data.l5;
this.addModel.distance = res.data.distance;
}
postGenerateLevel(this.addModel).then(res=>{
if (res.code == 200) {
this.display = 2;
this.addModel.l1 = res.data.l1;
this.addModel.l2 = res.data.l2;
this.addModel.l3 = res.data.l3;
this.addModel.l4 = res.data.l4;
this.addModel.l5 = res.data.l5;
this.addModel.distance = res.data.distance;
this.display = true;
}
}).catch((error)=>{
this.$messageBox('生成运行等级失败: ' + error.message);
});
}
});
},
@ -341,24 +285,38 @@ export default {
}
},
save() {
this.loading = true;
if (this.editShow) {
putUploadLevel(this.runLevelId, this.addModel).then(res => { //
this.$message.success('更新成功');
this.clear();
}).catch(() => {
this.$messageBox('更新失败');
this.loading = false;
});
} else {
postSaveLevel(this.addModel).then(res => { //
this.$message.success('保存成功');
this.clear();
}).catch(() => {
this.$messageBox('保存失败');
this.loading = false;
});
}
this.$refs.form.validate(async (valid) => {
if (valid) {
if (this.editShow) {
this.loading = true;
putUploadLevel(this.runLevelId, this.addModel).then(res => { //
this.$message.success('更新成功');
this.clear();
this.display = false;
}).catch(() => {
this.$messageBox('更新失败');
this.loading = false;
});
} else {
if (this.display) {
this.loading = true;
postSaveLevel(this.addModel).then(res => { //
this.$message.success('保存成功');
this.clear();
this.display = false;
}).catch(() => {
this.$messageBox('保存失败');
this.loading = false;
});
} else {
this.$messageBox('请生成等级');
}
}
}
});
},
clear() {
if (this.$refs && this.$refs.form && this.mapInfo) {
@ -383,9 +341,6 @@ export default {
this.loading = false;
}
},
lastStep() {
this.display = 1;
},
hover(field) {
this.field = field === this.field ? '' : field;
},
@ -407,5 +362,26 @@ export default {
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.runLevelList{
width: 450px;
margin: 0 auto;
border: 1px #EBEEF5 solid;
}
.runLevelListHeader{
padding:10px 0px;
display: inline-block;
width: 100%;
}
.runLevelListHeaderL{
margin-left: 15px;
font-size: 14px;
display: inline-block;
margin-top: 7px;
}
.runLevelListHeaderR{display:inline-block;float: right;margin-right:10px;}
.runLevelListContent{
}
.runLevelButtonGroup{
margin-top:10px;
}
</style>