<template>
  <div id="model-2">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="12" class="list" v-for="(item, index) in list" :key="index" @click.native="detail(item.id)">
          <el-col :span="5" class="image">
            <el-image :src="getImage(item.img_path)">
              <template #error>
                <el-image :src="expetImg"></el-image>
              </template>
            </el-image>
          </el-col>
          <el-col :span="19" class="other">
            <p class="name textOver">{{ item.name }}</p>
            <p class="textOver">工作单位：{{ item.company || '暂无' }}</p>
            <p class="textOver">擅长领域：{{ item.expertise || '暂无' }}</p>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
const _ = require('lodash');
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'model-2',
  props: {
    list: { type: Array, default: () => [] },
  },
  components: {},
  data: function () {
    return {
      expetImg: require('@a/expert.png'),
    };
  },
  created() {},
  methods: {
    detail(id) {
      this.$router.push({ path: './list', query: { index: this.index, id } });
    },
    getImage(data) {
      if (_.map(data, 'url')[0]) {
        return _.map(data, 'url')[0];
      }
    },
  },
  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 dashed #ccc;
    .image {
      .el-image {
        border-radius: 90px;
        width: 90px;
        height: 90px;
      }
    }
    .other {
      padding: 0 10px;
      p {
        font-size: 16px;
        color: #666;
        padding: 0 0 10px 0;
        span {
          display: inline-block;
          width: 50%;
        }
      }
      p:nth-child(1) {
        font-size: 18px;
        color: #000;
      }
    }
  }
  .list:hover {
    cursor: pointer;
    .other {
      p:nth-child(1) {
        font-weight: bold;
        color: #409eff;
      }
    }
  }
}
</style>
