class.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. <template>
  2. <div class="pb_content" style="background: unset">
  3. <div v-if="ctype == 1" class="pb_content_body" style="
  4. background: #fff;
  5. padding: 0px 25px;
  6. box-sizing: border-box;
  7. border-radius: 5px;
  8. ">
  9. <div class="pb_head top">
  10. <span>班级管理</span>
  11. <div class="student_button" style="border-radius: 4px;">
  12. <el-button type="primary" class="bgColor" @click="dialogVisible = true">添加班级</el-button>
  13. </div>
  14. </div>
  15. <div class="student_head">
  16. <div class="student_search">
  17. <span>
  18. <el-input placeholder="请输入班级名称" v-model="sClassName" clearable>
  19. </el-input>
  20. </span>
  21. <el-button type="primary" @click="searchClass">查询</el-button>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="pb_content_body" v-if="ctype == 1">
  26. <div class="student_table">
  27. <el-table v-if="ctype == 1" ref="table" :key="1" :data="tableData" border :height="tableHeight" :fit="true"
  28. v-loading="isLoading" style="width: 100%; height: 60%" :header-cell-style="{ background: '#f1f1f1' }"
  29. :row-class-name="tableRowClassName">
  30. <el-table-column prop="name" label="班级名称" min-width="40%" align="center">
  31. </el-table-column>
  32. <el-table-column prop="pnum" label="人数" min-width="40%" align="center">
  33. </el-table-column>
  34. <el-table-column label="操作" min-width="20%">
  35. <template slot-scope="scope">
  36. <el-button type="primary" size="small" @click="getStudent(scope.row.id)">查看学生</el-button>
  37. <el-button type="primary" size="small" @click="openUpdate(scope.row.id, scope.row.name)">修改</el-button>
  38. <el-button type="primary" size="small" @click="deleteClass(scope.row.id)">删除</el-button>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. </div>
  43. <div class="student_page">
  44. <el-pagination background layout="prev, pager, next" :page-size="10" :total="total" v-if="page"
  45. @current-change="handleCurrentChange">
  46. </el-pagination>
  47. </div>
  48. </div>
  49. <div v-if="ctype == 2" class="pb_content_body" style="
  50. background: #fff;
  51. padding: 0px 25px;
  52. box-sizing: border-box;
  53. border-radius: 5px;
  54. ">
  55. <div class="pb_head top">
  56. <span>查看学生</span>
  57. <div class="student_button" style="border-radius: 4px;">
  58. <el-button type="primary" class="bgColor" @click="ctype = 1, getClass()">返回</el-button>
  59. </div>
  60. </div>
  61. <div class="student_head">
  62. <div class="head_left">
  63. <el-input v-model="sPhoneUser" class="student_input" placeholder="请输入用户名"></el-input>
  64. <el-select disabled v-model="cid" placeholder="请选择班级" class="student_input" @change="searchStudent"
  65. style="margin:0 10px">
  66. <el-option label="所有人" value=""></el-option>
  67. <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
  68. </el-select>
  69. <el-button class="student_button" @click="searchStudent">查询</el-button>
  70. </div>
  71. <div class="head_right">
  72. <el-button @click="addStudent">添加学生</el-button>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="pb_content_body" v-if="ctype == 2">
  77. <div class="student_table">
  78. <el-table v-if="ctype == 2" :key="2" ref="table2" :data="tableData2" border :height="tableHeight" :fit="true"
  79. v-loading="isLoading" style="width: 100%" :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
  80. :row-class-name="tableRowClassName">
  81. <el-table-column label="姓名" min-width="10" align="center">
  82. <template slot-scope="scope">
  83. <div class="userImg">
  84. <div class="tx">
  85. <img :src="
  86. scope.row.headportrait != null
  87. ? scope.row.headportrait
  88. : tx
  89. " alt />
  90. </div>
  91. <div style="
  92. width: 150px;
  93. text-align: left;
  94. white-space: nowrap;
  95. overflow: hidden;
  96. text-overflow: ellipsis;
  97. ">
  98. {{ scope.row.name }}
  99. </div>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="学生账号" min-width="15" align="center">
  104. <template slot-scope="scope">
  105. <div>{{ scope.row.un ? scope.row.un : "" }}</div>
  106. </template>
  107. </el-table-column>
  108. <el-table-column prop="classname2" label="班级" min-width="15" align="center">
  109. </el-table-column>
  110. <el-table-column label="操作" width="250px">
  111. <template slot-scope="scope">
  112. <div class="btnBox">
  113. <el-button class="de_button" type="primary" size="small"
  114. @click="iniPassword(scope.row.userid)">初始化密码</el-button>
  115. <el-button class="de_button" type="primary" size="small" @click="updateStudentA(scope.row)">修改</el-button>
  116. <el-button class="de_button" type="primary" size="small"
  117. @click="deleteClassStudent(scope.row.userid)">移除</el-button>
  118. <!-- <div class="delete">
  119. <img src="../../assets/remove.png" alt @click="deleteStudent(scope.row.userid, scope.row.state)" />
  120. </div> -->
  121. </div>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. </div>
  126. <div class="student_page">
  127. <el-pagination background layout="prev, pager, next" :page-size="10" :total="total2" v-if="page2"
  128. @current-change="handleCurrentChange2"></el-pagination>
  129. </div>
  130. </div>
  131. <el-dialog :visible.sync="dialogVisibleAddStudent" :append-to-body="true" width="700px" :before-close="handleClose"
  132. class="add_student">
  133. <div slot="title" class="header-title">
  134. <div class="logoImg">
  135. <img src="../../assets/logo.png" alt />
  136. </div>
  137. <div class="title_add_student">添加学生</div>
  138. </div>
  139. <el-form>
  140. <el-form-item label="学生姓名" :label-width="formLabelWidth">
  141. <span>
  142. <el-input placeholder="请输入学生姓名" clearable v-model="sName" class="add_input"></el-input>
  143. </span>
  144. </el-form-item>
  145. <el-form-item label="学生学号" :label-width="formLabelWidth">
  146. <span>
  147. <el-input placeholder="请输入学生学号" clearable v-model="sId" class="add_input"></el-input>
  148. </span>
  149. </el-form-item>
  150. <el-form-item label="学生手机号" :label-width="formLabelWidth">
  151. <span>
  152. <el-input placeholder="请输入学生手机号" clearable v-model="sPhone" class="add_input"></el-input>
  153. </span>
  154. </el-form-item>
  155. <el-form-item label="学生账号" :label-width="formLabelWidth">
  156. <span>
  157. <el-input placeholder="请输入学生账号" clearable v-model="sMail" class="add_input"></el-input>
  158. </span>
  159. </el-form-item>
  160. <el-form-item label="所属学校" :label-width="formLabelWidth">
  161. <el-input disabled style="width: 300px" v-model="schoolName"></el-input>
  162. </el-form-item>
  163. <el-form-item label="班级" :label-width="formLabelWidth">
  164. <el-select v-model="cid" placeholder="请选择班级" disabled>
  165. <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
  166. </el-select>
  167. </el-form-item>
  168. <div style="text-align: center; color: #adb3b7">
  169. 注:添加学生的账号密码为123456
  170. </div>
  171. </el-form>
  172. <span slot="footer" class="dialog-footer flex">
  173. <el-button class="right" @click="insertStudent">确认</el-button>
  174. </span>
  175. </el-dialog>
  176. <el-dialog :visible.sync="dialogVisibleUpdate" :append-to-body="true" width="700px" :before-close="handleClose"
  177. class="add_student">
  178. <div slot="title" class="header-title">
  179. <div class="logoImg">
  180. <img src="../../assets/logo.png" alt />
  181. </div>
  182. <div class="title_add_student">修改学生</div>
  183. </div>
  184. <el-form>
  185. <el-form-item label="学生名称" :label-width="formLabelWidth">
  186. <span>
  187. <el-input placeholder="请输入学生姓名" clearable v-model="userinfo.name" class="add_input"></el-input>
  188. </span>
  189. </el-form-item>
  190. <el-form-item label="学生学号" :label-width="formLabelWidth">
  191. <span>
  192. <el-input placeholder="请输入学生学号" clearable v-model="userinfo.studentid" class="add_input"></el-input>
  193. </span>
  194. </el-form-item>
  195. <el-form-item label="学生手机号" :label-width="formLabelWidth">
  196. <span>
  197. <el-input placeholder="请输入学生手机号" clearable v-model="userinfo.phonenumber" class="add_input"></el-input>
  198. </span>
  199. </el-form-item>
  200. <el-form-item label="学生账号" :label-width="formLabelWidth">
  201. <span>
  202. <el-input placeholder="请输入学生账号" clearable v-model="userinfo.un" class="add_input"></el-input>
  203. </span>
  204. </el-form-item>
  205. <el-form-item label="所属学校" :label-width="formLabelWidth">
  206. <el-input disabled style="width: 300px" v-model="schoolName"></el-input>
  207. </el-form-item>
  208. <el-form-item label="班级" :label-width="formLabelWidth">
  209. <el-select multiple collapse-tags v-model="userinfo.classid" placeholder="请选择班级">
  210. <el-option v-for="(item, index) in classJuri" :key="index" :label="item.name" :value="item.id"></el-option>
  211. </el-select>
  212. </el-form-item>
  213. <div style="text-align: center; color: #adb3b7">
  214. 注:添加学生的账号密码为123456
  215. </div>
  216. </el-form>
  217. <span slot="footer" class="dialog-footer flex">
  218. <el-button class="right" @click="updateStudent">修改</el-button>
  219. </span>
  220. </el-dialog>
  221. <el-dialog title="添加班级" :visible.sync="dialogVisible" :append-to-body="true" width="25%" :before-close="handleClose"
  222. class="dialog_diy">
  223. <el-form>
  224. <el-form-item label="班级名称" :label-width="formLabelWidth">
  225. <el-input v-model="className" auto-complete="off" placeholder="请输入班级..."></el-input>
  226. </el-form-item>
  227. </el-form>
  228. <span slot="footer" class="dialog-footer">
  229. <el-button @click="dialogVisible = false">取 消</el-button>
  230. <el-button type="primary" @click="insertClass">确 定</el-button>
  231. </span>
  232. </el-dialog>
  233. <el-dialog title="修改班级" :visible.sync="dialogVisible1" :append-to-body="true" width="25%" :before-close="handleClose"
  234. class="dialog_diy">
  235. <el-form>
  236. <el-form-item label="班级名称" :label-width="formLabelWidth">
  237. <el-input v-model="className1" auto-complete="off" placeholder="请输入班级..."></el-input>
  238. </el-form-item>
  239. </el-form>
  240. <span slot="footer" class="dialog-footer">
  241. <el-button @click="dialogVisible1 = false">取 消</el-button>
  242. <el-button type="primary" @click="updateClass">确 定</el-button>
  243. </span>
  244. </el-dialog>
  245. <el-dialog title="添加学生" :visible.sync="dialogVisibleMember" :append-to-body="true" width="500px" height="80%"
  246. :before-close="handleClose" class="addNewPP">
  247. <div class="people">
  248. <div class="people_top">
  249. <div class="people_top_right">
  250. <div class="people_search">
  251. <el-input placeholder="搜索学生姓名" v-model="searchTN" @keyup.enter.native="getClassStudent"></el-input>
  252. <div class="search_img" @click="getClassStudent">
  253. <img src="../../assets/icon/search.png" alt />
  254. </div>
  255. </div>
  256. </div>
  257. <div class="people_nav">选择成员</div>
  258. </div>
  259. <div class="t_j_box" style="
  260. padding: 20px 0 0 25px;
  261. width: calc(100% - 55px);
  262. margin-left: 25px;
  263. ">
  264. <span>姓名</span>
  265. <span>账号</span>
  266. </div>
  267. <el-checkbox-group v-model="checkboxList3" class="people_name" v-if="teacherJuri.length" v-loading="isLoading2">
  268. <el-checkbox v-for="item in teacherJuri" :key="item.userid" :label="item.userid">
  269. <div class="t_j_box">
  270. <el-tooltip placement="top" :content="item.name ? item.name : '暂无姓名'">
  271. <span>{{ item.name ? item.name : "暂无姓名" }}</span>
  272. </el-tooltip>
  273. <el-tooltip placement="top" :content="item.username">
  274. <span>{{ item.username }}</span>
  275. </el-tooltip>
  276. </div>
  277. </el-checkbox>
  278. </el-checkbox-group>
  279. <div style="text-align: center; margin-top: 10px" v-else>暂无数据</div>
  280. </div>
  281. <div style="margin-top: 10px;">
  282. <el-pagination background layout="prev, pager, next" :page-size="pageSize3" :total="total3"
  283. v-if="page3 && teacherJuri.length" style="padding-bottom: 20px"
  284. @current-change="handleCurrentChange3"></el-pagination>
  285. </div>
  286. <span slot="footer" class="dialog-footer">
  287. <el-button @click="dialogVisibleMember = false">取 消</el-button>
  288. <el-button type="primary" @click="addClassStudent">确定</el-button>
  289. </span>
  290. </el-dialog>
  291. </div>
  292. </template>
  293. <script>
  294. import TaskListHeader from 'gantt-elastic/src/components/TaskList/TaskListHeader.vue';
  295. export default {
  296. data() {
  297. return {
  298. tableHeight: "500px",
  299. isLoading: false,
  300. formLabelWidth: "100px",
  301. sClassName: "",
  302. className: "",
  303. className1: "",
  304. classid: "",
  305. dialogVisible: false,
  306. dialogVisible1: false,
  307. dialogVisibleUpdate: false,
  308. dialogVisibleAddStudent: false,
  309. tableData: [],
  310. page: 1,
  311. total: 0,
  312. tableData2: [],
  313. page2: 1,
  314. total2: 0,
  315. userid: this.$route.query.userid,
  316. oid: this.$route.query.oid,
  317. cid: "",
  318. ctype: 1,
  319. sName: "",
  320. sPhone: "",
  321. sId: "",
  322. schoolName: "",
  323. sByClass: "",
  324. sMail: "",
  325. classJuri: [],
  326. userinfo: {},
  327. userinfoA: {},
  328. sPhoneUser: "",
  329. tx: require("../../assets/avatar.png"),
  330. dialogVisibleMember: false,
  331. checkboxList3: [],
  332. teacherJuri: [],
  333. pageSize3: 10,
  334. total3: 0,
  335. page3: 1,
  336. isLoading2: false,
  337. searchTN: "",
  338. };
  339. },
  340. created() {
  341. this.page = 1;
  342. this.getClass();
  343. this.getClass2();
  344. this.getSchoolName();
  345. },
  346. mounted() {
  347. this.$nextTick(function () {
  348. this.tableHeight =
  349. window.innerHeight - this.$refs.table.$el.offsetTop - 200;
  350. if (this.tableHeight <= 530) {
  351. this.tableHeight = 530;
  352. }
  353. // 监听窗口大小变化
  354. let self = this;
  355. window.onresize = function () {
  356. self.tableHeight =
  357. window.innerHeight - self.$refs.table.$el.offsetTop - 200;
  358. if (self.tableHeight <= 530) {
  359. self.tableHeight = 530;
  360. }
  361. };
  362. });
  363. },
  364. methods: {
  365. tableRowClassName({ row, rowIndex }) {
  366. if ((rowIndex + 1) % 2 === 0) {
  367. return "even_row";
  368. } else {
  369. return "";
  370. }
  371. },
  372. handleCurrentChange(val) {
  373. this.page = val;
  374. this.getClass();
  375. },
  376. handleClose(done) {
  377. done();
  378. },
  379. time() {
  380. if (!this.now) {
  381. this.now = new Date().getTime();
  382. return true;
  383. } else {
  384. let time = new Date().getTime();
  385. if (time - this.now > 3000) {
  386. this.now = time;
  387. return true;
  388. } else {
  389. return false;
  390. }
  391. }
  392. },
  393. searchClass() {
  394. this.page = 1;
  395. this.getClass();
  396. },
  397. openUpdate(id, n) {
  398. this.classid = id;
  399. this.className1 = n;
  400. this.dialogVisible1 = true;
  401. },
  402. //新增班级
  403. insertClass() {
  404. let params = {
  405. name: this.className,
  406. oid: this.oid,
  407. uid: this.userid,
  408. };
  409. this.ajax
  410. .get(this.$store.state.api + "insertClass", params)
  411. .then((res) => {
  412. if (res.data[0] && res.data[0][0].classname == 1) {
  413. this.$message({
  414. message: "不能与其他班级名称相同!",
  415. type: "error",
  416. });
  417. } else {
  418. this.$message({
  419. message: "新增成功",
  420. type: "success",
  421. });
  422. this.dialogVisible = false;
  423. this.sClassName = "";
  424. this.getClass();
  425. this.className = "";
  426. }
  427. })
  428. .catch((err) => {
  429. this.$message({
  430. message: "新增失败",
  431. type: "error",
  432. });
  433. console.error(err);
  434. });
  435. },
  436. //修改班级
  437. updateClass() {
  438. let params = {
  439. id: this.classid,
  440. n: this.className1,
  441. oid: this.oid,
  442. };
  443. this.ajax
  444. .get(this.$store.state.api + "updateClass", params)
  445. .then((res) => {
  446. if (res.data[0] && res.data[0][0].classname == 1) {
  447. this.$message({
  448. message: "不能与其他班级名称相同!",
  449. type: "error",
  450. });
  451. } else {
  452. this.$message({
  453. message: "修改成功",
  454. type: "success",
  455. });
  456. this.dialogVisible1 = false;
  457. this.getClass();
  458. this.classid = "";
  459. this.className1 = "";
  460. }
  461. })
  462. .catch((err) => {
  463. this.$message({
  464. message: "修改失败",
  465. type: "error",
  466. });
  467. console.error(err);
  468. });
  469. },
  470. //获取班级列表
  471. getClass() {
  472. this.isLoading = true;
  473. let params = {
  474. // username: this.$store.state.userInfo.userid,
  475. cu: "",
  476. oid: this.oid,
  477. cn: this.sClassName,
  478. page: this.page,
  479. };
  480. this.ajax
  481. .get(this.$store.state.api + "selectClass", params)
  482. .then((res) => {
  483. this.isLoading = false;
  484. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  485. this.tableData = res.data[0];
  486. })
  487. .catch((err) => {
  488. this.isLoading = false;
  489. console.error(err);
  490. });
  491. },
  492. //删除班级
  493. deleteClass(id) {
  494. let params = {
  495. id: id,
  496. };
  497. if (this.time()) {
  498. this.$confirm("确定删除此班级吗?", "提示", {
  499. confirmButtonText: "确定",
  500. cancelButtonText: "取消",
  501. type: "warning",
  502. })
  503. .then(() => {
  504. this.ajax
  505. .get(this.$store.state.api + "deleteClass", params)
  506. .then((res) => {
  507. this.$message({
  508. message: "删除成功",
  509. type: "success",
  510. });
  511. if (this.page != 1 && this.tableData.length == 1) {
  512. this.page - 1;
  513. }
  514. this.getClass();
  515. })
  516. .catch((err) => {
  517. this.$message.error("删除失败");
  518. console.error(err);
  519. });
  520. })
  521. .catch(() => { });
  522. }
  523. },
  524. addStudent() {
  525. // this.dialogVisibleAddStudent = true;
  526. // (this.sName = ""), (this.sPhone = ""), (this.sByClass = ""), this.sMail;
  527. // this.getClass2();
  528. this.dialogVisibleMember = true
  529. this.searchTN = ""
  530. this.getClassStudent();
  531. },
  532. //新增学生
  533. insertStudent() {
  534. if (this.sName === "") {
  535. this.$message.error("学生姓名不能为空");
  536. return;
  537. } else if (
  538. this.sPhone != "" &&
  539. !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.sPhone)
  540. ) {
  541. this.$message.error("手机号格式不正确");
  542. return;
  543. } else if (
  544. !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.sMail)
  545. ) {
  546. this.$message.error("邮箱格式不正确");
  547. return;
  548. }
  549. if (this.time()) {
  550. let params = { un: this.sMail };
  551. this.ajax
  552. .get(this.$store.state.api + "findMail", params)
  553. .then((res) => {
  554. if (res.data[0].length > 0) {
  555. this.$message.error("此学生账号已被注册");
  556. } else {
  557. this.add_Student();
  558. }
  559. })
  560. .catch((err) => {
  561. console.error(err);
  562. });
  563. }
  564. },
  565. add_Student() {
  566. let params = [
  567. {
  568. username: this.sMail,
  569. userpassword: 123456,
  570. alias: this.sName,
  571. oid: this.oid,
  572. ph: this.sPhone,
  573. sid: this.sId,
  574. cid: this.cid,
  575. },
  576. ];
  577. this.ajax
  578. .post(this.$store.state.api + "batchRegistration", params)
  579. .then((res) => {
  580. let params = [
  581. {
  582. userid: res.data.uid,
  583. username: this.sName,
  584. sid: this.sId,
  585. type: 2,
  586. oid: res.data.oid,
  587. phone: res.data.ph,
  588. cid: res.data.cid,
  589. intro: "",
  590. sex: "0",
  591. },
  592. ];
  593. this.ajax
  594. .post(this.$store.state.api + "updateUserByEdu", params)
  595. .then((res) => {
  596. console.log(res);
  597. })
  598. .catch((err) => {
  599. console.error(err);
  600. });
  601. this.$message({
  602. message: "新增成功",
  603. type: "success",
  604. });
  605. this.dialogVisibleAddStudent = false;
  606. this.sPhone = "";
  607. this.sName = "";
  608. this.sByClass = [];
  609. this.sMail = "";
  610. this.getStudent(this.cid);
  611. })
  612. .catch((err) => {
  613. this.isLoading = false;
  614. this.$message({
  615. message: "新增失败",
  616. type: "error",
  617. });
  618. console.error(err);
  619. });
  620. },
  621. updateStudentA(res) {
  622. this.userinfo = JSON.parse(JSON.stringify(res));
  623. this.userinfoA = JSON.parse(JSON.stringify(res));
  624. this.userinfo.classid = this.userinfo.classid.split(",")
  625. this.dialogVisibleUpdate = true;
  626. },
  627. updateStudent() {
  628. if (this.userinfo.name === "") {
  629. this.$message.error("学生姓名不能为空");
  630. return;
  631. } else if (!this.userinfo.classid) {
  632. this.$message.error("请为学生选择班级");
  633. return;
  634. } else if (
  635. this.userinfo.phonenumber &&
  636. !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.userinfo.phonenumber)
  637. ) {
  638. this.$message.error("手机号格式不正确");
  639. return;
  640. } else if (
  641. !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
  642. this.userinfo.un
  643. )
  644. ) {
  645. this.$message.error("邮箱格式不正确");
  646. return;
  647. }
  648. if (this.time()) {
  649. if (this.userinfoA.un != this.userinfo.un) {
  650. let params = { un: this.userinfo.un };
  651. this.ajax
  652. .get(this.$store.state.api + "findMail", params)
  653. .then((res) => {
  654. if (res.data[0].length > 0) {
  655. this.$message.error("此学生账号已被注册");
  656. } else {
  657. this.update_Student();
  658. }
  659. })
  660. .catch((err) => {
  661. console.error(err);
  662. });
  663. } else {
  664. this.update_Student();
  665. }
  666. }
  667. },
  668. update_Student() {
  669. let params = [
  670. {
  671. userid: this.userinfo.userid,
  672. username: this.userinfo.un,
  673. alias: this.userinfo.name,
  674. ph: this.userinfo.phonenumber,
  675. sid: this.userinfo.studentid,
  676. cid: this.userinfo.classid.join(","),
  677. },
  678. ];
  679. this.ajax
  680. .post(this.$store.state.api + "updateStudentInfo", params)
  681. .then((res) => {
  682. this.$message({
  683. message: "修改成功",
  684. type: "success",
  685. });
  686. this.dialogVisibleUpdate = false;
  687. this.getStudent(this.cid);
  688. })
  689. .catch((err) => {
  690. this.isLoading = false;
  691. this.$message({
  692. message: "修改失败",
  693. type: "error",
  694. });
  695. console.error(err);
  696. });
  697. },
  698. deleteClassStudent(id) {
  699. let params = [{ uid: id, cid: this.cid }];
  700. this.$confirm("确定移除此学生在本班级吗?", "提示", {
  701. confirmButtonText: "确定",
  702. cancelButtonText: "取消",
  703. type: "warning",
  704. })
  705. .then(() => {
  706. this.ajax
  707. .post(this.$store.state.api + "deleteClassStudent", params)
  708. .then((res) => {
  709. this.$message({
  710. message: "操作成功",
  711. type: "success",
  712. });
  713. this.getStudent(this.cid);
  714. })
  715. .catch((err) => {
  716. this.$message.error("操作失败");
  717. console.error(err);
  718. });
  719. })
  720. .catch(() => { });
  721. },
  722. //获取班级列表
  723. getClass2() {
  724. this.isLoading = true;
  725. let params = {
  726. oid: this.oid,
  727. };
  728. this.ajax
  729. .get(this.$store.state.api + "selectClassBySchool", params)
  730. .then((res) => {
  731. this.isLoading = false;
  732. this.classJuri = res.data[0];
  733. })
  734. .catch((err) => {
  735. this.isLoading = false;
  736. console.error(err);
  737. });
  738. },
  739. getSchoolName() {
  740. let params = {
  741. oid: this.oid,
  742. };
  743. this.ajax
  744. .get(this.$store.state.api + "selectSchoolName2", params)
  745. .then((res) => {
  746. this.schoolName = res.data[0][0].name;
  747. })
  748. .catch((err) => {
  749. console.error(err);
  750. });
  751. },
  752. searchStudent() {
  753. this.page2 = 1;
  754. this.getStudent(this.cid);
  755. },
  756. handleCurrentChange2(val) {
  757. this.page2 = val;
  758. this.getStudent(this.cid);
  759. },
  760. handleCurrentChange3(val) {
  761. this.page3 = val;
  762. this.getClassStudent();
  763. },
  764. getStudent(cid) {
  765. this.cid = cid
  766. this.ctype = 2
  767. this.isLoading = true;
  768. let params = {
  769. oid: this.oid,
  770. cid: this.cid,
  771. cu: "",
  772. cn: this.sPhoneUser,
  773. page: this.page2,
  774. };
  775. this.ajax
  776. .get(this.$store.state.api + "selectStudent2", params)
  777. .then((res) => {
  778. this.isLoading = false;
  779. this.total2 = res.data[0].length > 0 ? res.data[0][0].num : 0;
  780. this.tableData2 = res.data[0];
  781. this.getClass2();
  782. })
  783. .catch((err) => {
  784. this.isLoading = false;
  785. console.error(err);
  786. });
  787. },
  788. getClassStudent() {
  789. this.isLoading2 = true;
  790. let params = {
  791. oid: this.oid,
  792. cid: this.cid,
  793. cn: this.searchTN,
  794. page: this.page3,
  795. num: this.pageSize3,
  796. };
  797. this.ajax
  798. .get(this.$store.state.api + "getClassStudent", params)
  799. .then((res) => {
  800. this.isLoading2 = false;
  801. this.total3 = res.data[0].length > 0 ? res.data[0][0].num : 0;
  802. this.teacherJuri = res.data[0];
  803. })
  804. .catch((err) => {
  805. this.isLoading2 = false;
  806. console.error(err);
  807. });
  808. },
  809. addClassStudent() {
  810. if (!this.checkboxList3.length) {
  811. this.$message.error('请选择要添加班级的学生');
  812. return;
  813. }
  814. let params = [{
  815. cid: this.cid,
  816. student: JSON.stringify(this.checkboxList3)
  817. }];
  818. this.ajax
  819. .post(this.$store.state.api + "addClassStudent", params)
  820. .then((res) => {
  821. this.checkboxList3 = []
  822. this.dialogVisibleMember = false
  823. this.getStudent(this.cid)
  824. })
  825. .catch((err) => {
  826. console.error(err);
  827. });
  828. },
  829. iniPassword(id) {
  830. let params = [
  831. {
  832. uid: id,
  833. pa: 123456,
  834. },
  835. ];
  836. this.ajax
  837. .post(this.$store.state.api + "iniPassword", params)
  838. .then((res) => {
  839. this.$message({
  840. message: "初始化密码成功!",
  841. type: "success",
  842. });
  843. })
  844. .catch((err) => {
  845. console.error(err);
  846. });
  847. },
  848. },
  849. };
  850. </script>
  851. <style scoped>
  852. .dialog_diy>>>.el-dialog__header {
  853. background: #3d67bc !important;
  854. padding: 15px 20px;
  855. }
  856. .dialog_diy>>>.el-dialog__title {
  857. color: #fff;
  858. }
  859. .student_table>>>.el-table--border td {
  860. border-right: 0px !important;
  861. }
  862. .dialog_diy>>>.el-dialog__headerbtn {
  863. top: 19px;
  864. }
  865. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  866. color: #fff;
  867. }
  868. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  869. color: #fff;
  870. }
  871. .student_head>>>.el-button--primary {
  872. background-color: #2268bc;
  873. }
  874. .xls_button {
  875. font-size: 14px;
  876. cursor: pointer;
  877. text-decoration: underline;
  878. color: rgb(34, 104, 188);
  879. }
  880. .pb_head {
  881. margin: 0 !important;
  882. width: 100% !important;
  883. }
  884. .student_page {
  885. margin-top: 10px;
  886. }
  887. .student_head {
  888. margin-top: 10px;
  889. padding-bottom: 15px;
  890. display: flex;
  891. justify-content: space-between;
  892. }
  893. .student_search {
  894. display: flex;
  895. width: 300px;
  896. }
  897. .student_search span {
  898. margin: 0 10px 0 0;
  899. }
  900. .student_button {
  901. display: flex;
  902. height: 40px;
  903. }
  904. .student_button .el-button--primary {
  905. /* margin-right: 10px; */
  906. }
  907. .upload-demo {
  908. display: flex;
  909. flex-direction: column;
  910. align-items: end;
  911. /* position: relative; */
  912. width: 100px;
  913. overflow: hidden;
  914. }
  915. .student_table {
  916. margin: 20px 0;
  917. }
  918. .el-table>>>.even_row {
  919. background-color: #f1f1f1;
  920. }
  921. .top {
  922. display: flex;
  923. justify-content: space-between;
  924. }
  925. .bgColor {
  926. background: #2167bc;
  927. }
  928. .student_table>>>.el-table,
  929. .student_table>>>.el-table__body-wrapper {
  930. height: auto !important;
  931. }
  932. .student_head {
  933. margin-top: 10px;
  934. padding-bottom: 10px;
  935. display: flex;
  936. justify-content: space-between;
  937. }
  938. .head_left {
  939. display: flex;
  940. align-items: center;
  941. }
  942. .head_right {
  943. display: flex;
  944. flex-direction: row;
  945. flex-wrap: nowrap;
  946. align-items: baseline;
  947. }
  948. .student_input>>>.el-input__inner {
  949. width: 190px;
  950. font-size: 13px;
  951. padding: 0 10px;
  952. }
  953. .student_button {
  954. color: #fff;
  955. background: #2268bc;
  956. }
  957. .head_right>button:nth-child(1) {
  958. color: #fff;
  959. background: #2268bc;
  960. }
  961. .head_right>div {
  962. line-height: 40px;
  963. margin-left: 10px;
  964. color: #2a6dbe;
  965. text-decoration: underline;
  966. cursor: pointer;
  967. }
  968. .userImg {
  969. display: flex;
  970. flex-direction: row;
  971. justify-content: center;
  972. align-items: center;
  973. }
  974. .tx {
  975. width: 40px;
  976. margin-right: 10px;
  977. }
  978. .delete {
  979. width: 25px;
  980. height: 25px;
  981. cursor: pointer;
  982. margin-left: 10px;
  983. }
  984. .tx>img,
  985. .delete>img {
  986. width: 100%;
  987. height: 100%;
  988. }
  989. .btnBox {
  990. display: flex;
  991. align-items: center;
  992. }
  993. .add_student>>>.el-dialog__header {
  994. padding: 20px 20px 10px;
  995. text-align: center;
  996. background: #32455b;
  997. }
  998. .add_student>>>.el-dialog__title {
  999. font-size: 14px !important;
  1000. color: #fff !important;
  1001. }
  1002. .add_student>>>.el-dialog__headerbtn {
  1003. font-size: 20px !important;
  1004. }
  1005. .add_student>>>.el-form-item__label {
  1006. margin-left: 65px;
  1007. }
  1008. .add_student>>>.el-form-item {
  1009. display: flex;
  1010. }
  1011. .add_student>>>.el-form-item__content {
  1012. margin: 0 !important;
  1013. }
  1014. .add_input {
  1015. width: 365px;
  1016. }
  1017. .add_student>>>.el-dialog__footer {
  1018. text-align: center !important;
  1019. }
  1020. .right {
  1021. width: 250px;
  1022. color: #fff;
  1023. background: #0e72e6;
  1024. margin-bottom: 20px;
  1025. }
  1026. .header-title {
  1027. display: flex;
  1028. }
  1029. .logoImg {
  1030. width: 30px;
  1031. }
  1032. .logoImg>img {
  1033. width: 100%;
  1034. height: 100%;
  1035. }
  1036. .title_add_student {
  1037. margin: 0 auto;
  1038. color: #fff;
  1039. }
  1040. .upload-demo {
  1041. line-height: 0px !important;
  1042. }
  1043. .upload-demo>>>.el-button {
  1044. color: #fff;
  1045. background: #2268bc;
  1046. width: 70px;
  1047. height: 30px;
  1048. padding: 0 !important;
  1049. font-size: 12px;
  1050. line-height: 0 !important;
  1051. }
  1052. .people {
  1053. border: 1px solid rgb(229 229 229);
  1054. height: 495px;
  1055. border-radius: 5px;
  1056. width: 100%;
  1057. overflow: auto;
  1058. }
  1059. .people_top {
  1060. display: flex;
  1061. width: 100%;
  1062. /* justify-content: space-between; */
  1063. /* align-items: center; */
  1064. flex-direction: column;
  1065. padding: 10px 25px 0;
  1066. box-sizing: border-box;
  1067. }
  1068. .people_nav,
  1069. .people_top_right {
  1070. /* padding: 20px 0 0 20px; */
  1071. }
  1072. .people_top_right {
  1073. height: 40px;
  1074. margin-bottom: 10px;
  1075. }
  1076. .people_search {
  1077. display: flex;
  1078. position: relative;
  1079. }
  1080. .people_search>>>.el-input__inner {
  1081. /* height: 25px; */
  1082. width: 95%;
  1083. }
  1084. .search_img {
  1085. width: 20px;
  1086. height: 20px;
  1087. position: absolute;
  1088. right: 30px;
  1089. top: 50%;
  1090. transform: translateY(-50%);
  1091. }
  1092. .search_img>img {
  1093. width: 100%;
  1094. height: 100%;
  1095. }
  1096. .people_name {
  1097. display: flex;
  1098. justify-content: flex-start;
  1099. padding: 10px 0 0 25px;
  1100. flex-direction: column;
  1101. flex-wrap: nowrap;
  1102. height: calc(100% - 140px);
  1103. overflow-y: auto;
  1104. overflow-x: hidden;
  1105. flex-direction: column;
  1106. }
  1107. .people_name>>>.el-checkbox {
  1108. width: 100%;
  1109. display: flex;
  1110. align-items: center;
  1111. margin-bottom: 10px;
  1112. }
  1113. .people_name>>>.el-checkbox__label {
  1114. text-overflow: ellipsis;
  1115. overflow: hidden;
  1116. width: 100%;
  1117. }
  1118. .addNewPP>>>.el-dialog__body {
  1119. padding: 5px 20px;
  1120. }
  1121. .t_j_box {
  1122. display: flex;
  1123. }
  1124. .t_j_box span:nth-child(1) {
  1125. width: 50%;
  1126. overflow: hidden;
  1127. margin-right: 10px;
  1128. text-overflow: ellipsis;
  1129. white-space: nowrap;
  1130. }
  1131. .t_j_box span:nth-child(2) {
  1132. width: 50%;
  1133. overflow: hidden;
  1134. margin-right: 10px;
  1135. text-overflow: ellipsis;
  1136. white-space: nowrap;
  1137. }
  1138. </style>