rt-sim-training-client/src/views/publish/runPlanCommon/draft.vue

179 lines
4.2 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-08 14:32:32 +08:00
<div class="card-box">
<el-steps class="steps" :active="display">
<el-step :title="title" icon="el-icon-edit-outline" />
<el-step title="" icon="el-icon-upload" />
</el-steps>
<el-card class="forms">
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{height:height -120 + 'px'}" style="padding-top: 40px">
<el-form ref="form" :model="model" :rules="rules" label-width="140px" size="small">
<el-form-item label="选择地图:" prop="mapId">
<el-select v-model="model.mapId" filterable>
<el-option v-for="item in mapList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="运行图名称:" prop="planId">
<el-row>
<el-col :span="19">
<el-input v-model="model.planName" :readonly="true" />
</el-col>
<el-col :span="4" :offset="1">
<el-button @click="handleChoose">选择 </el-button>
</el-col>
</el-row>
</el-form-item>
</el-form>
</el-scrollbar>
</el-card>
<div class="draft">
<el-button-group>
<el-button v-if="isAdd" type="primary" @click="create">创建</el-button>
<el-button type="primary" @click="turnback">返回</el-button>
</el-button-group>
2019-07-26 13:32:43 +08:00
</div>
2019-08-08 14:32:32 +08:00
<choose-template-plan ref="choose" @chooseConfirm="chooseConfirm" />
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-08-08 14:32:32 +08:00
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
import { listPublishMap } from '@/api/jmap/map';
import { createRunPlanCommon } from '@/api/runplan';
import ChooseTemplatePlan from './chooseTemplatePlan';
2019-07-26 13:32:43 +08:00
2019-08-08 14:32:32 +08:00
export default {
name: 'CommonPlanDraft',
components: {
ChooseTemplatePlan
},
mixins: [
WindowResizeHandler
],
data() {
return {
height: '',
display: 1,
loading: false,
mapList: [],
model: {
mapId: '',
planId: '',
planName: ''
}
};
},
computed: {
title() {
return '创建通用运行图';
},
isAdd() {
return this.$route.params.mode.toUpperCase() == 'add'.toUpperCase();
},
rules() {
const rules = {
mapId: [
{ required: true, message: '请选择地图', trigger: 'blur' }
],
planId: [
{ required: true, message: '请选择模板运行图', trigger: 'change' }
]
};
2019-07-26 13:32:43 +08:00
2019-08-08 14:32:32 +08:00
return rules;
}
},
mounted() {
this.initLoadPage();
},
methods: {
resizeHandler: function () {
this.height = this._clientHeight - 130;
},
initLoadPage() {
listPublishMap().then(resp => {
this.mapList = resp.data;
});
},
handleChoose() {
let model = {};
const index = this.mapList.findIndex(elem => { return elem.id == this.model.mapId; });
if (index >= 0) {
model = this.mapList[index];
}
this.$refs.choose.doShow(model);
},
chooseConfirm(choose) {
if (choose) {
this.model.planId = choose.id;
this.model.planName = choose.name;
}
},
buildModel() {
return {
mapId: this.model.mapId,
templatePlanId: this.model.planId
};
},
create() {
this.$refs['form'].validate((valid) => {
if (valid) {
createRunPlanCommon(this.buildModel()).then(response => {
this.$message.success('创建通用运行图成功');
this.$router.go(-1);
}).catch(() => {
this.$messageBox('创建通用运行图失败');
});
}
});
},
turnback() {
this.$router.go(-1);
}
}
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.steps {
width: 940px;
margin: 0 auto;
margin-top: 20px;
height: 100%;
/deep/ {
.el-step__icon.is-icon {
width: 95px;
}
}
}
.forms {
width: 800px;
margin: 0 auto;
margin-top: 20px;
/deep/ {
.el-select {
float: left;
width: calc(600px);
}
.el-form-item__content>.el-input>.el-input__inner {
float: left;
width: calc(600px);
}
.el-input-number {
float: left;
width: calc(250px);
}
}
}
.draft {
width: 400px;
text-align: center;
margin: 20px auto;
}
2019-08-08 14:32:32 +08:00
</style>