<template>
  <div class="consult-info">
    <Row class="row row-title">
        <i-col class="col" v-for="col in layout" :key="col.key" :span="col.width" :offset="col.offset || 0">
          <div :style="`text-align: ${col.align || 'left'};width:100%;`">{{col.title}}</div>
        </i-col>
      </Row>
      <m-scroll :length="model.length" :limit="3">
        <Row class="row" v-for="(row, rowIndex) in model" :key="rowIndex" :style="`${row.count >= 15 ? 'color:#d04e4b': ''}`">
          <i-col class="col" v-for="col in layout" :key="col.key" :span="col.width" :offset="col.offset || 0">
            <div v-if="typeof row[col.key] === 'number'" :style="`text-align: ${col.align || 'left'};color: ${col.color};width:100%;`">
              <m-count :value="row[col.key]" :decimal="0"/>
            </div>
            <div v-else-if="col.formatter">
              {{col.formatter(row[col.key])}}
            </div>
            <div v-else :style="`text-align: ${col.align || 'left'};color: ${col.color};width:100%;`">{{row[col.key]}}</div>
          </i-col>
        </Row>
      </m-scroll>
  </div>
</template>

<script>
export default {
  name: 'ConsultInfo',
  data() {
    return {
      layout: [
        {
          title: '主题',
          key: 'theme',
          width: 6,
        },
        {
          title: '处理状态',
          key: 'status',
          width: 4,
          formatter: val => {
            return val == '1' ? '已处理' : '未处理'
          }
        },
        {
          title: '送检单位',
          key: 'unit',
          width: 6,
        },
        {
          title: '送检时间',
          key: 'time',
          width: 4,
        },
        {
          title: '处理时间',
          key: 'done',
          width: 4,
        },
      ],
      model: [
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '1', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '1', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '0', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '1', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '1', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '0', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '1', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '1', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
        {theme: '送检鱼已经死亡，鱼体表鳞片…', status: '0', unit: '呼山众创农业开发有限公司', time: '2020.08.20 14:12:02', done: '2020.08.23 14:12:00'},
      ]
    }
  },
}
</script>

<style lang="stylus" scoped>
.consult-info
  width 100%
  height 100%
  overflow hidden
  .row
      display flex
      align-items center
      // line-height 2.4rem
      line-height 2.5
      &.row-title
        font-weight bold
        background-color $color-map()
        font-size 1rem
      &:nth-child(2n)
        background-color $color-map(0.15)
    .col
      padding 0 .5rem
      display flex
      align-items center
      flex-wrap wrap
      font-size .9rem
</style>
