2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
2019-09-02 15:37:57 +08:00
|
|
|
<el-card :style="{height: height+'px'}">
|
|
|
|
<div class="home-box">
|
|
|
|
<el-card class="box-card">
|
2019-09-10 16:14:54 +08:00
|
|
|
<div id="scriptTitle">{{ $t('scriptRecord.createScript') }}</div>
|
2019-09-02 15:37:57 +08:00
|
|
|
<div id="sciptForm">
|
|
|
|
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
2019-08-15 14:06:53 +08:00
|
|
|
</div>
|
2019-09-02 15:37:57 +08:00
|
|
|
<div id="btnList">
|
|
|
|
<span slot="footer" class="btn-footer">
|
2019-09-10 16:14:54 +08:00
|
|
|
<el-button type="primary" :loading="loading" @click="doCreate">{{$t('scriptRecord.submit')}}</el-button>
|
2019-09-02 15:37:57 +08:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</el-card>
|
|
|
|
</div>
|
|
|
|
</el-card>
|
2019-07-26 13:32:43 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-09-02 15:37:57 +08:00
|
|
|
import { UrlConfig } from '@/router/index';
|
|
|
|
import {listPublishMap} from '@/api/jmap/map';
|
|
|
|
import {createQuest} from '@/api/quest';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-09-02 15:37:57 +08:00
|
|
|
export default {
|
|
|
|
name: 'ScriptDraft',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
mapList: [],
|
|
|
|
taskStatusList: [],
|
|
|
|
disabled: true,
|
|
|
|
formModel: {
|
|
|
|
name: '',
|
|
|
|
mapId: '',
|
|
|
|
description: ''
|
|
|
|
},
|
|
|
|
isShow: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
form() {
|
|
|
|
const form = {
|
2019-09-10 16:14:54 +08:00
|
|
|
labelWidth: '150px',
|
2019-09-02 15:37:57 +08:00
|
|
|
items: [
|
2019-09-10 16:14:54 +08:00
|
|
|
{ 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}
|
2019-09-02 15:37:57 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
return form;
|
|
|
|
},
|
|
|
|
rules() {
|
|
|
|
const crules = {
|
|
|
|
name: [
|
2019-09-10 17:32:41 +08:00
|
|
|
{ required: true, message: this.$t('scriptRecord.scriptNameRule'), trigger: 'blur' },
|
|
|
|
{ required: true, message: this.$t('scriptRecord.scriptNameRule'), trigger: 'change' }
|
|
|
|
|
|
|
|
|
2019-09-02 15:37:57 +08:00
|
|
|
],
|
|
|
|
mapId: [
|
|
|
|
{ required: true, message: '请选择所属地图', trigger: 'change' }
|
|
|
|
],
|
|
|
|
description: [
|
2019-09-10 17:32:41 +08:00
|
|
|
{ required: true, message: this.$t('scriptRecord.scriptDescriptionRule'), trigger: 'blur' },
|
|
|
|
{ required: true, message: this.$t('scriptRecord.scriptDescriptionRule'), trigger: 'change' }
|
2019-09-02 15:37:57 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
return crules;
|
|
|
|
},
|
|
|
|
height() {
|
|
|
|
return this.$store.state.app.height - 50;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$store.state.scriptRecord.scriptId': function (val) {
|
|
|
|
this.formModel.mapId=val;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.loadInitData();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadInitData() {
|
|
|
|
this.mapList = [];
|
|
|
|
listPublishMap().then(response => {
|
|
|
|
this.mapList = response.data.map(elem => { return { value: elem.id, label: elem.name }; });
|
|
|
|
this.formModel.mapId=this.$store.state.scriptRecord.scriptId|| this.mapList[0].value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
doCreate() {
|
|
|
|
const self = this;
|
|
|
|
if (!this.loading) {
|
|
|
|
this.$refs.dataform.validateForm(() => {
|
|
|
|
this.loading=true;
|
|
|
|
const data=this.formModel;
|
|
|
|
createQuest(data).then(resp => {
|
|
|
|
const data={mapId: self.formModel.mapId, scriptId: resp.data};
|
|
|
|
this.$emit('refresh', data);
|
2019-09-10 17:32:41 +08:00
|
|
|
this.$message.success(this.$t('scriptRecord.createScriptSuccess'));
|
|
|
|
|
|
|
|
|
2019-09-02 15:37:57 +08:00
|
|
|
this.formModel={};
|
|
|
|
this.loading=false;
|
|
|
|
this.$router.push({ path: `${UrlConfig.script.detail}/${resp.data}` });
|
|
|
|
}).catch(error => {
|
|
|
|
this.loading=false;
|
2019-09-24 14:09:26 +08:00
|
|
|
this.$messageBox(`${this.$t('scriptRecord.createScriptFail')}${error.message}`);
|
2019-09-02 15:37:57 +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>
|