ClazzSimpleManage.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="clazz-simple-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-select
  8. v-model="filter.teachCourseId"
  9. placeholder="课程"
  10. filterable
  11. >
  12. <el-option
  13. v-for="item in courses"
  14. :key="item.id"
  15. :value="item.id"
  16. :label="item.name"
  17. >
  18. <span>{{ `${item.name}(${item.code})` }}</span>
  19. </el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="班级名称:">
  23. <el-input
  24. v-model.trim="filter.teachClazzName"
  25. placeholder="班级名称"
  26. clearable
  27. ></el-input>
  28. </el-form-item>
  29. </template>
  30. <el-form-item>
  31. <el-button
  32. v-if="checkPrivilege('button', 'select')"
  33. type="primary"
  34. :disabled="!filter.teachCourseId"
  35. @click="toPage(1)"
  36. >查询</el-button
  37. >
  38. </el-form-item>
  39. </el-form>
  40. <div class="part-box-action">
  41. <el-button
  42. v-if="checkPrivilege('button', 'add')"
  43. type="primary"
  44. icon="el-icon-circle-plus-outline"
  45. @click="toAdd"
  46. >新增班级</el-button
  47. >
  48. </div>
  49. </div>
  50. <div class="part-box part-box-pad">
  51. <el-table ref="TableList" :data="dataList">
  52. <el-table-column
  53. type="index"
  54. label="序号"
  55. width="70"
  56. :index="indexMethod"
  57. ></el-table-column>
  58. <el-table-column
  59. prop="teachClazzName"
  60. label="班级名称"
  61. ></el-table-column>
  62. <el-table-column
  63. prop="teachStudentCount"
  64. label="学生人数"
  65. ></el-table-column>
  66. <el-table-column prop="createTime" label="创建时间" width="170">
  67. <span slot-scope="scope">{{
  68. scope.row.createTime | timestampFilter
  69. }}</span>
  70. </el-table-column>
  71. <el-table-column class-name="action-column" label="操作" width="170px">
  72. <template slot-scope="scope">
  73. <el-button
  74. v-if="checkPrivilege('link', 'edit')"
  75. class="btn-primary"
  76. type="text"
  77. @click="toEdit(scope.row)"
  78. >重命名</el-button
  79. >
  80. <el-button
  81. v-if="checkPrivilege('link', 'Window')"
  82. class="btn-primary"
  83. type="text"
  84. @click="toEditStudent(scope.row)"
  85. >人员管理</el-button
  86. >
  87. <el-button
  88. v-if="checkPrivilege('link', 'delete')"
  89. class="btn-danger"
  90. type="text"
  91. @click="toDelete(scope.row)"
  92. >删除</el-button
  93. >
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <div class="part-page">
  98. <el-pagination
  99. background
  100. layout="total,prev, pager, next"
  101. :current-page="current"
  102. :total="total"
  103. :page-size="size"
  104. @current-change="toPage"
  105. >
  106. </el-pagination>
  107. </div>
  108. </div>
  109. <!-- ModifyClazzSimple -->
  110. <modify-clazz-simple
  111. :instance="curRow"
  112. :courses="courses"
  113. @modified="getList"
  114. ref="ModifyClazzSimple"
  115. ></modify-clazz-simple>
  116. <!-- ModifyClazzSimpleStudent -->
  117. <modify-clazz-simple-student
  118. ref="ModifyClazzSimpleStudent"
  119. :clazz="curRow"
  120. @modified="getList"
  121. ></modify-clazz-simple-student>
  122. </div>
  123. </template>
  124. <script>
  125. import {
  126. clazzSimpleListPage,
  127. clazzTeachCourseQuery,
  128. deleteClazzSimple
  129. } from "../api";
  130. import ModifyClazzSimple from "../components/ModifyClazzSimple";
  131. import ModifyClazzSimpleStudent from "../components/ModifyClazzSimpleStudent";
  132. export default {
  133. name: "clazz-simple-manage",
  134. components: { ModifyClazzSimple, ModifyClazzSimpleStudent },
  135. data() {
  136. return {
  137. filter: {
  138. teachCourseId: "",
  139. teachClazzName: ""
  140. },
  141. current: 1,
  142. size: this.GLOBAL.pageSize,
  143. total: 0,
  144. courses: [],
  145. dataList: [],
  146. curRow: {}
  147. };
  148. },
  149. mounted() {
  150. this.initData();
  151. },
  152. methods: {
  153. async initData() {
  154. if (this.$route.params.teachCourseId) {
  155. this.filter.teachCourseId = this.$route.params.teachCourseId;
  156. this.getCourseSimple();
  157. this.getList();
  158. } else {
  159. await this.getCourseSimple();
  160. this.filter.teachCourseId = this.courses[0] && this.courses[0].id;
  161. this.getList();
  162. }
  163. },
  164. async getList() {
  165. if (!this.checkPrivilege("list", "list")) return;
  166. const datas = {
  167. ...this.filter,
  168. pageNumber: this.current,
  169. pageSize: this.size
  170. };
  171. const data = await clazzSimpleListPage(datas);
  172. this.dataList = data.records;
  173. this.total = data.total;
  174. },
  175. toPage(page) {
  176. this.current = page;
  177. this.getList();
  178. },
  179. async getCourseSimple() {
  180. const data = await clazzTeachCourseQuery();
  181. this.courses = data || [];
  182. },
  183. toAdd() {
  184. this.curRow = { teachCourseId: this.filter.teachCourseId };
  185. this.$refs.ModifyClazzSimple.open();
  186. },
  187. toEdit(row) {
  188. this.curRow = row;
  189. this.$refs.ModifyClazzSimple.open();
  190. },
  191. toEditStudent(row) {
  192. this.curRow = row;
  193. this.$refs.ModifyClazzSimpleStudent.open();
  194. },
  195. toDelete(row) {
  196. this.$confirm(`确定要删除班级【${row.teachClazzName}】吗?`, "提示", {
  197. type: "warning"
  198. })
  199. .then(async () => {
  200. await deleteClazzSimple([row.id]);
  201. this.$message.success("删除成功!");
  202. this.deletePageLastItem();
  203. })
  204. .catch(() => {});
  205. }
  206. }
  207. };
  208. </script>