<template>
  <div class="context">
    <div class="">
      <div class="panel">
        <h5>预约管理</h5>
      </div>
      <div class="timeList">
        <ul>
          <li :class="[{'active': i == choiceDate}]" v-for="(day,i) in weeks" @click="choiceTime(i)">
            <em>{{ day.name }}</em><span>{{ day.data }}</span>
          </li>
        </ul>
      </div>
      <el-tabs v-model="activeName" type="card">

        <el-tab-pane label="会员预约列表" name="second">
          <div class="panel-body">
            <div class="panel_control">
              <el-row :gutter="1">
                <el-col :span="4">
                  <em>会员名:</em>
                  <el-input v-model="panel.name" placeholder="请输入会员名"></el-input>
                </el-col>
                <el-col :span="4">
                  <em>手机号:</em>
                  <el-input v-model="panel.phone" placeholder="请输入手机号" type="number"></el-input>
                </el-col>
                <el-col :span="4">
                  <em>预约课程:</em>
                  <el-select v-model="panel.class_id">
                    <el-option
                        v-for="item in panel.classOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                    </el-option>
                  </el-select>
                </el-col>
                <el-col :span="2">
                  <el-button size="" type="primary" @click="query" plain :disabled="searchBtnStatus">
                    查询
                  </el-button>
                </el-col>
                &nbsp;
                <el-col :span="8">
                  <el-button class="pull-right acrossAddBtn" type="success" @click="addAppoint(2)">跨店预约</el-button>
                  <el-button class="pull-right vipAddBtn" type="warning" @click="addAppoint(1)">本店预约</el-button>
                </el-col>
              </el-row>
            </div>
          </div>
          <br>
          <div class="table">
            <el-table
                :data="tableDataMember"
                border
                is-horizontal-resize
                :default-sort="{prop: 'date', order: 'descending'}"
                element-loading-background="rgba(0, 0, 0, 0.8)"
                class=""
                @selection-change="handleSelectionChange" @current-change="clickChange"
            >
              <el-table-column label="选择" width="55" fixed>
                <template slot-scope="scope">
                  <el-radio v-model="tableRadio" :label="scope.row"><i></i></el-radio>
                </template>
              </el-table-column>
              <el-table-column label="序号" type="index" width="50" align="center" fixed>
                <template scope="scope">
                  <span>{{ (start) + scope.$index + 1 }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  prop="user_name"
                  label="会员名"
                  fixed
              >
              </el-table-column>
              <el-table-column
                  prop="usercode"
                  label="手机号"
                  width="160"
                  sortable
                  fixed
              >
              </el-table-column>
              <el-table-column
                  prop="class_name"
                  label="预约课程"
                  width="120"
                  sortable
              >
                <template slot-scope="scope">
                  <span class="lessons" :style="{ background:scope.row.class_color }">{{ scope.row.class_name }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  prop="begin_time"
                  label="上课时间"
                  :formatter="filterFmtDate"
                  width="160"
                  sortable
              >
              </el-table-column>
              <el-table-column
                  prop="created_at"
                  label="会员预约时间"
                  width="160"
                  :formatter="filterFmtDate"
                  sortable
              >
              </el-table-column>
              <el-table-column
                  prop="consume_hour"
                  label="消耗课时"
                  sortable
              >
              </el-table-column>
              <el-table-column
                  prop="remain_hour"
                  label="剩余课时"
                  sortable
              >
              </el-table-column>
              <el-table-column
                  prop="status"
                  label="预约状态"
                  sortable
              >
                <template slot-scope="scope">
                  <span v-if="scope.row.status == 1" style="color: chartreuse">已预约</span>
                  <span v-if="scope.row.status == 2" style="color: #ccc">已取消</span>
                  <span v-if="scope.row.status == 3" style="color: red">预约未到</span>
                  <span v-if="scope.row.status == 4" style="color: #015B9E">已完成</span>
                </template>
              </el-table-column>
              <el-table-column
                  prop="status"
                  label="操作"
              >
                <template slot-scope="scope">
                  <el-button type="danger" size="mini" round
                             @click="cancelMemberReserve(scope.row)">取消预约
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <br>
            <el-pagination
                background
                :total="pagination.total"
                :page-size="pagination.pageItem"
                @current-change="pageChange"
            ></el-pagination>
          </div>
        </el-tab-pane>

        <el-tab-pane label="课程预约列表" name="first">
          <div class="table">
            <el-table
                :data="tableDataLesson"
                border
                is-horizontal-resize
                :default-sort="{prop: 'date', order: 'descending'}"
                element-loading-background="rgba(0, 0, 0, 0.8)"
                class=""
                @selection-change="handleSelectionChange" @current-change="clickChange"
            >
              <el-table-column label="序号" type="index" width="50" align="center">
                <template scope="scope">
                  <span>{{ (start) + scope.$index + 1 }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  prop="begin_time"
                  label="上课时间"
                  width="160"
                  :formatter="filterFmtDate"
              >
              </el-table-column>
              <el-table-column
                  prop="class_name"
                  label="课程"
                  width="110"
                  sortable
              >
                <template slot-scope="scope">
                  <span class="lessons" :style="{ background:scope.row.class_color }">{{ scope.row.class_name }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  prop="Recovered"
                  label="预约比例"
                  width="210px"
                  sortable
              >
                <template slot-scope="scope">
                  <el-progress
                      :percentage="parseInt((scope.row.order_count/scope.row.order_toplimit * 100))"
                      :format="appointPercent"
                  ></el-progress>
                </template>
              </el-table-column>
              <el-table-column
                  prop="order_toplimit"
                  label="预约名额"
              >
              </el-table-column>
              <el-table-column
                  prop="order_count"
                  label="预约人数"
              >
              </el-table-column>
              <el-table-column
                  prop="consume_hour"
                  label="消耗课时"
              >
              </el-table-column>
              <el-table-column
                  prop="std_id"
                  label="操作"
                  width=70px
              >
                <template slot-scope="scope">
                  <el-button type="text" @click="getAppointDetail(scope.row)">详情</el-button>
                </template>
              </el-table-column>
            </el-table>
            <br>
            <el-pagination
                background
                :total="pagination.total"
                :page-size="pagination.pageItem"
                @current-change="pageChange"
            ></el-pagination>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <el-dialog :title="dialogTitle" :visible.sync="dialogAppointVisible" width="650px">
      <div class="dialogContent">
        <div class="">
          <el-form ref="form" :model="form" label-width="160px">
            <el-form-item label="当前日期" :required="true">
              <el-input v-model="form.displayDay" placeholder="placeholder" :disabled="true"
                        style="width: 220px"></el-input>
            </el-form-item>
            <el-form-item label="课程" :required="true">
              <el-select v-model="form.stb_id" filterable placeholder="请选择"
                         @change="getUserByClass(form.stb_id)">
                <el-option
                    v-for="item in form.stdList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <!-- 课程联动查询userlist by classid-->
            <el-form-item label="本店会员" :required="true" v-if="form.addType == 1 ">
              <el-select v-model="form.userId" filterable placeholder="请选择"
                         @change="checkUserSelect(form.userId)">
                <el-option
                    v-for="item in form.userList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="跨店会员" :required="true" v-if="form.addType == 2 ">
              <el-select v-model="form.userId" filterable placeholder="请选择"
                         @change="checkUserSelect(form.userId)">
                <el-option
                    v-for="item in form.userList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="消耗课时">
              <el-input v-model="form.ConsumeHour" placeholder="placeholder" :disabled="true"
                        style="width: 220px"></el-input>
            </el-form-item>
            <el-form-item label="会员剩余课时">
              <el-input v-model="form.remain" placeholder="placeholder" :disabled="true"
                        style="width: 220px"></el-input>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div class="dialogFooter">
        <el-button type="primary" size="small" @click="confirmAddAppoint"
                   :disabeld="BtnConfirmOrderAddByManager">确定
        </el-button>
        <el-button size="small" @click="dialogAppointVisible = false">取消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="预约会员" :visible.sync="dialogTableVisible" width="650px">
      <el-table :data="gridData">
        <el-table-column property="user_name" label="姓名" width="200"></el-table-column>
        <el-table-column property="usercode" label="手机"></el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import Global from '../../Global.js'
import {
  StandardRequest
} from "@/grpc/base_pb";

let qs = require('qs');
export default {
  data() {
    return {
      BtnConfirmOrderAddByManager: false,
      searchBtnStatus: false,
      activeName: 'second',
      choiceDate: 0,//默认为今天
      dialogTableVisible: false,
      dialogAppointVisible: false,
      dialogTitle: '增加预约',
      weeks: [],
      gridData: [],
      //控制分页相关
      start: 0,
      draw: 1,
      // panel 配置项目
      panel: {
        name: '',
        phone: '',
        class_id: -99,
        draw: 1,
        start: 0,
        recordsTotal: 0,
        recordsTotal2: 0,
        allTableData: [],
        allTableData2: [],
        multipleSort: false,
        loading: false,
        multipleSelection: [],
      },
      multipleSelection: [],
      pagination: {
        pageItem: 100,
        pageOptions: pageOptions(),
        total: 100,
        pageIndex: 1,
      },
      form: {
        name: '',
        displayDay: '',
        userCode: '',
        shopId: '',
        stdId: 0,
        userId: 0,
        btnType: 0,//0新建，1编辑编辑
        userList: [],//穿梭已选
        stdList: [],//穿梭已选
        remain: 0,
        ConsumeHour: 0,
        addType: 0
      },
      tableDataLesson: [],
      tableDataMember: [],
      tableRadio: [],
    }
  },
  mounted() {
    if (this.$route.query.page == 'second') {
      this.panel.name = this.$route.query.name;
      this.activeName = 'second'
    } else {
      this.activeName = 'second'
    }
    //加载可查询的课程列表
    this.panelSelect();
    //加载会员预约页面右侧的日期
    this.getFutureDays();
  },
  methods: {
    clickChange(item) {
      this.tableRadio = item
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 选择右上方日期
    choiceTime(i) {
      this.choiceDate = parseInt(i);
      // 读取当前页
      if (this.activeName == 'first') {
        this.lessonAppointTableQuery();
      } else {
        // second
        this.memberAppointTableQuery();
      }
    },
    panelSelect() {
      let that = this;
      const jsonStr = {
        shopId: localStorage.shopId,
        classId: -99
      };
      let paraRequest = new StandardRequest();
      paraRequest.setShopid(localStorage.shopId);
      paraRequest.setJsonstr(JSON.stringify(jsonStr));
      paraRequest.setSign(getSignStr(jsonStr));
      console.log(paraRequest);
      that.client.classSimpleQuery(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
        if (err == null) {
          console.log(StandardReply.getJsonrst());
          let res = JSON.parse(StandardReply);
          if (res.code == 0) {
            if(res.rs){
              that.panel.classOptions = turnClassResToOption(res.rs);
              that.panel.classOptions.unshift({value: -99, label: '全部'})
            }else {
              return false;
            }
          } else {
            that.$message.error(res.memo + ',错误代码：' + res.code);
          }
        } else {
          let res = err;
          that.$message.error(res.message + ',错误代码：' + res.code);
          console.log(res);
        }
      });
    },
    //获取包含今天未来7天的日期
    getFutureDays() {
      let now = new Date();
      let nowTime = now.getTime();
      let oneDayTime = 24 * 60 * 60 * 1000;
      let days = '';
      let item = [];
      let month = 0;
      let day = 0;
      for (let i = 0; i < 7; i++) {
        days = new Date(nowTime + (i) * oneDayTime);//显示周日
        month = days.getMonth() + 1;
        day = days.getDate();
        month = month < 10 ? '0' + month : month;
        day = day < 10 ? '0' + day : day;
        item = {
          name: this.numberToWeek(days.getDay()),
          data: days.getMonth() + 1 + '月' + days.getDate() + '日',
          orderDate: days.getFullYear() + '-' + month + '-' + day
        }
        this.weeks.push(item)
      }
      this.memberAppointTableQuery();
      this.lessonAppointTableQuery();
    },
    //获取门店该课程下的人员
    getUserByClass(stdId) {
      let that = this;
      // 筛选相同的stdId的classId
      that.form.stdList.map(function (item) {
        if (item.value == stdId) {
          that.form.ConsumeHour = item.ConsumeHour;

          let paraRequest = new StandardRequest();
          paraRequest.setShopid(localStorage.shopId);

          //添加本店会员
          if (that.form.addType == 1) {
            const jsonStr = {
              shopId: localStorage.shopId,
              classId: item.classId,//-99代表查询全部
              isAcross: 0//0：不跨店 1跨店  -99是全部
            };
            paraRequest.setJsonstr(JSON.stringify(jsonStr));
            paraRequest.setSign(getSignStr(jsonStr));
          }

          //添加跨店会员
          if (that.form.addType == 2) {
            const jsonStr = {
              shopId: localStorage.shopId,
              classId: item.classId,//-99代表查询全部
              isAcross: 0//0：不跨店 1跨店  -99是全部
            };
            paraRequest.setJsonstr(JSON.stringify(jsonStr));
            paraRequest.setSign(getSignStr(jsonStr));
          }

          console.log(paraRequest);
          that.client.vipUserSimpleQuery(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
            if (err == null) {
              console.log(StandardReply.getJsonrst());
              let res = JSON.parse(StandardReply);
              if (res.code === 0) {
                that.form.userId = '';
                that.form.userList = turnResToOptionBySimViper(res.rs);
              } else {
                that.$message.error(res.memo + ',错误代码：' + res.code);
              }
            } else {
              let res = err;
              that.$message.error(res.message + ',错误代码：' + res.code);
              console.log(res);
            }
          });
        }
      })
    },
    //更新选中会员的剩余课时
    checkUserSelect(userId) {
      let that = this;
      this.form.userList.filter((v) => {
        if (v.key == userId) {
          that.form.remain = v.RemainHour;
        }
      })

    },
    //取消用户预约
    cancelMemberReserve(row) {
      let that = this;
      this.$confirm('是否取消用户  ' + row.user_name + '  的预约？', '取消预约', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const jsonStr = {
          UuOrderId: row.uu_order_id,
        };

        let paraRequest = new StandardRequest();
        paraRequest.setShopid(localStorage.shopId);
        paraRequest.setJsonstr(JSON.stringify(jsonStr));
        paraRequest.setSign(getSignStr(jsonStr));
        console.log(paraRequest);
        that.client.orderCancelByManager(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
          if (err == null) {
            console.log(StandardReply.getJsonrst());
            let res = JSON.parse(StandardReply);
            if (res.code === 0) {
              that.$message({
                showClose: true,
                message: row.user_name + '取消预约成功！',
                type: 'success'
              });
              // table 重载
              that.memberAppointTableQuery();
            } else {
              that.$message.error(res.memo + ',错误代码：' + res.code);
            }
          } else {
            let res = err;
            that.$message.error(res.message + ',错误代码：' + res.code);
            console.log(res);
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        });
      });
    },
    clearForm() {
      // clear
      this.form.stb_id = '';
      this.form.userId = '';
      this.form.name = '';
      this.form.userCode = '';
      this.form.shopId = '';
      this.form.userList = [];
    },
    //新增预约
    addAppoint(addType) {
      this.clearForm();
      // 加载当前可选课程
      this.getClassListByOrderDate();
      //控制弹出窗口数据
      this.dialogAppointVisible = true;
      this.form.displayDay = this.weeks[this.choiceDate].data + ' ' + this.weeks[this.choiceDate].name;
      this.btnType = 0;
      this.form.ConsumeHour = 0;
      this.form.addType = addType
      this.dialogTitle = '新增预约';
    },
    //提交预约
    confirmAddAppoint() {
      let that = this;
      that.BtnConfirmOrderAddByManager = true;
      const jsonStr = {
        UUStdId: this.form.stb_id,
        UuUserId: this.form.userId,
      };

      let paraRequest = new StandardRequest();
      paraRequest.setShopid(localStorage.shopId);
      paraRequest.setJsonstr(JSON.stringify(jsonStr));
      paraRequest.setSign(getSignStr(jsonStr));
      console.log(paraRequest);
      that.client.orderAddByManager(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
        that.BtnConfirmOrderAddByManager = false;
        if (err == null) {
          console.log(StandardReply.getJsonrst());
          let res = JSON.parse(StandardReply);
          if (res.code === 0) {
            that.$message({
              showClose: true,
              message: '预约添加成功！',
              type: 'success'
            });
            this.memberAppointTableQuery();
            that.dialogAppointVisible = false;
          } else {
            that.$message.error(res.memo + ',错误代码：' + res.code);
          }
        } else {
          let res = err;
          that.$message.error(res.message + ',错误代码：' + res.code);
          console.log(res);
        }
      });
    },
    // 加载当前可选课程
    getClassListByOrderDate() {
      let that = this;
      let dayIndex = parseInt(this.choiceDate);

      const jsonStr = {
        shopId: localStorage.shopId,
        orderDate: this.weeks[dayIndex].orderDate
      };

      let paraRequest = new StandardRequest();
      paraRequest.setShopid(localStorage.shopId);
      paraRequest.setJsonstr(JSON.stringify(jsonStr));
      paraRequest.setSign(getSignStr(jsonStr));
      console.log(paraRequest);
      that.client.classListByOrderDate(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
        if (err == null) {
          console.log(StandardReply.getJsonrst());
          let res = JSON.parse(StandardReply);
          if (res.code === 0) {
            that.form.stdList = turnStdToOption(res.rs);
          } else {
            that.$message.error(res.memo + ',错误代码：' + res.code);
          }
        } else {
          let res = err;
          that.$message.error(res.message + ',错误代码：' + res.code);
          console.log(res);
        }
      });
    },
    //查看课程预约详情
    getAppointDetail(row) {
      let that = this;
      const jsonStr = {
        UUStdId: row.uu_std_id
      };

      let paraRequest = new StandardRequest();
      paraRequest.setShopid(localStorage.shopId);
      paraRequest.setJsonstr(JSON.stringify(jsonStr));
      paraRequest.setSign(getSignStr(jsonStr));
      console.log(paraRequest);
      that.client.userOrderQueryByStd(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
        if (err == null) {
          console.log(StandardReply.getJsonrst());
          let res = JSON.parse(StandardReply);
          if (res.code === 0) {
            if(res.rs){
              this.dialogTableVisible = true;
              this.gridData = res.rs;
            }else{
              that.$message.info("当前课程暂无预约");
            }
          } else {
            that.$message.error(res.memo + ',错误代码：' + res.code);
          }
        } else {
          let res = err;
          that.$message.error(res.message + ',错误代码：' + res.code);
          console.log(res);
        }
      });
    },
    appointPercent(percentage) {
      return percentage === 100 ? '已满' : `${percentage}%`;
    },
    //查询按钮
    query() {
      let that = this;
      that.searchBtnStatus = true;
      let totalTime = 2
      let clock = window.setInterval(() => {
        totalTime--
        if (totalTime < 0) {
          totalTime = 2;
          that.searchBtnStatus = false;
        }
      }, 1000)
      this.memberAppointTableQuery();
      this.$message.success('查询完毕');
    },
    //页面数据-课程预约-查询
    lessonAppointTableQuery() {
      let that = this;
      that.loading = true;
      let dayIndex = parseInt(this.choiceDate);
      //含参数调用过程
      const jsonStr = {
        shopId: localStorage.shopId,
        orderDate: this.weeks[dayIndex].orderDate,
        start:that.start,
        tableMax:that.pagination.pageItem
      };

      console.log(localStorage.token);
      let paraRequest = new StandardRequest();
      paraRequest.setShopid(localStorage.shopId);
      paraRequest.setJsonstr(JSON.stringify(jsonStr));
      paraRequest.setSign(getSignStr(jsonStr));
      console.log(paraRequest);
      that.client.classOrderQuery(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
        if (err == null) {
          console.log(StandardReply.getJsonrst());
          let res = JSON.parse(StandardReply);
          if (res.code === 0) {
            that.loading = false;
            if (res.rs) {
              that.allTableData = [];
              that.allTableData = res.rs;
              that.recordsTotal = res.rs.length;
            } else {
              that.allTableData = [];
              that.recordsTotal = 0;
            }
            // 设置分页数据
            that.setPagination();
          } else {
            that.$message.error(res.memo + ',错误代码：' + res.code);
          }
        } else {
          let res = err;
          that.$message.error(res.message + ',错误代码：' + res.code);
          console.log(res);
        }
      })
    },
    //页面数据-用户预约-查询
    memberAppointTableQuery() {
      let that = this;
      that.loading = true;
      let dayIndex = parseInt(this.choiceDate);
      const jsonStr = {
        shopId: localStorage.shopId,
        classId: this.panel.class_id,
        name: this.panel.name,
        phone: this.panel.phone,
        orderDate: this.weeks[dayIndex].orderDate,
        start:that.start,
        tableMax:that.pagination.pageItem
      };
      let paraRequest = new StandardRequest();
      paraRequest.setShopid(localStorage.shopId);
      paraRequest.setJsonstr(JSON.stringify(jsonStr));
      paraRequest.setSign(getSignStr(jsonStr));
      console.log(paraRequest);
      that.client.vipUserOrderQuery(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
        if (err == null) {
          console.log(StandardReply.getJsonrst());
          let res = JSON.parse(StandardReply);
          if (res.code === 0) {
            that.loading = false;
            if (res.rs) {
              that.allTableData2 = res.rs;
              that.recordsTotal2 = res.rs.length;
            } else {
              that.allTableData2 = [];
              that.recordsTotal2 = 0;
            }
            // 设置分页数据
            that.setPagination2();
          } else {
            that.$message.error(res.memo + ',错误代码：' + res.code);
          }
        } else {
          let res = err;
          that.$message.error(res.message + ',错误代码：' + res.code);
          console.log(res);
        }
      });
    },
    // 设置分页数据
    setPagination() {
      // 分页属性
      let that = this;
      that.pagination.total = that.recordsTotal;

      // 默认分页
      that.tableDataLesson = that.allTableData.filter((item, index) => {
        return index < that.pagination.pageItem;
      });
    },
    // 设置分页数据
    setPagination2() {
      // 分页属性
      let that = this;
      that.pagination.total = that.recordsTotal2;
      // 默认分页
      that.tableDataMember = that.allTableData2.filter((item, index) => {
        return index < that.pagination.pageItem;
      });
    },
    // 每页显示数量
    handleSizeChange() {
      let that = this;
      that.tableDataLesson = that.allTableData.filter((item, index) => {
        return index < that.pagination.pageItem;
      });
      that.draw = that.pagination.pageItem;
      that.lessonAppointTableQuery();
    },
    // 翻页
    pageChange(pageIndex) {
      let that = this;
      // 获取当前页
      let index = that.pagination.pageItem * (pageIndex - 1);
      // 数据总数
      let nums = that.pagination.pageItem * pageIndex;
      // 容器
      let tables = [];
      for (let i = index; i < nums; i++) {
        if (that.allTableData[i]) {
          tables.push(that.allTableData[i])
        }
        this.tableDataLesson = tables;
      }
      that.start = index * that.draw;
      // that.lessonAppointTableQuery();
    },
    // 自动排序
    sortChange(params) {
      console.log(params)
    },
    // 过滤时间
    filterFmtDate(value, row, column) {
      return nonTfmtDate(column, 11);
    },
    // 过滤金额
    filterMoney(value, row, column) {
      let that = this;
      return parseFloat(column).toFixed(2);
    },
    numberToWeek(val) {
      switch (parseInt(val)) {
        case 1:
          return '星期一';
          break;
        case 2:
          return '星期二';
          break;
        case 3:
          return '星期三';
          break;
        case 4:
          return '星期四';
          break;
        case 5:
          return '星期五';
          break;
        case 6:
          return '星期六';
          break;
        case 0:
          return '星期天';
          break;
      }
    }
  },
  watch: {
    $route(to) {
      if (to.name == 'appointManage') {
        this.panelSelect();
        if (this.$route.query.page == 'second') {
          this.activeName = 'second';
          this.panel.name = this.$route.query.name;
          this.memberAppointTableQuery();
        }
      }
    },
    activeName(val) {
      // 重置一次选择
      this.tableRadio = [];
      if (val == 'first') {
        this.lessonAppointTableQuery();
      } else {// second
        this.memberAppointTableQuery();
        this.panelSelect();
      }
    },
  }
}
</script>

<style scoped>
@import "../../assets/css/panel.css";

.context {
  /* height: 770px; */

  overflow-y: scroll;
  display: block;
  margin: 0 auto;
  background-color: #fff !important;
  padding: 30px;
}

.panel-body {
  padding: 20px;
  background: #F0F2F5;
}

.change {
  width: 100%;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  padding-top: 10px;
  padding-bottom: 10px;
}

.change button {
  float: left;
}

.change button.pull-right {
  float: right;
}

.dialogTitle {
  width: 100%;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  color: #000000;
  font-size: 18px;
  text-align: center;
}

.dialogTitle em {
  float: none;
  font-style: normal;
  color: #3799FF;
  margin: 0;
}

/deep/ .el-transfer-panel__item .el-checkbox__input {
  left: 40px;
}

.dialogFooter {
  width: 90%;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  margin-top: 10px;
}

.dialogFooter button {
  float: right;
  margin-left: 10px;
}

.dialogContent {
  width: 100%;
  overflow: hidden;
  display: block;
  margin: 0 auto;
}

.dialogContent .pull-left {
  width: 30%;
  float: left;
}

.dialogContent .pull-right {
  width: 70%;
  float: right;
}

.current {
  width: 158px;
  height: 23px;
  /*float: left;*/
  border-radius: 250px;
  text-align: center;
  background: #F0F2F5;
  color: #545454;
  font-size: 14px;
  padding: 3px 10px;
  margin-left: 20px;
}

.timeList {
  width: 800px;
  overflow: hidden;
  float: right;
  position: relative;
  z-index: 100;
  cursor: pointer;
}

.timeList ul {
  width: 100%;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  list-style: none;
}

.timeList li {
  width: 100px;
  overflow: hidden;
  list-style: none;
  float: left;
  margin-right: 6px;
  border: 1px solid #ccc;
  border-bottom: 0;
  text-align: center;
  height: 40px;
  background: #fff;
  z-index: 222;
}

em {
  font-style: normal;
}

.timeList em {
  width: 100%;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  font-size: 14px;
  text-align: center;
}

.timeList span {
  width: 100%;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  font-size: 12px;
  text-align: center;
}

.timeList li.active {
  border: 1px solid #3799FF;
  border-bottom: 0;
}

.timeList li.active em {
  color: #3799FF;
}

.timeList li.active span {
  color: #3799FF;
}

.panel_control /deep/ .el-input {
  max-width: 140px;
  float: left;
}

.panel-body em {
  float: left;
  line-height: 40px;
  margin-right: 10px;
}

.gary {
  border: 1px solid #ccc;
  border-bottom: 0;
  color: #ccc;
}

.pull-right {
  float: right;

}

.lessons {
  padding: 1px 7px;
  border-radius: 250px;
  float: left;
  color: #000;
}

/deep/ .el-progress__text {
  position: relative;
  top: 1px;
  float: right;
  line-height: 14px;
  height: 16px;
}

/deep/ .el-progress-bar {
  width: 190px;
  float: left;
  overflow: hidden;
  margin-top: 5px;
}

.timeList li.active {
  color: #fff;
  background: #409EFF;
}

.timeList li.active span, .timeList li.active em {
  color: #fff;
}

.vipAddBtn {
  margin-right: 10px;
}

/*ipad only*/
@media only screen and (max-width: 1366px) {
  .panel-body em {
    font-size: 12px;
  }

  .timeList {
    width: 510px;
  }

  .timeList li {
    width: 60px;
    font-size: 12px;
  }

  .timeList em {
    font-size: 12px;
  }

  .timeList span {
    font-size: 12px;
  }

  .panel_control /deep/ .el-input {
    width: 130px;
  }

  /deep/ .el-button--warning {
    margin-bottom: 5px;
  }

  .acrossAddBtn {
    margin-right: 0;
  }

}
</style>
