<template>
  <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body destroy-on-close>
    <el-row>
      <el-col :span="14">
        <el-form label-width="100px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="小区名称">
                <span>{{ detailInfo.name }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="简称">
                <span>{{ detailInfo.sname?detailInfo.sname:'-' }}</span>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="区域类型">
                <span>{{ detailInfo.areatypeName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="居民总数">
                <span>{{ detailInfo.usersNum?detailInfo.usersNum:'-' }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="所属区域" >
              <span>{{(detailInfo.cityName?detailInfo.cityName+ '-':'')+(detailInfo.countyName?detailInfo.countyName+'-':'')+(detailInfo.streetName?detailInfo.streetName:'') }}</span>
            </el-form-item>
          </el-row>


          <el-row>
            <el-col :span="24">
              <el-form-item label="详细地址">
                <span>{{ detailInfo.address?detailInfo.address:'-' }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="备注">
                <span>{{ detailInfo.remark?detailInfo.remark:'-' }}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="10">
        <div id="com_map" style="width: 100%;height: 400px;border: 1px solid"></div>
      </el-col>
    </el-row>

  </el-dialog>

</template>

<script>
  import { getCommunity } from "@/api/baseinfo/community";
  import { EditorMap } from "@/utils/mapClass/map";
  import { mapGetters } from "vuex";
  export default {
    name: "detail-info",
    data(){
      return{
        open: false,
        detailInfo: {},
        title: "",
      }
    },

    methods: {
      getDetailInfo(cId){
        getCommunity(cId).then(response => {
          this.detailInfo = response.data;
          this.title = "小区信息详情";
          this.open = true;
          this.initMap();
        });
      },
      initMap(){
        this.$nextTick(() => {
            const path = eval(this.systemSetting.map_center);
            let com_map = new EditorMap(
                "com_map",
                {
                  center: path,
                  //mapStyle: "amap://styles/f71d3a3d73e14f5b2bf5508bf1411758",
                  zoom: 14.5,
                },
                this
             );
            if(this.detailInfo.longitude){
              com_map.control = 1;
              com_map.addDevice(this.detailInfo);
              com_map.setCenter([this.detailInfo.longitude,this.detailInfo.latitude])
            }
        });
      }
    },
    computed: {
      ...mapGetters(["systemSetting"]),
    },
  }
</script>

<style scoped>

</style>
