<template>
  <div>

    <div>
      <div ref="lxHeader">
        <lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
          <div slot="content">
            <div class="searchwrap" style="display: flex;align-items: center;">
              <div>
                <el-input v-model="select.name" placeholder="请输入课程名称"></el-input>
              </div>
              <div>
                <el-date-picker v-model="select.daterange" type="daterange" range-separator="至" start-placeholder="开课日期"
                  end-placeholder="结束日期">
                </el-date-picker>
              </div>
              <div>
                <el-select v-model="select.type" placeholder="请选择类别" clearable>
                  <el-option v-for="item in type_options" :key="item.id" :label="item.value" :value="item.id">
                  </el-option>
                </el-select>
              </div>
              <div>
                <el-select v-model="select.status" placeholder="请选择课程状态" clearable>
                  <el-option v-for="item in status_options" :key="item.id" :label="item.value" :value="item.id">
                  </el-option>
                </el-select>
              </div>
              <div>
                <el-button type="primary" size="small">查询</el-button>
              </div>
              <div>
                <el-button type="primary" size="small" @click="editCourse('add')">新增课程</el-button>
              </div>
            </div>
          </div>

        </lx-header>
      </div>
    </div>

    <div>
      <xy-table :list="list" :total="total" :table-item="table_item">
        <template v-slot:btns>
          <el-table-column align='center' label="操作" width="380" header-align="center">
            <template slot-scope="scope">
              <el-button type="primary" size="small" @click="editCourse('add',scope.row.id)">编辑</el-button>
              <el-button type="danger" size="small">删除</el-button>
              <el-button type="primary" size="small" @click="toTxl">通讯录</el-button>
              <el-button type="primary" size="small" @click="toPay">缴费</el-button>
              <el-button type="primary" size="small" @click="showQrCode">二维码</el-button>
            </template>
          </el-table-column>
        </template>
      </xy-table>
    </div>

    <add-course ref="addCourse"></add-course>
    <show-code ref="showCode"></show-code>
  </div>
</template>

<script>
  import addCourse from './components/addCourse.vue';
  import showCode from './components/showCode.vue';

  export default {
    components: {
      addCourse,
      showCode
    },
    data() {
      return {
        select: {
          name: '',
          daterange: '',
          type: ''
        },
        type_options: [{
          id: 0,
          value: '常规课程'
        }, {
          id: 1,
          value: '短期课程'
        }],
        status_options: [{
          id: 0,
          value: '进行中'
        }, {
          id: 1,
          value: '未开始'
        }],
        list: [{
          name: '第六期高级科创人才研修班',
          daterange: '2024.3.1-2024.9.1',
          type: '常规课程',
          status: '进行中',
          status2: '已发布'
        }],
        total: 0,
        table_item: [{
          prop: 'name',
          label: '课程名称',
          align: 'left'
        }, {
          prop: 'daterange',
          label: '开课日期',
          align: 'center',
          width: 180,
        }, {
          prop: 'type',
          label: '类别',
          align: 'center',
          width: 160,
        }, {
          prop: 'status',
          label: '课程状态',
          align: 'center',
          width: 180,
        }, {
          prop: 'status2',
          label: '发布状态',
          align: 'center',
          width: 180,
        }]

      }
    },
    created() {

    },
    methods: {
      editCourse(type, id) {

        this.$refs.addCourse.type = type
        this.$refs.addCourse.isShow = true
      },
      showQrCode() {
        this.$refs.showCode.isShow = true
      },
      toTxl() {
        window.location.href = '/admin/#/course/txl'
      },
      toPay(){
        window.location.href = '/admin/#/course/pay'
      },
      deleteList() {
        var that = this;
        destroy({
          id: this.id,
          table_name: 'new_plans'
        }).then(response => {
          this.$Message.success('操作成功');
          this.isShow = false
          this.$emit('refresh')
        }).catch(error => {
          console.log(error)
          reject(error)
        })
      },
    }
  }
</script>

<style lang="scss" scoped>
  .searchwrap {
    display: flex;
    align-items: center;

    &>div {
      display: flex;
      align-items: center;
      margin-right: 10px;

      span {
        min-width: 70px;
      }
    }
  }
</style>
