浏览代码

新增选择题题目上传图片功能及学生初始化密码功能

zengyicheng 2 年之前
父节点
当前提交
af0e84dc28
共有 3 个文件被更改,包括 885 次插入384 次删除
  1. 二进制
      src/assets/autorUp.png
  2. 639 310
      src/components/pages/addCourse.vue
  3. 246 74
      src/components/pages/student.vue

二进制
src/assets/autorUp.png


文件差异内容过多而无法显示
+ 639 - 310
src/components/pages/addCourse.vue


+ 246 - 74
src/components/pages/student.vue

@@ -1,29 +1,57 @@
 <template>
   <div class="pb_content" style="background: unset">
-    <div class="pb_content_body" style="
+    <div
+      class="pb_content_body"
+      style="
         background: #fff;
         padding: 0px 25px;
         box-sizing: border-box;
         border-radius: 5px;
-      ">
+      "
+    >
       <div class="pb_head">
         <span>学生管理</span>
       </div>
       <div class="student_head">
         <div class="head_left">
-          <el-input v-model="sPhoneUser" class="student_input" placeholder="请输入用户名"></el-input>
-          <el-select v-model="cid" placeholder="请选择班级" class="student_input" @change="searchStudent">
+          <el-input
+            v-model="sPhoneUser"
+            class="student_input"
+            placeholder="请输入用户名"
+          ></el-input>
+          <el-select
+            v-model="cid"
+            placeholder="请选择班级"
+            class="student_input"
+            @change="searchStudent"
+          >
             <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-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>
+          <el-button class="student_button" @click="searchStudent"
+            >查询</el-button
+          >
         </div>
         <div class="head_right">
           <el-button @click="addStudent">添加学生</el-button>
-          <el-upload v-show="false" class="upload-demo newCss" :http-request="handleChange" :on-remove="handleRemove" action="#"
-            :file-list="fileListUpload" accept=".xlsx">
+          <el-upload
+            v-show="false"
+            class="upload-demo newCss"
+            :http-request="handleChange"
+            :on-remove="handleRemove"
+            action="#"
+            :file-list="fileListUpload"
+            accept=".xlsx"
+          >
             <el-button size="primary" type="primary">批量添加</el-button>
-            <div slot="tip" class="el-upload__tip" style="margin-left:10px;">只能上传xlsx文件,且不超过500kb</div>
+            <div slot="tip" class="el-upload__tip" style="margin-left: 10px">
+              只能上传xlsx文件,且不超过500kb
+            </div>
           </el-upload>
           <!-- <el-button @click="exportExcel">导出学生</el-button> -->
           <div @click="getExcel" v-show="false">xls 上传样例</div>
@@ -32,26 +60,41 @@
     </div>
     <div class="pb_content_body">
       <div class="student_table">
-        <el-table ref="table" :data="tableData" border :height="tableHeight" :fit="true" v-loading="isLoading"
-          style="width: 100%" :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
-          :row-class-name="tableRowClassName">
+        <el-table
+          ref="table"
+          :data="tableData"
+          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 />
+                  <img
+                    :src="
+                      scope.row.headportrait != null
+                        ? scope.row.headportrait
+                        : tx
+                    "
+                    alt
+                  />
                 </div>
-                <div style="
+                <div
+                  style="
                     width: 150px;
                     text-align: left;
                     white-space: nowrap;
                     overflow: hidden;
                     text-overflow: ellipsis;
-                  ">{{ scope.row.name }}</div>
+                  "
+                >
+                  {{ scope.row.name }}
+                </div>
               </div>
             </template>
           </el-table-column>
@@ -73,15 +116,41 @@
             align="center"
           >
           </el-table-column>-->
-          <el-table-column prop="classname2" label="班级" min-width="15" align="center">
+          <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="updateStudentA(scope.row)">修改</el-button>
+                <el-button
+                  class="de_button"
+                  type="primary"
+                  size="small"
+                  style="
+                    width: auto;
+                    padding: 5px !important;
+                    line-height: 15px;
+                  "
+                  @click="iniPassword(scope.row.userid)"
+                  >初始化密码</el-button
+                >
+                <el-button
+                  class="de_button"
+                  type="primary"
+                  size="small"
+                  @click="updateStudentA(scope.row)"
+                  >修改</el-button
+                >
                 <div class="delete">
-                  <img src="../../assets/remove.png" alt @click="deleteStudent(scope.row.userid, scope.row.state)" />
+                  <img
+                    src="../../assets/remove.png"
+                    alt
+                    @click="deleteStudent(scope.row.userid, scope.row.state)"
+                  />
                 </div>
               </div>
             </template>
@@ -89,12 +158,23 @@
         </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>
+        <el-pagination
+          background
+          layout="prev, pager, next"
+          :page-size="10"
+          :total="total"
+          v-if="page"
+          @current-change="handleCurrentChange"
+        ></el-pagination>
       </div>
     </div>
-    <el-dialog :visible.sync="dialogVisible" :append-to-body="true" width="700px" :before-close="handleClose"
-      class="add_student">
+    <el-dialog
+      :visible.sync="dialogVisible"
+      :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 />
@@ -104,40 +184,76 @@
       <el-form>
         <el-form-item label="学生姓名" :label-width="formLabelWidth">
           <span>
-            <el-input placeholder="请输入学生姓名" clearable v-model="sName" class="add_input"></el-input>
+            <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>
+            <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>
+            <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>
+            <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-input
+            disabled
+            style="width: 300px"
+            v-model="schoolName"
+          ></el-input>
         </el-form-item>
         <el-form-item label="班级" :label-width="formLabelWidth">
           <el-select v-model="sByClass" placeholder="请选择班级">
-            <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
+            <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>
+        <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">
+    <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 />
@@ -147,33 +263,64 @@
       <el-form>
         <el-form-item label="学生名称" :label-width="formLabelWidth">
           <span>
-            <el-input placeholder="请输入学生姓名" clearable v-model="userinfo.name" class="add_input"></el-input>
+            <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>
+            <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>
+            <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>
+            <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-input
+            disabled
+            style="width: 300px"
+            v-model="schoolName"
+          ></el-input>
         </el-form-item>
         <el-form-item label="班级" :label-width="formLabelWidth">
           <el-select v-model="userinfo.classid" placeholder="请选择班级">
-            <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
+            <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>
+        <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>
@@ -212,7 +359,7 @@ export default {
       sPhoneUser: "",
       userid: this.$route.query.userid,
       oid: this.$route.query.oid,
-      cid: '',
+      cid: "",
       tx: require("../../assets/avatar.png"),
     };
   },
@@ -248,7 +395,7 @@ export default {
     },
     addStudent() {
       this.dialogVisible = true;
-      (this.sName = ""), (this.sPhone = ""), (this.sByClass = ""),(this.sMail);
+      (this.sName = ""), (this.sPhone = ""), (this.sByClass = ""), this.sMail;
       this.getClass();
       // this.getSchool();
     },
@@ -290,7 +437,10 @@ export default {
       } else if (this.sByClass === "") {
         this.$message.error("请为学生选择班级");
         return;
-      } else if (this.sPhone != "" && !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.sPhone)) {
+      } else if (
+        this.sPhone != "" &&
+        !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.sPhone)
+      ) {
         this.$message.error("手机号格式不正确");
         return;
       } else if (
@@ -467,7 +617,7 @@ export default {
       if (this.fileTemp) {
         if (
           this.fileTemp.type ==
-          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
+            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
           this.fileTemp.type == "application/vnd.ms-excel"
         ) {
           this.importCount = 1;
@@ -941,7 +1091,26 @@ export default {
               console.error(err);
             });
         })
-        .catch(() => { });
+        .catch(() => {});
+    },
+    iniPassword(id) {
+      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);
+        });
     },
     updateStudentA(res) {
       this.userinfo = JSON.parse(JSON.stringify(res));
@@ -955,17 +1124,21 @@ export default {
       } 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)) {
+      } 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)
+        !/^([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 };
@@ -981,10 +1154,9 @@ export default {
             .catch((err) => {
               console.error(err);
             });
-        }else{
+        } else {
           this.update_Student();
         }
-
       }
     },
     update_Student() {
@@ -1028,7 +1200,7 @@ export default {
 </script>
 
 <style scoped>
-.pb_head>span:nth-child(2) {
+.pb_head > span:nth-child(2) {
   font-size: 20px;
   margin-left: 5px;
   color: #828282;
@@ -1062,7 +1234,7 @@ export default {
   align-items: baseline;
 }
 
-.student_input>>>.el-input__inner {
+.student_input >>> .el-input__inner {
   height: 30px;
   width: 190px;
   font-size: 13px;
@@ -1079,7 +1251,7 @@ export default {
   line-height: 30px;
 }
 
-.head_right>button:nth-child(1) {
+.head_right > button:nth-child(1) {
   color: #fff;
   background: #2268bc;
   width: 70px;
@@ -1089,7 +1261,7 @@ export default {
   line-height: 30px;
 }
 
-.head_right>button:nth-child(2) {
+.head_right > button:nth-child(2) {
   color: #fff;
   background: #2268bc;
   width: 70px;
@@ -1099,7 +1271,7 @@ export default {
   line-height: 30px;
 }
 
-.head_right>div {
+.head_right > div {
   font-size: 12px;
   line-height: 40px;
   margin-left: 10px;
@@ -1108,16 +1280,16 @@ export default {
   cursor: pointer;
 }
 
-.student_table>>>.el-table--border td {
+.student_table >>> .el-table--border td {
   border-right: 0px !important;
 }
 
-.student_table>>>.el-table,
-.student_table>>>.el-table__body-wrapper {
+.student_table >>> .el-table,
+.student_table >>> .el-table__body-wrapper {
   height: auto !important;
 }
 
-.el-table>>>.even_row {
+.el-table >>> .even_row {
   background-color: #f1f1f1 !important;
 }
 
@@ -1131,30 +1303,30 @@ export default {
   line-height: 25px;
 }
 
-.add_student>>>.el-dialog__header {
+.add_student >>> .el-dialog__header {
   padding: 20px 20px 10px;
   text-align: center;
   background: #32455b;
 }
 
-.add_student>>>.el-dialog__title {
+.add_student >>> .el-dialog__title {
   font-size: 14px !important;
   color: #fff !important;
 }
 
-.add_student>>>.el-dialog__headerbtn {
+.add_student >>> .el-dialog__headerbtn {
   font-size: 20px !important;
 }
 
-.add_student>>>.el-form-item__label {
+.add_student >>> .el-form-item__label {
   margin-left: 65px;
 }
 
-.add_student>>>.el-form-item {
+.add_student >>> .el-form-item {
   display: flex;
 }
 
-.add_student>>>.el-form-item__content {
+.add_student >>> .el-form-item__content {
   margin: 0 !important;
 }
 
@@ -1162,7 +1334,7 @@ export default {
   width: 365px;
 }
 
-.add_student>>>.el-dialog__footer {
+.add_student >>> .el-dialog__footer {
   text-align: center !important;
 }
 
@@ -1181,7 +1353,7 @@ export default {
   width: 30px;
 }
 
-.logoImg>img {
+.logoImg > img {
   width: 100%;
   height: 100%;
 }
@@ -1195,7 +1367,7 @@ export default {
   line-height: 0px !important;
 }
 
-.upload-demo>>>.el-button {
+.upload-demo >>> .el-button {
   color: #fff;
   background: #2268bc;
   width: 70px;
@@ -1224,8 +1396,8 @@ export default {
   margin-left: 10px;
 }
 
-.tx>img,
-.delete>img {
+.tx > img,
+.delete > img {
   width: 100%;
   height: 100%;
 }
@@ -1245,7 +1417,7 @@ export default {
   margin-right: 10px;
 }
 
-.student_input>>>.el-input__icon {
+.student_input >>> .el-input__icon {
   line-height: unset;
 }
 

部分文件因为文件数量过多而无法显示