| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166 |
- <template>
- <div
- class="pb_content"
- style="background: unset; height: 100%; overflow: auto"
- >
- <div
- class="pb_content_body"
- style="
- background: #fff;
- padding: 0px 25px;
- box-sizing: border-box;
- margin: 10px auto 0;
- /* 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 inputClass"
- @change="searchStudent"
- v-if="org && org != 'undefined' && org != 'null'"
- >
- <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>
- <el-upload
- 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>
- </el-upload>
- <!-- <el-button @click="exportExcel">导出学生</el-button> -->
- <div @click="getExcel">xls 上传样例</div>
- </div>
- </div>
- </div>
- <div class="pb_content_body" style="margin: 0 auto">
- <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-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.username }}
- </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 label="身份" min-width="15" align="center">
- <template slot-scope="scope">
- <div>{{ scope.row.role ? '管理员' : "普通教师" }}</div>
- </template>
- </el-table-column>
- <el-table-column
- prop="schoolName"
- label="学校"
- min-width="15"
- align="center"
- >
- </el-table-column>
- <el-table-column label="操作" width="220px">
- <template slot-scope="scope">
- <div style="display: flex;">
- <el-button
- size="mini"
- type="primary"
- @click="modifyDiaBtn(scope.row)"
- >修改</el-button
- >
- <div
- class="delete"
- @click="deleteStudent(scope.row.userid, scope.row.state)"
- >
- <img src="../../../assets/remove.png" alt />
- </div>
- </div>
- </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>
- <el-dialog
- title="修改账号信息"
- :visible.sync="modifyDia"
- :append-to-body="true"
- width="700px"
- :before-close="handleClose"
- :close-on-click-modal="true"
- class="add_student"
- >
- <el-form class="inputClass">
- <el-form-item label="教师名称" :label-width="formLabelWidth">
- <span>
- <el-input
- placeholder="请输入教师姓名"
- clearable
- v-model.trim="modifyDiaData.dName"
- class="add_input"
- ></el-input>
- </span>
- </el-form-item>
- <el-form-item label="教师账号" :label-width="formLabelWidth">
- <span>
- <el-input
- placeholder="请输入教师姓名"
- clearable
- disabled
- v-model.trim="modifyDiaData.mail"
- class="add_input"
- ></el-input>
- </span>
- </el-form-item>
- <!-- <el-form-item label="手机号" :label-width="formLabelWidth">
- <span>
- <el-input
- placeholder="请输入手机号"
- clearable
- disabled
- v-model="modifyDiaData.tel"
- class="add_input"
- ></el-input>
- </span>
- </el-form-item> -->
- <el-form-item
- label="角色"
- :label-width="formLabelWidth"
- v-if="org && org != 'undefined' && org != 'null'"
- >
- <template>
- <el-radio v-model="modifyDiaData.radio" :label="0">管理员</el-radio>
- <el-radio v-model="modifyDiaData.radio" :label="1"
- >普通教师</el-radio
- >
- </template>
- </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"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item> -->
- </el-form>
- <span slot="footer" class="dialog-footer flex">
- <el-button class="right" @click="conModify">确认</el-button>
- </span>
- </el-dialog>
- <el-dialog
- title="添加教师"
- :visible.sync="dialogVisible"
- :append-to-body="true"
- width="700px"
- :before-close="handleClose"
- :close-on-click-modal="true"
- 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 class="inputClass">
- <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="sMail"
- class="add_input"
- ></el-input>
- </span>
- </el-form-item>
- <el-form-item label="教师账号" :label-width="formLabelWidth">
- <span>
- <template>
- <el-radio v-model="addRadio" :label="0">管理员</el-radio>
- <el-radio v-model="addRadio" :label="1">普通教师</el-radio>
- </template>
- </span>
- </el-form-item>
- <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"
- :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>
- </div>
- </template>
- <script>
- import $ from "jquery";
- // import pinyin from "../../../../node_modules/js-pinyin/index";
- export default {
- data() {
- return {
- tableHeight: "500px",
- isLoading: false,
- formLabelWidth: "100px",
- tableData: [],
- dialogVisible: false,
- modifyDia: false,
- modifyDiaData: {
- userid: "",
- mail: "",
- dName: "",
- tel: "",
- radio: 0,
- type: 1,
- role: 0
- },
- sName: "",
- sMail: "",
- addPol: "",
- addTyp: 0,
- addRadio: 1,
- sId: "",
- schoolName: "",
- schoolJuri: [],
- classJuri: [],
- fileListUpload: [],
- oidName: [],
- page: 1,
- total: 0,
- sPhoneUser: "",
- userid: this.$route.query.userid,
- oid: this.$route.query.oid,
- cid: "",
- org: this.$route.query.org,
- tx: require("../../../assets/avatar.png"),
- userSuffix: ""
- };
- },
- mounted() {
- this.$nextTick(function() {
- this.getUser()
- 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: {
- getUser() {
-
- let params = {
- userid: this.userid
- };
- // console.log(111,params);
- this.ajax
- .get(this.$store.state.api + "selectUser", params)
- .then(res => {
- // console.log(res);
- this.userSuffix = res.data[0][0].accountNumber.split("@")[1];
- // console.log(this.userSuffix);
- })
- .catch(err => {
- console.error(err);
- });
- },
- // 确定修改信息
- conModify() {
- if (!this.modifyDiaData.dName) {
- this.$message({
- message: "教师名称不能为空",
- type: "error"
- });
- return;
- }
- let uRole = null;
- let uType = 1;
- if (!this.modifyDiaData.radio) {
- uRole = 1;
- } else {
- uRole = 0;
- }
- let params = [
- {
- uid: this.modifyDiaData.userid,
- uname: this.modifyDiaData.dName,
- rol: uRole,
- typ: uType
- }
- ];
- this.ajax
- .post(this.$store.state.api + "updateYTeacherInfo", params)
- .then(res => {
- this.$message({
- message: "修改成功",
- type: "success"
- });
- this.modifyDia = false;
- this.getStudent();
- })
- .catch(err => {
- this.isLoading = false;
- this.$message({
- message: "修改失败",
- type: "error"
- });
- console.error(err);
- });
- // return console.log(data);
- // this.
- },
- // 修改用户信息弹窗
- modifyDiaBtn(val) {
- // console.log(val);
- this.modifyDiaData.userid = val.userid;
- this.modifyDiaData.dName = val.username;
- this.modifyDiaData.tel = "";
- this.modifyDiaData.role = val.role;
- this.modifyDiaData.type = val.type;
- this.modifyDiaData.mail = val.un;
- if (val.role == 1) {
- this.modifyDiaData.radio = 0;
- } else {
- this.modifyDiaData.radio = 1;
- }
- this.modifyDia = true;
- },
- tableRowClassName({ row, rowIndex }) {
- if ((rowIndex + 1) % 2 === 0) {
- return "even_row";
- } else {
- return "";
- }
- },
- searchStudent() {
- this.page = 1;
- this.getStudent();
- },
- addStudent() {
- this.dialogVisible = true;
- (this.sName = ""), (this.sMail = ""), (this.schoolName = "");
- if (this.org && this.org != "undefined" && this.org != "null") {
- this.getClass();
- } else {
- this.getOidName();
- }
- // this.getSchool();
- },
- handleClose(done) {
- done();
- },
- getExcel(res) {
- require.ensure([], () => {
- const {
- export_json_to_excel
- } = require("../../../common/Export2Excel");
- const tHeader = ["教师姓名", "教师账号", "学校"];
- const data = [];
- export_json_to_excel(tHeader, data, "上传教师样例");
- });
- },
- handleCurrentChange(val) {
- this.page = val;
- this.getStudent();
- },
- 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;
- }
- }
- },
- //新增学生
- insertStudent() {
- this.dialogVisible = true;
- 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 (this.schoolName === "") {
- this.$message.error("请选择学校");
- return;
- }
- // else if (
- // // !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
- // // this.sMail
- // // )
- // this.sMail === ""
- // ) {
- // this.$message.error("学生账号不能为空");
- // // 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.sMail === ""
- // ) {
- // this.$message.error("学生账号不能为空");
- // // 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{
- mail = this.sMail + "@" + this.userSuffix
- }
-
- if (this.time()) {
- // let params = { un: this.sMail };
- let params = { un: mail};
- // console.log('mail',mail,this.userSuffix);
- 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 AddT = 1;
- let addR = 0;
- if (!this.addRadio) {
- addR = 1;
- } else {
- addR = 0;
- }
- let mail = '';
- if(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.sMail)){
- mail = this.sMail;
- }else{
- mail = this.sMail + "@" + this.userSuffix
- }
- let params = [
- {
- username: mail,
- userpassword: 123456,
- alias: this.sName,
- 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: "",
- typ: AddT,
- rol: addR
- }
- ];
- // return console.log('params:',params);
- this.ajax
- .post(this.$store.state.api + "teacherRegistration", params)
- .then(res => {
- // debugger;
- // let params = [
- // {
- // userid: res.data.uid,
- // username: this.sName,
- // sid: this.sId,
- // type: 1,
- // org: this.org,
- // oid: res.data.oid,
- // phone: res.data.ph,
- // cid: "",
- // intro: "",
- // sex: "0"
- // }
- // ];
- // this.ajax
- // .post(this.$store.state.api + "updateUserByEdu1", params)
- // .then(res => {
- // console.log(res);
- // })
- // .catch(err => {
- // console.error(err);
- // });
- this.$message({
- message: "新增成功",
- type: "success"
- });
- this.dialogVisible = false;
- this.sName = "";
- this.sMail = "";
- this.schoolName = "";
- this.getStudent();
- })
- .catch(err => {
- this.isLoading = false;
- this.$message({
- message: "新增失败",
- type: "error"
- });
- console.error(err);
- });
- },
- //获取班级列表
- getClass() {
- this.isLoading = true;
- let params = {
- org: this.org
- };
- this.ajax
- .get(this.$store.state.api + "selectSchoolByOrg", params)
- .then(res => {
- this.isLoading = false;
- this.classJuri = res.data[0];
- })
- .catch(err => {
- this.isLoading = false;
- 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 = {
- // page: this.page,
- // };
- // this.ajax
- // .get(this.$store.state.api + "selectOrg", params)
- // .then((res) => {
- // this.isLoading = false;
- // this.schoolJuri = res.data[0];
- // })
- // .catch((err) => {
- // this.isLoading = false;
- // console.error(err);
- // });
- // },
- getStudent() {
- this.isLoading = true;
- let params = {
- 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 + "selectOrgTeachar", params)
- .then(res => {
- this.isLoading = false;
- this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
- this.tableData = res.data[0];
- // console.log("this.tableData", this.tableData);
- })
- .catch(err => {
- this.isLoading = false;
- console.error(err);
- });
- },
- handleChange(file) {
- this.fileTemp = file.file;
- if (this.fileTemp) {
- if (
- this.fileTemp.type ==
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
- this.fileTemp.type == "application/vnd.ms-excel"
- ) {
- this.importCount = 1;
- this.importfxx(this.fileTemp);
- } else {
- this.$message({
- type: "warning",
- message: "附件格式错误,请删除后重新上传!"
- });
- }
- } else {
- this.$message({
- type: "warning",
- message: "请上传附件!"
- });
- }
- },
- handleRemove(file, fileList) {
- this.fileTemp = null;
- },
- exportExcel() {
- try {
- let params = {
- oid: this.oid
- };
- this.ajax
- .get(this.$store.state.api + "selectUserBySchool", params)
- .then(res => {
- var res = res.data[0];
- //如果value的json字段的key值和想要的headers值不一致时,可做如下更改
- //将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
- var array = [];
- for (var i = 0; i < res.length; i++) {
- var _json = {};
- _json["用户名"] = res[i].username;
- _json["姓名"] = res[i].alias ? res[i].alias : "";
- _json["班级"] = res[i].classid ? res[i].classid : "";
- array.push(_json);
- }
- var XLSX = require("xlsx");
- const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
- let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
- ws["!cols"] = [
- //设置每一列的宽度
- { wch: 50 },
- { wch: 50 },
- { wch: 50 }
- ];
- XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
- XLSX.writeFile(workbook, "学生信息.xlsx");
- // const wopts = { bookType: "xlsx", bookSST: false, type: "array" };//写入的样式bookType:输出的文件类型,type:输出的数据类型,bookSST: 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
- // const wbout = XLSX.write(workbook, wopts);// 浏览器端和node共有的API,实际上node可以直接使用xlsx.writeFile来写入文件,但是浏览器没有该API
- // FileSaver.saveAs(new Blob([wbout], { type: "application/octet-stream" }), `${title} demo.xlsx`);//保存文件
- this.$message({
- message: "导出成功",
- type: "success"
- });
- })
- .catch(err => {
- console.error(err);
- });
- } catch (e) {
- console.log(e, e.stack);
- }
- },
- importfxx(obj) {
- const loading = this.$loading.service({
- background: "rgba(255, 255, 255, 0.7)",
- target: document.body
- });
- var _$ = $;
- this.importCount++;
- let _this = this;
- // 通过DOM取文件数据
- this.file = obj;
- var rABS = false; //是否将文件读取为二进制字符串
- var f = this.file;
- var reader = new FileReader();
- //if (!FileReader.prototype.readAsBinaryString) {
- FileReader.prototype.readAsBinaryString = function(f) {
- var binary = "";
- var rABS = false; //是否将文件读取为二进制字符串
- var pt = this;
- var wb; //读取完成的数据
- var outdata;
- var reader = new FileReader();
- reader.onload = function(e) {
- var bytes = new Uint8Array(reader.result);
- var length = bytes.byteLength;
- for (var i = 0; i < length; i++) {
- binary += String.fromCharCode(bytes[i]);
- }
- var XLSX = require("xlsx");
- if (rABS) {
- wb = XLSX.read(btoa(fixdata(binary)), {
- //手动转化
- type: "base64"
- });
- } else {
- wb = XLSX.read(binary, {
- type: "binary"
- });
- }
- outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]); //outdata就是你想要的东西
- this.da = [...outdata];
- let arr = [];
- this.da.map(v => {
- let obj = {};
- obj.name = v["教师姓名"];
- obj.mail = v["教师账号"];
- obj.school = v["学校"];
- arr.push(obj);
- });
- console.log(arr);
- let _b = 1;
- for (var i = 0; i < arr.length; i++) {
- let item = arr[i];
- if (item.school === "") {
- _b = 1;
- _this.$message.error("教师学校不能为空,请重新上传");
- break;
- } else if (item.name === "") {
- _b = 1;
- _this.$message.error("教师姓名不能为空,请重新上传");
- break;
- } else if (item.mail === "") {
- _b = 1;
- _this.$message.error("教师账号不能为空,请重新上传");
- } else if (
- !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
- item.mail
- )
- ) {
- _b = 1;
- _this.$message.error("有教师账号格式不正确,请重新上传");
- break;
- }
- }
- let z = 2;
- let newArr = JSON.stringify(arr);
- let params = [
- {
- arr: newArr,
- userpassword: 123456,
- org:
- _this.org && _this.org != "undefined" && _this.org != "null"
- ? _this.org
- : ""
- }
- ];
- _this.ajax
- .post(_this.$store.state.api + "batchRegistrationMore1", params)
- .then(res => {
- if (z == 2) {
- _this.$message({
- message: "新增成功",
- type: "success"
- });
- _this.getStudent();
- }
- loading.close();
- })
- .catch(err => {
- console.error(err);
- });
- _this.fileListUpload = [];
- };
- reader.readAsArrayBuffer(f);
- };
- if (rABS) {
- reader.readAsArrayBuffer(f);
- } else {
- reader.readAsBinaryString(f);
- }
- },
- 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);
- });
- },
- 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(() => {});
- }
- },
- created() {
- this.page = 1;
- this.getStudent();
- this.getSchoolName();
- this.getClass();
- }
- };
- </script>
- <style scoped>
- @media screen and (max-width: 1024px) {
- .student_head {
- flex-direction: column !important;
- }
- .head_right {
- margin-top: 10px !important;
- }
- }
- .pb_head > span:nth-child(2) {
- font-size: 20px;
- margin-left: 5px;
- color: #828282;
- }
- .pb_head {
- margin: 0 !important;
- width: 100% !important;
- }
- .student_page {
- margin-top: 10px;
- }
- .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 {
- height: 30px;
- width: 190px;
- font-size: 13px;
- padding: 0 10px;
- }
- .student_button {
- color: #fff;
- background: #2268bc;
- width: 60px;
- height: 30px;
- padding: 0 !important;
- font-size: 12px;
- line-height: 30px;
- }
- .head_right > button:nth-child(1) {
- color: #fff;
- background: #2268bc;
- width: 70px;
- height: 30px;
- padding: 0 !important;
- font-size: 12px;
- line-height: 30px;
- }
- .head_right > button:nth-child(2) {
- color: #fff;
- background: #2268bc;
- width: 70px;
- height: 30px;
- padding: 0 !important;
- font-size: 12px;
- line-height: 30px;
- }
- .head_right > div {
- font-size: 12px;
- line-height: 40px;
- margin-left: 10px;
- color: #2a6dbe;
- text-decoration: underline;
- cursor: pointer;
- }
- .student_table >>> .el-table--border td {
- border-right: 0px !important;
- }
- .student_table >>> .el-table,
- .student_table >>> .el-table__body-wrapper {
- height: auto !important;
- }
- .el-table >>> .even_row {
- background-color: #f1f1f1 !important;
- }
- .de_button {
- color: #fff;
- background: #5190fd;
- width: 50px;
- height: 25px;
- padding: 0 !important;
- font-size: 12px;
- line-height: 25px;
- }
- .add_student >>> .el-dialog__header {
- padding: 20px 20px 10px;
- text-align: center;
- background: #454545;
- }
- .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: #2268bc;
- 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;
- }
- .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%;
- }
- .newCss {
- display: flex;
- flex-direction: row;
- flex-wrap: nowrap;
- align-items: baseline;
- }
- .student_input.el-input {
- width: auto;
- }
- .student_input {
- margin-right: 10px;
- }
- .student_input >>> .el-input__icon {
- line-height: unset;
- }
- </style>
|