<template>
  <a-modal
    centered
    class="dealerAccountDetail-modal"
    :footer="null"
    :maskClosable="false"
    title="详情"
    v-model="isShow"
    @cancel="isShow=false"
    :width="800">
    <div>
      <a-descriptions bordered size="small" :column="2">
        <a-descriptions-item label="经销商名称：">{{ (detailData&&detailData.org&&detailData.org.name) ? detailData.org.name : '--' }}</a-descriptions-item>
        <a-descriptions-item label="管理员姓名：">{{ detailData&&detailData.name ? detailData.name : '--' }}</a-descriptions-item>
        <a-descriptions-item label="管理员手机：">{{ detailData&&detailData.phone ? detailData.phone : '--' }}</a-descriptions-item>
        <a-descriptions-item label="管理员账号：">{{ detailData&&detailData.loginName ? detailData.loginName : '--' }}</a-descriptions-item>
        <a-descriptions-item label="最大可开通用户数（含管理员账号）：">{{ (detailData&&detailData.org&&detailData.org.childUserMaxNum) ? detailData.org.childUserMaxNum : '--' }}</a-descriptions-item>
      </a-descriptions>
      <div class="btn-cont"><a-button id="dealerAccountDetail-modal-back" @click="isShow = false">关闭</a-button></div>
    </div>
  </a-modal>
</template>

<script>
// 接口
import { dealerUserDetail } from '@/api/dealer'
export default {
  name: 'DealerAccountDetailModal',
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    },
    itemId: {
      type: [Number, String],
      default: ''
    }
  },
  data () {
    return {
      isShow: this.openModal, //  是否打开弹框
      detailData: null //  详情数据
    }
  },
  methods: {
    //  获取详情
    getDetail () {
      dealerUserDetail({ id: this.itemId }).then(res => {
        if (res.status == 200) {
          this.detailData = res.data
        } else {
          this.detailData = null
        }
      })
    }
  },
  watch: {
    //  父页面传过来的弹框状态
    openModal (newValue, oldValue) {
      this.isShow = newValue
      this.detailData = null
    },
    //  重定义的弹框状态
    isShow (newValue, oldValue) {
      if (!newValue) {
        this.$emit('close')
      }
    },
    itemId (newValue, oldValue) {
      if (this.isShow && newValue) {
        this.getDetail()
      }
    }
  }
}
</script>

<style lang="less">
  .dealerAccountDetail-modal{
    .ant-modal-body {
      padding: 40px 40px 24px;
    }
    .ant-descriptions-item-label.ant-descriptions-item-colon{
      width: 133px;
    }
    .btn-cont {
      text-align: center;
      margin: 35px 0 10px;
    }
  }
</style>
