class-pay-list.vue 6.9 KB

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