classList-group.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div>
  3. <el-form :model="form" ref="form">
  4. <classListItem v-for="(item, index) in form.classList" :key="index" :index="index" :item="item"
  5. @deteleClass="deteleClass" :soundList="soundList" :form="form" :classList="activeClassList" @filterClassList="filterClassList" />
  6. </el-form>
  7. <!-- <el-button
  8. icon="el-icon-circle-plus-outline"
  9. plain
  10. type="info"
  11. style="width: 100%; margin: 20px 0"
  12. @click="addClass"
  13. :disabled="form.classList.length >= classList.length"
  14. >添加班级</el-button
  15. > -->
  16. <el-dialog :visible.sync="showSecondVisable" title="缴费信息设置" append-to-body width="800px">
  17. <classPayList :classIdList="classIdList" :addCourseType="addCourseType" :courseTypesByType="courseTypesByType"
  18. :classMaxCourseNumMap="classMaxCourseNumMap" :form="form" :teacherList="teacherList" :payInfo.sync="payInfo"
  19. @resetPayInfo="resetPayInfo" @close="showSecondVisable = false" v-if="showSecondVisable" />
  20. </el-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. import classListItem from "./classList-item";
  25. import classPayList from "./class-pay-list";
  26. import { getDefaultPaymentCalender } from "@/api/buildTeam";
  27. export default {
  28. props: ["classList", "courseTypesByType", "teacherList", "soundList"],
  29. components: { classListItem, classPayList },
  30. data() {
  31. return {
  32. form: {
  33. classList: [
  34. {
  35. classId: "",
  36. studentList: [],
  37. courseList: {},
  38. index: "",
  39. type: "",
  40. classList: this.classList,
  41. },
  42. ],
  43. },
  44. showSecondVisable: false,
  45. classIdList: [],
  46. activeClassList: [],
  47. addCourseType: [],
  48. };
  49. },
  50. mounted() {
  51. this.activeClassList = this.classList;
  52. },
  53. methods: {
  54. addClass() {
  55. this.form.classList.push({
  56. classId: "",
  57. studentList: [],
  58. courseList: {},
  59. index: "",
  60. type: "",
  61. classList: this.classList,
  62. });
  63. },
  64. deteleClass(index) {
  65. this.form.classList.splice(index, 1);
  66. },
  67. gotoSecond() {
  68. this.$refs.form.validate(async (res) => {
  69. if (res) {
  70. let flag = false;
  71. this.form.classList.forEach((item) => {
  72. if (item.studentList.length <= 0) {
  73. flag = true;
  74. }
  75. });
  76. if (flag) {
  77. this.$message.error("每个班级至少勾选一名学员");
  78. return;
  79. }
  80. this.classIdList = this.form.classList.map((item) => {
  81. return item.classId;
  82. });
  83. try {
  84. let result = await getDefaultPaymentCalender(this.classIdList);
  85. this.payInfo = result.data.defaultPaymentCalender;
  86. this.addCourseType = result.data.groupTypeSet;
  87. this.classMaxCourseNumMap = result.data.classMaxCourseNumMap;
  88. this.showSecondVisable = true;
  89. } catch { }
  90. }
  91. });
  92. },
  93. filterClassList(id) {
  94. let arr = [];
  95. this.form.classList.forEach((item) => {
  96. if (item.classId) {
  97. arr.push(item.classId);
  98. }
  99. });
  100. if (id) {
  101. let item;
  102. // 找到对应的班级
  103. this.classList.forEach((classes) => {
  104. if (classes.id == id) {
  105. item = classes;
  106. }
  107. });
  108. this.form.classList.forEach((classes) => {
  109. if (classes.classId == id) {
  110. classes.type = item.type;
  111. }
  112. });
  113. // 过滤类型不一样的
  114. this.activeClassList = this.classList.filter((classes) => {
  115. return item.type == classes.type;
  116. });
  117. this.addDisabled(arr);
  118. } else {
  119. if (arr.length == 0) {
  120. this.activeClassList = this.classList;
  121. } else {
  122. this.addDisabled(arr);
  123. }
  124. }
  125. },
  126. addDisabled(arr) {
  127. this.activeClassList = this.activeClassList.map((classes) => {
  128. return {
  129. ...classes,
  130. disabled: arr.indexOf(classes.id) != -1,
  131. };
  132. });
  133. },
  134. resetPayInfo(key, value, time) {
  135. console.log(value, time);
  136. console.log(this.payInfo);
  137. let obj = { ...this.payInfo };
  138. for (let k in obj) {
  139. if (obj[k][key]) {
  140. obj[k][key].courseCurrentPrice = value;
  141. obj[k][key].courseOriginalPrice = value;
  142. obj[k][key].courseTotalMinuties = parseInt(time);
  143. }
  144. }
  145. this.payInfo = obj;
  146. },
  147. },
  148. };
  149. </script>
  150. <style lang="scss" scoped></style>