AddClazzSimpleDialog.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <el-dialog
  3. class="modify-course-simple"
  4. :visible.sync="modalIsShow"
  5. title="添加教学班"
  6. top="10px"
  7. width="800px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <el-form ref="FilterForm" label-position="left" inline label-width="0px">
  14. <el-form-item>
  15. <el-input
  16. v-model.trim="clazzName"
  17. placeholder="请输入教学班名称"
  18. clearable
  19. ></el-input>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" @click="getList">查询</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-table
  26. ref="TableList"
  27. :data="dataList"
  28. border
  29. max-height="440px"
  30. @selection-change="handleSelectionChange"
  31. >
  32. <el-table-column
  33. type="selection"
  34. width="55"
  35. align="center"
  36. ></el-table-column>
  37. <el-table-column
  38. type="index"
  39. label="序号"
  40. width="70"
  41. :index="indexMethod"
  42. ></el-table-column>
  43. <el-table-column
  44. prop="clazzName"
  45. label="教学班名称"
  46. min-width="120"
  47. ></el-table-column>
  48. <el-table-column
  49. prop="courseCode"
  50. label="课程编码"
  51. min-width="120"
  52. ></el-table-column>
  53. </el-table>
  54. <div slot="footer">
  55. <el-button type="primary" :disabled="isSubmit" @click="submit"
  56. >确认</el-button
  57. >
  58. <el-button @click="cancel">取消</el-button>
  59. </div>
  60. </el-dialog>
  61. </template>
  62. <script>
  63. import { updateClazzSimple, basicTeachClazzListPage } from "../../api";
  64. export default {
  65. name: "add-clazz-simple-dialog",
  66. props: {
  67. course: {
  68. type: Object,
  69. default() {
  70. return {};
  71. },
  72. },
  73. },
  74. data() {
  75. return {
  76. modalIsShow: false,
  77. isSubmit: false,
  78. dataList: [],
  79. clazzName: "",
  80. multipleSelection: [],
  81. };
  82. },
  83. methods: {
  84. visibleChange() {
  85. this.multipleSelection = [];
  86. this.getList();
  87. },
  88. cancel() {
  89. this.modalIsShow = false;
  90. },
  91. open() {
  92. this.modalIsShow = true;
  93. },
  94. async getList() {
  95. const datas = {
  96. examId: this.course.examId,
  97. clazzName: this.clazzName,
  98. };
  99. const data = await basicTeachClazzListPage(datas);
  100. this.dataList = data || [];
  101. },
  102. handleSelectionChange(val) {
  103. this.multipleSelection = val.map((item) => item.id);
  104. },
  105. async submit() {
  106. if (!this.multipleSelection.length) {
  107. this.$message.error("请选择班级");
  108. return;
  109. }
  110. if (this.isSubmit) return;
  111. this.isSubmit = true;
  112. const data = await updateClazzSimple({
  113. idList: this.multipleSelection,
  114. teachCourseId: this.course.id,
  115. }).catch(() => {});
  116. this.isSubmit = false;
  117. if (!data) return;
  118. this.$message.success("添加成功!");
  119. this.multipleSelection = [];
  120. this.$refs.TableList.clearSelection();
  121. this.$emit("modified");
  122. this.cancel();
  123. },
  124. },
  125. };
  126. </script>