specially.vue 27 KB

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