specially.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. <template>
  2. <section class="content">
  3. <div class="box-body">
  4. <el-form :inline="true" :model="formSearch" ref="primaryForm">
  5. <el-row>
  6. <el-form-item label="专业名称">
  7. <el-input
  8. class="input_width_lg"
  9. placeholder="请输入专业名称"
  10. v-model="formSearch.name"
  11. />
  12. </el-form-item>
  13. <el-form-item label="专业代码">
  14. <el-input
  15. class="input_width_lg"
  16. placeholder="请输入专业代码"
  17. v-model="formSearch.code"
  18. />
  19. </el-form-item>
  20. <el-form-item label="课程">
  21. <el-select
  22. class="input"
  23. :remote-method="getCourses"
  24. :loading="courseLoading"
  25. remote
  26. filterable
  27. clearable
  28. v-model="formSearch.courseId"
  29. placeholder="请选择"
  30. >
  31. <el-option
  32. v-for="item in courseList4SearchWrapper"
  33. :label="item.name"
  34. :value="item.id"
  35. :key="item.id"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button
  41. size="small"
  42. type="primary"
  43. icon="el-icon-search"
  44. @click="handleSearchBtn"
  45. >
  46. 查询
  47. </el-button>
  48. <el-button
  49. size="small"
  50. @click="resetPrimaryForm"
  51. icon="el-icon-refresh"
  52. >
  53. 重置
  54. </el-button>
  55. <el-button
  56. size="small"
  57. type="primary"
  58. icon="el-icon-plus"
  59. @click="insert"
  60. >
  61. 新增
  62. </el-button>
  63. </el-form-item>
  64. </el-row>
  65. </el-form>
  66. <div class="block-seperator"></div>
  67. <span>操作:</span>
  68. <el-button
  69. size="small"
  70. type="danger"
  71. @click="deleteIds"
  72. :disabled="noBatchSelected"
  73. icon="el-icon-delete"
  74. >
  75. 删除
  76. </el-button>
  77. <el-button
  78. size="small"
  79. type="primary"
  80. @click="impSpecialty"
  81. icon="el-icon-upload2"
  82. >
  83. 导入
  84. </el-button>
  85. <el-button
  86. size="small"
  87. type="primary"
  88. @click="exportSpeciatly"
  89. icon="el-icon-download"
  90. >
  91. 导出
  92. </el-button>
  93. <div style="width: 100%;margin-bottom: 10px;"></div>
  94. <!-- 新增或修改弹出框 -->
  95. <el-dialog
  96. title="专业信息"
  97. width="450px"
  98. :visible.sync="speciallyDialog"
  99. @close="dialogBeforeClose"
  100. >
  101. <el-form
  102. :inline="true"
  103. inline-message
  104. :model="speciallyForm"
  105. ref="speciallyForm"
  106. :rules="rules"
  107. label-position="right"
  108. label-width="90px"
  109. >
  110. <el-form-item label="专业代码" prop="code">
  111. <el-input
  112. :disabled="null != speciallyForm.id"
  113. class="pull_length"
  114. v-model="speciallyForm.code"
  115. auto-complete="off"
  116. placeholder="专业代码"
  117. maxlength="100"
  118. />
  119. </el-form-item>
  120. <el-form-item label="专业名称" prop="name">
  121. <el-input
  122. class="pull_length"
  123. v-model="speciallyForm.name"
  124. auto-complete="off"
  125. placeholder="专业名称"
  126. maxlength="100"
  127. />
  128. </el-form-item>
  129. <el-row class="pull_center">
  130. <el-button type="primary" @click="submitForm('speciallyForm')">
  131. 保 存
  132. </el-button>
  133. <el-button @click="close">取 消</el-button>
  134. </el-row>
  135. </el-form>
  136. </el-dialog>
  137. <!-- 关联课程弹出框 -->
  138. <el-dialog
  139. :title="courseDialogTitle"
  140. width="740px"
  141. :visible.sync="courseDialog"
  142. >
  143. <!-- 表单 -->
  144. <el-form :inline="true" :model="courseSearchForm">
  145. <el-row>
  146. <el-form-item label="课程名称" class="pull-left">
  147. <el-input
  148. class="input_width_lg"
  149. placeholder="请输入课程名称"
  150. v-model="courseSearchForm.name"
  151. />
  152. </el-form-item>
  153. <el-form-item label="课程代码" class="pull-left">
  154. <el-input
  155. class="input_width_lg"
  156. placeholder="请输入课程代码"
  157. v-model="courseSearchForm.code"
  158. />
  159. </el-form-item>
  160. <el-form-item class="pull-right">
  161. <el-button
  162. size="small"
  163. type="primary"
  164. icon="el-icon-search"
  165. @click="searchCoursePage"
  166. >
  167. 查询
  168. </el-button>
  169. <el-button
  170. size="small"
  171. type="primary"
  172. icon="el-icon-plus"
  173. @click="addRelation"
  174. >
  175. 新增
  176. </el-button>
  177. </el-form-item>
  178. </el-row>
  179. </el-form>
  180. <!-- 课程列表 -->
  181. <el-table :data="courseTableData" border resizable stripe>
  182. <el-table-column prop="id" label="ID" width="60" />
  183. <el-table-column prop="name" label="课程名称" width="220" />
  184. <el-table-column prop="code" label="课程代码" />
  185. <el-table-column prop="updateTime" label="更新时间" width="170" />
  186. <el-table-column label="操作" width="120">
  187. <span slot-scope="scope">
  188. <el-button
  189. size="mini"
  190. type="primary"
  191. @click="deleteRelation(scope.row)"
  192. icon="el-icon-edit"
  193. >
  194. 取消关联
  195. </el-button>
  196. </span>
  197. </el-table-column>
  198. </el-table>
  199. <div class="page pull-right">
  200. <el-pagination
  201. @current-change="handleCourseCurrentChange"
  202. :current-page="currentCoursePage"
  203. :page-size="10"
  204. layout="total, prev, pager, next, jumper"
  205. :total="courseTotal"
  206. />
  207. </div>
  208. </el-dialog>
  209. <!-- 添加关联 -->
  210. <el-dialog
  211. title="添加关联课程"
  212. width="500px"
  213. :visible.sync="addRelationDialog"
  214. >
  215. <el-form
  216. :inline="true"
  217. :model="addRelationForm"
  218. ref="addRelationForm"
  219. :rules="addRelationRules"
  220. >
  221. <el-row>
  222. <el-form-item label="课程" class="pull-left" prop="courseId">
  223. <el-select
  224. class="input"
  225. :remote-method="getCourses4AddRelation"
  226. :loading="courseLoading4AddRelation"
  227. remote
  228. filterable
  229. clearable
  230. v-model="addRelationForm.courseId"
  231. placeholder="请选择"
  232. >
  233. <el-option
  234. v-for="item in courseList4AddRelationWrapper"
  235. :label="item.name"
  236. :value="item.id"
  237. :key="item.id"
  238. />
  239. </el-select>
  240. </el-form-item>
  241. <el-button type="primary" @click="submitAddRelationForm">
  242. 保 存
  243. </el-button>
  244. <el-button @click="addRelationDialog = false">取 消</el-button>
  245. </el-row>
  246. </el-form>
  247. </el-dialog>
  248. <!-- 页面列表 -->
  249. <el-table
  250. :data="tableData"
  251. border
  252. @selection-change="handleSelectionChange"
  253. >
  254. <el-table-column type="selection" width="35"> </el-table-column>
  255. <el-table-column prop="id" label="ID" width="60"> </el-table-column>
  256. <el-table-column prop="code" label="专业代码"> </el-table-column>
  257. <el-table-column prop="name" label="专业名称"> </el-table-column>
  258. <el-table-column prop="updateTime" label="更新时间" width="170">
  259. </el-table-column>
  260. <el-table-column label="操作" width="300">
  261. <template slot-scope="scope">
  262. <div>
  263. <el-button
  264. size="mini"
  265. type="primary"
  266. @click="relation(scope.row)"
  267. plain
  268. icon="el-icon-share"
  269. >
  270. 关联课程
  271. </el-button>
  272. <el-button
  273. size="mini"
  274. type="primary"
  275. icon="el-icon-edit"
  276. @click="edit(scope.row)"
  277. plain
  278. >
  279. 编辑
  280. </el-button>
  281. <el-button
  282. size="mini"
  283. type="danger"
  284. icon="el-icon-delete"
  285. @click="deleteId(scope.row)"
  286. >
  287. 删除
  288. </el-button>
  289. </div>
  290. </template>
  291. </el-table-column>
  292. </el-table>
  293. <div class="page pull-right">
  294. <el-pagination
  295. @current-change="handleCurrentChange"
  296. :current-page="currentPage"
  297. :page-size="pageSize"
  298. :page-sizes="[10, 20, 50, 100]"
  299. @size-change="handleSizeChange"
  300. layout="total, sizes, prev, pager, next, jumper"
  301. :total="total"
  302. />
  303. </div>
  304. <!-- 导入弹窗 -->
  305. <el-dialog title="导入窗口" width="420px" :visible.sync="impDialog">
  306. <el-form>
  307. <el-row>
  308. <el-form-item style="margin-left:20px">
  309. <el-upload
  310. class="form_left"
  311. ref="upload"
  312. accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  313. :action="uploadAction"
  314. :headers="uploadHeaders"
  315. :data="uploadData"
  316. :before-upload="beforeUpload"
  317. :on-progress="uploadProgress"
  318. :on-success="uploadSuccess"
  319. :on-error="uploadError"
  320. :file-list="fileList"
  321. :auto-upload="false"
  322. :multiple="false"
  323. >
  324. <el-button size="small" slot="trigger" type="primary">
  325. 选择文件
  326. </el-button>
  327. &nbsp;
  328. <el-button size="small" type="success" @click="submitUpload">
  329. 确认上传
  330. </el-button>
  331. <el-button size="small" type="danger" @click="removeFile">
  332. 清空文件
  333. </el-button>
  334. <el-button size="small" type="info" @click="exportFile">
  335. 下载模板
  336. </el-button>
  337. <div slot="tip" class="el-upload__tip">只能上传xlsx文件</div>
  338. </el-upload>
  339. </el-form-item>
  340. </el-row>
  341. </el-form>
  342. </el-dialog>
  343. <!-- 导入错误信息列表 -->
  344. <el-dialog title="错误提示" :visible.sync="errDialog">
  345. <div
  346. class="text-danger"
  347. v-for="errMessage in errMessages"
  348. :key="errMessage.lineNum"
  349. >
  350. 第{{ errMessage.lineNum }}行:{{ errMessage.msg }}
  351. </div>
  352. <span slot="footer" class="dialog-footer">
  353. <el-button @click="errDialog = false">确定</el-button>
  354. </span>
  355. </el-dialog>
  356. </div>
  357. </section>
  358. </template>
  359. <script>
  360. import { CORE_API } from "@/constants/constants.js";
  361. import { mapState } from "vuex";
  362. export default {
  363. name: "Specially",
  364. data() {
  365. return {
  366. courseLoading: false,
  367. formSearch: {
  368. name: "",
  369. code: "",
  370. courseId: ""
  371. },
  372. speciallyForm: {
  373. id: null,
  374. name: "",
  375. code: ""
  376. },
  377. speciatlyId: "",
  378. speciallyDialog: false,
  379. courseDialog: false,
  380. loading: false,
  381. multipleSelection: [],
  382. tableData: [],
  383. currentPage: 1,
  384. pageSize: 10,
  385. total: 10,
  386. courseAllList: [],
  387. courseList: [],
  388. courseList4Search: [],
  389. courseAll: [],
  390. impDialog: false,
  391. uploadAction: CORE_API + "/specialty/import",
  392. uploadHeaders: {},
  393. uploadData: {},
  394. errMessages: [],
  395. errDialog: false,
  396. fileLoading: false,
  397. fileList: [],
  398. rules: {
  399. name: [{ required: true, message: "请输入专业名称", trigger: "blur" }],
  400. code: [{ required: true, message: "请输入专业代码", trigger: "blur" }]
  401. },
  402. courseDialogTitle: null,
  403. courseSearchForm: {
  404. specialtyId: null,
  405. code: "",
  406. name: ""
  407. },
  408. courseTableData: [],
  409. currentCoursePage: 1,
  410. coursePageSize: 10,
  411. courseTotal: 10,
  412. addRelationDialog: false,
  413. addRelationForm: {
  414. specialtyId: null,
  415. courseId: null
  416. },
  417. courseLoading4AddRelation: false,
  418. courseList4AddRelation: [],
  419. addRelationRules: {
  420. courseId: [
  421. {
  422. required: true,
  423. type: "number",
  424. message: "请选择课程",
  425. trigger: "change"
  426. }
  427. ]
  428. }
  429. };
  430. },
  431. computed: {
  432. ...mapState({
  433. user: state => state.user
  434. }),
  435. noBatchSelected() {
  436. return this.multipleSelection.length === 0;
  437. },
  438. courseAllListSelect() {
  439. let courseList = [];
  440. for (let course of this.courseAllList) {
  441. let courseInfo = course.name + "(" + course.code + ")";
  442. courseList.push({ id: course.id, courseInfo: courseInfo });
  443. }
  444. return courseList;
  445. },
  446. courseList4SearchWrapper() {
  447. var courseList = [];
  448. for (let course of this.courseList4Search) {
  449. var name = course.name + " - " + course.code;
  450. var id = course.id;
  451. courseList.push({ id: id, name: name, enable: course.enable });
  452. }
  453. return courseList;
  454. },
  455. courseList4AddRelationWrapper() {
  456. var courseList = [];
  457. for (let course of this.courseList4AddRelation) {
  458. var name = course.name + " - " + course.code;
  459. var id = course.id;
  460. courseList.push({ id: id, name: name, enable: course.enable });
  461. }
  462. return courseList;
  463. }
  464. },
  465. methods: {
  466. dialogBeforeClose() {
  467. this.$refs.speciallyForm.clearValidate();
  468. },
  469. handleSizeChange(val) {
  470. this.pageSize = val;
  471. this.searchForm();
  472. },
  473. resetPrimaryForm() {
  474. this.formSearch = {
  475. name: "",
  476. code: "",
  477. enable: "",
  478. level: "",
  479. specialtyId: ""
  480. };
  481. this.$refs.primaryForm.resetFields();
  482. },
  483. deleteRelation(row) {
  484. var courseId = row.id;
  485. var specialtyId = this.courseSearchForm.specialtyId;
  486. var param = new URLSearchParams({
  487. courseId: courseId,
  488. specialtyId: specialtyId
  489. });
  490. var url = CORE_API + "/courseSpeciatlyRelation/delete?" + param;
  491. this.$http
  492. .delete(url)
  493. .then(() => {
  494. this.$notify({
  495. type: "success",
  496. message: "取消关联成功!"
  497. });
  498. this.searchCoursePage();
  499. })
  500. .catch(response => {
  501. if (response.status == 500) {
  502. this.$notify({
  503. showClose: true,
  504. message: response.data.desc,
  505. type: "error"
  506. });
  507. }
  508. });
  509. },
  510. submitAddRelationForm() {
  511. this.$refs.addRelationForm.validate(valid => {
  512. if (valid) {
  513. var param = new URLSearchParams(this.addRelationForm);
  514. var url = CORE_API + "/courseSpeciatlyRelation/add?" + param;
  515. this.$http.post(url, this.speciallyForm).then(
  516. () => {
  517. this.$notify({
  518. type: "success",
  519. message: "添加成功!"
  520. });
  521. this.searchCoursePage();
  522. this.addRelationDialog = false;
  523. },
  524. response => {
  525. if (response.status == 500) {
  526. this.$notify({
  527. showClose: true,
  528. message: response.data.desc,
  529. type: "error"
  530. });
  531. }
  532. this.addRelationDialog = false;
  533. }
  534. );
  535. } else {
  536. console.log("error submit!");
  537. return false;
  538. }
  539. });
  540. },
  541. addRelation() {
  542. this.addRelationForm.courseId = null;
  543. this.addRelationForm.specialtyId = this.courseSearchForm.specialtyId;
  544. this.addRelationDialog = true;
  545. // this.$refs.addRelationForm.resetFields();
  546. },
  547. searchCoursePage() {
  548. var param = new URLSearchParams(this.courseSearchForm);
  549. var url =
  550. CORE_API +
  551. "/course/coursePage/" +
  552. (this.currentPage - 1) +
  553. "/" +
  554. this.pageSize +
  555. "?" +
  556. param;
  557. this.$http.get(url).then(response => {
  558. console.log(response);
  559. this.courseTableData = response.data.content;
  560. this.courseTotal = response.data.totalElements;
  561. });
  562. },
  563. getCourses(query) {
  564. this.courseLoading = true;
  565. this.$http
  566. .get(CORE_API + "/course/query?name=" + query)
  567. .then(response => {
  568. this.courseList4Search = response.data;
  569. this.courseLoading = false;
  570. });
  571. },
  572. getCourses4AddRelation(query) {
  573. this.courseLoading4AddRelation = true;
  574. this.$http
  575. .get(CORE_API + "/course/query?name=" + query)
  576. .then(response => {
  577. this.courseList4AddRelation = response.data;
  578. this.courseLoading4AddRelation = false;
  579. });
  580. },
  581. handleSearchBtn() {
  582. this.currentPage = 1;
  583. this.searchForm();
  584. },
  585. //查询
  586. searchForm() {
  587. var param = new URLSearchParams(this.formSearch);
  588. var url =
  589. CORE_API +
  590. "/specialty/specialtyPage/" +
  591. (this.currentPage - 1) +
  592. "/" +
  593. this.pageSize +
  594. "?" +
  595. param;
  596. this.$http
  597. .get(url)
  598. .then(response => {
  599. console.log("response :", response);
  600. this.tableData = response.data.content;
  601. this.total = response.data.totalElements;
  602. })
  603. .catch(response => {
  604. if (response.status == 500) {
  605. this.$notify({
  606. showClose: true,
  607. message: response.data.desc,
  608. type: "error"
  609. });
  610. }
  611. });
  612. },
  613. handleCurrentChange(val) {
  614. this.currentPage = val;
  615. this.currentPage = 1;
  616. this.searchForm();
  617. },
  618. handleCourseCurrentChange(val) {
  619. this.currentCoursePage = val;
  620. this.searchCoursePage();
  621. },
  622. //全选
  623. handleSelectionChange(val) {
  624. this.multipleSelection = val;
  625. },
  626. //删除方法
  627. deleteSchool() {
  628. this.$confirm("是否删除学校信息?", "提示", {
  629. confirmButtonText: "确定",
  630. cancelButtonText: "取消",
  631. type: "error"
  632. }).then(() => {
  633. this.loading = true;
  634. var vm = this;
  635. var url = CORE_API;
  636. vm.$http.delete(url).then(() => {
  637. this.loading = false;
  638. this.$notify({
  639. type: "success",
  640. message: "删除成功!"
  641. });
  642. //this.searchForm()
  643. });
  644. });
  645. },
  646. //保存
  647. submitForm(formData) {
  648. this.$refs[formData].validate(valid => {
  649. if (valid) {
  650. var url = CORE_API + "/specialty";
  651. //修改
  652. if (null != this.speciallyForm.id) {
  653. this.$http.put(url, this.speciallyForm).then(
  654. () => {
  655. this.$notify({
  656. type: "success",
  657. message: "修改成功!"
  658. });
  659. this.searchForm();
  660. this.speciallyDialog = false;
  661. },
  662. response => {
  663. if (response.status == 500) {
  664. this.$notify({
  665. showClose: true,
  666. message: response.data.desc,
  667. type: "error"
  668. });
  669. }
  670. this.searchForm();
  671. this.speciallyDialog = false;
  672. }
  673. );
  674. }
  675. //新增
  676. else {
  677. this.$http.post(url, this.speciallyForm).then(
  678. () => {
  679. this.$notify({
  680. type: "success",
  681. message: "新增成功!"
  682. });
  683. this.speciallyDialog = false;
  684. this.searchForm();
  685. },
  686. response => {
  687. if (response.status == 500) {
  688. this.$notify({
  689. showClose: true,
  690. message: response.data.desc,
  691. type: "error"
  692. });
  693. }
  694. this.speciallyDialog = false;
  695. this.searchForm();
  696. }
  697. );
  698. }
  699. } else {
  700. console.log("error submit!");
  701. return false;
  702. }
  703. });
  704. },
  705. //重置
  706. resetForm(formData) {
  707. this.$refs[formData].resetFields();
  708. },
  709. close() {
  710. this.speciallyDialog = false;
  711. },
  712. //新增
  713. insert() {
  714. this.speciallyForm.id = null;
  715. this.speciallyForm.name = "";
  716. this.speciallyForm.code = "";
  717. this.speciallyDialog = true;
  718. },
  719. //修改
  720. edit(row) {
  721. this.speciallyForm = Object.assign({}, row);
  722. this.speciallyDialog = true;
  723. },
  724. //删除
  725. deleteId(row) {
  726. this.$confirm("是否删除该条课程信息?", "提示", {
  727. confirmButtonText: "确定",
  728. cancelButtonText: "取消",
  729. type: "error"
  730. }).then(() => {
  731. var url = CORE_API + "/specialty/" + row.id;
  732. this.$http
  733. .delete(url)
  734. .then(() => {
  735. this.$notify({
  736. type: "success",
  737. message: "删除成功!"
  738. });
  739. this.searchForm();
  740. })
  741. .catch(response => {
  742. if (response.status == 500) {
  743. this.$notify({
  744. showClose: true,
  745. message: response.data.desc,
  746. type: "error"
  747. });
  748. }
  749. });
  750. });
  751. },
  752. //删除多条信息
  753. deleteIds() {
  754. if (this.multipleSelection.length === 0) {
  755. this.$notify({
  756. type: "warning",
  757. message: "请选择要删除的专业"
  758. });
  759. } else {
  760. this.$confirm("是否删除这些课程信息?", "提示", {
  761. confirmButtonText: "确定",
  762. cancelButtonText: "取消",
  763. type: "error"
  764. }).then(() => {
  765. var ids = [];
  766. for (var i = 0; i < this.multipleSelection.length; i++) {
  767. ids.push(this.multipleSelection[i].id);
  768. }
  769. var url = CORE_API + "/specialty/" + ids;
  770. this.$http
  771. .delete(url)
  772. .then(() => {
  773. this.$notify({
  774. type: "success",
  775. message: "删除成功!"
  776. });
  777. this.searchForm();
  778. })
  779. .catch(response => {
  780. if (response.status == 500) {
  781. this.$notify({
  782. showClose: true,
  783. message: response.data.desc,
  784. type: "error"
  785. });
  786. }
  787. });
  788. });
  789. }
  790. },
  791. //关联课程
  792. relation(row) {
  793. this.courseDialogTitle =
  794. "关联课程列表 【专业名称:" +
  795. row.name +
  796. "】【专业代码:" +
  797. row.code +
  798. "】";
  799. this.courseSearchForm.specialtyId = row.id;
  800. this.courseSearchForm.code = "";
  801. this.courseSearchForm.name = "";
  802. this.searchCoursePage();
  803. this.courseDialog = true;
  804. },
  805. closeCourse() {
  806. this.courseDialog = false;
  807. },
  808. saveCourse() {
  809. //debugger;
  810. var url = CORE_API + "/CourseSpeciatly/addCourse/" + this.speciatlyId;
  811. this.$http.post(url, this.courseList).then(
  812. () => {
  813. this.$notify({
  814. type: "success",
  815. message: "课程关联成功!"
  816. });
  817. this.courseDialog = false;
  818. this.searchForm();
  819. },
  820. () => {
  821. this.$notify({
  822. type: "error",
  823. message: "课程关联失败!"
  824. });
  825. this.courseDialog = false;
  826. this.searchForm();
  827. }
  828. );
  829. },
  830. exportSpeciatly() {
  831. let param = new URLSearchParams(this.formSearch);
  832. window.open(
  833. CORE_API +
  834. "/specialty/export?$key=" +
  835. this.user.key +
  836. "&$token=" +
  837. this.user.token +
  838. "&" +
  839. param
  840. );
  841. },
  842. //导入
  843. impSpecialty() {
  844. this.impDialog = true;
  845. this.initUpload();
  846. },
  847. initUpload() {
  848. this.fileList = [];
  849. },
  850. beforeUpload(file) {
  851. console.log(file);
  852. },
  853. uploadProgress() {
  854. console.log("uploadProgress");
  855. },
  856. uploadSuccess(response) {
  857. if (!response.hasError) {
  858. this.$notify({
  859. message: "上传成功",
  860. type: "success"
  861. });
  862. this.fileLoading = false;
  863. this.impDialog = false;
  864. this.searchForm();
  865. } else {
  866. this.fileLoading = false;
  867. this.impDialog = false;
  868. this.errMessages = response.failRecords;
  869. this.errDialog = true;
  870. }
  871. },
  872. uploadError(response) {
  873. var json = JSON.parse(response.message);
  874. if (response.status == 500) {
  875. this.$notify({
  876. message: json.desc,
  877. type: "error"
  878. });
  879. }
  880. this.fileLoading = false;
  881. },
  882. //确定上传
  883. submitUpload() {
  884. if (!this.checkUpload()) {
  885. return false;
  886. }
  887. this.$refs.upload.submit();
  888. this.fileLoading = true;
  889. },
  890. checkUpload() {
  891. var fileList = this.$refs.upload.uploadFiles;
  892. if (fileList.length == 0) {
  893. this.$notify({
  894. message: "上传文件不能为空",
  895. type: "error"
  896. });
  897. return false;
  898. }
  899. if (fileList.length > 1) {
  900. this.$notify({
  901. message: "每次只能上传一个文件",
  902. type: "error"
  903. });
  904. return false;
  905. }
  906. for (let file of fileList) {
  907. if (!file.name.endsWith(".xlsx")) {
  908. this.$notify({
  909. message: "上传文件必须为xlsx格式",
  910. type: "error"
  911. });
  912. this.initUpload();
  913. return false;
  914. }
  915. }
  916. return true;
  917. },
  918. //清空文件
  919. removeFile() {
  920. // this.fileList = [];
  921. this.$refs.upload.clearFiles();
  922. },
  923. //下载模板
  924. exportFile() {
  925. window.location.href =
  926. CORE_API +
  927. "/specialty/importTemplate?$key=" +
  928. this.user.key +
  929. "&$token=" +
  930. this.user.token;
  931. }
  932. },
  933. //初始化查询
  934. created() {
  935. this.searchForm();
  936. this.uploadHeaders = {
  937. key: this.user.key,
  938. token: this.user.token
  939. };
  940. }
  941. };
  942. </script>
  943. <style scoped>
  944. .pull_center {
  945. margin-left: 120px;
  946. }
  947. .pull_length {
  948. width: 200px;
  949. }
  950. </style>