<template>
  <div class="other-container" style="margin-top: 178px;">
    <IHeader />
    <div style="padding-top: 10px;background: #FFF;margin-top:20px;">
      <div style="width: 200px;display:inline-block;">
        <el-menu
          :default-active="selectDepartId"
          class="el-menu-vertical-demo"
          style="min-height: 700px;"
          @select="handleSelectDepart">
          <template  v-for="(item, index) in options">
            <el-menu-item :index="item.id.toString()">
              <span>{{ item.value }}</span>
            </el-menu-item>
          </template>
        </el-menu>
      </div>

      <div style="width: 800px;display:inline-block;padding: 0 20px;vertical-align: top;">
        <el-card class="">
          <div slot="header" class="clearfix">
            <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
            	<el-form-item :label="selectDepartName">
                <el-input placeholder="" v-model="searchInfo.keyword" clearable></el-input>
              </el-form-item>

              <el-form-item>
                <el-button @click="getArticalList" type="primary">搜索</el-button>
              </el-form-item>
            </el-form>

          </div>


          <el-table :data="list"  border stripe>
            <el-table-column label="序号" width="50" prop="id">
            </el-table-column>

            <el-table-column label="标题" min-width="200" prop="title">
            </el-table-column>

            <el-table-column label="发布时间" min-width="60" prop="createAt">
              <template slot-scope="{row, $index}">
                <span> {{row.createAt|toDatetime}}</span>
              </template>
            </el-table-column>
          </el-table>


          <el-pagination
            :current-page="1"
            :page-size="10"
            :page-sizes="[10, 30, 50, 100]"
            :style="{float:'center',padding:'20px'}"
            :total="total"
            layout="total, sizes, prev, pager, next, jumper"
          ></el-pagination>
        </el-card>

      </div>
    </div>
  <IFooter />
  </div>
</template>

<script>
import IHeader from "./components/IHeader";
import IFooter from "./components/IFooter";
import {getArticalList,getApplyArticalList}  from '@/api/article'
import {toDatetime} from '@/utils/date.js'

const options = [{
  id: 1,
  value: '我发布的文件',
  label: '我发布的文件'
}, {
  id: 2,
  value: '我收藏的文件',
  label: '我收藏的文件'
}, {
  id: 3,
  value: '最近浏览的文件',
  label: '最近浏览的文件'
}, {
  id: 4,
  value: '最近下载的文件',
  label: '最近下载的文件'
}];

export default {
  name: 'application',
  components: {
    IHeader,
    IFooter
  },
  data() {
    return {
      list: [],
      total: 0,
      options:options,
      pageSize: 10,
      page:1,
      searchDepartId: "",
      restaurants: [],
      searchInfo:{
        keyword:''
      },
      state3: '',
      selectDepartId:1,
      selectDepartName: '我发布的文件',
      isShowMore: false
    }
  },
  filters:{
    toDatetime
  },
  created() {
    this.list = options
  },
  mounted() {
    this.getArticalList();
  },
  watch: {
    selectDepartId: function(newDepartId, oldDepartId) {
      let that = this
      console.log("selectDepartId", newDepartId, oldDepartId)
      options.filter(function(item){
        if(item.id == newDepartId){
          that.selectDepartName = item.value
        }
      })
    }
  },
  methods: {
    handleSelectDepart(key, keyPath) {
      console.log("handleSelectDepart", key, keyPath);
      this.selectDepartId = key;
      // 切换文件列表
    },
    getArticalList(){
      let param = {page:this.page,pageSize: this.pageSize}
      getArticalList( param ).then( res=>{
        if( res.code == 200){
          this.list = res.data.list
          this.total = res.data.total
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  .el-breadcrumb{
    display: inline-block;
    padding-left: 10px;
  }
  .box-card{
    margin-bottom: 20px;
  }
  .my-autocomplete {
    li {
      line-height: normal;
      padding: 7px;

      .name {
        text-overflow: ellipsis;
        overflow: hidden;
      }
      .addr {
        font-size: 12px;
        color: #b4b4b4;
      }

      .highlighted .addr {
        color: #ddd;
      }
    }
  }
  .el-card__body .text{
    margin: 5px 0;
  }

  .el-card{
    color: #1890ff;
  }
  .el-card__header{
    padding: 15px 20px;
  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
</style>
