ClassPaper.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="data-manage">
  3. <div class="part-box">
  4. <el-form ref="FilterForm" label-position="left" label-width="80px" inline>
  5. <el-form-item label="年级名称">
  6. <el-input
  7. v-model.trim="filter.name"
  8. placeholder="年级名称模糊查询"
  9. clearable
  10. ></el-input>
  11. </el-form-item>
  12. <el-form-item label="年级状态">
  13. <el-select v-model="filter.status" style="width: 150px;" clearable>
  14. <el-option
  15. v-for="(val, key) in ABLE_TYPE"
  16. :key="key"
  17. :value="key"
  18. :label="val"
  19. ></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label-width="0px">
  23. <el-button type="primary" icon="ios-search" @click="toPage(1)"
  24. >查询</el-button
  25. >
  26. </el-form-item>
  27. </el-form>
  28. </div>
  29. <div class="part-box">
  30. <div class="part-title">
  31. <div class="part-title-infos">
  32. <el-button type="primary" icon="md-add" @click="toAdd"
  33. >新增</el-button
  34. >
  35. </div>
  36. </div>
  37. <el-table ref="TableList" :data="grades" border>
  38. <el-table-column
  39. type="index"
  40. label="序号"
  41. width="70"
  42. align="center"
  43. :index="indexMethod"
  44. >
  45. </el-table-column>
  46. <el-table-column prop="name" label="年级名称" min-width="200">
  47. </el-table-column>
  48. <el-table-column prop="status" label="状态" min-width="200">
  49. <template slot-scope="scope">
  50. <span>{{ ABLE_TYPE[scope.row.status] }}</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column min-width="200" align="center">
  54. <template slot-scope="scope">
  55. <el-button
  56. size="mini"
  57. type="primary"
  58. icon="el-icon-edit"
  59. @click="toEdit(scope.row)"
  60. >编辑</el-button
  61. >
  62. <el-button
  63. size="mini"
  64. type="danger"
  65. icon="el-icon-delete"
  66. @click="toDelete(scope.row)"
  67. >删除</el-button
  68. >
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <div class="part-page">
  73. <el-pagination
  74. background
  75. layout="prev, pager, next"
  76. :current-page="current"
  77. :total="total"
  78. :page-size="size"
  79. @current-change="toPage"
  80. >
  81. </el-pagination>
  82. </div>
  83. </div>
  84. <!-- modify-data -->
  85. <modify-data
  86. :instance="curCourse"
  87. @modified="getList"
  88. ref="ModifyData"
  89. ></modify-data>
  90. </div>
  91. </template>
  92. <script>
  93. import { ABLE_TYPE } from "@/constants/enumerate";
  94. import { courseList, deleteCourse } from "../api";
  95. import ModifyData from "../components/ModifyData";
  96. export default {
  97. name: "data-manage",
  98. components: { ModifyData },
  99. data() {
  100. return {
  101. filter: {
  102. name: "",
  103. status: ""
  104. },
  105. current: 1,
  106. size: this.GLOBAL.pageSize,
  107. total: 0,
  108. visible: false,
  109. grades: [
  110. {
  111. id: "11",
  112. name: "名称1",
  113. status: "ENABLE"
  114. },
  115. {
  116. id: "22",
  117. name: "名称2",
  118. status: "ENABLE"
  119. },
  120. {
  121. id: "33",
  122. name: "名称3",
  123. status: "ENABLE"
  124. }
  125. ],
  126. curCourse: {},
  127. ABLE_TYPE
  128. };
  129. },
  130. created() {
  131. // this.getList();
  132. },
  133. methods: {
  134. indexMethod(index) {
  135. return (this.current - 1) * this.size + index + 1;
  136. },
  137. async getList() {
  138. const datas = {
  139. ...this.filter,
  140. current: this.current,
  141. size: this.size
  142. };
  143. const data = await courseList(datas);
  144. this.grades = data.list.map(item => {
  145. return {
  146. id: item.id,
  147. name: item.name,
  148. status: item.status,
  149. createTime: item.createTime
  150. };
  151. });
  152. this.total = data.totalCount;
  153. },
  154. toPage(page) {
  155. this.current = page;
  156. this.getList();
  157. },
  158. toAdd() {
  159. this.curCourse = {};
  160. this.$refs.ModifyData.open();
  161. },
  162. toEdit(row) {
  163. this.curCourse = row;
  164. this.$refs.ModifyData.open();
  165. },
  166. toDelete(row) {
  167. this.$confirm("确定要删除当前学校吗?", "删除警告", {
  168. cancelButtonClass: "el-button--danger is-plain",
  169. confirmButtonClass: "el-button--primary",
  170. type: "warning"
  171. })
  172. .then(async () => {
  173. await deleteCourse(row.id);
  174. this.$message.success("删除成功!");
  175. // 解决最后一项删除后的问题
  176. this.deletePageLastItem();
  177. })
  178. .catch(() => {});
  179. }
  180. }
  181. };
  182. </script>