class-pay-list.vue 6.8 KB

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