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