ソースを参照

新增教师页面

zengyicheng 2 年 前
コミット
29bf273d2b
1 ファイル変更95 行追加34 行削除
  1. 95 34
      src/components/pages/tencent/teacher.vue

+ 95 - 34
src/components/pages/tencent/teacher.vue

@@ -28,6 +28,7 @@
             placeholder="请选择学校"
             class="student_input inputClass"
             @change="searchStudent"
+            v-if="org && org != 'undefined' && org != 'null'"
           >
             <el-option label="所有学校" value=""></el-option>
             <el-option
@@ -98,7 +99,7 @@
                     text-overflow: ellipsis;
                   "
                 >
-                  {{ scope.row.name }}
+                  {{ scope.row.username }}
                 </div>
               </div>
             </template>
@@ -139,18 +140,19 @@
       </div>
     </div>
     <el-dialog
+      title="添加教师"
       :visible.sync="dialogVisible"
       :append-to-body="true"
       width="700px"
       :before-close="handleClose"
       class="add_student"
     >
-      <div slot="title" class="header-title">
+      <!-- <div slot="title" class="header-title">
         <div class="logoImg">
           <img src="../../../assets/logo.png" alt />
         </div>
         <div class="title_add_student">添加教师</div>
-      </div>
+      </div> -->
       <el-form class="inputClass">
         <el-form-item label="教师名称" :label-width="formLabelWidth">
           <span>
@@ -172,12 +174,22 @@
             ></el-input>
           </span>
         </el-form-item>
-        <el-form-item label="所属学校" :label-width="formLabelWidth">
-          <el-select
-            v-model="schoolName"
-            placeholder="请选择学校"
-            @change="checkEva"
-          >
+        <el-form-item
+          label="所属学校"
+          :label-width="formLabelWidth"
+          v-if="org && org != 'undefined' && org != 'null'"
+        >
+          <el-select v-model="schoolName" placeholder="请选择学校">
+            <el-option
+              v-for="(item, index) in classJuri"
+              :key="index"
+              :label="item.name"
+              :value="item.id"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="所属学校" :label-width="formLabelWidth" v-else>
+          <el-select v-model="oidName.name" disabled>
             <el-option
               v-for="(item, index) in classJuri"
               :key="index"
@@ -215,12 +227,13 @@ export default {
       schoolJuri: [],
       classJuri: [],
       fileListUpload: [],
+      oidName: [],
       page: 1,
       total: 0,
       sPhoneUser: "",
       userid: this.$route.query.userid,
       oid: this.$route.query.oid,
-      cid: '',
+      cid: "",
       org: this.$route.query.org,
       tx: require("../../../assets/avatar.png"),
     };
@@ -258,7 +271,11 @@ export default {
     addStudent() {
       this.dialogVisible = true;
       (this.sName = ""), (this.sMail = ""), (this.schoolName = "");
-      this.getClass();
+      if (this.org && this.org != "undefined" && this.org != "null") {
+        this.getClass();
+      } else {
+        this.getOidName();
+      }
       // this.getSchool();
     },
     handleClose(done) {
@@ -295,21 +312,41 @@ export default {
     //新增学生
     insertStudent() {
       this.dialogVisible = true;
-      if (this.sName === "") {
-        this.$message.error("教师昵称不能为空");
-        return;
-      } else if (this.sMail === "") {
-        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;
-      }else if(this.schoolName === ""){
-        this.$message.error("请选择学校");
-        return;
+      if (this.org && this.org != "undefined" && this.org != "null") {
+        if (this.sName === "") {
+          this.$message.error("教师昵称不能为空");
+          return;
+        } else if (this.sMail === "") {
+          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;
+        } else if (this.schoolName === "") {
+          this.$message.error("请选择学校");
+          return;
+        }
+      } else {
+        if (this.sName === "") {
+          this.$message.error("教师昵称不能为空");
+          return;
+        } else if (this.sMail === "") {
+          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
@@ -332,11 +369,11 @@ export default {
           username: this.sMail,
           userpassword: 123456,
           alias: this.sName,
-          org:this.org,
-          oid: this.schoolName,
+          org: this.org && this.org != "undefined" && this.org != "null" ? this.org : '',
+          oid: this.org && this.org != "undefined" && this.org != "null" ? this.schoolName : this.oid,
           ph: this.sPhone,
           sid: this.sId,
-          cid: '',
+          cid: "",
         },
       ];
       this.ajax
@@ -349,10 +386,10 @@ export default {
               username: this.sName,
               sid: this.sId,
               type: 1,
-              org:this.org,
+              org: this.org,
               oid: res.data.oid,
               phone: res.data.ph,
-              cid: '',
+              cid: "",
               intro: "",
               sex: "0",
             },
@@ -401,6 +438,23 @@ export default {
           console.error(err);
         });
     },
+    //获取学校名称
+    getOidName() {
+      this.isLoading = true;
+      let params = {
+        oid: this.oid,
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectSchoolName2", params)
+        .then((res) => {
+          this.isLoading = false;
+          this.oidName = res.data[0][0];
+        })
+        .catch((err) => {
+          this.isLoading = false;
+          console.error(err);
+        });
+    },
     // getSchool() {
     // 	this.isLoading = true;
     // 	let params = {
@@ -420,13 +474,20 @@ export default {
     getStudent() {
       this.isLoading = true;
       let params = {
-        org: this.org,
+        org:
+          this.org && this.org != "undefined" && this.org != "null"
+            ? this.org
+            : "",
+        oid:
+          this.org && this.org != "undefined" && this.org != "null"
+            ? ""
+            : this.oid,
         cu: this.cid,
         cn: this.sPhoneUser,
         page: this.page,
       };
       this.ajax
-        .get(this.$store.state.api + "selectTeacher", params)
+        .get(this.$store.state.api + "selectTcTeacher", params)
         .then((res) => {
           this.isLoading = false;
           this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
@@ -572,7 +633,7 @@ export default {
             } else if (item.mail === "") {
               _b = 1;
               _this.$message.error("教师邮箱不能为空,请重新上传");
-            }else if (
+            } else if (
               !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
                 item.mail
               )
@@ -588,7 +649,7 @@ export default {
             {
               arr: newArr,
               userpassword: 123456,
-              org: _this.org,
+              org: _this.org && _this.org != "undefined" && _this.org != "null" ? _this.org : '',
             },
           ];
           _this.ajax