<template>
  <section class="content">
    <div class="box box-info">
      <!-- 正文信息 -->
      <div class="box-body">
        <el-form
          :model="formSearch"
          :inline="true"
          ref="formSearch"
          label-width="70px"
        >
          <el-form-item v-if="isSuperAdmin" label="学校">
            <el-select
              v-model="formSearch.rootOrgId"
              placeholder="请选择"
              class="input"
            >
              <el-option
                v-for="item in rootOrgList"
                :label="item.name"
                :value="item.id"
                :key="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="姓名">
            <el-input
              placeholder="请输入姓名"
              v-model="formSearch.name"
              class="input"
            ></el-input>
          </el-form-item>
          <el-form-item label="学号">
            <el-input
              placeholder="请输入学号"
              v-model="formSearch.studentCode"
              class="input"
            ></el-input>
          </el-form-item>
          <el-form-item label="身份证">
            <el-input
              placeholder="请输入身份证"
              v-model="formSearch.identityNumber"
              class="input"
            ></el-input>
          </el-form-item>
          <el-form-item label="照片状态">
            <el-select v-model="formSearch.hasPhoto" class="input">
              <el-option label="未选择" value="UNDEFINED"> </el-option>
              <el-option label="已上传" value="TRUE"> </el-option>
              <el-option label="未上传" value="FALSE"> </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="d-block">
            <el-button
              v-if="rolePrivileges.search_student"
              size="small"
              type="primary"
              icon="el-icon-search"
              @click="resetPageAndSearchForm"
              >查询
            </el-button>
            <el-button
              size="small"
              icon="el-icon-refresh"
              @click="resetSearchForm"
            >
              重置
            </el-button>
            <el-button
              v-if="rolePrivileges.upload_student_photo"
              size="small"
              type="primary"
              icon="el-icon-upload2"
              @click="uploadPhoto"
              >上传照片
            </el-button>
            <el-button
              size="small"
              type="primary"
              icon="el-icon-download"
              @click="exportStudent"
            >
              导出
            </el-button>
          </el-form-item>
        </el-form>

        <div class="block-seperator"></div>
        <span>批量操作：</span>

        <el-button
          v-if="rolePrivileges.reset_student_password"
          size="small"
          type="danger"
          icon="el-icon-refresh"
          :disabled="noBatchSelected"
          @click="resetPassword('')"
          >重置密码
        </el-button>
        <el-button
          v-if="rolePrivileges.change_student_availability"
          size="small"
          type="success"
          icon="el-icon-check"
          :disabled="noBatchSelected"
          @click="enableStudent('')"
          >启用
        </el-button>
        <el-button
          v-if="rolePrivileges.change_student_availability"
          size="small"
          type="danger"
          icon="el-icon-close"
          :disabled="noBatchSelected"
          @click="disableStudent('')"
        >
          禁用
        </el-button>

        <div style="width: 100%;margin-bottom: 10px;"></div>

        <!-- 页面列表 -->
        <el-table
          :data="tableData"
          border
          style="width: 100%;text-align:center;"
          @selection-change="selectChange"
        >
          <el-table-column type="selection" width="50"></el-table-column>
          <el-table-column
            prop="id"
            width="100"
            label="ID"
            sortable
          ></el-table-column>
          <el-table-column label="考生" width="100">
            <template slot-scope="scope">
              <el-popover trigger="hover" placement="left">
                <div style="font-size: 18px;font-family: 新宋体">
                  <tr>
                    <td style="color: green">姓名</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.name }}
                    </td>
                  </tr>
                  <tr>
                    <td style="color: green">身份证号</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.identityNumber }}
                    </td>
                  </tr>
                  <tr>
                    <td style="color: green">学号</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.studentCodeList }}
                    </td>
                  </tr>
                  <tr>
                    <td style="color: green">学习中心名称</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.orgName }}
                    </td>
                  </tr>
                  <tr>
                    <td style="color: green">学习中心编码</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.orgCode }}
                    </td>
                  </tr>
                  <tr>
                    <td style="color: green">手机号</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.phoneNumber }}
                    </td>
                  </tr>
                  <tr>
                    <td style="color: green">安全手机号</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.securityPhone }}
                    </td>
                  </tr>
                  <tr>
                    <td style="color: green">创建时间</td>
                    <td style="color:purple;padding-left: 20px;">
                      {{ scope.row.creationTime }}
                    </td>
                  </tr>
                </div>

                <div slot="reference" class="name-wrapper">
                  <span>{{ scope.row.name }}</span>
                </div>
              </el-popover>
            </template>
          </el-table-column>
          <el-table-column label="学号">
            <span slot-scope="scope" v-html="scope.row.studentCodesStr"> </span>
          </el-table-column>
          <el-table-column
            prop="identityNumber"
            width=""
            label="身份证"
            sortable
          ></el-table-column>
          <el-table-column
            prop="orgName"
            width=""
            label="学习中心"
            sortable
          ></el-table-column>
          <el-table-column
            prop="updateTime"
            width="168"
            label="更新时间"
            sortable
          ></el-table-column>
          <el-table-column width="50" label="状态">
            <span slot-scope="scope">
              <span v-if="scope.row.enable">
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="启用"
                  placement="left"
                >
                  <i class="el-icon-success" style="color:green;"></i>
                </el-tooltip>
              </span>
              <span v-else>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="禁用"
                  placement="left"
                >
                  <i class="el-icon-error" style="color:red;"></i>
                </el-tooltip>
              </span>
            </span>
          </el-table-column>
          <el-table-column label="操作" width="300">
            <div slot-scope="scope">
              <el-button
                :disabled="!scope.row.photoPath"
                size="mini"
                type="primary"
                plain
                icon="el-icon-picture"
                @click="showPhoto(scope.row)"
                >查看照片
              </el-button>
              <el-button
                v-if="
                  null != scope.row.enable &&
                    !scope.row.enable &&
                    rolePrivileges.change_student_availability
                "
                size="mini"
                type="primary"
                plain
                icon="el-icon-check"
                @click="enableStudent(scope.row)"
                >启用
              </el-button>
              <el-button
                v-else-if="rolePrivileges.change_student_availability"
                size="mini"
                type="danger"
                icon="el-icon-close"
                @click="disableStudent(scope.row)"
                >禁用
              </el-button>

              <el-dropdown style="margin-left: 10px;">
                <el-button type="primary" plain size="mini">
                  更多<i class="el-icon-arrow-down el-icon--right"></i>
                </el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item
                    v-if="rolePrivileges.reset_student_password"
                  >
                    <el-button
                      size="mini"
                      type="danger"
                      icon="el-icon-refresh"
                      @click="resetPassword(scope.row)"
                      >重置密码
                    </el-button>
                  </el-dropdown-item>
                  <el-dropdown-item>
                    <el-button
                      size="mini"
                      type="primary"
                      icon="el-icon-document"
                      @click="showStuExamDialog(scope.row)"
                      >考试记录
                    </el-button>
                  </el-dropdown-item>
                  <el-dropdown-item v-if="rolePrivileges.unbind_student_code">
                    <el-button
                      size="mini"
                      type="danger"
                      icon="el-icon-refresh"
                      @click="showUnbindStudentCode(scope.row)"
                      >解绑学号
                    </el-button>
                  </el-dropdown-item>
                  <el-dropdown-item v-if="rolePrivileges.unbind_security_phone">
                    <el-button
                      size="mini"
                      type="danger"
                      icon="el-icon-refresh"
                      @click="unbindSecurityPhone(scope.row)"
                      >解绑安全手机
                    </el-button>
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </el-table-column>
        </el-table>
        <div class="page pull-right">
          <el-pagination
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-size="pageSize"
            :page-sizes="[10, 20, 50, 100, 200, 300]"
            @size-change="handleSizeChange"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
          >
          </el-pagination>
        </div>

        <!-- 解绑学号-->
        <el-dialog
          title="解绑学号"
          width="50%"
          :visible.sync="unbindStudentCodeDialog"
        >
          <el-table
            :data="unbindStudentCodeData.tableData"
            border
            style="width: 100%;text-align:center;"
          >
            <el-table-column prop="name" label="姓名" />
            <el-table-column prop="identityNumber" label="身份证" />
            <el-table-column prop="studentCode" label="学号" />
            <el-table-column label="操作" width="100">
              <div slot-scope="scope">
                <el-button
                  size="mini"
                  type="danger"
                  @click="unbindStudentCode(scope.row)"
                  icon="el-icon-delete"
                  >解绑
                </el-button>
              </div>
            </el-table-column>
          </el-table>
        </el-dialog>

        <!-- 考试记录 -->
        <el-dialog
          title="学生考试记录"
          width="60%"
          :visible.sync="stuExamDialog"
          v-loading="stuExamLoading"
          element-loading-text="拼命加载中"
        >
          <el-form
            :inline="true"
            :model="stuExamSearch"
            label-position="right"
            label-width="50px"
          >
            <el-form-item label="考试" class="pull-left">
              <el-select
                class="input"
                :remote-method="queryExams4Search"
                remote
                :loading="queryExams4SearchLoading"
                filterable
                clearable
                v-model="stuExamSearch.examId"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in examList4Search"
                  :label="item.name"
                  :value="item.id"
                  :key="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item class="pull-left">
              <el-button
                size="small"
                type="primary"
                icon="el-icon-search"
                @click="searchStuExam"
                >查询
              </el-button>
            </el-form-item>
          </el-form>

          <el-table
            :data="stuExamList"
            border
            style="width: 100%;text-align:center;"
          >
            <el-table-column prop="studentName" label="学生姓名">
            </el-table-column>
            <el-table-column prop="studentCode" label="学号"> </el-table-column>
            <el-table-column prop="identityNumber" label="身份证">
            </el-table-column>
            <el-table-column prop="examName" label="考试" sortable>
            </el-table-column>
            <el-table-column prop="courseName" label="课程" sortable>
            </el-table-column>
            <el-table-column width="130" label="考试状态">
              <div slot-scope="scope">
                <span v-if="null == scope.row.started"></span>
                <span v-else-if="scope.row.started">已考</span>
                <span v-else>未考</span>
              </div>
            </el-table-column>
          </el-table>
          <div class="page pull-right">
            <el-pagination
              @current-change="stuExamCurChange"
              :current-page="stuExamCurPage"
              :page-size="stuExamPageSize"
              :page-sizes="[10, 20, 50, 100, 200, 300]"
              @size-change="handleStuExamSizeChange"
              layout="total, sizes, prev, pager, next, jumper"
              :total="stuExamTotal"
            >
            </el-pagination>
          </div>
          <div style="margin-top: 10px;"></div>
        </el-dialog>

        <!-- 导入照片弹窗 -->
        <el-dialog
          title="学生照片导入"
          width="350px"
          :visible.sync="photoUploadDialog"
        >
          <el-form>
            <el-row>
              <el-form-item style="margin-left:30px">
                <el-upload
                  class="form_left"
                  ref="upload"
                  list-type="picture"
                  :action="uploadAction"
                  :headers="uploadHeaders"
                  :data="uploadData"
                  :before-upload="beforeUpload"
                  :on-progress="uploadProgress"
                  :on-success="uploadSuccess"
                  :on-error="uploadError"
                  :file-list="fileList"
                  :auto-upload="false"
                  :multiple="false"
                >
                  <el-button
                    size="small"
                    slot="trigger"
                    type="primary"
                    icon="el-icon-search"
                    >选择文件
                  </el-button>
                  <el-button
                    size="small"
                    style="margin-left:10px;"
                    type="primary"
                    icon="el-icon-check"
                    @click="submitUpload"
                    >确认上传
                  </el-button>
                  <div slot="tip" class="el-upload__tip">
                    只能上传jpg,png文件
                  </div>
                </el-upload>
              </el-form-item>
            </el-row>
          </el-form>
        </el-dialog>

        <!--查看照片-->
        <el-dialog
          title="照片"
          @close="closePhotoDialog"
          :visible.sync="photoDialog"
          width="300px"
          :center="true"
        >
          <img :src="photo.url" height="100%" width="100%" />
        </el-dialog>
      </div>
    </div>
  </section>
</template>

<script>
import {
  CORE_API,
  EXAM_WORK_API,
  EXCHANGE_API
} from "@/constants/constants.js";
import { mapState } from "vuex";

export default {
  data() {
    return {
      rolePrivileges: {
        search_student: false,
        upload_student_photo: false,
        reset_student_password: false,
        change_student_availability: false,
        unbind_student_code: false,
        unbind_security_phone: false
      },
      rootOrgList: null,
      stuExamLoading: false,
      button: {},
      formSearch: {
        rootOrgId: null,
        name: "",
        studentCode: "",
        identityNumber: "",
        enable: "",
        hasPhoto: "UNDEFINED"
      },
      selectedStuIds: [],
      statusList: [
        {
          value: true,
          label: "启用"
        },
        {
          value: false,
          label: "禁用"
        }
      ],

      tableData: [],
      currentPage: 1,
      pageSize: 10,
      total: 10,
      photoDialog: false,
      photo: { url: "" },

      unbindStudentCodeDialog: false,
      unbindStudentCodeData: {
        tableData: []
      },

      errMessages: [],
      uploadAction: EXCHANGE_API + "/facepp/add",
      uploadData: {},
      fileLoading: false,
      fileList: [],
      uploadHeaders: {},
      photoUploadDialog: false,

      stuExamCurPage: 1,
      stuExamPageSize: 10,
      stuExamTotal: 10,
      stuExamDialog: false,
      stuExamList: [],
      examList4Search: [],
      queryExams4SearchLoading: false,
      stuExamSearch: {
        rootOrgId: "",
        examId: "",
        studentCode: "",
        studentName: "",
        orgId: "",
        specialtyName: "",
        courseCode: "",
        courseName: "",
        infoCollector: "",
        identityNumber: "",
        identityNumberLike: false
      }
    };
  },
  computed: {
    ...mapState({ user: state => state.user }),
    stuIds() {
      var stuIds = "";
      for (let stuId of this.selectedStuIds) {
        if (!stuIds) {
          stuIds += stuId;
        } else {
          stuIds += "," + stuId;
        }
      }
      return stuIds;
    },
    noBatchSelected() {
      return this.selectedStuIds.length === 0;
    },
    isSuperAdmin() {
      return this.user.roleList.some(role => role.roleCode == "SUPER_ADMIN");
    }
  },
  methods: {
    queryExams4Search(name) {
      this.queryExams(name, "search");
    },
    queryExams(name, where) {
      console.log("queryExams; name: " + name);
      if ("search" == where) {
        this.queryExams4SearchLoading = true;
      }
      this.$httpWithMsg
        .get(EXAM_WORK_API + "/exam/queryByNameLike?name=" + name)
        .then(response => {
          if ("search" == where) {
            this.queryExams4SearchLoading = false;
            this.examList4Search = response.data;
          }
        })
        .catch(() => {
          if ("search" == where) {
            this.queryExams4SearchLoading = false;
          }
        });
    },
    showStuExamDialog(row) {
      this.stuExamSearch.identityNumber = row.identityNumber;
      this.stuExamSearch.rootOrgId = row.rootOrgId;
      this.stuExamList = [];
      this.stuExamTotal = 0;
      this.queryExams4Search("");
      this.searchStuExam();
      this.stuExamDialog = true;
    },
    searchStuExam() {
      var param = new URLSearchParams(this.stuExamSearch);
      this.stuExamLoading = true;
      var url =
        EXAM_WORK_API +
        "/exam_student/examStudentPage/" +
        (this.stuExamCurPage - 1) +
        "/" +
        this.stuExamPageSize +
        "?" +
        param;
      this.$httpWithMsg
        .get(url)
        .then(response => {
          this.stuExamList = response.data.list;
          this.stuExamTotal = response.data.total;
          this.stuExamLoading = false;
        })
        .catch(function(response) {
          console.log(response);
          this.stuExamLoading = false;
        });
    },
    stuExamCurChange(val) {
      this.stuExamCurPage = val;
      this.searchStuExam();
    },
    handleStuExamSizeChange(val) {
      this.stuExamPageSize = val;
      this.searchStuExam();
    },
    closePhotoDialog() {
      this.photo.url = "/img/blank.png";
      this.photoDialog = false;
    },
    showPhoto(row) {
      if (row.photoPath) {
        this.photo.url = row.photoPath;
        this.photoDialog = true;
      } else {
        this.$notify({
          showClose: true,
          message: "未上传照片",
          type: "error"
        });
      }
    },
    uploadPhoto() {
      this.photoUploadDialog = true;
      this.initUpload();
    },
    selectChange(row) {
      this.selectedStuIds = [];
      row.forEach((element, index) => {
        console.log(index);
        this.selectedStuIds.push(element.id);
      });
      console.log(this.selectedStuIds);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.searchForm();
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.searchForm();
    },
    resetSearchForm() {
      this.formSearch.name = "";
      this.formSearch.studentCode = "";
      this.formSearch.identityNumber = "";
      this.formSearch.enable = "";
      this.formSearch.hasPhoto = "UNDEFINED";
    },
    resetPageAndSearchForm() {
      this.currentPage = 1;
      this.searchForm();
    },
    //查询方法
    searchForm() {
      var param = new URLSearchParams(this.formSearch);
      var url =
        CORE_API +
        "/student/studentPage/" +
        (this.currentPage - 1) +
        "/" +
        this.pageSize +
        "?" +
        param;
      this.$httpWithMsg.get(url).then(response => {
        this.tableData = response.data.list;
        this.total = response.data.total;
      });
    },
    exportStudent() {
      var param = new URLSearchParams(this.formSearch);
      window.open(
        CORE_API +
          "/student/export?$key=" +
          this.user.key +
          "&$token=" +
          this.user.token +
          "&" +
          param
      );
    },
    checkIds(row) {
      if (row) {
        return row.id;
      } else {
        if (this.stuIds.length == 0) {
          this.$notify({
            type: "warning",
            message: "请选择学生"
          });
          return "";
        } else {
          return this.stuIds;
        }
      }
    },
    showUnbindStudentCode(row) {
      this.unbindStudentCodeData.tableData = [];
      for (let cur of row.studentCodeList) {
        this.unbindStudentCodeData.tableData.push({
          studentCode: cur,
          rootOrgId: row.rootOrgId,
          name: row.name,
          identityNumber: row.identityNumber
        });
      }
      this.unbindStudentCodeDialog = true;
    },
    unbindStudentCode(row) {
      var params = new URLSearchParams({
        studentCode: row.studentCode,
        rootOrgId: row.rootOrgId
      });
      this.$confirm("是否解绑学号？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        var url = CORE_API + "/student/unbindStudentCode?" + params;
        this.$httpWithMsg.post(url).then(response => {
          console.log(response);
          let newTableData = [];
          for (let cur of this.unbindStudentCodeData.tableData) {
            if (row.studentCode != cur.studentCode) {
              newTableData.push(cur);
            }
          }
          this.unbindStudentCodeData.tableData = newTableData;
          this.$notify({
            type: "success",
            message: "解绑成功"
          });
          this.searchForm();
        });
      });
    },
    unbindSecurityPhone(row) {
      var stuIds = this.checkIds(row);
      if (!stuIds) return;
      this.$confirm("是否解绑安全手机号？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        var url = CORE_API + "/student/unbindSecurityPhone/" + stuIds;
        this.$httpWithMsg.put(url).then(response => {
          console.log(response);
          this.$notify({
            type: "success",
            message: "解绑成功"
          });
          this.searchForm();
        });
      });
    },
    //重置密码方法
    resetPassword(row) {
      var stuIds = this.checkIds(row);
      if (!stuIds) return;
      this.$confirm("是否重置所选学生的密码？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        var url = CORE_API + "/student/resetPass/" + stuIds;
        this.$httpWithMsg.put(url).then(response => {
          console.log(response);
          this.$notify({
            type: "success",
            message: "重置密码成功"
          });
          this.searchForm();
        });
      });
    },

    //禁用
    disableStudent(row) {
      var stuIds = this.checkIds(row);
      if (!stuIds) return;
      this.$confirm("是否禁用所选学生？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        var url = CORE_API + "/student/disable/" + stuIds;
        this.$httpWithMsg.put(url).then(response => {
          console.log(response);
          this.$notify({
            type: "success",
            message: "禁用成功"
          });
          this.searchForm();
        });
      });
    },

    //启用
    enableStudent(row) {
      var stuIds = this.checkIds(row);
      if (!stuIds) return;
      this.$confirm("是否启用所选学生？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        var url = CORE_API + "/student/enable/" + stuIds;
        this.$httpWithMsg.put(url).then(response => {
          console.log(response);
          this.$notify({
            type: "success",
            message: "启用成功"
          });
          this.searchForm();
        });
      });
    },
    beforeUpload(file) {
      console.log(file);
    },
    uploadProgress(event, file, fileList) {
      console.log("uploadProgress");
      console.log(event);
      console.log(file);
      console.log(fileList);
    },
    uploadSuccess(response, file, fileList) {
      console.log(response);
      console.log(file);
      console.log(fileList);
      this.$notify({
        message: "上传成功",
        type: "success"
      });
      this.fileLoading = false;
      this.photoUploadDialog = false;
      this.searchForm();
    },
    uploadError(response, file, fileList) {
      console.log(response);
      console.log(file);
      console.log(fileList);
      var json = JSON.parse(response.message);
      if (response.status == 500) {
        this.$notify({
          message: json.desc,
          type: "error"
        });
      }
      this.fileLoading = false;
    },
    initUpload() {
      this.fileList = [];
    },
    checkUpload() {
      var fileList = this.$refs.upload.uploadFiles;
      if (fileList.length == 0) {
        this.$notify({
          message: "上传文件不能为空",
          type: "error"
        });
        return false;
      }
      if (fileList.length > 1) {
        this.$notify({
          message: "每次只能上传一个文件",
          type: "error"
        });
        return false;
      }
      for (let file of fileList) {
        let f = file.name.toLowerCase();
        if (!f.endsWith(".jpg") && !f.endsWith(".png")) {
          this.$notify({
            message: "上传文件必须为jpg或者png格式",
            type: "error"
          });
          this.initUpload();
          return false;
        }
      }
      return true;
    },
    //确定上传
    submitUpload() {
      if (!this.checkUpload()) {
        return false;
      }
      this.$refs.upload.submit();
      this.fileLoading = true;
    },
    //清空文件
    removeFile() {
      this.$refs.upload.clearFiles();
    },
    initPrivileges() {
      let params = new URLSearchParams();
      params.append(
        "privilegeCodes",
        Object.keys(this.rolePrivileges).toString()
      );
      let url = CORE_API + "/rolePrivilege/checkPrivileges?" + params;
      this.$httpWithMsg.post(url).then(response => {
        this.rolePrivileges = response.data;
      });
    },
    init() {
      this.initPrivileges();

      var url = CORE_API + "/org/getRootOrgList";

      this.$httpWithMsg.get(url).then(response => {
        this.rootOrgList = response.data;
        this.formSearch.rootOrgId = this.user.rootOrgId;
        this.searchForm();
      });
    }
  },
  created() {
    this.init();
    this.uploadHeaders = {
      key: this.user.key,
      token: this.user.token
    };
  }
};
</script>
<style scoped>
.input {
  width: 180px;
}
</style>
