specially.vue 28 KB

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