<template>
  <div class="m-container">
    <h2>
      <div class="squrt"></div>
      报表中心
    </h2>
    <div class="m-core">
      <el-collapse v-model="activeName" class="formCollapse">
        <el-collapse-item
          name="1"
          v-if="
            $helpers.permission('export/musicGroupRegister') ||
            $helpers.permission('export/musicGroupNormalStudentNum') ||
            $helpers.permission('export/exportStudentAttendances') ||
            $helpers.permission('export/cloudStudyStudentTrainData')
          "
        >
          <template slot="title">
            <p class="wrapTitle">教务信息</p>
          </template>
          <div class="m-wrap" v-permission="'export/musicGroupRegister'">
            <div class="title">乐团招生汇总：</div>
            <select-all
              v-model.trim="organIdList"
              class="organSelect"
              style="width: 100%"
              filterable
              placeholder="请选择分部"
              multiple
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportMusicGroup"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="MUSIC_GROUP_REGISTER"
              :exportData="{ organIds: this.organIdList.join(',') }"
              fileName="招生情况汇总表"
              errorMsg="请至少选择一个分部"
              :flag="this.organIdList.length < 1"
            />
            <el-tooltip placement="top" popper-class="mTooltip">
              <div slot="content">
                请选择分部后，导出招生情况汇总表，分部可多选
              </div>
              <i
                class="el-icon-question micon el-tooltip"
                v-permission="'export/musicGroupRegister'"
                style="font-size: 18px; color: #f56c6c"
              ></i>
            </el-tooltip>
          </div>
          <div
            class="m-wrap"
            v-permission="'export/musicGroupNormalStudentNum'"
          >
            <div class="title">乐团在读人数：</div>
            <select-all
              v-model.trim="musicTeamNum"
              class="organSelect"
              style="width: 100%"
              filterable
              multiple
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportMusicTeamNum"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="MUSIC_GROUP_NORMAL_STUDENT_NUM"
              :exportData="{ organIds: this.musicTeamNum.join(',') }"
              fileName="乐团在读人数"
              errorMsg="请至少选择一个分部"
            />
            <el-tooltip placement="top" popper-class="mTooltip">
              <div slot="content">请选择分部后，导出乐团在读人数信息</div>
              <i
                class="el-icon-question micon el-tooltip"
                style="font-size: 18px; color: #f56c6c"
              ></i>
            </el-tooltip>
          </div>
          <div class="m-wrap" v-permission="'export/exportStudentAttendances'">
            <div class="title">学生考勤：</div>
            <select-all
              v-model.trim="attendanceOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              multiple
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <el-select
              v-model.trim="attendanceCourseType"
              class="organSelect"
              style="margin-left: 15px; width: 100%"
              filterable
              placeholder="请选择课程类型"
            >
              <el-option
                v-for="(item, index) in courseListType"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
            <el-date-picker
              v-model.trim="timer"
              style="width: 360px; margin-left: 15px"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="上课开始日期"
              end-placeholder="上课结束日期"
              :picker-options="{
                firstDayOfWeek: 1,
              }"
            ></el-date-picker>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportAttendance"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="EXPORT_STUDENT_ATTENDANCES"
              :exportData="exportAttendance"
              fileName="学生考勤"
              errorMsg="请至少选择一个分部"
            />
          </div>
          <div
            class="m-wrap"
            v-permission="'export/cloudStudyStudentTrainData'"
          >
            <div class="title">团练宝学员统计：</div>
            <el-select
              v-model.trim="trainOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportTrain"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="CLOUD_STUDY_STUDENT_TRAIN_DATA"
              :exportData="exportTrain"
              fileName="团练宝学员统计"
              errorMsg="请选择分部"
              :flag="!this.trainOrganId"
            />
          </div>
        </el-collapse-item>
        <el-collapse-item
          name="2"
          v-if="
            $helpers.permission('export/teacherDefaultSalary') ||
            $helpers.permission('export/studentOrder') ||
            $helpers.permission('studentInstrument/export') ||
            $helpers.permission('export/studentVipPractice') ||
            $helpers.permission('export/exercisesSituation') ||
            $helpers.permission('export/exportIndexErrData')
          "
        >
          <template slot="title">
            <p class="wrapTitle">运营数据</p>
          </template>
          <div class="m-wrap" v-permission="'export/teacherDefaultSalary'">
            <div class="title">老师默认课酬：</div>
            <select-all
              v-model.trim="teacherDefaultSalaryOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              placeholder="请选择分部"
              multiple
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>

            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportDefaultSalary"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="TEACHER_DEFAULT_SALARY"
              :exportData="exportDefaultSalary"
              fileName="老师默认课酬"
              errorMsg="请至少选择一个分部"
            />
            <el-tooltip placement="top" popper-class="mTooltip">
              <div slot="content">请选择分部后，导出老师列表及老师课酬信息</div>
              <i
                class="el-icon-question micon el-tooltip"
                style="font-size: 18px; color: #f56c6c"
                v-permission="'export/teacherDefaultSalary'"
              ></i>
            </el-tooltip>
          </div>
          <div class="m-wrap" v-permission="'export/studentOrder'">
            <div class="title">回款统计：</div>
            <select-all
              v-model.trim="studentOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              placeholder="请选择分部"
              multiple
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <el-date-picker
              style="margin-left: 15px"
              v-model="studentMonth"
              type="month"
              placeholder="选择月"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportStudent"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="STUDENT_ORDER"
              :exportData="exportStudent"
              fileName="回款统计"
              errorMsg="请选择导出月份"
              :flag="!this.studentMonth"
            />
            <el-tooltip placement="top" popper-class="mTooltip">
              <div slot="content">请选择分部和月份，导出回款统计</div>
              <i
                class="el-icon-question micon el-tooltip"
                style="font-size: 18px; color: #f56c6c"
                v-permission="'export/studentOrder'"
              ></i>
            </el-tooltip>
          </div>
          <div class="m-wrap" v-permission="'studentInstrument/export'">
            <div class="title">乐保订单导出：</div>
            <el-date-picker
              v-model="leBaoTimer"
              style="width: 360px"
              type="monthrange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始月份"
              end-placeholder="结束月份"
            >
            </el-date-picker>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportLeBao"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="STUDENT_INSTRUMENT"
              :exportData="exportLeBao"
              fileName="乐保订单"
              errorMsg="请选择导出月份"
              :flag="!(leBaoTimer && leBaoTimer.length > 1)"
            />
            <!-- <el-tooltip placement="top"
                      popper-class="mTooltip">
            <div slot="content">
              请选择分部和月份，导出回款统计
            </div>
            <i class="el-icon-question micon el-tooltip"
               style="font-size: 18px; color: #F56C6C"
               v-permission="'export/studentOrder'"></i>
          </el-tooltip> -->
          </div>
          <div class="m-wrap" v-permission="'export/studentVipPractice'">
            <div class="title">VIP网管课耗导出：</div>
            <select-all
              v-model.trim="vipOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportVip"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="STUDENT_VIP_PRACTICE"
              :exportData="exportVip"
              fileName="VIP网管课耗"
              errorMsg="请选择分部"
              :flag="vipOrganId.length <= 0"
              :isDownList="true"
            />
          </div>
          <div class="m-wrap" v-permission="'export/exercisesSituation'">
            <div class="title">服务指标明细导出：</div>
            <select-all
              v-model.trim="serviceOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              multiple
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <el-date-picker
              v-model.trim="serviceTimer"
              style="width: 360px; margin-left: 15px"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              @change="getWeekTime"
              :picker-options="{
                firstDayOfWeek: 1,
              }"
            ></el-date-picker>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportDetailService"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="EXERCISES_SITUATION"
              :exportData="exportDetailService"
              fileName="服务指标明细"
              errorMsg="请选择导出月份"
            />
          </div>
          <div class="m-wrap" v-permission="'export/exportIndexErrData'">
            <div class="title">异常处理数据导出：</div>
            <el-select
              clearable
              filterable
              class="organSelect"
              v-model="Abnormal.organId"
              placeholder="请选择分部"
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id+''"
              ></el-option>
            </el-select>

            <!-- <el-button
              type="primary"
              style="margin-left: 10px"
              @click="exportAbnormal"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="EXPORT_INDEX_ERR_DATA"
              :exportData="exportAbnormal"
              fileName="异常处理数据导出"
              errorMsg="请选择分部"
            />
          </div>

          <div class="m-wrap" v-permission="'export/STUDENT_VIP_COURSE_INFO'">
            <div class="title">VIP课学员课程导出：</div>
            <select-all
              v-model.trim="vipStudentCourseOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              multiple
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>

            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="STUDENT_VIP_COURSE_INFO"
              :exportData="exportAbnormal"
              fileName="VIP课学员课程信息导出"
              errorMsg="请选择分部"
              :flag="this.vipStudentCourseOrganId.length < 1"
              :isDownList="true"
            />
          </div>

          <div class="m-wrap" v-permission="'export/STUDENT_MUSIC_THEORY_COURSE_INFO'">
            <div class="title">乐理课学员课程导出：</div>
            <select-all
              v-model.trim="musicStudentCourseOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              multiple
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>

            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="STUDENT_MUSIC_THEORY_COURSE_INFO"
              :exportData="exportAbnormal"
              fileName="乐理课学员课程信息导出"
              errorMsg="请选择分部"
              :flag="this.musicStudentCourseOrganId.length < 1"
              :isDownList="true"
            />
          </div>
        </el-collapse-item>
        <el-collapse-item
          name="3"
          v-if="
            $helpers.permission('export/teacherSalary') ||
            $helpers.permission('export/userCoursesAccount/4388') ||
            $helpers.permission('export/userCashAccountDetail/4389')
          "
        >
          <template slot="title">
            <p class="wrapTitle">财务数据</p>
          </template>
          <div class="m-wrap" v-permission="'export/teacherSalary'">
            <div class="title">课酬导出：</div>
            <el-date-picker
              v-model="mouth"
              type="month"
              placeholder="选择月"
              value-format="yyyy-MM-dd"
              class="organSelect"
            ></el-date-picker>
            <!-- <el-select v-model.trim="courseScheduleType"
                   style="marginLeft:10px"
                   filterable
                   clearable
                   multiple
                   placeholder="课程类型">
          <el-option v-for="(item, index) in courseArray"
                     :key="index"
                     :label="item.label"
                     :value="item.value"></el-option>
        </el-select> -->
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportSalar"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="TEACHER_SALARY"
              :exportData="exportSalar"
              fileName="课酬导出"
              errorMsg="请选择月份"
              :flag="!this.mouth"
            />
            <el-tooltip placement="top" popper-class="mTooltip">
              <div slot="content">将只导出当前选择月份已结算的课程课酬。</div>
              <i
                class="el-icon-question micon el-tooltip"
                style="font-size: 18px; color: #f56c6c"
                v-permission="'export/teacherSalary'"
              ></i>
            </el-tooltip>
          </div>
          <div class="m-wrap" v-permission="'export/userCoursesAccount/4388'">
            <div class="title">课程余额明细：</div>
            <select-all
              v-model.trim="AccountOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              multiple
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <el-date-picker
              v-model.trim="AccountTimer"
              style="width: 360px; margin-left: 15px"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="{
                firstDayOfWeek: 1,
              }"
            ></el-date-picker>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportAccount"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="USER_COURSES_ACCOUNT"
              :exportData="exportAccount"
              fileName="课程余额明细"
              errorMsg="请选择月份"
            />
          </div>
          <div
            class="m-wrap"
            v-permission="'export/userCashAccountDetail/4389'"
          >
            <div class="title">账户余额明细：</div>
            <select-all
              v-model.trim="AccountDetailOrganId"
              class="organSelect"
              style="width: 100%"
              filterable
              multiple
              placeholder="请选择分部"
              clearable
            >
              <el-option
                v-for="(item, index) in selects.branchs"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </select-all>
            <el-date-picker
              v-model.trim="AccountDetailTimer"
              style="width: 360px; margin-left: 15px"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="{
                firstDayOfWeek: 1,
              }"
            ></el-date-picker>
            <!-- <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportDetailAccount"
              >导出</el-button
            > -->
            <ExportChiose
              style="margin-left: 10px"
              ExportEnum="USER_CASH_ACCOUNT_DETAIL"
              :exportData="exportAccount"
              fileName="课程余额明细"
              errorMsg="请选择月份"
            />
          </div>
        </el-collapse-item>
        <el-collapse-item
          name="4"
          v-if="$helpers.permission('questionnaireUserResult/export/report')"
        >
          <template slot="title">
            <p class="wrapTitle">其他数据</p>
          </template>
          <div
            class="m-wrap"
            v-if="$helpers.permission('questionnaireUserResult/export/report')"
          >
            <div class="title">问卷调查：</div>
            <el-select
              v-model.trim="questionActiveType"
              class="organSelect"
              style="width: 100%"
              filterable
              placeholder="请选择导出类型"
              clearable
            >
              <el-option
                label="团练宝用户反馈"
                value="CLOUD_TEACHER_FEEDBACK"
              ></el-option>
            </el-select>
            <el-button
              style="margin-left: 10px"
              type="primary"
              @click="exportQuestion"
              >导出</el-button
            >
            <!-- <ExportChiose
              style="margin-left: 10px"
              ExportEnum="USER_CASH_ACCOUNT_DETAIL"
              :exportData="{ activeType: this.questionActiveType }"
              fileName="问卷调查"
              errorMsg="请选择月份"
            /> -->
          </div>
        </el-collapse-item>
      </el-collapse>
    </div>
  </div>
</template>
<script>
import { exportTeacherSalary } from "@/api/generalSettings";
import { courseType, courseListType } from "@/utils/searchArray";
import ExportChiose from "@/components/Export-chiose";
import { Export } from "@/utils/downLoadFile";
import cleanDeep from "clean-deep";
import qs from "qs";
import dayjs from "dayjs";
import axios from "axios";
import { getToken, getTenantId } from "@/utils/auth";
import load from "@/utils/loading";
export default {
  name: "reportForm",
  components: {
    ExportChiose,
  },
  data() {
    return {
      mouth: "",
      organIdList: [],
      teacherDefaultSalaryOrganId: [],
      courseArray: courseType,
      courseListType,
      courseScheduleType: [],
      musicTeamNum: [],
      studentOrganId: [],
      studentMonth: "",
      attendanceOrganId: [],
      attendanceCourseType: "MUSIC",
      timer: [],
      leBaoTimer: [],
      AccountOrganId: [],
      AccountTimer: [],
      AccountDetailOrganId: [],
      AccountDetailTimer: [],
      trainOrganId: null,
      questionActiveType: "CLOUD_TEACHER_FEEDBACK",
      vipOrganId: [],
      serviceOrganId: [], // 服务报表
      serviceTimer: [],
      Abnormal: {
        organId: null,
      },
      activeName: ["1", "2", "3", "4"],
      vipStudentCourseOrganId: [],
      musicStudentCourseOrganId: [],
    };
  },
  mounted() {
    this.$store.dispatch("setBranchs");
  },
  methods: {
    // exportSalar() {
    //   if (!this.mouth) {
    //     this.$message.error("请选择导出月份");
    //     return;
    //   }
    //   // let courseTypeList = this.courseScheduleType.join(',')
    //   let url = "/api-web/export/teacherSalary";
    //   let data = { date: this.mouth };
    //   const options = {
    //     method: "POST",
    //     headers: {
    //       Authorization: getToken(),
    //       tenantId: getTenantId(),
    //     },
    //     data: qs.stringify(cleanDeep(data)),
    //     url,
    //     responseType: "blob",
    //   };
    //   this.$confirm("您确定导出课酬", "提示", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {
    //       load.startLoading();
    //       axios(options)
    //         .then((res) => {
    //           let blob = new Blob([res.data], {
    //             // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
    //             type: "application/vnd.ms-excel;charset=utf-8",
    //             //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
    //           });

    //           let text = new Response(blob).text();
    //           text.then((res) => {
    //             // 判断是否报错
    //             if (res.indexOf("code") != -1) {
    //               let json = JSON.parse(res);
    //               if (json.code == 403) {
    //                 this.$message.error(`登录过期，请重新登录！`);
    //                 setTimeout(() => {
    //                   this.$store.dispatch("user/resetToken").then(() => {
    //                     location.reload();
    //                   });
    //                 }, 1000);
    //                 return;
    //               }
    //               this.$message.error(json.msg);
    //             } else {
    //               let objectUrl = URL.createObjectURL(blob);
    //               let link = document.createElement("a");
    //               let nowTime = new Date();
    //               let ymd =
    //                 nowTime.getFullYear() +
    //                 "" +
    //                 (nowTime.getMonth() + 1) +
    //                 "" +
    //                 nowTime.getDate();
    //               let fname = ymd + "课酬.xls"; //下载文件的名字
    //               link.href = objectUrl;
    //               link.setAttribute("download", fname);
    //               document.body.appendChild(link);
    //               link.click();
    //             }
    //           });
    //           load.endLoading();
    //         })
    //         .catch((error) => {
    //           this.$message.error("导出数据失败，请联系管理员");
    //           load.endLoading();
    //         });
    //     })
    //     .catch(() => {});
    // },
    exportMusicGroup() {
      if (this.organIdList.length < 1) {
        this.$message.error("请至少选择一个分部");
        return;
      }
      let url = "/api-web/export/musicGroupRegister";
      let data = { organIds: this.organIdList.join(",") };
      const options = {
        method: "POST",
        headers: {
          Authorization: getToken(),
          tenantId: getTenantId(),
        },
        data: qs.stringify(cleanDeep(data)),
        url,
        responseType: "blob",
      };
      this.$confirm("您确定导出招生情况汇总表", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          load.startLoading();
          axios(options)
            .then((res) => {
              let blob = new Blob([res.data], {
                // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
                type: "application/vnd.ms-excel;charset=utf-8",
                //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
              });

              let text = new Response(blob).text();
              text.then((res) => {
                // 判断是否报错
                if (res.indexOf("code") != -1) {
                  let json = JSON.parse(res);
                  if (json.code == 403) {
                    this.$message.error(`登录过期，请重新登录！`);
                    setTimeout(() => {
                      this.$store.dispatch("user/resetToken").then(() => {
                        location.reload();
                      });
                    }, 1000);
                    return;
                  }
                  this.$message.error(json.msg);
                } else {
                  let objectUrl = URL.createObjectURL(blob);
                  let link = document.createElement("a");
                  let nowTime = new Date();
                  let ymd =
                    nowTime.getFullYear() +
                    "" +
                    (nowTime.getMonth() + 1) +
                    "" +
                    nowTime.getDate();
                  let fname = ymd + "招生情况汇总表.xls"; //下载文件的名字
                  link.href = objectUrl;
                  link.setAttribute("download", fname);
                  document.body.appendChild(link);
                  link.click();
                }
              });
              load.endLoading();
            })
            .catch((error) => {
              this.$message.error("导出数据失败，请联系管理员");
              load.endLoading();
            });
        })
        .catch(() => {});
    },
    // exportDefaultSalary() {
    //   let organIdList = this.teacherDefaultSalaryOrganId.join(",");
    //   let url = "/api-web/export/teacherDefaultSalary";
    //   let data = { organIdList };
    //   return data;
    //   const options = {
    //     method: "POST",
    //     headers: {
    //       Authorization: getToken(),
    //       tenantId: getTenantId(),
    //     },
    //     data: qs.stringify(cleanDeep(data)),
    //     url,
    //     responseType: "blob",
    //   };
    //   this.$confirm("您确定导出老师默认课酬表", "提示", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {
    //       load.startLoading();
    //       axios(options)
    //         .then((res) => {
    //           let blob = new Blob([res.data], {
    //             // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
    //             type: "application/vnd.ms-excel;charset=utf-8",
    //             //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
    //           });

    //           let text = new Response(blob).text();
    //           text.then((res) => {
    //             // 判断是否报错
    //             if (res.indexOf("code") != -1) {
    //               let json = JSON.parse(res);
    //               if (json.code == 403) {
    //                 this.$message.error(`登录过期，请重新登录！`);
    //                 setTimeout(() => {
    //                   this.$store.dispatch("user/resetToken").then(() => {
    //                     location.reload();
    //                   });
    //                 }, 1000);
    //                 return;
    //               }
    //               this.$message.error(json.msg);
    //             } else {
    //               let objectUrl = URL.createObjectURL(blob);
    //               let link = document.createElement("a");
    //               let nowTime = new Date();
    //               let ymd =
    //                 nowTime.getFullYear() +
    //                 "" +
    //                 (nowTime.getMonth() + 1) +
    //                 "" +
    //                 nowTime.getDate();
    //               let fname = ymd + "老师默认课酬表.xls"; //下载文件的名字
    //               link.href = objectUrl;
    //               link.setAttribute("download", fname);
    //               document.body.appendChild(link);
    //               link.click();
    //             }
    //           });
    //           load.endLoading();
    //         })
    //         .catch((error) => {
    //           this.$message.error("导出数据失败，请联系管理员");
    //           load.endLoading();
    //         });
    //     })
    //     .catch(() => {});
    // },
    exportMusicTeamNum() {
      let organIds = this.musicTeamNum.join(",");
      let url = "/api-web/export/musicGroupNormalStudentNum";
      let data = { organIds };
      const options = {
        method: "POST",
        headers: {
          Authorization: getToken(),
          tenantId: getTenantId(),
        },
        data: qs.stringify(cleanDeep(data)),
        url,
        responseType: "blob",
      };
      this.$confirm("您确定导出乐团在读人数", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          load.startLoading();
          axios(options)
            .then((res) => {
              let blob = new Blob([res.data], {
                // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
                type: "application/vnd.ms-excel;charset=utf-8",
                //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
              });

              let text = new Response(blob).text();
              text.then((res) => {
                // 判断是否报错
                if (res.indexOf("code") != -1) {
                  let json = JSON.parse(res);
                  if (json.code == 403) {
                    this.$message.error(`登录过期，请重新登录！`);
                    setTimeout(() => {
                      this.$store.dispatch("user/resetToken").then(() => {
                        location.reload();
                      });
                    }, 1000);
                    return;
                  }
                  this.$message.error(json.msg);
                } else {
                  let objectUrl = URL.createObjectURL(blob);
                  let link = document.createElement("a");
                  let nowTime = new Date();
                  let ymd =
                    nowTime.getFullYear() +
                    "" +
                    (nowTime.getMonth() + 1) +
                    "" +
                    nowTime.getDate();
                  let fname = ymd + "乐团在读人数.xls"; //下载文件的名字
                  link.href = objectUrl;
                  link.setAttribute("download", fname);
                  document.body.appendChild(link);
                  link.click();
                }
              });
              load.endLoading();
            })
            .catch((error) => {
              this.$message.error("导出数据失败，请联系管理员");
              load.endLoading();
            });
        })
        .catch(() => {});
    },
    // exportStudent() {
    //   if (!this.studentMonth) {
    //     this.$message.error("请选择导出月份");
    //     return;
    //   }
    //   let studentOrganId = this.studentOrganId.join(",");
    //   let url = "/api-web/export/studentOrder";
    //   let data = { organIds: studentOrganId, date: this.studentMonth };
    //   const options = {
    //     method: "POST",
    //     headers: {
    //       Authorization: getToken(),
    //       tenantId: getTenantId(),
    //     },
    //     data: qs.stringify(cleanDeep(data)),
    //     url,
    //     responseType: "blob",
    //   };
    //   this.$confirm("您确定导出回款统计", "提示", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {
    //       load.startLoading();
    //       axios(options)
    //         .then((res) => {
    //           let blob = new Blob([res.data], {
    //             // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
    //             type: "application/vnd.ms-excel;charset=utf-8",
    //             //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
    //           });

    //           let text = new Response(blob).text();
    //           text.then((res) => {
    //             // 判断是否报错
    //             if (res.indexOf("code") != -1) {
    //               let json = JSON.parse(res);
    //               if (json.code == 403) {
    //                 this.$message.error(`登录过期，请重新登录！`);
    //                 setTimeout(() => {
    //                   this.$store.dispatch("user/resetToken").then(() => {
    //                     location.reload();
    //                   });
    //                 }, 1000);
    //                 return;
    //               }
    //               this.$message.error(json.msg);
    //             } else {
    //               let objectUrl = URL.createObjectURL(blob);
    //               let link = document.createElement("a");
    //               let nowTime = new Date();
    //               let ymd =
    //                 nowTime.getFullYear() +
    //                 "" +
    //                 (nowTime.getMonth() + 1) +
    //                 "" +
    //                 nowTime.getDate();
    //               let fname = ymd + "回款统计.xls"; //下载文件的名字
    //               link.href = objectUrl;
    //               link.setAttribute("download", fname);
    //               document.body.appendChild(link);
    //               link.click();
    //             }
    //           });
    //           load.endLoading();
    //         })
    //         .catch((error) => {
    //           this.$message.error("导出数据失败，请联系管理员");
    //           load.endLoading();
    //         });
    //     })
    //     .catch(() => {});
    // },
    // exportAttendance() {
    //   let classStartDate, classEndDate;
    //   if (this.timer && this.timer.length > 0) {
    //     classStartDate = this.timer[0];
    //     classEndDate = this.timer[1];
    //   } else {
    //     classStartDate = null;
    //     classEndDate = null;
    //   }
    //   return {
    //     organId: this.attendanceOrganId.join(","),
    //     groupType: this.attendanceCourseType,
    //     classStartDate,
    //     classEndDate,
    //   };
    //   Export(
    //     this,
    //     {
    //       url: "/api-web/export/exportStudentAttendances",
    //       fileName: "学生考勤.xls",
    //       method: "post",
    //       params: qs.stringify({
    //         organId: this.attendanceOrganId.join(","),
    //         groupType: this.attendanceCourseType,
    //         classStartDate,
    //         classEndDate,
    //       }),
    //     },
    //     "您确定导出学生考勤?"
    //   );
    // },
    // exportTrain() {
    //   if (!this.trainOrganId) {
    //     this.$message.error("请选择分部");
    //     return;
    //   }
    //   return {
    //     organId: this.trainOrganId,
    //   };
    //   Export(
    //     this,
    //     {
    //       url: "/api-web/export/cloudStudyStudentTrainData",
    //       fileName: "团练宝学员统计.xls",
    //       method: "post",
    //       params: qs.stringify({
    //         organId: this.trainOrganId,
    //       }),
    //     },
    //     "您确定导出团练宝学员统计?"
    //   );
    // },
    exportQuestion() {
      Export(
        this,
        {
          url: "/api-web/questionnaireUserResult/export",
          fileName: "问卷调查.xls",
          method: "get",
          params: { activeType: this.questionActiveType },
        },
        "您确定导出问卷调查?"
      );
    },
    // exportLeBao() {
    //   let endTime, startTime;
    //   if (this.leBaoTimer && this.leBaoTimer.length > 1) {
    //     startTime = this.leBaoTimer[0];
    //     let end = this.leBaoTimer[1];
    //     end = new Date(end);
    //     end = new Date(end.getFullYear(), end.getMonth() + 1, 0);
    //     endTime = dayjs(end).format("YYYY-MM-DD");
    //   } else {
    //     this.$message.error("请选择导出月份");
    //     return;
    //   }
    //   Export(
    //     this,
    //     {
    //       url: "/api-web/studentInstrument/export",
    //       fileName: "乐保订单.xls",
    //       method: "get",
    //       params: { startTime: startTime, endTime: endTime },
    //     },
    //     "您确定导出乐保订单?"
    //   );
    // },
    // exportAccount() {
    //   let endTime, startTime;
    //   if (this.AccountTimer && this.AccountTimer.length > 1) {
    //     startTime = this.AccountTimer[0];
    //     endTime = this.AccountTimer[1];
    //   } else {
    //     startTime = null;
    //     endTime = null;
    //   }
    //   Export(
    //     this,
    //     {
    //       url: "/api-web/export/userCoursesAccount",
    //       fileName: "课程余额明细.xls",
    //       method: "post",
    //       params: qs.stringify({
    //         startTime: startTime,
    //         endTime: endTime,
    //         organId: this.AccountOrganId.join(","),
    //       }),
    //     },
    //     "您确定导出课程余额明细?"
    //   );
    // },
    // exportDetailAccount() {
    //   let endTime, startTime;
    //   if (this.AccountDetailTimer && this.AccountDetailTimer.length > 1) {
    //     startTime = this.AccountDetailTimer[0];
    //     endTime = this.AccountDetailTimer[1];
    //   } else {
    //     startTime = null;
    //     endTime = null;
    //   }
    //   Export(
    //     this,
    //     {
    //       url: "/api-web/export/userCashAccountDetail",
    //       fileName: "账户余额明细.xls",
    //       method: "post",
    //       params: qs.stringify({
    //         startTime: startTime,
    //         endTime: endTime,
    //         organId: this.AccountDetailOrganId.join(","),
    //       }),
    //     },
    //     "您确定导出账户余额明细?"
    //   );
    // },
    // exportVip() {
    //   if (!this.vipOrganId.length < 0) {
    //     this.$message.error("请选择分部");
    //     return;
    //   }
    //   let data = {
    //     organId: this.vipOrganId.join(","),
    //   };
    //   let url = "/api-web/export/studentVipPractice";
    //   const options = {
    //     method: "get",
    //     headers: {
    //       Authorization: getToken(),
    //       tenantId: getTenantId(),
    //     },
    //     params: cleanDeep(data),
    //     url,
    //     responseType: "form",
    //   };
    //   this.$confirm("您确定导出VIP网管课耗", "提示", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {
    //       load.startLoading();
    //       axios(options)
    //         .then((res) => {
    //           load.endLoading();
    //           if (res.data.code == 200) {
    //             this.$message.info(res.data.msg);
    //           } else if (res.data.code == 403) {
    //             this.$message.error(`登录过期，请重新登录！`);
    //             setTimeout(() => {
    //               this.$store.dispatch("user/resetToken").then(() => {
    //                 location.reload();
    //               });
    //             }, 1000);
    //           } else {
    //             this.$message.error(res.data.msg);
    //           }
    //           // this.$confirm(res.data.data, "提示", {
    //           //   confirmButtonText: "确定",
    //           //   cancelButtonText: "取消",
    //           //   type: "warning",
    //           // }).then(() => {

    //           // }).catch(err => {

    //           // })
    //         })
    //         .catch((error) => {
    //           this.$message.error("导出数据失败，请联系管理员");
    //           load.endLoading();
    //         });
    //     })
    //     .catch(() => {});

    //   // Export(
    //   //   this,
    //   //   {
    //   //     url: "/api-web/export/studentVipPractice",
    //   //     fileName: "vip网管课.xls",
    //   //     method: "post",
    //   //     params: qs.stringify({
    //   //       organId: this.vipOrganId.join(',')
    //   //     }),
    //   //   },
    //   //   "您确定导出vip网管课?"
    //   // );
    // },
    // exportDetailService() {
    //   let sunday, monday;
    //   if (this.serviceTimer && this.serviceTimer.length > 1) {
    //     monday = this.serviceTimer[0];
    //     sunday = this.serviceTimer[1];
    //   } else {
    //     monday = null;
    //     sunday = null;
    //   }
    //   Export(
    //     this,
    //     {
    //       url: "/api-web/export/exercisesSituation",
    //       fileName: "服务指标明细.xls",
    //       method: "post",
    //       params: qs.stringify({
    //         monday: monday,
    //         sunday: sunday,
    //         organId: this.serviceOrganId.join(","),
    //       }),
    //     },
    //     "您确定导出服务指标明细?"
    //   );
    // },
    getNowDateAndMonday(time) {
      let timestamp = new Date(time.replace(/-/g, "/")).getTime();
      let serverDate = new Date(time);
      if (serverDate.getDay() == 0) {
        timestamp -= 7 * 24 * 60 * 60 * 1000;
      }
      let mondayTime =
        timestamp - (serverDate.getDay() - 1) * 24 * 60 * 60 * 1000;

      let mondayData = new Date(mondayTime);
      //年
      let mondayY = mondayData.getFullYear();
      //月
      let mondayM =
        mondayData.getMonth() + 1 < 10
          ? "0" + (mondayData.getMonth() + 1)
          : mondayData.getMonth() + 1;
      //日
      let mondayD =
        mondayData.getDate() < 10
          ? "0" + mondayData.getDate()
          : mondayData.getDate();

      let str = mondayY + "-" + mondayM + "-" + mondayD;
      return str;
    },
    getNowDateAndSunday(time) {
      let timestamp = new Date(time.replace(/-/g, "/")).getTime();
      let serverDate = new Date(time);

      let num = 7 - serverDate.getDay();
      if (num == 7) {
        num = 0;
      }
      let sundayTiem = timestamp + num * 24 * 60 * 60 * 1000;
      let SundayData = new Date(sundayTiem);
      //年
      let tomorrowY = SundayData.getFullYear(); //月
      let tomorrowM =
        SundayData.getMonth() + 1 < 10
          ? "0" + (SundayData.getMonth() + 1)
          : SundayData.getMonth() + 1;
      //日
      let tomorrowD =
        SundayData.getDate() < 10
          ? "0" + SundayData.getDate()
          : SundayData.getDate();
      let str = tomorrowY + "-" + tomorrowM + "-" + tomorrowD;
      return str;
    },
    getWeekTime(val) {
      if (val && val.length > 0) {
        let start = this.getNowDateAndMonday(val[0]);
        let end = this.getNowDateAndSunday(val[1]);
        this.serviceTimer.splice(0, 1, start);
        this.serviceTimer.splice(1, 1, end);
      }
    },
    // exportAbnormal() {
    //   let params = this.Abnormal;
    //   Export(
    //     this,
    //     {
    //       method: "post",
    //       url: "/api-web/export/exportIndexErrData",
    //       params: this.$helpers.qs.stringify({
    //         ...params,
    //       }),
    //     },
    //     "是否确认导出报表？"
    //   );
    // },
  },
  computed: {
    exportAttendance() {
      let classStartDate, classEndDate;
      if (this.timer && this.timer.length > 0) {
        classStartDate = this.timer[0];
        classEndDate = this.timer[1];
      } else {
        classStartDate = null;
        classEndDate = null;
      }
      return {
        organId: this.attendanceOrganId.join(","),
        groupType: this.attendanceCourseType,
        classStartDate,
        classEndDate,
      };
    },
    exportTrain() {
      return {
        organId: this.trainOrganId,
      };
    },
    exportDefaultSalary() {
      let organIdList = this.teacherDefaultSalaryOrganId.join(",");
      let url = "/api-web/export/teacherDefaultSalary";
      let data = { organIdList };
      return data;
    },
    exportStudent() {
      let studentOrganId = this.studentOrganId.join(",");
      return { organIds: studentOrganId, date: this.studentMonth };
    },
    exportLeBao() {
      let endTime, startTime;
      if (this.leBaoTimer && this.leBaoTimer.length > 1) {
        startTime = this.leBaoTimer[0];
        let end = this.leBaoTimer[1];
        end = new Date(end);
        end = new Date(end.getFullYear(), end.getMonth() + 1, 0);
        endTime = dayjs(end).format("YYYY-MM-DD");
      }
      return { startTime: startTime, endTime: endTime };
    },
    exportVip() {
      // if (!this.vipOrganId.length < 0) {
      //   this.$message.error("请选择分部");
      //   return;
      // }
      let data = {
        organId: this.vipOrganId.join(","),
      };
      return data;
    },
    exportDetailService() {
      let sunday, monday;
      if (this.serviceTimer && this.serviceTimer.length > 1) {
        monday = this.serviceTimer[0];
        sunday = this.serviceTimer[1];
      } else {
        monday = null;
        sunday = null;
      }
      return {
        monday: monday,
        sunday: sunday,
        organId: this.serviceOrganId.join(","),
      };
    },
    exportAbnormal() {
      console.log(this.Abnormal)
      return this.Abnormal;
    },
    exportSalar() {
      // if (!this.mouth) {
      //   this.$message.error("请选择导出月份");
      //   return;
      // }
      // let courseTypeList = this.courseScheduleType.join(',')
      // let url = "/api-web/export/teacherSalary";
      let data = { date: this.mouth };
      return data;
    },
    exportAccount() {
      let endTime, startTime;
      if (this.AccountTimer && this.AccountTimer.length > 1) {
        startTime = this.AccountTimer[0];
        endTime = this.AccountTimer[1];
      } else {
        startTime = null;
        endTime = null;
      }
      return {
        startTime: startTime,
        endTime: endTime,
        organId: this.AccountOrganId.join(","),
      };
    },
    exportDetailAccount() {
      let endTime, startTime;
      if (this.AccountDetailTimer && this.AccountDetailTimer.length > 1) {
        startTime = this.AccountDetailTimer[0];
        endTime = this.AccountDetailTimer[1];
      } else {
        startTime = null;
        endTime = null;
      }
      return {
        startTime: startTime,
        endTime: endTime,
        organId: this.AccountDetailOrganId.join(","),
      };
    },
  },
  // AccountDetailTimer
};
</script>
<style lang="scss" scoped>
.m-container {
  // margin-top: 20px;
  .m-wrap {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    align-items: center;
    margin-bottom: 16px;
    .newBand {
      margin: 0 5px 0 10px;
    }
    .title {
      width: 150px;
      // height: 40px;
      // line-height: 40px;
      text-align: right;
      color: #212121;
      font-weight: 600;
    }
    .organSelect {
      width: 260px !important;
    }
    .el-tooltip.micon {
      width: 20px;
      height: 20px;
      position: relative;
      margin-left: 8px;
      // top: 12px;
    }
  }

  .formCollapse {
    border: none;
    /deep/.el-collapse-item__header {
      padding: 0 15px;
      border-bottom: none;
      background-color: #f8f8f8;
    }
    /deep/.el-collapse-item__wrap {
      padding: 15px;
      border-bottom: none;
    }
    /deep/ .el-collapse-item__arrow.is-active {
      transform: rotate(-90deg);
    }
    //  默认方向
    /deep/ .el-collapse-item__arrow,
    .el-tabs__nav {
      transform: rotate(90deg);
    }
    /deep/.el-collapse-item__content {
      padding-bottom: 0px !important;
    }
    .wrapTitle {
      font-size: 18px;
      position: relative;
      font-weight: 600;
      margin-left: 12px;

      &::after {
        position: absolute;
        width: 4px;
        height: 18px;
        background: var(--color-primary);
        border-radius: 2px;
        left: -13px;
        top: 14px;
        content: "";
      }
    }
  }
}
/deep/.el-input__icon.el-icon-date {
  height: 40px !important;
}
</style>
