surprise
2024-01-15 87e98d5b5efeb7a9cf6330ae03e6dd53699b7ef1
src/components/left/layerTree/messageInfo.vue
@@ -3,16 +3,35 @@
    <div>
      <div class="modleTitle ">
        <div>属性信息</div>
        <div class="modelClose" @click="$store.state.showMessageInfo = false"> X</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 class="contentMessage" v-for="(item, index) in modelOption" :key="index">
        <div>{{ item.name }}</div>
      <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>
@@ -20,8 +39,7 @@
<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: {
@@ -30,8 +48,11 @@
  data() {
    return {
      modelOption: null
      modelOption: null,
      showMenuGrid: false,
      disabled: true,
      gid: null,
      obj: null,
    };
  },
  mounted() {
@@ -41,12 +62,78 @@
  },
  methods: {
    setLayerStart() {
      this.modelOption = mapInfo.mssageInfo;
    },
      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>
@@ -75,6 +162,12 @@
    align-items: center;
    padding: 0% 5%;
    .modelmenu {
      display: flex;
      align-items: center;
    }
    .modelClose {
      height: 16px;
      width: 16px;
@@ -83,6 +176,8 @@
      justify-content: center;
      background: rgba(128, 128, 128, 0.6);
      font-size: 14x;
      margin-left: 20px;
    }
  }
@@ -96,6 +191,7 @@
    overflow-y: auto;
    overflow-x: hidden;
    .contentMessage {
      width: 100%;
      color: white;
@@ -109,6 +205,9 @@
        // margin-bottom: 5%;
        line-height: 50px;
        border-right: 1px solid white;
        border-top: 1px solid white !important;
        word-wrap:break-word;
      }
      div:first-child {
@@ -119,11 +218,16 @@
    }
    .contentMessage:first-child {
      border-top: 1px solid white;
      ;
      border-top: 1px solid white !important;
    }
  }
  /deep/.el-input__inner {
    background: transparent !important;
    border: transparent !important;
    color: white !important;
  }
}
</style>