2019-12-19 18:04:28 +08:00
|
|
|
<template>
|
|
|
|
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="30%" :before-close="handleClose" center :close-on-click-modal="false">
|
|
|
|
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
<el-button 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 { addSkinCode, updateSkinCode } from '@/api/management/mapline';
|
|
|
|
export default {
|
|
|
|
name: 'DictionaryEdit',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dialogVisible: false,
|
|
|
|
formModel: {
|
|
|
|
id: '',
|
|
|
|
code: '',
|
|
|
|
name: '',
|
|
|
|
origin: { x: 0, y: 0 },
|
|
|
|
scaling: 1
|
2020-11-12 09:54:42 +08:00
|
|
|
},
|
|
|
|
isAdd:false,
|
|
|
|
title:''
|
2019-12-19 18:04:28 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
form() {
|
|
|
|
const form = {
|
|
|
|
labelWidth: '100px',
|
|
|
|
items: [
|
2020-11-12 09:54:42 +08:00
|
|
|
{ prop: 'code', label: this.$t('system.code'), type: 'text', disabled: !this.isAdd },
|
2019-12-19 18:04:28 +08:00
|
|
|
{ prop: 'name', label: this.$t('system.name'), type: 'text' },
|
|
|
|
{ prop: 'origin', label: '坐标:', type: 'coordinate', children: [
|
2020-11-12 09:54:42 +08:00
|
|
|
{ prop: 'origin.x', firstLevel: 'origin', secondLevel: 'x', label: 'x', type: 'number', labelWidth: '30px'},
|
|
|
|
{ prop: 'origin.y', firstLevel: 'origin', secondLevel: 'y', label: 'y', type: 'number', labelWidth: '30px'}
|
2019-12-19 18:04:28 +08:00
|
|
|
] },
|
|
|
|
{ prop: 'scaling', label: '缩放比例:', type: 'number', min: 0.4, max: 8, step: 0.2 }
|
|
|
|
]
|
|
|
|
};
|
|
|
|
return form;
|
|
|
|
},
|
|
|
|
rules() {
|
|
|
|
const crules = {
|
2020-11-12 09:54:42 +08:00
|
|
|
code: [
|
|
|
|
{ required: true, message: this.$t('rules.pleaseInputCode'), trigger: 'blur' }
|
|
|
|
],
|
2019-12-19 18:04:28 +08:00
|
|
|
name: [
|
|
|
|
{ required: true, message: this.$t('rules.pleaseInputName'), trigger: 'blur' }
|
|
|
|
],
|
|
|
|
status: [
|
|
|
|
{ required: true, message: this.$t('rules.pleaseSelectStatus'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
'origin.x': [
|
|
|
|
{ required: true, message: '请输入坐标x', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
'origin.y': [
|
|
|
|
{ required: true, message: '请输入坐标y', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
scaling: [
|
|
|
|
{ required: true, message: '请输入缩放比例', trigger: 'blur' }
|
|
|
|
]
|
|
|
|
};
|
2020-11-12 09:54:42 +08:00
|
|
|
return crules;
|
2019-12-19 18:04:28 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
show(row) {
|
|
|
|
if (row && row.id) {
|
|
|
|
this.formModel = {
|
|
|
|
id: row.id,
|
|
|
|
code: row.code,
|
|
|
|
name: row.name,
|
|
|
|
origin: row.origin,
|
|
|
|
scaling: row.scaling
|
|
|
|
};
|
2020-11-12 09:54:42 +08:00
|
|
|
this.isAdd = false;
|
|
|
|
this.title = this.$t('system.editDictionary');
|
|
|
|
} else {
|
|
|
|
this.isAdd = true;
|
|
|
|
this.title = this.$t('system.createDirectory');
|
2019-12-19 18:04:28 +08:00
|
|
|
}
|
2020-11-12 09:54:42 +08:00
|
|
|
this.dialogVisible = true;
|
2019-12-19 18:04:28 +08:00
|
|
|
},
|
|
|
|
doSave() {
|
|
|
|
const self = this;
|
|
|
|
this.$refs.dataform.validateForm(() => {
|
2020-12-18 09:35:43 +08:00
|
|
|
if (this.isAdd) {
|
2019-12-19 18:04:28 +08:00
|
|
|
self.create();
|
|
|
|
} else {
|
|
|
|
self.update();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
create() {
|
|
|
|
addSkinCode(this.formModel).then(response => {
|
|
|
|
this.$message.success(this.$t('system.createSuccess'));
|
|
|
|
this.handleClose();
|
|
|
|
this.$emit('reloadTable');
|
|
|
|
}).catch(error => {
|
|
|
|
this.$message.error(`${this.$t('error.createDictionaryFailed')}:${error.message}`);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
update() {
|
|
|
|
updateSkinCode(this.formModel).then(response => {
|
|
|
|
this.$message.success(this.$t('system.updateSuccess'));
|
|
|
|
this.handleClose();
|
|
|
|
this.$emit('reloadTable');
|
|
|
|
}).catch(error => {
|
|
|
|
this.$message.error(`${this.$t('error.updateDictionaryFailed')}:${error.message}`);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleClose(done) {
|
|
|
|
this.formModel = {
|
|
|
|
id: '',
|
|
|
|
code: '',
|
|
|
|
name: '',
|
|
|
|
origin: { x: 0, y: 0 },
|
|
|
|
scaling: 1
|
|
|
|
};
|
|
|
|
this.$refs.dataform.resetForm();
|
|
|
|
if (done) {
|
|
|
|
done();
|
|
|
|
} else {
|
|
|
|
this.dialogVisible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|