<template>
  <div class="pb_content" style="background: unset">
    <div v-if="ctype == 1" class="pb_content_body" style="
              background: #fff;
              padding: 0px 25px;
              box-sizing: border-box;
              border-radius: 5px;
            ">
      <div class="pb_head top">
        <span>班级管理</span>
        <div class="student_button" style="border-radius: 4px;">
          <el-button type="primary" class="bgColor" @click="dialogVisible = true">添加班级</el-button>
        </div>
      </div>
      <div class="student_head">
        <div class="student_search">
          <span>
            <el-input placeholder="请输入班级名称" v-model="sClassName" clearable>
            </el-input>
          </span>
          <el-button type="primary" @click="searchClass">查询</el-button>
        </div>
      </div>
    </div>
    <div class="pb_content_body" v-if="ctype == 1">
      <div class="student_table">
        <el-table v-if="ctype == 1" ref="table" :key="1" :data="tableData" border :height="tableHeight" :fit="true"
          v-loading="isLoading" style="width: 100%; height: 60%" :header-cell-style="{ background: '#f1f1f1' }"
          :row-class-name="tableRowClassName">
          <el-table-column prop="name" label="班级名称" min-width="40%" align="center">
          </el-table-column>
          <el-table-column prop="pnum" label="人数" min-width="40%" align="center">
          </el-table-column>
          <el-table-column label="操作" min-width="20%">
            <template slot-scope="scope">
              <el-button type="primary" size="small" @click="getStudent(scope.row.id)">查看学生</el-button>
              <el-button type="primary" size="small" @click="openUpdate(scope.row.id, scope.row.name)">修改</el-button>
              <el-button type="primary" size="small" @click="deleteClass(scope.row.id)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="student_page">
        <el-pagination background layout="prev, pager, next" :page-size="10" :total="total" v-if="page"
          @current-change="handleCurrentChange">
        </el-pagination>
      </div>
    </div>
    <div v-if="ctype == 2" class="pb_content_body" style="
              background: #fff;
              padding: 0px 25px;
              box-sizing: border-box;
              border-radius: 5px;
            ">
      <div class="pb_head top">
        <span>查看学生</span>
        <div class="student_button" style="border-radius: 4px;">
          <el-button type="primary" class="bgColor" @click="ctype = 1, getClass()">返回</el-button>
        </div>
      </div>
      <div class="student_head">
        <div class="head_left">
          <el-input v-model="sPhoneUser" class="student_input" placeholder="请输入用户名"></el-input>
          <el-select disabled v-model="cid" placeholder="请选择班级" class="student_input" @change="searchStudent"
            style="margin:0 10px">
            <el-option label="所有人" value=""></el-option>
            <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
          </el-select>
          <el-button class="student_button" @click="searchStudent">查询</el-button>
        </div>
        <div class="head_right">
          <el-button @click="addStudent">添加学生</el-button>
        </div>
      </div>
    </div>
    <div class="pb_content_body" v-if="ctype == 2">
      <div class="student_table">
        <el-table v-if="ctype == 2" :key="2" ref="table2" :data="tableData2" border :height="tableHeight" :fit="true"
          v-loading="isLoading" style="width: 100%" :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
          :row-class-name="tableRowClassName">
          <el-table-column label="姓名" min-width="10" align="center">
            <template slot-scope="scope">
              <div class="userImg">
                <div class="tx">
                  <img :src="
                    scope.row.headportrait != null
                      ? scope.row.headportrait
                      : tx
                  " alt />
                </div>
                <div style="
                          width: 150px;
                          text-align: left;
                          white-space: nowrap;
                          overflow: hidden;
                          text-overflow: ellipsis;
                        ">
                  {{ scope.row.name }}
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="学生账号" min-width="15" align="center">
            <template slot-scope="scope">
              <div>{{ scope.row.un ? scope.row.un : "" }}</div>
            </template>
          </el-table-column>
          <el-table-column prop="classname2" label="班级" min-width="15" align="center">
          </el-table-column>
          <el-table-column label="操作" width="250px">
            <template slot-scope="scope">
              <div class="btnBox">
                <el-button class="de_button" type="primary" size="small"
                  @click="iniPassword(scope.row.userid)">初始化密码</el-button>
                <el-button class="de_button" type="primary" size="small" @click="updateStudentA(scope.row)">修改</el-button>
                <el-button class="de_button" type="primary" size="small"
                  @click="deleteClassStudent(scope.row.userid)">移除</el-button>
                <!-- <div class="delete">
                  <img src="../../assets/remove.png" alt @click="deleteStudent(scope.row.userid, scope.row.state)" />
                </div> -->
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="student_page">
        <el-pagination background layout="prev, pager, next" :page-size="10" :total="total2" v-if="page2"
          @current-change="handleCurrentChange2"></el-pagination>
      </div>
    </div>
    <el-dialog :visible.sync="dialogVisibleAddStudent" :append-to-body="true" width="700px" :before-close="handleClose"
      class="add_student">
      <div slot="title" class="header-title">
        <div class="logoImg">
          <img src="../../assets/logo.png" alt />
        </div>
        <div class="title_add_student">添加学生</div>
      </div>
      <el-form>
        <el-form-item label="学生姓名" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生姓名" clearable v-model="sName" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="学生学号" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生学号" clearable v-model="sId" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="学生手机号" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生手机号" clearable v-model="sPhone" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="学生账号" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生账号" clearable v-model="sMail" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="所属学校" :label-width="formLabelWidth">
          <el-input disabled style="width: 300px" v-model="schoolName"></el-input>
        </el-form-item>
        <el-form-item label="班级" :label-width="formLabelWidth">
          <el-select v-model="cid" placeholder="请选择班级" disabled>
            <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <div style="text-align: center; color: #adb3b7">
          注：添加学生的账号密码为123456
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer flex">
        <el-button class="right" @click="insertStudent">确认</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisibleUpdate" :append-to-body="true" width="700px" :before-close="handleClose"
      class="add_student">
      <div slot="title" class="header-title">
        <div class="logoImg">
          <img src="../../assets/logo.png" alt />
        </div>
        <div class="title_add_student">修改学生</div>
      </div>
      <el-form>
        <el-form-item label="学生名称" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生姓名" clearable v-model="userinfo.name" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="学生学号" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生学号" clearable v-model="userinfo.studentid" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="学生手机号" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生手机号" clearable v-model="userinfo.phonenumber" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="学生账号" :label-width="formLabelWidth">
          <span>
            <el-input placeholder="请输入学生账号" clearable v-model="userinfo.un" class="add_input"></el-input>
          </span>
        </el-form-item>
        <el-form-item label="所属学校" :label-width="formLabelWidth">
          <el-input disabled style="width: 300px" v-model="schoolName"></el-input>
        </el-form-item>
        <el-form-item label="班级" :label-width="formLabelWidth">
          <el-select multiple collapse-tags v-model="userinfo.classid" placeholder="请选择班级">
            <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <div style="text-align: center; color: #adb3b7">
          注：添加学生的账号密码为123456
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer flex">
        <el-button class="right" @click="updateStudent">修改</el-button>
      </span>
    </el-dialog>
    <el-dialog title="添加班级" :visible.sync="dialogVisible" :append-to-body="true" width="25%" :before-close="handleClose"
      class="dialog_diy">
      <el-form>
        <el-form-item label="班级名称" :label-width="formLabelWidth">
          <el-input v-model="className" auto-complete="off" placeholder="请输入班级..."></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="insertClass">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="修改班级" :visible.sync="dialogVisible1" :append-to-body="true" width="25%" :before-close="handleClose"
      class="dialog_diy">
      <el-form>
        <el-form-item label="班级名称" :label-width="formLabelWidth">
          <el-input v-model="className1" auto-complete="off" placeholder="请输入班级..."></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible1 = false">取 消</el-button>
        <el-button type="primary" @click="updateClass">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="添加学生" :visible.sync="dialogVisibleMember" :append-to-body="true" width="500px" height="80%"
      :before-close="handleClose" class="addNewPP">
      <div class="people">
        <div class="people_top">
          <div class="people_top_right">
            <div class="people_search">
              <el-input placeholder="搜索学生姓名" v-model="searchTN" @keyup.enter.native="getClassStudent"></el-input>
              <div class="search_img" @click="getClassStudent">
                <img src="../../assets/icon/search.png" alt />
              </div>
            </div>
          </div>
          <div class="people_nav">选择成员</div>
        </div>
        <div class="t_j_box" style="
                  padding: 20px 0 0 25px;
                  width: calc(100% - 55px);
                  margin-left: 25px;
                ">
          <span>姓名</span>
          <span>账号</span>
        </div>
        <el-checkbox-group v-model="checkboxList3" class="people_name" v-if="teacherJuri.length" v-loading="isLoading2">
          <el-checkbox v-for="item in teacherJuri" :key="item.userid" :label="item.userid">
            <div class="t_j_box">
              <el-tooltip placement="top" :content="item.name ? item.name : '暂无姓名'">
                <span>{{ item.name ? item.name : "暂无姓名" }}</span>
              </el-tooltip>
              <el-tooltip placement="top" :content="item.username">
                <span>{{ item.username }}</span>
              </el-tooltip>
            </div>
          </el-checkbox>
        </el-checkbox-group>
        <div style="text-align: center; margin-top: 10px" v-else>暂无数据</div>
      </div>
      <div style="margin-top: 10px;">
        <el-pagination background layout="prev, pager, next" :page-size="pageSize3" :total="total3"
          v-if="page3 && teacherJuri.length" style="padding-bottom: 20px"
          @current-change="handleCurrentChange3"></el-pagination>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleMember = false">取 消</el-button>
        <el-button type="primary" @click="addClassStudent">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import TaskListHeader from 'gantt-elastic/src/components/TaskList/TaskListHeader.vue';

export default {
  data() {
    return {
      tableHeight: "500px",
      isLoading: false,
      formLabelWidth: "100px",
      sClassName: "",
      className: "",
      className1: "",
      classid: "",
      dialogVisible: false,
      dialogVisible1: false,
      dialogVisibleUpdate: false,
      dialogVisibleAddStudent: false,
      tableData: [],
      page: 1,
      total: 0,
      tableData2: [],
      page2: 1,
      total2: 0,
      userid: this.$route.query.userid,
      oid: this.$route.query.oid,
      cid: "",
      ctype: 1,
      sName: "",
      sPhone: "",
      sId: "",
      schoolName: "",
      sByClass: "",
      sMail: "",
      classJuri: [],
      userinfo: {},
      userinfoA: {},
      sPhoneUser: "",
      tx: require("../../assets/avatar.png"),
      dialogVisibleMember: false,
      checkboxList3: [],
      teacherJuri: [],
      pageSize3: 10,
      total3: 0,
      page3: 1,
      isLoading2: false,
      searchTN: "",
    };
  },
  created() {
    this.page = 1;
    this.getClass();
    this.getClass2();
    this.getSchoolName();
  },
  mounted() {
    this.$nextTick(function () {
      this.tableHeight =
        window.innerHeight - this.$refs.table.$el.offsetTop - 200;
      if (this.tableHeight <= 530) {
        this.tableHeight = 530;
      }
      // 监听窗口大小变化
      let self = this;
      window.onresize = function () {
        self.tableHeight =
          window.innerHeight - self.$refs.table.$el.offsetTop - 200;
        if (self.tableHeight <= 530) {
          self.tableHeight = 530;
        }
      };
    });
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if ((rowIndex + 1) % 2 === 0) {
        return "even_row";
      } else {
        return "";
      }
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getClass();
    },
    handleClose(done) {
      done();
    },
    time() {
      if (!this.now) {
        this.now = new Date().getTime();
        return true;
      } else {
        let time = new Date().getTime();
        if (time - this.now > 3000) {
          this.now = time;
          return true;
        } else {
          return false;
        }
      }
    },
    searchClass() {
      this.page = 1;
      this.getClass();
    },
    openUpdate(id, n) {
      this.classid = id;
      this.className1 = n;
      this.dialogVisible1 = true;
    },
    //新增班级
    insertClass() {
      let params = {
        name: this.className,
        oid: this.oid,
        uid: this.userid,
      };
      this.ajax
        .get(this.$store.state.api + "insertClass", params)
        .then((res) => {
          if (res.data[0] && res.data[0][0].classname == 1) {
            this.$message({
              message: "不能与其他班级名称相同！",
              type: "error",
            });
          } else {
            this.$message({
              message: "新增成功",
              type: "success",
            });
            this.dialogVisible = false;
            this.sClassName = "";
            this.getClass();
            this.className = "";
          }
        })
        .catch((err) => {
          this.$message({
            message: "新增失败",
            type: "error",
          });
          console.error(err);
        });
    },
    //修改班级
    updateClass() {
      let params = {
        id: this.classid,
        n: this.className1,
        oid: this.oid,
      };
      this.ajax
        .get(this.$store.state.api + "updateClass", params)
        .then((res) => {
          if (res.data[0] && res.data[0][0].classname == 1) {
            this.$message({
              message: "不能与其他班级名称相同！",
              type: "error",
            });
          } else {
            this.$message({
              message: "修改成功",
              type: "success",
            });
            this.dialogVisible1 = false;
            this.getClass();
            this.classid = "";
            this.className1 = "";
          }
        })
        .catch((err) => {
          this.$message({
            message: "修改失败",
            type: "error",
          });
          console.error(err);
        });
    },
    //获取班级列表
    getClass() {
      this.isLoading = true;
      let params = {
        // username: this.$store.state.userInfo.userid,
        cu: "",
        oid: this.oid,
        cn: this.sClassName,
        page: this.page,
      };
      this.ajax
        .get(this.$store.state.api + "selectClass", params)
        .then((res) => {
          this.isLoading = false;
          this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
          this.tableData = res.data[0];
        })
        .catch((err) => {
          this.isLoading = false;
          console.error(err);
        });
    },
    //删除班级
    deleteClass(id) {
      let params = {
        id: id,
      };
      if (this.time()) {
        this.$confirm("确定删除此班级吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.ajax
              .get(this.$store.state.api + "deleteClass", params)
              .then((res) => {
                this.$message({
                  message: "删除成功",
                  type: "success",
                });
                if (this.page != 1 && this.tableData.length == 1) {
                  this.page - 1;
                }
                this.getClass();
              })
              .catch((err) => {
                this.$message.error("删除失败");
                console.error(err);
              });
          })
          .catch(() => { });
      }
    },
    addStudent() {
      // this.dialogVisibleAddStudent = true;
      // (this.sName = ""), (this.sPhone = ""), (this.sByClass = ""), this.sMail;
      // this.getClass2();
      this.dialogVisibleMember = true
      this.searchTN = ""
      this.getClassStudent();
    },
    //新增学生
    insertStudent() {
      if (this.sName === "") {
        this.$message.error("学生姓名不能为空");
        return;
      } else if (
        this.sPhone != "" &&
        !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.sPhone)
      ) {
        this.$message.error("手机号格式不正确");
        return;
      } else if (
        !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.sMail)
      ) {
        this.$message.error("邮箱格式不正确");
        return;
      }

      if (this.time()) {
        let params = { un: this.sMail };
        this.ajax
          .get(this.$store.state.api + "findMail", params)
          .then((res) => {
            if (res.data[0].length > 0) {
              this.$message.error("此学生账号已被注册");
            } else {
              this.add_Student();
            }
          })
          .catch((err) => {
            console.error(err);
          });
      }
    },
    add_Student() {
      let params = [
        {
          username: this.sMail,
          userpassword: 123456,
          alias: this.sName,
          oid: this.oid,
          ph: this.sPhone,
          sid: this.sId,
          cid: this.cid,
        },
      ];
      this.ajax
        .post(this.$store.state.api + "batchRegistration", params)
        .then((res) => {

          let params = [
            {
              userid: res.data.uid,
              username: this.sName,
              sid: this.sId,
              type: 2,
              oid: res.data.oid,
              phone: res.data.ph,
              cid: res.data.cid,
              intro: "",
              sex: "0",
            },
          ];
          this.ajax
            .post(this.$store.state.api + "updateUserByEdu", params)
            .then((res) => {
              console.log(res);
            })
            .catch((err) => {
              console.error(err);
            });
          this.$message({
            message: "新增成功",
            type: "success",
          });
          this.dialogVisibleAddStudent = false;
          this.sPhone = "";
          this.sName = "";
          this.sByClass = [];
          this.sMail = "";
          this.getStudent(this.cid);
        })
        .catch((err) => {
          this.isLoading = false;
          this.$message({
            message: "新增失败",
            type: "error",
          });
          console.error(err);
        });
    },
    updateStudentA(res) {
      this.userinfo = JSON.parse(JSON.stringify(res));
      this.userinfoA = JSON.parse(JSON.stringify(res));
      this.userinfo.classid = this.userinfo.classid.split(",")
      this.dialogVisibleUpdate = true;
    },
    updateStudent() {
      if (this.userinfo.name === "") {
        this.$message.error("学生姓名不能为空");
        return;
      } else if (!this.userinfo.classid) {
        this.$message.error("请为学生选择班级");
        return;
      } else if (
        this.userinfo.phonenumber &&
        !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.userinfo.phonenumber)
      ) {
        this.$message.error("手机号格式不正确");
        return;
      } else if (
        !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
          this.userinfo.un
        )
      ) {
        this.$message.error("邮箱格式不正确");
        return;
      }

      if (this.time()) {
        if (this.userinfoA.un != this.userinfo.un) {
          let params = { un: this.userinfo.un };
          this.ajax
            .get(this.$store.state.api + "findMail", params)
            .then((res) => {
              if (res.data[0].length > 0) {
                this.$message.error("此学生账号已被注册");
              } else {
                this.update_Student();
              }
            })
            .catch((err) => {
              console.error(err);
            });
        } else {
          this.update_Student();
        }
      }
    },
    update_Student() {
      let params = [
        {
          userid: this.userinfo.userid,
          username: this.userinfo.un,
          alias: this.userinfo.name,
          ph: this.userinfo.phonenumber,
          sid: this.userinfo.studentid,
          cid: this.userinfo.classid.join(","),
        },
      ];
      this.ajax
        .post(this.$store.state.api + "updateStudentInfo", params)
        .then((res) => {
          this.$message({
            message: "修改成功",
            type: "success",
          });
          this.dialogVisibleUpdate = false;
          this.getStudent(this.cid);
        })
        .catch((err) => {
          this.isLoading = false;
          this.$message({
            message: "修改失败",
            type: "error",
          });
          console.error(err);
        });
    },
    deleteClassStudent(id) {
      let params = [{ uid: id, cid: this.cid }];
      this.$confirm("确定移除此学生在本班级吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.ajax
            .post(this.$store.state.api + "deleteClassStudent", params)
            .then((res) => {
              this.$message({
                message: "操作成功",
                type: "success",
              });
              this.getStudent(this.cid);
            })
            .catch((err) => {
              this.$message.error("操作失败");
              console.error(err);
            });
        })
        .catch(() => { });
    },
    //获取班级列表
    getClass2() {
      this.isLoading = true;
      let params = {
        oid: this.oid,
      };
      this.ajax
        .get(this.$store.state.api + "selectClassBySchool", params)
        .then((res) => {
          this.isLoading = false;
          this.classJuri = res.data[0];
        })
        .catch((err) => {
          this.isLoading = false;
          console.error(err);
        });
    },
    getSchoolName() {
      let params = {
        oid: this.oid,
      };
      this.ajax
        .get(this.$store.state.api + "selectSchoolName2", params)
        .then((res) => {
          this.schoolName = res.data[0][0].name;
        })
        .catch((err) => {
          console.error(err);
        });
    },
    searchStudent() {
      this.page2 = 1;
      this.getStudent(this.cid);
    },
    handleCurrentChange2(val) {
      this.page2 = val;
      this.getStudent(this.cid);
    },
    handleCurrentChange3(val) {
      this.page3 = val;
      this.getClassStudent();
    },
    getStudent(cid) {
      this.cid = cid
      this.ctype = 2
      this.isLoading = true;
      let params = {
        oid: this.oid,
        cid: this.cid,
        cu: "",
        cn: this.sPhoneUser,
        page: this.page2,
      };
      this.ajax
        .get(this.$store.state.api + "selectStudent2", params)
        .then((res) => {
          this.isLoading = false;
          this.total2 = res.data[0].length > 0 ? res.data[0][0].num : 0;
          this.tableData2 = res.data[0];
          this.getClass2();
        })
        .catch((err) => {
          this.isLoading = false;
          console.error(err);
        });
    },
    getClassStudent() {
      this.isLoading2 = true;
      let params = {
        oid: this.oid,
        cid: this.cid,
        cn: this.searchTN,
        page: this.page3,
        num: this.pageSize3,
      };
      this.ajax
        .get(this.$store.state.api + "getClassStudent", params)
        .then((res) => {
          this.isLoading2 = false;
          this.total3 = res.data[0].length > 0 ? res.data[0][0].num : 0;
          this.teacherJuri = res.data[0];
        })
        .catch((err) => {
          this.isLoading2 = false;
          console.error(err);
        });
    },
    addClassStudent() {
      if (!this.checkboxList3.length) {
        this.$message.error('请选择要添加班级的学生');
        return;
      }
      let params = [{
        cid: this.cid,
        student: JSON.stringify(this.checkboxList3)
      }];
      this.ajax
        .post(this.$store.state.api + "addClassStudent", params)
        .then((res) => {
          this.checkboxList3 = []
          this.dialogVisibleMember = false
          this.getStudent(this.cid)
        })
        .catch((err) => {
          console.error(err);
        });
    },
    iniPassword(id) {
      this.$confirm("确定" + "初始化" + "此学生的密码吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let params = [
            {
              uid: id,
              pa: 123456,
            },
          ];
          this.ajax
            .post(this.$store.state.api + "iniPassword", params)
            .then((res) => {
              this.$message({
                message: "初始化密码成功！",
                type: "success",
              });
            })
            .catch((err) => {
              console.error(err);
            });
        })
        .catch(() => { });
    },
  },
};
</script>

<style scoped>
.dialog_diy>>>.el-dialog__header {
  background: #3d67bc !important;
  padding: 15px 20px;
}

.dialog_diy>>>.el-dialog__title {
  color: #fff;
}

.student_table>>>.el-table--border td {
  border-right: 0px !important;
}

.dialog_diy>>>.el-dialog__headerbtn {
  top: 19px;
}

.dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  color: #fff;
}

.dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  color: #fff;
}

.student_head>>>.el-button--primary {
  background-color: #2268bc;
}

.xls_button {
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  color: rgb(34, 104, 188);
}

.pb_head {
  margin: 0 !important;
  width: 100% !important;
}

.student_page {
  margin-top: 10px;
}

.student_head {
  margin-top: 10px;
  padding-bottom: 15px;
  display: flex;
  justify-content: space-between;
}

.student_search {
  display: flex;
  width: 300px;
}

.student_search span {
  margin: 0 10px 0 0;
}

.student_button {
  display: flex;
  height: 40px;
}

.student_button .el-button--primary {
  /* margin-right: 10px; */
}

.upload-demo {
  display: flex;
  flex-direction: column;
  align-items: end;
  /* position: relative; */
  width: 100px;
  overflow: hidden;
}

.student_table {
  margin: 20px 0;
}

.el-table>>>.even_row {
  background-color: #f1f1f1;
}

.top {
  display: flex;
  justify-content: space-between;
}

.bgColor {
  background: #2167bc;
}

.student_table>>>.el-table,
.student_table>>>.el-table__body-wrapper {
  height: auto !important;
}

.student_head {
  margin-top: 10px;
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
}

.head_left {
  display: flex;
  align-items: center;
}

.head_right {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: baseline;
}

.student_input>>>.el-input__inner {
  width: 190px;
  font-size: 13px;
  padding: 0 10px;
}

.student_button {
  color: #fff;
  background: #2268bc;
}

.head_right>button:nth-child(1) {
  color: #fff;
  background: #2268bc;
}


.head_right>div {
  line-height: 40px;
  margin-left: 10px;
  color: #2a6dbe;
  text-decoration: underline;
  cursor: pointer;
}

.userImg {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

.tx {
  width: 40px;
  margin-right: 10px;
}

.delete {
  width: 25px;
  height: 25px;
  cursor: pointer;
  margin-left: 10px;
}

.tx>img,
.delete>img {
  width: 100%;
  height: 100%;
}

.btnBox {
  display: flex;
  align-items: center;
}

.add_student>>>.el-dialog__header {
  padding: 20px 20px 10px;
  text-align: center;
  background: #32455b;
}

.add_student>>>.el-dialog__title {
  font-size: 14px !important;
  color: #fff !important;
}

.add_student>>>.el-dialog__headerbtn {
  font-size: 20px !important;
}

.add_student>>>.el-form-item__label {
  margin-left: 65px;
}

.add_student>>>.el-form-item {
  display: flex;
}

.add_student>>>.el-form-item__content {
  margin: 0 !important;
}

.add_input {
  width: 365px;
}

.add_student>>>.el-dialog__footer {
  text-align: center !important;
}

.right {
  width: 250px;
  color: #fff;
  background: #0e72e6;
  margin-bottom: 20px;
}

.header-title {
  display: flex;
}

.logoImg {
  width: 30px;
}

.logoImg>img {
  width: 100%;
  height: 100%;
}

.title_add_student {
  margin: 0 auto;
  color: #fff;
}

.upload-demo {
  line-height: 0px !important;
}

.upload-demo>>>.el-button {
  color: #fff;
  background: #2268bc;
  width: 70px;
  height: 30px;
  padding: 0 !important;
  font-size: 12px;
  line-height: 0 !important;
}

.people {
  border: 1px solid rgb(229 229 229);
  height: 495px;
  border-radius: 5px;
  width: 100%;
  overflow: auto;
}

.people_top {
  display: flex;
  width: 100%;
  /* justify-content: space-between; */
  /* align-items: center; */
  flex-direction: column;
  padding: 10px 25px 0;
  box-sizing: border-box;
}

.people_nav,
.people_top_right {
  /* padding: 20px 0 0 20px; */
}

.people_top_right {
  height: 40px;
  margin-bottom: 10px;
}

.people_search {
  display: flex;
  position: relative;
}

.people_search>>>.el-input__inner {
  /* height: 25px; */
  width: 95%;
}

.search_img {
  width: 20px;
  height: 20px;
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
}

.search_img>img {
  width: 100%;
  height: 100%;
}

.people_name {
  display: flex;
  justify-content: flex-start;
  padding: 10px 0 0 25px;
  flex-direction: column;
  flex-wrap: nowrap;
  height: calc(100% - 140px);
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: column;
}

.people_name>>>.el-checkbox {
  width: 100%;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.people_name>>>.el-checkbox__label {
  text-overflow: ellipsis;
  overflow: hidden;
  width: 100%;
}

.addNewPP>>>.el-dialog__body {
  padding: 5px 20px;
}

.t_j_box {
  display: flex;
}

.t_j_box span:nth-child(1) {
  width: 50%;
  overflow: hidden;
  margin-right: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.t_j_box span:nth-child(2) {
  width: 50%;
  overflow: hidden;
  margin-right: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>
