<template>
<div class="app-container calendar-list-container">
  <!-- 筛选条件 -->
  <div class="filter-container">
  <el-input @keyup.enter.native="handleSearch" style="width: 200px;" class="filter-item" clearable placeholder="标签名称" v-model="params.search_like_name"></el-input>
      <el-button class="filter-item" type="primary" v-waves icon="search" @click="handleSearch">搜索</el-button>
      <el-button class="filter-item pull-right " type="success" icon="edit" @click="handleCreate">添加</el-button>
  </div>

  <!-- 列表数据 -->
  <Pagination uri="/venue/lesson/tag/configs" :request-params="params" ref="pagination">
    <!-- 课程tag名称 -->
    <el-table-column align="center" label="标签名称">
      <template scope="scope">
        <span>{{scope.row.name}}</span>
      </template>
    </el-table-column>
    <!-- 创建时间 -->
      <el-table-column align="center" label="创建时间">
        <template scope="scope">
          <span>{{scope.row.createdTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
        </template>
      </el-table-column>

    <el-table-column label="操作" align="center" width="150">
      <template scope="scope">
        <el-button size="small" type="text" @click="handleEdit(scope.row.id)">编辑</el-button>
        <el-button size="small" type="text" class="danger" @click="handleDelete(scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </Pagination>
</div>
</template>

<script>
import { remove } from '@/api//venue/lesson/tag/config'
import waves from '@/directive/waves.js'// 水波纹指令
import Pagination from '@/components/Pagination'

export default {
  name: 'venueLessonTagConfig_list',
  components: { Pagination },
  directives: {
    waves
  },
  data() {
    return {
      params: {
        search_like_name: undefined
      }
    }
  },
  created() {
  },
  methods: {
    /**
     * 搜索课程tag
     */
    handleSearch() {
      this.$refs.pagination.handleSearch()
    },

    /**
     * 编辑课程tag
     */
    handleEdit(id) {
      this.$router.push({ path: '/venue/lesson/tag/config/edit', query: { id: id }})
    },

    /**
     * 创建课程tag
     */
    handleCreate() {
      this.$router.push({ path: '/venue/lesson/tag/config/edit' })
    },

    /**
     * 删除课程tag
     */
    handleDelete(row) {
      this.$confirm('确认删除该课程标签？').then(_ => {
        remove(row.id).then(response => {
          this.$refs.pagination.removeItem(row)
        })
      }).catch(_ => {})
    }
  }
}
</script>

