specially.vue 26 KB

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