<template>
  <view class="content p-10">
    <u-subsection :list="subsectionList" :current="subsectionCurrent"
                  @change="subsectionChange"></u-subsection>
    <template v-if="subsectionCurrent === 0">
      <view class="card">
        <view class="view-title">
          <u--text text="基本信息" bold></u--text>
        </view>
        <u-cell-group :border="false" class="mt-10">
          <u-cell>
            <view slot="title" class="title">分公司名称：</view>
            <view slot="value">{{ form.CORP_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">登录账号：</view>
            <view slot="value">{{ form.CORP_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">属地：</view>
            <view slot="value" v-if="form.PROVINCE_VAL">{{ form.PROVINCE_VAL }}/</view>
            <view slot="value" v-if="form.CITY_VAL">{{ form.CITY_VAL }}/</view>
            <view slot="value" v-if="form.COUNTRY_VAL">{{ form.COUNTRY_VAL }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">企事业单位经营地址：</view>
            <view slot="value">{{ form.ADDRESS_BUSINESS }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">统一社会信用代码：</view>
            <view slot="value">{{ form.CODE }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">分公司状态：</view>
            <view slot="value">{{ form.CORP_STATE_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">行业分类：</view>
            <view slot="value">{{ form.ECO_TYPE_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">成立日期：</view>
            <view slot="value">{{ form.CREATE_DATE }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">占地面积：</view>
            <view slot="value">{{ form.AREA_COVERED }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">注册资金：</view>
            <view slot="value">{{ form.REGCAPITAL }}万元</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">资产总额：</view>
            <view slot="value">{{ form.TOTALASSETS }}万元</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">职工人数：</view>
            <view slot="value">{{ form.EMPLOYEES }}人</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">经度/纬度：</view>
            <view slot="value" v-if="form.LONGITUDE">{{ form.LONGITUDE }} - {{ form.LATITUDE }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">企业经济类型：</view>
            <view slot="value">{{ form.ECO_TYPE_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">企业角色组：</view>
            <view slot="value">{{ form.ROLENAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">隶属关系：</view>
            <view slot="value">{{ form.SUBORDINATION_VAL }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">企业规模：</view>
            <view slot="value">{{ form.SCALE_VAL }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">是否规模以上：</view>
            <view slot="value">{{ form.SCALE_TYPE == 0 ? '否' : '是' }}</view>
          </u-cell>
        </u-cell-group>
      </view>
      <view class="card">
        <view class="view-title">
          <u--text text="法定代表人信息" bold></u--text>
        </view>
        <u-cell-group :border="false" class="mt-10">
          <u-cell>
            <view slot="title" class="title">姓名：</view>
            <view slot="value">{{ form.LR_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">手机号码：</view>
            <view slot="value">{{ form.LR_PHONE }}</view>
          </u-cell>
        </u-cell-group>
      </view>
      <view class="card">
        <view class="view-title">
          <u--text text="主要负责人信息" bold></u--text>
        </view>
        <u-cell-group :border="false" class="mt-10">
          <u-cell>
            <view slot="title" class="title">姓名：</view>
            <view slot="value">{{ form.CONTACTS }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">手机号码：</view>
            <view slot="value">{{ form.CONTACTS_PHONE }}</view>
          </u-cell>
        </u-cell-group>
      </view>
	  <view class="card" v-if="form.SAFETY_NAME">
	    <view class="view-title">
	      <u--text text="安全负责人信息" bold></u--text>
	    </view>
	    <u-cell-group :border="false" class="mt-10">
	      <u-cell>
	        <view slot="title" class="title">姓名：</view>
	        <view slot="value">{{ form.SAFETY_NAME }}</view>
	      </u-cell>
	      <u-cell>
	        <view slot="title" class="title">手机号码：</view>
	        <view slot="value">{{ form.SAFETY_PHONE }}</view>
	      </u-cell>
	    </u-cell-group>
	  </view>
    </template>
    <template v-if="subsectionCurrent === 1">
      <u-list v-if="list.length > 0">
        <u-list-item v-for="(item, index) in list" :key="index">
          <view>
            <view class="flex-between main-title">
              <text>{{ item.NAME }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>证书有效期：{{ item.VALIDITYTIME }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>证书编号：{{ item.NUMBER }}</text>
            </view>
            <view class="flex-end mt-10">
              <u-button type="primary" text="查看" size="mini" class="bth-mini"
                        @click="fnNavigatorDetail(item.QUALIFICATIONS_ID,'','/pages/branch-information-management/branch-information/qualification')"></u-button>
            </view>
          </view>
        </u-list-item>
      </u-list>
    </template>
    <template v-if="subsectionCurrent === 2">
      <u-list v-if="list.length > 0">
        <u-list-item v-for="(item, index) in list" :key="index">
          <view>
            <view class="flex-between main-title">
              <text>姓名：{{ item.NAME }}</text>
              <text>性别：{{ item.SEX }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>人员类型：{{ item.PERSONNEL_TYPE }}</text>
              <text>在职情况：{{ item.INDUSTRY }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>职务：{{ item.DUTIES }}</text>
            </view>
          </view>
        </u-list-item>
      </u-list>
    </template>
    <template v-if="subsectionCurrent === 3">
      <u-list v-if="list.length > 0">
        <u-list-item v-for="(item, index) in list" :key="index">
          <view>
            <view class="flex-between main-title">
              <text>姓名：{{ item.INFOR_NAME }}</text>
              <text>性别：{{ item.INFORSEX == '0' ? '男' : '女' }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>证照名称：{{ item.CERTIFICATENAME }}</text>
              <text>职务：{{ item.INFORPOSTNAME }}</text>
            </view>
            <view class="flex-between mt-10 subtitle">
              <text>有效期：{{ item.TERMOFVALIDITY }}</text>
            </view>
            <view class="flex-end mt-10">
              <u-button type="primary" text="查看" size="mini" class="bth-mini"
                        @click="fnNavigatorDetail('',item.INFOR_ID,'/pages/branch-information-management/branch-information/personnel')"></u-button>
            </view>
          </view>
        </u-list-item>
      </u-list>
    </template>
    <empty v-if="list.length === 0 && subsectionCurrent !== 0"></empty>
  </view>
</template>

<script>
import {
  getCorpInfoGoEdit, getCorpInfoLicenseList,
  getCorpInfoPersonregistration,
  getCorpInfoQualification
} from "../../../api";

export default {
  data() {
    return {
      subsectionList: ['基础信息', '资质证照', '入职从业人员', '人员证照'],
      subsectionCurrent: 0,
      list: [],
      form: {},
      CORPINFO_ID: ''
    }
  },
  onLoad(event) {
    this.CORPINFO_ID = event.CORPINFO_ID
    if (this.CORPINFO_ID) {
      this.fnGetCorpInfoGoEdit()
    }
  },
  methods: {
    async fnGetCorpInfoGoEdit() {
      let resData = await getCorpInfoGoEdit({
        CORPINFO_ID: this.CORPINFO_ID
      })
      this.form = resData.pd
    },
    async fnGetCorpInfoPersonregistration() {
      let resData = await getCorpInfoPersonregistration({
        CORPINFO_ID: this.CORPINFO_ID
      })
      this.list = resData.userList
    },
    async fnGetCorpInfoQualification() {
      let resData = await getCorpInfoQualification({
        CORPINFO_ID: this.CORPINFO_ID
      })
      this.list = resData.varList
    },
    async fnGetCorpInfoLicenseList() {
      let resData = await getCorpInfoLicenseList({
        CORPINFO_ID: this.CORPINFO_ID
      })
      this.list = resData.userList
    },
    subsectionChange(index) {
      this.subsectionCurrent = index
      if (index === 0) this.fnGetCorpInfoGoEdit()
      if (index === 1) this.fnGetCorpInfoQualification()
      if (index === 2) this.fnGetCorpInfoPersonregistration()
      if (index === 3) this.fnGetCorpInfoLicenseList()
    },
    fnNavigatorDetail(QUALIFICATIONS_ID, INFOR_ID, url) {
      uni.$u.route({
        url,
        params: {
          QUALIFICATIONS_ID,
          INFOR_ID,
        }
      })
    }
  },
}
</script>

<style scoped>

</style>
