<template>
  <div>
    <!-- 搜索标题 -->
    <div @click="openTeaching('create')"
           class='newBand'>新建</div>
    <!-- 列表 -->
    <div class="tableWrap">
      <el-table :data='tableList' :header-cell-style="{background:'#EDEEF0',color:'#444'}">
        <el-table-column align='center'
                         label="轮播图">
          <template slot-scope="scope">
            <img class="bannerImg" :src="scope.row.coverImage" alt="">
          </template>
        </el-table-column>
        <el-table-column align='center'
                         label="跳转连接">
          <template slot-scope="scope">
            {{ scope.row.linkUrl + '/' + scope.row.id }}
          </template>
        </el-table-column>
        <el-table-column align='center' prop="remark"
                         label="是否使用">
          <template slot-scope="scope">
            {{ scope.row.status == 1 ? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column align='center' label="操作">
            <template slot-scope="scope">
              <el-button @click="onDel(scope.row)" type="text">删除</el-button>
              <el-button @click="onStop(scope.row)"  type="text">停用</el-button>
            </template>
        </el-table-column>
      </el-table>
      <pagination :total="pageInfo.total"
                :page.sync="pageInfo.page"
                :limit.sync="pageInfo.limit"
                :page-sizes="pageInfo.page_size"
                @pagination="getList" />
    </div>
  </div>
</template>
<script>
import { newsList, newsUpdate } from '@/api/contentManager'
import pagination from '@/components/Pagination/index'
import store from '@/store'
export default {
  components: {
    pagination
  },
  data () {
    return {
      tableList: [],
      organId: store.getters.organ,
      teacherId: this.$route.query.teacherId,
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 1, // 总条数
        page_size: [10, 20, 40, 50] // 选择限制显示条数
      }
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      let params = {
        rows: this.pageInfo.limit,
        page: this.pageInfo.page,
        type: 3
      }
      newsList(params).then(res => {
        if(res.code == 200) {
          this.tableList = res.data.rows
          this.pageInfo.total = res.data.total
        }
      })
    },
    openTeaching(type, rows) {
        this.$router.push({
            path: '/contentManager/contentOperation',
            query: {
              type: 3,
              pageType: type
            }
        })
    },
    onDel(row) { // 删除

    },
    onStop(row) { // 停止
      // newsUpdate
    }
  }
}
</script>
<style lang="scss" scoped>
.bannerImg {
  height: 60px;
}
</style>