<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.username }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="联系电话">
                <span>{{ detailInfo.phone }}</span>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="身份证">
                <span>{{ detailInfo.idcard }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="营业网点">
                <span>{{ $parent.branchFormat(this.detailInfo) }}</span>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="用户编号">
                <span>{{ detailInfo.usernum }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="表具厂家">
               {{$parent.companyFormat(this.detailInfo)}}
              </el-form-item>
            </el-col>
          </el-row>


          <el-row>
            <el-col :span="12">
              <el-form-item label="表具编号">
                <span>{{ detailInfo.meternum }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="表具位置">
                <span v-if="detailInfo.position==1">单元屋内</span>
                <span v-if="detailInfo.position==2">单元屋外</span>
                <span v-if="detailInfo.position==3">院内</span>
                <span v-if="detailInfo.position==4">院外</span>
                <span v-if="detailInfo.position==null">-</span>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="20">
              <el-form-item label="所属区域">
                <span>{{ detailInfo.countyName }}{{ detailInfo.streetName }}{{ detailInfo.villageName }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <el-form-item label="具体地址">
                <span>{{ detailInfo.address }}</span>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="通气日期">
                <span v-if="detailInfo.starttime">{{ detailInfo.starttime}}</span>
                <span v-else>-</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="开通状态">
                <span>{{ $parent.statusFormat(this.detailInfo) }}</span>
              </el-form-item>
            </el-col>
          </el-row>



          <el-row>
            <!--<el-col :span="12">-->
              <!--<el-form-item label="表具型号">-->
                <!--<span v-if="detailInfo.meterModel==1">G1.5</span>-->
                <!--<span v-if="detailInfo.meterModel==2">G2.5</span>-->
                <!--<span v-if="detailInfo.meterModel==3">G4</span>-->
                <!--<span v-if="detailInfo.meterModel==null">-</span>-->
              <!--</el-form-item>-->
            <!--</el-col>-->
            <el-col :span="12">
              <el-form-item label="进气方向">
                <span v-if="detailInfo.direction==1">左</span>
                <span v-if="detailInfo.direction==2">右</span>
                <span v-if="detailInfo.direction==null">-</span>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="24">
              <el-form-item label="用户照片">
                <MyImage
                  v-if="detailInfo.imgurl"
                  :src="detailInfo.imgurl.split(',')[0]"
                  :previewSrcList="detailInfo.imgurl.split(',')"
                />
                <div class="error" v-else>暂无图片</div>
              </el-form-item>
            </el-col>
          </el-row>


          <el-row>
            <el-col :span="24">
              <el-form-item label="备注">
                <span v-if="detailInfo.remark">{{ detailInfo.remark }}</span>
                <span v-else>-</span>
              </el-form-item>
            </el-col>
          </el-row>


        </el-form>
      </el-col>
      <el-col :span="10">
        <div id="jm_map" style="width: 100%;height: 500px;border: 1px solid"></div>
      </el-col>
    </el-row>

  </el-dialog>

</template>

<script>
  //import { getInfo } from "@/api/baseinfo/deviceInfo";
  import {  getUser } from "@/api/baseinfo/user";
  import { EditorMap } from "@/utils/mapClass/map";
  import { mapGetters } from "vuex";
  import MyImage from "@/components/MyImage/index.vue";
  export default {
    name: "detail-info",
    components:{
      MyImage
    },
    data(){
      return{
        open: false,
        detailInfo: {},
        title: "",
        // 开通状态字典
        statusOptions: [],
        typeOptions:[],
        sceneOptions:[],
        dialogTableVisibles: false,
        bjlxList:[
          {
            id:1,
            name:'皮膜'
          },
          {
            id:2,
            name:"超声"
          }
        ],
        bjcjList:[
          {
            id:1,
            name:'金卡'
          },
          {
            id:2,
            name:"秦川"
          }
        ],
        bjxhList:[
          {
            id:1,
            name:'G1.5'
          },
          {
            id:2,
            name:"G2.5"
          },
          {
            id:3,
            name:"G4"
          }
        ],
        jqfxList:[
          {
            id:1,
            name:'左'
          },
          {
            id:2,
            name:"右"
          }
        ],
      }
    },

    methods: {
      getDetailInfo(userId){
        getUser(userId).then(response => {
          this.detailInfo = response.data;
          this.title = "居民用户信息详情";
          this.open = true;
          this.initMap();
        });
      },

      initMap(){
        this.$nextTick(() => {
            const path = eval(this.systemSetting.map_center);
            let map = new EditorMap(
                "jm_map",
                {
                  center: path,
                  //mapStyle: "amap://styles/f71d3a3d73e14f5b2bf5508bf1411758",
                  zoom: 14.5,
                },
                this
             );
            if(this.detailInfo.longitude){
              map.control = 1;
              map.addDevice(this.detailInfo);
              map.map.setCenter([this.detailInfo.longitude,this.detailInfo.latitude])
            }
        });
      }
    },
    computed: {
      ...mapGetters(["systemSetting"]),
    },
  }
</script>

<style scoped>

</style>
