<template>
  <div class="chart-list-cont">
    <span>共{{ total }}张图表</span>
    <div
      class="chartList-wrapper"
      ref="listRef"
      @scroll="$emit('loadMoreHandle')"
    >
      <el-col
        :span="6"
        style="margin-bottom: 20px; padding-right: 20px"
        v-for="chart in list"
        :key="chart.ChartInfoId"
      >
        <el-card class="sheet-item">
          <div class="chartEn-mark" v-show="chart.IsEnChart" style="top: 0;left: 0;">En</div>
          <div slot="header" class="item-top">
            <span class="text_oneLine">{{ chart.ChartName }}</span>
          </div>
          <img
            :src="chart.ChartImage"
            alt=""
            class="chart-img"
            @click="$emit('detailShowHandle',chart)"
          />
          <div class="item-bottom">
            <span>创建时间: {{ chart.CreateTime.slice(0,10) }}</span>
            <div v-if="isShowBtn(chart)">
              <span
                class="join_txt"
                @click="$emit('addMychartHandle',chart)"
              >
                <img
                  :src="$icons.chart_join_ico"
                  alt=""
                  style="width: 13px; height: 12px; vertical-align: middle"
                />
                加入我的图库
              </span>
            </div>
          </div>
        </el-card>
      </el-col>
    </div>
    <div v-if="!total" class="nodata">
      <tableNoData text="暂无图表"/>
    </div>
  </div>
</template>
<script>
export default {
  props: ['total','list'],
  data() {
    return {

    }
  },
  mounted(){

  },
  methods:{
    isShowBtn(item){
        const {path} = this.$route
        const {statisticPermission,productPricePermission,checkPermissionBtn} = this.permissionBtn
        //相关性分析
        if(path==='/chartrelevance'){
            return checkPermissionBtn(statisticPermission.corrAnalysis_addMyChart)
        }
        //拟合方程曲线
        if(path==='/fittingEquationList'){
            return checkPermissionBtn(statisticPermission.fittingEq_addMyChart)
        }
        //统计特性
        if(path==='/statisticFeatureList'){
            return checkPermissionBtn(statisticPermission.statisticFeature_addMyChart)
        }
        //商品价格曲线
        if(path==='/commordityChartBase'){
            const {Source,ChartType} = item
            if(Source===2&&ChartType===8){//是商品价格曲线
                return checkPermissionBtn(productPricePermission.goodsPrice_priceLine_addMyChart)
            }else{//是利润曲线
                return checkPermissionBtn(productPricePermission.goodsPrice_incomeLine_addMyChart)
            }
        }
        return false
    }
  },
}
</script>
<style scoped lang='scss'>
.chart-list-cont {
  color: #333;
  .el-card .el-card__header,
  .el-card__body {
    padding: 10px;
  }

  .chartList-wrapper {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    max-height: calc(100vh - 143px);
    overflow: hidden;
    overflow-y: auto;
    .drag-cont {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
    }
    .dragShdow {
      box-shadow: 0 1px 8px rgba(64, 158, 255, 0.8);
      opacity: 0.5;
    }
    .sheet-item {
      position: relative;
      .item-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 16px;
        font-weight: 600;
      }
      .chart-img {
        width: 100%;
        height: 230px;
        object-fit: contain !important;
        cursor: pointer;
      }
      .item-bottom {
        margin-top: 10px;
        display: flex;
        justify-content: space-between;
        font-size: 12px;
        color: #666;
        .collected {
          color: #f00;
          cursor: pointer;
        }
        .join_txt {
          color: #409eff;
          cursor: pointer;
        }
      }
    }
  }
  .nodata {
    text-align: center;
  }
}
</style>
