rt-sim-training-client/src/views/newMap/newDesignUser/mapmanage/saveAs.vue
2019-11-29 12:51:58 +08:00

75 lines
2.0 KiB
Vue

<template>
<el-dialog v-dialogDrag :title="$t('map.saveMapAs')" :visible.sync="dialogShow" width="30%" :before-close="handleClose">
<div>
<el-form ref="form" label-position="right" :model="editModel" label-width="100px" :rules="editRules" size="mini" @submit.native.prevent>
<el-form-item :label="$t('map.mapName')" prop="name">
<el-input v-model="editModel.name" />
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="saveAs">{{ $t('map.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { saveAsMap } from '@/api/jmap/mapdraft';
export default {
name: 'MapSaveAs',
props: {
map: {
type: Object,
required: true
}
},
data() {
return {
dialogShow: false,
loading: false,
editModel: {
id: '',
name: ''
},
editRules: {
name: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'blur' }
]
}
};
},
watch: {
map: function (val, old) {
if (val) {
Object.assign(this.editModel, this.map);
}
}
},
methods: {
show() {
this.dialogShow = true;
},
close() {
this.$refs.form.resetFields();
this.dialogShow = false;
},
handleClose() {
this.close();
},
saveAs() {
this.loading = true;
saveAsMap(this.editModel).then(response => {
this.loading = false;
this.$emit('refresh');
this.close();
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('map.saveFailed'));
});
}
}
};
</script>