<template>
  <!-- 现场监护 -->
  <view class="infrastructure">
    <h4>基建-计划{{ title }}</h4>
    <view class="infrastructure-content">
      <view
        class="icon-box"
        v-for="(icon, index) in iconList"
        :key="index"
        @tap="onOpenPlanPage(icon.url)"
        v-show="icon.isShow.includes(roles)"
      >
        <image :src="icon.img_src" mode="scaleToFill" />
        {{ icon.icon_title }}
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      iconList: [
        {
          icon_title: '日计划',
          url: '/pages/workPlan/dayPlan/index',
          img_src: require('../../../../static/images/workPlan/day_plan.png'),
          isShow: ['22', '23', '24', '25']
        },
        {
          icon_title: '周计划',
          url: '/pages/workPlan/weekPlan/inf-index',
          img_src: require('../../../../static/images/workPlan/week_plan.png'),
          isShow: ['22', '23', '24', '25']
        },
        {
          icon_title: '月计划',
          url: '/pages/workPlan/monthPlan/inf-index',
          img_src: require('../../../../static/images/workPlan/month_plan.png'),
          isShow: ['22', '23', '24', '25']
        },
        {
          icon_title: '涉网计划',
          url: '/pages/workPlan/networkPlan/index',
          img_src: require('../../../../static/images/workPlan/web_plan.png'),
          isShow: ['23', '24', '25']
        },
        {
          icon_title: '临时计划',
          url: '/pages/workPlan/tempPlan/index',
          img_src: require('../../../../static/images/workPlan/temporary_plan.png'),
          isShow: ['23', '24', '25']
        }
      ],

      title: '',
      roles: uni.getStorageSync('wkRole')
    }
  },
  methods: {
    onOpenPlanPage(url) {
      uni.navigateTo({ url: `${url}` })
    }
  },
  mounted() {
    if (this.roles == 22) {
      this.title = '填报'
    }
    if (this.roles == 23) {
      this.title = '上报'
    }
    if (this.roles == 24 || this.roles == 25) {
      this.title = '审核'
    }
  }
}
</script>

<style lang="scss" scoped>
.infrastructure-content {
  padding: 25rpx 5rpx;
  background-color: #fff;
  display: flex;
  flex-wrap: wrap;

  image {
    width: 58rpx;
    height: 58rpx;
    margin-bottom: 30rpx;
  }

  .icon-box {
    width: 33.33%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

.infrastructure-content .icon-box:nth-child(4),
.infrastructure-content .icon-box:nth-child(5) {
  margin-top: 30rpx;
}

h4 {
  margin: 20rpx 0;
  padding-left: 15rpx;
  font-size: 36rpx;
  font-weight: normal;
}
</style>
