index.vue 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header @back="onCancel"
  5. content="VIP课申请"></el-page-header>
  6. <!-- <div class="squrt" /> -->
  7. </h2>
  8. <div class="m-core">
  9. <div class="vipLeft">
  10. <h4>课程信息</h4>
  11. <el-form ref="leftForm"
  12. :rules="leftFormRules"
  13. :label-position="labelPosition"
  14. label-width="110px"
  15. :model="leftForm">
  16. <el-form-item label="课程名称"
  17. prop="name">
  18. <el-input v-model="leftForm.name" />
  19. </el-form-item>
  20. <el-form-item label="科目名称"
  21. prop="subject">
  22. <el-select v-model="leftForm.subject"
  23. clearable
  24. @change="changeSubject">
  25. <el-option v-for="(item,index) in subjectList"
  26. :key="index"
  27. :value="item.id"
  28. :label="item.name" />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="指导老师"
  32. prop="teacher">
  33. <el-select v-model="leftForm.teacher"
  34. filterable
  35. clearable
  36. :disabled="!leftForm.subject"
  37. @change="setSection($event)">
  38. <el-option v-for="(item,index) in teacherList"
  39. :key="index"
  40. :label="item.username"
  41. :value="item.id" />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="课程形式"
  45. prop="courseType">
  46. <el-select v-model="leftForm.courseType"
  47. clearable
  48. :disabled="!leftForm.teacher"
  49. @change="changeType">
  50. <el-option v-for="(item,index) in courseTypeList"
  51. :key="index"
  52. :label="item.name"
  53. :value="item.id" />
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item label="活动方案"
  57. prop="activeType">
  58. <el-select v-model="leftForm.activeType"
  59. clearable
  60. :disabled="!leftForm.courseType"
  61. @change="chioseActive">
  62. <el-option v-for="(item,index) in activeList"
  63. :key="index"
  64. :value="item.id"
  65. :label="item.name" />
  66. </el-select>
  67. </el-form-item>
  68. <!-- 11111111111111111111111111111111 -->
  69. <el-form-item label="教学点">
  70. <el-select v-model="leftForm.section"
  71. clearable
  72. :disabled="!leftForm.teacher">
  73. <el-option v-for="(item,index) in scetionList"
  74. :key="index"
  75. :value="item.id"
  76. :label="item.name" />
  77. </el-select>
  78. </el-form-item>
  79. <el-form-item label="每班人数">
  80. <el-input type="number"
  81. v-model="leftForm.classNum"
  82. disabled />
  83. </el-form-item>
  84. <el-form-item label="每课时长">
  85. <!-- <el-input type="number"
  86. v-model="leftForm.classTime"
  87. disabled /> -->
  88. <el-select v-model="leftForm.classTime"
  89. :disabled="timeTable.length>0">
  90. <el-option v-for='(item,index) in this.classTimeList'
  91. :key="index"
  92. :value="item"
  93. :label="item"></el-option>
  94. </el-select>
  95. </el-form-item>
  96. <el-form-item label="
  97. 报名开始时间"
  98. prop="signUpStart">
  99. <el-date-picker v-model="leftForm.signUpStart"
  100. type="date"
  101. value-format="yyyy-MM-dd HH:mm:ss"
  102. placeholder="请选择时间" />
  103. </el-form-item>
  104. <el-form-item label="报名结束时间"
  105. prop="signUpEnd">
  106. <el-date-picker v-model="leftForm.signUpEnd"
  107. type="date"
  108. value-format="yyyy-MM-dd HH:mm:ss"
  109. placeholder="请选择时间" />
  110. </el-form-item>
  111. <el-form-item v-if="leftForm.courseStart"
  112. label="最早排课时间">
  113. <el-date-picker v-model="leftForm.courseStart"
  114. disabled
  115. type="date"
  116. value-format="yyyy-MM-dd HH:mm:ss"
  117. placeholder="请选择时间" />
  118. </el-form-item>
  119. <el-form-item v-if="leftForm.courseEnd"
  120. label="最晚排课时间">
  121. <el-date-picker v-model="leftForm.courseEnd"
  122. disabled
  123. type="date"
  124. value-format="yyyy-MM-dd HH:mm:ss"
  125. placeholder="请选择时间" />
  126. </el-form-item>
  127. </el-form>
  128. </div>
  129. <div class="center">
  130. <h4>排课设置</h4>
  131. <el-form :model="centerForm"
  132. label-width="100px"
  133. :label-position="labelPosition">
  134. <el-form-item v-if="hasOnline"
  135. label="线上课数">
  136. <el-input v-model="centerForm.onlineCourseNum"
  137. type='number' />
  138. </el-form-item>
  139. <el-form-item v-if="hasOffline"
  140. label="线下课数">
  141. <el-input v-model="centerForm.offlineCourseNum"
  142. type='number' />
  143. </el-form-item>
  144. <el-form-item label="待排课数">
  145. <el-input v-model="allCourseCount"
  146. disabled />
  147. </el-form-item>
  148. <el-form-item v-if="hotType=='GIVE_CLASS'&&isGiveClass"
  149. label="赠课课程类型">
  150. <el-radio v-model="centerForm.radio"
  151. label="ONLINE">
  152. 线上课
  153. </el-radio>
  154. <el-radio v-model="centerForm.radio"
  155. label="OFFLINE">
  156. 线下课
  157. </el-radio>
  158. </el-form-item>
  159. </el-form>
  160. <!-- 排课列表开始 -->
  161. <div class="planList">
  162. <div class="planTop">
  163. <p>已排课程</p>
  164. <el-button type="text"
  165. @click="setCourse">
  166. {{id?'新增排课':'点击排课'}}
  167. </el-button>
  168. </div>
  169. <div class="planCore">
  170. <div class="row">
  171. <div class="name">
  172. 时间
  173. </div>
  174. <div class="week">
  175. 开始时间
  176. </div>
  177. <div class="time">
  178. 结束时间
  179. </div>
  180. <div class="time">
  181. 课程类型
  182. </div>
  183. </div>
  184. <div v-for="(item,index) in this.timeTable"
  185. class="row">
  186. <div class="name">
  187. {{ item.classDate | formatTimer }}
  188. </div>
  189. <div class="week">
  190. {{ item.startClassTimeStr }}
  191. </div>
  192. <div class="time">
  193. {{ item.endClassTimeStr }}
  194. </div>
  195. <div class="time">
  196. {{ item.teachMode |teachMode }}
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="right">
  203. <h4>课酬设置</h4>
  204. <el-form :model="rightForm"
  205. label-width="100px"
  206. :label-position="labelPosition">
  207. <el-form-item v-if="hasOnline"
  208. label="线上课课酬">
  209. <el-input v-model="rightForm.onlineCourse"
  210. :disabled="salaryReadonlyFlag==0" />
  211. <!-- || onlineSalary!='TEACHER_DEFAULT' -->
  212. </el-form-item>
  213. <el-form-item v-if="hasOffline"
  214. label="线下课课酬">
  215. <el-input v-model="rightForm.offlineCourse"
  216. :disabled="salaryReadonlyFlag==0" />
  217. <!-- || offlineSalary!='TEACHER_DEFAULT' -->
  218. </el-form-item>
  219. <el-form-item v-if="hasOnline"
  220. label="线上课单价">
  221. <el-input v-model="rightForm.onlinePrice"
  222. :disabled="salaryReadonlyFlag==0" />
  223. </el-form-item>
  224. <el-form-item v-if="hasOffline"
  225. label="线下课单价">
  226. <el-input v-model="rightForm.offlinePrice"
  227. :disabled="salaryReadonlyFlag==0" />
  228. </el-form-item>
  229. <el-form-item label="课程总价">
  230. <el-input v-model="rightForm.allPrice"
  231. disabled />
  232. </el-form-item>
  233. </el-form>
  234. <el-button type="primary"
  235. style="float:right"
  236. @click="computational">
  237. 计算
  238. </el-button>
  239. </div>
  240. </div>
  241. <!-- 弹窗 -->
  242. <el-dialog title="VIP排课"
  243. ref='maskForm'
  244. width="500px"
  245. :visible.sync="dialogFormVisible">
  246. <el-form :model="maskForm"
  247. label-position="right"
  248. label-width="150px">
  249. <el-form-item label="线上课开课时间">
  250. <el-date-picker v-model="maskForm.courseStartOnline"
  251. type="date"
  252. :picker-options="courseOption"
  253. placeholder="请选择开课时间" />
  254. </el-form-item>
  255. <el-form-item label="线下课开课时间">
  256. <el-date-picker v-model="maskForm.courseStartOffline"
  257. type="date"
  258. :picker-options="courseOption"
  259. placeholder="请选择开课时间" />
  260. </el-form-item>
  261. <div class="line"
  262. style="height:1px; background:#ccc; margin:0 25px;"></div>
  263. <el-form-item label="课程类型"
  264. prop="type">
  265. <el-radio v-if="hasOnline"
  266. v-model="maskForm.type"
  267. label="ONLINE">
  268. 线上课
  269. </el-radio>
  270. <el-radio v-if="hasOffline"
  271. v-model="maskForm.type"
  272. label="OFFLINE">
  273. 线下课
  274. </el-radio>
  275. </el-form-item>
  276. <el-form-item label="循环周次"
  277. prop="week">
  278. <el-select v-model="maskForm.week"
  279. style="width:220px!important;">
  280. <el-option label="星期日"
  281. value="0" />
  282. <el-option label="星期一"
  283. value="1" />
  284. <el-option label="星期二"
  285. value="2" />
  286. <el-option label="星期三"
  287. value="3" />
  288. <el-option label="星期四"
  289. value="4" />
  290. <el-option label="星期五"
  291. value="5" />
  292. <el-option label="星期六"
  293. value="6" />
  294. </el-select>
  295. </el-form-item>
  296. <el-form-item label="上课时间"
  297. prop="startTime">
  298. <el-time-picker v-model="maskForm.startTime"
  299. format="HH:mm"
  300. value-format="HH:mm"
  301. :picker-options="{
  302. selectableRange: '00:00:00 - 23:59:00'
  303. }"
  304. placeholder="选择时间" />
  305. </el-form-item>
  306. </el-form>
  307. <div class="btnWrap">
  308. <div class="okBtn"
  309. @click="addWeek">
  310. 确认
  311. </div>
  312. </div>
  313. <div class="planList">
  314. <div class="planTop">
  315. <p>已排课程</p>
  316. </div>
  317. <div class="planCore">
  318. <div v-for="(item,index) in this.lookList"
  319. class="row"
  320. :key="index">
  321. <div class="name">
  322. {{ item.type }}
  323. </div>
  324. <div class="week">
  325. {{ item.week }}
  326. </div>
  327. <div class="time">
  328. {{ item.time }}
  329. </div>
  330. <div class="operation">
  331. <el-button type="text"
  332. @click="removeWeekCourse(item.id)">
  333. 删除
  334. </el-button>
  335. </div>
  336. </div>
  337. </div>
  338. <div slot="footer"
  339. style='margin-top:20px;'
  340. class="dialog-footer">
  341. <el-button @click="dialogFormVisible = false">
  342. 取 消
  343. </el-button>
  344. <el-button type="primary"
  345. @click="setTimeTable">
  346. 确 定
  347. </el-button>
  348. </div>
  349. </div>
  350. </el-dialog>
  351. <div class="btnWrap">
  352. <!-- <div class="closeBtn">
  353. 取消
  354. </div> -->
  355. <div class="okBtn"
  356. @click="submitInfo">
  357. {{id?'修改':'确定'}}
  358. </div>
  359. </div>
  360. </div>
  361. </template>
  362. <script>
  363. import { getTeacher, getSubject } from '@/api/buildTeam'
  364. import { vipGroupCategory, vipGroupActivityFind, getVipGroupCostCount, createVip, getVipGroupDetail, updateVipBaseInfo } from '@/api/vipSeting'
  365. import { getTeachSchool, getTeacherBySubject } from '@/api/teacherManager'
  366. export default {
  367. data () {
  368. return {
  369. dialogFormVisible: false,
  370. labelPosition: 'right',
  371. leftForm: {
  372. name: '',
  373. teacher: '',
  374. subject: '',
  375. courseType: '',
  376. activeType: '',
  377. classNum: '',
  378. classTime: '',
  379. signUpStart: '',
  380. signUpEnd: '',
  381. courseStartOnline: '',
  382. courseStartOffline: '',
  383. courseEnd: '',
  384. section: ''
  385. },
  386. classTimeList: [],
  387. centerForm: {
  388. allCourseNum: '',
  389. onlineCourseNum: 0,
  390. offlineCourseNum: 0,
  391. radio: ''
  392. },
  393. maskForm: {
  394. type: '',
  395. week: '',
  396. startTime: ''
  397. },
  398. rightForm: {
  399. onlineCourse: '',
  400. offlineCourse: '',
  401. onlinePrice: '',
  402. offlinePrice: '',
  403. allPrice: ''
  404. },
  405. subjectList: [], // 科目列表
  406. teacherList: [], // 老师列表
  407. courseTypeList: [], // 课程类型集合
  408. activeList: [], //活动集合
  409. hasOnline: false,
  410. hasOffline: false,
  411. onlineSalary: '', // 线上课课酬结算方式
  412. offlineSalary: '',// 线下课课酬结算方式
  413. hotType: '',
  414. attribute1: '',
  415. attribute2: '',
  416. salaryReadonlyFlag: '', // 老师工资是否可配
  417. lookList: [],
  418. onlinelookList: [], // 展示课表线上
  419. offlineLookList: [], // 展示课表线下
  420. timeTable: [], // 真正的课表
  421. giveNum: '',
  422. weekDay: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
  423. scetionList: [],
  424. isGiveClass: false,
  425. courseOption: {
  426. disabledDate: time => {
  427. let startTime = this.leftForm.courseStart;
  428. if (startTime) {
  429. let date = new Date(startTime.replace(/-/, "/"))
  430. return time.getTime() < date.getTime()
  431. }
  432. return;
  433. }
  434. },
  435. leftFormRules: {
  436. /**?
  437. * teacher: '',
  438. subject: '',
  439. courseType: '',
  440. activeType: '',
  441. */
  442. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  443. teacher: [
  444. { required: true, message: '请选择老师', trigger: 'blur' },],
  445. subject: [{
  446. required: true, message: '请选择科目', trigger: 'blur'
  447. }],
  448. courseType: [{
  449. required: true, message: '请选择课程类型', trigger: 'blur'
  450. }],
  451. activeType: [{
  452. required: true, message: '请选择活动', trigger: 'blur'
  453. }],
  454. signUpStart: [{
  455. required: true, message: '请选择报名开始时间', trigger: 'blur'
  456. }],
  457. signUpEnd: [{
  458. required: true, message: '请选择报名结束时间', trigger: 'blur'
  459. }]
  460. },
  461. id: ''
  462. }
  463. },
  464. computed: {
  465. allCourseCount () {
  466. let online, offline;
  467. this.centerForm.onlineCourseNum ? online = this.centerForm.onlineCourseNum : online = 0;
  468. this.centerForm.offlineCourseNum ? offline = this.centerForm.offlineCourseNum : offline = 0;
  469. let giveNum;
  470. if (this.hotType == 'GIVE_CLASS') {
  471. // this.attribute1 从多少节开始送
  472. // this.attribute2 送多少节
  473. giveNum = parseInt((parseInt(offline) + parseInt(online)) - this.attribute1 >= 0 ? giveNum = this.attribute2 : giveNum = 0);
  474. if (giveNum) {
  475. // 有赠送课时
  476. this.isGiveClass = true
  477. }
  478. this.giveNum = giveNum || 0;
  479. return (parseInt(offline) + parseInt(online) + '+' + giveNum) || '';
  480. }
  481. return parseInt(offline) + parseInt(online) || ''
  482. }
  483. },
  484. created () {
  485. // 如果有id则是修改 带出所有的数据
  486. // 没有id 则是新增
  487. this.id = this.$route.query.id
  488. if (this.$route.query.rules) {
  489. this.rules = this.$route.query.rules
  490. }
  491. if (this.$route.query.searchForm) {
  492. this.searchForm = this.$route.query.searchForm
  493. }
  494. if (this.id) {
  495. // 发请求获取信息
  496. getVipGroupDetail({ vipGroupId: this.id }).then(res => {
  497. if (res.code == 200) {
  498. this.setVipInfo(res.data);
  499. }
  500. })
  501. }
  502. },
  503. mounted () {
  504. // 获取所有科目的接口
  505. getSubject().then(res => {
  506. if (res.code == 200) {
  507. this.subjectList = res.data;
  508. }
  509. })
  510. getTeacher().then(res => {
  511. if (res.code == 200) {
  512. this.teacherList = res.data;
  513. }
  514. })
  515. // 获取所有老师的接口 根据声部id获取老师
  516. // 获取课程类型的接口
  517. },
  518. methods: {
  519. changeSubject (val) {
  520. this.leftForm.teacher = ''
  521. this.leftForm.section = ''
  522. // 根据科目id获取相应的老师
  523. // getTeacherBySubject({ subjecId: val }).then(res => {
  524. // if (res.code == 200) {
  525. // this.teacherList = res.data;
  526. // }
  527. // })
  528. },
  529. // 选择课程类型
  530. changeType (val) {
  531. // 在这里清空默认课酬
  532. this.rightForm.offlineCourse = '';
  533. this.rightForm.onlineCourse = '';
  534. this.leftForm.activeType = '';
  535. for (let i in this.courseTypeList) {
  536. if (this.courseTypeList[i].id == val) {
  537. // 学生人数
  538. this.leftForm.classNum = this.courseTypeList[i].studentNum;
  539. // 每课时长
  540. this.classTimeList = this.courseTypeList[i].singleClassMinutes.split(',')
  541. // this.leftForm.classTime = this.courseTypeList[i].singleClassMinutes;
  542. this.leftForm.classTime = this.classTimeList[0];
  543. // 线上课单节价格
  544. this.rightForm.onlinePrice = this.courseTypeList[i].onlineClassesUnitPrice;
  545. // 线下课单节价格
  546. this.rightForm.offlinePrice = this.courseTypeList[i].offlineClassesUnitPrice;
  547. }
  548. }
  549. // teacherId
  550. // 根据课程类型获取活动方案
  551. if (this.leftForm.courseType) {
  552. // console.log(this.leftForm.teacher)
  553. vipGroupActivityFind({ 'categoryId': this.leftForm.courseType, teacherId: this.leftForm.teacher }).then(res => {
  554. if (res.code == 200) {
  555. this.activeList = res.data;
  556. }
  557. })
  558. }
  559. },
  560. // 选择活动方案
  561. chioseActive (val) {
  562. this.lookList = []
  563. this.timeTable = []
  564. this.attribute1 = '';
  565. this.attribute2 = '';
  566. this.giveNum = 0;
  567. this.isGiveClass = false;
  568. // 根须活动id获取 相应的值
  569. for (let i in this.activeList) {
  570. if (this.activeList[i].id == val) {
  571. // 如果是买赠就必须选择赠课类型
  572. // 报名开始 报名结束 课程开始 课程结束 // 判断是否有线上,线下课 并同步状态
  573. // this.leftForm.signUpStart = this.activeList[i].startTime;
  574. // this.leftForm.signUpEnd = this.activeList[i].endTime;
  575. this.leftForm.courseStart = this.activeList[i].coursesStartTime;
  576. this.leftForm.courseEnd = this.activeList[i].coursesEndTime;
  577. // 获取活动种类并保存
  578. this.hotType = this.activeList[i].type;
  579. // 获取买赠必要参数
  580. this.attribute1 = this.activeList[i].attribute1;
  581. this.attribute2 = this.activeList[i].attribute2;
  582. // 存储课酬是否可配置
  583. this.salaryReadonlyFlag = this.activeList[i].salaryReadonlyFlag
  584. // hasOnline: false, hasOffline: false 还需要判断type类型 根据活动id获取
  585. if (this.activeList[i].salarySettlementJson) {
  586. let obj = JSON.parse(this.activeList[i].salarySettlementJson)
  587. if (obj && obj.onlineSalarySettlement) {
  588. // 有线上课
  589. this.hasOnline = true;
  590. this.onlineSalary = obj.onlineSalarySettlement.salarySettlementType;
  591. // console.log('线上:' + this.onlineSalary)
  592. } else {
  593. this.hasOnline = false;
  594. }
  595. if (obj && obj.offlineSalarySettlement) {
  596. // 有线下课
  597. this.hasOffline = true;
  598. this.offlineSalary = obj.offlineSalarySettlement.salarySettlementType;
  599. // console.log('线下:' + this.offlineSalary)
  600. } else {
  601. this.hasOffline = false;
  602. }
  603. }
  604. }
  605. }
  606. },
  607. // 点击确插入课表
  608. addWeek () {
  609. let courseType = this.maskForm.type;
  610. // let week = ;this.maskForm.week
  611. let startTime = this.maskForm.startTime;
  612. if (!courseType || !this.maskForm.week || !startTime) {
  613. this.$message.error('请填写完成信息')
  614. return;
  615. }
  616. // 拿到相应的值插入数组
  617. let endTime = this.MinutesTest(startTime, this.leftForm.classTime);
  618. let str;
  619. switch (courseType) {
  620. case 'ONLINE': {
  621. str = '线上课'
  622. break;
  623. }
  624. case 'OFFLINE': {
  625. str = '线下课'
  626. break;
  627. }
  628. }
  629. let flag = false;
  630. for (let i in this.lookList) {
  631. if (this.lookList[i].weekDay == this.maskForm.week) {
  632. flag = true;
  633. }
  634. }
  635. // true=> 说明有这一周 那么循环找到这一周 在判断时间
  636. // flase=> 说明没有这一周的时间 直接添加
  637. if (flag) {
  638. // 有相同的周日
  639. let arr = [];
  640. for (let i in this.lookList) {
  641. if (this.lookList[i].weekDay == this.maskForm.week) { // 找到这一天的所有元素
  642. // && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, startTime) && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, endTime)
  643. let isStartTime = this.timeIsrange(startTime, endTime, this.lookList[i].startTime);
  644. let isEndTime = this.timeIsrange(startTime, endTime, this.lookList[i].endTime);
  645. arr.push(!isEndTime && !isStartTime)
  646. }
  647. }
  648. let isAdd = true;
  649. for (let j = 0; j < arr.length; j++) {
  650. isAdd = isAdd && arr[j]
  651. }
  652. if (isAdd) {
  653. this.lookList.push({
  654. 'type': str,
  655. 'week': this.weekDay[this.maskForm.week],
  656. 'weekDay': this.maskForm.week,
  657. 'startTime': startTime,
  658. 'endTime': endTime,
  659. 'time': startTime + '-' + endTime,
  660. 'id': Date.now()
  661. })
  662. } else {
  663. this.$message.error('该时间段已排课请重选时间')
  664. return
  665. }
  666. } else {
  667. this.lookList.push({
  668. 'type': str,
  669. 'week': this.weekDay[this.maskForm.week],
  670. 'weekDay': this.maskForm.week,
  671. 'startTime': startTime,
  672. 'endTime': endTime,
  673. 'time': startTime + '-' + endTime,
  674. 'id': Date.now()
  675. })
  676. }
  677. // console.log(this.lookList)
  678. // let courseType = this.maskForm.type;
  679. // // let week = ;this.maskForm.week
  680. // let startTime = this.maskForm.startTime;
  681. this.maskForm.type = '';
  682. this.maskForm.week = '';
  683. this.maskForm.startTime = '';
  684. },
  685. // 分钟小时相加减
  686. MinutesTest (str, interval) {
  687. let houer = str.split(':')[0];
  688. let min = str.split(':')[1];
  689. let sdate1 = new Date(1900, 1, 1, houer, min);
  690. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  691. let H = sdate1.getHours();
  692. let M = sdate1.getMinutes();
  693. if (H < 10) H = '0' + H;
  694. if (M < 10) M = '0' + M;
  695. return H + ':' + M
  696. },
  697. // 判断时间是否在时间段内
  698. timeIsrange (beginTime, endTime, nowTime) {
  699. var strb = beginTime.split(":");
  700. if (strb.length != 2) {
  701. return false;
  702. }
  703. var stre = endTime.split(":");
  704. if (stre.length != 2) {
  705. return false;
  706. }
  707. var strn = nowTime.split(":");
  708. if (stre.length != 2) {
  709. return false;
  710. }
  711. var b = new Date();
  712. var e = new Date();
  713. var n = new Date();
  714. b.setHours(strb[0]);
  715. b.setMinutes(strb[1]);
  716. e.setHours(stre[0]);
  717. e.setMinutes(stre[1]);
  718. n.setHours(strn[0]);
  719. n.setMinutes(strn[1]);
  720. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  721. // 在时间范围内
  722. return true;
  723. } else {
  724. // 不在时间范围内
  725. return false;
  726. }
  727. },
  728. removeWeekCourse (id) {
  729. for (let i in this.lookList) {
  730. if (this.lookList[i].id == id) {
  731. this.lookList.splice(i, 1);
  732. }
  733. }
  734. },
  735. setTimeTable () {
  736. // 拿到线上课数与线下课数 以及
  737. this.timeTable = [];
  738. let online = parseInt(this.centerForm.onlineCourseNum) || 0;
  739. let offline = parseInt(this.centerForm.offlineCourseNum) || 0;
  740. let giveNum = this.giveNum;
  741. let giveClassType = this.centerForm.radio;
  742. if (giveClassType == 'ONLINE') {
  743. // 线上
  744. online += giveNum;
  745. } else if (giveClassType == 'OFFLINE') {
  746. offline += giveNum;
  747. }
  748. // 这里判断是否选择了排课开始时间
  749. if (online && !this.maskForm.courseStartOnline) {
  750. this.$message.error('选择了线上课 但没有线上课开始时间')
  751. return
  752. }
  753. if (offline && !this.maskForm.courseStartOffline) {
  754. this.$message.error('选择了线下课 但没有线下课开始时间')
  755. return
  756. }
  757. let date, date1;
  758. if (this.maskForm.courseStartOnline) {
  759. date = new Date(this.maskForm.courseStartOnline.getTime());
  760. }
  761. if (this.maskForm.courseStartOffline) {
  762. date1 = new Date(this.maskForm.courseStartOffline.getTime());
  763. }
  764. // let startWeekday = this.maskForm.courseStart.getDay();
  765. let onlineList = []; // 装线上课的数组
  766. let offlineList = []; //装线下课的数组
  767. if (this.lookList.length <= 0) {
  768. this.$message.error('请先排课后再点击确认按钮');
  769. return
  770. }
  771. for (let i in this.lookList) {
  772. if (this.lookList[i].type == '线上课') {
  773. onlineList.push({ week: this.lookList[i].weekDay, date: this.lookList[i] })
  774. }
  775. if (this.lookList[i].type == '线下课') {
  776. offlineList.push({ week: this.lookList[i].weekDay, date: this.lookList[i] })
  777. }
  778. }
  779. // console.log(onlineList + '----------------------------------------------------------------------------------');
  780. // console.log(offlineList);
  781. if (online > 0 && onlineList.length <= 0) {
  782. this.$message.error('选择了线上课但未排线上课');
  783. this.timeTable = [];
  784. return;
  785. }
  786. if (offline > 0 && offlineList.length <= 0) {
  787. this.$message.error('选择了线下课但未排线下课')
  788. this.timeTable = [];
  789. return;
  790. }
  791. // 获取要排课的总数 获取每周要排多少次
  792. while (online && online > 0) {
  793. // 排线上课g
  794. for (let i in onlineList) {
  795. let num;
  796. onlineList[i].week - date.getDay() >= 0 ? num = onlineList[i].week - date.getDay() : num = onlineList[i].week - date.getDay() + 7// +差值的天数://差值的天数+7
  797. // console.log(num);
  798. let dataStr = this.getThinkDate(date, num);
  799. this.timeTable.push({
  800. 'classDate': dataStr + ' 00:00:00',
  801. 'actualTeacherId': this.leftForm.teacher,
  802. 'startClassTimeStr': onlineList[i].date.startTime,
  803. "endClassTimeStr": onlineList[i].date.endTime,
  804. "teachMode": 'ONLINE'
  805. })
  806. online--;
  807. if (online == 0) break
  808. }
  809. if (onlineList.length == 1 || this.isAllEqual(onlineList)) {
  810. date.setDate(date.getDate() + 7);
  811. }
  812. // 加一周
  813. }
  814. // console.log(date1)
  815. while (offline && offline > 0) {
  816. // 排线下课
  817. for (let i in offlineList) {
  818. let num;
  819. offlineList[i].week - date1.getDay() >= 0 ? num = offlineList[i].week - date1.getDay() : num = offlineList[i].week - date1.getDay() + 7// +差值的天数://差值的天数+7
  820. let dataStr = this.getThinkDate(date1, num);
  821. this.timeTable.push({
  822. 'classDate': dataStr + ' 00:00:00',
  823. 'actualTeacherId': this.leftForm.teacher,
  824. 'startClassTimeStr': offlineList[i].date.startTime,
  825. "endClassTimeStr": offlineList[i].date.endTime,
  826. "teachMode": 'OFFLINE'
  827. })
  828. offline--;
  829. if (offline == 0) break
  830. }
  831. // 加一周
  832. if (offlineList.length == 1 || this.isAllEqual(offlineList)) {
  833. date1.setDate(date1.getDate() + 7);
  834. }
  835. }
  836. // console.log(this.timeTable);
  837. this.dialogFormVisible = false;
  838. },
  839. getThinkDate (date, num) {
  840. let Stamp = date;
  841. Stamp.setDate(date.getDate() + num) // 获取当前月数的第几天
  842. // console.log(date.getMonth() + 1)
  843. // console.log(Stamp.getMonth() + 1)
  844. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  845. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  846. var mvar = '';
  847. if (month < 10) {
  848. mvar = '0' + month;
  849. } else {
  850. mvar = month + '';
  851. }
  852. var day = Stamp.getDate();
  853. var dvar = '';
  854. if (day < 10) {
  855. dvar = '0' + day;
  856. } else {
  857. dvar = day + '';
  858. }
  859. // console.log(year + "-" + mvar + '-' + dvar);
  860. return year + "-" + mvar + '-' + dvar;
  861. },
  862. // 计算课酬
  863. computational () {
  864. let userId = this.leftForm.teacher || null;
  865. let giveTeachMode = this.centerForm.radio || null;
  866. let vipGroupCategoryId = this.leftForm.courseType || null;
  867. let vipGroupActivityId = this.leftForm.activeType || null;
  868. let onlineClassesUnitPrice = this.rightForm.onlinePrice || null;
  869. let offlineClassesUnitPrice = this.rightForm.offlinePrice || null;
  870. let onlineClassesNum = this.centerForm.onlineCourseNum || 0;
  871. let offlineClassesNum = this.centerForm.offlineCourseNum || 0;
  872. let singleClassMinutes = this.leftForm.classTime
  873. if (this.hotType == 'GIVE_CLASS') {
  874. if (this.centerForm.radio == 'ONLINE') {
  875. onlineClassesNum = parseInt(onlineClassesNum) + parseInt(this.giveNum)
  876. } else if (this.centerForm.radio == 'OFFLINE') {
  877. offlineClassesNum = parseInt(offlineClassesNum) + parseInt(this.giveNum)
  878. }
  879. }
  880. let onlineTeacherSalary = this.rightForm.onlineCourse || null;
  881. let offlineTeacherSalary = this.rightForm.offlineCourse || null;
  882. getVipGroupCostCount({ vipGroupActivityId, onlineClassesUnitPrice, onlineTeacherSalary, offlineTeacherSalary, vipGroupCategoryId, offlineClassesUnitPrice, onlineClassesNum, offlineClassesNum, userId, giveTeachMode, singleClassMinutes }).then(res => {
  883. if (res.code == 200) {
  884. this.rightForm.onlineCourse = res.data.onlineTeacherSalary;
  885. this.rightForm.offlineCourse = res.data.offlineTeacherSalary;
  886. this.rightForm.allPrice = res.data.totalPrice;
  887. }
  888. })
  889. },
  890. isAllEqual (array) {
  891. if (array.length > 0) {
  892. return !array.some((val, index) => {
  893. return val.week != array[0].week
  894. })
  895. } else {
  896. return true
  897. }
  898. },
  899. submitInfo () {
  900. let online = parseInt(this.centerForm.onlineCourseNum);
  901. let offline = parseInt(this.centerForm.offlineCourseNum);
  902. let giveNum = this.giveNum;
  903. let giveClassType = this.centerForm.radio;
  904. if (giveClassType == 'ONLINE') {
  905. // 线上
  906. online += giveNum;
  907. } else if (giveClassType == 'OFFLINE') {
  908. offline += giveNum;
  909. }
  910. let obj = {};
  911. obj.courseSchedules = this.timeTable;
  912. /**
  913. *
  914. * teacher: '',
  915. subject: '',
  916. courseType: '',
  917. activeType: '',
  918. classNum: '',
  919. classTime: '',
  920. signUpStart: '',
  921. signUpEnd: '',
  922. courseStart: '',
  923. courseEnd: ''
  924. */
  925. obj.vipGroupApplyBaseInfo = {
  926. coursesExpireDate: this.leftForm.courseEnd,
  927. teacherSchoolId: this.leftForm.section,
  928. name: this.leftForm.name,
  929. offlineClassesNum: offline || 0,
  930. onlineClassesNum: online || 0,
  931. offlineClassesUnitPrice: this.rightForm.offlinePrice,
  932. onlineClassesUnitPrice: this.rightForm.onlinePrice,
  933. paymentExpireDate: this.leftForm.signUpEnd,
  934. registrationStartTime: this.leftForm.signUpStart,
  935. singleClassMinutes: this.leftForm.classTime,
  936. studentNum: this.leftForm.classNum,
  937. userId: this.leftForm.teacher,
  938. vipGroupActivityId: this.leftForm.activeType,
  939. vipGroupCategoryId: this.leftForm.courseType,
  940. onlineTeacherSalary: this.rightForm.onlineCourse,
  941. offlineTeacherSalary: this.rightForm.offlineCourse,
  942. giveTeachMode: this.centerForm.radio,
  943. subjectIdList: this.leftForm.subject,
  944. }
  945. // 调接前判断是新增还是修改
  946. if (!this.id) {
  947. // 新增
  948. createVip(obj).then(res => {
  949. if (res.code == 200) {
  950. this.$message.success('恭喜您创建成功');
  951. this.$router.push({ path: '/business/vipList', query: { rules: this.rules, searchForm: this.searchForm } })
  952. }
  953. })
  954. } else {
  955. // 修改
  956. obj.vipGroupApplyBaseInfo.id = this.id;
  957. updateVipBaseInfo(obj.vipGroupApplyBaseInfo).then(res => {
  958. })
  959. }
  960. },
  961. setSection (val) {
  962. console.log(val)
  963. this.leftForm.section = '';
  964. this.rightForm.offlineCourse = '';
  965. this.rightForm.onlineCourse = '';
  966. this.leftForm.courseType = ''
  967. getTeachSchool({ userId: val }).then(res => {
  968. if (res.code == 200) {
  969. this.scetionList = res.data;
  970. }
  971. })
  972. for (let i in this.teacherList) {
  973. if (this.teacherList[i].id == val) {
  974. // 根据分部id去获取课程形式
  975. vipGroupCategory({ organId: this.teacherList[i].organId }).then(res => {
  976. if (res.code == 200) {
  977. this.courseTypeList = res.data;
  978. }
  979. })
  980. }
  981. }
  982. },
  983. onCancel () {
  984. this.$router.push({ path: '/business/vipList', query: { rules: this.rules, searchForm: this.searchForm } })
  985. },
  986. setCourse () {
  987. //
  988. if (this.hotType == 'GIVE_CLASS' && this.isGiveClass && !this.centerForm.radio) {
  989. this.$message.error('您还未选择赠课类型')
  990. return
  991. }
  992. this.$refs['leftForm'].validate(vali => {
  993. if (vali) {
  994. this.dialogFormVisible = true
  995. }
  996. })
  997. },
  998. setVipInfo (data) {
  999. this.leftForm.name = data.name;
  1000. this.leftForm.subject = parseInt(data.subjectIdList)
  1001. // 激活声部下的所有老师
  1002. this.changeSubject(parseInt(data.subjectIdList));
  1003. // 设置老师
  1004. this.leftForm.teacher = data.userId;
  1005. this.setSection(data.userId)
  1006. // 课程形式
  1007. this.leftForm.courseType = data.vipGroupCategoryId;
  1008. // 获取课程形式下的活动方案
  1009. this.changeType(this.leftForm.courseType)
  1010. // 根据课程形式获取活动方案
  1011. this.leftForm.activeType = data.vipGroupActivityId;
  1012. setTimeout(res => {
  1013. this.chioseActive(data.vipGroupActivityId)
  1014. }, 1000)
  1015. this.leftForm.section = data.teacherSchoolId;
  1016. this.leftForm.classNum = data.studentNum;
  1017. this.leftForm.classTime = data.singleClassMinutes;
  1018. this.leftForm.signUpStart = data.registrationStartTime;
  1019. this.leftForm.signUpEnd = data.paymentExpireDate;
  1020. this.centerForm.onlineCourseNum = data.onlineClassesNum;
  1021. this.centerForm.offlineCourseNum = data.offlineCourseNum;
  1022. /**
  1023. * rightForm: {
  1024. onlineCourse: '',
  1025. offlineCourse: '',
  1026. onlinePrice: '',
  1027. offlinePrice: '',
  1028. allPrice: ''
  1029. },
  1030. *
  1031. */
  1032. this.rightForm.onlineCourse = data.onlineTeacherSalary
  1033. this.rightForm.onlinePrice = data.onlineClassesUnitPrice;
  1034. this.rightForm.offlineCourse = data.offlineTeacherSalary
  1035. this.rightForm.offlinePrice = data.offlineClassesUnitPrice;
  1036. this.rightForm.allPrice = data.totalPrice;
  1037. //subjectIdList
  1038. }
  1039. },
  1040. }
  1041. </script>
  1042. <style lang="scss" scoped>
  1043. .m-core {
  1044. margin-top: 30px;
  1045. display: flex;
  1046. flex-direction: row;
  1047. justify-content: space-around;
  1048. .el-input {
  1049. width: 180px;
  1050. }
  1051. h4 {
  1052. font-size: 16px;
  1053. background-color: #ccc;
  1054. color: #fff;
  1055. text-align: center;
  1056. width: 100%;
  1057. height: 40px;
  1058. line-height: 40px;
  1059. margin-bottom: 20px;
  1060. }
  1061. .vipLeft {
  1062. width: 400px;
  1063. // h4 {
  1064. // font-size: 16px;
  1065. // background-color: #ccc;
  1066. // color: #fff;
  1067. // text-align: center;
  1068. // width: 100%;
  1069. // height: 40px;
  1070. // line-height: 40px;
  1071. // margin-bottom: 20px;
  1072. // }
  1073. }
  1074. .center {
  1075. width: 400px;
  1076. }
  1077. .right {
  1078. width: 400px;
  1079. }
  1080. }
  1081. .planList {
  1082. padding: 0 25px;
  1083. .planTop {
  1084. height: 40px;
  1085. line-height: 40px;
  1086. display: flex;
  1087. flex-direction: row;
  1088. justify-content: space-between;
  1089. border-bottom: 1px solid #ccc;
  1090. margin-top: 20px;
  1091. > p {
  1092. font-size: 14px;
  1093. }
  1094. }
  1095. .planCore {
  1096. .row {
  1097. width: 100%;
  1098. display: flex;
  1099. flex-direction: row;
  1100. justify-content: space-between;
  1101. flex-wrap: nowrap;
  1102. height: 40px;
  1103. line-height: 40px;
  1104. font-size: 14px;
  1105. text-align: center;
  1106. div {
  1107. width: 87px;
  1108. }
  1109. // div {
  1110. // &:nth-child(1) {
  1111. // text-align: left;
  1112. // }
  1113. // }
  1114. }
  1115. }
  1116. }
  1117. .okBtn {
  1118. width: 120px;
  1119. height: 40px;
  1120. line-height: 40px;
  1121. text-align: center;
  1122. color: #fff;
  1123. border-radius: 4px;
  1124. margin-right: 20px;
  1125. cursor: pointer;
  1126. background-color: #f97215;
  1127. float: right;
  1128. }
  1129. </style>