<template>
|
<div id="mapInfo" class="modelBox" v-drag>
|
<div>
|
<div class="modleTitle ">
|
<div>属性信息</div>
|
<div class="modelmenu">
|
<div v-show="showMenuGrid">
|
<el-link v-show="disabled" @click="disabled = false" style="color: white;font-size: 14x;">编辑</el-link>
|
<el-link v-show="!disabled" @click="setObjSave" style="color: white;font-size: 14x;">保存</el-link>
|
</div>
|
<div class="modelClose" @click="$store.state.showMessageInfo = false">X</div>
|
</div>
|
|
</div>
|
</div>
|
<div class="modelContent">
|
<div v-show="!showMenuGrid" class="contentMessage" v-for="(item, index) in modelOption" :key="index">
|
<div>
|
<label>{{ item.name }}</label>
|
|
</div>
|
<div>{{ item.value }}</div>
|
</div>
|
<div v-show="showMenuGrid" class="contentMessage" v-for="(item, index) in modelOption" :key="index">
|
<div>{{ item.name }}</div>
|
<div v-show="item.name == 'ID'">{{ item.value }}
|
</div>
|
<div v-show="item.name == 'type'">{{ item.value }}
|
</div>
|
<div v-show="item.name != 'ID' && item.name != 'type'"><el-input style="width: 100%; text-align: center;"
|
v-model="item.value" :disabled="disabled"></el-input>
|
</div>
|
</div>
|
</div>
|
|
</div>
|
</template>
|
|
<script>
|
import model from '../../../assets/js/Layer/model';
|
import mapInfo from '../../../assets/js/Layer/mapInfo';
|
import { Grid_SelectById, Grid_UpdateById } from '../../../api/api'
|
export default {
|
name: "modelEdit",
|
components: {
|
|
},
|
|
data() {
|
return {
|
modelOption: null,
|
showMenuGrid: false,
|
disabled: true,
|
gid: null,
|
obj: null,
|
};
|
},
|
mounted() {
|
this.setLayerStart();
|
},
|
destroyed() {
|
|
},
|
methods: {
|
setLayerStart() {
|
this.obj = null;
|
var data = mapInfo.mssageInfo;
|
if (!data) {
|
this.$store.state.showMessageInfo = false;
|
return
|
}
|
var flag = false;
|
for (var i in data) {
|
if (data[i].name == "TYPE" && data[i].value == 'DrawGrid') {
|
flag = true;
|
break;
|
}
|
}
|
if (flag) {
|
for (var i in data) {
|
if (data[i].name == "gid") {
|
this.gid = data[i].value
|
this.getInfoMessage(this.gid);
|
break;
|
}
|
}
|
|
} else {
|
this.setInfoMesgData(data);
|
}
|
},
|
setInfoMesgData(res) {
|
this.modelOption = res
|
},
|
async setObjSave() {
|
var properties = this.obj.features[0].properties;
|
for (var key in properties) {
|
for (var i in this.modelOption) {
|
if (this.modelOption[i].name == key) {
|
properties[key] = this.modelOption[i].value
|
}
|
}
|
}
|
const data = await Grid_UpdateById({
|
id: this.gid,
|
json: JSON.stringify(this.obj.features[0])
|
});
|
if (data.status == 200) {
|
this.$message({
|
message: "保存成功",
|
type: "success",
|
});
|
this.disabled = true;
|
}
|
},
|
async getInfoMessage(res) {
|
const data = await Grid_SelectById(res);
|
if (data.status == 200) {
|
this.obj = data.data;
|
var properties = this.obj.features[0].properties;
|
console.log(data.data.features[0])
|
var std = [];
|
for (var key in properties) {
|
std.push({
|
name: key,
|
value: properties[key]
|
})
|
}
|
this.showMenuGrid = true
|
this.modelOption = std;
|
|
}
|
}
|
|
},
|
|
};
|
</script>
|
|
<style scoped lang="less">
|
.modelBox {
|
width: 370px;
|
height: 30%;
|
border: 1px solid white;
|
top: 30%;
|
left: calc(50% - 180px);
|
|
background-color: rgba(0, 0, 0, 0.6); // #0048fd69 !important
|
z-index: 9999;
|
position: absolute;
|
|
|
.modleTitle {
|
height: 42px;
|
width: 90%;
|
background: #0048fd69 !important;
|
border-bottom: 1px solid white;
|
color: white;
|
font-weight: 700px;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
padding: 0% 5%;
|
|
.modelmenu {
|
display: flex;
|
align-items: center;
|
|
}
|
|
.modelClose {
|
height: 16px;
|
width: 16px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
background: rgba(128, 128, 128, 0.6);
|
font-size: 14x;
|
margin-left: 20px;
|
|
|
}
|
}
|
|
.modelContent {
|
width: 88%;
|
height: calc(95% - 62px);
|
margin: 5%;
|
// display: flex;
|
// justify-content: space-between;
|
|
overflow-y: auto;
|
overflow-x: hidden;
|
|
.contentMessage {
|
width: 100%;
|
color: white;
|
display: flex;
|
border: 1px solid white;
|
border-top: transparent;
|
|
div {
|
width: calc(50% - 2px);
|
text-align: center;
|
// margin-bottom: 5%;
|
line-height: 50px;
|
border-right: 1px solid white;
|
border-top: 1px solid white !important;
|
word-wrap:break-word;
|
|
}
|
|
div:first-child {
|
border-right: 1px solid white;
|
|
}
|
|
}
|
|
.contentMessage:first-child {
|
border-top: 1px solid white !important;
|
|
}
|
}
|
|
/deep/.el-input__inner {
|
background: transparent !important;
|
border: transparent !important;
|
color: white !important;
|
}
|
|
}
|
</style>
|