<template>
  <div id="model-0">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="detail(item.id)">
          <el-col :span="24" class="title textOver">
            {{ item.name }}
          </el-col>
          <el-col :span="24" class="other">
            <el-col :span="12" class="text textOver">
              成果单位：<span>{{ item.company }}</span>
            </el-col>
            <el-col :span="12" class="text textOver">
              发布时间：<span>{{ getDate(item.meta.createdAt) }}</span>
            </el-col>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
const moment = require('moment');
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'model-0',
  props: {
    list: { type: Array, default: () => [] },
  },
  components: {},
  data: function () {
    return {};
  },
  created() {},
  methods: {
    detail(id) {
      this.$router.push({ path: './list', query: { index: this.index, id } });
    },
    getDate(date) {
      let newDate = moment(date).format('YYYY-MM-DD');
      if (newDate) return newDate;
    },
  },
  computed: {
    ...mapState(['user']),
    index() {
      return parseInt(this.$route.query.index) || 0;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .list {
    padding: 12px 10px;
    border-bottom: 1px solid #ccc;
    .title {
      font-size: 16px;
      margin: 0 0 5px 0;
    }
    .other {
      .text {
        font-size: 14px;
        color: #666;
        span {
          color: #000;
        }
      }
    }
  }
  .list:hover {
    cursor: pointer;
    .title {
      color: #409eff;
      font-weight: bold;
    }
  }
}
</style>
