studentGM.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. <template>
  2. <div class="pb_content" style="background: unset;height: 100%;overflow: auto;">
  3. <div
  4. class="pb_content_body"
  5. style="
  6. background: #fff;
  7. padding: 0px 25px;
  8. box-sizing: border-box;
  9. margin: 10px auto 0;
  10. /* border-radius: 5px; */
  11. "
  12. >
  13. <div class="pb_head">
  14. <span>我的学生列表</span>
  15. </div>
  16. <div class="student_head">
  17. <div class="head_left">
  18. <el-input v-model="sPhoneUser" class="student_input" placeholder="请输入用户名"></el-input>
  19. <el-select v-model="cid" placeholder="请选择班级" class="student_input inputClass" @change="searchStudent">
  20. <el-option label="所有人" value=""></el-option>
  21. <el-option
  22. v-for="(item, index) in classJuri"
  23. :key="index"
  24. :label="item.name"
  25. :value="item.id"
  26. ></el-option>
  27. </el-select>
  28. <el-button class="student_button" @click="searchStudent">查询</el-button>
  29. </div>
  30. <div class="head_right">
  31. <el-button @click="addStudent">添加学生</el-button>
  32. <el-upload
  33. class="upload-demo newCss"
  34. :http-request="handleChange"
  35. :on-remove="handleRemove"
  36. action="#"
  37. :file-list="fileListUpload"
  38. accept=".xlsx"
  39. >
  40. <el-button class="btnClassGM" size="primary" type="primary">批量添加</el-button>
  41. <div slot="tip" class="el-upload__tip" style="margin-left:10px;">只能上传xlsx文件,且不超过500kb</div>
  42. </el-upload>
  43. <!-- <el-button @click="exportExcel">导出学生</el-button> -->
  44. <div @click="getExcel">xls 上传样例</div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="pb_content_body" style="margin:0 auto">
  49. <div class="student_table">
  50. <el-table
  51. ref="table"
  52. :data="tableData"
  53. border
  54. :height="tableHeight"
  55. :fit="true"
  56. v-loading="isLoading"
  57. style="width: 100%"
  58. :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
  59. :row-class-name="tableRowClassName"
  60. >
  61. <el-table-column label="姓名" min-width="10" align="center">
  62. <template slot-scope="scope">
  63. <div class="userImg">
  64. <div class="tx">
  65. <img
  66. :src="
  67. scope.row.headportrait != null
  68. ? scope.row.headportrait
  69. : tx
  70. "
  71. alt
  72. />
  73. </div>
  74. <div
  75. style="
  76. width: 150px;
  77. text-align: left;
  78. white-space: nowrap;
  79. overflow: hidden;
  80. text-overflow: ellipsis;
  81. "
  82. >{{ scope.row.name }}</div>
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="账号" min-width="15" align="center">
  87. <template slot-scope="scope">
  88. <div>{{scope.row.un ? scope.row.un : "" }}</div>
  89. </template>
  90. </el-table-column>
  91. <!-- <el-table-column label="电话" min-width="15" align="center">
  92. <template slot-scope="scope">
  93. <div>{{scope.row.phonenumber ? scope.row.phonenumber : "" }}</div>
  94. </template>
  95. </el-table-column>
  96. <el-table-column prop="studentid" label="学号" min-width="10" align="center"></el-table-column> -->
  97. <!-- <el-table-column
  98. prop="school"
  99. label="学校"
  100. min-width="30"
  101. align="center"
  102. >
  103. </el-table-column>-->
  104. <el-table-column
  105. prop="classname2"
  106. label="班级"
  107. min-width="15"
  108. align="center"
  109. >
  110. </el-table-column>
  111. <el-table-column label="操作" width="220px">
  112. <template slot-scope="scope">
  113. <!-- <el-button
  114. class="de_button"
  115. type="primary"
  116. size="small"
  117. @click="deleteStudent(scope.row.userid, scope.row.state)"
  118. >删除</el-button
  119. >-->
  120. <div class="delete" @click="deleteStudent(scope.row.userid, scope.row.state)">
  121. <img src="../../assets/remove.png" alt />
  122. </div>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. <div class="student_page">
  128. <el-pagination
  129. background
  130. layout="prev, pager, next"
  131. :page-size="10"
  132. :total="total"
  133. v-if="page"
  134. @current-change="handleCurrentChange"
  135. ></el-pagination>
  136. </div>
  137. </div>
  138. <el-dialog
  139. :visible.sync="dialogVisible"
  140. :append-to-body="true"
  141. width="700px"
  142. :before-close="handleClose"
  143. class="add_student"
  144. >
  145. <div slot="title" class="header-title">
  146. <div class="logoImg">
  147. <img src="../../assets/logo.png" alt />
  148. </div>
  149. <div class="title_add_student">添加学生</div>
  150. </div>
  151. <el-form class="inputClass">
  152. <el-form-item label="学生名称" :label-width="formLabelWidth">
  153. <span>
  154. <el-input placeholder="请输入学生昵称" clearable v-model="sName" class="add_input"></el-input>
  155. </span>
  156. </el-form-item>
  157. <el-form-item label="学生学号" :label-width="formLabelWidth">
  158. <span>
  159. <el-input placeholder="请输入学生学号" clearable v-model="sId" class="add_input"></el-input>
  160. </span>
  161. </el-form-item>
  162. <el-form-item label="学生手机号" :label-width="formLabelWidth">
  163. <span>
  164. <el-input placeholder="请输入学生手机号" clearable v-model="sPhone" class="add_input"></el-input>
  165. </span>
  166. </el-form-item>
  167. <el-form-item label="学生邮箱" :label-width="formLabelWidth">
  168. <span>
  169. <el-input placeholder="请输入学生邮箱" clearable v-model="sMail" class="add_input"></el-input>
  170. </span>
  171. </el-form-item>
  172. <el-form-item label="所属学校" :label-width="formLabelWidth">
  173. <el-input disabled style="width: 300px" v-model="schoolName"></el-input>
  174. </el-form-item>
  175. <el-form-item label="班级" :label-width="formLabelWidth">
  176. <el-select v-model="sByClass" placeholder="请选择班级">
  177. <el-option
  178. v-for="(item, index) in classJuri"
  179. :key="index"
  180. :label="item.name"
  181. :value="item.id"
  182. ></el-option>
  183. </el-select>
  184. </el-form-item>
  185. <div style="text-align: center; color: #adb3b7">注:添加学生的账号密码为123456</div>
  186. </el-form>
  187. <span slot="footer" class="dialog-footer flex">
  188. <el-button class="right" @click="insertStudent">确认</el-button>
  189. </span>
  190. </el-dialog>
  191. </div>
  192. </template>
  193. <script>
  194. import $ from "jquery";
  195. import pinyin from "../../../node_modules/js-pinyin/index";
  196. export default {
  197. data() {
  198. return {
  199. tableHeight: "500px",
  200. isLoading: false,
  201. formLabelWidth: "100px",
  202. tableData: [],
  203. dialogVisible: false,
  204. sName: "",
  205. sPhone: "",
  206. sId: "",
  207. schoolName: "",
  208. // sBySchool: [],
  209. // sBySchoolName:"",
  210. sByClass: "",
  211. sMail: "",
  212. schoolJuri: [],
  213. classJuri: [],
  214. fileListUpload: [],
  215. page: 1,
  216. total: 0,
  217. sPhoneUser: "",
  218. userid: this.$route.query.userid,
  219. oid: this.$route.query.oid,
  220. org: this.$route.query.org,
  221. cid: '',
  222. tx: require("../../assets/avatar.png"),
  223. };
  224. },
  225. mounted() {
  226. this.$nextTick(function () {
  227. this.tableHeight =
  228. window.innerHeight - this.$refs.table.$el.offsetTop - 200;
  229. if (this.tableHeight <= 530) {
  230. this.tableHeight = 530;
  231. }
  232. // 监听窗口大小变化
  233. let self = this;
  234. window.onresize = function () {
  235. self.tableHeight =
  236. window.innerHeight - self.$refs.table.$el.offsetTop - 200;
  237. if (self.tableHeight <= 530) {
  238. self.tableHeight = 530;
  239. }
  240. };
  241. });
  242. },
  243. methods: {
  244. tableRowClassName({ row, rowIndex }) {
  245. if ((rowIndex + 1) % 2 === 0) {
  246. return "even_row";
  247. } else {
  248. return "";
  249. }
  250. },
  251. searchStudent() {
  252. this.page = 1;
  253. this.getStudent();
  254. },
  255. addStudent() {
  256. this.dialogVisible = true;
  257. (this.sName = ""), (this.sPhone = ""), (this.sByClass = "");
  258. this.getClass();
  259. // this.getSchool();
  260. },
  261. handleClose(done) {
  262. done();
  263. },
  264. getExcel(res) {
  265. require.ensure([], () => {
  266. const { export_json_to_excel } = require("../../common/Export2Excel");
  267. const tHeader = ["学号", "学生姓名", "学生邮箱", "学生手机号", "班级"];
  268. const data = [];
  269. export_json_to_excel(tHeader, data, "上传学生样例");
  270. });
  271. },
  272. handleCurrentChange(val) {
  273. this.page = val;
  274. this.getStudent();
  275. },
  276. time() {
  277. if (!this.now) {
  278. this.now = new Date().getTime();
  279. return true;
  280. } else {
  281. let time = new Date().getTime();
  282. if (time - this.now > 3000) {
  283. this.now = time;
  284. return true;
  285. } else {
  286. return false;
  287. }
  288. }
  289. },
  290. //新增学生
  291. insertStudent() {
  292. this.dialogVisible = true;
  293. if (this.sName === "") {
  294. this.$message.error("学生昵称不能为空");
  295. return;
  296. } else if (this.sByClass === "") {
  297. this.$message.error("请为学生选择班级");
  298. return;
  299. } else if (this.sPhone != "" && !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.sPhone)) {
  300. this.$message.error("手机号格式不正确");
  301. return;
  302. } else if (
  303. !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.sMail)
  304. ) {
  305. this.$message.error("邮箱格式不正确");
  306. return;
  307. }
  308. // else if (this.sId === "") {
  309. // this.$message.error("学生学号不能为空");
  310. // return;
  311. // } else if (this.sPhone === "") {
  312. // this.$message.error("学生手机号不能为空");
  313. // return;
  314. // }
  315. if (this.time()) {
  316. // let params = { un: this.sPhone };
  317. // this.ajax
  318. // .get(this.$store.state.api + "findPhone", params)
  319. // .then((res) => {
  320. // if (res.data[0].length > 0) {
  321. // this.$message.error("此学生手机号码已被注册");
  322. // } else {
  323. let params = { un: this.sMail };
  324. this.ajax
  325. .get(this.$store.state.api + "findMail", params)
  326. .then((res) => {
  327. if (res.data[0].length > 0) {
  328. this.$message.error("此学生邮箱已被注册");
  329. } else {
  330. // let params = { un: this.sId };
  331. // this.ajax
  332. // .get(this.$store.state.api + "findSid", params)
  333. // .then((res) => {
  334. // if (res.data[0].length > 0) {
  335. // this.$message.error("此学生学号已被注册");
  336. // } else {
  337. this.add_Student();
  338. // }
  339. // })
  340. // .catch((err) => {
  341. // console.error(err);
  342. // });
  343. }
  344. })
  345. .catch((err) => {
  346. console.error(err);
  347. });
  348. // }
  349. // })
  350. // .catch((err) => {
  351. // console.error(err);
  352. // });
  353. }
  354. },
  355. add_Student() {
  356. let params = [
  357. {
  358. username: this.sMail,
  359. userpassword: 123456,
  360. alias: this.sName,
  361. oid: this.oid,
  362. ph: this.sPhone,
  363. sid: this.sId,
  364. cid: this.sByClass,
  365. org: this.org,
  366. },
  367. ];
  368. this.ajax
  369. .post(this.$store.state.api + "batchRegistrationOrg", params)
  370. .then((res) => {
  371. // console.log(res.data.uid, res.data.ph, res.data.oid, res.data.cid);
  372. // this.isLoading = false;
  373. let params = [
  374. {
  375. userid: res.data.uid,
  376. username: this.sName,
  377. sid: this.sId,
  378. type: 2,
  379. oid: res.data.oid,
  380. phone: res.data.ph,
  381. cid: res.data.cid,
  382. intro: "",
  383. sex: "0",
  384. },
  385. ];
  386. this.ajax
  387. // .post(this.$store.state.api + "updateUser", params)
  388. .post(this.$store.state.api + "updateUserByEdu", params)
  389. .then((res) => {
  390. console.log(res);
  391. })
  392. .catch((err) => {
  393. console.error(err);
  394. });
  395. this.$message({
  396. message: "新增成功",
  397. type: "success",
  398. });
  399. this.dialogVisible = false;
  400. this.sPhone = "";
  401. this.sName = "";
  402. // this.sBySchool = [];
  403. this.sByClass = [];
  404. this.sMail = "";
  405. this.getStudent();
  406. })
  407. .catch((err) => {
  408. this.isLoading = false;
  409. this.$message({
  410. message: "新增失败",
  411. type: "error",
  412. });
  413. console.error(err);
  414. });
  415. },
  416. //获取班级列表
  417. getClass() {
  418. this.isLoading = true;
  419. let params = {
  420. oid: this.oid,
  421. };
  422. this.ajax
  423. .get(this.$store.state.api + "selectClassBySchool", params)
  424. .then((res) => {
  425. this.isLoading = false;
  426. this.classJuri = res.data[0];
  427. })
  428. .catch((err) => {
  429. this.isLoading = false;
  430. console.error(err);
  431. });
  432. },
  433. // getSchool() {
  434. // this.isLoading = true;
  435. // let params = {
  436. // page: this.page,
  437. // };
  438. // this.ajax
  439. // .get(this.$store.state.api + "selectOrg", params)
  440. // .then((res) => {
  441. // this.isLoading = false;
  442. // this.schoolJuri = res.data[0];
  443. // })
  444. // .catch((err) => {
  445. // this.isLoading = false;
  446. // console.error(err);
  447. // });
  448. // },
  449. getStudent() {
  450. this.isLoading = true;
  451. let params = {
  452. oid: this.oid,
  453. cid: this.cid,
  454. cu: "",
  455. cn: this.sPhoneUser,
  456. page: this.page,
  457. };
  458. this.ajax
  459. .get(this.$store.state.api + "selectStudent2", params)
  460. .then((res) => {
  461. this.isLoading = false;
  462. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  463. this.tableData = res.data[0];
  464. })
  465. .catch((err) => {
  466. this.isLoading = false;
  467. console.error(err);
  468. });
  469. },
  470. handleChange(file) {
  471. this.fileTemp = file.file;
  472. if (this.fileTemp) {
  473. if (
  474. this.fileTemp.type ==
  475. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
  476. this.fileTemp.type == "application/vnd.ms-excel"
  477. ) {
  478. this.importCount = 1;
  479. this.importfxx(this.fileTemp);
  480. } else {
  481. this.$message({
  482. type: "warning",
  483. message: "附件格式错误,请删除后重新上传!",
  484. });
  485. }
  486. } else {
  487. this.$message({
  488. type: "warning",
  489. message: "请上传附件!",
  490. });
  491. }
  492. },
  493. handleRemove(file, fileList) {
  494. this.fileTemp = null;
  495. },
  496. exportExcel() {
  497. try {
  498. let params = {
  499. oid: this.oid,
  500. };
  501. this.ajax
  502. .get(this.$store.state.api + "selectUserBySchool", params)
  503. .then((res) => {
  504. var res = res.data[0];
  505. //如果value的json字段的key值和想要的headers值不一致时,可做如下更改
  506. //将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
  507. var array = [];
  508. for (var i = 0; i < res.length; i++) {
  509. var _json = {};
  510. _json["用户名"] = res[i].username;
  511. _json["姓名"] = res[i].alias ? res[i].alias : "";
  512. _json["班级"] = res[i].classid ? res[i].classid : "";
  513. array.push(_json);
  514. }
  515. var XLSX = require("xlsx");
  516. const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
  517. let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
  518. ws["!cols"] = [
  519. //设置每一列的宽度
  520. { wch: 50 },
  521. { wch: 50 },
  522. { wch: 50 },
  523. ];
  524. XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
  525. XLSX.writeFile(workbook, "学生信息.xlsx");
  526. // const wopts = { bookType: "xlsx", bookSST: false, type: "array" };//写入的样式bookType:输出的文件类型,type:输出的数据类型,bookSST: 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
  527. // const wbout = XLSX.write(workbook, wopts);// 浏览器端和node共有的API,实际上node可以直接使用xlsx.writeFile来写入文件,但是浏览器没有该API
  528. // FileSaver.saveAs(new Blob([wbout], { type: "application/octet-stream" }), `${title} demo.xlsx`);//保存文件
  529. this.$message({
  530. message: "导出成功",
  531. type: "success",
  532. });
  533. })
  534. .catch((err) => {
  535. console.error(err);
  536. });
  537. } catch (e) {
  538. console.log(e, e.stack);
  539. }
  540. },
  541. importfxx(obj) {
  542. const loading = this.$loading.service({
  543. background: "rgba(255, 255, 255, 0.7)",
  544. target: document.body,
  545. });
  546. var _$ = $;
  547. this.importCount++;
  548. let _this = this;
  549. // 通过DOM取文件数据
  550. this.file = obj;
  551. var rABS = false; //是否将文件读取为二进制字符串
  552. var f = this.file;
  553. var reader = new FileReader();
  554. //if (!FileReader.prototype.readAsBinaryString) {
  555. FileReader.prototype.readAsBinaryString = function (f) {
  556. var binary = "";
  557. var rABS = false; //是否将文件读取为二进制字符串
  558. var pt = this;
  559. var wb; //读取完成的数据
  560. var outdata;
  561. var reader = new FileReader();
  562. reader.onload = function (e) {
  563. var bytes = new Uint8Array(reader.result);
  564. var length = bytes.byteLength;
  565. for (var i = 0; i < length; i++) {
  566. binary += String.fromCharCode(bytes[i]);
  567. }
  568. var XLSX = require("xlsx");
  569. if (rABS) {
  570. wb = XLSX.read(btoa(fixdata(binary)), {
  571. //手动转化
  572. type: "base64",
  573. });
  574. } else {
  575. wb = XLSX.read(binary, {
  576. type: "binary",
  577. });
  578. }
  579. outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]); //outdata就是你想要的东西
  580. this.da = [...outdata];
  581. let arr = [];
  582. this.da.map((v) => {
  583. let obj = {};
  584. let a = "";
  585. var num = "";
  586. // for (var cj = 0; cj < 3; cj++) {
  587. // num += Math.floor(Math.random() * 10);
  588. // }
  589. // a =
  590. // pinyin.getFullChars(v["学生姓名"]).toLowerCase() +
  591. // num +
  592. // "@cocorobo.cc";
  593. obj.sId = v["学号"];
  594. obj.name = v["学生姓名"];
  595. obj.mail = v["学生邮箱"];
  596. obj.phone = v["学生手机号"];
  597. obj.class = v["班级"];
  598. arr.push(obj);
  599. });
  600. console.log(arr);
  601. let _b = 1;
  602. for (var i = 0; i < arr.length; i++) {
  603. let item = arr[i];
  604. if (item.class === "") {
  605. _b = 1;
  606. _this.$message.error("学生班级不能为空,请重新上传");
  607. break;
  608. } else if (item.name === "") {
  609. _b = 1;
  610. _this.$message.error("学生姓名不能为空,请重新上传");
  611. break;
  612. } else if (item.sId === "") {
  613. _b = 1;
  614. _this.$message.error("学生学号不能为空,请重新上传");
  615. }else if (item.mail === "") {
  616. _b = 1;
  617. _this.$message.error("学生邮箱不能为空,请重新上传");
  618. break;
  619. } else if (
  620. !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
  621. item.mail
  622. )
  623. ) {
  624. _b = 1;
  625. _this.$message.error("有学生邮箱格式不正确,请重新上传");
  626. break;
  627. }
  628. }
  629. let z = 2;
  630. let newArr = JSON.stringify(arr);
  631. let params = [
  632. {
  633. arr: newArr,
  634. userpassword: 123456,
  635. oid: _this.oid,
  636. org: _this.org,
  637. },
  638. ];
  639. _this.ajax
  640. .post(_this.$store.state.api + "batchRegistrationMoreOrg", params)
  641. .then((res) => {
  642. if (res.data.type == 1) {
  643. _this.$message.error("有学生手机号码已被注册");
  644. z = 1;
  645. }
  646. if (res.data.type == 2) {
  647. _this.$message.error("有学生邮箱已被注册");
  648. z = 1;
  649. }
  650. if (res.data.type == 3) {
  651. _this.$message.error("有学生学号重复");
  652. z = 1;
  653. }
  654. if (z == 2) {
  655. _this.$message({
  656. message: "新增成功",
  657. type: "success",
  658. });
  659. _this.getStudent();
  660. }
  661. loading.close();
  662. })
  663. .catch((err) => {
  664. console.error(err);
  665. });
  666. _this.fileListUpload = [];
  667. };
  668. reader.readAsArrayBuffer(f);
  669. };
  670. if (rABS) {
  671. reader.readAsArrayBuffer(f);
  672. } else {
  673. reader.readAsBinaryString(f);
  674. }
  675. },
  676. getSchoolName() {
  677. let params = {
  678. oid: this.oid,
  679. };
  680. this.ajax
  681. .get(this.$store.state.api + "selectSchoolName2", params)
  682. .then((res) => {
  683. this.schoolName = res.data[0][0].name;
  684. })
  685. .catch((err) => {
  686. console.error(err);
  687. });
  688. },
  689. deleteStudent(id, state) {
  690. state = 0;
  691. let params = [{ uid: id, state: state }];
  692. this.$confirm("确定" + "删除" + "此学生吗?", "提示", {
  693. confirmButtonText: "确定",
  694. cancelButtonText: "取消",
  695. type: "warning",
  696. })
  697. .then(() => {
  698. this.ajax
  699. .post(this.$store.state.api + "deleteStudent", params)
  700. .then((res) => {
  701. this.$message({
  702. message: "操作成功",
  703. type: "success",
  704. });
  705. this.getStudent();
  706. })
  707. .catch((err) => {
  708. this.$message.error("操作失败");
  709. console.error(err);
  710. });
  711. })
  712. .catch(() => {});
  713. },
  714. },
  715. created() {
  716. this.page = 1;
  717. this.getStudent();
  718. this.getSchoolName();
  719. this.getClass();
  720. },
  721. };
  722. </script>
  723. <style scoped>
  724. .pb_head > span:nth-child(2) {
  725. font-size: 20px;
  726. margin-left: 5px;
  727. color: #828282;
  728. }
  729. .pb_head {
  730. margin: 0 !important;
  731. width: 100% !important;
  732. }
  733. .student_page {
  734. margin-top: 10px;
  735. }
  736. .student_head {
  737. margin-top: 10px;
  738. padding-bottom: 10px;
  739. display: flex;
  740. justify-content: space-between;
  741. }
  742. .head_left {
  743. display: flex;
  744. align-items: center;
  745. }
  746. .head_right {
  747. display: flex;
  748. flex-direction: row;
  749. flex-wrap: nowrap;
  750. align-items: baseline;
  751. }
  752. .student_input >>> .el-input__inner {
  753. height: 30px;
  754. width: 190px;
  755. font-size: 13px;
  756. padding: 0 10px;
  757. }
  758. .student_button {
  759. color: #fff;
  760. background: #8681b7;
  761. border-color: #8681b7;
  762. width: 60px;
  763. height: 30px;
  764. padding: 0 !important;
  765. font-size: 12px;
  766. line-height: 30px;
  767. }
  768. .head_right > button:nth-child(1) {
  769. color: #fff;
  770. background: #8681b7;
  771. border-color: #8681b7;
  772. width: 70px;
  773. height: 30px;
  774. padding: 0 !important;
  775. font-size: 12px;
  776. line-height: 30px;
  777. }
  778. .head_right > button:nth-child(2) {
  779. color: #fff;
  780. background: #8681b7;
  781. width: 70px;
  782. height: 30px;
  783. padding: 0 !important;
  784. font-size: 12px;
  785. line-height: 30px;
  786. }
  787. .head_right > div {
  788. font-size: 12px;
  789. line-height: 40px;
  790. margin-left: 10px;
  791. color: #2a6dbe;
  792. text-decoration: underline;
  793. cursor: pointer;
  794. }
  795. .student_table >>> .el-table--border td {
  796. border-right: 0px !important;
  797. }
  798. .student_table >>> .el-table,.student_table >>> .el-table__body-wrapper{
  799. height: auto !important;
  800. }
  801. .el-table >>> .even_row {
  802. background-color: #f1f1f1 !important;
  803. }
  804. .de_button {
  805. color: #fff;
  806. background: #5190fd;
  807. width: 50px;
  808. height: 25px;
  809. padding: 0 !important;
  810. font-size: 12px;
  811. line-height: 25px;
  812. }
  813. .add_student >>> .el-dialog__header {
  814. padding: 20px 20px 10px;
  815. text-align: center;
  816. background: #454545;
  817. }
  818. .add_student >>> .el-dialog__title {
  819. font-size: 14px !important;
  820. color: #fff !important;
  821. }
  822. .add_student >>> .el-dialog__headerbtn {
  823. font-size: 20px !important;
  824. }
  825. .add_student >>> .el-form-item__label {
  826. margin-left: 65px;
  827. }
  828. .add_student >>> .el-form-item {
  829. display: flex;
  830. }
  831. .add_student >>> .el-form-item__content {
  832. margin: 0 !important;
  833. }
  834. .add_input {
  835. width: 365px;
  836. }
  837. .add_student >>> .el-dialog__footer {
  838. text-align: center !important;
  839. }
  840. .right {
  841. width: 250px;
  842. color: #fff;
  843. background: #8681b7;
  844. margin-bottom: 20px;
  845. }
  846. .header-title {
  847. display: flex;
  848. }
  849. .logoImg {
  850. width: 30px;
  851. }
  852. .logoImg > img {
  853. width: 100%;
  854. height: 100%;
  855. }
  856. .title_add_student {
  857. margin: 0 auto;
  858. color: #fff;
  859. }
  860. .upload-demo {
  861. line-height: 0px !important;
  862. }
  863. .upload-demo >>> .el-button {
  864. color: #fff;
  865. background: #8681b7;
  866. width: 70px;
  867. height: 30px;
  868. padding: 0 !important;
  869. font-size: 12px;
  870. line-height: 0 !important;
  871. }
  872. .userImg {
  873. display: flex;
  874. flex-direction: row;
  875. justify-content: center;
  876. align-items: center;
  877. }
  878. .tx {
  879. width: 40px;
  880. margin-right: 10px;
  881. }
  882. .delete {
  883. width: 25px;
  884. cursor: pointer;
  885. }
  886. .tx > img,
  887. .delete > img {
  888. width: 100%;
  889. height: 100%;
  890. }
  891. .newCss {
  892. display: flex;
  893. flex-direction: row;
  894. flex-wrap: nowrap;
  895. align-items: baseline;
  896. }
  897. .student_page
  898. >>> .el-pagination.is-background
  899. .el-pager
  900. li:not(.disabled).active {
  901. background-color: #5c549f;
  902. color: #fff !important;
  903. }
  904. .student_page
  905. >>> .el-pagination.is-background
  906. .el-pager
  907. li:not(.disabled):hover {
  908. color: #5c549f;
  909. }
  910. .el-select-dropdown__item.selected {
  911. color: #5c549f;
  912. }
  913. .inputClass.is-active >>> .el-input__inner,
  914. .inputClass >>> .el-input__inner:focus {
  915. border-color: #5c549f;
  916. }
  917. .inputClass >>> .el-select .el-input.is-focus .el-input__inner {
  918. border-color: #5c549f;
  919. }
  920. .inputClass >>> .el-select .el-input__inner:focus {
  921. border-color: #5c549f;
  922. }
  923. .student_input.el-input{
  924. width: auto;
  925. }
  926. .student_input{
  927. margin-right: 10px;
  928. }
  929. .student_input >>> .el-input__icon{
  930. line-height: unset;
  931. }
  932. </style>