<template>
  <!-- 当前新闻的相似新闻对话框 -->
  <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
    <el-table v-loading="loading" :data="dataList" >
      <el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
      <el-table-column label="新闻标题" align="center" prop="title"  >
        <template slot="header" slot-scope="scope">
          <span>新闻标题</span>
          <el-tooltip class="item" effect="dark" content="鼠标单机数据可查看新闻详情"
                      placement="bottom"
          >
            <i class="el-icon-question"></i>
          </el-tooltip>
        </template>
        <template slot-scope="scope">
          <span @click="goProdDetail(scope.row.id)" style="color: #1890ff;cursor: pointer"
          >{{ scope.row.title }}</span>
        </template>
      </el-table-column>
      <el-table-column label="所属栏目" align="center" prop="catgName" width="160" />
      <el-table-column label="新闻图" align="center" prop="mainPic" width="200">
        <template slot-scope="scope">
          <image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="相似度" align="center" prop="similarityStr" width="160" >
<!--        <template slot-scope="scope">-->
<!--          <span>{{scope.row.similarity}}%</span>-->
<!--        </template>-->
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancelRandom">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'similarityNew',
  props: {
    //当前产品的随机产品数组
    dataList: {
      type: Array,
      default: null,
    },
  },
  data() {
    return {
      // 弹出层标题
      title: "相似新闻",
      // 是否显示弹出层
      open: false,
      // 遮罩层
      loading: true,
    }
  },
  created() {
  },
  methods:{
    /**
     * 组件显示
     */
    show(){
      this.open=true
      this.loading = false
    },
    // 取消按钮
    cancelRandom() {
      this.open = false;
      this.$emit("refresh")
    },
    /**
     * 查看新闻详情
     */
    goProdDetail(id) {
      let routeData = this.$router.resolve({ path:'/new/newForm', query: {  id: id } });
      window.open(routeData.href, '_blank');
    }
  }
}
</script>

<style scoped>

</style>
