<template>
  <!-- 风险总览 -->
  <view class="risk-overview">
    <view class="crop-name">{{corpInfo.qc}}</view>
    <!-- <view class="overview">
      <view class="title">风险扫描</view>
      <view class="item">
        <view class="label">
          <view class="name">处罚信息</view>
          <view class="count">{{riskInfo.cfhfxCountResVo.cfxxCount}}</view>
        </view>
        <view class="value" v-if="riskInfo.cfhfxCountResVo.cfxxCount === 0">暂无处罚信息</view>
        <view class="value" v-else>该企业有处罚信息({{riskInfo.cfhfxCountResVo.cfxxCount}}条)</view>
      </view>
      <view class="item">
        <view class="label">
          <view class="name">严重失信</view>
          <view class="count">{{riskInfo.cfhfxCountResVo.yzsxCount}}</view>
        </view>
        <view class="value" v-if="riskInfo.cfhfxCountResVo.yzsxCount === 0">暂无严重失信行为</view>
        <view class="value" v-else>该企业有严重失信行为({{riskInfo.cfhfxCountResVo.yzsxCount}}条)</view>
      </view>
      <view class="item">
        <view class="label">
          <view class="name">经营异常</view>
          <view class="count">{{riskInfo.cfhfxCountResVo.jyycCount}}</view>
        </view>
        <view class="value" v-if="riskInfo.cfhfxCountResVo.jyycCount === 0">暂无经营异常信息</view>
        <view class="value" v-else>该企业有经营异常信息({{riskInfo.cfhfxCountResVo.jyycCount}}条)</view>
      </view>
    </view> -->
    
    <view v-if="title==='处罚信息'">
      <view class="content" v-if="riskCount.cfxxCount > 0">
        <view class="list" v-for="(item, index) in riskInfo" :key="index">
          <view class="item">
            <view class="label">决定书文号：</view>
            <view class="value">{{item.cfJdswh}}</view>
          </view>
          <view class="item">
            <view class="label">违法行为类型：</view>
            <view class="value">{{item.cfWfxwlx}}</view>
          </view>
          <view class="item">
            <view class="label">决定机关名称：</view>
            <view class="value">{{item.cfJdjgmc}}</view>
          </view>
          <view class="item">
            <view class="label">处罚决定日期：</view>
            <view class="value">{{item.cfCfjdrq}}</view>
          </view>
          <view class="item">
            <view class="label">处罚内容：</view>
            <view class="value">{{item.cfXzcfnr}}</view>
          </view>
        </view>
      </view>
      <view class="no-content" v-else>暂无处罚信息</view>
    </view>
    <view v-if="title==='严重失信'">
      <view class="content" v-if="riskCount.yzsxCount > 0">
        <view class="list" v-for="(item, index) in riskInfo" :key="index">
          <view class="item">
            <view class="label">类别：</view>
            <view class="value">{{item.sxLb}}</view>
          </view>
          <view class="item">
            <view class="label">列入严重违法失信名单(黑名单)原因：</view>
            <view class="value">{{item.sxLryzwfsxmdyy}}</view>
          </view>
          <view class="item">
            <view class="label">列入日期：</view>
            <view class="value">{{item.sxLrrq}}</view>
          </view>
          <view class="item">
            <view class="label">作出决定机关(列入)：</view>
            <view class="value">{{item.sxZcjdjglr}}</view>
          </view>
          <view class="item">
            <view class="label">移出严重违法失信名单(黑名单)原因：</view>
            <view class="value">{{item.sxYcyzwfsxmdyy}}</view>
          </view>
          <view class="item">
            <view class="label">移出日期：</view>
            <view class="value">{{item.sxYcrq}}</view>
          </view>
          <view class="item">
            <view class="label">作出决定机关(移出)：</view>
            <view class="value">{{item.sxZcjdjgyc}}</view>
          </view>
        </view>
      </view>
      <view class="no-content" v-else>暂无严重失信行为</view>
    </view>
    <view v-if="title==='经营异常'">
      <view class="content" v-if="riskCount.jyycCount > 0">
        <view class="list" v-for="(item, index) in riskInfo" :key="index">
          <view class="item">
            <view class="label">列入经营异常名录原因：</view>
            <view class="value">{{item.ycLrjyycmlyy}}</view>
          </view>
          <view class="item">
            <view class="label">列入日期：</view>
            <view class="value">{{item.ycLrrq}}</view>
          </view>
          <view class="item">
            <view class="label">作出决定机关(列入)：</view>
            <view class="value">{{item.ycZcjdjglr}}</view>
          </view>
          <view class="item">
            <view class="label">移出经营异常名录原因：</view>
            <view class="value">{{item.ycYcjyycmlyy}}</view>
          </view>
          <view class="item">
            <view class="label">移出日期：</view>
            <view class="value">{{item.ycYcrq}}</view>
          </view>
          <view class="item">
            <view class="label">作出决定机关(移出)：</view>
            <view class="value">{{item.ycZcjdjgyc}}</view>
          </view>
        </view>
      </view>
      <view class="no-content" v-else>暂无经营异常信息</view>
    </view>
    <view class="page" v-if="total > 10">
      <uni-pagination
        :total="total"
        :current="pageIndex"
        :pageSize="pageSize"
        @change="handelPageChanged"/>
    </view>
  </view>
</template>

<script>
import { getCropRiskList } from "@/api/control.js";

export default {
  name: "riskOverview",
  props: {},
  data() {
    return {
      title: '处罚信息',
      userInfo: {},
      mpId: '',
      riskCount: {},
      corpInfo: {},
      riskInfo: {},
      total: 0,
      pageIndex: 1,
      pageSize: 10,
    }
  },
  onLoad(options) {
    this.userInfo = uni.getStorageSync('userInfo') || {};
    const globalData = getApp().globalData;
    this.riskCount = globalData.doorInfo.cfhfxCountResVo;
    this.corpInfo = globalData.doorInfo.ownerCorpInfo;
		this.mpId = globalData.doorInfo.baseInfo.mpid;
    // const doorInfo = uni.getStorageSync('doorInfo');
    // this.riskCount = doorInfo.cfhfxCountResVo;
    this.title = options.title;
    uni.setNavigationBarTitle({
      title: options.title
    })
    this.getCropRiskList();
  },
  methods: {
    // 获取企业门牌的处罚、失信、经营异常列表
    getCropRiskList () {
      const data = {
        mpid: this.mpId,
        tyshxydm: this.corpInfo.tyshxydm,
        flag: this.title,
        userInfoId: this.userInfo.uuid,
        current: this.pageIndex,
        size: this.pageSize
      }
      getCropRiskList(data).then(res =>{
        this.riskInfo = res.data;
        this.total= res.total;
      })
    },

    // 修改页码
    handelPageChanged(event) {
      this.pageIndex = event.current;
      this.getCropRiskList();
    },
  },
} 
</script>

<style lang="scss" scoped>
.risk-overview {
  height: 100%;
  overflow: auto;
  .crop-name {
    height: 40px;
    line-height: 40px;
    background-color: #fff;
    padding: 0 10px;
    font-size: 16px;
    font-weight: 900;
    margin-bottom: 10px;
  }
  .overview {
    padding: 10px;
    margin-bottom: 10px;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    .title {
      width: 14px;
      font-size: 12px;
      color: #db7676;
      background-color: #ecd0d0;
    }
    .item {
      width: 31%;
      padding: 0 5px;
      background-color: #f8f5f5;
      .label {
        font-size: 13px;
        color: #333333;
        margin-bottom: 3px;
        display: flex;
        .name {
          width: 60px;
        }
        .count {
          width: 40px;
          text-align: center;
          color: #dd7070;
          background-color: #ecd0d0;
          border-radius: 3px;
        }
      }
      .value {
        font-size: 12px;
        color: #999999;
      }
    }
  }
  .content {
    height: calc(100vh - 110px);
    .list {
      background-color: #fff;
      margin-bottom: 10px;
      padding: 5px 10px;
      .item {
        display: flex;
        justify-content: space-between;
        margin-bottom: 5px;
        font-size: 14px;
        .label {
          width: 100px;
          color: #333333;
        }
        .value {
          width: calc(100% - 110px);
          color: #999999;
        }
      }
    }
  }
  .no-content {
    height: calc(100vh - 110px);
    padding: 10px;
    font-size: 14px;
    color: #999999;
  }
}
</style>

<style>
.uni-section .uni-section-header {
  padding: 0 !important;
}
</style>