CourseManage.vue 8.0 KB

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