<template>
  <div>
    <Card style="width:100%">
      <div class="config_meta">
        <p class="fl">
          消息通知 {{ total }}
        </p>
        <div class="fr" @click="_detail">
          <Tooltip content="查看更多" placement="left">
            <Icon type="ios-more" size="30" color="#2d8cf0" style="cursor:pointer;" />
          </Tooltip>
        </div>
        <div class="clear" />
      </div>
      <div style="width: 100%;">
        <element-table
          ref="pageTable"
          :page-columns="pageColumns"
          :table-height="tableHeight"
          :get-page="tableData"
          show-check-box
          hide-page
          @on-result-change="_tableResultChange"
        >
          <el-table-column
            v-for="item in pageColumns"
            :key="item.key"
            show-overflow-tooltip
            sortable
            :prop="item.key"
            :label="item.title"
            :align="item.align"
            :width="item.width"
            :min-width="200"
            :fixed="item.fixed?item.fixed:undefined"
          >
            <template slot-scope="scope">
              <span v-if="item.datetime">
                {{ scope.row[item.key]?$dateformat(scope.row[item.key],'yyyy-mm-dd HH:MM'):'' }}
              </span>
              <span v-else-if="item.key==='content'" class="blue-color">
                {{ scope.row[item.key]?scope.row[item.key]:'' }}
              </span>
              <span v-else>
                {{ scope.row[item.key] }}
              </span>
            </template>
          </el-table-column>
        </element-table>
      </div>
    </Card>
    <!--&lt;!&ndash;未完成检测项目列表&ndash;&gt;-->
    <!--<FoodUnfinishedItem ref="unfinishedDetail"></FoodUnfinishedItem>-->
  </div>
</template>

<script>
// import FoodUnfinishedItem from '../../lims/food-test/homeDetail/FoodUnfinishedItem'
import Global from '../../api/config'
import { workbench } from '../../api'

export default {
  data() {
    return {
      tableData: { records: [] },
      pageColumns: [
        { title: '标题', key: 'title', status: true },
        { title: '内容', key: 'content' },
        { title: '创建时间', key: 'ctime', datetime: true }
      ],
      total: ''
    }
  },
  computed: {
    tableHeight() {
      return this.$tableHeight('tableModal')
    }
  },
  mounted() {
    this._request()
  },
  methods: {
    _detail() {
      // 跳转到系统管理，我的任务界面
      window.open(Global.webURL + '/#/sysmanage/my_message', '_blank')
    },
    _tableResultChange(msg) {},
    async _request() {
      this.$refs.pageTable._hideLoading()
      const data = {
        page: 1,
        rows: 10
      }
      const result = await workbench.myMessagePage(data)
      if (result) {
        this.tableData = result
      }
      // this.$store.dispatch('ManufactContract/messagePage', {page: 1, rows: 7}).then(() => {
      //   let tableData = this.$store.state.ManufactContract.page.records
      //   let total = this.$store.state.ManufactContract.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>
<style>
.config_meta .ivu-tooltip-popper {
  top: 23px !important;
}
.fr {
  float: right;
}
.blue-color {
  color: #00a0e9;
}
</style>
