rt-sim-training-client/src/views/map/mapdraft/mapmanage/saveAs.vue
2019-07-25 10:30:30 +08:00

78 lines
1.5 KiB
Vue

<template>
<el-dialog title="地图另存为" :visible.sync="dialogShow" width="30%" :before-close="handleClose">
<div>
<el-form
ref="form"
label-position="right"
:model="editModel"
label-width="100px"
size="mini"
@submit.native.prevent
>
<el-form-item label="地图名称:" 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">取 消</el-button>
<el-button type="primary" :loading="loading" @click="saveAs"> </el-button>
</span>
</el-dialog>
</template>
<script>
import { saveAsMap } from '@/api/jmap/mapdraft';
// import localStore from 'storejs';
export default {
name: 'MapSaveAs',
props: {
map: {
type: Object,
required: true
}
},
data() {
return {
dialogShow: false,
loading: false,
editModel: {
id: '',
name: ''
}
};
},
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('另存失败');
});
}
}
};
</script>