student.vue 26 KB

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