<template>
  <div>
    <div v-for="item in data" :key="item.date" class="list">
      <div class="tableTitle">{{ item.date }}</div>
      <el-table
        v-loading="table_loading"
        :data="item.data"
        style="width: 100%;"
        highlight-current-row
        :header-cell-style="{ 'background':'#F7F7F7', 'color':'#4a4a4a','font-size':'14px','font-weight':'500' }"
        :cell-style="{ 'font-size':'14px','color':'rgba(102,102,102,1)' }"
        size="small"
        show-overflow-tooltip="true"
      >
        <el-table-column label="优先级" width="105" prop="priority" sortable align="right">
          <template slot-scope="scope">
            <span class="div_priority" :style="{background: priorityColors[scope.row.priority]}">{{ scope.row.priorityName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="标题" min-width="200" show-overflow-tooltip align="left">
          <template slot-scope="scope">
            <div>
              <div class="titleId">
                PROBLEM-{{ scope.row.id }}
              </div>
              <div class="title" @click.stop="gotoDetail(scope.row)">
                {{ scope.row.title }}
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="责任团队" min-width="150" prop="teamName" show-overflow-tooltip align="center" />
        <el-table-column label="复盘链接" show-overflow-tooltip align="center">
          <template slot-scope="scope">
            <i v-if="scope.row.replayUrl" class="el-icon-link" @click="goto(scope.row.replayUrl)" />
          </template>
        </el-table-column>
        <el-table-column label="改进项已完成" min-width="130" show-overflow-tooltip align="center">
          <template slot="header">
            改进项已完成
            <el-tooltip effect="dark" content="已完成改进项条数/总改进项条数" placement="top-start">
              <i class="el-icon-info" />
            </el-tooltip>
          </template>
          <template slot-scope="scope">
            <span :class="scope.row.finishImpr !== scope.row.imprTotal && 'origin'">{{ scope.row.finishImpr }}</span>
            /
            <span :class="scope.row.finishImpr !== scope.row.imprTotal && 'origin'">{{ scope.row.imprTotal }}</span>
          </template>
        </el-table-column>
        <el-table-column label="是否星辰花定级" min-width="130" show-overflow-tooltip align="center">
          <template slot-scope="scope">{{ scope.row.isGrading ? '是' : '否' }}</template>
        </el-table-column>
        <el-table-column label="影响面" min-width="120" show-overflow-tooltip align="center">
          <template slot-scope="scope">{{ scope.row.influenceSurfaceName }}</template>
        </el-table-column>
        <el-table-column label="发生时间" min-width="150" prop="happenDate" show-overflow-tooltip align="center" />
        <el-table-column label="创建人" prop="creatorName" show-overflow-tooltip align="center" />
      </el-table>
    </div>
  </div>
</template>
<script>
export default {
  components: {
    // searchHeader
  },
  props: {
    data: {
      type: Array,
      default: () => [],
      required: true
    }
  },
  data() {
    return {
      table_loading: false,
      priorityColors: ['#F56C6C', '#FF8952', '#F5E300', '#7ED321', '#61D3B8', '#69B3FF', '#BDBDBD']
    }
  },
  methods: {
    gotoDetail(data) {
      const { href } = this.$router.resolve({
        name: '质惠线上问题详情',
        query: {
          id: data.id
        }
      })
      window.log({ c: 'problem', d: 'get_problem_detail' })
      window.open(href, '_blank')
    },
    goto(url) {
      window.open(url, '_blank')
    }
  }
}
</script>
<style lang="scss" scoped>
.list {
  padding-bottom: 40px;
  .tableTitle{
    color: #333;
    font-size: 16px;
    padding: 16px 30px;
    background: #fff;
    font-weight: 700;
  }
  .titleId {
    font-size: 12px;
    color: #A7AEBC;
  }
  .title {
    line-height: 23px;
    font-size: 14px;
    color: #666;
    &:hover {
      color: #409eff;
      cursor: pointer;
      background: #f5f7fa;
    }
  }
  .origin {
    color: #EE7546;
  }
  .div_priority {
    display: inline-block;
    text-align: center;
    width: 38px;
    text-align: center;
    line-height: 24px;
    font-size: 14px;
    color: #fff;
    border-radius: 4px;
    margin-right: 30px;
  }
}
</style>

