2019-07-25 10:30:30 +08:00
|
|
|
<template>
|
2019-08-09 15:40:33 +08:00
|
|
|
<el-dialog :title="$t('map.mapEditor')" :visible.sync="dialogShow" width="30%" :before-close="handleClose">
|
2019-07-25 10:30:30 +08:00
|
|
|
<div>
|
|
|
|
<template v-if="basicInfo">
|
|
|
|
<el-form
|
|
|
|
ref="edit"
|
|
|
|
label-position="right"
|
|
|
|
:model="editModel"
|
|
|
|
:rules="editRules"
|
|
|
|
label-width="120px"
|
|
|
|
size="mini"
|
|
|
|
@submit.native.prevent
|
|
|
|
>
|
2019-08-09 15:40:33 +08:00
|
|
|
<el-form-item :label="$t('map.mapName')" prop="name">
|
2019-07-25 10:30:30 +08:00
|
|
|
<el-input v-model="editModel.name" />
|
|
|
|
</el-form-item>
|
2019-08-14 09:35:38 +08:00
|
|
|
<el-form-item :label="$t('map.skinName')" prop="skinCode">
|
|
|
|
<el-select v-model="editModel.skinCode" :placeholder="$t('map.pleaseSelect')" size="mini">
|
2019-07-25 10:30:30 +08:00
|
|
|
<el-option
|
2019-08-14 16:37:17 +08:00
|
|
|
v-for="item in skinCodeList"
|
2019-07-25 10:30:30 +08:00
|
|
|
:key="item.code"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2019-08-09 15:40:33 +08:00
|
|
|
<el-form-item :label="$t('map.selectCity')" prop="cityCode">
|
|
|
|
<el-select v-model="editModel.cityCode" :placeholder="$t('map.pleaseSelect')" size="mini">
|
2019-07-25 10:30:30 +08:00
|
|
|
<el-option v-for="item in cityList" :key="item.code" :label="item.name" :value="item.code" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<el-form
|
|
|
|
ref="updt"
|
|
|
|
label-position="right"
|
|
|
|
:model="updtModel"
|
|
|
|
:rules="updtRules"
|
|
|
|
label-width="120px"
|
|
|
|
size="mini"
|
|
|
|
@submit.native.prevent
|
|
|
|
>
|
2019-08-09 15:40:33 +08:00
|
|
|
<el-form-item :label="$t('map.offsetXColon')" :prop="'origin.x'">
|
|
|
|
<el-input v-model="updtModel.origin.x" :label="$t('map.offsetX')" disabled />
|
2019-07-25 10:30:30 +08:00
|
|
|
</el-form-item>
|
2019-08-09 15:40:33 +08:00
|
|
|
<el-form-item :label="$t('map.offsetYColon')" :prop="'origin.y'">
|
|
|
|
<el-input v-model="updtModel.origin.y" :label="$t('map.offsetY')" disabled />
|
2019-07-25 10:30:30 +08:00
|
|
|
</el-form-item>
|
2019-08-09 15:40:33 +08:00
|
|
|
<el-form-item :label="$t('map.scalingColon')" prop="scaling">
|
|
|
|
<el-input v-model="updtModel.scaling" :label="$t('map.scaling')" disabled />
|
2019-07-25 10:30:30 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
<span slot="footer" class="dialog-footer">
|
2019-08-09 15:40:33 +08:00
|
|
|
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
|
|
|
|
<el-button type="primary" :loading="loading" @click="save">{{ $t('map.confirm') }}</el-button>
|
2019-07-25 10:30:30 +08:00
|
|
|
</span>
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { updateMap, getMapDetail } from '@/api/jmap/mapdraft';
|
2019-08-14 16:37:17 +08:00
|
|
|
import { getSkinCodeList } from '@/api/management/mapskin';
|
|
|
|
import { updateSkinCodeByCode } from '@/api/management/mapskin';
|
2019-07-25 10:30:30 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'MapEdit',
|
|
|
|
props: {
|
|
|
|
map: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
basicInfo: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
default: function () {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
2019-08-14 09:35:38 +08:00
|
|
|
skinCode: {
|
2019-07-25 10:30:30 +08:00
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dialogShow: false,
|
|
|
|
loading: false,
|
2019-08-14 16:37:17 +08:00
|
|
|
skinCodeList: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
cityList: [],
|
|
|
|
editModel: {
|
|
|
|
id: '',
|
|
|
|
name: '',
|
2019-08-14 09:35:38 +08:00
|
|
|
skinCode: '',
|
2019-07-25 10:30:30 +08:00
|
|
|
cityCode: ''
|
|
|
|
},
|
|
|
|
updtModel: {
|
|
|
|
code: '',
|
|
|
|
scaling: '',
|
|
|
|
origin: {
|
|
|
|
x: '',
|
|
|
|
y: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
isUpdate: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
editRules() {
|
|
|
|
return {
|
|
|
|
name: [
|
2019-08-09 15:40:33 +08:00
|
|
|
{ required: true, message: this.$t('map.pleaseEnterMapName'), trigger: 'blur' }
|
2019-07-25 10:30:30 +08:00
|
|
|
],
|
2019-08-14 09:35:38 +08:00
|
|
|
skinCode: [
|
2019-08-09 15:40:33 +08:00
|
|
|
{ required: true, message: this.$t('map.pleaseSelectAssociatedSkin'), trigger: 'change' }
|
2019-07-25 10:30:30 +08:00
|
|
|
],
|
|
|
|
cityCode: [
|
2019-08-09 15:40:33 +08:00
|
|
|
{ required: true, message: this.$t('map.pleaseSelectAssociatedCity'), trigger: 'change' }
|
2019-07-25 10:30:30 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
updtRules() {
|
|
|
|
return {
|
|
|
|
linkWidth: [
|
2019-08-09 15:40:33 +08:00
|
|
|
{ required: true, message: this.$t('map.pleaseEnteMapLinkWidth'), trigger: 'blur' }
|
2019-07-25 10:30:30 +08:00
|
|
|
],
|
|
|
|
zoneWidth: [
|
2019-08-09 15:40:33 +08:00
|
|
|
{ required: true, message: this.$t('map.pleaseEnterMapSectionWidth'), trigger: 'blur' }
|
2019-07-25 10:30:30 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
map: function (val, old) {
|
|
|
|
if (val) {
|
|
|
|
Object.assign(this.editModel, this.map);
|
|
|
|
}
|
|
|
|
},
|
2019-07-29 17:57:00 +08:00
|
|
|
'$store.state.map.mapDataLoadedCount': function () {
|
2019-08-14 09:35:38 +08:00
|
|
|
if (this.$jlmap.skinCode) {
|
2019-07-29 17:57:00 +08:00
|
|
|
this.isUpdate = true;
|
|
|
|
}
|
2019-07-25 10:30:30 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.initLoadData();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
show() {
|
|
|
|
const dataZoom = this.$store.state.map.dataZoom;
|
|
|
|
if (dataZoom) {
|
|
|
|
this.updtModel.origin.x = Number.parseInt(dataZoom.offsetX);
|
|
|
|
this.updtModel.origin.y = Number.parseInt(dataZoom.offsetY);
|
|
|
|
this.updtModel.scaling = dataZoom.scaleRate;
|
|
|
|
}
|
|
|
|
this.dialogShow = true;
|
|
|
|
},
|
|
|
|
close() {
|
|
|
|
if (this.basicInfo) {
|
|
|
|
this.$refs.edit.resetFields();
|
|
|
|
} else {
|
|
|
|
this.$refs.updt.resetFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.dialogShow = false;
|
|
|
|
},
|
|
|
|
handleClose() {
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
save() {
|
|
|
|
this.loading = true;
|
|
|
|
if (this.basicInfo) {
|
|
|
|
this.editModel.id = this.$route.params.mapId;
|
2019-08-14 09:35:38 +08:00
|
|
|
// this.editModel.skinCode = skinCode;
|
2019-07-25 10:30:30 +08:00
|
|
|
this.$refs['edit'].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
updateMap(this.editModel).then(response => {
|
|
|
|
this.loading = false;
|
|
|
|
if (this.isUpdate && this.$route.params.mapId) {
|
|
|
|
getMapDetail(this.$route.params.mapId).then(response => {
|
|
|
|
this.$store.dispatch('map/setMapData', response.data);
|
|
|
|
});
|
|
|
|
}
|
2019-08-09 15:40:33 +08:00
|
|
|
this.$message.success(this.$t('map.mapUpdateSuccessful'));
|
2019-07-25 10:30:30 +08:00
|
|
|
this.$emit('refresh');
|
|
|
|
this.close();
|
|
|
|
}).catch(error => {
|
|
|
|
this.loading = false;
|
2019-08-09 15:40:33 +08:00
|
|
|
this.$message.error(this.$t('map.operationUnusual') + error.message);
|
2019-07-25 10:30:30 +08:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2019-08-14 09:35:38 +08:00
|
|
|
this.updtModel.code = this.skinCode;
|
2019-07-25 10:30:30 +08:00
|
|
|
this.$refs['updt'].validate((valid) => {
|
|
|
|
if (valid) {
|
2019-08-14 16:37:17 +08:00
|
|
|
updateSkinCodeByCode(this.updtModel).then(response => {
|
2019-07-25 10:30:30 +08:00
|
|
|
this.loading = false;
|
|
|
|
this.close();
|
2019-08-09 15:40:33 +08:00
|
|
|
this.$message.success(this.$t('map.updateSuccessfully'));
|
2019-07-25 10:30:30 +08:00
|
|
|
}).catch(() => {
|
|
|
|
this.loading = false;
|
2019-08-09 15:40:33 +08:00
|
|
|
this.$messageBox(this.$t('map.updateFailed'));
|
2019-07-25 10:30:30 +08:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
initLoadData() {
|
|
|
|
this.cityList = [];
|
2019-08-01 15:19:24 +08:00
|
|
|
this.$Dictionary.cityType().then(list => {
|
|
|
|
this.cityList = list;
|
|
|
|
}).catch(() => {
|
2019-08-09 15:40:33 +08:00
|
|
|
this.$messageBox(this.$t('map.failedLoadCityList'));
|
2019-08-01 15:19:24 +08:00
|
|
|
});
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-08-14 16:37:17 +08:00
|
|
|
this.skinCodeList = [];
|
|
|
|
getSkinCodeList().then(response => {
|
|
|
|
this.skinCodeList = response.data;
|
2019-07-25 10:30:30 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|