<template>
  <cs-page isCustom>
    <template #header>
      <view class="wd-flex wd-flex-row wd-flex-center" style="position: relative" @click="goBack">
        <view class="icon-box">
          <u-icon name="arrow-left" size="12"></u-icon>
        </view>
        <view class="wd-font-800 wd-text-16">企业档案</view>
      </view>
    </template>
    <view class="detail-container">
      <view class="box detail">
        <view>
          <text class="wd-font-800">{{ detail.enterprisesName }}</text>
        </view>
        <view class="address">企业地址 {{ detail.address }}</view>
        <text>{{ detail.introduction }}</text>
        <view class="images-box">
          <image v-for="(src, index) in detail.files" :key="index" :src="src" mode="widthFix" class="image"></image>
        </view>
        <view>
          <text class="address" style="margin-right: 8px">环保负责人</text>
          <text style="margin-right: 8px">{{ detail.enterprisesName }}</text>
          <text style="text-decoration: underline">{{ detail.environmentalContactPhone }}</text>
        </view>
        <view>
          <text class="address" style="margin-right: 8px">成立时间</text>
          <text>{{ $util.formatDate(detail.establishmentDate, 'YYYY年M月D日') }}</text>
        </view>
        <view class="prove-list">
          <view class="prove" v-for="prove in detail.qualificationList" :key="prove.id">
            <view>
              {{ $dict.echoDicValue(dictMap.enterprise_qua, prove.qualificationName.toString()) }}
            </view>
            <view class="">
              {{ $util.formatDate(prove.handleDate, 'YYYY年M月D日') }}-
              {{ $util.formatDate(prove.expiryDate, 'YYYY年M月D日') }}
            </view>
          </view>
        </view>
      </view>
      <!-- 
      <view class="box">
        <view class="wd-font-800">资质许可</view>
     
      </view> -->

      <view class="box">
        <view class="wd-font-800">实时监控</view>
      </view>

      <view class="box">
        <view class="wd-font-800">检查记录</view>
      </view>
    </view>
  </cs-page>
</template>

<script>
import { getEnterPrise } from '@/api/enterprise/index.js'
import { getDictBatchByType } from '@/api/system/dict.js'
export default {
  data() {
    return {
      detail: {
        id: ''
      },
      dictMap: {}
    }
  },
  onLoad(res) {
    if (res.id) {
      this.detail.id = res.id
    }
    this.getDict()
    this.init()
  },
  methods: {
    /**
     * 获取字典
     */
    async getDict() {
      const dict = await getDictBatchByType({ type: ['enterprises_type', 'enterprise_qua'].join(',') })
      this.dictMap = {
        ...dict.data
      }
    },
    async init() {
      const res = await getEnterPrise(this.detail.id)
      this.detail = res.data
    },
    goBack() {
      uni.navigateBack()
    }
  }
}
</script>

<style lang="scss" scoped>
.detail-container {
  padding: 12px;
  .box {
    margin-bottom: 12px;
    background-color: #fff;
    border-radius: $cs-border-radius;
    padding: 16px;
  }
  .detail {
    display: flex;
    flex-flow: column nowrap;
    gap: 16px;
    .address {
      color: $uni-text-color-grey;
    }
  }

  .images-box {
    display: flex;
    flex-flow: row nowrap;
    gap: 12px;
    .image {
      border-radius: $cs-border-radius;
    }
  }
  .prove-list {
    display: flex;
    flex-flow: column nowrap;
    gap: 5px;
    .prove {
      border: 1px solid $uni-color-primary;
      padding: 5px 10px;
      border-radius: 6px;
      color: $uni-color-primary;
      background-color: #ecf5ff;
    }
  }
}
.icon-box {
  position: absolute;
  left: 0;
}
</style>
