class-pay-list.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div>
  3. <el-alert title="课程时长设置" type="info" :closable="false"> </el-alert>
  4. <el-form :model="courseTimeForm" ref="courseTimeForms" :inline="true" style="margin-top: 20px">
  5. <el-form-item v-for="(item, index) in courseTimeForm.timeList" :key="index" :label="item.label"
  6. :prop="'timeList.' + index + '.value'" :rules="[
  7. { required: true, message: '请选择课程时长', trigger: 'blur' },
  8. ]" label-width="100px">
  9. <el-select clearable v-model="item.value" placeholder="请选择课程时长" @change="(val) => setCourseTime(item, val)">
  10. <el-option v-for="(time, index) in item.list" :key="index" :value="time" :label="time"></el-option>
  11. </el-select>
  12. </el-form-item>
  13. </el-form>
  14. <classPayListItem :payInfo="payInfo" ref="base" :courseTypesByType="courseTypesByType"
  15. v-for="(item, index) in form.classList" :key="index" :item="item" :index="index" />
  16. <div slot="footer" class="dialog-footer">
  17. <el-button @click="close">上一步</el-button>
  18. <el-button type="primary" @click="gotoLast">下一步</el-button>
  19. </div>
  20. <div style="clear: both"></div>
  21. <el-dialog :visible.sync="showLastVisable" title="结果确认" append-to-body width="800px">
  22. <classSetting :form="form" ref="classSetting" :musicGroupPaymentCalenderDtos="musicGroupPaymentCalenderDtos"
  23. :classType="5" :musicGroupId="teamid" :activeType="activeType" :courseTypeList="courseTypeList"
  24. :studentSubmitedData="studentSubmitedData" :classIdList="classIdList" :classGroupStudents="classGroupStudents"
  25. :selectPrices="classCourseMinuteMap" :classCouresTimeList="classCouresTimeList" :teacherList="teacherList"
  26. :cooperationList="teacherList" @close="showLastVisable = false" v-if="showLastVisable" />
  27. <div slot="footer" class="dialog-footer">
  28. <el-button @click="showLastVisable = false">上一步</el-button>
  29. <el-button type="primary" @click="submitResetClass">确 定</el-button>
  30. </div>
  31. </el-dialog>
  32. </div>
  33. </template>
  34. <script>
  35. import classNewInfo from "./class-new-info";
  36. import classPayListItem from "./class-pay-list-item";
  37. import classSetting from "./classroom-setting-merge";
  38. import { getCourseType } from "@/utils/utils";
  39. import { courseType, classTime } from "@/constant";
  40. import { getOrganCourseDurationSettings } from "@/api/buildTeam";
  41. import MusicStore from "@/views/resetTeaming/store";
  42. export default {
  43. props: [
  44. "form",
  45. "payInfo",
  46. "courseTypesByType",
  47. "classIdList",
  48. "addCourseType",
  49. "classMaxCourseNumMap",
  50. "teacherList",
  51. ],
  52. components: {
  53. classNewInfo,
  54. classPayListItem,
  55. classSetting,
  56. },
  57. data() {
  58. return {
  59. showLastVisable: false,
  60. musicGroupPaymentCalenderDtos: null,
  61. teacherList: [],
  62. studentList: [],
  63. teamid: "",
  64. activeType: "",
  65. courseTypeList: [],
  66. studentSubmitedData: {},
  67. classGroupStudents: [],
  68. courseTimeForm: {
  69. timeList: [],
  70. },
  71. organId: "",
  72. organCourseTime: {},
  73. classCourseMinuteMap: {},
  74. };
  75. },
  76. async mounted() {
  77. // 1.查询该分部下得所有课程时长
  78. // 2.组成select需要得选项并且指定
  79. this.teamid = this.$route.query.id;
  80. MusicStore.dispatch("getBaseInfo", {
  81. data: { musicGroupId: this.teamid },
  82. }).then(async (res) => {
  83. this.organId = res.data.musicGroup.organId;
  84. try {
  85. const res = await getOrganCourseDurationSettings({
  86. organId: this.organId,
  87. });
  88. this.organCourseTime = res.data;
  89. this.setTimeList(res.data);
  90. } catch { }
  91. });
  92. },
  93. methods: {
  94. init() {
  95. // this.$store.dispatch('setTeachers')
  96. this.studentList = [];
  97. let classGroupStudents = [];
  98. this.form.classList.forEach((classes) => {
  99. this.studentList = this.studentList.concat(classes.studentList);
  100. let arr = [];
  101. classes.studentList.forEach((stu) => {
  102. arr.push(stu.userId);
  103. });
  104. classGroupStudents.push({ [classes.classId]: arr.join(",") });
  105. });
  106. this.classGroupStudents = classGroupStudents;
  107. this.teamid = this.$route.query.id;
  108. this.activeType = this.form.classList[0].type;
  109. this.courseTypeList = getCourseType(this.activeType);
  110. this.studentSubmitedData = {
  111. name: "",
  112. seleched: this.studentList.map((stu) => {
  113. return stu.userId;
  114. }),
  115. };
  116. this.courseTimeForm.timeList.map((item) => {
  117. this.classCourseMinuteMap[item.type] = item.value;
  118. });
  119. // this.classMaxCourseNumMap;
  120. this.classCouresTimeList = {};
  121. for (let key in this.classCourseMinuteMap) {
  122. this.classCouresTimeList[key] =
  123. this.classMaxCourseNumMap[key] * this.classCourseMinuteMap[key];
  124. }
  125. this.showLastVisable = true;
  126. },
  127. close() {
  128. this.$emit("close");
  129. },
  130. getForms() {
  131. const { $refs: refs } = this;
  132. // [refs.base, refs.eclass, refs.cycle, ...(refs.cycles || []), refs.other, refs.payment]
  133. return [...refs.base]
  134. .filter((item) => !!item)
  135. .map((item) => item.$refs.form || item);
  136. },
  137. gotoLast() {
  138. this.$refs.courseTimeForms.validate((_) => {
  139. if (_) {
  140. const forms = this.getForms();
  141. let musicGroupPaymentCalenderDtos = [];
  142. // 判断有没有缴费项目(因为又可能没有)
  143. // let flag = false
  144. let arr = [];
  145. for (const form of forms) {
  146. let data = form.getData();
  147. if (data == "error") {
  148. arr.push(data);
  149. }
  150. if (data && data != "error") {
  151. musicGroupPaymentCalenderDtos.push(data);
  152. }
  153. }
  154. if (arr.length > 0) {
  155. return;
  156. }
  157. this.musicGroupPaymentCalenderDtos = musicGroupPaymentCalenderDtos;
  158. this.init();
  159. }
  160. });
  161. // 弹出最后一页
  162. },
  163. submitResetClass() {
  164. this.$refs.classSetting.submit();
  165. },
  166. setTimeList(organCourseTime) {
  167. this.addCourseType.map((course) => {
  168. let arr = [];
  169. if (organCourseTime[course]) {
  170. arr = organCourseTime[course].split(",");
  171. } else {
  172. arr = [classTime[course]];
  173. }
  174. this.courseTimeForm.timeList.push({
  175. type: course,
  176. value: "",
  177. label: courseType[course],
  178. list: arr,
  179. });
  180. });
  181. },
  182. setCourseTime(item, val) {
  183. console.log(this.payInfo);
  184. let obj = { ...this.payInfo };
  185. for (let k in obj) {
  186. if (obj[k][item.type]) {
  187. let courseCurrentPrice = val
  188. ? val * obj[[k]][item.type].unitPrice
  189. : 0;
  190. let courseTotalMinuties = val
  191. ? val * obj[[k]][item.type].courseTotalNum
  192. : 0;
  193. this.$emit(
  194. "resetPayInfo",
  195. item.type,
  196. courseCurrentPrice,
  197. courseTotalMinuties
  198. );
  199. }
  200. }
  201. this.payInfo = obj;
  202. },
  203. },
  204. };
  205. </script>
  206. <style lang="scss" scoped>
  207. .studentTitle {
  208. width: 120px !important;
  209. text-align: right;
  210. display: inline-block;
  211. color: #409eff;
  212. }
  213. .dialog-footer {
  214. text-align: right;
  215. }
  216. </style>