CourseManage.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="课程名称:">
  7. <el-input
  8. style="width: 142px;"
  9. v-model.trim="filter.courseName"
  10. placeholder="课程名称"
  11. clearable
  12. ></el-input>
  13. </el-form-item>
  14. <el-form-item label="创建时间:">
  15. <el-date-picker
  16. v-model="createTime"
  17. type="datetimerange"
  18. :picker-options="pickerOptions"
  19. range-separator="至"
  20. start-placeholder="创建开始时间"
  21. end-placeholder="创建结束时间"
  22. value-format="timestamp"
  23. align="right"
  24. unlink-panels
  25. >
  26. </el-date-picker>
  27. </el-form-item>
  28. </template>
  29. <el-form-item>
  30. <el-button
  31. v-if="checkPrivilege('button', 'select')"
  32. type="primary"
  33. @click="toPage(1)"
  34. >查询</el-button
  35. >
  36. </el-form-item>
  37. </el-form>
  38. <div class="part-box-action">
  39. <el-button
  40. type="success"
  41. icon="el-icon-download"
  42. v-if="checkPrivilege('button', 'TempleteDownload')"
  43. ><a :href="downloadUrl" :download="dfilename">模板下载</a></el-button
  44. >
  45. <upload-button
  46. v-if="checkPrivilege('button', 'Import')"
  47. btn-icon="el-icon-circle-plus-outline"
  48. btn-content="批量导入"
  49. btn-type="success"
  50. :upload-url="uploadUrl"
  51. :format="['xls', 'xlsx']"
  52. @upload-error="uplaodError"
  53. @upload-success="uploadSuccess"
  54. >
  55. </upload-button>
  56. <el-button
  57. v-if="checkPrivilege('button', 'add')"
  58. type="primary"
  59. icon="el-icon-circle-plus-outline"
  60. @click="toAdd"
  61. >新增课程</el-button
  62. >
  63. </div>
  64. </div>
  65. <div class="part-box part-box-pad">
  66. <el-table ref="TableList" :data="courses">
  67. <el-table-column
  68. type="index"
  69. label="序号"
  70. width="70"
  71. :index="indexMethod"
  72. ></el-table-column>
  73. <el-table-column prop="courseName" label="课程名称"></el-table-column>
  74. <el-table-column prop="courseCode" label="课程编码"></el-table-column>
  75. <el-table-column
  76. prop="teachingRoomName"
  77. label="所属教研室"
  78. ></el-table-column>
  79. <el-table-column prop="clazzList" label="授课班级">
  80. <span slot-scope="scope">
  81. {{ scope.row.clazzList.map(item => item.name).join(",") }}
  82. </span>
  83. </el-table-column>
  84. <el-table-column prop="createTime" label="创建日期">
  85. <span slot-scope="scope">{{
  86. scope.row.createTime | timestampFilter
  87. }}</span>
  88. </el-table-column>
  89. <el-table-column label="操作" width="120px">
  90. <template slot-scope="scope">
  91. <el-button
  92. v-if="checkPrivilege('link', 'edit')"
  93. class="btn-primary"
  94. type="text"
  95. @click="toEdit(scope.row)"
  96. >编辑</el-button
  97. >
  98. <el-button
  99. v-if="checkPrivilege('link', 'delete')"
  100. class="btn-danger"
  101. type="text"
  102. @click="toDelete(scope.row)"
  103. >删除</el-button
  104. >
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <div class="part-page">
  109. <el-pagination
  110. background
  111. layout="total,prev, pager, next"
  112. :current-page="current"
  113. :total="total"
  114. :page-size="size"
  115. @current-change="toPage"
  116. >
  117. </el-pagination>
  118. </div>
  119. </div>
  120. <modify-course
  121. :instance="curCourse"
  122. @modified="getList"
  123. ref="ModifyCourse"
  124. ></modify-course>
  125. </div>
  126. </template>
  127. <script>
  128. import { courseListPage, deleteCourse } from "../api";
  129. import pickerOptions from "@/constants/datePickerOptions";
  130. import ModifyCourse from "../components/ModifyCourse";
  131. import UploadButton from "../../../components/UploadButton";
  132. export default {
  133. name: "course-manage",
  134. components: { ModifyCourse, UploadButton },
  135. data() {
  136. return {
  137. filter: {
  138. courseName: "",
  139. startCreateTime: "",
  140. endCreateTime: ""
  141. },
  142. pickerOptions,
  143. current: 1,
  144. size: this.GLOBAL.pageSize,
  145. total: 0,
  146. courses: [],
  147. // import
  148. uploadUrl: "/api/admin/basic/course/data_import",
  149. downloadUrl: "/temps/courseTemplate.xlsx",
  150. dfilename: "课程导入模板.xlsx",
  151. // date-picker
  152. createTime: [],
  153. curCourse: {}
  154. };
  155. },
  156. mounted() {
  157. this.getList();
  158. },
  159. methods: {
  160. async getList() {
  161. if (!this.checkPrivilege("list", "list")) return;
  162. const datas = {
  163. ...this.filter,
  164. pageNumber: this.current,
  165. pageSize: this.size
  166. };
  167. if (this.createTime) {
  168. datas.startCreateTime = this.createTime[0];
  169. datas.endCreateTime = this.createTime[1];
  170. }
  171. const data = await courseListPage(datas);
  172. this.courses = data.records;
  173. this.total = data.total;
  174. },
  175. toPage(page) {
  176. this.current = page;
  177. this.getList();
  178. },
  179. toAdd() {
  180. this.curCourse = {};
  181. this.$refs.ModifyCourse.open();
  182. },
  183. toEdit(row) {
  184. this.curCourse = row;
  185. this.$refs.ModifyCourse.open();
  186. },
  187. toDelete(row) {
  188. this.$confirm(`确定要删除课程【${row.courseName}】吗?`, "提示", {
  189. type: "warning"
  190. })
  191. .then(async () => {
  192. await deleteCourse([row.id]);
  193. this.$message.success("删除成功!");
  194. this.deletePageLastItem();
  195. })
  196. .catch(() => {});
  197. },
  198. // import
  199. uplaodError(errorData) {
  200. this.$notify.error({ title: "错误提示", message: errorData.message });
  201. },
  202. uploadSuccess() {
  203. this.$message.success("文件上传成功,后台正在导入!");
  204. this.getList();
  205. }
  206. }
  207. };
  208. </script>