<template>
  <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item :label="$t('document.form.title')" prop="title">
        <el-col :span="4">
          <el-input v-model="form.title" :placeholder="$t('input_please',{keyword:$t('document.form.title')})"/>
        </el-col>
      </el-form-item>
      <el-form-item :label="$t('document.form.author')" prop="author">
        <el-col :span="4">
          <el-input v-model="form.author" :placeholder="$t('input_please',{keyword:$t('document.form.author')})"/>
        </el-col>
      </el-form-item>
      <el-form-item :label="$t('document.form.keyword')" prop="keyword">
        <el-col :span="4">
          <el-input v-model="form.keyword" :placeholder="$t('input_please',{keyword:$t('document.form.keyword')})"/>
        </el-col>
      </el-form-item>
      <el-form-item :label="$t('document.form.specialty')" prop="specialty">
        <el-col :span="4">
          <el-input v-model="form.specialty" :placeholder="$t('input_please',{keyword:$t('document.form.specialty')})"/>
        </el-col>
      </el-form-item>
      <el-collapse v-model="activeNames">
        <el-collapse-item :title="activeNames[0]==='1'?$t('hide_more_query'):$t('more_query')" name="1">
          <el-form-item :label="$t('document.form.school')" prop="school">
            <el-col :span="4">
              <el-input v-model="form.school" :placeholder="$t('input_please',{keyword:$t('document.form.school')})"/>
            </el-col>
          </el-form-item>
          <el-form-item :label="$t('document.form.tutor')" prop="tutor">
            <el-col :span="4">
              <el-input v-model="form.tutor" :placeholder="$t('input_please',{keyword:$t('document.form.tutor')})"/>
            </el-col>
          </el-form-item>
          <el-form-item :label="$t('document.form.start_year')" prop="start_year">
            <el-col :span="4">
              <el-input v-model="form.start_year"
                        :placeholder="$t('input_please',{keyword:$t('document.form.start_year')})"/>
            </el-col>
          </el-form-item>
          <el-form-item :label="$t('document.form.end_year')" prop="end_year">
            <el-col :span="4">
              <el-input v-model="form.end_year"
                        :placeholder="$t('input_please',{keyword:$t('document.form.end_year')})"/>
            </el-col>
          </el-form-item>
        </el-collapse-item>
      </el-collapse>
    </el-form>
    <el-row class="mt3">
      <el-col :span="18">
            <el-row v-for="(item,index) in docList" class="mt2" :key="index">
              <el-row type="flex" align="middle">
                <el-col :span="1"><span>{{index+1}}.</span></el-col>
                <el-col :span="3">
                  <el-button size="mini" round>{{$t('button.catalog')}}</el-button>
                </el-col>
                <el-col :span="16" class="doc-title"><span>{{item.title}}</span></el-col>
              </el-row>
              <el-row type="flex" align="middle" class="center mt1">
                <el-col :span="2"><span>[{{item.type}}]</span></el-col>
                <el-col :span="1"><span>{{item.author}}</span></el-col>
                <el-col :span="3"><span>{{item.profession}}</span></el-col>
                <el-col :span="3"><span>{{item.school}}&nbsp{{item.year}}</span></el-col>
                <el-col :span="4"><span>{{$t('document.doc_list.year')}}</span></el-col>
              </el-row>
              <el-row class="mt1">
                <p class="doc-summary">{{item.summary}}</p>
              </el-row>
              <el-row class="mt1">
                <el-col :span="10" class="doc-title">
                  <el-tag v-for="tag in item.tags" :key="tag" class="ml1">{{tag}}</el-tag>
                </el-col>
                <el-col :span="2">
                  <el-button @click="read(item)">{{$t('reading_online')}}</el-button>
                </el-col>
              </el-row>
            </el-row>
      </el-col>
      <el-col :span="5" class="ml3">
         <el-row>
           <h1 class="center">{{$t('today_recommend')}}</h1>
         </el-row>
        <div class="recommend-list">
           <el-row v-for="(item,index) in recommend_list" :key="index">
              <h3 class="center doc-title">{{item.title}}</h3>
              <p class="doc-summary">{{item.summary}}</p>
           </el-row>
        </div>
      </el-col>
    </el-row>
    <el-pagination
      layout="prev, pager, next"
      :total="1000" class="center mt1">
    </el-pagination>
  </div>
</template>

<script lang="ts">
  import Vue from 'vue'

  export default Vue.extend({
    name: 'document',
    data() {
      return {
        form: {
          title: '',
          author: '',
          keyword: '',
          specialty: '',
          school: '',
          tutor: '',
          start_year: '',
          end_year: ''
        },
        rules: {},
        activeNames: [],
        docList:[],
        recommend_list:[]
      }
    },
    methods:{
      read(item:any){
        this.$store.commit('menus/read')
        this.$store.commit('read/open',item)
        this.$router.push(this.localePath('/read'))
      }
    },
    mounted() {
      for(let i=0;i<10;i++){
        this.docList.push({
          title:'浅谈中国山水画的传承与创新'+i,
          type:'硕士论文',
          author:'马俊',
          profession:'网络游戏',
          school:'中国美术学院',
          year:2011,
          summary:'摘要：传统的中国山水画建立在自然形象及其对人对自然升华的基础上。在哲学意义上，它的语言和精神性依赖于一个自然体系。而当下中国艺术的现代性转变也是一个如何超越自然体系的问题。现代性面对的社会和空间是工业社会和城市。',
          tags:['山水画','空间经验','构成主义'],
          content:`<div>123</div>`
        })
        this.recommend_list.push({
          title:'玩具产品的情感设计研究',
          summary:'摘要：首先,玩具作为一种产品,是设计者情感的外显化与实物化,设计者通过玩具的设计,将生活中的感动和梦想投射到玩具形像中,使得这样的情感和梦想得到延续。而使用者在使用玩具时,也能感受到设计师的情感,从而产生共鸣。'
        })
      }
    }
  })
</script>
<style>
  .doc-title{
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
  }
  .doc-summary{
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
  .recommend-list{
    overflow-y: scroll;
  }
</style>
