<template>
  <div id="items">
    <div id="item" v-for="(item, index) in itemDatas" :key="index">
      <header v-if="item.statu==='待办'" class="statu-red">{{ item.statu }}</header>
      <header v-if="item.statu==='办结'" class="statu-green">{{ item.statu }}</header>
      <header v-if="item.statu==='已办'" class="statu-blue">{{ item.statu }}</header>
      <header v-if="item.statu==='邮件'" class="statu-brown">{{ item.statu }}</header>
      <div class="bind">
        <div class="title"><a>{{ item.infor }}</a></div>
        <!-- <div class="content">{{ item.content }}</div> -->
      </div>
      <div class="others">
        <span class="type">{{ item.typeContent }}</span>
        <span class="system"><a :title="item.source">{{ item.source }}</a></span>
        <span class="name">{{ item.name }}</span>
        <span class="time">{{ item.time }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import '../../systemNavComponents/js'
export default {
  data () {
    return {
        itemDatas:[],
        startPage:0,
        endPage:1
    }
  },
  props: {
    itemData: {
      type: Array,
      default: () => {}
    },
    // endPage,
    // startPage
  },
  components: {
  },
  methods: {
      changeData() {
          let {startPage, endPage} = this
        //   console.log('object :>> ', startPage, endPage)
          this.itemDatas = this.itemData.slice(startPage, endPage)
        //   console.log('this.itemData >> ', this.itemData)
      },
      changeDatas() {
          let {startPage, endPage} = this.$parent
          console.log('object :>> ', startPage, endPage)
          this.itemDatas = this.itemData.slice(startPage, endPage)
          console.log('this.itemData >> ', this.itemData)
      }
  },
  watch: {
      startPage: {
          immediate: true,
          handler: 'changeData',
      },
      endPage: {
          immediate: true,
          handler: 'changeData',
      },
      itemData: {
          immediate: true,
          deep: true,
          handler: 'changeDatas'
      }
  },
  created () {
    //   console.log('aaaaaaaaaaa :>> ');
      this.$root.$on('pageChange',e => {
          console.log('a,b >> ', e)
          this.startPage = e.startPage
          this.endPage = e.endPage
        //   this.changeData()
      })
      this.changeData()
  }
}
</script>

<style lang="less" scoped>
#items {
  width: 100%;
  align-items: center;
  #item {
    position: relative;
    width: 100%;
    height: 13rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 1);
    display: grid;
    grid-template-columns: 40% 60%;
    align-items: center;
    margin: 2rem 0;
    border: 1px solid #eee;
    padding-top: 1rem;
    &:hover {
      cursor: pointer;
      box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1);
    }
    header {
      position: absolute;
      top: -1px;
      left: -1px;
      height: 2.6rem;
      width: 7.2rem;
      color: white;
      text-align: center;
      line-height: 2.6rem;
      font-size: 1.4rem;
      padding-right: 0.5rem;
    }
    .statu-red {
      background: url('../../../assets/images/systemNav/b2.png') no-repeat center center;
      background-size: 100% 100%;
    }
    .statu-green {
      background: url('../../../assets/images/systemNav/b1.png') no-repeat center center;
      background-size: 100% 100%;
    }
    .statu-blue {
      background: url('../../../assets/images/systemNav/b3.png') no-repeat center center;
      background-size: 100% 100%;
    }
    .statu-brown {
      background: url('../../../assets/images/systemNav/b4.png') no-repeat center center;
      background-size: 100% 100%;
    }
    .bind {
      padding-left: 4rem;
      .title {
        width: 38.3rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        a {
          font-size: 1.8rem;
          font-weight: 400;
          color: #333;
          // &:hover {
          //   color: #009fe2;
          //   text-decoration: underline;
          // }
        }
      }
      .content {
        margin-top: 1rem;
        font-size: 1.6rem;
        font-weight: 400;
        color: #999;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
    .others {
      display: grid;
      grid-template-columns: 25% 25% 25% 25%;
      align-items: center;
      font-size: 1.6rem;
      color: #000;

      .type,
      .system a {
        font-size: 1.6rem;
        font-weight: 400;
        color: #000;
        text-align: center;
      }
      .name {
        text-align: center;
      }
      .time {
        text-align: center;
      }
      .system {
        text-align: center;
        //   a {
        //     display: inline-block;
        //     width: auto;
        //     width: 14rem;
        //     height: 4rem;
        //     border-radius: 2rem;
        //     background: #f5f1e1;
        //     font-weight: Bold;
        //     color: #f4de9c;
        //     font-size: 1.8rem;
        //     line-height: 4rem;
        //     text-align: center;
        //     font-style: normal;
        //     padding: 0 1.5rem;
        //     margin: 0 auto;
        //     white-space: nowrap;
        //     overflow: hidden;
        //     text-overflow: ellipsis;
        //   }
      }

      // .details {
      //     width: 120px;
      //     height: 40px;
      // }
    }
  }
}
</style>
