index.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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. 注:添加学生的账号密码为123456
  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. 注:添加学生的账号密码为123456
  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="getClassStudent"></el-input>
  271. <div class="search_img" @click="getClassStudent">
  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.getClassStudent();
  564. },
  565. //新增学生
  566. insertStudent() {
  567. if (this.sName === "") {
  568. this.$message.error("学生姓名不能为空");
  569. return;
  570. } else if (
  571. this.sPhone != "" &&
  572. !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.sPhone)
  573. ) {
  574. this.$message.error("手机号格式不正确");
  575. return;
  576. } else if (
  577. !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.sMail)
  578. ) {
  579. this.$message.error("邮箱格式不正确");
  580. return;
  581. }
  582. if (this.time()) {
  583. let params = { un: this.sMail };
  584. this.ajax
  585. .get(this.$store.state.api + "findMail", params)
  586. .then((res) => {
  587. if (res.data[0].length > 0) {
  588. this.$message.error("此学生账号已被注册");
  589. } else {
  590. this.add_Student();
  591. }
  592. })
  593. .catch((err) => {
  594. console.error(err);
  595. });
  596. }
  597. },
  598. add_Student() {
  599. let params = [
  600. {
  601. username: this.sMail,
  602. userpassword: 123456,
  603. alias: this.sName,
  604. oid: this.oid,
  605. ph: this.sPhone,
  606. sid: this.sId,
  607. cid: this.cid,
  608. },
  609. ];
  610. this.ajax
  611. .post(this.$store.state.api + "batchRegistration", params)
  612. .then((res) => {
  613. let params = [
  614. {
  615. userid: res.data.uid,
  616. username: this.sName,
  617. sid: this.sId,
  618. type: 2,
  619. oid: res.data.oid,
  620. phone: res.data.ph,
  621. cid: res.data.cid,
  622. intro: "",
  623. sex: "0",
  624. },
  625. ];
  626. this.ajax
  627. .post(this.$store.state.api + "updateUserByEdu", params)
  628. .then((res) => {
  629. console.log(res);
  630. })
  631. .catch((err) => {
  632. console.error(err);
  633. });
  634. this.$message({
  635. message: "新增成功",
  636. type: "success",
  637. });
  638. this.dialogVisibleAddStudent = false;
  639. this.sPhone = "";
  640. this.sName = "";
  641. this.sByClass = [];
  642. this.sMail = "";
  643. this.getStudent(this.cid);
  644. })
  645. .catch((err) => {
  646. this.isLoading = false;
  647. this.$message({
  648. message: "新增失败",
  649. type: "error",
  650. });
  651. console.error(err);
  652. });
  653. },
  654. updateStudentA(res) {
  655. this.userinfo = JSON.parse(JSON.stringify(res));
  656. this.userinfoA = JSON.parse(JSON.stringify(res));
  657. this.userinfo.classid = this.userinfo.classid.split(",");
  658. this.dialogVisibleUpdate = true;
  659. },
  660. updateStudent() {
  661. if (this.userinfo.name === "") {
  662. this.$message.error("学生姓名不能为空");
  663. return;
  664. } else if (!this.userinfo.classid) {
  665. this.$message.error("请为学生选择年级");
  666. return;
  667. } else if (
  668. this.userinfo.phonenumber &&
  669. !/^[1][3,4,5,7,8][0-9]{9}$/.test(this.userinfo.phonenumber)
  670. ) {
  671. this.$message.error("手机号格式不正确");
  672. return;
  673. } else if (
  674. !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(
  675. this.userinfo.un
  676. )
  677. ) {
  678. this.$message.error("邮箱格式不正确");
  679. return;
  680. }
  681. if (this.time()) {
  682. if (this.userinfoA.un != this.userinfo.un) {
  683. let params = { un: this.userinfo.un };
  684. this.ajax
  685. .get(this.$store.state.api + "findMail", params)
  686. .then((res) => {
  687. if (res.data[0].length > 0) {
  688. this.$message.error("此学生账号已被注册");
  689. } else {
  690. this.update_Student();
  691. }
  692. })
  693. .catch((err) => {
  694. console.error(err);
  695. });
  696. } else {
  697. this.update_Student();
  698. }
  699. }
  700. },
  701. update_Student() {
  702. let params = [
  703. {
  704. userid: this.userinfo.userid,
  705. username: this.userinfo.un,
  706. alias: this.userinfo.name,
  707. ph: this.userinfo.phonenumber,
  708. sid: this.userinfo.studentid,
  709. cid: this.userinfo.classid.join(","),
  710. },
  711. ];
  712. this.ajax
  713. .post(this.$store.state.api + "updateStudentInfo", params)
  714. .then((res) => {
  715. this.$message({
  716. message: "修改成功",
  717. type: "success",
  718. });
  719. this.dialogVisibleUpdate = false;
  720. this.getStudent(this.cid);
  721. })
  722. .catch((err) => {
  723. this.isLoading = false;
  724. this.$message({
  725. message: "修改失败",
  726. type: "error",
  727. });
  728. console.error(err);
  729. });
  730. },
  731. deleteClassStudent(id) {
  732. let params = [{ uid: id, cid: this.cid }];
  733. this.$confirm("确定在本年级移除此班级吗?", "提示", {
  734. confirmButtonText: "确定",
  735. cancelButtonText: "取消",
  736. type: "warning",
  737. })
  738. .then(() => {
  739. this.ajax
  740. .post(this.$store.state.api + "deleteGradeClass", params)
  741. .then((res) => {
  742. this.$message({
  743. message: "操作成功",
  744. type: "success",
  745. });
  746. this.getStudent(this.cid);
  747. })
  748. .catch((err) => {
  749. this.$message.error("操作失败");
  750. console.error(err);
  751. });
  752. })
  753. .catch(() => { });
  754. },
  755. //获取班级列表
  756. getClass2() {
  757. this.isLoading = true;
  758. let params = {
  759. oid: this.oid,
  760. };
  761. this.ajax
  762. .get(this.$store.state.api + "selectGrageBySchool", params)
  763. .then((res) => {
  764. this.isLoading = false;
  765. this.classJuri = res.data[0];
  766. })
  767. .catch((err) => {
  768. this.isLoading = false;
  769. console.error(err);
  770. });
  771. },
  772. getSchoolName() {
  773. let params = {
  774. oid: this.oid,
  775. };
  776. this.ajax
  777. .get(this.$store.state.api + "selectSchoolName2", params)
  778. .then((res) => {
  779. this.schoolName = res.data[0][0].name;
  780. })
  781. .catch((err) => {
  782. console.error(err);
  783. });
  784. },
  785. searchStudent() {
  786. this.page2 = 1;
  787. this.getStudent(this.cid);
  788. },
  789. handleCurrentChange2(val) {
  790. this.page2 = val;
  791. this.getStudent(this.cid);
  792. },
  793. handleCurrentChange3(val) {
  794. this.page3 = val;
  795. this.getClassStudent();
  796. },
  797. getStudent(cid) {
  798. this.cid = cid;
  799. this.ctype = 2;
  800. this.isLoading = true;
  801. let params = {
  802. cid: this.cid,
  803. oid: this.oid,
  804. cn: this.sPhoneUser,
  805. page: this.page2,
  806. };
  807. this.ajax
  808. .get(this.$store.state.api + "selectClass2", params)
  809. .then((res) => {
  810. this.isLoading = false;
  811. this.total2 = res.data[0].length > 0 ? res.data[0][0].num : 0;
  812. this.tableData2 = res.data[0];
  813. this.getClass2();
  814. })
  815. .catch((err) => {
  816. this.isLoading = false;
  817. console.error(err);
  818. });
  819. },
  820. getClassStudent() {
  821. this.isLoading2 = true;
  822. let params = {
  823. oid: this.oid,
  824. cid: this.cid,
  825. cn: this.searchTN,
  826. page: this.page3,
  827. num: this.pageSize3,
  828. };
  829. this.ajax
  830. .get(this.$store.state.api + "getGradeClass", params)
  831. .then((res) => {
  832. this.isLoading2 = false;
  833. this.total3 = res.data[0].length > 0 ? res.data[0][0].num : 0;
  834. this.teacherJuri = res.data[0];
  835. })
  836. .catch((err) => {
  837. this.isLoading2 = false;
  838. console.error(err);
  839. });
  840. },
  841. addClassStudent() {
  842. if (!this.checkboxList3.length) {
  843. this.$message.error("请选择要添加的班级");
  844. return;
  845. }
  846. let params = [
  847. {
  848. cid: this.cid,
  849. student: JSON.stringify(this.checkboxList3),
  850. },
  851. ];
  852. this.ajax
  853. .post(this.$store.state.api + "addGradeClass", params)
  854. .then((res) => {
  855. this.checkboxList3 = [];
  856. this.dialogVisibleMember = false;
  857. this.getStudent(this.cid);
  858. })
  859. .catch((err) => {
  860. console.error(err);
  861. });
  862. },
  863. iniPassword(id) {
  864. this.$confirm("确定" + "初始化" + "此学生的密码吗?", "提示", {
  865. confirmButtonText: "确定",
  866. cancelButtonText: "取消",
  867. type: "warning",
  868. })
  869. .then(() => {
  870. let params = [
  871. {
  872. uid: id,
  873. pa: 123456,
  874. },
  875. ];
  876. this.ajax
  877. .post(this.$store.state.api + "iniPassword", params)
  878. .then((res) => {
  879. this.$message({
  880. message: "初始化密码成功!",
  881. type: "success",
  882. });
  883. })
  884. .catch((err) => {
  885. console.error(err);
  886. });
  887. })
  888. .catch(() => { });
  889. },
  890. },
  891. };
  892. </script>
  893. <style scoped>
  894. .dialog_diy>>>.el-dialog__header {
  895. background: #3d67bc !important;
  896. padding: 15px 20px;
  897. }
  898. .dialog_diy>>>.el-dialog__title {
  899. color: #fff;
  900. }
  901. .student_table>>>.el-table--border td {
  902. border-right: 0px !important;
  903. }
  904. .dialog_diy>>>.el-dialog__headerbtn {
  905. top: 19px;
  906. }
  907. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  908. color: #fff;
  909. }
  910. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  911. color: #fff;
  912. }
  913. .student_head>>>.el-button--primary {
  914. background-color: #2268bc;
  915. }
  916. .xls_button {
  917. font-size: 14px;
  918. cursor: pointer;
  919. text-decoration: underline;
  920. color: rgb(34, 104, 188);
  921. }
  922. .pb_head {
  923. margin: 0 !important;
  924. width: 100% !important;
  925. }
  926. .student_page {
  927. margin-top: 10px;
  928. display: flex;
  929. justify-content: flex-end;
  930. }
  931. .student_head {
  932. margin-top: 10px;
  933. padding-bottom: 15px;
  934. display: flex;
  935. justify-content: space-between;
  936. }
  937. .student_search {
  938. display: flex;
  939. align-items: center;
  940. width: 300px;
  941. line-height: 40px;
  942. }
  943. .student_search span {
  944. /* margin: 0 10px 0 0; */
  945. }
  946. .student_button {
  947. /* display: flex; */
  948. /* height: 40px; */
  949. }
  950. .student_button .el-button--primary {
  951. /* margin-right: 10px; */
  952. }
  953. .upload-demo {
  954. display: flex;
  955. flex-direction: column;
  956. align-items: end;
  957. /* position: relative; */
  958. width: 100px;
  959. overflow: hidden;
  960. }
  961. .student_table {
  962. /* margin: 20px 0; */
  963. }
  964. .el-table>>>.even_row {
  965. background-color: #f1f1f1;
  966. }
  967. .top {
  968. display: flex;
  969. justify-content: space-between;
  970. }
  971. .bgColor {
  972. background: #2167bc;
  973. }
  974. .student_table>>>.el-table,
  975. .student_table>>>.el-table__body-wrapper {
  976. height: auto !important;
  977. }
  978. .student_head {
  979. margin-top: 10px;
  980. padding-bottom: 10px;
  981. display: flex;
  982. justify-content: space-between;
  983. }
  984. .head_left {
  985. display: flex;
  986. align-items: center;
  987. line-height: 40px;
  988. }
  989. .head_right {
  990. display: flex;
  991. flex-direction: row;
  992. flex-wrap: nowrap;
  993. align-items: center;
  994. line-height: 40px;
  995. }
  996. /* .student_input >>> .el-input__inner {
  997. width: 190px;
  998. font-size: 13px;
  999. padding: 0 10px;
  1000. } */
  1001. .student_button {
  1002. color: #fff;
  1003. background: #2268bc;
  1004. }
  1005. .head_right>button:nth-child(1) {
  1006. color: #fff;
  1007. background: #2268bc;
  1008. }
  1009. .head_right>div {
  1010. line-height: 40px;
  1011. margin-left: 10px;
  1012. color: #2a6dbe;
  1013. text-decoration: underline;
  1014. cursor: pointer;
  1015. }
  1016. .userImg {
  1017. display: flex;
  1018. flex-direction: row;
  1019. justify-content: center;
  1020. align-items: center;
  1021. }
  1022. .tx {
  1023. width: 40px;
  1024. margin-right: 10px;
  1025. }
  1026. .delete {
  1027. width: 25px;
  1028. height: 25px;
  1029. cursor: pointer;
  1030. margin-left: 10px;
  1031. }
  1032. .tx>img,
  1033. .delete>img {
  1034. width: 100%;
  1035. height: 100%;
  1036. }
  1037. .btnBox {
  1038. display: flex;
  1039. align-items: center;
  1040. }
  1041. .add_student>>>.el-dialog__header {
  1042. padding: 20px 20px 10px;
  1043. text-align: center;
  1044. background: #32455b;
  1045. }
  1046. .add_student>>>.el-dialog__title {
  1047. font-size: 14px !important;
  1048. color: #fff !important;
  1049. }
  1050. .add_student>>>.el-dialog__headerbtn {
  1051. font-size: 20px !important;
  1052. }
  1053. .add_student>>>.el-form-item__label {
  1054. margin-left: 65px;
  1055. }
  1056. .add_student>>>.el-form-item {
  1057. display: flex;
  1058. }
  1059. .add_student>>>.el-form-item__content {
  1060. margin: 0 !important;
  1061. }
  1062. .add_input {
  1063. width: 365px;
  1064. }
  1065. .add_student>>>.el-dialog__footer {
  1066. text-align: center !important;
  1067. }
  1068. .right {
  1069. width: 250px;
  1070. color: #fff;
  1071. background: #0e72e6;
  1072. margin-bottom: 20px;
  1073. }
  1074. .header-title {
  1075. display: flex;
  1076. }
  1077. .logoImg {
  1078. width: 30px;
  1079. }
  1080. .logoImg>img {
  1081. width: 100%;
  1082. height: 100%;
  1083. }
  1084. .title_add_student {
  1085. margin: 0 auto;
  1086. color: #fff;
  1087. }
  1088. .upload-demo {
  1089. line-height: 0px !important;
  1090. }
  1091. .upload-demo>>>.el-button {
  1092. color: #fff;
  1093. background: #2268bc;
  1094. width: 70px;
  1095. height: 30px;
  1096. padding: 0 !important;
  1097. font-size: 12px;
  1098. line-height: 0 !important;
  1099. }
  1100. .people {
  1101. border: 1px solid rgb(229 229 229);
  1102. height: 450px;
  1103. border-radius: 5px;
  1104. width: 100%;
  1105. overflow: auto;
  1106. }
  1107. .people_top {
  1108. display: flex;
  1109. width: 100%;
  1110. /* justify-content: space-between; */
  1111. /* align-items: center; */
  1112. flex-direction: column;
  1113. padding: 10px 25px 0;
  1114. box-sizing: border-box;
  1115. }
  1116. .people_nav,
  1117. .people_top_right {
  1118. /* padding: 20px 0 0 20px; */
  1119. }
  1120. .people_top_right {
  1121. height: 40px;
  1122. margin-bottom: 10px;
  1123. }
  1124. .people_search {
  1125. display: flex;
  1126. position: relative;
  1127. }
  1128. .people_search>>>.el-input__inner {
  1129. /* height: 25px; */
  1130. width: 95%;
  1131. }
  1132. .search_img {
  1133. width: 20px;
  1134. height: 20px;
  1135. position: absolute;
  1136. right: 30px;
  1137. top: 50%;
  1138. transform: translateY(-50%);
  1139. }
  1140. .search_img>img {
  1141. width: 100%;
  1142. height: 100%;
  1143. }
  1144. .people_name {
  1145. display: flex;
  1146. justify-content: flex-start;
  1147. padding: 10px 0 0 25px;
  1148. flex-direction: column;
  1149. flex-wrap: nowrap;
  1150. height: calc(100% - 140px);
  1151. overflow-y: auto;
  1152. overflow-x: hidden;
  1153. flex-direction: column;
  1154. }
  1155. .people_name>>>.el-checkbox {
  1156. width: 100%;
  1157. display: flex;
  1158. align-items: center;
  1159. margin-bottom: 10px;
  1160. }
  1161. .people_name>>>.el-checkbox__label {
  1162. text-overflow: ellipsis;
  1163. overflow: hidden;
  1164. width: 100%;
  1165. }
  1166. .addNewPP>>>.el-dialog {
  1167. margin-top: 5vh !important;
  1168. }
  1169. .addNewPP>>>.el-dialog__body {
  1170. padding: 5px 20px;
  1171. }
  1172. .t_j_box {
  1173. display: flex;
  1174. }
  1175. .t_j_box span:nth-child(1) {
  1176. width: 100%;
  1177. overflow: hidden;
  1178. margin-right: 10px;
  1179. text-overflow: ellipsis;
  1180. white-space: nowrap;
  1181. }
  1182. .t_j_box span:nth-child(2) {
  1183. width: 50%;
  1184. overflow: hidden;
  1185. margin-right: 10px;
  1186. text-overflow: ellipsis;
  1187. white-space: nowrap;
  1188. }
  1189. .student_input>>>.el-input__inner {
  1190. height: 30px;
  1191. width: 190px;
  1192. font-size: 13px;
  1193. padding: 0 10px;
  1194. }
  1195. .student_input.el-input {
  1196. width: auto;
  1197. }
  1198. .student_input {
  1199. margin-right: 10px;
  1200. }
  1201. .student_input>>>.el-input__icon {
  1202. line-height: unset;
  1203. }
  1204. .student_button {
  1205. color: #fff;
  1206. background: #2268bc;
  1207. width: 60px;
  1208. height: 30px;
  1209. padding: 0 !important;
  1210. font-size: 12px;
  1211. line-height: 30px;
  1212. }
  1213. .sub_head {
  1214. position: relative;
  1215. }
  1216. .sub_head::after {
  1217. content: "";
  1218. width: 100%;
  1219. background: #5a9cea;
  1220. height: 2px;
  1221. position: absolute;
  1222. left: 0;
  1223. bottom: -10px;
  1224. }
  1225. .subClick {
  1226. /* font-size: 16px; */
  1227. font-size: 26px;
  1228. cursor: pointer;
  1229. /* margin-left: 17.5px; */
  1230. /* color: #ab582f; */
  1231. /* color: #409eff; */
  1232. color: #999;
  1233. }
  1234. .subClick:hover {
  1235. color: #000;
  1236. }
  1237. .sub_head+.subClick,
  1238. .subClick+.subClick,
  1239. .subClick+.sub_head {
  1240. margin-left: 17.5px;
  1241. }
  1242. .pb_content_body {
  1243. width: 100% !important;
  1244. }
  1245. .sm_box {
  1246. display: flex;
  1247. width: calc(100% - 20px);
  1248. margin: 0 auto;
  1249. }
  1250. .sm_right {
  1251. width: calc(100% - 210px);
  1252. margin-left: 210px;
  1253. }
  1254. .sm_left {
  1255. width: 200px;
  1256. background: #fff;
  1257. height: calc(100vh - 20px);
  1258. position: fixed;
  1259. left: 10px;
  1260. top: 10px;
  1261. border-radius: 5px;
  1262. }
  1263. .nav {
  1264. height: 55px;
  1265. display: flex;
  1266. align-items: center;
  1267. justify-content: center;
  1268. cursor: pointer;
  1269. color: #777777;
  1270. transition: all .5s;
  1271. }
  1272. .nav:hover {
  1273. background: rgb(204, 204, 204);
  1274. }
  1275. .nav.active {
  1276. background: #3d67bc !important;
  1277. color: #fff;
  1278. }
  1279. .nav .icon {
  1280. width: 16px;
  1281. height: 16px;
  1282. margin-right: 5px;
  1283. background-size: 100% 100%;
  1284. }
  1285. .nav .name {}
  1286. .nav .icon.gradeI {
  1287. background-image: url(../../../../assets/icon/studentManage/grade.png);
  1288. }
  1289. .nav .icon.classI {
  1290. background-image: url(../../../../assets/icon/studentManage/class.png);
  1291. }
  1292. .nav .icon.studentI {
  1293. background-image: url(../../../../assets/icon/studentManage/student.png);
  1294. }
  1295. .nav.active .icon.gradeI {
  1296. background-image: url(../../../../assets/icon/studentManage/grade-a.png);
  1297. }
  1298. .nav.active .icon.classI {
  1299. background-image: url(../../../../assets/icon/studentManage/class-a.png);
  1300. }
  1301. .nav.active .icon.studentI {
  1302. background-image: url(../../../../assets/icon/studentManage/student-a.png);
  1303. }
  1304. </style>