student.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <!-- 正文信息 -->
  5. <div class="box-body">
  6. <el-form
  7. :model="formSearch"
  8. :inline="true"
  9. ref="formSearch"
  10. label-width="100px"
  11. >
  12. <el-form-item v-if="isSuperAdmin" label="顶级机构">
  13. <el-select
  14. v-model="formSearch.rootOrgId"
  15. placeholder="请选择"
  16. class="input"
  17. >
  18. <el-option
  19. v-for="item in rootOrgList"
  20. :label="item.name"
  21. :value="item.id"
  22. :key="item.id"
  23. >
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="姓名">
  28. <el-input
  29. placeholder="请输入姓名"
  30. v-model="formSearch.name"
  31. class="input"
  32. ></el-input>
  33. </el-form-item>
  34. <el-form-item label="学号">
  35. <el-input
  36. placeholder="请输入学号"
  37. v-model="formSearch.studentCode"
  38. class="input"
  39. ></el-input>
  40. </el-form-item>
  41. <el-form-item label="身份证">
  42. <el-input
  43. placeholder="请输入身份证"
  44. v-model="formSearch.identityNumber"
  45. class="input"
  46. ></el-input>
  47. </el-form-item>
  48. <el-form-item label="是否上传照片">
  49. <el-select v-model="formSearch.hasPhoto" class="input">
  50. <el-option label="未选择" value="ALL"> </el-option>
  51. <el-option label="是" value="TRUE"> </el-option>
  52. <el-option label="否" value="FALSE"> </el-option>
  53. </el-select>
  54. </el-form-item>
  55. <el-form-item class="d-block">
  56. <el-button
  57. v-if="rolePrivileges.search_student"
  58. size="small"
  59. type="primary"
  60. icon="el-icon-search"
  61. @click="searchForm"
  62. >查询
  63. </el-button>
  64. <el-button size="small" @click="resetSearchForm"> 重置 </el-button>
  65. <el-button
  66. v-if="rolePrivileges.upload_student_photo"
  67. size="small"
  68. type="info"
  69. @click="uploadPhoto"
  70. >上传照片
  71. </el-button>
  72. <el-button size="small" type="primary" @click="exportStudent">
  73. <i class="fa fa-download" aria-hidden="true"></i>导出
  74. </el-button>
  75. </el-form-item>
  76. </el-form>
  77. <div class="block-seperator"></div>
  78. <span>批量操作:</span>
  79. <el-button
  80. v-if="rolePrivileges.reset_student_password"
  81. size="small"
  82. type="warning"
  83. :disabled="noBatchSelected"
  84. @click="resetPassword('')"
  85. >重置密码
  86. </el-button>
  87. <el-button
  88. v-if="rolePrivileges.change_student_availability"
  89. size="small"
  90. type="success"
  91. :disabled="noBatchSelected"
  92. @click="enableStudent('')"
  93. >
  94. <i class="fa fa-check" aria-hidden="true"></i>启用
  95. </el-button>
  96. <el-button
  97. v-if="rolePrivileges.change_student_availability"
  98. size="small"
  99. type="danger"
  100. :disabled="noBatchSelected"
  101. @click="disableStudent('')"
  102. >
  103. <i class="fa fa-close" aria-hidden="true"></i>禁用
  104. </el-button>
  105. <div style="width: 100%;margin-bottom: 10px;"></div>
  106. <!-- 页面列表 -->
  107. <el-table
  108. :data="tableData"
  109. border
  110. style="width: 100%;text-align:center;"
  111. @selection-change="selectChange"
  112. >
  113. <el-table-column type="selection" width="50"></el-table-column>
  114. <el-table-column prop="id" width="100" label="ID"></el-table-column>
  115. <el-table-column label="考生" width="100">
  116. <template slot-scope="scope">
  117. <el-popover trigger="hover" placement="left">
  118. <div style="font-size: 18px;font-family: 新宋体">
  119. <tr>
  120. <td style="color: green">姓名</td>
  121. <td style="color:purple;padding-left: 20px;">
  122. {{ scope.row.name }}
  123. </td>
  124. </tr>
  125. <tr>
  126. <td style="color: green">身份证号</td>
  127. <td style="color:purple;padding-left: 20px;">
  128. {{ scope.row.identityNumber }}
  129. </td>
  130. </tr>
  131. <tr>
  132. <td style="color: green">学号</td>
  133. <td style="color:purple;padding-left: 20px;">
  134. {{ scope.row.studentCode }}
  135. </td>
  136. </tr>
  137. <tr>
  138. <td style="color: green">学习中心</td>
  139. <td style="color:purple;padding-left: 20px;">
  140. {{ scope.row.orgName }}
  141. </td>
  142. </tr>
  143. <tr>
  144. <td style="color: green">手机号</td>
  145. <td style="color:purple;padding-left: 20px;">
  146. {{ scope.row.phoneNumber }}
  147. </td>
  148. </tr>
  149. <tr>
  150. <td style="color: green">安全手机号</td>
  151. <td style="color:purple;padding-left: 20px;">
  152. {{ scope.row.securityPhone }}
  153. </td>
  154. </tr>
  155. <tr>
  156. <td style="color: green">创建时间</td>
  157. <td style="color:purple;padding-left: 20px;">
  158. {{ scope.row.creationTime }}
  159. </td>
  160. </tr>
  161. </div>
  162. <div slot="reference" class="name-wrapper">
  163. <span>{{ scope.row.name }}</span>
  164. </div>
  165. </el-popover>
  166. </template>
  167. </el-table-column>
  168. <el-table-column
  169. prop="studentCode"
  170. width=""
  171. label="学号"
  172. ></el-table-column>
  173. <el-table-column
  174. prop="identityNumber"
  175. width=""
  176. label="身份证"
  177. ></el-table-column>
  178. <el-table-column
  179. prop="updateTime"
  180. width="168"
  181. label="更新时间"
  182. ></el-table-column>
  183. <el-table-column width="50" label="状态">
  184. <span slot-scope="scope">
  185. <span v-if="scope.row.enable">
  186. <el-tooltip
  187. class="item"
  188. effect="dark"
  189. content="启用"
  190. placement="left"
  191. >
  192. <i class="el-icon-success" style="color:green;"></i>
  193. </el-tooltip>
  194. </span>
  195. <span v-else>
  196. <el-tooltip
  197. class="item"
  198. effect="dark"
  199. content="禁用"
  200. placement="left"
  201. >
  202. <i class="el-icon-success" style="color:red;"></i>
  203. </el-tooltip>
  204. </span>
  205. </span>
  206. </el-table-column>
  207. <el-table-column label="操作" width="260">
  208. <div slot-scope="scope">
  209. <el-button
  210. :disabled="!scope.row.photoPath"
  211. size="mini"
  212. type="info"
  213. plain
  214. @click="showPhoto(scope.row)"
  215. ><i class="fa fa-check" aria-hidden="true"></i>查看照片
  216. </el-button>
  217. <el-button
  218. v-if="
  219. null != scope.row.enable &&
  220. !scope.row.enable &&
  221. rolePrivileges.change_student_availability
  222. "
  223. size="mini"
  224. type="danger"
  225. plain
  226. @click="enableStudent(scope.row)"
  227. >
  228. <i class="fa fa-check" aria-hidden="true"></i>启用
  229. </el-button>
  230. <el-button
  231. v-else-if="rolePrivileges.change_student_availability"
  232. size="mini"
  233. type="info"
  234. plain
  235. @click="disableStudent(scope.row)"
  236. >
  237. <i class="fa fa-close" aria-hidden="true"></i>禁用
  238. </el-button>
  239. <el-dropdown style="margin-left: 10px;">
  240. <el-button type="primary" plain size="mini">
  241. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  242. </el-button>
  243. <el-dropdown-menu slot="dropdown">
  244. <el-dropdown-item
  245. v-if="rolePrivileges.reset_student_password"
  246. >
  247. <el-button
  248. size="mini"
  249. type="warning"
  250. plain
  251. @click="resetPassword(scope.row)"
  252. >重置密码
  253. </el-button>
  254. </el-dropdown-item>
  255. <el-dropdown-item>
  256. <el-button
  257. size="mini"
  258. type="info"
  259. plain
  260. @click="showStuExamDialog(scope.row)"
  261. >考试记录
  262. </el-button>
  263. </el-dropdown-item>
  264. <el-dropdown-item v-if="rolePrivileges.unbind_student_code">
  265. <el-button
  266. size="mini"
  267. type="warning"
  268. plain
  269. @click="unbindStudentCode(scope.row)"
  270. >解绑学号
  271. </el-button>
  272. </el-dropdown-item>
  273. <el-dropdown-item v-if="rolePrivileges.unbind_security_phone">
  274. <el-button
  275. size="mini"
  276. type="warning"
  277. plain
  278. @click="unbindSecurityPhone(scope.row)"
  279. >解绑安全手机
  280. </el-button>
  281. </el-dropdown-item>
  282. </el-dropdown-menu>
  283. </el-dropdown>
  284. </div>
  285. </el-table-column>
  286. </el-table>
  287. <div class="page pull-right">
  288. <el-pagination
  289. @current-change="handleCurrentChange"
  290. :current-page="currentPage"
  291. :page-size="pageSize"
  292. :page-sizes="[10, 20, 50, 100]"
  293. @size-change="handleSizeChange"
  294. layout="total, sizes, prev, pager, next, jumper"
  295. :total="total"
  296. >
  297. </el-pagination>
  298. </div>
  299. <!-- 考试记录 -->
  300. <el-dialog
  301. title="学生考试记录"
  302. width="60%"
  303. :visible.sync="stuExamDialog"
  304. v-loading="stuExamLoading"
  305. element-loading-text="拼命加载中"
  306. >
  307. <el-form
  308. :inline="true"
  309. :model="stuExamSearch"
  310. label-position="right"
  311. label-width="50px"
  312. >
  313. <el-form-item label="考试" class="pull-left">
  314. <el-select
  315. class="input"
  316. :remote-method="queryExams4Search"
  317. remote
  318. :loading="queryExams4SearchLoading"
  319. filterable
  320. clearable
  321. v-model="stuExamSearch.examId"
  322. placeholder="请选择"
  323. >
  324. <el-option
  325. v-for="item in examList4Search"
  326. :label="item.name"
  327. :value="item.id"
  328. :key="item.id"
  329. >
  330. </el-option>
  331. </el-select>
  332. </el-form-item>
  333. <el-form-item class="pull-left">
  334. <el-button
  335. size="small"
  336. type="primary"
  337. icon="el-icon-search"
  338. @click="searchStuExam"
  339. >查询
  340. </el-button>
  341. </el-form-item>
  342. </el-form>
  343. <el-table
  344. :data="stuExamList"
  345. border
  346. style="width: 100%;text-align:center;"
  347. >
  348. <el-table-column prop="studentName" label="学生姓名">
  349. </el-table-column>
  350. <el-table-column prop="studentCode" label="学号"> </el-table-column>
  351. <el-table-column prop="identityNumber" label="身份证">
  352. </el-table-column>
  353. <el-table-column prop="examName" label="考试"> </el-table-column>
  354. <el-table-column prop="courseName" label="课程"> </el-table-column>
  355. <el-table-column width="80" label="考试状态">
  356. <div slot-scope="scope">
  357. <span v-if="null == scope.row.started"></span>
  358. <span v-else-if="scope.row.started">已考</span>
  359. <span v-else>未考</span>
  360. </div>
  361. </el-table-column>
  362. </el-table>
  363. <div class="page pull-right">
  364. <el-pagination
  365. @current-change="stuExamCurChange"
  366. :current-page="stuExamCurPage"
  367. :page-size="stuExamPageSize"
  368. :page-sizes="[10, 20, 50, 100]"
  369. @size-change="handleStuExamSizeChange"
  370. layout="total, sizes, prev, pager, next, jumper"
  371. :total="stuExamTotal"
  372. >
  373. </el-pagination>
  374. </div>
  375. <div style="margin-top: 10px;"></div>
  376. </el-dialog>
  377. <!-- 导入照片弹窗 -->
  378. <el-dialog
  379. title="学生照片导入页"
  380. width="500px"
  381. :visible.sync="photoUploadDialog"
  382. >
  383. <el-form>
  384. <el-row>
  385. <el-form-item style="margin-left:30px">
  386. <el-upload
  387. class="form_left"
  388. ref="upload"
  389. list-type="picture"
  390. :action="uploadAction"
  391. :headers="uploadHeaders"
  392. :data="uploadData"
  393. :before-upload="beforeUpload"
  394. :on-progress="uploadProgress"
  395. :on-success="uploadSuccess"
  396. :on-error="uploadError"
  397. :file-list="fileList"
  398. :auto-upload="false"
  399. :multiple="false"
  400. >
  401. <el-button size="small" slot="trigger" type="primary"
  402. >选择文件
  403. </el-button>
  404. <el-button
  405. size="small"
  406. style="margin-left:10px;"
  407. type="success"
  408. @click="submitUpload"
  409. >确认上传
  410. </el-button>
  411. <div slot="tip" class="el-upload__tip">
  412. 只能上传jpg,png文件
  413. </div>
  414. </el-upload>
  415. </el-form-item>
  416. </el-row>
  417. </el-form>
  418. </el-dialog>
  419. <!--查看照片-->
  420. <el-dialog
  421. title="照片"
  422. :visible.sync="photoDialog"
  423. width="300px"
  424. :center="true"
  425. >
  426. <img :src="photo.url" alt="学生照片" height="100%" width="100%" />
  427. </el-dialog>
  428. </div>
  429. </div>
  430. </section>
  431. </template>
  432. <script>
  433. import {
  434. CORE_API,
  435. EXAM_WORK_API,
  436. EXCHANGE_API
  437. } from "@/constants/constants.js";
  438. import { mapState } from "vuex";
  439. export default {
  440. data() {
  441. return {
  442. rolePrivileges: {
  443. search_student: false,
  444. upload_student_photo: false,
  445. reset_student_password: false,
  446. change_student_availability: false,
  447. unbind_student_code: false,
  448. unbind_security_phone: false
  449. },
  450. isSuperAdmin: false,
  451. rootOrgList: null,
  452. stuExamLoading: false,
  453. button: {},
  454. formSearch: {
  455. rootOrgId: null,
  456. name: "",
  457. studentCode: "",
  458. identityNumber: "",
  459. enable: "",
  460. hasPhoto: "ALL"
  461. },
  462. selectedStuIds: [],
  463. statusList: [
  464. {
  465. value: true,
  466. label: "启用"
  467. },
  468. {
  469. value: false,
  470. label: "禁用"
  471. }
  472. ],
  473. tableData: [],
  474. currentPage: 1,
  475. pageSize: 10,
  476. total: 10,
  477. photoDialog: false,
  478. photo: { url: "" },
  479. errMessages: [],
  480. uploadAction: EXCHANGE_API + "/facepp/add",
  481. uploadData: {},
  482. fileLoading: false,
  483. fileList: [],
  484. uploadHeaders: {},
  485. photoUploadDialog: false,
  486. stuExamCurPage: 1,
  487. stuExamPageSize: 10,
  488. stuExamTotal: 10,
  489. stuExamDialog: false,
  490. stuExamList: [],
  491. examList4Search: [],
  492. queryExams4SearchLoading: false,
  493. stuExamSearch: {
  494. rootOrgId: "",
  495. examId: "",
  496. studentCode: "",
  497. studentName: "",
  498. orgId: "",
  499. specialtyName: "",
  500. courseCode: "",
  501. courseName: "",
  502. infoCollector: "",
  503. identityNumber: "",
  504. identityNumberLike: false,
  505. withStarted: true
  506. }
  507. };
  508. },
  509. computed: {
  510. ...mapState({ user: state => state.user }),
  511. stuIds() {
  512. var stuIds = "";
  513. for (let stuId of this.selectedStuIds) {
  514. if (!stuIds) {
  515. stuIds += stuId;
  516. } else {
  517. stuIds += "," + stuId;
  518. }
  519. }
  520. return stuIds;
  521. },
  522. noBatchSelected() {
  523. return this.selectedStuIds.length === 0;
  524. }
  525. },
  526. methods: {
  527. queryExams4Search(name) {
  528. this.queryExams(name, "search");
  529. },
  530. queryExams(name, where) {
  531. console.log("queryExams; name: " + name);
  532. if ("search" == where) {
  533. this.queryExams4SearchLoading = true;
  534. }
  535. this.$http
  536. .get(EXAM_WORK_API + "/exam/queryByNameLike?name=" + name)
  537. .then(response => {
  538. if ("search" == where) {
  539. this.queryExams4SearchLoading = false;
  540. this.examList4Search = response.body;
  541. }
  542. })
  543. .catch(response => {
  544. if (response.status == 500) {
  545. this.$notify({
  546. showClose: true,
  547. message: response.body.desc,
  548. type: "error"
  549. });
  550. }
  551. if ("search" == where) {
  552. this.queryExams4SearchLoading = false;
  553. }
  554. });
  555. },
  556. closeStuExamDialog() {
  557. this.stuExamDialog = false;
  558. },
  559. showStuExamDialog(row) {
  560. this.stuExamSearch.identityNumber = row.identityNumber;
  561. this.stuExamSearch.rootOrgId = row.rootOrgId;
  562. this.stuExamList = [];
  563. this.stuExamTotal = 0;
  564. this.searchStuExam();
  565. this.stuExamDialog = true;
  566. },
  567. searchStuExam() {
  568. var param = new URLSearchParams(this.stuExamSearch);
  569. this.stuExamLoading = true;
  570. var url =
  571. EXAM_WORK_API +
  572. "/exam_student/examStudentPage/" +
  573. (this.stuExamCurPage - 1) +
  574. "/" +
  575. this.stuExamPageSize +
  576. "?" +
  577. param;
  578. this.$http
  579. .get(url)
  580. .then(response => {
  581. this.stuExamList = response.data.list;
  582. this.stuExamTotal = response.data.total;
  583. this.stuExamLoading = false;
  584. })
  585. .catch(function(response) {
  586. console.log(response);
  587. this.stuExamLoading = false;
  588. });
  589. },
  590. stuExamCurChange(val) {
  591. this.stuExamCurPage = val;
  592. this.searchStuExam();
  593. },
  594. handleStuExamSizeChange(val) {
  595. this.stuExamPageSize = val;
  596. this.searchStuExam();
  597. },
  598. showPhoto(row) {
  599. if (row.photoPath) {
  600. this.photo.url = row.photoPath;
  601. this.photoDialog = true;
  602. } else {
  603. this.$notify({
  604. showClose: true,
  605. message: "未上传照片",
  606. type: "error"
  607. });
  608. }
  609. },
  610. uploadPhoto() {
  611. this.photoUploadDialog = true;
  612. this.initUpload();
  613. },
  614. selectChange(row) {
  615. this.selectedStuIds = [];
  616. row.forEach((element, index) => {
  617. console.log(index);
  618. this.selectedStuIds.push(element.id);
  619. });
  620. console.log(this.selectedStuIds);
  621. },
  622. handleCurrentChange(val) {
  623. this.currentPage = val;
  624. this.searchForm();
  625. },
  626. handleSizeChange(val) {
  627. this.pageSize = val;
  628. this.searchForm();
  629. },
  630. resetSearchForm() {
  631. this.formSearch.name = "";
  632. this.formSearch.studentCode = "";
  633. this.formSearch.identityNumber = "";
  634. this.formSearch.enable = "";
  635. this.formSearch.hasPhoto = "ALL";
  636. },
  637. //查询方法
  638. searchForm() {
  639. var param = new URLSearchParams(this.formSearch);
  640. var url =
  641. CORE_API +
  642. "/student/studentPage/" +
  643. (this.currentPage - 1) +
  644. "/" +
  645. this.pageSize +
  646. "?" +
  647. param;
  648. this.$http
  649. .get(url)
  650. .then(response => {
  651. this.tableData = response.data.list;
  652. this.total = response.data.total;
  653. })
  654. .catch(function(response) {
  655. if (response.status == 500) {
  656. this.$notify({
  657. showClose: true,
  658. message: response.body.desc,
  659. type: "error"
  660. });
  661. }
  662. });
  663. },
  664. exportStudent() {
  665. var param = new URLSearchParams(this.formSearch);
  666. window.open(
  667. CORE_API +
  668. "/student/export?$key=" +
  669. this.user.key +
  670. "&$token=" +
  671. this.user.token +
  672. "&" +
  673. param
  674. );
  675. },
  676. checkIds(row) {
  677. if (row) {
  678. return row.id;
  679. } else {
  680. if (this.stuIds.length == 0) {
  681. this.$notify({
  682. type: "warning",
  683. message: "请选择学生"
  684. });
  685. return "";
  686. } else {
  687. return this.stuIds;
  688. }
  689. }
  690. },
  691. unbindStudentCode(row) {
  692. var stuIds = this.checkIds(row);
  693. if (!stuIds) return;
  694. this.$confirm("是否解绑学号?", "提示", {
  695. confirmButtonText: "确定",
  696. cancelButtonText: "取消",
  697. type: "warning"
  698. }).then(() => {
  699. var url = CORE_API + "/student/unbindStudentCode/" + stuIds;
  700. this.$http.put(url).then(response => {
  701. console.log(response);
  702. this.$notify({
  703. type: "success",
  704. message: "解绑成功"
  705. });
  706. this.searchForm();
  707. });
  708. });
  709. },
  710. unbindSecurityPhone(row) {
  711. var stuIds = this.checkIds(row);
  712. if (!stuIds) return;
  713. this.$confirm("是否解绑安全手机号?", "提示", {
  714. confirmButtonText: "确定",
  715. cancelButtonText: "取消",
  716. type: "warning"
  717. }).then(() => {
  718. var url = CORE_API + "/student/unbindSecurityPhone/" + stuIds;
  719. this.$http.put(url).then(response => {
  720. console.log(response);
  721. this.$notify({
  722. type: "success",
  723. message: "解绑成功"
  724. });
  725. this.searchForm();
  726. });
  727. });
  728. },
  729. //重置密码方法
  730. resetPassword(row) {
  731. var stuIds = this.checkIds(row);
  732. if (!stuIds) return;
  733. this.$confirm("是否重置所选学生的密码?", "提示", {
  734. confirmButtonText: "确定",
  735. cancelButtonText: "取消",
  736. type: "warning"
  737. }).then(() => {
  738. var url = CORE_API + "/student/resetPass/" + stuIds;
  739. this.$http.put(url).then(response => {
  740. console.log(response);
  741. this.$notify({
  742. type: "success",
  743. message: "重置密码成功"
  744. });
  745. this.searchForm();
  746. });
  747. });
  748. },
  749. //禁用
  750. disableStudent(row) {
  751. var stuIds = this.checkIds(row);
  752. if (!stuIds) return;
  753. this.$confirm("是否禁用所选学生?", "提示", {
  754. confirmButtonText: "确定",
  755. cancelButtonText: "取消",
  756. type: "warning"
  757. }).then(() => {
  758. var url = CORE_API + "/student/disable/" + stuIds;
  759. this.$http.put(url).then(response => {
  760. console.log(response);
  761. this.$notify({
  762. type: "success",
  763. message: "禁用成功"
  764. });
  765. this.searchForm();
  766. });
  767. });
  768. },
  769. //启用
  770. enableStudent(row) {
  771. var stuIds = this.checkIds(row);
  772. if (!stuIds) return;
  773. this.$confirm("是否启用所选学生?", "提示", {
  774. confirmButtonText: "确定",
  775. cancelButtonText: "取消",
  776. type: "warning"
  777. }).then(() => {
  778. var url = CORE_API + "/student/enable/" + stuIds;
  779. this.$http.put(url).then(response => {
  780. console.log(response);
  781. this.$notify({
  782. type: "success",
  783. message: "启用成功"
  784. });
  785. this.searchForm();
  786. });
  787. });
  788. },
  789. beforeUpload(file) {
  790. console.log(file);
  791. },
  792. uploadProgress(event, file, fileList) {
  793. console.log("uploadProgress");
  794. console.log(event);
  795. console.log(file);
  796. console.log(fileList);
  797. },
  798. uploadSuccess(response, file, fileList) {
  799. console.log(response);
  800. console.log(file);
  801. console.log(fileList);
  802. this.$notify({
  803. message: "上传成功",
  804. type: "success"
  805. });
  806. this.fileLoading = false;
  807. this.photoUploadDialog = false;
  808. this.searchForm();
  809. },
  810. uploadError(response, file, fileList) {
  811. console.log(response);
  812. console.log(file);
  813. console.log(fileList);
  814. var json = JSON.parse(response.message);
  815. if (response.status == 500) {
  816. this.$notify({
  817. message: json.desc,
  818. type: "error"
  819. });
  820. }
  821. this.fileLoading = false;
  822. },
  823. initUpload() {
  824. this.fileList = [];
  825. },
  826. checkUpload() {
  827. var fileList = this.$refs.upload.uploadFiles;
  828. if (fileList.length == 0) {
  829. this.$notify({
  830. message: "上传文件不能为空",
  831. type: "error"
  832. });
  833. return false;
  834. }
  835. if (fileList.length > 1) {
  836. this.$notify({
  837. message: "每次只能上传一个文件",
  838. type: "error"
  839. });
  840. return false;
  841. }
  842. for (let file of fileList) {
  843. let f = file.name.toLowerCase();
  844. if (!f.endsWith(".jpg") && !f.endsWith(".png")) {
  845. this.$notify({
  846. message: "上传文件必须为jpg或者png格式",
  847. type: "error"
  848. });
  849. this.initUpload();
  850. return false;
  851. }
  852. }
  853. return true;
  854. },
  855. //确定上传
  856. submitUpload() {
  857. if (!this.checkUpload()) {
  858. return false;
  859. }
  860. this.$refs.upload.submit();
  861. this.fileLoading = true;
  862. },
  863. //清空文件
  864. removeFile() {
  865. this.$refs.upload.clearFiles();
  866. },
  867. initPrivileges() {
  868. let params = new URLSearchParams({
  869. privilegeCodes: Object.keys(this.rolePrivileges).toString()
  870. });
  871. let url = CORE_API + "/rolePrivilege/checkPrivileges?" + params;
  872. this.$http.post(url).then(response => {
  873. this.rolePrivileges = response.data;
  874. });
  875. },
  876. init() {
  877. this.initPrivileges();
  878. for (let role of this.user.roleList) {
  879. if (role.roleCode == "SUPER_ADMIN") {
  880. this.isSuperAdmin = true;
  881. break;
  882. }
  883. }
  884. var url = CORE_API + "/org/getRootOrgList";
  885. this.$http.get(url).then(response => {
  886. this.rootOrgList = response.data;
  887. this.formSearch.rootOrgId = this.user.rootOrgId;
  888. this.searchForm();
  889. });
  890. }
  891. },
  892. created() {
  893. this.init();
  894. this.uploadHeaders = {
  895. key: this.user.key,
  896. token: this.user.token
  897. };
  898. }
  899. };
  900. </script>
  901. <style scoped>
  902. .input {
  903. width: 180px;
  904. }
  905. </style>