|
@@ -0,0 +1,969 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="fontlist" v-loading="isLoading">
|
|
|
+ <div class="listA" v-for="i in tableData" :key="i.userid">
|
|
|
+ <div class="baseFlex">
|
|
|
+ <img :src="i.headportrait ? i.headportrait : tx" alt />
|
|
|
+ <div
|
|
|
+ style="display: flex;flex-direction: column;justify-content: space-between;color: #666666;height: 100%;"
|
|
|
+ >
|
|
|
+ <div style="font-size: 16px;color: #000;">{{ i.username }}</div>
|
|
|
+ <div>{{ i.acc }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="baseFlex">
|
|
|
+ <el-tag size="mini" v-if="i.gname">{{ i.gname }}</el-tag>
|
|
|
+ <el-tag size="mini" v-else type="danger">无年级</el-tag>
|
|
|
+
|
|
|
+ <el-tag size="mini" v-if="i.classname" type="success">{{
|
|
|
+ i.classname
|
|
|
+ }}</el-tag>
|
|
|
+ <el-tag size="mini" v-else type="danger">无班级</el-tag>
|
|
|
+
|
|
|
+
|
|
|
+ <span @click="iniPassword(i.userid)">初始化密码</span>
|
|
|
+ <span @click="updateStudentA(i)">编辑</span>
|
|
|
+ <template v-if="cidL">
|
|
|
+ <span @click="deleteClassStudent(i.userid)">移出</span>
|
|
|
+ </template>
|
|
|
+ <span v-else @click="deleteStudent(i.userid, i.state)">删除</span>
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="fontPage">
|
|
|
+ <el-pagination
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="currentPage"
|
|
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
|
+ :page-size="pageSize"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :total="total"
|
|
|
+ >
|
|
|
+ </el-pagination>
|
|
|
+ </div>
|
|
|
+ <!-- 添加学生 -->
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ :append-to-body="true"
|
|
|
+ width="600px"
|
|
|
+ :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="100px">
|
|
|
+ <span>
|
|
|
+ <el-input
|
|
|
+ placeholder="请输入学生姓名"
|
|
|
+ clearable
|
|
|
+ v-model="sName"
|
|
|
+ class="add_input"
|
|
|
+ ></el-input>
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="学生账号" label-width="100px">
|
|
|
+ <span>
|
|
|
+ <el-input
|
|
|
+ placeholder="请输入学生账号"
|
|
|
+ clearable
|
|
|
+ v-model="sMail"
|
|
|
+ class="add_input"
|
|
|
+ ></el-input>
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="所属学校" label-width="100px">
|
|
|
+ <el-input
|
|
|
+ disabled
|
|
|
+ style="width: 300px"
|
|
|
+ v-model="schoolName"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="班级" label-width="100px">
|
|
|
+ <el-select
|
|
|
+ multiple
|
|
|
+ collapse-tags
|
|
|
+ v-model="sByClass"
|
|
|
+ placeholder="请选择班级"
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <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">
|
|
|
+ 注:添加学生的账号密码为Coco1234
|
|
|
+ </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="600px"
|
|
|
+ :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="100px">
|
|
|
+ <span>
|
|
|
+ <el-input
|
|
|
+ placeholder="请输入学生姓名"
|
|
|
+ clearable
|
|
|
+ v-model="userinfo.username"
|
|
|
+ class="add_input"
|
|
|
+ ></el-input>
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="学生账号" label-width="100px">
|
|
|
+ <span>
|
|
|
+ <el-input
|
|
|
+ placeholder="请输入学生账号"
|
|
|
+ clearable
|
|
|
+ v-model="userinfo.acc"
|
|
|
+ class="add_input"
|
|
|
+ ></el-input>
|
|
|
+ </span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="所属学校" label-width="100px">
|
|
|
+ <el-input
|
|
|
+ disabled
|
|
|
+ style="width: 300px"
|
|
|
+ v-model="schoolName"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="班级" label-width="100px">
|
|
|
+ <el-select
|
|
|
+ multiple
|
|
|
+ collapse-tags
|
|
|
+ v-model="userinfo.classid"
|
|
|
+ v-loading="optionLoading"
|
|
|
+ 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">
|
|
|
+ 注:添加学生的账号密码为Coco1234
|
|
|
+ </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="dialogVisibleMember"
|
|
|
+ :append-to-body="true"
|
|
|
+ width="600px"
|
|
|
+ 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="10"
|
|
|
+ :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 pinyin from "../../../../../node_modules/js-pinyin/index";
|
|
|
+
|
|
|
+export default {
|
|
|
+ props: ["userid", "oid", "org", "role", "searhValue","cid","cidL"],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 学生视图
|
|
|
+ tableData: [], //学生视图数据
|
|
|
+ tx: require("../../../../assets/avatar.png"),
|
|
|
+ isLoading: false,
|
|
|
+ total: 0,
|
|
|
+ currentPage: 1,
|
|
|
+ pageSize: 10,
|
|
|
+
|
|
|
+ // 班级添加学生弹框
|
|
|
+ dialogVisibleMember:false,
|
|
|
+ isLoading2:false,
|
|
|
+ teacherJuri:[], //数据
|
|
|
+ total3: 0, //学生总数
|
|
|
+ checkboxList3:[], //勾选中的学生
|
|
|
+ page3: 1, //页数
|
|
|
+ searchTN:'', //搜索框
|
|
|
+
|
|
|
+ // 修改学生弹框
|
|
|
+ dialogVisibleUpdate: false,
|
|
|
+ userinfo: {},
|
|
|
+ userinfoA: {},
|
|
|
+ classJuri: [], //班级列表
|
|
|
+ optionLoading: false, //班级列表loading
|
|
|
+
|
|
|
+ // 添加学生弹框
|
|
|
+ dialogVisible: false,
|
|
|
+ sName: "",
|
|
|
+ sByClass: "", //班级
|
|
|
+ sMail: "", //学生账号
|
|
|
+ sPhone: "",
|
|
|
+ userSuffix: "", //后缀
|
|
|
+ sId: "",
|
|
|
+
|
|
|
+ schoolName: "",//学校名称
|
|
|
+ schoolChar: "",
|
|
|
+
|
|
|
+
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+
|
|
|
+ // 获取table获取学生
|
|
|
+ getStudent() {
|
|
|
+ this.isLoading = true;
|
|
|
+ let params = {
|
|
|
+ oid: this.oid,
|
|
|
+ cid: this.cid,
|
|
|
+ inp: this.searhValue,
|
|
|
+ page: this.currentPage,
|
|
|
+ num: this.pageSize
|
|
|
+ };
|
|
|
+ this.ajax
|
|
|
+ .get(this.$store.state.api + "selectStudentManage", 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);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取创建学生用户后缀
|
|
|
+ getUser() {
|
|
|
+ let params = {
|
|
|
+ userid: this.userid
|
|
|
+ };
|
|
|
+ this.ajax
|
|
|
+ .get(this.$store.state.api + "selectUser", params)
|
|
|
+ .then(res => {
|
|
|
+ this.userSuffix = res.data[0][0].accountNumber.split("@")[1];
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ 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;
|
|
|
+ const cleanedSchoolName = res.data[0][0].name.replace(
|
|
|
+ /[,。;:!“”‘’()()]/g,
|
|
|
+ ""
|
|
|
+ ); // 去掉标点符号
|
|
|
+ // console.log(pinyin);
|
|
|
+ // console.log(pinyin.getFullChars(cleanedSchoolName));
|
|
|
+ // console.log(pinyin.getCamelChars(cleanedSchoolName));
|
|
|
+ this.schoolChar = pinyin
|
|
|
+ .getCamelChars(cleanedSchoolName)
|
|
|
+ .toLowerCase();
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //获取班级列表
|
|
|
+ getClass() {
|
|
|
+ this.optionLoading = true;
|
|
|
+ let params = {
|
|
|
+ oid: this.oid
|
|
|
+ };
|
|
|
+ this.ajax
|
|
|
+ .get(this.$store.state.api + "selectClassBySchool", params)
|
|
|
+ .then(res => {
|
|
|
+ this.optionLoading = false;
|
|
|
+ this.classJuri = res.data[0];
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ this.optionLoading = false;
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 初始化密码
|
|
|
+ iniPassword(id) {
|
|
|
+ this.$confirm("确定" + "初始化" + "此学生的密码吗?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ let params = [
|
|
|
+ {
|
|
|
+ uid: id,
|
|
|
+ pa: "Coco1234"
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ this.ajax
|
|
|
+ .post(this.$store.state.api + "iniPassword", params)
|
|
|
+ .then(res => {
|
|
|
+ this.$message({
|
|
|
+ message: "初始化密码成功!",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ // 删除学生
|
|
|
+ deleteStudent(id, state) {
|
|
|
+ state = 0;
|
|
|
+ let params = [{ uid: id, state: state }];
|
|
|
+ this.$confirm("确定删除此学生吗?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.ajax
|
|
|
+ .post(this.$store.state.api + "deleteStudent", params)
|
|
|
+ .then(res => {
|
|
|
+ this.$message({
|
|
|
+ message: "操作成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ this.getStudent();
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ this.$message.error("操作失败");
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ // 修改每页获取个数
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.pageSize = val;
|
|
|
+ this.currentPage = 1;
|
|
|
+ this.getStudent();
|
|
|
+ console.log(`每页 ${val} 条`);
|
|
|
+ },
|
|
|
+ // 跳转页数
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.currentPage = val;
|
|
|
+ this.getStudent();
|
|
|
+ console.log(`当前页: ${val}`);
|
|
|
+ },
|
|
|
+ // 关闭弹框
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 班级添加学生弹框
|
|
|
+ // 首页调用打开班级添加学生弹框
|
|
|
+ diaAdd(){
|
|
|
+ this.dialogVisibleMember = true;
|
|
|
+ this.searchTN = "";
|
|
|
+ this.getClassStudent();
|
|
|
+ },
|
|
|
+ // 添加学生弹框获取数据
|
|
|
+ getClassStudent() {
|
|
|
+ this.isLoading2 = true;
|
|
|
+ let params = {
|
|
|
+ oid: this.oid,
|
|
|
+ cid: this.cid,
|
|
|
+ cn: this.searchTN,
|
|
|
+ page: this.page3,
|
|
|
+ num: 10
|
|
|
+ };
|
|
|
+ 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();
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ //添加学生弹框
|
|
|
+ addStudent() {
|
|
|
+ this.dialogVisible = true;
|
|
|
+ this.sName = "";
|
|
|
+ this.sPhone = "";
|
|
|
+ this.sByClass = "" ;
|
|
|
+ this.sMail='';
|
|
|
+ // this.getClass();
|
|
|
+ },
|
|
|
+ //确认添加学生新增学生前判断是否被注册以及格式问题
|
|
|
+ insertStudent() {
|
|
|
+ this.dialogVisible = true;
|
|
|
+ if (this.sName === "") {
|
|
|
+ this.$message.error("学生姓名不能为空");
|
|
|
+ return;
|
|
|
+ } else if (this.sByClass === "") {
|
|
|
+ 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 (this.sMail === "") {
|
|
|
+ this.$message.error("学生账号不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let mail = "";
|
|
|
+ if (
|
|
|
+ /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.sMail)
|
|
|
+ ) {
|
|
|
+ mail = this.sMail;
|
|
|
+ } else {
|
|
|
+ if (
|
|
|
+ this.org != "" &&
|
|
|
+ this.org != "null" &&
|
|
|
+ this.org != undefined &&
|
|
|
+ this.org &&
|
|
|
+ this.schoolChar
|
|
|
+ ) {
|
|
|
+ mail = this.sMail + "@" + this.schoolChar + "." + this.userSuffix;
|
|
|
+ } else {
|
|
|
+ mail = this.sMail + "@" + this.userSuffix;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.time()) {
|
|
|
+ let params = { un: mail };
|
|
|
+ this.ajax
|
|
|
+ .get(this.$store.state.api + "findMail", params)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data[0].length > 0) {
|
|
|
+ this.$message.error("此学生账号已被注册");
|
|
|
+ } else {
|
|
|
+ this.comfirmAddStudent();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 最终添加学生函数
|
|
|
+ comfirmAddStudent() {
|
|
|
+ let mail = "";
|
|
|
+ if (
|
|
|
+ /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.sMail)
|
|
|
+ ) {
|
|
|
+ mail = this.sMail;
|
|
|
+ } else {
|
|
|
+ if (
|
|
|
+ this.org != "" &&
|
|
|
+ this.org != "null" &&
|
|
|
+ this.org != undefined &&
|
|
|
+ this.org &&
|
|
|
+ this.schoolChar
|
|
|
+ ) {
|
|
|
+ mail = this.sMail + "@" + this.schoolChar + "." + this.userSuffix;
|
|
|
+ } else {
|
|
|
+ mail = this.sMail + "@" + this.userSuffix;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let params = [
|
|
|
+ {
|
|
|
+ username: mail,
|
|
|
+ userpassword: "Coco1234",
|
|
|
+ alias: this.sName,
|
|
|
+ oid: this.oid,
|
|
|
+ ph: this.sPhone,
|
|
|
+ sid: this.sId,
|
|
|
+ cid: this.sByClass.join(","),
|
|
|
+ org: this.org
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ console.log("params", params);
|
|
|
+
|
|
|
+ this.ajax
|
|
|
+ .post(this.$store.state.api + "batchRegistrationOrg", params)
|
|
|
+ .then(res => {
|
|
|
+ this.$message({
|
|
|
+ message: "新增成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.sPhone = "";
|
|
|
+ this.sName = "";
|
|
|
+ // this.sBySchool = [];
|
|
|
+ this.sByClass = [];
|
|
|
+ this.sMail = "";
|
|
|
+ this.getStudent();
|
|
|
+ this.addOp3("1", "", { type: "student_user_add" }, "success");
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ this.isLoading = false;
|
|
|
+ this.addOp3("1", "", { type: "student_user_add" }, err);
|
|
|
+
|
|
|
+ this.$message({
|
|
|
+ message: "新增失败",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 控制添加学生分页
|
|
|
+ handleCurrentChange3(val) {
|
|
|
+ this.page3 = val;
|
|
|
+ this.getClassStudent();
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // 修改,编辑学生弹框(班级视图的与学生视图的学生编辑修改共用一个修改函数)
|
|
|
+ // 打开编辑学生弹框
|
|
|
+ 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.username === "") {
|
|
|
+ this.$message.error("学生姓名不能为空");
|
|
|
+ return;
|
|
|
+ } else if (!this.userinfo.classid) {
|
|
|
+ this.$message.error("请为学生选择班级");
|
|
|
+ return;
|
|
|
+ } else if (
|
|
|
+ !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
|
|
|
+ this.userinfo.acc
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ this.$message.error("邮箱格式不正确");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.time()) {
|
|
|
+ if (this.userinfoA.acc != this.userinfo.acc) {
|
|
|
+ let params = { un: this.userinfo.acc };
|
|
|
+ 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.acc,
|
|
|
+ alias: this.userinfo.username,
|
|
|
+ ph: this.userinfo.phonenumber,
|
|
|
+ sid: this.userinfo.studentid,
|
|
|
+ cid: this.userinfo.classid.join(",")
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ console.log("params", params);
|
|
|
+
|
|
|
+ this.ajax
|
|
|
+ .post(this.$store.state.api + "updateStudentInfo", params)
|
|
|
+ .then(res => {
|
|
|
+ this.$message({
|
|
|
+ message: "修改成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ this.dialogVisibleUpdate = false;
|
|
|
+ this.getStudent();
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ this.isLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: "修改失败",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 班级视图调用学生视图方法
|
|
|
+ // 将学生移除班级
|
|
|
+ deleteClassStudent(id) {
|
|
|
+ let params = [{ uid: id, cid: this.cidL }];
|
|
|
+ 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();
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.$message.error("操作失败");
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => { });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getUser();
|
|
|
+ this.getSchoolName();
|
|
|
+ this.getClass();
|
|
|
+ // this.getStudent();
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+.baseFlex {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 10px;
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
+.baseFlex > img {
|
|
|
+ /* width: 50px; */
|
|
|
+ height: 100%;
|
|
|
+ object-fit: cover;
|
|
|
+}
|
|
|
+.baseFlex > span {
|
|
|
+ color: #6b6b6b;
|
|
|
+ font-size: 14px;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+.fontlist {
|
|
|
+ border-radius: 10px;
|
|
|
+ overflow: auto;
|
|
|
+ background: #fff;
|
|
|
+ flex: 1;
|
|
|
+ min-height: 250px;
|
|
|
+}
|
|
|
+.listA {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ border-bottom: 1px #e7e7e7 solid;
|
|
|
+ height: 70px;
|
|
|
+ align-items: center;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 15px;
|
|
|
+ /* background: #fff; */
|
|
|
+}
|
|
|
+.fontPage {
|
|
|
+ height: 70px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: end;
|
|
|
+ align-content: center;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 15px 0;
|
|
|
+}
|
|
|
+.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;
|
|
|
+}
|
|
|
+.header-title {
|
|
|
+ display: flex;
|
|
|
+}
|
|
|
+
|
|
|
+.logoImg {
|
|
|
+ width: 30px;
|
|
|
+}
|
|
|
+
|
|
|
+.logoImg > img {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+.title_add_student {
|
|
|
+ margin: 0 auto;
|
|
|
+ color: #fff;
|
|
|
+}
|
|
|
+.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_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>
|