<template>
  <div class="onlineclassifyList">
    <div class="el-card__header">
      <span>在线分类管理</span>
      <div style="display: flex;flex-direction: row;align-items: center">
        <el-button type="primary" class="el-button--small" @click="addRecharge">新增</el-button>
      </div>
    </div>



    <div style="padding: 20px;background: #fff;margin-top: 20px">
      <el-table
        :data="tableData"
        header-cell-class-name="headClass"
        style="width: 100%"
        border
      >


        <el-table-column
          prop="ID"
          label="ID"
          width="100">
        </el-table-column>
        <el-table-column
          prop="Title"
          label="标题">
        </el-table-column>
        <el-table-column
          prop="CourseClassName"
          label="分类类型">
        </el-table-column>
        <el-table-column
          prop="Duration"
          label="课程时长"
        >
          <template slot-scope="scope">
            <span>
              {{scope.row.Duration}}{{scope.row.DurationUnitStr}}
            </span>
          </template>
        </el-table-column>
        <el-table-column
          prop="PointNum"
          label="点数">

        </el-table-column>
        <el-table-column
          prop="IsGive"
          label="是否免费">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.IsFree==0" size="small" type="info">不免费</el-tag>
            <el-tag v-if="scope.row.IsFree==1" size="small" type="success">免费</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="StudentNumTypeStr"
          label="上课人数">

        </el-table-column>
        <el-table-column
          prop="IsPublic"
          label="是否为公开课"
        >
          <template slot-scope="scope">
            <span>
              {{scope.row.IsPublic==0?'不是':'是'}}
            </span>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="180"
        >
          <template slot-scope="scope">

            <el-tooltip class="item" effect="dark" content="编辑" placement="top" >
              <img src="../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="Edit(scope.row)">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top" >
              <img src="../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b(scope.row)">
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right"
                     background
                     @current-change="handleCurrentChange"
                     :page-size="msg.pageSize"
                     layout="prev, pager, next"
                     :current-page.sync="msg.pageIndex"
                     :total="count">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  export default {
    name: "onlineclassifyList",
    data(){
      return{
        msg:{
          pageIndex:1,
          pageSize:15,
        },
        changeState:false,
        dateList:[],

        tableData:[],
        count:0,
        loading:false,
        EnableMsg:{
          Ids:'',
          TeacherStatus:0,
        },
      }
    },
    created(){
      this.getDateList();//获取数据

    },
    methods:{
      getDateList(){
        this.loading=true;
        this.apipost("/api/Point/GetPointCourseClassPageList", this.msg, res => {
          this.loading=false;
          if(res.data.resultCode==1){
            this.tableData = res.data.data.pageData;
            this.count = res.data.data.count;
          }else {
            this.Info(res.data.message);
          }

        })
      },
      addRecharge(){
        this.$router.push('/addclassify');
      },

      Edit(row){
        this.$router.push({
          name: 'addclassify',
          query: {
            ID:row.ID,
            blank: "y"
          }
        });
      },
      delete_b(row){
        let that=this;
        that.Confirm("是否删除?", function () {
          that.apipost(
            "/api/Point/DeletePointCourseClass",
            {Id:row.ID},
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getDateList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });
      },
      getList(){
        this.msg.pageIndex = 1
        this.getDateList()
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getDateList();
      },
    },
  }
</script>

<style >
  .onlineclassifyList .el-card__header{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #fff;

  }
  .onlineclassifyList .el-button--small{
    padding: 9px 15px;
  }
  .onlineclassifyList .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
    /*margin-left: 10px;*/
  }
  .onlineclassifyList .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px;
    line-height: 30px;
  }
  .onlineclassifyList .content .searchInput{
    line-height: normal;
    display: inline-table;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
  }
  .onlineclassifyList .content{
    background: #fff;
    margin-top:10px;
    padding: 15px;
    box-sizing: border-box;
  }
  .onlineclassifyList .el-tag{
    margin-right: 5px;
  }
  .onlineclassifyList .app-image{
    background-position: center center;
    width: 50px;
    height: 50px;
    border-radius:0%;
    float: left;
    margin-right: 8px;
  }
</style>
