specially.vue 26 KB

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