<template>
  <div class="subPage">
    <div class="system-table-search">
      <div class="flex-h">
        <div class="flex-item flex-h"></div>
        <ul>
          <li>
            <el-select v-model="postData.caseid" placeholder="请选择">
              <el-option
                v-for="item in cases"
                :key="item.CaseId"
                :label="item.CaseName"
                :value="item.CaseId">
              </el-option>
            </el-select>
          </li>
          <li>
            <el-input
              placeholder="请输入课程名称"
              v-model="postData.name"
            >
            </el-input>
          </li>
        </ul>
        <el-button
          size="mini"
          type="primary" @click="search">搜索</el-button>
      </div>
      <div class="moreFilter"></div>
    </div>
    <div class="system-table-box">
      <el-table
        :data="currentList"
        stripe
        style="width: 100%">
        <el-table-column
          prop="CourseName"
          label="课程名称">
        </el-table-column>
        <el-table-column
          prop="Price"
          label="课程价格">
        </el-table-column>
        <el-table-column
          prop="CourseNum"
          label="课时数">
        </el-table-column>
        <el-table-column
          prop="ScheduleNum"
          label="已排课时数">
        </el-table-column>
        <el-table-column
          prop="LocationId"
          label="课程分类">
        </el-table-column>
        <el-table-column
          prop="CaseName"
          label="所在案场">
        </el-table-column>
        <el-table-column
          label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="success"
              @click="setCourseDate(item)">设置课程时间</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page.sync="postData.page"
      :page-size="postData.pagesize"
      layout="prev, pager, next, jumper"
      :total="total">
    </el-pagination>
    <el-dialog
      title="设置课时时间"
      :visible.sync="centerDialogVisible"
      width="500px"
      center>
      <div>
        <ul class="courseDetailForm">
          <li class="flex-h">
            <span>开始时间：</span>
            <div class="flex-item">
              <div>
                <el-date-picker
                  v-model="currentCourseItem.BeginDate"
                  type="date"
                  placeholder="选择开始日期">
                </el-date-picker>
              </div>
            </div>
          </li>
          <li class="flex-h">
            <span>结束时间：</span>
            <div class="flex-item">
              <div>
                <el-date-picker
                  v-model="currentCourseItem.EndDate"
                  type="date"
                  placeholder="选择结束日期">
                </el-date-picker>
              </div>
            </div>
          </li>
          <li class="flex-h">
            <span>课时名称：</span>
            <div class="flex-item">
              <div>
                <el-input
                  placeholder="请输入课时名称"
                  v-model="currentCourseItem.DetailName"
                  clearable>
                </el-input>
              </div>
            </div>
          </li>
          <li class="flex-h">
            <span>课时描述：</span>
            <div class="flex-item">
              <div>
                <el-input
                  type="textarea"
                  placeholder="请输入课时描述"
                  v-model="currentCourseItem.DetailDesc"
                  clearable>
                </el-input>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
        <el-button type="danger" @click="centerDialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: '',
  data () {
    return {
      currentCourseItem: { // 当前设置课程时间
        BeginDate: null,
        EndDate: null,
        DetailName: null,
        DetailDesc: null,
      },
      centerDialogVisible: false,
      total: 0,
      postData: { // 表格搜索条件
        caseid: '', // 案场id
        page: 1, // 当前页码
        pagesize: 10, // 请求数据量
        typeid: '', // 课程类型
        name: '', // 课程名称
      },
      currentList: [{
        CourseName: 'xxx',
        Price: 'xxx',
        CourseNum: 'xxx',
        ScheduleNum: 'xxx',
        LocationId: 'xxx',
        CaseName: 'xxx',
      }],
      courseTypeList: [],
    }
  },
  mounted () {
    this.$nextTick(function () {
      this.getList()
    })
  },
  computed: {
    ...mapState({
      cases: x => x.app.cases.list,
      defaultCaseId: x => x.app.cases.default
    }),
    CaseId: {
      get () {
        return this.postData.caseid || this.defaultCaseId
      },
      set (val) {
        this.postData.caseid = val
      }
    }
  },
  methods: {
    setCourseDate (item) { // 设置课程时间
      this.centerDialogVisible = true
    },
    search () { // 搜索
      this.postData.page = 1
      this.currentList = []
      this.getList()
    },
    getList () { // 获取列表
    },
    handleCurrentChange (val) { // 跳转到分页
      this.getList()
    },
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import "page.scss";
</style>
