<template>
  <div class="DisplayControlList">
      <div class="module">
        <CodeShow ref="CodeShow" :apiurl="apiurl" @getFeaturesByAttribute="getFeaturesByAttribute" />
        <FacilityDevice ref="FacilityDevice" :apiurl="apiurl" />
        <BuildStatus ref="BuildStatus" :apiurl="apiurl"  @queryMapByAttribute="queryMapByAttribute" />
        <ThematicMap ref="ThematicMap" :apiurl="apiurl" @queryMapByAttribute="queryMapByAttribute" />
      </div>
  </div>
</template>

<script>
import CodeShow from './CodeShow.vue'
import FacilityDevice from './FacilityDevice.vue'
import BuildStatus from './BuildStatus.vue'
import ThematicMap from './ThematicMap.vue'
export default {
    name:"DisplayControlList",//显示控制
    components:{
      CodeShow,
      FacilityDevice,
      BuildStatus,
      ThematicMap
    },
    data(){
      return{
        apiurl :{
            smiddtfw: "",
            sjfw: "",
        }
      }
    },
    computed:{
      AppX: function () {
          return this.$store.getters.AppX;
      },
    },
    mounted(){
        this.apiurl.sjfw = this.AppX.appConfig.gisResource.tiplayers.config["sjfw"].url;
        this.apiurl.smiddtfw = this.AppX.appConfig.gisResource.tiplayers.config["bjsmidfw"].url;
    },
    methods:{
      /**
       * 属性查询(数据服务)
       */
      getFeaturesByAttribute(options) {
          let getFeatureParam, getFeatureBySQLService, getFeatureBySQLParams;
          getFeatureParam = new SuperMap.REST.FilterParameter({
              attributeFilter: options.whereclause,
              fields: options.fields
          });
          getFeatureBySQLParams = new SuperMap.REST.GetFeaturesBySQLParameters({
              queryParameter: getFeatureParam,
              toIndex: -1,
              datasetNames: options.datasetNames
          });
          getFeatureBySQLService = new SuperMap.REST.GetFeaturesBySQLService(options.url, {
              eventListeners: {
                  "processCompleted": options.completed,
                  "processFailed": options.failed
              }
          });
          getFeatureBySQLService.processAsync(getFeatureBySQLParams);
      },
      /**
      * 属性查询（查询地图服务）根据PBS编码查询部件SMID
      * @param options 
      */
      queryMapByAttribute(options) {
          let filterParams = options.filterParameters;
          const sqlParams = new SuperMap.REST.QueryBySQLParameters({
              queryParams: filterParams,
              queryOption: !options.queryOption ? SuperMap.REST.QueryOption.ATTRIBUTEANDGEOMETRY : options.queryOption
          });
          const sqlService = new SuperMap.REST.QueryBySQLService(options.url, {
              eventListeners: {
                  processCompleted: options.completed,
                  processFailed: options.failed
              }
          });
          sqlService.processAsync(sqlParams);
      },
      removeAll(){
            this.$refs.CodeShow.removeSource();
            this.$refs.FacilityDevice.removeSource();
            this.$refs.BuildStatus.removeSource();
            this.$refs.ThematicMap.removeSource();
      }
    },
    beforeDestroy(){
        this.removeAll()
    }
}
</script>

<style lang="scss" scoped>
.DisplayControlList{
    padding: 5px 0 !important;
    .module{
        width: 100%;
        display: flex;
        flex-flow: column;
    }
}
</style>