<template>
  <div>
    <q-dialog v-model="show" persistent transition-show="scale" transition-hide="scale" @input="changeDig">
      <q-card style="width: 800px;max-width:900px;">
        <q-card-section class="row items-center q-pb-none">
          <div class="text-h6">{{ editType == 1 ? "新增约课" : "详情" }}</div>
          <q-space />
          <q-btn icon="close" flat round dense @click="changeDig(false)" />
        </q-card-section>
        <q-card-section class="q-pt-none scroll" style="max-height: 70vh">
          <div class="row col q-mr-lg q-col-gutter-md">
            <q-field filled label="日期" stack-label class="col-12">
              <template v-slot:control>
                <div>{{ dateObj.date }} </div>
              </template>
            </q-field>
            <!-- 详情显示内容 start-->
            <div class="col-12" v-if="editType == 2">
              <Detail :dateObj="dateObj" :saveObj="saveObj" :auth="auth" :CourseChapterName="CourseChapterName"
                @success="detailSuccessHandle" @close="detailCloseHandle" />
            </div>
            <!-- 详情显示内容 end -->
            <q-select filled stack-label use-input option-value="CourseId" option-label="CourseName"
              v-model="saveMsg.CourseId" ref="CourseId" :options="CourseList" label="课程" :dense="false" class="col-12"
              emit-value map-options @filter="filterCourse"
              @input="changeCourse(),getChapterTree(),getCanTeacherTimeList() " v-if="editType == 1"
              :rules="[val => !!val || '请选择课程']">
              <template v-slot:no-option>
                <q-item>
                  <q-item-section class="text-grey">
                    未找到相关数据
                  </q-item-section>
                </q-item>
              </template>
              <template v-slot:option="scope">
                <q-item v-bind="scope.itemProps" v-on="scope.itemEvents">
                  <q-item-section>
                    <q-item-label class="row flex justify-between">
                      <span>{{scope.opt.CourseName}}</span><span> 最小成班人数 {{ scope.opt.ScrollMinNum}} 人</span>
                    </q-item-label>
                  </q-item-section>
                </q-item>
              </template>
            </q-select>
            <select-tree v-show="saveMsg.CourseId > 0 && editType == 1" :treeData="chapterList"
              :defaultArray="returnString" nodeKey="ChapterId" labelKey="ChapterName" childrenKey="ChildList"
              tipText="章节" @getChild="getChapter" class="col-12" ref="selectTree"></select-tree>

            <div class="row col-12 q-col-gutter-md">
              <q-select v-show="saveMsg.CourseId > 0 && editType == 1" filled v-model="saveMsg.TeacherId"
                option-value="TId" option-label="TeacherName" :options="teacherList" emit-value map-options label="老师"
                class="col-6" @input="getCanTeacherTimeList" />
              <q-select v-show="saveMsg.CourseId > 0 && editType == 1" filled v-model="saveMsg.RoomId"
                option-value="RoomId" option-label="RoomName" :options="ClassRoomList" emit-value map-options label="教室"
                :disable="addStuList.length > 0" class="col-6">
                <template v-slot:selected-item="scope">
                  <div class="row col-12 flex justify-between">
                    <span>{{scope.opt.RoomName}}</span><span>{{ scope.opt.SchoolName}}</span></div>
                </template>
                <template v-slot:option="scope">
                  <q-item v-bind="scope.itemProps" v-on="scope.itemEvents">
                    <q-item-section>
                      <q-item-label class="row flex justify-between">
                        <span>{{scope.opt.RoomName}}</span><span>{{ scope.opt.SchoolName}}</span></q-item-label>
                    </q-item-section>
                  </q-item>
                </template>
              </q-select>
            </div>
            <template v-if="editType==1">
              <q-field filled label-slot stack-label class="col-12" v-if="editType==1 ">
                <template #label>
                  <div class="row flex">
                    上课时段
                    <span style="color:#f5576c;font-size:13px;margin-left:5px;font-weight:500">(按顺序选择)</span>
                    <div style="color:#333;font-size:13px;margin-left:10px;font-weight:500">
                      需选课时：{{ checkChapter.StudyMinutes }}分钟
                    </div>
                  </div>
                </template>
                <template v-slot:control>
                  <div v-if="teacherTimeList.length > 0">
                    <div v-for="(item, index) in teacherTimeList" :key="index">
                      <div v-if="
                        item.CourseTimeList && item.CourseTimeList.length > 0
                      ">
                        <div v-for="(_item, _index) in item.CourseTimeList" :key="_index" class="timeItem">
                          <q-checkbox v-model="courseCheckList" :val="_item">
                            {{ _item.StartTime }}-{{ _item.EndTime }}
                          </q-checkbox>
                        </div>
                      </div>
                      <div v-else>
                        暂无可约课程
                      </div>
                    </div>
                  </div>
                  <div v-else>
                    暂无可约课程
                  </div>
                </template>
              </q-field>
            </template>
            <div class="row col-12" v-if="(saveObj&& saveObj.ClassType==3)||editType==1">
              <div class="row col-12">
                <div class="col-9">
                  <q-select filled stack-label use-input option-value="StuId" option-label="StuName" v-model="stuInfo"
                    ref="StuId" :options="stuList" label="学员列表" :dense="false" class="col-6" @filter="filterStu"
                    :rules="[val => !!val || '请选择学员']">
                    <template v-slot:no-option>
                      <q-item>
                        <q-item-section class="text-grey">
                          未找到相关数据
                        </q-item-section>
                      </q-item>
                    </template>
                    <template v-slot:option="scope">
                      <q-item v-bind="scope.itemProps" v-on="scope.itemEvents">
                        <q-item-section>
                          <div class="flex">
                            <span>{{ scope.opt.StuName }}</span>
                            <span v-if="scope.opt.State === 3">(重)</span>
                            <span class="q-ml-sm">{{
                              scope.opt.CourseName
                            }}</span>
                          </div>
                        </q-item-section>
                      </q-item>
                    </template>
                  </q-select>
                </div>
                <div class="col-3 q-pt-md q-pl-md">

                  <q-btn v-if="(saveObj.State==1||saveObj.State==2||editType==1)||currentUser.Id==1" size="sm"
                    color="accent" label="添加" @click="subscribeCourse" />
                </div>
              </div>
              <div class="row col-12" style="margin-top: 20px;">
                <table class="col-12 table" style="border-collapse: collapse;" border="0px">
                  <thead class="thead">
                    <tr>
                      <th>
                        姓名
                      </th>
                      <th>
                        报名课程
                      </th>
                      <th>
                        最近一次上课章节
                      </th>
                      <th>
                        消课编号/章节
                      </th>
                      <th>
                        操作
                      </th>
                    </tr>
                  </thead>
                  <template v-if="saveMsg.ChooseStuList.length>0">
                    <tbody v-for="(item,index) in saveMsg.ChooseStuList" :key="index" style="text-align: center;">
                      <tr>
                        <td width="80px">
                          {{item.StuName}}
                        </td>
                        <td>
                          {{item.CourseName}}
                        </td>
                        <td>

                          {{item.FinishChapterNoName}}

                        </td>
                        <td>
                          <template v-if="item.AppointmentId>0">
                            {{item.CourseChapterNoName}}
                          </template>
                          <template v-else>
                            <q-select filled stack-label use-input option-value="ChapterNo" option-label="ChapterName"
                              v-model="item.CourseGradeNo" ref="ChapterGradeNo" :options="item.CourseChapterList"
                              label="消课章节" :dense="false" emit-value map-options class="col-4">
                              <template v-slot:option="{ itemProps, itemEvents, opt,   }">
                                <q-item v-bind="itemProps" v-on="itemEvents">
                                  <q-item-section>
                                    <q-item-label v-html="opt.ChapterName"></q-item-label>
                                  </q-item-section>
                                  <q-item-section side>
                                    <q-item-label v-html="opt.CourseRateName"></q-item-label>
                                  </q-item-section>
                                </q-item>
                              </template>
                            </q-select>
                          </template>
                        </td>
                        <td width="60px">
                          <q-btn size="8px" class="SurverDel" v-if="item.AppointmentId==0" @click="DeleteStu(index)"
                            round color="red" icon="iconfont icon-shanchu" />
                        </td>
                      </tr>
                    </tbody>
                  </template>
                  <tbody v-if="saveMsg.ChooseStuList.length==0" style="text-align: center;">
                    <tr>
                      <td colspan="5" style="padding: 20px 0;">暂无数据</td>
                    </tr>
                  </tbody>
                </table>
                <table class="col-12" style="margin-top: 10px;">
                  <tfoot>
                    <tr>
                      <td colspan="1" style="text-align: center;">
                        <q-btn v-if="(saveObj.State==1||saveObj.State==2||editType==1)||currentUser.Id==1" size="sm"
                          color="accent" label="保存" @click="SaveStuAppointment" :loading="addLoading" />
                      </td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            </div>
            <q-field filled label="已约学员" stack-label disable class="col-12"
              v-if="editType == 1 && addStuList.length > 0">
              <template v-slot:control>
                <div v-for="(item, index) in addStuList" :key="index" class="q-mr-md">
                  {{ item }}
                </div>
              </template>
            </q-field>
          </div>
        </q-card-section>
        <q-separator />
        <q-card-actions align="right" class="bg-white">
          <q-btn label="取消" flat color="grey-10" style="font-weight:400 !important" @click="changeDig(false)" />
        </q-card-actions>
      </q-card>
    </q-dialog>
  </div>
</template>
<script>
  import {
    GetCanTeacherClassTimeList,
    getCanAppointmentStuList_V2,
    setAdminScrollAppointment_V3,
    getScrollCourseChapterName,
  } from "../../../api/studyabroad/subscribe.js";
  import {
    queryCourseDropdownList,
    queryChapterTree,
    queryChapterList,
  } from "../../../api/course/index";
  import {
    queryClassRoomList
  } from "../../../api/school/index";
  import selectTree from "./select-tree";
  import Detail from "./detail.vue";
  export default {
    components: {
      selectTree,
      Detail
    },
    model: {
      prop: "show",
      event: "changeshow"
    },
    props: {
      dateObj: {
        type: Object,
        default: null
      },
      saveObj: {
        type: Object,
        default: null
      },
      show: {
        type: Boolean,
        default: false
      },
      editType: {
        type: Number,
        default: 1 //1:新增，2详情
      },
      teacherList: {
        type: Array,
        default: () => []
      },
      auth: {
        type: Object,
        default: () => {
          return {
            IsEdit: false
          };
        }
      }
    },
    watch: {
      show: {
        handler(val) {
          this.addLoading = false;
          this.addStuList = [];
          if (val) {
            this.stuInfo = "";
            this.saveMsg.CourseId = 0;
            this.saveMsg.TeacherId = 0;
            this.chapterList = [];
            this.teacherTimeList = [];
            this.courseCheckList = [];
            this.stuList = [];
            this.allStuList = [];
            this.stuMsg_v2.StuName = "";
            this.checkChapter = {};
            if (this.editType == 2 && this.saveObj.ClassType == 3) {
              this.getScrollCourseChapterName();
              this.getStu_V2();
            }
          }
        },
        deep: true
      },
      saveObj: {
        handler(val) {
          if (val) {
            this.saveMsg.Date = this.dateObj.date;
            this.saveMsg.TeacherId = this.saveObj.Tid;
            this.saveMsg.ShiftSort = this.saveObj.ShiftSort;
            this.saveMsg.RoomId = this.saveObj.RoomId;
            this.saveMsg.CourseId = this.saveObj.CourseId;
            this.saveMsg.CourseGradeNo = this.saveObj.Ranks;
            this.saveMsg.CourseGradeId = this.saveObj.CourseGradeId;
            this.saveMsg.ChapterNo = this.saveObj.ChapterNo;
            this.saveMsg.ChooseStuList = [];
            if (this.saveObj.GuestList && this.saveObj.GuestList.length > 0) {
              this.saveObj.GuestList.forEach(gItem => {
                var cObj = {
                  StuId: gItem.StuId,
                  StuName: gItem.GuestName,
                  GuestId: gItem.GuestId,
                  LearnCourseId: gItem.LearnCourseId,
                  CourseName: gItem.LearnCourseName,
                  CourseGradeNo: gItem.CourseGradeNo,
                  FinishChapterNoName: gItem.FinishChapterNoName,
                  CourseChapterNoName: gItem.CourseChapterNoName,
                  AppointmentId: gItem.AppointmentId,
                  CourseGradeId: gItem.CourseGradeId,
                  CourseChapterList: [],
                }
                this.saveMsg.ChooseStuList.push(cObj);
              })
            }
          }
        },
        deep: true
      },
    },
    data() {
      return {
        CourseList: [], //关联课程下拉数据
        AllCourseList: [], //所有课程列表
        teacherTimeList: [],
        stuList: [],
        allStuList: [],
        stuMsg_v2: {
          StuName: "",
          NextCourseGradeNo: 0,
          CourseGradeId: 0
        },
        detailObj: {},
        saveMsg: {
          Date: "",
          TeacherId: 0,
          ShiftSort: "",
          RoomId: 0,
          CourseId: 0,
          ChapterNo: 0,
          CourseGradeNo: 0,
          ChooseStuList: []
        },
        stuInfo: "",
        checkStuList: [],
        courseCheckList: [],
        addLoading: false,
        chapterList: [], //章节列表，
        checkChapter: {}, //选择的章节
        returnString: [], //章节默认值
        addStuList: [], //新增时展示用
        ClassRoomList: [], //教室下拉
        CourseChapterName: "",
        currentUser: {},
      };
    },
    created() {
      this.currentUser = this.getLocalStorage();
      this.getCourseList();
      this.getClassRoomList();
    },
    mounted() {

    },
    methods: {
      //获取教室下拉
      getClassRoomList() {
        queryClassRoomList({}).then(res => {
          if (res.Code == 1) {
            this.ClassRoomList = res.Data;
          }
        });
      },
      //开关弹窗
      changeDig(val) {
        this.$emit("changeshow", val);
        if (!val) {
          this.stuList = [];
          this.allStuList = [];
        }
      },
      //获取课程
      getCourseList() {
        queryCourseDropdownList({
          IsQPrice: 1,
          IsQuerySalePlat: 0,
          IsScrollClass: 1
        }).then(res => {
          if (res.Code == 1) {
            this.CourseList = res.Data;
            var obj = {
              CourseName: "请选择",
              CourseId: 0
            };
            this.CourseList.unshift(obj);
            this.AllCourseList = res.Data;
          }
        });
      },
      changeCourse() {
        this.saveMsg.TeacherId = 0;
        this.checkChapter = {};
        this.checkStuList = [];
        this.stuInfo = "";
        this.$refs.selectTree.clearData();
      },
      //筛选课程
      filterCourse(val, update) {
        update(() => {
          if (val === "") {
            this.CourseList = JSON.parse(JSON.stringify(this.AllCourseList));
          } else {
            const needle = val.toLowerCase();
            this.CourseList = this.AllCourseList.filter(
              v => v.CourseName.toLowerCase().indexOf(needle) > -1
            );
          }
        });
      },
      //获取老师的空闲上课时段
      getCanTeacherTimeList() {
        this.saveMsg.Date = this.dateObj.date;
        this.courseCheckList = [];
        this.stuInfo = "";
        var qMsg = {
          Date: this.saveMsg.Date,
          TeacherId: this.saveMsg.TeacherId,
          CourseId: this.saveMsg.CourseId
        };
        GetCanTeacherClassTimeList(qMsg).then(res => {
          this.teacherTimeList = res.Data;
          if (res.Data.length > 0) {
            this.saveMsg.RoomId = res.Data[0].RoomId;
          } else {
            this.saveMsg.RoomId = 0;
          }
        });
      },
      //筛选学生
      filterStu(val, update) {
        update(() => {
          if (val === "") {
            this.stuList = JSON.parse(JSON.stringify(this.allStuList));
          } else {
            const needle = val.toLowerCase();
            this.stuList = this.allStuList.filter(
              v => v.StuName.toLowerCase().indexOf(needle) > -1
            );
          }
        });
      },
      //获取学生列表
      getStu_V2() {
        if (this.editType == 1) {
          this.stuMsg_v2.NextCourseGradeNo = this.checkChapter.ChapterGradeNo;
          this.stuMsg_v2.CourseGradeId = this.checkChapter.CourseRate;
        }
        if (this.editType == 2) {
          this.stuMsg_v2.NextCourseGradeNo = this.saveObj.Ranks;
          this.stuMsg_v2.CourseGradeId = this.saveObj.CourseGradeId;
        }
        if ((this.stuMsg_v2.CourseGradeId && this.stuMsg_v2.CourseGradeId > 0) ||
          (this.stuMsg_v2.NextCourseGradeNo && this.stuMsg_v2.NextCourseGradeNo > 0)) {
          getCanAppointmentStuList_V2(this.stuMsg_v2).then(res => {
            this.stuList = JSON.parse(JSON.stringify(res.Data));
            this.allStuList = JSON.parse(JSON.stringify(res.Data));
          });
        }
      },
      //删除选择的学生
      DeleteStu(index) {
        this.saveMsg.ChooseStuList.splice(index, 1);
      },
      //获取章节
      getChapterTree() {
        if (!this.saveMsg.CourseId) return;
        if (this.saveMsg.CourseId == 0) return;
        const msg = {
          CourseId: this.saveMsg.CourseId
        };
        queryChapterTree(msg).then(res => {
          this.chapterList = res.Data;
          this.chapterList.forEach(e => {
            this.mapChapter(e.ChildList, "ChildList");
          });
        });
      },
      //禁用第一层后的子级
      mapChapter(arr = [], key) {
        arr.forEach(e => {
          e.disabled = true;
          if (e[key] && e[key].length > 0) {
            this.mapChapter(e[key]);
          }
        });
      },
      //章节选择
      getChapter(data) {
        this.checkStuList = [];
        this.stuInfo = "";
        this.chapterList.map(e => {
          if (e.ChapterId == data) {
            this.checkChapter = e;
            return;
          }
        });
        this.saveMsg.ChapterNo = this.checkChapter.ChapterNo;
        // HK 2024-09-06 注释，可以不选老师，不选老师就默认通班的时间段
        // this.saveMsg.TeacherId = 0;
        // this.teacherTimeList = [];
        //获取学生列表
        this.getStu_V2();
      },
      //添加学员
      subscribeCourse() {
        if (this.editType == 1) {
          if (this.stuInfo.AppointDate) {
            if (
              new Date(this.dateObj.date).getTime() <
              new Date(this.stuInfo.AppointDate).getTime()
            ) {
              this.$q.notify({
                message: `${this.stuInfo.StuName},不能预约${this.stuInfo.AppointDate}之前的日期`,
                position: "top",
                type: "negative"
              });
              return;
            }
          }
          this.$refs.CourseId.validate();
          this.$refs.StuId.validate();
          if (!this.saveMsg.CourseId) {
            this.$q.notify({
              type: 'negative',
              position: "top",
              message: `请选择课程`
            })
            return;
          }
          if (!this.saveMsg.ChapterNo) {
            this.$q.notify({
              type: 'negative',
              position: "top",
              message: `请选择章节`
            })
            return;
          }
          if (!this.saveMsg.TeacherId) {
            this.$q.notify({
              type: 'negative',
              position: "top",
              message: `请选择老师`
            })
            return;
          }
          if (this.courseCheckList.length === 0) {
            this.$q.notify({
              message: "请选择上课时段",
              position: "top",
              type: "negative"
            });
            return;
          }
          if (!this.stuInfo) {
            this.$q.notify({
              message: "请选择学员",
              position: "top",
              type: "negative"
            });
            return;
          }
          const totalTime = this.courseCheckList.reduce((pre, cur) => {
            return (pre += cur.Minutes);
          }, 0);
          if (this.checkChapter.StudyMinutes !== totalTime) {
            this.$q.notify({
              message: "课时不匹配，请重新上课时段",
              position: "top",
              type: "negative"
            });
            return;
          }
          let newCourseCheckList = this.courseCheckList.sort((a, b) => {
            return a.Sort - b.Sort;
          });
          for (let i = 0; i < newCourseCheckList.length; i++) {
            if (i > 0) {
              const cur = newCourseCheckList[i].Sort;
              const pre = newCourseCheckList[i - 1].Sort;
              if (cur - pre > 1) {
                this.$q.notify({
                  message: "请按顺序选择上课时段",
                  position: "top",
                  type: "negative"
                });
                return;
              }
            }
          }
          this.saveMsg.Date = this.dateObj.date;
          this.saveMsg.CourseGradeNo = this.checkChapter.ChapterGradeNo;
          this.saveMsg.CourseGradeId = this.checkChapter.CourseRate;
          this.saveMsg.ShiftSort = newCourseCheckList.map(e => e.Sort).toString();
        }

        var sObj = {
          StuId: this.stuInfo.StuId,
          StuName: this.stuInfo.StuName,
          GuestId: this.stuInfo.GuestId,
          LearnCourseId: this.stuInfo.CourseId,
          CourseName: this.stuInfo.CourseName,
          FinishChapterNoName: this.stuInfo.FinishChapterNoName,
          AppointmentId: 0,
          //学员消课编号
          CourseChapterList: [],
        };
        sObj.CourseGradeId = this.stuInfo.CourseRate;
        sObj.CourseGradeNo = "";

        // 对比是否存在改学员
        if (this.saveMsg.ChooseStuList.length > 0) {
          let ArrId = this.saveMsg.ChooseStuList.map(item => {
            return item.GuestId
          })
          if (ArrId.indexOf(sObj.GuestId) == -1) {
            this.getCourseChapterList(sObj);
            this.saveMsg.ChooseStuList.push(sObj);
          } else {
            this.$q.notify({
              message: "该学员已选择,试试别的学员吧",
              position: "top",
              type: "negative"
            });
          }
        } else {
          this.getCourseChapterList(sObj);
          this.saveMsg.ChooseStuList.push(sObj);
        }
      },
      //保存约课
      SaveStuAppointment() {
        var tipStr = ""
        if (this.saveMsg.ChooseStuList && this.saveMsg.ChooseStuList.length > 0) {
          this.saveMsg.ChooseStuList.forEach(item => {
            if (item.CourseGradeNo == '' || !item.CourseGradeNo) {
              tipStr += "请选择【" + item.StuName + "】消课编号;";

            }
          })
        }
        if (tipStr != '') {
          this.$q.notify({
            message: tipStr,
            position: "top",
            type: "negative"
          });
          return;
        }

        this.addLoading = true;
        setAdminScrollAppointment_V3(this.saveMsg)
          .then(res => {
            this.addLoading = false;
            if (res.Code == 1) {
              this.$q.notify({
                message: "操作成功",
                position: "top"
              });

              // this.$emit("success");
              this.detailCloseHandle();
            }
          })
          .catch(() => {
            this.addLoading = false;
          });
      },
      //获取课程章节列表
      getCourseChapterList(item) {
        queryChapterList({
          CourseId: item.LearnCourseId,
          IsQRoot: 1
        }).then(res => {
          if (res.Code == 1) {
            item.CourseChapterList = res.Data;
          }
        });
      },
      //刷新弹窗
      detailSuccessHandle(val) {
        this.stuMsg_v2.StuName = "";
        this.stuList = [];
        this.allStuList = [];
        this.$emit("success");
      },
      //关闭详情弹窗
      detailCloseHandle() {
        this.changeDig(false);
        this.$emit("success");
      },
      getScrollCourseChapterName() {
        const msg = {
          CourseId: this.saveObj.CourseId,
          CourseGradeId: this.saveObj.CourseGradeId,
          CourseGradeNo: this.saveObj.Ranks,
        }
        getScrollCourseChapterName(msg).then(res => {
          this.CourseChapterName = res.Data
        })
      }
    }
  };

</script>
<style>
  .q-calendar-daily__day-interval:hover {
    background: rgba(0, 0, 255, 0.1);
  }

  .q-calendar-weekly__workweek:hover {
    background: rgba(0, 0, 255, 0.1);
  }

  .q-calendar-weekly__day:hover {
    background: rgba(0, 0, 255, 0.1);
  }

  .q-calendar-weekly__head-weekday:hover {
    background: rgba(0, 0, 255, 0.1);
  }

  .q-calendar-scheduler__day:hover {
    background: rgba(0, 0, 255, 0.1);
  }

  .q-calendar-resource__resource-interval:hover {
    background: rgba(0, 0, 255, 0.1);
  }

  .q-calendar-daily__day:hover {
    background: rgba(0, 0, 255, 0.1);
  }

</style>
<style>
  .upload-assiatant-box .q-uploader__list {
    display: none;
  }

  .upload-assiatant-box .q-uploader {
    width: auto;
  }

  .timeItem {
    margin: 10px 0;
  }

  .table {
    border-radius: 5px 5px 0 0;
    background: rgba(0, 0, 0, 0.05);
    overflow: hidden;
  }

  .thead {
    background: rgba(0, 0, 0, 0.09);
  }

  .thead tr th {
    padding: 10px 0;
  }

</style>
