<template>
  <div class="widget-LayerUpOrDown">
    <el-input type="number" step="1" v-model="layerdown">
      <template slot="prepend">管道抬升:</template>
      <template slot="append"><span style="color: #006ed4">米</span></template>
    </el-input>
  </div>
</template>
<script>
const gLayerList=["NETWORK_SJ_PSWS@sxgk#1","NETWORK_SJ_PSYS@sxgk#1"
        ,"NETWORK_SJ_PSWS_Node@sxgk#1","NETWORK_SJ_PSYS_Node@sxgk#1","TF_SJ_PSYS_JG_B_3D@sxgk#1","TF_SJ_PSYS_JG_B_3D@sxgk#2","TF_SJ_PSWS_JG_B_3D@sxgk#2","TF_SJ_PSWS_JG_B_3D@sxgk#1"];
export default {
  name: "LayerUpOrDown",
  data() {
    return {
      layerdown: 0,
    };
  },
  props: {
    isInit: false,
  },
  watch:{
    layerdown(newVal){
        this.changeDepth(newVal)
    },
    isInit(){
      this.viewer=window.viewer;
    }
  },
  computed:{
    AppX(){
      return this.$store.getters.AppX;
    }
  },
  mounted(){
    this.AppX.appConfig.upDepth=-this.AppX.appConfig.downDepth;
  },
  methods: {
    changeDepth(value){
            let height = parseFloat(value);
            if(isNaN(height)){
              return;
            }
            this.AppX.appConfig.upDepth=height;
            const style3D=new Cesium.Style3D();
            style3D.altitudeMode=0;
            style3D.bottomAltitude=height;
            gLayerList.forEach(item => {
                var layer = this.viewer.scene.layers.find(item);
                if (layer) {
                    //layer.style3D.bottomAltitude = height + this.AppX.appConfig.downDepth;
                    //layer.style3D.bottomAltitude = height;
                    layer.style3D=style3D;
                    layer.refresh();
                }
            })
    }
  },
};
</script>
<style lang="scss" scoped>
.widget-LayerUpOrDown {
  font-size: 12px;
  position: absolute;
  top: 13px;
  padding-left: 4px;
  padding-right: 5px;
  color: white;
  z-index: 100;
  height: 36px;
  left: 510px;
  ::v-deep .el-input__inner{
    width: 35px;
    height: 36px;
    padding:0;
    border:none;
    color:#006ED4;
  }
  ::v-deep .el-input {
    .el-input-group__append,
    .el-input-group__prepend {
      font-size: 0.875rem;
      color: #666666;
      padding: 0.275rem 0.45rem;
      background-color: #fff;
      border: none;
      font-family: Source Han Sans CN;
    }
  }
}
</style>