index.vue 35 KB

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