<template>
  <div>
    <Card style="width:100%">
      <div class="config_meta">
        <p class="fl">待检检测项目 {{total}} </p>
        <div class="fr">
          <Tooltip content="刷新" placement="left-start">
            <Icon @click="_request" type="ios-refresh" size="30" color="#2d8cf0" style="cursor:pointer;"></Icon>
          </Tooltip>
          <Tooltip content="查看更多" placement="left-start" style="margin-left: 5px">
            <Icon @click="_detail" type="ios-more" size="30" color="#2d8cf0" style="cursor:pointer;"></Icon>
          </Tooltip>
        </div>
        <div class="clear"></div>
      </div>
      <div style="width: 100%;">
        <element-table ref="pageTable" :pageColumns="pageColumns"
                       :tableHeight="tableHeight" :getPage="tableData" hide-checkbox>
          <el-table-column
            :prop="item.key"
            :label="item.title"
            :min-width="item.width"
            :fixed="item.fixed?item.fixed:undefined"
            v-for="item in pageColumns"
            :key="item.key"
            show-overflow-tooltip sortable>
            <template slot-scope="scope">
              <span v-if="item.status">{{scope.row.progress.display}}</span>
              <span v-else>{{scope.row[item.key]}}</span>
            </template>
          </el-table-column>
        </element-table>
      </div>
    </Card>
    <!--未完成检测项目列表-->
<!--    <FoodUnfinishedItem ref="unfinishedDetail"></FoodUnfinishedItem>-->
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      tableData: { records: [] },
      pageColumns: [
        { title: '状态', key: 'progress', width: 110, status: true },
        { title: '检测项目名称', key: 'name', width: 150 },
        { title: '检测依据', key: 'testBasis', width: 140 },
        { title: '样品编号', key: 'num', width: 180 },
        { title: '样品名称', key: 'sampleName', width: 120 },
        { title: '所属科室', key: 'groupName', width: 100 }
      ],
      tableHeight: '280',
      total: ''
    }
  },
  mounted() {
    // this._request()
  },
  methods: {
    _detail() {
      this.$refs.unfinishedDetail._open()
    },
    _request() {
      this.$refs.pageTable._hideLoading()
      this.$store
        .dispatch('StatisticContract/pageItem', { page: 1, rows: 7 })
        .then(() => {
          const tableData = this.$store.state.StatisticContract.page.records
          const total = this.$store.state.StatisticContract.page.total

          if (total === 0) {
            this.total = ''
          } else {
            this.total = '（共 ' + total + ' 条）'
          }
          let num = 0
          if (tableData.length < 7) {
            num = tableData.length
          } else {
            num = 7
          }
          for (let i = 0; i < num; i++) {
            this.tableData.records.push(tableData[i])
          }
        })
    }
  }
}
</script>
