<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 wd-text-16" style="margin-bottom: 4px">{{ detail.enterprisesName }}</text>
          <view class="address">
            <u-icon name="map" size="14" color="#17C653"></u-icon>
            {{ detail.address }}
          </view>
        </view>
        <view class="wd-flex" style="align-items: center">
          <text class="address" style="margin-right: 8px">环保负责人</text>
          <text style="margin-right: 16px">{{ detail.enterprisesName }}</text>
          <text class="address" style="margin-right: 8px">联系方式</text>
          <text style="text-decoration: underline">{{ detail.environmentalContactPhone }}</text>
        </view>
        <view class="images-box">
          <image v-for="(src, index) in detail.files" :key="index" :src="src.url" mode="widthFix" class="image"></image>
        </view>
        <text class="address">{{ detail.introduction }}</text>
      </view>

      <view class="box wd-text-12" v-for="prove in detail.qualificationList" :key="prove.id">
        <view class="wd-flex" style="gap: 8px">
          <image src="@/static/images/enterprise/zz.png" style="width: 90px; height: 70px" mode="widthFix"></image>
          <view style="flex: 1; justify-content: space-between" class="wd-flex wd-flex-col">
            <view class="wd-flex" style="gap: 8px; align-items: center">
              <text class="label">资质名称</text>
              <view>
                {{ $dict.echoDicValue(dictMap.enterprise_qua, prove.qualificationName.toString()) }}
              </view>
            </view>
            <view class="wd-flex" style="gap: 8px; align-items: center">
              <text class="label">资质编号</text>
              <view>
                {{ prove.enterpriseAuth }}
              </view>
            </view>
            <view class="wd-flex" style="gap: 8px; align-items: center">
              <text class="label">资质时限</text>
              <view>
                {{ $util.formatDate(prove.handleDate, 'YYYY/M/D') }}~
                {{ $util.formatDate(prove.expiryDate, 'YYYY/M/D') }}
              </view>
            </view>
          </view>
        </view>
      </view>

      <view class="box">
        <view class="wd-font-800">执法记录</view>
      </view>

      <view class="button-box">
        <view class="button">确认审核</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.switchTab({
        url: '/pages/enterprise'
      })
    }
  }
}
</script>

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

  .images-box {
    display: flex;
    flex-flow: row nowrap;
    gap: 12px;
    .image {
      border-radius: $cs-border-radius;
    }
  }
}
.label {
  color: $uni-text-color-grey;
}
.icon-box {
  position: absolute;
  left: 0;
}
.button-box {
  width: 100%;
  bottom: 0;
  position: fixed;
  background-color: #fff;
  display: flex;
  left: 0;
  padding: var(--Number-12px, 12px);
  padding-bottom: 25px;
  align-items: center;
  gap: var(--Number-12px, 12px);
  .button {
    display: flex;
    padding: var(--Number-12px, 12px) 0px;
    justify-content: center;
    align-items: center;
    gap: var(--Number-12px, 12px);
    flex: 1 0 0;
    background: #17c653;
    border-radius: var(--Number-4px, 4px);
    background: var(--LightMode-Success-Success-Light, #eafff1);
    color: var(--LightMode-Success-Success, #17c653);
    text-align: center;
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: normal;
  }
}
</style>