<template>
  <div id="out-link-list" class="out-link-list">
    <div v-if="outlinkData && outlinkData.length>0" class="outlink-box">
      <div class="outlink-item" :class="'outlink'+(index%4)" v-for="(item,index) in outlinkData" :key="item.Id" @click="gotoOutlink(item)"
      >
        <img src="~@/assets/img/eta_base_config/outlink.png">
        <div class="outlink-item-text-zone">
          <span>{{ item.Title }}</span>
          <span>{{ item.Url }}</span>
        </div>
      </div>
    </div>
    <div class="no-outlink" v-else>
      <img src="~@/assets/img/data_m/nodata.png"/>
      <span>暂无数据</span>
    </div>

  </div>
</template>

<script>
import {outlinkConfigInterence} from "@/api/modules/etaBaseConfigApi.js"
  export default {
    name:"outlinkList",
    data() {
      return {
        outlinkData:[],
        colors:['#E3EAFD','#FBEBD5','#DEF4D8','#DEF2FC']
      }
    },
    created(){
      this.getOutlinkData()
    },
    methods: {
      getOutlinkData(){
        outlinkConfigInterence.getOutlinkListAll().then(res=>{
          if(res.Ret == 200){
            this.outlinkData = res.Data.List || []
            // console.log(this.outlinkData);
            //ETA1.0.8 在数组开头增加一项培训视频链接
            this.outlinkData.unshift({
                Id:9999,
                Title:'培训视频课堂',
                Url:`${process.env.VUE_APP_ETA_VIDEO}?bus_code=${this.$setting.bus_code}`
            })
          }
        })
      },
      gotoOutlink(item){
        let Url = item.Url
        if(!(item.Url.startsWith("http://") || item.Url.startsWith("https://") || item.Url.startsWith("ftp://") || 
        item.Url.startsWith("ftps://") || item.Url.startsWith("file://") || item.Url.startsWith("\/"))){
          Url = "http://"+item.Url
        }
        // console.log(Url);
        window.open(Url, '_blank')
      }
    },
  }
</script>

<style lang="scss" scoped>
  .out-link-list{
    min-height: calc(100vh - 120px);
    height:calc(100vh - 120px);
    background-color: white;
    border: solid 1px #DCDFE6;
    box-sizing: border-box;
    padding: 30px;
    .outlink-box{
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: flex-start;
      margin-right: -30px;
      .outlink-item{
        display: flex;
        align-items: flex-start;
        height: 100px;
        width: 250px;
        border-radius: 8px;
        box-sizing: border-box;
        padding: 30px 40px 30px 13px;
        // border: solid 2px #0052D9;
        cursor: pointer;
        margin: 0 30px 30px 0;
        // background-color: #F2F3FF;
        img{
          height: 55px;
          margin-top: -6px;
          width: 55px;
        }
        .outlink-item-text-zone{
          overflow: hidden;
          text-overflow: ellipsis;
          span{
            font-size: 16px;
            font-weight: bold;
            color: #333;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            &:last-child{
              font-size: 12px;
              font-weight: 400;
              display: block;
              margin-top: 4px;
            }
          }
        }
        &:hover{
          // box-shadow: 6px 7px 11px 0px rgba($color: #646464, $alpha: 0.1);
          // box-shadow: 6px 7px 11px 0px #64646417;
          // background-color: #0052D9;
          // .outlink-item-text-zone{
          //   span{
          //     color: #ffffff;
          //     &:last-child{
          //       color: rgba($color: #ffffff, $alpha: 0.65);
          //     }
          //   }
          // }
        }
      }
      .outlink0{
        background-color: #E3EAFD;
        border: 2px solid #E3EAFD;
        &:hover{
          border: 2px solid #436FF6;
        }
      }
      .outlink1{
        background-color: #FBEBD5;
        border: 2px solid #FBEBD5;
        &:hover{
          border: 2px solid #EF8E34;
        }
      }
      .outlink2{
        background-color: #DEF4D8;
        border: 2px solid #DEF4D8;
        &:hover{
          border: 2px solid #65C444;
        }
      }
      .outlink3{
        background-color: #DEF2FC;
        border: 2px solid #DEF2FC;
        &:hover{
          border: 2px solid #479DD2;
        }
      }
    }
    .no-outlink{
      margin: 70px auto;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 260px;
      img{
        width: 260px;
      }
      span{
       font-size: 16px;
       color: #999999; 
      }
    }
  }
</style>