MajorManage.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="major-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="90px" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="专业名称:">
  7. <el-input
  8. v-model.trim="filter.majorName"
  9. placeholder="专业名称"
  10. clearable
  11. ></el-input>
  12. </el-form-item>
  13. </template>
  14. <el-form-item>
  15. <el-button
  16. v-if="checkPrivilege('button', 'select')"
  17. type="primary"
  18. @click="toPage(1)"
  19. >查询</el-button
  20. >
  21. </el-form-item>
  22. </el-form>
  23. <div class="part-box-action">
  24. <el-button
  25. v-if="checkPrivilege('button', 'delete')"
  26. type="danger"
  27. icon="el-icon-delete"
  28. @click="toBatchDelete"
  29. >批量删除</el-button
  30. >
  31. <el-button
  32. v-if="checkPrivilege('button', 'add')"
  33. type="primary"
  34. icon="el-icon-circle-plus-outline"
  35. @click="toAdd"
  36. >新增专业</el-button
  37. >
  38. </div>
  39. </div>
  40. <div class="part-box part-box-pad">
  41. <el-table
  42. ref="TableList"
  43. :data="dataList"
  44. @selection-change="handleSelectionChange"
  45. >
  46. <el-table-column
  47. type="selection"
  48. width="55"
  49. align="center"
  50. ></el-table-column>
  51. <el-table-column
  52. type="index"
  53. label="序号"
  54. width="70"
  55. :index="indexMethod"
  56. ></el-table-column>
  57. <el-table-column prop="majorName" label="专业名称"></el-table-column>
  58. <el-table-column prop="collegeName" label="所属机构"></el-table-column>
  59. <el-table-column prop="createTime" label="创建时间">
  60. <span slot-scope="scope">{{
  61. scope.row.createTime | timestampFilter
  62. }}</span>
  63. </el-table-column>
  64. <el-table-column class-name="action-column" label="操作" width="120px">
  65. <template slot-scope="scope">
  66. <el-button
  67. v-if="checkPrivilege('link', 'edit')"
  68. class="btn-primary"
  69. type="text"
  70. @click="toEdit(scope.row)"
  71. >编辑</el-button
  72. >
  73. <el-button
  74. v-if="checkPrivilege('link', 'delete')"
  75. class="btn-danger"
  76. type="text"
  77. @click="toDelete(scope.row)"
  78. >删除</el-button
  79. >
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <div class="part-page">
  84. <el-pagination
  85. background
  86. layout="total,prev, pager, next"
  87. :current-page="current"
  88. :total="total"
  89. :page-size="size"
  90. @current-change="toPage"
  91. >
  92. </el-pagination>
  93. </div>
  94. </div>
  95. <modify-major
  96. :instance="curRow"
  97. @modified="getList"
  98. ref="ModifyMajor"
  99. ></modify-major>
  100. </div>
  101. </template>
  102. <script>
  103. import { majorListQuery, deleteMajor } from "../api";
  104. import ModifyMajor from "../components/ModifyMajor";
  105. export default {
  106. name: "major-manage",
  107. components: { ModifyMajor },
  108. data() {
  109. return {
  110. filter: {
  111. majorName: ""
  112. },
  113. current: 1,
  114. size: this.GLOBAL.pageSize,
  115. total: 0,
  116. dataList: [],
  117. multipleSelection: [],
  118. curRow: {}
  119. };
  120. },
  121. mounted() {
  122. this.getList();
  123. },
  124. methods: {
  125. async getList() {
  126. if (!this.checkPrivilege("list", "list")) return;
  127. const datas = {
  128. ...this.filter,
  129. pageNumber: this.current,
  130. pageSize: this.size
  131. };
  132. const data = await majorListQuery(datas);
  133. this.dataList = data.records;
  134. this.total = data.total;
  135. },
  136. toPage(page) {
  137. this.multipleSelection = [];
  138. this.current = page;
  139. this.getList();
  140. },
  141. toAdd() {
  142. this.curRow = {};
  143. this.$refs.ModifyMajor.open();
  144. },
  145. toEdit(row) {
  146. this.curRow = row;
  147. this.$refs.ModifyMajor.open();
  148. },
  149. handleSelectionChange(val) {
  150. this.multipleSelection = val.map(item => item.id);
  151. },
  152. toBatchDelete() {
  153. if (!this.multipleSelection.length) {
  154. this.$message.error("请选择要删除的数据");
  155. return;
  156. }
  157. this.$confirm(`确定要删除选中的这些数据吗?`, "提示", {
  158. type: "warning"
  159. })
  160. .then(async () => {
  161. await deleteMajor(this.multipleSelection);
  162. this.$message.success("删除成功!");
  163. this.deletePageLastItem(this.multipleSelection.length);
  164. this.multipleSelection = [];
  165. })
  166. .catch(() => {});
  167. },
  168. toDelete(row) {
  169. this.$confirm(`确定要删除专业【${row.majorName}】吗?`, "提示", {
  170. type: "warning"
  171. })
  172. .then(async () => {
  173. await deleteMajor([row.id]);
  174. this.$message.success("删除成功!");
  175. this.deletePageLastItem();
  176. })
  177. .catch(() => {});
  178. }
  179. }
  180. };
  181. </script>