ModifyClazzSimpleStudent.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div>
  3. <el-dialog
  4. class="modify-clazz-simple-student page-dialog"
  5. :visible.sync="modalIsShow"
  6. :title="title"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. fullscreen
  11. destroy-on-close
  12. @open="visibleChange"
  13. @close="closed"
  14. >
  15. <div class="part-box part-box-filter part-box-flex">
  16. <el-form
  17. ref="FilterForm"
  18. label-position="left"
  19. label-width="85px"
  20. inline
  21. >
  22. <el-form-item label="学生:">
  23. <el-input
  24. v-model="filter.studentInfo"
  25. placeholder="请输入姓名或者学号"
  26. clearable
  27. ></el-input>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button type="primary" @click="toPage(1)">查询</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <div class="part-box-action">
  34. <el-button type="success" icon="el-icon-download"
  35. ><a :href="downloadUrl" :download="dfilename"
  36. >模板下载</a
  37. ></el-button
  38. >
  39. <upload-button
  40. btn-icon="el-icon-circle-plus-outline"
  41. btn-content="批量导入"
  42. btn-type="success"
  43. :upload-url="uploadUrl"
  44. :upload-data="uploadData"
  45. :format="['xls', 'xlsx']"
  46. @upload-error="uplaodError"
  47. @upload-success="uploadSuccess"
  48. >
  49. </upload-button>
  50. <el-button
  51. type="primary"
  52. icon="el-icon-circle-plus-outline"
  53. @click="toAdd"
  54. >新增学生</el-button
  55. >
  56. </div>
  57. </div>
  58. <div class="part-box part-box-pad">
  59. <el-table ref="TableList" :data="studentList">
  60. <el-table-column
  61. type="index"
  62. label="序号"
  63. width="70"
  64. :index="indexMethod"
  65. ></el-table-column>
  66. <el-table-column prop="studentName" label="姓名"> </el-table-column>
  67. <el-table-column prop="studentCode" label="学号"> </el-table-column>
  68. <el-table-column prop="belongOrgName" label="院系"> </el-table-column>
  69. <el-table-column prop="majorName" label="专业"> </el-table-column>
  70. <el-table-column prop="clazzName" label="班级"> </el-table-column>
  71. <el-table-column class-name="action-column" label="操作" width="80">
  72. <template slot-scope="scope">
  73. <el-button
  74. class="btn-danger"
  75. type="text"
  76. @click="toDelete(scope.row)"
  77. >移除</el-button
  78. >
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <div class="part-page">
  83. <el-pagination
  84. background
  85. layout="total,prev, pager, next"
  86. :current-page="current"
  87. :total="total"
  88. :page-size="size"
  89. @current-change="toPage"
  90. >
  91. </el-pagination>
  92. </div>
  93. </div>
  94. </el-dialog>
  95. <!-- ModifyStudentSimple -->
  96. <modify-student-simple
  97. ref="ModifyStudentSimple"
  98. :instance="curStudent"
  99. @modified="getList"
  100. ></modify-student-simple>
  101. </div>
  102. </template>
  103. <script>
  104. import { studentSimpleListQuery, deleteStudentSimple } from "../api";
  105. import ModifyStudentSimple from "./ModifyStudentSimple";
  106. import UploadButton from "../../../components/UploadButton";
  107. export default {
  108. name: "modify-clazz-simple-student",
  109. components: { UploadButton, ModifyStudentSimple },
  110. props: {
  111. clazz: {
  112. type: Object,
  113. default() {
  114. return {};
  115. }
  116. }
  117. },
  118. data() {
  119. return {
  120. modalIsShow: false,
  121. filter: {
  122. teachClazzId: "",
  123. studentInfo: ""
  124. },
  125. current: 1,
  126. size: this.GLOBAL.pageSize,
  127. total: 0,
  128. studentList: [],
  129. curStudent: {},
  130. // import
  131. uploadData: {},
  132. uploadUrl: "/api/admin/teach/student/import",
  133. downloadUrl: "/temps/clazzSimpleStudentTemplate.xlsx",
  134. dfilename: "教学班级学生导入模板.xlsx"
  135. };
  136. },
  137. computed: {
  138. title() {
  139. return `学生管理-${this.clazz.teachClazzName}`;
  140. }
  141. },
  142. methods: {
  143. visibleChange() {
  144. this.filter.teachClazzId = this.clazz.id;
  145. this.uploadData = {
  146. teachClazzId: this.clazz.id
  147. };
  148. this.toPage(1);
  149. },
  150. closed() {
  151. this.$emit("modified");
  152. },
  153. cancel() {
  154. this.modalIsShow = false;
  155. },
  156. open() {
  157. this.modalIsShow = true;
  158. },
  159. async getList() {
  160. const datas = {
  161. ...this.filter,
  162. pageNumber: this.current,
  163. pageSize: this.size
  164. };
  165. const data = await studentSimpleListQuery(datas);
  166. this.studentList = data.records;
  167. this.total = data.total;
  168. },
  169. toPage(page) {
  170. this.current = page;
  171. this.getList();
  172. },
  173. toAdd() {
  174. this.curStudent = { teachClazzId: this.clazz.id };
  175. this.$refs.ModifyStudentSimple.open();
  176. },
  177. toDelete(row) {
  178. this.$confirm(`确定要移除学生【${row.studentName}】吗?`, "提示", {
  179. type: "warning"
  180. })
  181. .then(async () => {
  182. await deleteStudentSimple([row.id]);
  183. this.$message.success("操作成功!");
  184. this.deletePageLastItem();
  185. })
  186. .catch(() => {});
  187. },
  188. // import
  189. uplaodError(errorData) {
  190. this.$notify.error({ title: "错误提示", message: errorData.message });
  191. },
  192. uploadSuccess() {
  193. this.$message.success("文件上传成功,后台正在导入!");
  194. this.getList();
  195. }
  196. }
  197. };
  198. </script>