<!--
  @description: 查看机构之公司基本信息
  @author: hdk
  @date:  2020-11-04 16:42:31
-->
<template>
  <div>
    <!--机构详情-->
    <div class="page-title">
      1.基本信息
    </div>
    <table class="tableData">
      <tr>
        <td>
          <span>上级单位</span>
        </td>
        <td colspan="3">
          <span>
            {{ organizationInfo.parentDepartName }}
          </span>
        </td>
      </tr>
      <tr>
        <td>
          <span>机构名称</span>
        </td>
        <td colspan="3">
          <span>
            {{ organizationInfo.departName }}
          </span>
        </td>
      </tr>
      <tr>
        <td>
          <span>机构属性</span>
        </td>
        <td>
          {{ filterDictText(orgTypeList,organizationInfo.orgType) }}
        </td>
        <td>
          <span>联系电话</span>
        </td>
        <td>
          <span>
            {{ organizationInfo.linktel }}
          </span>
        </td>
      </tr>
      <tr v-if="organizationInfo.orgType !== '2'">
        <td>
          <span>统一社会信用代码</span>
        </td>
        <td>
          <span>
            {{ organizationInfo.orgCode }}
          </span>
        </td>
        <td>
          <span>企业性质</span>
        </td>
        <td>
          <span>
            {{ filterDictText(entPrptList,organizationInfo.entPrpt) }}
          </span>
        </td>
      </tr>
      <tr v-if="organizationInfo.orgType !== '2'">
        <td>
          <span>联系地址</span>
        </td>
        <td colspan="3">
          <span>
            {{ organizationInfo.address }}
          </span>
        </td>
      </tr>
      <tr v-if="organizationInfo.orgType !== '2'">
        <td>
          <span>营业执照扫描件</span>
        </td>
        <td colspan="3">
          <span>
            <downloadFile :data="businessUpLoadData" :dis-block="'block'" />
          </span>
        </td>
        <!-- <td>
          <span>营业执照有效期</span>
        </td>
        <td>
          <span>
            {{ organizationInfo.auditNotPassReason }}
          </span>
        </td> -->
      </tr>
    </table>
    <div v-if="organizationInfo.orgType !== '2'" class="page-title">
      2.财务信息
    </div>
    <table v-if="organizationInfo.orgType !== '2'" class="tableData">
      <tr>
        <td>开户银行</td>
        <td>
          <span>
            {{ organizationInfo.bankName }}
          </span>
        </td>
        <td>账号</td>
        <td>
          <span>
            {{ organizationInfo.bankaccount }}
          </span>
        </td>
      </tr>
      <tr>
        <td>注册资本(万元)</td>
        <td>
          <span>
            {{ organizationInfo.regcapital }}
          </span>
        </td>
        <td>币种</td>
        <td>
          <span>
            {{ organizationInfo.currencies }}
          </span>
        </td>
      </tr>
    </table>
    <table class="tableData">
      <tr style="visibility:hidden;">
        <td />
        <td />
        <td />
        <td />
      </tr>
      <tr>
        <td>状态</td>
        <td colspan="3">
          <span v-if="organizationInfo.useStatus">
            {{ filterDictText(useStatusList,organizationInfo.useStatus) }}
          </span>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
/* api */
import { getBasicDepartInfoVo } from '@/api/rolemanagment/organization'
/* 公共混入 */
import { organizationCommonMixin } from '../mixins/organizationCommonMixin'
import { organizationGroupMixin } from '../mixins/organizationGroupMixin'
/* 公共方法 */
import { filterDictText } from '@/assets/js/utils'// 常用方法
/* 组件 */
import downloadFile from '@comp/common/updownload/downloadFile' // 获取附件信息 下载组件

export default {
  name: 'OrganizationInfoDetailComp',
  components: {
    downloadFile // 文件下载
  },
  mixins: [organizationCommonMixin, organizationGroupMixin],
  props: {
    // 当前选中机构信息
    organizationInformation: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      organizationInfoInit: { // 机构基本信息
        parentDepartName: '', // 上级单位名称
        parentdepartid: '', // 上级单位id
        departName: '', // 机构名称
        departId: '', // 机构id
        orgType: '', // 机构属性
        linktel: '', // 联系电话
        orgCode: '', // 统一社会信用代码
        entPrpt: '', // 企业性质
        areaValue: '', // 联系地址
        address: '', // 详细地址
        bankName: '', // 开户银行
        bankaccount: '', // 账号
        regcapital: '', // 注册资本(万元)
        currencies: '' // 币种
      },
      organizationInfo: {} // 机构基本信息
    }
  },
  watch: {
    organizationInformation: {
      handler(newVal, oldVal) {
        // 请求机构基本信息
        this.getBasicDepartInfo()
      },
      deep: true
    }
  },
  created() {
    // 获取字典
    this.getGroup(['entPrpt'])
    // 数据初始化
    this.organizationInfo = JSON.parse(JSON.stringify(this.organizationInfoInit))
    // 获取机构基本信息
    this.getBasicDepartInfo()
  },
  methods: {
    filterDictText,
    getBasicDepartInfo() {
      if (this.organizationInformation.id) {
        // 是否是机构树第一层
        if (this.organizationInformation.orgType !== '0') {
          const params = {
            id: this.organizationInformation.id
          }
          // 请求机构基本信息
          getBasicDepartInfoVo(params).then(res => {
            this.organizationInfo = res.data
            this.businessUpLoadData.bizId = res.data.businesslicenceAttr
          }).catch(() => {
          })
        } else {
          // 数据初始化
          this.organizationInfo = JSON.parse(JSON.stringify(this.organizationInfoInit))
        }
      }
    }
  }
}
</script>

<style lang="less" scoped>
.bottom-btn {
  text-align: center;
  padding: 15px;
}
</style>
