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

114 lines
4.0 KiB
Vue
Raw Normal View History

2019-09-26 10:54:07 +08:00
<template>
2019-09-26 13:21:15 +08:00
<el-dialog :title="title" :visible.sync="dialogVisible" width="500px" :before-close="doClose" center>
2019-09-26 10:54:07 +08:00
<data-form ref="dataform" :form="form" :formModel="formModel" :rules="rules"></data-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doCreate">{{$t('global.confirm')}}</el-button>
<el-button @click="doClose">{{$t('global.cancel')}}</el-button>
</span>
</el-dialog>
</template>
<script>
import { listPublishMap } from '@/api/jmap/map'
import { getQuestById} from '@/api/quest';
export default {
name: 'ScriptDraft',
data() {
return {
dialogVisible: false,
mapList: [],
taskStatusList: [],
disabled:null,
formModel: {
name: '',
mapId: '',
description:''
},
isShow: false,
}
},
props: {
title: String,
},
computed: {
form() {
let isAdd = this.type === 'ADD'
let form = {
2019-09-26 13:21:15 +08:00
labelWidth: '150px',
2019-09-26 10:54:07 +08:00
items: [
{ prop: 'name', label: this.$t('scriptRecord.scriptName'), type: 'text', required: true},
{ prop: 'mapId', label: this.$t('scriptRecord.map'), type: 'select', required: true, options: this.mapList,disabled:this.disabled},
{ prop: 'description', label: this.$t('scriptRecord.scriptDescription'), type: 'textarea', required: true},
]
}
return form
},
rules() {
let crules = {
name: [
{ required: true, message: this.$t('scriptRecord.inputScriptName'), trigger: 'blur' },
2019-09-26 10:54:07 +08:00
],
mapId: [
{ required: true, message: this.$t('scriptRecord.selectMap'), trigger: 'change' },
2019-09-26 10:54:07 +08:00
],
description:[
{ required: true, message: this.$t('scriptRecord.inputScriptDescription'), trigger: 'blur' },
2019-09-26 10:54:07 +08:00
]
}
return crules
},
// title() {
// return '创建剧本'
// }
},
mounted() {
this.loadInitData();
},
methods: {
loadInitData() {
this.mapList = [];
listPublishMap().then(response => {
this.mapList = response.data.map(elem => { return { value: elem.id, label: elem.name } });
})
},
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.formModel.mapId=this.$route.params.mapId;
this.disabled="disabled";
this.dialogVisible = true
}
},
doCreate() {
let self = this
this.$refs.dataform.validateForm(() => {
self.$emit('create', Object.assign({}, this.formModel));
self.doClose()
})
},
doClose() {
this.$refs.dataform.resetForm();
this.isShow = false;
this.dialogVisible = false
}
}
}
2019-09-26 13:21:15 +08:00
</script>
<style lang="scss" scoped>
/deep/ .el-dialog--center .el-dialog__body{
padding: 25px 65px 30px 10px;
}
</style>