<template>
  <div style="background-color: #ffffff;padding: 10px;">
    <template v-if="this.selectdata.defname === '报装申请'|| this.selectdata.defname === '报建受理'|| this.selectdata.defname ==='现场勘察'">
      <apply-input-search
        :markmapdata="markmapdata" v-ref:pick
        @locationclick="locationclick"
      ></apply-input-search>
    </template>
    <template v-else>
      <apply-amap-location
        :isshowsearch="false"
        :mylocationinfo="false"
        :isshowmapmodel="false"
        :islocation="false"
         mapmodel="dragMarker"
        :labelmarksarray="labelmarksarray"
      ></apply-amap-location>
    </template>
  </div>
</template>
<script>
export default {
  title: '地图',
  props: {
    selectdata: {
      type: Object
    }
  },
  data () {
    return {
    }
  },
  ready () {
    console.log('-----------------------进入地图-------------------------')
  },
  methods: {
    locationclick (res) {
      console.log('=======选点回调=======')
      console.log(res)

      this.$dispatch('locationclick', res)
    }
  },
  events: {
  },
  computed: {
    markmapdata () {
      if (!this.selectdata.f_lng || !this.selectdata.f_lat) {
        return null
      }
      return {
        name: `${this.selectdata.f_user_name}`,
        address: `${this.selectdata.f_order_address}`,
        location: {
          Q: this.selectdata.f_lat,
          R: this.selectdata.f_lng,
          lat: this.selectdata.f_lat,
          lng: this.selectdata.f_lng
        }
      }
    },
    labelmarksarray () {
      return [{
        data: {
          data: this.selectdata,
          label: `<div style="background: #fff;border-radius: 5px;height: 100px;padding: 5px">
                  <h5>${this.selectdata.f_user_name}</h5>
                  <h5>${this.selectdata.f_phone}</h5>
                  <h5>${this.selectdata.f_order_address}</h5>
                </div>`
        },
        position: [this.selectdata.f_lng, this.selectdata.f_lat],
        isclearmarker: false
      }]
    }
  },
  watch: {
  }
}
</script>
<style scoped>
</style>
