course.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <div
  5. v-loading.body="fileLoading"
  6. element-loading-text="课程上传中,请稍后..."
  7. >
  8. <el-form
  9. inline
  10. :model="formSearch"
  11. label-width="70px"
  12. ref="primaryForm"
  13. >
  14. <el-form-item label="课程名称">
  15. <el-input
  16. class="input_width_lg"
  17. placeholder="请输入课程名称"
  18. v-model="formSearch.name"
  19. />
  20. </el-form-item>
  21. <el-form-item label="课程代码">
  22. <el-input
  23. class="input_width_lg"
  24. placeholder="请输入课程代码"
  25. v-model="formSearch.code"
  26. />
  27. </el-form-item>
  28. <el-form-item label="课程状态">
  29. <el-select
  30. class="input_width_lg"
  31. v-model="formSearch.enable"
  32. placeholder="请选择"
  33. clearable
  34. >
  35. <el-option
  36. v-for="item in statusList"
  37. :label="item.label"
  38. :value="item.value"
  39. :key="item.value"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="层次">
  44. <el-select
  45. class="input_width_lg"
  46. v-model="formSearch.level"
  47. placeholder="请选择"
  48. clearable
  49. >
  50. <el-option
  51. v-for="item in levelList"
  52. :label="item.label"
  53. :value="item.value"
  54. :key="item.value"
  55. />
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item label="专业" prop="specialtyId">
  59. <el-select
  60. class="input_width_lg"
  61. remote
  62. :remote-method="getSpecialtyList4Search"
  63. :loading="specialtyLoading4Search"
  64. filterable
  65. clearable
  66. v-model="formSearch.specialtyId"
  67. placeholder="请选择"
  68. >
  69. <el-option
  70. v-for="item in specialtyList4SearchWrapper"
  71. :label="item.name"
  72. :value="item.id"
  73. :key="item.id"
  74. />
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item class="d-block">
  78. <el-button
  79. size="small"
  80. type="primary"
  81. icon="el-icon-search"
  82. @click="handleSearchBtn"
  83. >查询</el-button
  84. >
  85. <el-button
  86. size="small"
  87. @click="resetPrimaryForm"
  88. icon="el-icon-refresh"
  89. >
  90. 重置
  91. </el-button>
  92. <el-button
  93. size="small"
  94. type="primary"
  95. icon="el-icon-plus"
  96. @click="insertCourse"
  97. >新增</el-button
  98. >
  99. </el-form-item>
  100. </el-form>
  101. <div class="block-seperator"></div>
  102. <span>操作:</span>
  103. <el-button
  104. size="small"
  105. type="success"
  106. @click="enableByIds"
  107. :disabled="noBatchSelected"
  108. icon="el-icon-check"
  109. >
  110. 启用
  111. </el-button>
  112. <el-button
  113. size="small"
  114. type="warning"
  115. @click="disableByIds"
  116. :disabled="noBatchSelected"
  117. icon="el-icon-close"
  118. >
  119. 禁用
  120. </el-button>
  121. <el-button
  122. size="small"
  123. type="primary"
  124. @click="impCourse"
  125. icon="el-icon-upload2"
  126. >
  127. 导入
  128. </el-button>
  129. <el-button
  130. size="small"
  131. type="primary"
  132. @click="exportCourse"
  133. icon="el-icon-download"
  134. >
  135. 导出
  136. </el-button>
  137. <div style="width: 100%;margin-bottom: 10px;"></div>
  138. <!-- 添加或新增课程弹出框 -->
  139. <el-dialog
  140. title="课程"
  141. width="420px"
  142. :visible.sync="courseDialog"
  143. @close="dialogBeforeClose"
  144. >
  145. <el-form
  146. :inline="true"
  147. inline-message
  148. :model="courseForm"
  149. ref="courseForm"
  150. :rules="rules"
  151. label-width="90px"
  152. >
  153. <el-row>
  154. <el-form-item label="课程代码" prop="code">
  155. <el-input
  156. :disabled="null != courseForm.id"
  157. class="pull_length"
  158. v-model="courseForm.code"
  159. auto-complete="off"
  160. placeholder="请输入课程代码"
  161. />
  162. </el-form-item>
  163. </el-row>
  164. <el-row>
  165. <el-form-item label="课程名称" prop="name">
  166. <el-input
  167. class="pull_length"
  168. v-model="courseForm.name"
  169. auto-complete="off"
  170. placeholder="请输入课程名称"
  171. />
  172. </el-form-item>
  173. </el-row>
  174. <el-row>
  175. <el-form-item label="层次" prop="level">
  176. <el-select
  177. class="pull_length"
  178. v-model="courseForm.level"
  179. placeholder="请选择"
  180. >
  181. <el-option
  182. v-for="item in levelList"
  183. :label="item.label"
  184. :value="item.value"
  185. :key="item.value"
  186. />
  187. </el-select>
  188. </el-form-item>
  189. </el-row>
  190. <el-row>
  191. <el-form-item label="课程状态" prop="enable">
  192. <el-radio-group class="pull_length" v-model="courseForm.enable">
  193. <el-radio label="true">开启</el-radio>
  194. <el-radio label="false">禁用</el-radio>
  195. </el-radio-group>
  196. </el-form-item>
  197. </el-row>
  198. <el-row class="pull-center">
  199. <el-button type="primary" @click="submitForm">保 存</el-button>
  200. <el-button @click="courseDialog = false">取 消</el-button>
  201. </el-row>
  202. </el-form>
  203. </el-dialog>
  204. <!-- 导入弹窗 -->
  205. <el-dialog title="导入窗口" width="420px" :visible.sync="impDialog">
  206. <el-form>
  207. <el-row>
  208. <el-form-item style="margin-left:20px">
  209. <el-upload
  210. class="form_left"
  211. ref="upload"
  212. accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  213. :action="uploadAction"
  214. :headers="uploadHeaders"
  215. :data="uploadData"
  216. :before-upload="beforeUpload"
  217. :on-progress="uploadProgress"
  218. :on-success="uploadSuccess"
  219. :on-error="uploadError"
  220. :file-list="fileList"
  221. :auto-upload="false"
  222. :multiple="false"
  223. >
  224. <el-button size="small" slot="trigger" type="primary">
  225. 选择文件
  226. </el-button>
  227. &nbsp;
  228. <el-button size="small" type="success" @click="submitUpload">
  229. 确认上传
  230. </el-button>
  231. <el-button size="small" type="danger" @click="removeFile">
  232. 清空文件
  233. </el-button>
  234. <el-button size="small" type="info" @click="exportFile">
  235. 下载模板
  236. </el-button>
  237. <div slot="tip" class="el-upload__tip">只能上传xlsx文件</div>
  238. </el-upload>
  239. </el-form-item>
  240. </el-row>
  241. </el-form>
  242. </el-dialog>
  243. <!-- 导入错误信息列表 -->
  244. <el-dialog title="错误提示" :visible.sync="errDialog">
  245. <div
  246. class="text-danger"
  247. v-for="errMessage in errMessages"
  248. :key="errMessage.lineNum"
  249. >
  250. 第{{ errMessage.lineNum }}行:{{ errMessage.msg }}
  251. </div>
  252. <span slot="footer" class="dialog-footer">
  253. <el-button @click="errDialog = false">确定</el-button>
  254. </span>
  255. </el-dialog>
  256. <!-- 关联专业弹出框 -->
  257. <el-dialog
  258. :title="specialtyDialogTitle"
  259. :visible.sync="specialtyDialog"
  260. width="800px"
  261. >
  262. <!-- 表单 -->
  263. <el-form :inline="true" :model="specialtySearchForm">
  264. <el-form-item label="专业名称">
  265. <el-input
  266. class="input_width_lg"
  267. placeholder="请输入专业名称"
  268. v-model="specialtySearchForm.name"
  269. />
  270. </el-form-item>
  271. <el-form-item label="专业代码">
  272. <el-input
  273. class="input_width_lg"
  274. placeholder="请输入专业代码"
  275. v-model="specialtySearchForm.code"
  276. />
  277. </el-form-item>
  278. <el-form-item>
  279. <el-button
  280. size="small"
  281. type="primary"
  282. icon="el-icon-search"
  283. @click="searchSpecialtyPage"
  284. >
  285. 查询
  286. </el-button>
  287. <el-button
  288. size="small"
  289. type="primary"
  290. icon="el-icon-plus"
  291. @click="addRelation"
  292. >
  293. 新增
  294. </el-button>
  295. </el-form-item>
  296. </el-form>
  297. <!-- 专业列表 -->
  298. <el-table :data="specialtyTableData" border>
  299. <el-table-column prop="id" label="ID" width="100" />
  300. <el-table-column prop="name" label="专业名称" width="250" />
  301. <el-table-column prop="code" label="专业代码" />
  302. <el-table-column prop="updateTime" label="更新时间" width="170" />
  303. <el-table-column label="操作">
  304. <div slot-scope="scope">
  305. <span>
  306. <el-button
  307. size="mini"
  308. type="primary"
  309. @click="deleteRelation(scope.row)"
  310. icon="el-icon-edit"
  311. plain
  312. >
  313. 取消关联
  314. </el-button>
  315. </span>
  316. </div>
  317. </el-table-column>
  318. </el-table>
  319. <div class="page pull-right">
  320. <el-pagination
  321. @current-change="handleSpecialtyCurrentChange"
  322. :current-page="currentSpecialtyPage"
  323. :page-size="10"
  324. :total="specialtyTotal"
  325. />
  326. </div>
  327. <div style="margin-bottom: 20px"></div>
  328. </el-dialog>
  329. <!-- 添加关联 -->
  330. <el-dialog
  331. title="添加关联专业"
  332. :visible.sync="addRelationDialog"
  333. width="420px"
  334. >
  335. <el-form
  336. :inline="true"
  337. inline-message
  338. :model="addRelationForm"
  339. ref="addRelationForm"
  340. label-width="100px"
  341. :rules="addRelationRules"
  342. >
  343. <el-row>
  344. <el-form-item label="专业" class="pull-left" prop="specialtyId">
  345. <el-select
  346. class="input"
  347. remote
  348. :remote-method="getSpecialtyList4AddRelation"
  349. :loading="specialtyLoading4AddRelation"
  350. filterable
  351. clearable
  352. v-model="addRelationForm.specialtyId"
  353. placeholder="请选择"
  354. >
  355. <el-option
  356. v-for="item in specialtyList4AddRelationWrapper"
  357. :label="item.name"
  358. :value="item.id"
  359. :key="item.id"
  360. />
  361. </el-select>
  362. </el-form-item>
  363. </el-row>
  364. <el-row class="d-flex justify-content-center">
  365. <el-button type="primary" @click="submitAddRelationForm">
  366. 保 存
  367. </el-button>
  368. <el-button @click="addRelationDialog = false">取 消</el-button>
  369. </el-row>
  370. </el-form>
  371. </el-dialog>
  372. <!-- 页面列表 -->
  373. <el-table
  374. :data="tableData"
  375. border
  376. resizable
  377. stripe
  378. @selection-change="selectChange"
  379. >
  380. <el-table-column type="selection" width="35" />
  381. <el-table-column prop="id" label="课程ID" width="80" />
  382. <el-table-column prop="name" label="课程名称" width="180" />
  383. <el-table-column prop="code" label="课程代码" />
  384. <el-table-column label="层次">
  385. <span slot-scope="scope">{{ getLevel(scope.row.level) }}</span>
  386. </el-table-column>
  387. <el-table-column width="50" label="状态">
  388. <span slot-scope="scope">
  389. <span v-if="scope.row.enable">
  390. <el-tooltip
  391. class="item"
  392. effect="dark"
  393. content="启用"
  394. placement="left"
  395. >
  396. <i class="el-icon-success" style="color:green;"></i>
  397. </el-tooltip>
  398. </span>
  399. <span v-else>
  400. <el-tooltip
  401. class="item"
  402. effect="dark"
  403. content="禁用"
  404. placement="left"
  405. >
  406. <i class="el-icon-error" style="color:red;"></i>
  407. </el-tooltip>
  408. </span>
  409. </span>
  410. </el-table-column>
  411. <el-table-column prop="updateTime" label="更新时间" width="170" />
  412. <el-table-column label="操作" width="290">
  413. <div slot-scope="scope">
  414. <el-button
  415. size="mini"
  416. type="primary"
  417. plain
  418. icon="el-icon-share"
  419. @click="relation(scope.row)"
  420. >
  421. 关联专业
  422. </el-button>
  423. <el-button
  424. size="mini"
  425. type="primary"
  426. plain
  427. @click="editCourse(scope.row)"
  428. >
  429. <i class="el-icon-edit"></i> 编辑
  430. </el-button>
  431. <el-button
  432. size="mini"
  433. v-if="!scope.row.enable"
  434. plain
  435. type="primary"
  436. @click="enableById(scope.row)"
  437. icon="el-icon-check"
  438. >
  439. 启用
  440. </el-button>
  441. <el-button
  442. size="mini"
  443. v-if="scope.row.enable"
  444. type="danger"
  445. @click="disableById(scope.row)"
  446. icon="el-icon-close"
  447. >
  448. 禁用
  449. </el-button>
  450. </div>
  451. </el-table-column>
  452. </el-table>
  453. <div class="page pull-right">
  454. <el-pagination
  455. @current-change="handleCurrentChange"
  456. :current-page="currentPage"
  457. :page-size="10"
  458. :page-sizes="[10, 20, 50, 100]"
  459. @size-change="handleSizeChange"
  460. layout="total, sizes, prev, pager, next, jumper"
  461. :total="total"
  462. >
  463. </el-pagination>
  464. </div>
  465. </div>
  466. </div>
  467. </section>
  468. </template>
  469. <script>
  470. import { CORE_API } from "@/constants/constants.js";
  471. import { ENABLE_TYPE, LEVEL_TYPE } from "../constants/constants.js";
  472. import { mapState } from "vuex";
  473. export default {
  474. name: "Course",
  475. data() {
  476. return {
  477. specialtyLoading4Search: false,
  478. specialtyList4Search: [],
  479. formSearch: {
  480. name: "",
  481. code: "",
  482. enable: "",
  483. level: "",
  484. specialtyId: ""
  485. },
  486. courseForm: {
  487. id: null,
  488. name: "",
  489. code: "",
  490. level: "ALL",
  491. enable: "true"
  492. },
  493. statusList: ENABLE_TYPE,
  494. levelList: LEVEL_TYPE,
  495. selectedCourseIds: [],
  496. tableData: [],
  497. currentPage: 1,
  498. pageSize: 10,
  499. total: 10,
  500. specialtyAllList: [],
  501. specialtyList: [],
  502. selectedSpecialtyList: [],
  503. specialtys: [],
  504. specialtyAll: [],
  505. impDialog: false,
  506. uploadAction: CORE_API + "/course/import",
  507. uploadHeaders: {},
  508. uploadData: {},
  509. errMessages: [],
  510. errDialog: false,
  511. fileLoading: false,
  512. fileList: [],
  513. courseDialog: false,
  514. relationDialog: false,
  515. rules: {
  516. name: [
  517. {
  518. required: true,
  519. message: "请输入课程名称",
  520. trigger: "blur"
  521. }
  522. ],
  523. code: [
  524. {
  525. required: true,
  526. message: "请输入课程代码",
  527. trigger: "blur"
  528. }
  529. ],
  530. level: [
  531. {
  532. required: true,
  533. message: "请选择层次",
  534. trigger: "change"
  535. }
  536. ],
  537. status: [
  538. {
  539. required: true,
  540. message: "请选择状态",
  541. trigger: "change"
  542. }
  543. ]
  544. },
  545. specialtyDialog: false,
  546. specialtyDialogTitle: null,
  547. specialtySearchForm: {
  548. courseId: null,
  549. code: "",
  550. name: ""
  551. },
  552. specialtyTableData: [],
  553. currentSpecialtyPage: 1,
  554. specialtyPageSize: 10,
  555. specialtyTotal: 10,
  556. addRelationDialog: false,
  557. addRelationForm: {
  558. specialtyId: null,
  559. courseId: null
  560. },
  561. specialtyLoading4AddRelation: false,
  562. specialtyList4AddRelation: [],
  563. addRelationRules: {
  564. specialtyId: [
  565. {
  566. required: true,
  567. type: "number",
  568. message: "请选择专业",
  569. trigger: "change"
  570. }
  571. ]
  572. }
  573. };
  574. },
  575. computed: {
  576. ...mapState({
  577. user: state => state.user
  578. }),
  579. noBatchSelected() {
  580. return this.selectedCourseIds.length === 0;
  581. },
  582. courseIds() {
  583. var courseIds = "";
  584. for (let courseId of this.selectedCourseIds) {
  585. if (!courseIds) {
  586. courseIds += courseId;
  587. } else {
  588. courseIds += "," + courseId;
  589. }
  590. }
  591. return courseIds;
  592. },
  593. specialtyAllListSelect() {
  594. let specialtyList = [];
  595. for (let specialty of this.specialtyAllList) {
  596. let specialtyInfo = specialty.name + "(" + specialty.code + ")";
  597. specialtyList.push({ id: specialty.id, specialtyInfo: specialtyInfo });
  598. }
  599. return specialtyList;
  600. },
  601. getSpecialtyAllSelect4Search() {
  602. let specialtyList4Search = [];
  603. for (let specialty of this.specialtys) {
  604. let specialtyInfo = specialty.name + "(" + specialty.code + ")";
  605. specialtyList4Search.push({
  606. id: specialty.id,
  607. specialtyInfo: specialtyInfo
  608. });
  609. }
  610. return specialtyList4Search;
  611. },
  612. specialtyList4SearchWrapper() {
  613. var specialtyList = [];
  614. for (let course of this.specialtyList4Search) {
  615. var name = course.name + " - " + course.code;
  616. var id = course.id;
  617. specialtyList.push({ id: id, name: name });
  618. }
  619. return specialtyList;
  620. },
  621. specialtyList4AddRelationWrapper() {
  622. var specialtyList = [];
  623. for (let course of this.specialtyList4AddRelation) {
  624. var name = course.name + " - " + course.code;
  625. var id = course.id;
  626. specialtyList.push({ id: id, name: name });
  627. }
  628. return specialtyList;
  629. }
  630. },
  631. methods: {
  632. handleSizeChange(val) {
  633. this.pageSize = val;
  634. this.currentPage = 1;
  635. this.searchForm();
  636. },
  637. dialogBeforeClose() {
  638. this.$refs.courseForm.clearValidate();
  639. },
  640. deleteRelation(row) {
  641. var specialtyId = row.id;
  642. var courseId = this.specialtySearchForm.courseId;
  643. var param = new URLSearchParams({
  644. courseId: courseId,
  645. specialtyId: specialtyId
  646. });
  647. var url = CORE_API + "/courseSpeciatlyRelation/delete?" + param;
  648. this.$http
  649. .delete(url)
  650. .then(() => {
  651. this.$notify({
  652. type: "success",
  653. message: "取消关联成功!"
  654. });
  655. this.searchSpecialtyPage();
  656. })
  657. .catch(response => {
  658. if (response.status == 500) {
  659. this.$notify({
  660. showClose: true,
  661. message: response.data.desc,
  662. type: "error"
  663. });
  664. }
  665. });
  666. },
  667. submitAddRelationForm() {
  668. this.$refs.addRelationForm.validate(valid => {
  669. if (valid) {
  670. var param = new URLSearchParams(this.addRelationForm);
  671. var url = CORE_API + "/courseSpeciatlyRelation/add?" + param;
  672. this.$http.post(url, this.speciallyForm).then(
  673. () => {
  674. this.$notify({
  675. type: "success",
  676. message: "添加成功!"
  677. });
  678. this.searchSpecialtyPage();
  679. this.addRelationDialog = false;
  680. },
  681. response => {
  682. if (response.status == 500) {
  683. this.$notify({
  684. showClose: true,
  685. message: response.data.desc,
  686. type: "error"
  687. });
  688. }
  689. }
  690. );
  691. } else {
  692. console.log("error submit!");
  693. return false;
  694. }
  695. });
  696. },
  697. getSpecialtyList4AddRelation(query) {
  698. this.specialtyLoading4AddRelation = true;
  699. this.$http
  700. .get(CORE_API + "/specialty/query?name=" + query)
  701. .then(response => {
  702. this.specialtyList4AddRelation = response.data;
  703. this.specialtyLoading4AddRelation = false;
  704. });
  705. },
  706. addRelation() {
  707. this.addRelationForm.specialtyId = null;
  708. this.addRelationForm.courseId = this.specialtySearchForm.courseId;
  709. this.addRelationDialog = true;
  710. if (this.$refs.addRelationForm) {
  711. this.$refs.addRelationForm.resetFields();
  712. }
  713. },
  714. handleSpecialtyCurrentChange(val) {
  715. this.currentSpecialtyPage = val;
  716. this.searchSpecialtyPage();
  717. },
  718. searchSpecialtyPage() {
  719. var param = new URLSearchParams(this.specialtySearchForm);
  720. var url =
  721. CORE_API +
  722. "/specialty/specialtyPage/" +
  723. (this.currentPage - 1) +
  724. "/" +
  725. this.pageSize +
  726. "?" +
  727. param;
  728. this.$http.get(url).then(response => {
  729. this.specialtyTableData = response.data.content;
  730. this.specialtyTotal = response.data.totalElements;
  731. });
  732. },
  733. getTag(status) {
  734. if (status == true) {
  735. return "success";
  736. } else if (status == false) {
  737. return "danger";
  738. }
  739. return status;
  740. },
  741. getLevel(level) {
  742. if (level == "ZSB") {
  743. return "专升本";
  744. } else if (level == "GQZ") {
  745. return "高起专";
  746. } else if (level == "GQB") {
  747. return "高起本";
  748. } else {
  749. return "不限";
  750. }
  751. },
  752. getSpecialtyList4Search(query) {
  753. this.specialtyLoading4Search = true;
  754. this.$http
  755. .get(CORE_API + "/specialty/query?name=" + query)
  756. .then(response => {
  757. this.specialtyList4Search = response.data;
  758. this.specialtyLoading4Search = false;
  759. });
  760. },
  761. handleSearchBtn() {
  762. this.currentPage = 1;
  763. this.searchForm();
  764. },
  765. searchForm() {
  766. var param = new URLSearchParams(this.formSearch);
  767. var url =
  768. CORE_API +
  769. "/course/coursePage/" +
  770. (this.currentPage - 1) +
  771. "/" +
  772. this.pageSize +
  773. "?" +
  774. param;
  775. this.$http.get(url).then(response => {
  776. this.tableData = response.data.content;
  777. this.total = response.data.totalElements;
  778. });
  779. },
  780. handleCurrentChange(val) {
  781. this.currentPage = val;
  782. this.searchForm();
  783. },
  784. selectChange(row) {
  785. this.selectedCourseIds = [];
  786. row.forEach(element => {
  787. this.selectedCourseIds.push(element.id);
  788. });
  789. console.log(this.selectedCourseIds);
  790. },
  791. //新增
  792. insertCourse() {
  793. this.courseForm.id = null;
  794. this.courseForm.name = null;
  795. this.courseForm.code = null;
  796. this.courseForm.level = "ALL";
  797. this.courseForm.enable = "true";
  798. this.courseDialog = true;
  799. },
  800. //修改
  801. editCourse(row) {
  802. this.courseForm = Object.assign({}, row);
  803. this.courseForm.enable = row.enable ? "true" : "false";
  804. this.courseId = row.id;
  805. this.courseDialog = true;
  806. },
  807. exportCourse() {
  808. var param = new URLSearchParams(this.formSearch);
  809. window.open(
  810. CORE_API +
  811. "/course/export?$key=" +
  812. this.user.key +
  813. "&$token=" +
  814. this.user.token +
  815. "&" +
  816. param
  817. );
  818. },
  819. //关联课程
  820. relation(row) {
  821. this.specialtyDialogTitle =
  822. "关联专业列表 【课程名称:" +
  823. row.name +
  824. "】【 课程代码:" +
  825. row.code +
  826. "】";
  827. this.specialtySearchForm.courseId = row.id;
  828. this.specialtySearchForm.name = "";
  829. this.specialtySearchForm.code = "";
  830. this.searchSpecialtyPage();
  831. this.specialtyDialog = true;
  832. },
  833. closeCourse() {
  834. this.courseDialog = false;
  835. },
  836. saveRelation() {},
  837. //保存(新增/修改)
  838. submitForm() {
  839. var url = CORE_API + "/course";
  840. if (null != this.courseForm.id) {
  841. //修改
  842. this.$refs.courseForm.validate(valid => {
  843. if (valid) {
  844. this.$http.put(url, this.courseForm).then(
  845. () => {
  846. this.$notify({
  847. type: "success",
  848. message: "修改成功!"
  849. });
  850. this.searchForm();
  851. this.resetForm();
  852. this.courseDialog = false;
  853. },
  854. response => {
  855. if (response.status == 500) {
  856. this.$notify({
  857. showClose: true,
  858. message: response.data.desc,
  859. type: "error"
  860. });
  861. }
  862. }
  863. );
  864. } else {
  865. console.log("error submit!");
  866. return false;
  867. }
  868. });
  869. } else {
  870. this.$refs.courseForm.validate(valid => {
  871. if (valid) {
  872. this.$http.post(url, this.courseForm).then(
  873. () => {
  874. this.$notify({
  875. type: "success",
  876. message: "添加成功"
  877. });
  878. this.searchForm();
  879. this.resetForm();
  880. this.courseDialog = false;
  881. },
  882. response => {
  883. if (response.status == 500) {
  884. this.$notify({
  885. showClose: true,
  886. message: response.data.desc,
  887. type: "error"
  888. });
  889. }
  890. }
  891. );
  892. } else {
  893. console.log("error submit!");
  894. return false;
  895. }
  896. });
  897. }
  898. },
  899. //重置
  900. resetForm() {
  901. this.$refs.courseForm.resetFields();
  902. },
  903. resetPrimaryForm() {
  904. this.formSearch = {
  905. name: "",
  906. code: "",
  907. enable: "",
  908. level: "",
  909. specialtyId: ""
  910. };
  911. this.$refs.primaryForm.resetFields();
  912. },
  913. //删除单个数据
  914. deleteById(row) {
  915. this.$confirm("是否删除该课程?", "提示", {
  916. confirmButtonText: "确定",
  917. cancelButtonText: "取消",
  918. type: "warning"
  919. }).then(() => {
  920. var url = CORE_API + "/course/" + row.id;
  921. this.$http
  922. .delete(url)
  923. .then(() => {
  924. this.$notify({
  925. type: "success",
  926. message: "删除成功!"
  927. });
  928. this.searchForm();
  929. })
  930. .catch(response => {
  931. if (response.status == 500) {
  932. this.$notify({
  933. showClose: true,
  934. message: response.data.desc,
  935. type: "error"
  936. });
  937. }
  938. });
  939. });
  940. },
  941. //删除多条数据
  942. deleteByIds() {
  943. if (this.selectedCourseIds.length === 0) {
  944. this.$notify({
  945. type: "warning",
  946. message: "请选择要删除的课程"
  947. });
  948. } else {
  949. this.$confirm("是否删除这些课程?", "提示", {
  950. confirmButtonText: "确定",
  951. cancelButtonText: "取消",
  952. type: "error"
  953. }).then(() => {
  954. var url = CORE_API + "/course/" + this.courseIds;
  955. this.$http
  956. .delete(url)
  957. .then(() => {
  958. this.$notify({
  959. type: "success",
  960. message: "删除成功!"
  961. });
  962. this.searchForm();
  963. })
  964. .catch(response => {
  965. if (response.status == 500) {
  966. this.$notify({
  967. showClose: true,
  968. message: response.data.desc,
  969. type: "error"
  970. });
  971. }
  972. });
  973. });
  974. }
  975. },
  976. //启用
  977. enableByIds() {
  978. if (this.selectedCourseIds.length === 0) {
  979. this.$notify({
  980. type: "warning",
  981. message: "请选择要开启的课程"
  982. });
  983. } else {
  984. this.$confirm("是否启用这些课程?", "提示", {
  985. confirmButtonText: "确定",
  986. cancelButtonText: "取消",
  987. type: "warning"
  988. }).then(() => {
  989. var url = CORE_API + "/course/enable/" + this.courseIds;
  990. this.$http
  991. .put(url, {})
  992. .then(() => {
  993. this.$notify({
  994. type: "success",
  995. message: "开启成功!"
  996. });
  997. this.searchForm();
  998. })
  999. .catch(response => {
  1000. if (response.status == 500) {
  1001. this.$notify({
  1002. showClose: true,
  1003. message: response.data.desc,
  1004. type: "error"
  1005. });
  1006. }
  1007. });
  1008. });
  1009. }
  1010. },
  1011. enableById(row) {
  1012. this.$confirm("是否启用该课程?", "提示", {
  1013. confirmButtonText: "确定",
  1014. cancelButtonText: "取消",
  1015. type: "warning"
  1016. }).then(() => {
  1017. var url = CORE_API + "/course/enable/" + row.id;
  1018. this.$http
  1019. .put(url, {})
  1020. .then(() => {
  1021. this.$notify({
  1022. type: "success",
  1023. message: "开启成功!"
  1024. });
  1025. this.searchForm();
  1026. })
  1027. .catch(response => {
  1028. if (response.status == 500) {
  1029. this.$notify({
  1030. showClose: true,
  1031. message: response.data.desc,
  1032. type: "error"
  1033. });
  1034. }
  1035. });
  1036. });
  1037. },
  1038. //禁用
  1039. disableByIds() {
  1040. if (this.selectedCourseIds.length === 0) {
  1041. this.$notify({
  1042. type: "warning",
  1043. message: "请选择要禁用的课程"
  1044. });
  1045. } else {
  1046. this.$confirm("是否禁用这些课程?", "提示", {
  1047. confirmButtonText: "确定",
  1048. cancelButtonText: "取消",
  1049. type: "error"
  1050. }).then(() => {
  1051. var url = CORE_API + "/course/disable/" + this.courseIds;
  1052. this.$http
  1053. .put(url, {})
  1054. .then(() => {
  1055. this.$notify({
  1056. type: "success",
  1057. message: "禁用成功!"
  1058. });
  1059. this.searchForm();
  1060. })
  1061. .catch(response => {
  1062. if (response.status == 500) {
  1063. this.$notify({
  1064. showClose: true,
  1065. message: response.data.desc,
  1066. type: "error"
  1067. });
  1068. }
  1069. });
  1070. });
  1071. }
  1072. },
  1073. //禁用
  1074. disableById(row) {
  1075. this.$confirm("是否禁用该课程?", "提示", {
  1076. confirmButtonText: "确定",
  1077. cancelButtonText: "取消",
  1078. type: "error"
  1079. }).then(() => {
  1080. var url = CORE_API + "/course/disable/" + row.id;
  1081. this.$http
  1082. .put(url, {})
  1083. .then(() => {
  1084. this.$notify({
  1085. type: "success",
  1086. message: "禁用成功!"
  1087. });
  1088. this.searchForm();
  1089. })
  1090. .catch(response => {
  1091. if (response.status == 500) {
  1092. this.$notify({
  1093. showClose: true,
  1094. message: response.data.desc,
  1095. type: "error"
  1096. });
  1097. }
  1098. });
  1099. });
  1100. },
  1101. //导入
  1102. impCourse() {
  1103. this.impDialog = true;
  1104. this.initUpload();
  1105. },
  1106. initUpload() {
  1107. this.fileList = [];
  1108. },
  1109. beforeUpload(file) {
  1110. console.log(file);
  1111. },
  1112. uploadProgress() {
  1113. console.log("uploadProgress");
  1114. },
  1115. uploadSuccess(response) {
  1116. if (!response.hasError) {
  1117. this.$notify({
  1118. message: "上传成功",
  1119. type: "success"
  1120. });
  1121. this.fileLoading = false;
  1122. this.impDialog = false;
  1123. this.searchForm();
  1124. } else {
  1125. this.fileLoading = false;
  1126. this.impDialog = false;
  1127. this.errMessages = response.failRecords;
  1128. this.errDialog = true;
  1129. }
  1130. },
  1131. uploadError(response) {
  1132. var json = JSON.parse(response.message);
  1133. if (response.status == 500) {
  1134. this.$notify({
  1135. message: json.desc,
  1136. type: "error"
  1137. });
  1138. }
  1139. this.fileLoading = false;
  1140. },
  1141. //确定上传
  1142. submitUpload() {
  1143. if (!this.checkUpload()) {
  1144. return false;
  1145. }
  1146. this.$refs.upload.submit();
  1147. this.fileLoading = true;
  1148. },
  1149. checkUpload() {
  1150. var fileList = this.$refs.upload.uploadFiles;
  1151. if (fileList.length == 0) {
  1152. this.$notify({
  1153. message: "上传文件不能为空",
  1154. type: "error"
  1155. });
  1156. return false;
  1157. }
  1158. if (fileList.length > 1) {
  1159. this.$notify({
  1160. message: "每次只能上传一个文件",
  1161. type: "error"
  1162. });
  1163. return false;
  1164. }
  1165. for (let file of fileList) {
  1166. if (!file.name.endsWith(".xlsx")) {
  1167. this.$notify({
  1168. message: "上传文件必须为xlsx格式",
  1169. type: "error"
  1170. });
  1171. this.initUpload();
  1172. return false;
  1173. }
  1174. }
  1175. return true;
  1176. },
  1177. //清空文件
  1178. removeFile() {
  1179. // this.fileList = [];
  1180. this.$refs.upload.clearFiles();
  1181. },
  1182. //下载模板
  1183. exportFile() {
  1184. window.location.href =
  1185. CORE_API +
  1186. "/course/importTemplate?$key=" +
  1187. this.user.key +
  1188. "&$token=" +
  1189. this.user.token;
  1190. }
  1191. },
  1192. //初始化查询
  1193. created() {
  1194. this.searchForm();
  1195. this.uploadHeaders = {
  1196. key: this.user.key,
  1197. token: this.user.token
  1198. };
  1199. }
  1200. };
  1201. </script>
  1202. <style scoped>
  1203. .input_width_lg {
  1204. width: 180px;
  1205. }
  1206. .pull_length {
  1207. width: 180px;
  1208. }
  1209. .pull-center {
  1210. margin-left: 30%;
  1211. }
  1212. </style>