CourseManage.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div class="course-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <el-form-item label="课程名称:">
  6. <el-input
  7. style="width: 142px;"
  8. v-model.trim="filter.courseName"
  9. placeholder="请输入内容"
  10. clearable
  11. ></el-input>
  12. </el-form-item>
  13. <el-form-item label="课程编码:">
  14. <el-input
  15. style="width: 142px;"
  16. v-model.trim="filter.courseCode"
  17. placeholder="请输入内容"
  18. clearable
  19. ></el-input>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
  23. >查询</el-button
  24. >
  25. </el-form-item>
  26. </el-form>
  27. <div class="part-box-action">
  28. <el-button type="warning" icon="icon icon-plus" @click="toAdd"
  29. >新增课程</el-button
  30. >
  31. </div>
  32. </div>
  33. <div class="part-box">
  34. <el-table ref="TableList" :data="courses" border stripe>
  35. <el-table-column prop="courseName" label="课程名称"></el-table-column>
  36. <el-table-column prop="courseCode" label="课程编码"></el-table-column>
  37. <el-table-column label="操作" align="center" width="120px">
  38. <template slot-scope="scope">
  39. <el-button
  40. class="btn-table-icon"
  41. type="text"
  42. icon="icon icon-edit"
  43. @click="toEdit(scope.row)"
  44. title="编辑"
  45. ></el-button>
  46. <el-button
  47. class="btn-table-icon"
  48. type="text"
  49. icon="icon icon-delete"
  50. @click="toDelete(scope.row)"
  51. title="删除"
  52. ></el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <div class="part-page">
  57. <el-pagination
  58. background
  59. layout="prev, pager, next"
  60. :current-page="current"
  61. :total="total"
  62. :page-size="size"
  63. @current-change="toPage"
  64. >
  65. </el-pagination>
  66. </div>
  67. </div>
  68. <modify-course
  69. :instance="curCourse"
  70. @modified="getList"
  71. ref="ModifyCourse"
  72. ></modify-course>
  73. </div>
  74. </template>
  75. <script>
  76. import { courseListPage, deleteCourse } from "../api";
  77. import ModifyCourse from "../components/ModifyCourse";
  78. export default {
  79. name: "course-manage",
  80. components: { ModifyCourse },
  81. data() {
  82. return {
  83. filter: {
  84. courseName: "",
  85. courseCode: ""
  86. },
  87. current: 1,
  88. size: this.GLOBAL.pageSize,
  89. total: 0,
  90. courses: [],
  91. curCourse: {}
  92. };
  93. },
  94. created() {
  95. this.getList();
  96. },
  97. methods: {
  98. async getList() {
  99. const datas = {
  100. ...this.filter,
  101. pageNumber: this.current,
  102. pageSize: this.size
  103. };
  104. const data = await courseListPage(datas);
  105. this.courses = data.records;
  106. this.total = data.total;
  107. },
  108. toPage(page) {
  109. this.current = page;
  110. this.getList();
  111. },
  112. toAdd() {
  113. this.curCourse = {};
  114. this.$refs.ModifyCourse.open();
  115. },
  116. toEdit(row) {
  117. this.curCourse = row;
  118. this.$refs.ModifyCourse.open();
  119. },
  120. toDelete(row) {
  121. this.$confirm("确定要删除当前课程吗?", "提示", {
  122. cancelButtonClass: "el-button--danger is-plain",
  123. confirmButtonClass: "el-button--primary",
  124. type: "warning"
  125. }).then(async () => {
  126. await deleteCourse(row.id);
  127. this.$message.success("删除成功!");
  128. this.deletePageLastItem();
  129. });
  130. }
  131. }
  132. };
  133. </script>