<template>
  <div id="asPlanned">
    <search-box-new
      ref="searchBox"
      :formData="formData"
      :formList="formList"
      @search="search"
      @init="init"
    >
      <template slot="month">
        <el-select
          size="small"
          v-model="month"
          placeholder="月份"
          @change="getCanActiveApplyMonth"
        >
          <el-option
            v-for="item in monthList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
        <el-select
          style="margin-left: 10px"
          size="small"
          v-model="day"
          v-if="month"
          placeholder="日期"
          @change="getCanActiveApply"
        >
          <el-option
            v-for="item in dayList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>

        <el-select
          style="margin-left: 10px"
          v-if="month || day"
          size="small"
          v-model="monthApplyIndex"
          placeholder="考试场次"
        >
          <el-option
            v-for="(item, index) in monthApplyList"
            :key="index"
            :label="item.examSession"
            :value="index"
          >
          </el-option>
        </el-select>
      </template>
    </search-box-new>
    <table-list
      rowKey="subscribeId"
      :tableSets="tableSet"
      :tableData="tableData"
      :navText="navText"
      @addClick="addClick"
      :loading="loading"
      @editInfo="editInfo"
      ref="tableList"
    >
      <template slot="customize">
        <el-popover title="" width="200" trigger="click">
          <div>
            <el-button size="small" type="primary" @click="controlsType(1)"
              >快捷筛选</el-button
            >
            <el-button size="small" type="primary" @click="controlsType(2)"
              >开通题库</el-button
            >
          </div>
          <el-button
            v-if="false"
            :size="size"
            slot="reference"
            type="success"
            style="margin-right: 10px"
            >更多</el-button
          >
        </el-popover>
        <el-button size="small" type="primary" @click="openBank"
          >开通题库</el-button
        >
        <el-button :size="size" type="warning" @click="moreActive(2)"
          >取消预约</el-button
        >
        <el-button :size="size" type="primary" @click="moreActive(5)"
          >前培账号标记</el-button
        >
        <el-button :size="size" type="primary" @click="moreActive(3)"
          >考试登记</el-button
        >
        <!-- <el-button :size="size" type="primary" @click="moreActive(4)"
          >批量：成绩证书登记</el-button
        > -->
        <el-button :size="size" type="success" @click="moreActive(1)"
          >批量导入</el-button
        >
      </template>
      <template slot="btn" slot-scope="props">
        <el-button
          type="text"
          @click="examBox(props.scope.row, 2)"
          :disabled="props.scope.row.subscribeStatus === 2"
          >考试登记</el-button
        >
        <el-button
          type="text"
          @click="openZS(props.scope.row, 2)"
          :disabled="props.scope.row.subscribeStatus === 2"
          >成绩和证书登记</el-button
        >
      </template>
    </table-list>
    <pagination
      :total="total"
      :pageSize="formData.pageSize"
      :currentPage="formData.pageNum"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    />
    <el-dialog
      :visible.sync="dialogCG"
      width="560px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">考试登记</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogCG = false"
          />
        </div>
      </div>
      <div>
        <div v-if="ints === 1" class="aListBottom">{{ listData.realname }}</div>
        <ul v-if="ints === 2">
          <li class="liBVS" v-for="(item, index) in peopleList" :key="index">
            {{ item.realname }}
            <i
              v-if="peopleList.length > 1"
              class="el-icon-error clsw"
              @click="peopleList.splice(index, 1)"
            ></i>
          </li>
          <div style="clear: both"></div>
        </ul>
        <el-form
          :model="listData"
          label-width="120px"
          class="demo-ruleForm"
          :rules="rules"
          ref="listData"
        >
          <el-form-item label="考试登记状态" prop="examStatus">
            <el-radio-group v-model="listData.examStatus">
              <el-radio :label="1">正常</el-radio>
              <el-radio :label="2">缺考</el-radio>
              <el-radio :label="3">作弊</el-radio>
              <el-radio :label="4">替考</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="考试登记补充" prop="remark">
            <el-input
              v-model="listData.remark"
              type="textarea"
              :rows="4"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogCG = false">取消</el-button>
        <el-button type="primary" @click="submitChecks('listData')"
          >确定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogDJ"
      width="560px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">取消预约</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogDJ = false"
          />
        </div>
      </div>
      <div>
        <div v-if="ints === 1" class="aListBottom">{{ listData.realname }}</div>
        <ul v-if="ints === 2">
          <li class="liBVS" v-for="(item, index) in peopleList" :key="index">
            {{ item.realname }}
            <i
              v-if="peopleList.length > 1"
              class="el-icon-error clsw"
              @click="peopleList.splice(index, 1)"
            ></i>
          </li>
          <div style="clear: both"></div>
        </ul>
        <p style="margin: 0px">您确定要取消所选学员的考试预约吗？</p>
        <p style="margin: 0px">取消后将无法恢复，请慎重考虑！</p>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogDJ = false">取消</el-button>
        <el-button type="primary" @click="submitChecksDJ">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogQP"
      width="460px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">前培账号已开通标记</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogQP = false"
          />
        </div>
      </div>
      <div>
        <div v-if="ints === 1" class="aListBottom">{{ listData.realname }}</div>
        <ul v-if="ints === 2" style="margin: 0px">
          <li class="liBVS" v-for="(item, index) in peopleList" :key="index">
            {{ item.realname }}
            <i
              v-if="peopleList.length > 1"
              class="el-icon-error clsw"
              @click="peopleList.splice(index, 1)"
            ></i>
          </li>
          <div style="clear: both"></div>
        </ul>
        <el-select
          size="small"
          v-model="plan"
          placeholder="请选择前培计划"
          style="margin-bottom: 12px"
        >
          <el-option
            v-for="item in optionsList"
            :key="item.beforeId"
            :label="item.beforeName"
            :value="item.beforeId"
          >
          </el-option>
        </el-select>
        <p style="margin: 0px">所选学员的前培账号标记为【已开通】吗？</p>
        <div style="text-align: center; margin-top: 12px">
          <el-radio-group v-model="beforeStatus">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="2">否</el-radio>
          </el-radio-group>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogQP = false">取消</el-button>
        <el-button type="primary" @click="submitChecksQP">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogPLS"
      width="460px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">成绩和证书登记</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogPLS = false"
          />
        </div>
      </div>
      <div>
        <div v-for="(item, index) in peopleList" :key="index">
          <div class="aListBottom">
            {{ item.realname }}
            <i
              v-if="peopleList.length > 1"
              class="el-icon-error clsw"
              @click="peopleList.splice(index, 1)"
            ></i>
          </div>
          <el-form label-width="100px">
            <el-form-item label="考试成绩" required>
              <el-input-number
                :controls="false"
                v-model="item.performance"
                :min="0"
              ></el-input-number
              >分
            </el-form-item>
            <el-form-item label="考试结果" required>
              <el-radio-group v-model="item.result">
                <el-radio :label="1">通过</el-radio>
                <el-radio :label="0">不通过</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="证书编号">
              <el-input v-model="item.certificateCode"></el-input>
            </el-form-item>
            <el-form-item label="登记补充">
              <el-input
                v-model="item.remark"
                type="textarea"
                :rows="4"
              ></el-input>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogPLS = false">取消</el-button>
        <el-button type="primary" @click="submitChecksPals">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogDR"
      width="660px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">导入</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogDR = false"
          />
        </div>
      </div>
      <div>
        <div class="swq">
          <img
            style="width: 182px; height: 168px"
            src="@/assets/images/dr.png"
            alt=""
          />
        </div>
        <div style="padding-left: 100px">
          <p>第一步：下载导入模板</p>
          <p style="padding-left: 50px">
            <i class="el-icon-upload"></i
            ><span class="dowmStys" @click="getDowm">下载模板</span>
          </p>
          <p>
            第二步：(批量新增)：适用于新增预约考试；使用模版整理文件，点击“上传Excel”完成导入
          </p>
          <label
            for="mobles"
            class="el-button el-button--primary"
            style="margin-left: 50px; padding: 10px 20px"
            >上传Excel</label
          ><input
            style="display: none"
            type="file"
            id="mobles"
            ref="input1"
            @change="importMobleadd"
          />
          <p>
            (批量修改)：适用于修改预约、分数登记；使用模版整理文件，点击“上传Excel”完成导入
          </p>
          <label
            for="moblest"
            class="el-button el-button--primary"
            style="margin-left: 50px; padding: 10px 20px"
            >上传Excel</label
          ><input
            style="display: none"
            type="file"
            id="moblest"
            ref="input2"
            @change="importMobleEdit"
          />
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogDR = false">取消</el-button>
        <!-- <el-button type="primary" @click="submitChecksDR">确定</el-button> -->
      </span>
    </el-dialog>
    <goodsList ref="goodsList" @backMsg="search(3)" />
    <batch-import-dialoga
      :dialogVisible.sync="dialogVisible"
      temUrl="/oss/images/file/20230908/1694137357751.xls"
      apiKey="importorderquestionopen"
      :isCheck="false"
      :isShowTip="false"
      :isSuccessBack="true"
      @success="search"
      type="Excel"
    ></batch-import-dialoga>
  </div>
</template>

<script>
import batchImportDialoga from "./batchImportDialog.vue";
import goodsList from "./goodsListOpen";
import * as baseUrls from "@/utils/request.js";
import searchBoxNew from "@/components/searchBoxNew";
import tableList from "@/components/tableList";
import pagination from "@/components/pagination";
export default {
  name: "AsPlanned",
  components: { batchImportDialoga,searchBoxNew, tableList, pagination, goodsList },
  data() {
    return {
      dialogVisible:false,
      month: "",
      monthList: [
        { label: "一月", value: "01" },
        { label: "二月", value: "02" },
        { label: "三月", value: "03" },
        { label: "四月", value: "04" },
        { label: "五月", value: "05" },
        { label: "六月", value: "06" },
        { label: "七月", value: "07" },
        { label: "八月", value: "08" },
        { label: "九月", value: "09" },
        { label: "十月", value: "10" },
        { label: "十一月", value: "11" },
        { label: "十二月", value: "12" },
      ],
      day: "",
      dayList: [],
      monthApplyIndex: "",
      monthApplyList: [],
      size: "small",
      plan: "",
      loading: false, //当前表单加载是否加载动画
      navText: {
        border: true,
        title: "计划",
        index: 0,
        ch: "条",
        num: false,
        tableHide: true,
        choice: true,
        changeWidth: "240px",
        openCheckMore: true,
        addHide: true,
        backFatherBtn: {
          status: false,
          title: "未定义",
        },
      },
      //搜索
      formList: [
        {
          prop: "educationTypeId",
          placeholder: "教育类型",
          scope: "educationType",
        },
        {
          prop: "businessId",
          placeholder: "业务层次",
          scope: "businessLevel",
          edu: "educationTypeId",
        },
        {
          prop: "subscribeStatus",
          placeholder: "预约状态",
          scope: "select",
          options: [
            { label: "正常", value: 1 },
            { label: "取消", value: 2 },
          ],
        },
        {
          prop: "applyId",
          placeholder: "考试标题",
          scope: "examLists",
        },
        {
          prop: "beforeId",
          placeholder: "前培标题",
          scope: "beforeList",
        },
        {
          prop: "syncStatus",
          placeholder: "同步状态",
          scope: "select",
          options: [
            { label: "未同步", value: 0 },
            { label: "成功", value: 1 },
            { label: "失败", value: 2 },
          ],
        },
        {
          prop: "studentType",
          placeholder: "学员报名类型",
          scope: "select",
          options: [
            { label: "新考学员", value: 1 },
            { label: "补考学员", value: 2 },
          ],
        },
        {
          prop: "examStatus",
          placeholder: "考试登记类型",
          scope: "select",
          options: [
            { label: "待登记", value: 0 },
            { label: "正常", value: 1 },
            { label: "缺考", value: 2 },
            { label: "作弊", value: 3 },
            { label: "替考", value: 4 },
          ],
        },
        {
          prop: "majorId",
          placeholder: "所报专业",
          scope: "ProfessionalList",
        },
        {
          prop: "realname",
          placeholder: "请输入用户名",
        },
        {
          prop: "month",
          placeholder: "月份",
          scope: "slot",
          slotName: "month",
        },
      ],
      formData: {
        pageSize: 10,
        pageNum: 1,
        applyId: "",
        beforeId: "",
      },
      // 表单
      tableSet: [
        {
          label: "教育类型",
          prop: "educationTypeName",
          hidden: true,
        },
        {
          label: "业务层次",
          prop1: "projectName",
          prop2: "businessName",
          hidden: true,
          scope: "InfoMore",
        },
        {
          label: "考试机会",
          prop1: "examNumber",
          prop2: "expendNumber",
          hidden: true,
          scope: "chance",
        },
        {
          label: "前培机会",
          prop1: "doNumber",
          prop2: "expendBefore",
          hidden: true,
          scope: "chance",
        },
        {
          label: "预约状态",
          prop: "subscribeStatus",
          hidden: true,
          scope: "isOptions",
          options: [
            {
              label: "正常",
              value: 1,
            },
            {
              label: "取消",
              value: 2,
            },
          ],
        },
        {
          label: "前培标记",
          prop: "beforeStatus",
          hidden: true,
          scope: "isOptions",
          options: [
            {
              label: "已开通",
              value: 1,
            },
          ],
        },
        {
          label: "考试登记",
          prop: "examStatus",
          hidden: true,
          scope: "isOptionsDZYQ",
          options: [
            {
              label: "待登记",
              value: 0,
            },
            {
              label: "正常",
              value: 1,
            },
            {
              label: "缺考",
              value: 2,
            },
            {
              label: "作弊",
              value: 3,
            },
            {
              label: "替考",
              value: 4,
            },
          ],
        },
        {
          label: "考试成绩和结果",
          prop1: "performance",
          prop2: "result",
          hidden: true,
          scope: "resultType",
        },
        {
          label: "证书编号",
          prop: "certificateCode",
          hidden: true,
        },
        {
          label: "考试标题",
          prop: "applyName",
          hidden: true,
        },
        {
          label: "前培标题",
          prop: "beforeName",
          hidden: true,
        },
        {
          label: "学员姓名",
          prop: "realname",
          hidden: true,
        },
        {
          label: "学员身份证",
          prop: "idCard",
          hidden: true,
        },
        {
          label: "所购商品",
          prop1: "goodsCode",
          prop2: "goodsName",
          prop3: "standPrice",
          hidden: true,
          scope: "goodsInfos",
        },
        {
          label: "学员报考类型",
          prop: "studentType",
          hidden: true,
          scope: "isOptions",
          options: [
            {
              label: "新考学员",
              value: 1,
            },
            {
              label: "补考学员",
              value: 2,
            },
          ],
        },
        {
          label: "所报专业",
          prop: "categoryName",
          hidden: true,
        },
        {
          label: "预约场次(考试地点和时间)",
          prop1: "applySiteAddress",
          prop2: "applySiteExamTime",
          prop3: "applySiteStartTime",
          prop4: "applySiteEndTime",
          prop5: "examineeCode",
          prop6: "seatNumber",
          prop7: "syncStatus",
          hidden: true,
          scope: "changAdress",
        },
        {
          label: "考试次数消耗",
          prop: "examExpend",
          hidden: true,
        },
        {
          label: "预约场次(考培地点和时间)",
          prop1: "applySiteAddressTrain",
          prop2: "applySiteExamTrainTime",
          prop3: "applySiteStartTrainTime",
          prop4: "applySiteEndTrainTime",
          hidden: true,
          scope: "changAdressKP",
        },
        {
          label: "前培次数消耗",
          prop: "beforeExpend",
          hidden: true,
        },
        {
          label: "创建时间",
          prop: "createTime",
          hidden: true,
          scope: "aTimeList",
        },
      ],
      tableData: [], //表单数据
      total: 0, //一共多少条
      dialogCG: false,
      dialogDJ: false,
      dialogQP: false,
      dialogPLS: false,
      dialogDR: false,
      listData: {},
      rules: {
        examStatus: [
          { required: true, message: "请选择考试登记状态", trigger: "change" },
        ],
      },
      ints: 0, //1单选2多选
      peopleList: [],
      optionsList: [],
      beforeStatus: "", //1已开通0未开通
    };
  },
  mounted() {
    // if (this.$route.params.educationId && this.$route.params.businessId) {
    //   this.$set(
    //     this.formData,
    //     "educationTypeId",
    //     this.$route.params.educationId
    //   );
    //   this.$set(this.formData, "businessId", this.$route.params.businessId);
    //   this.$refs.searchBox.changeEducationType(
    //     this.$route.params.educationId,
    //     true
    //   );
    //   this.$refs.searchBox.changeBusinessLevel(this.$route.params.businessId);
    // }
    if (this.$route.query.type == 1) {
      this.formData.applyId = Number(this.$route.query.id);
    }
    if (this.$route.query.type == 2) {
      this.formData.beforeId = Number(this.$route.query.id);
    }
    if (this.$route.params.type == 3) {
      this.formData.applyId = Number(this.$route.params.id);
      this.formData.syncStatus = 2;
    }
    this.search();
    this.getQP();
  },
  activated() {
    this.search();
    this.getQP();
  },
  methods: {
    /**
     * 默认选择考前培训-施工七大员
     */
    moRenBus() {
      return new Promise((resolve, reject) => {
        this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
          for (let i = 0; i < res.rows.length; i++) {
            if (res.rows[i].educationName === "考前培训") {
              this.$set(this.formData, "educationTypeId", res.rows[i].id);
              this.$refs.searchBox.changeEducationType(res.rows[i].id, true);
              this.$api
                .inquirebusinessList({ status: 1, educationId: res.rows[i].id })
                .then((result) => {
                  for (let j = 0; j < result.rows.length; j++) {
                    if (
                      result.rows[j].projectName === "施工现场专业人员" &&
                      result.rows[j].businessName === "七大员"
                    ) {
                      this.$set(this.formData, "businessId", result.rows[j].id);
                      this.$refs.searchBox.changeBusinessLevel(
                        result.rows[j].id
                      );
                      resolve();
                      break;
                    }
                  }
                });
              break;
            }
          }
        });
      });
    },
    openBank() {
      this.dialogVisible = true
    },
    async controlsType(type) {
      if (type == 1) {
        await this.moRenBus();
        this.$set(this.formData, "subscribeStatus", 1);
        this.search(1);
        this.$refs.tableList.clearMoreActive();
      }
      if (type == 2) {
        if (this.$refs.tableList.allCheckData.length === 0) {
          this.$message.warning("请选择需要开通题库的数据");
          return;
        }
        const STATUS = this.$refs.tableList.allCheckData.every((i) => {
          return (
            i.subscribeStatus == 1 &&
            i.educationTypeName == "考前培训" &&
            i.projectName == "施工现场专业人员" &&
            i.businessName == "七大员"
          );
        });
        if (STATUS) {
          this.$refs.goodsList.showBox(
            this.$refs.tableList.allCheckData.map((i) => i.subscribeId)
          );
        } else {
          this.$message.error(
            `请选择业务类型为《考前培训-施工现场专业人员-七大员》及预约状态为正常的数据`
          );
          return;
        }
      }
    },
    getMonthDays(target) {
      let date = new Date(target + "-01"); // 移动端使用格式要转成： "2018/10/01"
      date.setMonth(date.getMonth() + 1); // 先设置为下个月
      date.setDate(0); // 再置0，变成当前月最后一天
      return date.getDate(); // 当前月最后一天即当前月拥有的天数
    },
    getCanActiveApplyMonth() {
      this.day = "";
      var year = new Date().getFullYear();
      var num = this.getMonthDays(year + "-" + this.month);
      var list = [];
      for (let i = 0; i < num; i++) {
        list.push({
          label: i + 1 + "号",
          value: i < 10 ? "0" + (i + 1) : i + 1,
        });
      }
      this.dayList = list || [];
      var a = year + this.month + this.day;
      this.getSearchApply(a);
    },
    getCanActiveApply() {
      var year = new Date().getFullYear();
      var a = year + "" + this.month + "" + this.day;
      this.getSearchApply(a);
    },
    getSearchApply(i) {
      this.monthApplyIndex = "";
      this.$api
        .obtainsystemsubscribesessiondata(i)
        .then((res) => {
          this.monthApplyList = res.data;
        })
        .catch(() => {
          this.monthApplyList = [];
        });
    },
    getDowm() {
      let url =
        baseUrls.BASE_IMG_URL +
        "/oss/images/file/20211228.xls" +
        `?time=${this.$methodsTools.getNewTime()}`;
      let link = document.createElement("a");
      let fileName = "导入模板" + ".xlsx";
      document.body.appendChild(link);
      link.href = url;
      link.dowmload = fileName;
      link.click();
      link.remove();
    },
    importMobleadd(e) {
      var self = this;
      var file = e.target.files[0];
      let formData = new FormData();
      formData.append("file", file);
      this.$api
        .editsystemsubscribeimportData(formData)
        .then((res) => {
          if (res.msg) {
            let url = baseUrls.baseURL + "common/download?fileName=" + res.msg;
            let link = document.createElement("a");
            let fileName = "失败原因" + ".xlsx";
            document.body.appendChild(link);
            link.href = url;
            link.dowmload = fileName;
            link.click();
            link.remove();
            self.$message.warning("导出失败，请看失败xlsx原因");
          } else {
            self.$message.success("导入成功");
          }
          self.search();
        })
        .finally(() => {
          e.target.value = "";
        });
    },
    importMobleEdit(e) {
      var self = this;
      var file = e.target.files[0];
      let formData = new FormData();
      formData.append("file", file);
      this.$api
        .editsystemimportUpdateData(formData)
        .then((res) => {
          if (res.msg) {
            let url = baseUrls.baseURL + "common/download?fileName=" + res.msg;
            let link = document.createElement("a");
            let fileName = "失败原因" + ".xlsx";
            document.body.appendChild(link);
            link.href = url;
            link.dowmload = fileName;
            link.click();
            link.remove();
            self.$message.warning("导出失败，请看失败xlsx原因");
          } else {
            self.$message.success("导入成功");
          }
          self.search();
        })
        .finally(() => {
          e.target.value = "";
        });
    },
    openZS(row, int) {
      if (row.examStatus !== 1) {
        this.$message.warning("考试登记状态为正常的计划才可执行该操作");
        return;
      }
      this.ints = 1;
      this.peopleList = [JSON.parse(JSON.stringify(row))];
      this.dialogPLS = true;
    },
    //证书
    submitChecksPals() {
      for (let i = 0; i < this.peopleList.length; i++) {
        if (
          !this.peopleList[i].performance &&
          this.peopleList[i].performance !== 0
        ) {
          this.$message.warning(
            `第${i + 1}条数据未填写考试成绩，请填写考试成绩！`
          );
          return;
        }
        if (!this.peopleList[i].result && this.peopleList[i].result !== 0) {
          this.$message.warning(
            `第${i + 1}条数据未选择考试结果，请选择考试结果！`
          );
          return;
        }
      }
      this.$api.appsystemsubscribe(this.peopleList).then((res) => {
        if (this.ints === 1) {
          this.$message.success("已修改成绩和证书登记");
        }
        if (this.ints === 2) {
          this.$message.success("已批量修改成绩和证书登记");
        }
        this.search();
        this.dialogPLS = false;
      });
    },
    getQP() {
      this.$api.inquiresystembefore({ status: 1 }).then((res) => {
        this.optionsList = res.rows;
      });
    },
    submitChecksDR() {},
    moreActive(int) {
      if (int === 1) {
        this.$router.push({
          path: "bulkImportPlan",
        });
        return;
      }
      if (int === 2) {
        this.$router.push({
          path: "cancelAppointMent",
        });
        return;
      }
      if (int === 3) {
        this.$router.push({
          path: "examRegistration",
        });
        return;
      }
      if (int === 5) {
        this.$router.push({
          path: "formerAccount",
        });
        return;
      }
      if (int === 1) {
        this.dialogDR = true;
        return;
      }
      if (!this.$refs.tableList.allCheckData.length) {
        this.$message.warning("请勾选需要操作的计划");
        return;
      }
      if (int === 2) {
        this.$router.push({
          path: "cancelAppointMent",
        });
        return;
        this.peopleList = JSON.parse(
          JSON.stringify(this.$refs.tableList.allCheckData)
        );
        var ast = this.peopleList.every((item) => {
          return (
            item.subscribeStatus === 1 &&
            item.beforeStatus !== 1 &&
            item.examStatus === 0 &&
            !item.examExpend
          );
        });
        if (ast) {
          this.listData = {};
          this.ints = 2;
          this.dialogDJ = true;
        } else {
          this.$message({
            type: "warning",
            duration: 7000,
            showClose: true,
            message:
              "请勾选预约考试为正常和前培标记【空】以及考试登记状态为待登记和没有消耗过考试次数的计划",
          });
          return;
        }
      }
      if (int === 3) {
        this.peopleList = JSON.parse(
          JSON.stringify(this.$refs.tableList.allCheckData)
        );
        var ast = this.peopleList.every((item) => {
          return item.subscribeStatus === 1;
        });
        if (ast) {
          this.listData = {};
          this.ints = 2;
          this.dialogCG = true;
        } else {
          this.$message.warning("请勾选预约状态为正常的计划");
          return;
        }
      }
      if (int === 4) {
        this.peopleList = JSON.parse(
          JSON.stringify(this.$refs.tableList.allCheckData)
        );
        var ast = this.peopleList.every((item) => {
          return item.examStatus === 1 && item.subscribeStatus === 1;
        });
        if (ast) {
          this.listData = {};
          this.ints = 2;
          this.dialogPLS = true;
        } else {
          this.$message.warning("请勾选考试登记状态以及预约状态为正常的计划");
          return;
        }
      }
      if (int === 5) {
        this.peopleList = JSON.parse(
          JSON.stringify(this.$refs.tableList.allCheckData)
        );
        var ast = this.peopleList.every((item) => {
          return (
            item.examStatus === 0 && item.subscribeStatus === 1
            // && item.beforeCount
          );
        });
        if (ast) {
          this.listData = {};
          this.ints = 2;
          this.plan = "";
          this.beforeStatus = "";
          this.dialogQP = true;
        } else {
          this.$message({
            type: "warning",
            duration: 7000,
            showClose: true,
            message:
              "请勾选考试登记为待登记和预约状态为正常以及存在预约前培场次",
          });
          return;
        }
      }
    },
    examBox(row) {
      this.ints = 1;
      this.listData = JSON.parse(JSON.stringify(row));
      this.dialogCG = true;
    },
    editInfo(v) {
      this.addClick(v, 2);
    },
    submitChecks(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (!this.listData.examStatus) {
            this.$message.warning("请选择考试登记状态");
            return;
          }
          this.submitForm();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    submitChecksDJ() {
      if (this.ints === 1) {
        var data = JSON.parse(JSON.stringify(this.listData));
        data.subscribeId = [data.subscribeId];
        data.subscribeStatus = 2;
        this.$api.editsystemsubscribe(data).then((res) => {
          this.$message.success("已取消预约");
          this.dialogDJ = false;
          this.search();
        });
      }
      if (this.ints === 2) {
        var data = JSON.parse(JSON.stringify(this.listData));
        var arrays = [];
        this.peopleList.forEach((item) => {
          arrays.push(item.subscribeId);
        });
        data.subscribeId = arrays;
        data.subscribeStatus = 2;
        this.$api.editsystemsubscribe(data).then((res) => {
          this.$message.success("已批量取消预约");
          this.dialogDJ = false;
          this.search();
        });
      }
    },
    submitForm() {
      if (this.ints === 1) {
        var data = JSON.parse(JSON.stringify(this.listData));
        data.subscribeId = [data.subscribeId];
        this.$api.editsystemsubscribe(data).then((res) => {
          this.$message.success("考试登记修改成功");
          this.dialogCG = false;
          this.search();
        });
      }
      if (this.ints === 2) {
        var data = JSON.parse(JSON.stringify(this.listData));
        var arrays = [];
        this.peopleList.forEach((item) => {
          arrays.push(item.subscribeId);
        });
        data.subscribeId = arrays;
        this.$api.editsystemsubscribe(data).then((res) => {
          this.$message.success("批量考试登记修改成功");
          this.dialogCG = false;
          this.search();
        });
      }
    },
    submitChecksQP() {
      var data = JSON.parse(JSON.stringify(this.listData));
      if (!this.plan && this.beforeStatus === 1) {
        this.$message.warning("请选择前培计划");
        return;
      }
      if (!this.beforeStatus) {
        this.$message.warning("请选择是或否");
        return;
      }
      var arrays = [];
      this.peopleList.forEach((item) => {
        arrays.push(item.subscribeId);
      });
      data.subscribeId = arrays;
      if (this.beforeStatus === 1) {
        data.beforeStatus = 1;
        data.beforeId = this.plan;
      }
      if (this.beforeStatus === 2) {
        data.beforeStatus = 0;
        data.beforeId = "";
      }
      this.$api.editsystemsubscribe(data).then((res) => {
        this.$message.success("前培账号已开通标记修改成功");
        this.dialogQP = false;
        this.search();
      });
    },
    search(int) {
      this.loading = true;
      if (int === 1) {
        this.formData.pageNum = 1;
      }
      if (int === 2) {
        this.formData = {
          pageSize: 10,
          pageNum: 1,
        };
      }
      if (int == 3) {
        this.$refs.tableList.clearMoreActive();
      }
      var data = JSON.parse(JSON.stringify(this.formData));
      if (this.month) {
        var year = new Date().getFullYear();
        var a = year + "" + this.month;
        if (this.day) {
          a = year + "" + this.month + "" + this.day;
        }
        data.ApplyDateTime = a;
      }
      if (this.monthApplyIndex) {
        data.applySiteExamTime =
          this.monthApplyList[this.monthApplyIndex].examTime;
        data.applySiteStartTime =
          this.monthApplyList[this.monthApplyIndex].examStartTime;
        data.applySiteEndTime =
          this.monthApplyList[this.monthApplyIndex].examEndTime;
      }
      this.$api
        .inquiresystemsubscribelist(data)
        .then((res) => {
          this.tableData = res.rows;
          this.total = res.total;
          this.navText.index = res.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    init() {
      this.month = "";
      this.monthApplyIndex = "";
      this.search(2);
    },
    del(v) {
      this.$alert(
        "确定删除此内容？<br />内容删除后将无法恢复，请慎重考虑",
        "提示",
        {
          dangerouslyUseHTMLString: true,
        }
      )
        .then(() => {
          var data = {
            gradeId: v.gradeId,
            status: -1,
          };
          this.$api.editGradegrade(data).then((res) => {
            this.$message.success("删除成功");
            this.search();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    addClick(v, int) {
      // int = 2详情 3学员管理
      if (v === undefined) {
        // 添加班级
        this.$router.push({
          path: "addClass",
        });
      } else {
        if (int === 2) {
          //班级详情
          this.$router.push({
            path: "manageClass",
            query: {
              id: v.gradeId,
            },
          });
        }
        if (int === 3) {
          // 学员管理
          this.$router.push({
            path: "studentMenu",
            query: {
              id: v.gradeId,
              goodsId: v.goodsList[0].goodsId,
            },
          });
        }
      }
    },
    handleSizeChange(v) {
      this.formData.pageSize = v;
      this.formData.pageNum = 1;
      this.search();
    },
    handleCurrentChange(v) {
      this.formData.pageNum = v;
      this.search();
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.el-button {
  border-radius: 8px;
}
/deep/.el-dialog {
  border-radius: 8px;
  .el-dialog__header {
    padding: 0;
    .hearders {
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0px 18px 0px 20px;
      border-bottom: 1px solid #e2e2e2;
      .leftTitle {
        font-size: 14px;
        font-weight: bold;
        color: #2f4378;
      }
      .rightBoxs {
        display: flex;
        align-items: center;
        img {
          width: 14px;
          height: 14px;
          margin-left: 13px;
          cursor: pointer;
        }
      }
    }
  }
  .el-dialog__footer {
    padding: 0;
    .dialog-footer {
      padding: 0px 40px;
      height: 70px;
      border-top: 1px solid #e2e2e2;
      display: flex;
      align-items: center;
      justify-content: flex-end;
    }
  }
}
.imgBox {
  width: 100%;
  // height: 210px;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  padding: 8px 8px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  .imgLabel {
    flex: 1;
    width: 100%;
    border: 1px dotted #e2e2e2;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    .msPhoto {
      display: flex;
      justify-content: center;
      align-items: center;
      max-width: 100%;
      max-height: 270px;
      img {
        max-width: 100%;
        max-height: 270px;
      }
    }
    .imgbbx {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      i {
        font-weight: bold;
        margin: 14px 0;
        font-size: 24px;
      }
    }
  }
  p {
    margin: 5px 0px;
  }
}
.aListBottom {
  margin-left: 20px;
  padding: 0px 6px;
  border: 1px solid #999;
  border-radius: 4px;
  height: 30px;
  line-height: 30px;
  display: inline-block;
}
.liBVS {
  margin-right: 20px;
  margin-bottom: 12px;
  padding: 0px 6px;
  border: 1px solid #999;
  border-radius: 4px;
  height: 30px;
  line-height: 30px;
  display: inline-block;
  float: left;
}
.clsw {
  margin-left: 4px;
  cursor: pointer;
  color: #f56c6c;
}
.swq {
  text-align: center;
  border-bottom: 1px solid #eee;
}
.dowmStys {
  color: blue;
  cursor: pointer;
}
</style>
