2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
|
|
|
<el-dialog :title="title" :visible.sync="dialogVisible" width="25%" :before-close="doClose" center>
|
|
|
|
<data-form ref="dataform" :form="form" :formModel="formModel" :rules="rules"></data-form>
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
<el-button type="primary" @click="doCreate">确 定</el-button>
|
|
|
|
<el-button @click="doClose">取 消</el-button>
|
|
|
|
</span>
|
|
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-08-12 11:31:43 +08:00
|
|
|
import { listPublishMap } from '@/api/jmap/map'
|
|
|
|
|
2019-07-26 13:32:43 +08:00
|
|
|
import { getQuestById} from '@/api/quest';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ScriptDraft',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dialogVisible: false,
|
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,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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 11:31:43 +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: [
|
|
|
|
{ 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: {
|
|
|
|
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
|
|
|
})
|
|
|
|
},
|
|
|
|
doShow(questid) {
|
|
|
|
if(questid)
|
|
|
|
{
|
|
|
|
getQuestById(questid).then(resp=>{
|
2019-08-12 11:31:43 +08:00
|
|
|
let data={'name':resp.data.name,'description':resp.data.description,'mapId':resp.data.mapId};
|
2019-07-26 13:32:43 +08:00
|
|
|
this.formModel=data;
|
|
|
|
this.formModel.id=questid;
|
|
|
|
this.disabled="disabled";
|
|
|
|
this.dialogVisible = true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.disabled=null;
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|