<template>
  <div class="edb-detail">
    <label>{{$t('OnlineExcelPage.selected_indicators_label')}}</label>
    <el-table
      :data="tableData"
      style="box-shadow: 0px 3px 6px rgba(155, 170, 219, 0.2); margin-top: 10px"
      border
    >
      <el-table-column
        v-for="item in tableColums"
        :key="item.label"
        :label="item.label"
        :width="item.widthsty"
        :min-width="item.minwidthsty"
        align="center"
      >
        <template slot-scope="scope">
          <span>{{ scope.row[item.key] }}</span>
        </template>
      </el-table-column>
      <div slot="empty">
        <tableNoData :text="$t('OnlineExcelPage.no_indicators_available_table')" size="mini" />
      </div>
    </el-table>
    <ul
      class="data-ul"
      ref="dataUl"
      v-if="tableData[0]&&tableData[0].DataList.length&&tableData[0].HaveOperaAuth"
    >
      <li
        class="value-item"
        v-for="(item, index) in tableData[0].DataList"
        :key="item.EdbDataId"
      >
        <span class="value-label">
          <i class="new-tag" v-if="index === 0"></i>
          {{ item.DataTime }}
        </span>
        <span
          class="value-label"
          style="min-width: 200px; text-align: center"
          >{{ item.Value }}</span
        >
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  props: {
    tableData: {
      type: Array
    }
  },
  data() {
    return {
      dataList: []
    };
  },
  computed:{
    tableColums(){
      return [
				{
					label: this.$t('Edb.Detail.e_id') || '指标ID',
					key: 'EdbCode',
				},
				{
					label: this.$t('Edb.Detail.e_name') || '指标名称',
					key: this.currentLang==='en'?'EdbNameEn':'EdbName',
				},
				{
					label: this.$t('Edb.Detail.e_fre') ||  '频度',
					key: 'Frequency',
				},
				{
					label: this.$t('Edb.Detail.e_unit') ||  '单位',
					key: this.currentLang==='en'?'UnitEn':'Unit',
				},
				{
					label: this.$t('Edb.Detail.e_start_time') ||  '起始时间',
					key: 'StartDate',
					minwidthsty: '100px'
				},
				{
					label: this.$t('Edb.Detail.e_update_time') ||  '更新时间',
					key: 'ModifyTime',
					minwidthsty: '110px'
				},
				{
					label: this.$t('Table.source') || '来源',
					key: 'SourceName',
				},
			]
    },

    currentLang() {
      return this.$store.state.lang
    }
  },
  methods: {},
};
</script>
<style scoped lang="scss">
.edb-detail {
  .data-ul {
    margin-top: 5px;
    border-bottom: 1px solid #dcdfe6;
    max-height: 140px;
    overflow-y: auto;
    .value-item {
      /* width: 100%; */
      padding: 14px 0;
      border: 1px solid #dcdfe6;
      border-bottom: none;
      display: flex;
      justify-content: space-around;
      .value-label {
        position: relative;
        color: #666;
      }
      .new-tag {
        width: 6px;
        height: 6px;
        display: inline-block;
        position: absolute;
        left: -12px;
        top: 50%;
        transform: translateY(-50%);
        border-radius: 50%;
        background: #f00;
      }
    }
  }
}
</style>
