rt-sim-training-client/src/views/scriptManage/home.vue

153 lines
5.0 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-15 14:06:53 +08:00
<el-card :style="{height: height+'px'}">
<div class="home-box">
<el-card class="box-card">
<div id="scriptTitle">创建剧本</div>
<div id="sciptForm">
<data-form ref="dataform" :form="form" :formModel="formModel" :rules="rules"></data-form>
</div>
<div id="btnList">
<span slot="footer" class="btn-footer">
<el-button type="primary" @click="doCreate"> </el-button>
<!-- <el-button @click="doClose"> </el-button> -->
</span>
</div>
</el-card>
</div>
</el-card>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-08-15 14:06:53 +08:00
import {listPublishMap} from '@/api/jmap/map'
2019-08-15 09:04:17 +08:00
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
2019-08-15 14:06:53 +08:00
import {createQuest} from '@/api/quest';
2019-07-26 13:32:43 +08:00
export default {
name: 'ScriptDraft',
2019-08-15 09:04:17 +08:00
mixins: [WindowResizeHandler],
2019-07-26 13:32:43 +08:00
data() {
return {
2019-08-12 11:31:43 +08:00
mapList: [],
2019-07-26 13:32:43 +08:00
taskStatusList: [],
disabled:null,
formModel: {
name: '',
2019-08-12 11:31:43 +08:00
mapId: '',
2019-07-26 13:32:43 +08:00
description:''
},
isShow: false,
2019-08-15 09:04:17 +08:00
height: 0,
2019-07-26 13:32:43 +08:00
}
},
props: {
title: String,
},
computed: {
form() {
let isAdd = this.type === 'ADD'
let form = {
labelWidth: '100px',
items: [
{ prop: 'name', label: '剧本名称', type: 'text', required: true},
2019-08-12 14:21:32 +08:00
{ prop: 'mapId', label: '地图', type: 'select', required: true, options: this.mapList,disabled:this.disabled},
2019-07-26 13:32:43 +08:00
{ prop: 'description', label: '剧本描述', type: 'textarea', required: true},
]
}
return form
},
rules() {
let crules = {
name: [
{ required: true, message: '请输入剧本', trigger: 'blur' },
],
2019-08-12 11:31:43 +08:00
mapId: [
2019-08-12 14:21:32 +08:00
{ required: true, message: '请选择地图', trigger: 'change' },
2019-07-26 13:32:43 +08:00
],
description:[
{ required: true, message: '请输入剧本描述', trigger: 'blur' },
]
}
return crules
},
// title() {
// return '创建剧本'
// }
},
mounted() {
this.loadInitData();
},
methods: {
2019-08-15 09:04:17 +08:00
resizeHandler() {
this.height = this._clientHeight - 50;
},
2019-07-26 13:32:43 +08:00
loadInitData() {
2019-08-12 11:31:43 +08:00
this.mapList = [];
listPublishMap().then(response => {
this.mapList = response.data.map(elem => { return { value: elem.id, label: elem.name } });
2019-07-26 13:32:43 +08:00
})
},
2019-08-15 14:06:53 +08:00
// doShow(questid) {
// if(questid)
// {
// getQuestById(questid).then(resp=>{
// let data={'name':resp.data.name,'description':resp.data.description,'mapId':resp.data.mapId};
// this.formModel=data;
// this.formModel.id=questid;
// this.disabled="disabled";
// this.dialogVisible = true
// });
// }
// else
// {
// this.disabled=null;
// this.dialogVisible = true
// }
// },
2019-07-26 13:32:43 +08:00
doCreate() {
let self = this
this.$refs.dataform.validateForm(() => {
2019-08-15 14:06:53 +08:00
//self.$emit('create', Object.assign({}, this.formModel));
let data=this.formModel;
createQuest(data).then(resp => {
this.$emit('refresh');
this.formModel={};
this.$message.success('创建剧本成功');
}).catch(error => {
this.$messageBox(`创建剧本失败: ${error.message}`);
});
2019-07-26 13:32:43 +08:00
})
}
}
}
2019-08-15 09:04:17 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.home-box {
2019-08-15 14:06:53 +08:00
padding: 20px 100px;
2019-08-15 09:04:17 +08:00
float: left;
width: 100%;
font-family: 'Microsoft YaHei';
}
2019-08-15 14:06:53 +08:00
.box-card {
width:800px;
margin: 0 auto;
margin-top: 20px;
padding-bottom: 50px;
}
#scriptTitle{
padding: 30px 40px;
}
#sciptForm{
margin-top: 10px;
padding: 0px 130px 0px 100px;
}
#btnList{
margin: 0px 100px;
}
.btn-footer{
margin-left: 100px;
margin-top: 10px;
display: inline-block;
}
2019-08-15 09:04:17 +08:00
</style>