VIP00Apply.vue 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. <template>
  2. <div class="vipapply">
  3. <m-header v-if="statusList.headerStatus" />
  4. <div class="vip-title">课程信息</div>
  5. <van-cell-group>
  6. <!-- <van-field v-model="form.name" label="课程班名称" input-align="right" size="large" placeholder="请输入班级名称" /> -->
  7. <van-field v-model="formName.subjectListName" @click="onGetSheetList('subjectList')" label="科目名称" :readonly="true" input-align="right" is-link size="large" placeholder="请选择" />
  8. <van-field v-model="formName.vipGroupCategoryName" @click="onGetSheetList('vipGroupCategory')" label="课程形式" :readonly="true" input-align="right" is-link size="large" placeholder="请选择" />
  9. <van-field v-model="formName.educationalTeacherName" @click="onGetSheetList('teacherList')" label="乐团主管" :readonly="true" input-align="right" is-link size="large" placeholder="请选择" />
  10. <van-cell title="上课学生" @click="onCheckStudent" :readonly="true" input-align="right" :is-link="checkboxSelectDataList.length > 0 ? false : true" size="large" :value="checkboxSelectDataList.length > 0 ? '重新选择' : '请选择'" :value-class="checkboxSelectDataList.length > 0 ? 'studentColor' : null" />
  11. <div v-if="checkboxSelectDataList.length > 0" style="text-align: center;line-height: 1.8; padding: .05rem 0;background: #fafbff;">
  12. <p style="color: #323233;" v-for="(item, index) in checkboxSelectDataList" :key="index">
  13. {{ item.userName }} - {{ item.phone }}
  14. </p>
  15. </div>
  16. <van-field v-model="formName.vipGroupActivityName" @click="onGetSheetList('vipGroupActivity')" label="活动方案" :readonly="true" input-align="right" is-link size="large" placeholder="请选择" />
  17. </van-cell-group>
  18. <div class="vip-title">课时组成</div>
  19. <van-cell-group>
  20. <van-field v-model="form.studentNum" label="每班人数" disabled input-align="right" size="large" placeholder="每班预计招收人数" />
  21. <van-field v-model="form.singleClassMinutes" @click="onClickSingleClass" label="每课时长" :readonly="true" input-align="right" is-link size="large" placeholder="请输入每课时长" />
  22. <!-- 判断是否选择活动方案 -->
  23. <div class="courseTips" v-if="loadData.vipGroupActivitySelect.type == 'DISCOUNT' && (loadData.vipGroupActivitySelect.maxCourseNum > 0 && loadData.vipGroupActivitySelect.minCourseNum > 0)">
  24. 该活动最小课时数:<span>{{ loadData.vipGroupActivitySelect.minCourseNum }}</span>节 最大课时数:<span>{{ loadData.vipGroupActivitySelect.maxCourseNum }}</span>节
  25. </div>
  26. <van-field v-if="statusList.hasOnline" v-model="form.onlineClassesNums" @keyup="onClassKeyUp" label="线上课" input-align="right" size="large" placeholder="请输入次数" type="number" />
  27. <van-field v-if="statusList.hasOffline" v-model="form.offlineClassesNums" @keyup="onClassKeyUp('offLine')" label="线下课" input-align="right" size="large" placeholder="请输入次数" type="number" />
  28. <van-field v-if="form.offlineClassesNums > 0" v-model="formName.teacherSchoolName" @click="onGetSheetList('teacherSchool')" label="线下课地址" :readonly="true" input-align="right" is-link size="large" placeholder="请选择" />
  29. <!-- <van-field v-if="formName.vipGroupActivityName || statusList.hasOnline" v-model="form.onlineClassesNums" @keyup="onClassKeyUp" label="线上课" input-align="right" size="large" placeholder="请输入次数" type="number" />
  30. <van-field v-if="formName.vipGroupActivityName || statusList.hasOffline" v-model="form.offlineClassesNums" @keyup="onClassKeyUp" label="线下课" input-align="right" size="large" placeholder="请输入次数" type="number" /> -->
  31. <van-field v-model="form.totalClassTime" label="课时总数" disabled input-align="right" size="large" placeholder="请输入次数" />
  32. <van-field v-if="statusList.teachOnOrOff" v-model="formName.giveTeachModeName" @click="onGiveMode" label="赠课类型" :readonly="true" input-align="right" is-link size="large" placeholder="请选择" />
  33. </van-cell-group>
  34. <div class="vip-title">时间安排</div>
  35. <van-cell-group>
  36. <van-cell title="最早排课时间" :readonly="true" v-if="loadData.vipGroupActivitySelect.coursesStartTime" input-align="right" size="large">
  37. <template #default>
  38. {{ dayjs(loadData.vipGroupActivitySelect.coursesStartTime).format('YYYY-MM-DD') }}
  39. </template>
  40. </van-cell>
  41. <van-cell title="最晚排课时间" :readonly="true" v-if="loadData.vipGroupActivitySelect.coursesEndTime" input-align="right" size="large">
  42. <template #default>
  43. {{ dayjs(loadData.vipGroupActivitySelect.coursesEndTime).format('YYYY-MM-DD') }}
  44. </template>
  45. </van-cell>
  46. <!-- <van-field v-if="loadData.vipGroupActivitySelect.coursesStartTime" v-model="loadData.vipGroupActivitySelect.coursesStartTime" label="最早排课时间" disabled input-align="right" size="large" placeholder="请选择" />
  47. <van-field v-if="loadData.vipGroupActivitySelect.coursesEndTime" v-model="loadData.vipGroupActivitySelect.coursesEndTime" label="最晚排课时间" disabled input-align="right" size="large" placeholder="请选择" /> -->
  48. <van-field v-model="form.registrationStartTime" label="报名开始时间" disabled @click="onEnListShow('start', form.registrationStartTime)" input-align="right" is-link size="large" placeholder="请选择" />
  49. <van-field v-model="form.coursesExpireDate" label="报名截止时间" disabled @click="onEnListShow('end', form.coursesExpireDate)" input-align="right" is-link size="large" placeholder="请选择" />
  50. </van-cell-group>
  51. <div class="vip-title">课时安排</div>
  52. <van-cell-group>
  53. <van-field @click="dataForm.status = true" v-model="form.courseStart" label="排课开始时间" :readonly="true" input-align="right" is-link size="large" placeholder="请选择" />
  54. <van-cell title-class="title-time" v-for="(item, index) in scheduleList" :key="index">
  55. <template slot="title">
  56. <span class="online">{{ item.type }}</span>
  57. <span class="week">{{ item.weekStr }}</span>
  58. <span class="timer">{{ item.startTime + '-' + item.endTime }}</span>
  59. </template>
  60. <template slot="default">
  61. <van-button type="warning" @click="onScheduleRemove(item)" round size="small" plain>删除</van-button>
  62. </template>
  63. </van-cell>
  64. <div class="add-plan van-cell" @click="onCourseShedule">
  65. <van-icon name="add-o" />课时安排
  66. </div>
  67. <van-field label="排课列表" v-if="scheduleList.length > 0" disabled input-align="right" @click="onShowTimeTable" is-link size="large" />
  68. </van-cell-group>
  69. <div class="vip-title">课酬设置</div>
  70. <van-cell-group>
  71. <van-field v-model="form.onlineClassesUnitPrice" label="线上课单价" type="number" input-align="right" size="large" @keyup="getCalcClass" :disabled="loadData.vipGroupActivitySelect.paymentReadonlyFlag == 0" placeholder="金额(每课时)" v-if="statusList.hasOnline" />
  72. <van-field v-model="form.offlineClassesUnitPrice" label="线下课单价" type="number" input-align="right" size="large" @keyup="getCalcClass" :disabled="loadData.vipGroupActivitySelect.paymentReadonlyFlag == 0" placeholder="金额(每课时)" v-if="statusList.hasOffline" />
  73. <van-field v-model="form.onlineTeacherSalary" label="线上课课酬" input-align="right" size="large" :disabled="loadData.vipGroupActivitySelect.salaryReadonlyFlag == 0" placeholder="金额(每课时)" v-if="statusList.hasOnline" type="number" />
  74. <!-- || other.onlineSalary !='TEACHER_DEFAULT' -->
  75. <van-field v-model="form.offlineTeacherSalary" label="线下课课酬" input-align="right" size="large" :disabled="loadData.vipGroupActivitySelect.salaryReadonlyFlag == 0" placeholder="金额(每课时)" v-if="statusList.hasOffline" type="number" />
  76. <!-- || other.offlineSalary !='TEACHER_DEFAULT' -->
  77. <van-field v-model="form.totalCount" disabled label="课程总价" input-align="right" size="large" placeholder="金额(每课时)" />
  78. </van-cell-group>
  79. <div class="button-group">
  80. <van-button type="primary" @click="onSubmit" round size="large">确认</van-button>
  81. </div>
  82. <!-- 每课时长 -->
  83. <van-action-sheet v-model="statusList.classTimerStatus" :actions="loadData.classTimer" cancel-text="取消" @cancel="statusList.classTimerStatus = false" @select="onClassTimerSelect" />
  84. <!-- 报名开始时间&报名结束时间 -->
  85. <van-popup v-model="enlistForm.status" position="bottom">
  86. <van-datetime-picker v-model="enlistForm.currentDate" type="date" :min-date="enlistForm.minDate" :max-date="enlistForm.maxDate" :formatter="formatter" @cancel="enlistForm.status = false" @confirm="onEnlistConfirm" />
  87. </van-popup>
  88. <!-- 赠课类型 -->
  89. <van-action-sheet v-model="statusList.giveTeachModeStatus" :actions="loadData.giveTeachMode" cancel-text="取消" @cancel="statusList.giveTeachModeStatus = false" @select="onModeSelect" />
  90. <!-- 课程信息所用 :close-on-click-overlay="false" -->
  91. <van-popup v-model="sheetForm.sheetStatus" position="bottom">
  92. <van-picker :loading="sheetForm.loading" :default-index="sheetForm.index" :columns="sheetForm.columns" show-toolbar @cancel="sheetForm.sheetStatus = false" @confirm="onSheetConfirm" />
  93. </van-popup>
  94. <!-- 课时安排 -->
  95. <van-popup v-model="dataForm.status" position="bottom">
  96. <van-datetime-picker v-model="dataForm.currentDate" type="date" :min-date="dataForm.minDate" :max-date="dataForm.maxDate" :formatter="formatter" @cancel="dataForm.status = false" @confirm="onCurrentConfirm" />
  97. </van-popup>
  98. <!-- 课时安排 -->
  99. <van-popup v-model="courseForm.teachingStatus" position="bottom">
  100. <van-picker :columns="courseForm.columns" show-toolbar @cancel="courseForm.teachingStatus = false" @confirm="onTeachinConfirm" />
  101. </van-popup>
  102. <!-- 选择上课学生 -->
  103. <van-popup v-model="statusList.studentStatus" :lock-scroll="true" position="bottom" :style="{ height: '180%' }">
  104. <van-sticky>
  105. <van-search show-action shape="round" @search="onSearch" v-model="params.search" placeholder="请输入学生名或手机号">
  106. <template #action>
  107. <div @click="onSearch">搜索</div>
  108. </template>
  109. </van-search>
  110. </van-sticky>
  111. <div class="paddingB80">
  112. <van-list v-model="loading" class="studentContainer" v-if="dataShow" key="data" :finished="finished" finished-text="" @load="getStudent">
  113. <van-checkbox-group v-model="checkboxSelect">
  114. <van-cell-group>
  115. <van-cell v-for="(item, index) in dataList" :key="index" @click="onCheckboxSelect(item)" class="input-cell" :center="true">
  116. <template slot="icon">
  117. <img class="logo" v-if="item.avatar" :src="item.avatar" alt="">
  118. <img class="logo" v-else src="@/assets/images/icon_student.png" alt="">
  119. </template>
  120. <template slot="title">
  121. {{ item.userName }}
  122. </template>
  123. <template slot="label">
  124. <span>{{ desensitPhone(item.phone) }}</span>
  125. </template>
  126. <template slot="default">
  127. <van-checkbox :name="item.userId.toString()"></van-checkbox>
  128. </template>
  129. </van-cell>
  130. </van-cell-group>
  131. </van-checkbox-group>
  132. </van-list>
  133. <m-empty class="empty" msg="暂无学生" v-else key="data" />
  134. </div>
  135. <div class="button-group-popup">
  136. <span class="btn" @click="onPopupCancel">取消</span>
  137. <span class="btn primary" @click="onPopupSubmit">确定</span>
  138. </div>
  139. </van-popup>
  140. <!-- 课表展示 -->
  141. <van-popup v-model="statusList.classTime" position="bottom">
  142. <van-row>
  143. <van-col span="12">上课类型</van-col>
  144. <van-col span="12">上课时间</van-col>
  145. </van-row>
  146. <div class="tableContainer">
  147. <van-row v-for="(item, index) in timeTable" :key="index">
  148. <van-col span="12">
  149. {{ item.teachMode == 'ONLINE' ? '线上' : '线下' }}
  150. </van-col>
  151. <van-col span="12">
  152. {{ item.classDate }} {{ item.startClassTimeStr }}
  153. </van-col>
  154. </van-row>
  155. </div>
  156. </van-popup>
  157. </div>
  158. </template>
  159. <script>
  160. /* eslint-disable */
  161. import MHeader from '@/components/MHeader'
  162. import {
  163. browser
  164. } from '@/common/common'
  165. import MEmpty from '@/components/MEmpty'
  166. import {
  167. findSubSubjects,
  168. vipGroupCategory,
  169. findByVipGroupCategory,
  170. findVipSchoolByTeacher2,
  171. findByTeacherAndCategory,
  172. vipGroupApply,
  173. findEducationUsers,
  174. queryStudentsWithTeacher
  175. } from '@/api/teacher'
  176. import setLoading from '@/utils/loading'
  177. import dayjs from 'dayjs'
  178. let minutes = [] // 分钟数
  179. for (let i = 0; i < 60; i++) {
  180. let mi = i < 10 ? '0' + i : i
  181. minutes.push(mi + '分')
  182. }
  183. export default {
  184. name: 'vipapply',
  185. components: {
  186. MHeader,
  187. MEmpty
  188. },
  189. data() {
  190. return {
  191. dataForm: { // 时间下拉框
  192. status: false,
  193. minDate: new Date(),
  194. maxDate: new Date(2025, 10, 1),
  195. currentDate: new Date()
  196. },
  197. enlistForm: { // 时间下拉框
  198. updateStatus: '', // 修改哪个状态
  199. status: false,
  200. minDate: new Date(),
  201. maxDate: new Date(2025, 10, 1),
  202. currentDate: new Date()
  203. },
  204. statusList: { // 散状态集合
  205. giveTeachModeStatus: false, // 赠课弹窗状态
  206. teachOnOrOff: false, // 是否显示赠课
  207. hasOnline: false, // 是否显示线上
  208. hasOffline: false, // 是否显示线下
  209. classTime: false, // 课表展示
  210. headerStatus: false, // 头部是否展示
  211. classTimerStatus: false, // 每课时长状态
  212. studentStatus: false, // 上课学生状态
  213. },
  214. loadData: { // 下拉加载数据
  215. subjectList: [], // 声部列表
  216. subjectListSelect: [], // 选中的声部JSON
  217. vipGroupCategory: [], // 课程形式
  218. vipGroupCategorySelect: [], // 选中的课程形式JSON
  219. vipGroupActivity: [], // 活动文案
  220. vipGroupActivitySelect: [], // 选中的活动文案JSON
  221. teacherSchool: [], // 线下课地址
  222. teacherSchoolSelect: [], // 选中的线下课地址JSON
  223. teacherList: [], // 线下课地址
  224. teacherListSelect: [], // 选中的线下课地址JSON
  225. giveTeachMode: [{
  226. name: '线上课',
  227. value: 'ONLINE'
  228. }, {
  229. name: '线下课',
  230. value: 'OFFLINE'
  231. }], // 赠课
  232. giveTeachModeSelect: [], // 选中的赠课JSON
  233. teacherCategory: [], // 老师课酬信息
  234. classTimer: [], // 每课时长
  235. },
  236. sheetForm: { // 上拉弹窗
  237. currentType: null, // 当前选择的类型
  238. sheetStatus: false,
  239. loading: true, // 加载数据
  240. index: 0, // 选中的索引值
  241. columns: []
  242. },
  243. courseForm: { // 排课弹窗
  244. teachingStatus: false, // 课时安排状态
  245. columns: [{ // 课程选项
  246. values: ['线上', '线下'],
  247. className: 'type'
  248. }, {
  249. values: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  250. className: 'week'
  251. }, {
  252. values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
  253. className: 'hours',
  254. defaultIndex: 7
  255. }, {
  256. values: minutes,
  257. className: 'minutes'
  258. }]
  259. },
  260. form: {
  261. name: null,
  262. subjectIdList: null,
  263. vipGroupCategoryId: null,
  264. vipGroupActivityId: null,
  265. teacherSchoolId: null,
  266. educationalTeacherId: null,
  267. studentNum: null,
  268. singleClassMinutes: null,
  269. onlineClassesNums: null,
  270. offlineClassesNums: null,
  271. registrationStartTime: null,
  272. coursesExpireDate: null,
  273. totalClassTime: null,
  274. courseStart: null,
  275. giveTeachMode: null,
  276. onlineClassesUnitPrice: null,
  277. offlineClassesUnitPrice: null,
  278. onlineTeacherSalary: null,
  279. offlineTeacherSalary: null,
  280. totalCount: null,
  281. },
  282. formName: {
  283. subjectListName: null, // 声部名称
  284. subjectListIndex: 0, // 声部名称
  285. vipGroupCategoryName: null, // 课程形式
  286. vipGroupCategoryIndex: 0, // 课程形式
  287. vipGroupActivityName: null, // 活动文案
  288. vipGroupActivityIndex: 0, // 活动文案
  289. teacherSchoolName: null, // 线下课地址
  290. teacherSchoolIndex: 0, // 线下课地址
  291. giveTeachModeName: null, // 赠课类型
  292. educationalTeacherName: null, // 乐团主管
  293. educationalTeacherIndex: 0,
  294. },
  295. other: {
  296. onlineSalary: null, // 线上课课酬结算方式
  297. offlineSalary: null, // 线下课课酬结算方式
  298. giveNum: 0, // 赠送课时
  299. },
  300. scheduleList: [], // 课时安排
  301. timeTable: [], // 生成的课表
  302. onSubmitStatus: true, // 点击
  303. checkboxSelect: [],
  304. checkboxSelectIds: [],
  305. checkboxSelectList: [], //选中学生列表
  306. checkboxSelectDataList: [],
  307. loading: false,
  308. finished: false,
  309. params: {
  310. search: null,
  311. page: 1,
  312. rows: 20
  313. },
  314. dataShow: true, // 是否有数据
  315. dataList: [],
  316. salaryStatus: true, // 是否跳过课酬二次确认
  317. }
  318. },
  319. mounted() {
  320. let params = this.$route.query
  321. if (params.Authorization) {
  322. localStorage.setItem('Authorization', decodeURI(params.Authorization))
  323. localStorage.setItem('userInfo', decodeURI(params.Authorization))
  324. }
  325. document.title = 'VIP课程班申请'
  326. if (browser().android) {
  327. this.headerStatus = true
  328. }
  329. },
  330. methods: {
  331. dayjs,
  332. onCheckStudent() {
  333. if (!this.form.vipGroupCategoryId) { // 判断是否选择了课程形式
  334. this.$toast('请选择课程形式')
  335. return
  336. }
  337. // this.checkboxSelectIds = JSON.parse(JSON.stringify(this.checkboxSelectIds))
  338. // this.checkboxSelectDataList = JSON.parse(JSON.stringify(this.checkboxSelectDataList))
  339. this.statusList.studentStatus = true
  340. },
  341. onGetSheetList(name) { // 获取科目列表
  342. let sheetForm = this.sheetForm
  343. sheetForm.columns = []
  344. if (!this.form.vipGroupCategoryId && name == 'vipGroupActivity') { // 判断是否选择了课程形式
  345. this.$toast('请选择课程形式')
  346. return
  347. }
  348. sheetForm.sheetStatus = true
  349. sheetForm.loading = true
  350. sheetForm.currentType = name
  351. sheetForm.index = 0
  352. let arr = this.loadData[name]
  353. if (arr.length > 0) {
  354. sheetForm.columns = arr
  355. sheetForm.index = this.formName[name + 'Index']
  356. sheetForm.loading = false
  357. } else {
  358. this.onLoadingData(name)
  359. }
  360. },
  361. onLoadingData() { // 加载数据
  362. let sheetForm = this.sheetForm
  363. if (sheetForm.currentType == 'subjectList') { // 声部列表
  364. findSubSubjects().then(res => {
  365. let result = res.data
  366. if (result.code == 200 && result.data.length > 0) {
  367. let tempArr = []
  368. result.data.forEach(item => {
  369. item.value = item.id
  370. item.text = item.name
  371. tempArr.push(item)
  372. })
  373. this.loadData.subjectList = tempArr
  374. sheetForm.columns = tempArr
  375. sheetForm.loading = false
  376. } else {
  377. this.$toast('暂无科目列表')
  378. sheetForm.loading = false
  379. }
  380. })
  381. } else if (sheetForm.currentType == 'vipGroupCategory') { // 课程形式
  382. vipGroupCategory().then(res => {
  383. let result = res.data
  384. if (result.code == 200 && result.data.length > 0) {
  385. let tempArr = []
  386. result.data.forEach(item => {
  387. item.value = item.id
  388. item.text = item.name
  389. tempArr.push(item)
  390. })
  391. this.loadData.vipGroupCategory = tempArr
  392. sheetForm.columns = tempArr
  393. sheetForm.loading = false
  394. } else {
  395. this.$toast('暂无课程形式')
  396. sheetForm.loading = false
  397. }
  398. })
  399. } else if (sheetForm.currentType == 'vipGroupActivity') { // 活动文案
  400. findByVipGroupCategory({
  401. categoryId: this.form.vipGroupCategoryId
  402. }).then(res => {
  403. let result = res.data
  404. if (result.code == 200 && result.data.length > 0) {
  405. let tempArr = []
  406. let regStr = new RegExp('双十一')
  407. result.data.forEach(item => {
  408. if(!regStr.test(item.name)) {
  409. item.value = item.id
  410. item.text = item.name
  411. item.startTime = item.startTime ? item.startTime.split(' ')[0] : null, // 报名开始时间
  412. item.endTime = item.endTime ? item.endTime.split(' ')[0] : null // 报名结束时间
  413. tempArr.push(item)
  414. }
  415. })
  416. this.loadData.vipGroupActivity = tempArr
  417. sheetForm.columns = tempArr
  418. sheetForm.loading = false
  419. } else {
  420. this.$toast('暂无活动方案')
  421. sheetForm.loading = false
  422. }
  423. })
  424. } else if (sheetForm.currentType == 'teacherSchool') { // 教师教学点
  425. findVipSchoolByTeacher2().then(res => {
  426. let result = res.data
  427. if (result.code == 200 && result.data.length > 0) {
  428. let tempArr = []
  429. result.data.forEach(item => {
  430. item.value = item.id
  431. item.text = item.name
  432. tempArr.push(item)
  433. })
  434. this.loadData.teacherSchool = tempArr
  435. sheetForm.columns = tempArr
  436. sheetForm.loading = false
  437. } else {
  438. this.$toast('暂无教学点')
  439. sheetForm.loading = false
  440. }
  441. })
  442. } else if (sheetForm.currentType == 'teacherList') { // 乐团主管
  443. findEducationUsers().then(res => {
  444. let result = res.data
  445. if (result.code == 200 && result.data.length > 0) {
  446. let tempArr = []
  447. result.data.forEach(item => {
  448. item.value = item.userId
  449. item.text = item.userName
  450. tempArr.push(item)
  451. })
  452. this.loadData.teacherList = tempArr
  453. sheetForm.columns = tempArr
  454. sheetForm.loading = false
  455. } else {
  456. this.$toast('暂无乐团主管')
  457. sheetForm.loading = false
  458. }
  459. })
  460. }
  461. },
  462. findTeacherCategory(id) { // 获取教师课酬
  463. findByTeacherAndCategory({
  464. categoryId: id
  465. }).then(res => {
  466. let result = res.data
  467. if (result.code == 200) {
  468. this.loadData.teacherCategory = result.data
  469. }
  470. })
  471. },
  472. onSheetConfirm(value, index) { // 上拉弹窗
  473. let sheetForm = this.sheetForm,
  474. form = this.form,
  475. formName = this.formName,
  476. loadData = this.loadData
  477. if (sheetForm.currentType == 'subjectList') { // 科目名称赋值
  478. form.subjectIdList = value.value
  479. formName.subjectListName = value.text
  480. formName.subjectListIndex = index
  481. loadData.subjectListSelect = value
  482. } else if (sheetForm.currentType == 'vipGroupCategory') { // 课程形式赋值
  483. if (loadData.vipGroupCategorySelect.id != value.id) {
  484. // 获取教师课酬
  485. this.findTeacherCategory(value.id)
  486. }
  487. form.vipGroupCategoryId = value.value
  488. formName.vipGroupCategoryName = value.text
  489. formName.vipGroupCategoryIndex = index
  490. loadData.vipGroupCategorySelect = value
  491. form.studentNum = value.studentNum // 每班人数
  492. // form.singleClassMinutes = value.singleClassMinutes // 每课时长
  493. form.onlineClassesUnitPrice = Math.ceil(value.onlineClassesUnitPrice)
  494. form.offlineClassesUnitPrice = Math.ceil(value.offlineClassesUnitPrice)
  495. // 每课时长赋值
  496. form.singleClassMinutes = null
  497. loadData.classTimer = []
  498. let tempSingle = value.singleClassMinutes.split(",")
  499. tempSingle.forEach(item => {
  500. this.loadData.classTimer.push({
  501. name: item,
  502. value: item
  503. })
  504. })
  505. // 重置上课学生
  506. this.checkboxSelect = []
  507. this.checkboxSelectIds = []
  508. this.checkboxSelectList = [] //选中学生列表
  509. this.checkboxSelectDataList = []
  510. // 重置活动文案
  511. form.vipGroupActivityId = null
  512. formName.vipGroupActivityName = null
  513. formName.vipGroupActivityIndex = 0
  514. loadData.vipGroupActivity = []
  515. loadData.vipGroupActivitySelect = []
  516. } else if (sheetForm.currentType == 'vipGroupActivity') { // 活动方案赋值
  517. // 重置线上课,线下课次数
  518. if (form.vipGroupActivityId != value.value) {
  519. form.offlineClassesNums = null
  520. form.onlineClassesNums = null
  521. }
  522. form.vipGroupActivityId = value.value
  523. formName.vipGroupActivityName = value.text
  524. formName.vipGroupActivityIndex = index
  525. loadData.vipGroupActivitySelect = value
  526. // 换活动之后单价重置
  527. form.onlineClassesUnitPrice = Math.ceil(loadData.vipGroupCategorySelect.onlineClassesUnitPrice)
  528. form.offlineClassesUnitPrice = Math.ceil(loadData.vipGroupCategorySelect.offlineClassesUnitPrice)
  529. this.onCalcClassTimes(value) // 计算时间等.........
  530. this.getCalcClass() // 课酬计算
  531. this.setTimeTable() // 重新排课
  532. // 时间安排
  533. // form.registrationStartTime = value.startTime
  534. // form.coursesExpireDate = value.endTime
  535. } else if (sheetForm.currentType == 'teacherSchool') { // 线下课地址
  536. form.teacherSchoolId = value.value
  537. formName.teacherSchoolName = value.text
  538. formName.teacherSchoolIndex = index
  539. } else if (sheetForm.currentType == 'teacherList') { // 乐团主管
  540. form.educationalTeacherId = value.value
  541. formName.educationalTeacherName = value.text
  542. formName.educationalTeacherIndex = index
  543. }
  544. sheetForm.sheetStatus = false
  545. },
  546. onClassKeyUp(type) { // 线上课&线下课修改时
  547. if(type == 'offLine' && this.form.offlineClassesNums <= 0) {
  548. this.form.teacherSchoolId = null
  549. this.formName.teacherSchoolName = null
  550. this.formName.teacherSchoolIndex = 0
  551. }
  552. let vas = this.loadData.vipGroupActivitySelect
  553. this.onCalcClassTimes(vas)
  554. this.getCalcClass()
  555. this.setTimeTable()
  556. },
  557. onCalcClassTimes(vas) { // 计算课时总数
  558. let form = this.form,
  559. other = this.other,
  560. statusList = this.statusList
  561. let totalCount = Number(form.onlineClassesNums) + Number(form.offlineClassesNums)
  562. // ...
  563. if (vas.salarySettlementJson) {
  564. let obj = JSON.parse(vas.salarySettlementJson)
  565. if (obj && obj.onlineSalarySettlement) {
  566. // 有线上课
  567. statusList.hasOnline = true
  568. } else {
  569. statusList.hasOnline = false
  570. }
  571. if (obj && obj.offlineSalarySettlement) {
  572. // 有线下课
  573. statusList.hasOffline = true
  574. } else {
  575. statusList.hasOffline = false
  576. }
  577. }
  578. if (vas.type == "GIVE_CLASS") { // 买赠活动
  579. this.statusList.teachOnOrOff = true // 显示赠课
  580. if (totalCount >= Number(vas.attribute1)) {
  581. form.totalClassTime = totalCount + '+' + vas.attribute2
  582. other.giveNum = vas.attribute2
  583. } else {
  584. form.totalClassTime = totalCount
  585. other.giveNum = 0
  586. }
  587. } else { // 折扣活动
  588. form.totalClassTime = totalCount
  589. other.giveNum = 0
  590. this.statusList.teachOnOrOff = false // 隐藏赠课
  591. }
  592. },
  593. onModeSelect(value) { // 赠课确认
  594. this.form.giveTeachMode = value.value
  595. this.formName.giveTeachModeName = value.name
  596. this.statusList.giveTeachModeStatus = false
  597. this.getCalcClass()
  598. },
  599. onClickSingleClass() {
  600. if (!this.formName.vipGroupCategoryName) {
  601. this.$toast('请选择课程形式')
  602. return
  603. }
  604. this.statusList.classTimerStatus = true
  605. },
  606. onClassTimerSelect(value) { // 每课时长设置
  607. this.form.singleClassMinutes = value.value
  608. this.statusList.classTimerStatus = false
  609. this.getCalcClass()
  610. },
  611. onCurrentConfirm(value) { // 排课开始时间
  612. let selectDate = new Date(value)
  613. let tempMonth = selectDate.getMonth() + 1 >= 10 ? selectDate.getMonth() + 1 : '0' + (selectDate.getMonth() + 1)
  614. let tempDay = selectDate.getDate() >= 10 ? selectDate.getDate() : '0' + selectDate.getDate()
  615. this.form.courseStart = selectDate.getFullYear() + '-' + tempMonth + '-' + tempDay
  616. this.dataForm.status = false
  617. },
  618. onEnlistConfirm(value) { // 报名开始/结束时间
  619. let selectDate = new Date(value)
  620. let tempMonth = selectDate.getMonth() + 1 >= 10 ? selectDate.getMonth() + 1 : '0' + (selectDate.getMonth() + 1)
  621. let tempDay = selectDate.getDate() >= 10 ? selectDate.getDate() : '0' + selectDate.getDate()
  622. let enlistForm = this.enlistForm
  623. let form = this.form
  624. if (enlistForm.updateStatus == 'start') {
  625. form.registrationStartTime = selectDate.getFullYear() + '-' + tempMonth + '-' + tempDay
  626. if (form.coursesExpireDate) {
  627. let temps = new Date(form.registrationStartTime.replace(/-/ig, '/')).getTime()
  628. let tempe = new Date(form.coursesExpireDate.replace(/-/ig, '/')).getTime()
  629. // 如果开始时间大于结束时间,结束时间制空
  630. if (temps > tempe) {
  631. form.coursesExpireDate = null
  632. }
  633. }
  634. } else if (enlistForm.updateStatus == 'end') {
  635. form.coursesExpireDate = selectDate.getFullYear() + '-' + tempMonth + '-' + tempDay
  636. }
  637. enlistForm.status = false
  638. },
  639. onEnListShow(type, value) { // 报名开始/截止时间
  640. let enlistForm = this.enlistForm
  641. if (type == 'end') {
  642. if (this.form.registrationStartTime) {
  643. enlistForm.minDate = new Date(this.form.registrationStartTime.replace(/-/ig, '/'))
  644. } else {
  645. enlistForm.minDate = new Date()
  646. }
  647. } else if (type == 'start') {
  648. // 开始时默认为当前时间
  649. enlistForm.minDate = new Date()
  650. }
  651. if (value) {
  652. enlistForm.currentDate = new Date(value.replace(/-/ig, '/'))
  653. } else {
  654. enlistForm.currentDate = new Date()
  655. }
  656. enlistForm.updateStatus = type
  657. enlistForm.status = true
  658. },
  659. onCourseShedule() { // 课时安排
  660. if (!this.form.singleClassMinutes) {
  661. this.$toast('请选每课时长')
  662. return
  663. }
  664. if (this.other.giveNum > 0 && !this.form.giveTeachMode) {
  665. this.$toast('请选择赠课类型')
  666. return
  667. }
  668. if (!this.form.courseStart) {
  669. this.$toast('请选择排课开始时间')
  670. return
  671. }
  672. this.courseForm.teachingStatus = true
  673. },
  674. onScheduleRemove(item) { // 删除课程安排
  675. let index = this.scheduleList.indexOf(item)
  676. if (index !== -1) {
  677. this.scheduleList.splice(index, 1)
  678. }
  679. },
  680. onTeachinConfirm(value) { // 添加课程
  681. let scheduleList = this.scheduleList
  682. let startTime = (value[2] >= 10 ? value[2] : '0' + value[2]) + ':' + value[3].split('分')[0]
  683. let endTime = this.MinutesTest(value[2], value[3], this.form.singleClassMinutes)
  684. let isAdd = true
  685. scheduleList.forEach(item => {
  686. let isStartTime = this.timeIsrange(startTime, endTime, item.startTime);
  687. let isEndTime = this.timeIsrange(startTime, endTime, item.endTime);
  688. if (isAdd) { //
  689. if (value[1] == item.weekStr) {
  690. if (isStartTime || isEndTime) {
  691. isAdd = false
  692. } else {
  693. isAdd = true
  694. }
  695. } else if (value[1] != item.weekStr) {
  696. isAdd = true
  697. }
  698. }
  699. })
  700. if (isAdd) { // 判断时间范围是否有重复
  701. scheduleList.push({
  702. type: value[0], // 线上还是线下
  703. weekStr: value[1],
  704. weekIndex: this.getWeek(value[1]),
  705. startTime: startTime,
  706. endTime: endTime,
  707. id: Date.now()
  708. })
  709. // scheduleList.sort((a, b) => {
  710. // return a.weekStr
  711. // })
  712. this.courseForm.teachingStatus = false
  713. this.setTimeTable()
  714. } else {
  715. this.$toast('该时间段已排课请重选时间')
  716. return
  717. }
  718. },
  719. onShowTimeTable() { // 显示排课列表
  720. if(!this.checkCourseList()) {
  721. return
  722. }
  723. this.statusList.classTime = true
  724. this.setTimeTable()
  725. },
  726. setTimeTable() {
  727. if(!this.checkCourseList(false)) {
  728. return
  729. }
  730. // return
  731. // 重置排课列表
  732. this.timeTable = []
  733. let form = this.form,
  734. scheduleList = this.scheduleList
  735. // if(!form.courseStart) {
  736. // this.$toast('请选择排课开始时间')
  737. // return
  738. // }
  739. // 拿到线上课数与线下课数 以及
  740. let online = parseInt(form.onlineClassesNums ? form.onlineClassesNums : 0)
  741. let offline = parseInt(form.offlineClassesNums ? form.offlineClassesNums : 0)
  742. let giveNum = parseInt(this.other.giveNum)
  743. let giveClassType = form.giveTeachMode
  744. if (giveClassType == 'ONLINE') {
  745. // 线上
  746. online += giveNum
  747. } else if (giveClassType == 'OFFLINE') {
  748. offline += giveNum
  749. }
  750. // 判断是否有课程安排
  751. if (scheduleList.length <= 0) {
  752. return
  753. }
  754. let totalCount = Number(online) + Number(offline)
  755. let tempCourseStart = form.courseStart.replace(/-/ig, '/')
  756. let dateOperation = new Date(tempCourseStart)
  757. let forMark = 0
  758. while (totalCount && totalCount > 0) {
  759. for (let i = 0; i < scheduleList.length; i++) {
  760. // console.log(totalCount, scheduleList)
  761. if (online == 0 && offline == 0) break
  762. let num = scheduleList[i].weekIndex - dateOperation.getDay()
  763. // 如果是同一天一个周期会出现排课都排到一天
  764. if (forMark > 0 && num == 0 && i == 0) {
  765. num = num + 7
  766. }
  767. if (num < 0) { // 如果为负数则为下周
  768. num = num + 7
  769. }
  770. let dataStr = this.getThinkDate(dateOperation, num)
  771. // 判断是否大于当前时间
  772. let nowGetTime = new Date().getTime()
  773. let courseTime = new Date(dataStr.replace(/-/ig, '/') + ' ' + scheduleList[i].startTime + ':00').getTime()
  774. if (nowGetTime < courseTime) {
  775. let tempArr = {
  776. 'classDate': dataStr,
  777. 'startClassTimeStr': scheduleList[i].startTime,
  778. "endClassTimeStr": scheduleList[i].endTime
  779. }
  780. // console.log(scheduleList[i].type, online, offline)
  781. if (scheduleList[i].type == '线上' && online > 0) {
  782. tempArr.teachMode = 'ONLINE'
  783. this.timeTable.push(tempArr)
  784. online--
  785. totalCount--
  786. } else if (scheduleList[i].type == '线下' && offline > 0) {
  787. tempArr.teachMode = 'OFFLINE'
  788. this.timeTable.push(tempArr)
  789. offline--
  790. totalCount--
  791. }
  792. // else {
  793. // if (online > 0) {
  794. // tempArr.teachMode = 'ONLINE'
  795. // this.timeTable.push(tempArr)
  796. // online--
  797. // } else if (offline > 0) {
  798. // tempArr.teachMode = 'OFFLINE'
  799. // this.timeTable.push(tempArr)
  800. // offline--
  801. // }
  802. // }
  803. }
  804. }
  805. // 加一周
  806. if (scheduleList.length == 1) {
  807. dateOperation.setDate(dateOperation.getDate() + 7)
  808. } else if (scheduleList.every(item => item.weekStr === scheduleList[0].weekStr)) {
  809. // 标记循环次数(标记判断课程安排是不是同一天)
  810. forMark++
  811. }
  812. }
  813. this.timeTable.sort((a,b)=>{
  814. let aStr = dayjs(dayjs(a.classDate).format('YYYY-MM-DD')+' '+a.startClassTimeStr+':00').valueOf()
  815. let bStr = dayjs(dayjs(b.classDate).format('YYYY-MM-DD')+' '+b.startClassTimeStr+':00').valueOf()
  816. return aStr-bStr
  817. })
  818. // console.log(this.timeTable)
  819. },
  820. onGiveMode() { // 赠送课改变时
  821. this.statusList.giveTeachModeStatus = true
  822. this.getCalcClass()
  823. },
  824. getCalcClass() { // 计算课酬
  825. let loadData = this.loadData
  826. let form = this.form
  827. let vas = loadData.vipGroupActivitySelect, // 活动
  828. vcs = loadData.vipGroupCategorySelect, // 课程形式
  829. tc = loadData.teacherCategory, // 老师基本信息
  830. oncn = form.onlineClassesNums ? form.onlineClassesNums : 0, // 线上课次数
  831. offcn = form.offlineClassesNums ? form.offlineClassesNums : 0, // 线下课次数
  832. giveNum = parseInt(this.other.giveNum),
  833. giveTeachMode = form.giveTeachMode // 线下或线下
  834. // 优惠活动
  835. // ...
  836. if (vas.salarySettlementJson) {
  837. let obj = JSON.parse(vas.salarySettlementJson)
  838. // 获取每课时长
  839. // 每45Min计算一些课酬
  840. // let b = form.singleClassMinutes ? (form.singleClassMinutes / 45) : 0
  841. let tempPrice = 0
  842. if ((Number(oncn) + Number(offcn)) > 0) {
  843. let countPrice = (oncn * form.onlineClassesUnitPrice) + (offcn * form.offlineClassesUnitPrice)
  844. if (giveNum > 0 && !giveTeachMode) {
  845. countPrice = 0
  846. }
  847. tempPrice = countPrice * form.studentNum / (Number(oncn) + Number(offcn) + Number(giveNum))
  848. if (vas.type == 'DISCOUNT') {
  849. tempPrice = tempPrice * (vas.attribute1 ? Number(vas.attribute1) : 100) / 100
  850. }
  851. }
  852. // 课程按课来计算
  853. if (obj && obj.onlineSalarySettlement) {
  854. let onss = obj.onlineSalarySettlement
  855. // 有线上课
  856. if (onss.salarySettlementType == 'TEACHER_DEFAULT') {
  857. form.onlineTeacherSalary = Math.round(tc.offlineClassesSalary) // 线上课酬
  858. } else if (onss.salarySettlementType == 'RATIO_DISCOUNT') {
  859. // 老师课酬的折扣 如果有则不打折
  860. // form.onlineTeacherSalary = Math.round(vcs.onlineClassesUnitPrice * (onss.settlementValue ? onss.settlementValue : 100) / 100)
  861. form.onlineTeacherSalary = Math.round(tempPrice ? (tempPrice * (onss.settlementValue ? onss.settlementValue :
  862. 100) / 100) : 0)
  863. } else if (onss.salarySettlementType == 'FIXED_SALARY') {
  864. form.onlineTeacherSalary = Math.round(onss.settlementValue)
  865. }
  866. form.onlineTeacherSalary = Number(form.onlineTeacherSalary)
  867. } else {
  868. form.onlineTeacherSalary = Math.round(tc.offlineClassesSalary)
  869. }
  870. if (obj && obj.offlineSalarySettlement) {
  871. let offss = obj.offlineSalarySettlement
  872. // 有线下课
  873. if (offss.salarySettlementType == 'TEACHER_DEFAULT') {
  874. form.offlineTeacherSalary = Math.round(tc.offlineClassesSalary) // 线上课酬
  875. } else if (offss.salarySettlementType == 'RATIO_DISCOUNT') {
  876. // 老师课酬的折扣
  877. // form.offlineTeacherSalary = Math.round((vcs.offlineClassesUnitPrice * (offss.settlementValue ? offss.settlementValue : 100) / 100))
  878. form.offlineTeacherSalary = Math.round(tempPrice ? (tempPrice * (offss.settlementValue ? offss.settlementValue :
  879. 100) / 100) : 0)
  880. } else if (offss.salarySettlementType == 'FIXED_SALARY') {
  881. form.offlineTeacherSalary = Math.round(offss.settlementValue)
  882. }
  883. form.offlineTeacherSalary = Number(form.offlineTeacherSalary)
  884. } else {
  885. form.offlineTeacherSalary = Math.round(tc.offlineClassesSalary)
  886. }
  887. }
  888. if (vas.type == 'GIVE_CLASS' || vas.type == 'BASE_ACTIVITY') {
  889. form.totalCount = Math.round((oncn * form.onlineClassesUnitPrice) + (offcn * form.offlineClassesUnitPrice))
  890. } else if (vas.type == 'DISCOUNT') {
  891. form.totalCount = Math.round(((oncn * form.onlineClassesUnitPrice) + (offcn * form.offlineClassesUnitPrice)) *
  892. Number(vas.attribute1) / 100)
  893. }
  894. form.totalCount = Number(form.totalCount)
  895. },
  896. getThinkDate(date, num) {
  897. let Stamp = date
  898. Stamp.setDate(date.getDate() + num) // 获取当前月数的第几天
  899. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  900. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  901. var mvar = '';
  902. if (month < 10) {
  903. mvar = '0' + month;
  904. } else {
  905. mvar = month + '';
  906. }
  907. var day = Stamp.getDate();
  908. var dvar = '';
  909. if (day < 10) {
  910. dvar = '0' + day;
  911. } else {
  912. dvar = day + '';
  913. }
  914. return year + "-" + mvar + '-' + dvar;
  915. },
  916. // 分钟小时相加减
  917. MinutesTest(houer, mins, interval) {
  918. let min = mins.split('分')[0]
  919. let sdate1 = new Date(1900, 1, 1, houer, min)
  920. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval))
  921. let H = sdate1.getHours()
  922. let M = sdate1.getMinutes()
  923. if (H < 10) H = '0' + H
  924. if (M < 10) M = '0' + M
  925. return H + ':' + M
  926. },
  927. // 判断时间是否在时间段内
  928. timeIsrange(beginTime, endTime, nowTime) {
  929. var strb = beginTime.split(":");
  930. if (strb.length != 2) {
  931. return false;
  932. }
  933. var stre = endTime.split(":");
  934. if (stre.length != 2) {
  935. return false;
  936. }
  937. var strn = nowTime.split(":");
  938. if (stre.length != 2) {
  939. return false;
  940. }
  941. var b = new Date();
  942. var e = new Date();
  943. var n = new Date();
  944. b.setHours(strb[0]);
  945. b.setMinutes(strb[1]);
  946. e.setHours(stre[0]);
  947. e.setMinutes(stre[1]);
  948. n.setHours(strn[0]);
  949. n.setMinutes(strn[1]);
  950. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  951. // 在时间范围内
  952. return true
  953. } else {
  954. // 不在时间范围内
  955. return false
  956. }
  957. },
  958. getWeek(str) { // 获取周几索引值
  959. let template = {
  960. '周一': 1,
  961. '周二': 2,
  962. '周三': 3,
  963. '周四': 4,
  964. '周五': 5,
  965. '周六': 6,
  966. '周日': 0
  967. }
  968. return template[str]
  969. },
  970. formatter(type, value) {
  971. if (type === 'year') {
  972. return `${value}年`;
  973. } else if (type === 'month') {
  974. return `${value}月`
  975. } else if (type === 'day') {
  976. return `${value}日`
  977. }
  978. return value;
  979. },
  980. async onSubmit() {
  981. let form = this.form
  982. let statusList = this.statusList
  983. // if (!(form.name)) {
  984. // this.$toast('请输入课程班名称')
  985. // return false
  986. // }
  987. if (!form.subjectIdList) {
  988. this.$toast('请选择科目')
  989. return false
  990. }
  991. if (!form.vipGroupCategoryId) {
  992. this.$toast('请选择课程形式')
  993. return false
  994. }
  995. if (!form.educationalTeacherId) {
  996. this.$toast('请选择乐团主管')
  997. return
  998. }
  999. if(this.checkboxSelectIds.length <= 0) {
  1000. this.$toast('请选择上课学生')
  1001. return
  1002. }
  1003. if (!form.vipGroupActivityId) {
  1004. this.$toast('请选择活动方案')
  1005. return false
  1006. }
  1007. if (!form.singleClassMinutes) {
  1008. this.$toast('请选择每课时长')
  1009. return false
  1010. }
  1011. let onlineClassesStatus = !form.onlineClassesNums && form.onlineClassesNums <= 0 ? true : false
  1012. let offlineClassesStatus = !form.offlineClassesNums && form.offlineClassesNums <= 0 ? true : false
  1013. if (statusList.hasOnline) {
  1014. if (onlineClassesStatus) {
  1015. this.$toast('请输入线上课次数')
  1016. return false
  1017. }
  1018. }
  1019. if (statusList.hasOffline) {
  1020. if (offlineClassesStatus) {
  1021. this.$toast('请输入线下课次数')
  1022. return false
  1023. }
  1024. // 判断是否有线下
  1025. if (form.offlineClassesNums > 0 && !form.teacherSchoolId) {
  1026. this.$toast('请选择线下课地址')
  1027. return false
  1028. }
  1029. }
  1030. if (!form.registrationStartTime) {
  1031. this.$toast('请选择报名开始时间')
  1032. return false
  1033. }
  1034. if (!form.coursesExpireDate) {
  1035. this.$toast('请选择报名结束时间')
  1036. return false
  1037. }
  1038. let vipGroupActivitySelect = this.loadData.vipGroupActivitySelect
  1039. if (vipGroupActivitySelect.type == 'GIVE_CLASS' && !form.giveTeachMode) {
  1040. this.$toast('请选择赠课类型')
  1041. return false
  1042. }
  1043. if (this.scheduleList.length <= 0) {
  1044. this.$toast('课时安排不能为空')
  1045. return false
  1046. }
  1047. if(vipGroupActivitySelect.type == 'DISCOUNT' && vipGroupActivitySelect.minCourseNum > 0 && vipGroupActivitySelect.maxCourseNum > 0) {
  1048. // debugger
  1049. let tempCourseCount = (parseInt(form.onlineClassesNums) + parseInt(form.offlineClassesNums))
  1050. if(vipGroupActivitySelect.minCourseNum > tempCourseCount || tempCourseCount > vipGroupActivitySelect.maxCourseNum) {
  1051. this.$toast(`课时总数为${vipGroupActivitySelect.minCourseNum}~${vipGroupActivitySelect.maxCourseNum}节`)
  1052. return
  1053. }
  1054. }
  1055. if(!this.checkCourseList()) {
  1056. return
  1057. }
  1058. // 排课
  1059. this.setTimeTable()
  1060. // 如果线上和线下课酬都为0时
  1061. if(statusList.hasOnline && statusList.hasOffline) {
  1062. if(form.onlineClassesNums > 0 && form.onlineTeacherSalary <= 0 && form.offlineClassesNums > 0 && form.offlineTeacherSalary <= 0 && this.salaryStatus) {
  1063. this.$dialog.confirm({
  1064. message: '当前课程课酬预计为0,是否继续?'
  1065. }).then(() => {
  1066. this.salaryStatus = false
  1067. this.onSubmit()
  1068. })
  1069. return
  1070. }
  1071. }
  1072. if (statusList.hasOnline) {
  1073. if (!form.onlineClassesUnitPrice) {
  1074. this.$toast('请输入线上课单价')
  1075. return false
  1076. }
  1077. if (!form.onlineTeacherSalary) {
  1078. this.$toast('请输入线上课课酬')
  1079. return false
  1080. }
  1081. if(form.onlineClassesNums > 0 && form.onlineTeacherSalary <= 0 && this.salaryStatus) {
  1082. this.$dialog.confirm({
  1083. message: '当前课程线上课酬预计为0,是否继续?'
  1084. }).then(() => {
  1085. this.salaryStatus = false
  1086. this.onSubmit()
  1087. })
  1088. return
  1089. }
  1090. }
  1091. if (statusList.hasOffline) {
  1092. if (!form.offlineClassesUnitPrice) {
  1093. this.$toast('请输入线下课单价')
  1094. return false
  1095. }
  1096. if (!form.offlineTeacherSalary) {
  1097. this.$toast('请输入线下课课酬')
  1098. return false
  1099. }
  1100. if(form.offlineClassesNums > 0 && form.offlineTeacherSalary <= 0 && this.salaryStatus) {
  1101. this.$dialog.confirm({
  1102. message: '当前课程线下课酬预计为0,是否继续?'
  1103. }).then(() => {
  1104. this.salaryStatus = false
  1105. this.onSubmit()
  1106. })
  1107. return
  1108. }
  1109. }
  1110. if (form.giveTeachMode == 'ONLINE') {
  1111. form.onlineClassesNum = Number(form.onlineClassesNums) + Number(this.other.giveNum)
  1112. form.offlineClassesNum = Number(form.offlineClassesNums)
  1113. } else {
  1114. form.onlineClassesNum = Number(form.onlineClassesNums)
  1115. form.offlineClassesNum = Number(form.offlineClassesNums) + Number(this.other.giveNum)
  1116. }
  1117. form.totalClassTimes = Number(form.onlineClassesNums) + Number(form.offlineClassesNums) + Number(this.other.giveNum)
  1118. form.paymentExpireDate = form.coursesExpireDate
  1119. form.studentIdList = this.checkboxSelectIds.join(',')
  1120. let params = {
  1121. courseSchedules: this.timeTable,
  1122. vipGroupApplyBaseInfo: form
  1123. }
  1124. if (!this.onSubmitStatus) {
  1125. return
  1126. }
  1127. this.onSubmitStatus = false
  1128. setLoading(true)
  1129. await vipGroupApply(params).then(res => {
  1130. let result = res.data
  1131. setLoading(false)
  1132. if (result.code == 200) {
  1133. this.$toast('申请成功')
  1134. setTimeout(() => {
  1135. this.onSubmitStatus = true
  1136. if (browser().iPhone) {
  1137. window.webkit.messageHandlers.DAYA.postMessage(JSON.stringify({
  1138. api: 'back'
  1139. }))
  1140. } else if (browser().android) {
  1141. DAYA.postMessage(JSON.stringify({
  1142. api: 'back'
  1143. }))
  1144. } else {
  1145. this.$router.push('/business')
  1146. }
  1147. }, 500)
  1148. } else {
  1149. this.onSubmitStatus = true
  1150. this.salaryStatus = true
  1151. this.$toast(result.msg)
  1152. }
  1153. }).catch(() => {
  1154. this.onSubmitStatus = true
  1155. this.salaryStatus = true
  1156. setLoading(false)
  1157. })
  1158. },
  1159. checkCourseList(isShowToast = true) {
  1160. let form = this.form
  1161. let scheduleList = this.scheduleList || []
  1162. let hasOnLine = false // 是否有线上课时安排
  1163. let hasOffLine = false
  1164. scheduleList.forEach(item => {
  1165. if(item.type == '线上') {
  1166. hasOnLine = true
  1167. }
  1168. if(item.type == '线下') {
  1169. hasOffLine = true
  1170. }
  1171. })
  1172. let statusList = this.statusList
  1173. let onlineClassesStatus = !form.onlineClassesNums && form.onlineClassesNums <= 0 ? true : false
  1174. let offlineClassesStatus = !form.offlineClassesNums && form.offlineClassesNums <= 0 ? true : false
  1175. // let onlineClassesStatus = false
  1176. // if(form.onlineClassesNums || form.onlineClassesNums >= 0) {
  1177. // onlineClassesStatus = true
  1178. // }
  1179. // let offlineClassesStatus = false
  1180. // if(form.offlineClassesNums || form.offlineClassesNums >= 0) {
  1181. // offlineClassesStatus = true
  1182. // }
  1183. if (statusList.hasOnline) {
  1184. if(onlineClassesStatus) {
  1185. if(isShowToast) {
  1186. this.$toast('请输入线上课次数')
  1187. }
  1188. return false
  1189. }
  1190. if ((!onlineClassesStatus && !hasOnLine)) {
  1191. if(isShowToast) {
  1192. this.$toast('课时安排缺少线上课类型')
  1193. }
  1194. return false
  1195. }
  1196. } else {
  1197. return false
  1198. }
  1199. if (statusList.hasOffline) {
  1200. if(offlineClassesStatus) {
  1201. if(isShowToast) {
  1202. this.$toast('请输入线下课次数')
  1203. }
  1204. return false
  1205. }
  1206. if (!offlineClassesStatus && !hasOffLine) {
  1207. if(isShowToast) {
  1208. this.$toast('课时安排缺少线下课类型')
  1209. }
  1210. return false
  1211. }
  1212. } else {
  1213. return false
  1214. }
  1215. return true
  1216. },
  1217. // 搜索
  1218. onSearch() {
  1219. this.params.page = 1
  1220. this.dataList = []
  1221. this.dataShow = true
  1222. this.loading = true
  1223. this.finished = false
  1224. this.getStudent()
  1225. },
  1226. getStudent() {
  1227. let params = this.params
  1228. queryStudentsWithTeacher(params).then(res => {
  1229. let result = res.data
  1230. this.loading = false
  1231. if (result.code == 200) {
  1232. params.page = result.data.pageNo
  1233. this.dataList = this.dataList.concat(result.data.rows)
  1234. if (params.page >= result.data.totalPage) {
  1235. this.finished = true
  1236. }
  1237. this.params.page++
  1238. } else {
  1239. this.finished = true
  1240. }
  1241. // 判断是否有数据
  1242. if (this.dataList.length <= 0) {
  1243. this.dataShow = false
  1244. }
  1245. })
  1246. },
  1247. onPopupCancel() { // 关闭弹窗
  1248. this.statusList.studentStatus = false
  1249. // this.params.search = null
  1250. this.checkboxSelect = []
  1251. this.checkboxSelectList = []
  1252. },
  1253. onPopupSubmit() {
  1254. const vipGroupCategorySelect = this.loadData.vipGroupCategorySelect
  1255. if(this.checkboxSelect.length != vipGroupCategorySelect.studentNum) {
  1256. this.$toast(`请选择学生${vipGroupCategorySelect.studentNum}名,当前选择${this.checkboxSelect.length}名`)
  1257. return
  1258. }
  1259. this.checkboxSelectDataList = JSON.parse(JSON.stringify(this.checkboxSelectList))
  1260. this.checkboxSelectIds = JSON.parse(JSON.stringify(this.checkboxSelect))
  1261. this.checkboxSelect = []
  1262. this.checkboxSelectList = []
  1263. this.statusList.studentStatus = false
  1264. },
  1265. onCheckboxSelect(value) {
  1266. if(this.checkboxSelect.includes(value.userId.toString())) {
  1267. this.checkboxSelect.forEach((item, index) => {
  1268. if(item == value.userId.toString()) {
  1269. this.checkboxSelect.splice(index, 1)
  1270. }
  1271. })
  1272. this.checkboxSelectList.forEach((item, index) => {
  1273. if(item.userId == value.userId) {
  1274. this.checkboxSelectList.splice(index, 1)
  1275. }
  1276. })
  1277. } else {
  1278. this.checkboxSelect.push(value.userId.toString())
  1279. this.checkboxSelectList.push(value)
  1280. }
  1281. // checkboxSelect = item.userId
  1282. },
  1283. desensitPhone(phone) { // 手机号脱敏
  1284. let first = phone.substr(0, 3)
  1285. let last = phone.substr(-4)
  1286. return first + '****' + last
  1287. }
  1288. }
  1289. }
  1290. </script>
  1291. <style lang='less' scoped>
  1292. @import url("../../assets/commonLess/variable.less");
  1293. .vip-title {
  1294. padding: .06rem 0 .04rem;
  1295. font-size: .12rem;
  1296. color: @mFontColor;
  1297. text-align: center;
  1298. }
  1299. .courseTips {
  1300. font-size: .13rem;
  1301. padding: 10px 16px;
  1302. background: #F3F4F8;
  1303. & > span {
  1304. color: red;
  1305. }
  1306. }
  1307. .add-plan {
  1308. display: flex;
  1309. align-items: center;
  1310. justify-content: center;
  1311. padding: .2rem 0;
  1312. font-size: .16rem;
  1313. color: @tFontColor;
  1314. .van-icon {
  1315. margin-right: .05rem;
  1316. font-size: .20rem;
  1317. }
  1318. }
  1319. .title-time {
  1320. display: flex;
  1321. align-items: center;
  1322. flex: 1 auto;
  1323. color: #4A4A4A;
  1324. .online {
  1325. color: @tFontColor;
  1326. }
  1327. .week {
  1328. padding-left: .4rem;
  1329. padding-right: .15rem;
  1330. }
  1331. }
  1332. /deep/.van-field__label,
  1333. /deep/.van-cell__value {
  1334. flex: 1 auto;
  1335. }
  1336. /deep/.van-field__control:disabled {
  1337. color: #6a6969;
  1338. }
  1339. .button-group {
  1340. margin: .3rem .26rem .2rem;
  1341. .van-button--primary {
  1342. background: @mColor;
  1343. border-color: @mColor;
  1344. font-size: .18rem;
  1345. }
  1346. }
  1347. .van-row {
  1348. line-height: .4rem;
  1349. border-top: 1px solid #edeef0;
  1350. text-align: center;
  1351. font-size: .14rem;
  1352. &:first-child {
  1353. border-top: 0;
  1354. background: #edeef0;
  1355. color: #444;
  1356. font-size: .15rem;
  1357. }
  1358. }
  1359. .tableContainer {
  1360. max-height: 2.44rem;
  1361. overflow: auto;
  1362. .van-row {
  1363. color: #444;
  1364. &:first-child {
  1365. border-top: 0;
  1366. background: #fff;
  1367. font-size: .14rem;
  1368. }
  1369. }
  1370. }
  1371. .studentContainer {
  1372. /deep/.van-cell__title {
  1373. font-size: .14rem;
  1374. color: @mFontColor;
  1375. flex: 1 auto;
  1376. }
  1377. .logo {
  1378. width: .35rem;
  1379. height: .35rem;
  1380. margin-right: .12rem;
  1381. border-radius: 100%;
  1382. }
  1383. .input-cell {
  1384. padding: .12rem .16rem .2rem;
  1385. .van-checkbox {
  1386. justify-content: flex-end;
  1387. }
  1388. }
  1389. /deep/.van-cell__value {
  1390. height: .2rem;
  1391. }
  1392. /deep/.van-checkbox__icon .van-icon {
  1393. border-color: @sFontColor;
  1394. }
  1395. /deep/.van-checkbox__icon--checked {
  1396. .van-icon {
  1397. border-color: @orangeColor;
  1398. background: @orangeColor;
  1399. }
  1400. }
  1401. .van-tag {
  1402. margin-left: .08rem;
  1403. }
  1404. }
  1405. .paddingB80 {
  1406. padding-bottom: .8rem
  1407. }
  1408. .button-group-popup {
  1409. position: fixed;
  1410. bottom: 0;
  1411. padding: 0.2rem 0;
  1412. width: 100%;
  1413. text-align: center;
  1414. background-color: #FFFFFF;
  1415. .btn {
  1416. padding: 0 0.45rem;
  1417. line-height: 0.4rem;
  1418. display: inline-block;
  1419. border: 1px solid @mColor;
  1420. border-radius: 1rem;
  1421. color: @mColor;
  1422. background: #fff;
  1423. font-size: 0.18rem;
  1424. &.primary {
  1425. color: #fff;
  1426. background: @mColor;
  1427. }
  1428. }
  1429. .btn+.btn {
  1430. margin-left: 0.1rem;
  1431. }
  1432. }
  1433. .studentColor {
  1434. color: #14928A;
  1435. }
  1436. /deep/.van-field--disabled .van-field__label, /deep/.van-field__label {
  1437. color: #323233;
  1438. }
  1439. </style>