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

95 lines
3.0 KiB
Vue
Raw Normal View History

2019-09-26 10:54:07 +08:00
<template>
2019-11-01 15:19:15 +08:00
<el-dialog :title="title" :visible.sync="dialogVisible" width="500px" :before-close="doClose" center>
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<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>
2019-09-26 10:54:07 +08:00
</template>
<script>
2019-11-01 15:19:15 +08:00
import { getQuestById} from '@/api/quest';
export default {
name: 'ScriptDraft',
props: {
title: {
type: String,
default() {
return '';
}
}
},
data() {
return {
dialogVisible: false,
mapList: [],
taskStatusList: [],
formModel: {
name: '',
mapId: '',
description:''
2019-09-26 10:54:07 +08:00
}
2019-11-01 15:19:15 +08:00
};
},
computed: {
form() {
const form = {
labelWidth: '150px',
items: [
{ prop: 'name', label: this.$t('scriptRecord.scriptName'), type: 'text', required: true},
{ prop: 'description', label: this.$t('scriptRecord.scriptDescription'), type: 'textarea', required: true}
]
};
return form;
2019-09-26 10:54:07 +08:00
},
2019-11-01 15:19:15 +08:00
rules() {
const crules = {
name: [
{ required: true, message: this.$t('scriptRecord.inputScriptName'), trigger: 'blur' },
{ required: true, message: this.$t('scriptRecord.inputScriptName'), trigger: 'change' }
],
description:[
{ required: true, message: this.$t('scriptRecord.inputScriptDescription'), trigger: 'blur' },
{ required: true, message: this.$t('scriptRecord.inputScriptDescription'), trigger: 'change' }
]
};
return crules;
}
},
methods: {
doShow(questid) {
if (questid) {
getQuestById(questid).then(resp=>{
const data = {'name':resp.data.name, 'description':resp.data.description, 'mapId':resp.data.mapId};
this.formModel = data;
this.formModel.id = questid;
this.dialogVisible = true;
});
} else {
this.formModel.mapId = this.$route.params.mapId;
this.dialogVisible = true;
}
2019-09-26 10:54:07 +08:00
},
2019-11-01 15:19:15 +08:00
doCreate() {
const self = this;
this.$refs.dataform.validateForm(() => {
self.$emit('create', Object.assign({}, this.formModel));
self.doClose();
});
2019-09-26 10:54:07 +08:00
},
2019-11-01 15:19:15 +08:00
doClose() {
this.$refs.dataform.resetForm();
this.dialogVisible = false;
2019-09-26 10:54:07 +08:00
}
}
2019-11-01 15:19:15 +08:00
};
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;
}
2019-11-01 15:19:15 +08:00
</style>