rt-sim-training-client/src/views/publish/publishMap/copy.vue

67 lines
2.1 KiB
Vue
Raw Normal View History

<template>
<el-dialog v-dialogDrag :title="this.$t('publish.copyMapAs')" :visible.sync="dialogVisible" width="30%" center>
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
2019-10-31 14:35:28 +08:00
<el-button v-loading="loading" type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="dialogVisible = false">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { copyMapAs } from '@/api/jmap/map';
export default {
name: 'CopyMap',
data() {
return {
dialogVisible: false,
formModel: {
name: '',
copyOtherData: false
},
2019-10-31 14:35:28 +08:00
loading: false,
mapId: '',
form:{
labelWidth: '100px',
items: [
{ prop: 'name', label: this.$t('publish.mapName'), type: 'text', required: true},
{ prop: 'copyOtherData', label: this.$t('publish.whetherToCopyData'), type: 'switch', required: true}
]
},
rules: {
name: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'blur' }
],
copyOtherData: [
{ required: true, message: this.$t('global.choose'), trigger: 'change' }
]
}
};
},
computed: {
},
methods: {
doShow(row) {
this.dialogVisible = true;
this.mapId = row.id;
},
doSave() {
2019-10-31 14:35:28 +08:00
if (this.loading) {
return;
}
this.loading = true;
copyMapAs(this.mapId, this.formModel).then(resp =>{
this.$message.success(this.$t('tip.copyMapSuccess'));
2019-10-31 14:35:28 +08:00
this.loading = false;
this.dialogVisible = false;
this.$emit('refresh');
2019-10-31 14:35:28 +08:00
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('tip.copyMapFail'));
});
}
}
};
</script>