<template>
  <div>
    <Card style="width:100%">
      <div class="config_meta">
        <p class="fl">
          消息通知
        </p>
        <div @click="_detail" class="fr">
          <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%;">
        <PTVXETableHeight ref="pageTable"
                          :table-height="300"
                    @on-result-change="_tableResultChange" :getPage="tableData" hide-checkbox="true">
          <vxe-table-column
                  :field="item.key"
                  :title="item.title"
                  :min-width="item.width?item.width:150"
                  :fixed="item.fixed?item.fixed:undefined"
                  v-for="item in pageColumns"
                  :key="item.key" sortable>
            <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>
          </vxe-table-column>
        </PTVXETableHeight>
      </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 }
      ],
      formObj: {}
    }
  },
  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()
      Object.assign(this.formObj, this.$refs.pageTable._searchParams())
      const result = await workbench.myMessagePage(this.formObj)
      if (result) {
        this.tableData = result
        this.$refs.pageTable._hideLoading()
      }
      // 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>
