index.vue 36 KB

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