<template>
  <div>
      <el-dialog
        v-dialogDrag
        :visible.sync="showModal"
        width="700px"
        title="企业详情"
      >
      <div class="maxHeight">
        <table class="tableClass">
          <tbody>
            <tr>
              <th>企业名称</th>
              <td>{{ obj.name }}</td>
              <th>营业执照编号</th>
              <td>{{ obj.busno }}</td>
            </tr>
            <tr>
              <th>联系人</th>
              <td>{{ obj.contact }}</td>
              <th>手机号</th>
              <td>{{ obj.contactWay }}</td>
            </tr>
            <tr>
              <th>省、市、区</th>
              <td>{{ province }} {{city}} {{area}}</td>
              <th>街道</th>
              <td>{{ obj.contactAddress }}</td>
            </tr>
            <tr>
              <th>经度</th>
              <td>{{ obj.longitude }}</td>
              <th>纬度</th>
              <td>{{ obj.latitude }}</td>
            </tr>
            <tr>
              <th>电话</th>
              <td colspan="3">
                {{ obj.phone }}
              </td>
            </tr>
            <tr>
              <th>传真</th>
              <td>{{ obj.fax }}</td>
              <th>邮编</th>
              <td>{{ obj.zipcode }}</td>
            </tr>
            <tr>
              <th>网址</th>
              <td>{{ obj.website }}</td>
              <th>二级域名</th>
              <td>{{ obj.domain }}</td>
            </tr>
            <tr>
              <th>类型</th>
              <td v-if="obj.type === 1">
                第一方企业
              </td>
              <td v-if="obj.type === 2">
                第三方检测
              </td>
              <td v-if="obj.type === 3">
                其它
              </td>
              <th>通知微信</th>
              <td v-if="obj.notifyWechat === 1">
                是
              </td>
              <td v-if="obj.notifyWechat === 0">
                否
              </td>
            </tr>
            <tr>
              <th>业务类型</th>
              <td>{{ obj.business }}</td>
              <th>状态</th>
              <td>{{ obj.status === 0 ? '禁用':'正常' }}</td>
            </tr>
            <tr>
              <th>排序</th>
              <td>{{ obj.sort }}</td>
              <th>备注</th>
              <td>
                {{ obj.remark }}
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      </el-dialog>
  </div>
</template>
<script>
/**
 * 公司表详情
 */
import { sysCompany, sysCity, sysArea, sysProvince } from '../../../api'
export default {
  data() {
    return {
      obj: {},
      showModal: false,
      province: '',
      city: '',
      area: ''
    }
  },
  methods: {
    _open: async function(id) {
      const result = await sysCompany.getById(id)
      this.showModal = true
      this.obj = result
      this._initData(result)
    },
    _getProvince: async function(obj) {
      const result = await sysProvince.list(obj)
      this.province = result[0].cn
    },
    _getCity: async function(obj) {
      const result = await sysCity.list(obj)
      this.city = result[0].cn
    },
    _getArea: async function(obj) {
      const result = await sysArea.list(obj)
      this.area = result[0].cn
    },
    // 回显省市区
    _initData(obj) {
      // 省
      if (obj.provinceCode) {
        this._getProvince({ code: obj.provinceCode })
      } else {
        this.province = ''
      }
      // 市
      if (obj.cityCode) {
        this._getCity({ code: obj.cityCode })
      } else {
        this.city = ''
      }
      // 区
      if (obj.areaCode) {
        this._getArea({ code: obj.areaCode })
      } else {
        this.area = ''
      }
    }
  }
}
</script>
