index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. VIP课申请
  6. </h2>
  7. <div class="m-core">
  8. <div class="vipLeft">
  9. <h4>课程信息</h4>
  10. <el-form ref='leftForm'
  11. :rules='leftFormRules'
  12. :label-position='labelPosition'
  13. label-width="100px"
  14. :model="leftForm">
  15. <el-form-item label="课程名称"
  16. prop="name">
  17. <el-input v-model="leftForm.name"></el-input>
  18. </el-form-item>
  19. <el-form-item label="科目名称"
  20. prop="subject">
  21. <el-select v-model="leftForm.subject">
  22. <el-option v-for='(item,index) in subjectList'
  23. :key='index'
  24. :value="item.id"
  25. :label="item.name"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="指导老师"
  29. prop="teacher">
  30. <el-select v-model="leftForm.teacher"
  31. :disabled="!leftForm.subject">
  32. <el-option v-for="(item,index) in teacherList"
  33. :key="index"
  34. :label="item.username"
  35. :value="item.id"></el-option>
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="课程形式"
  39. prop="courseType">
  40. <el-select v-model="leftForm.courseType"
  41. @change="changeType">
  42. <el-option v-for="(item,index) in courseTypeList"
  43. :key="index"
  44. :label="item.name"
  45. :value="item.id"></el-option>
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item label="活动方案"
  49. prop="activeType">
  50. <el-select v-model="leftForm.activeType"
  51. :disabled="!leftForm.courseType"
  52. @change='chioseActive'>
  53. <el-option v-for='(item,index) in activeList'
  54. :key='index'
  55. :value="item.id"
  56. :label="item.name"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="每班人数">
  60. <el-input type='number'
  61. disabled
  62. v-model="leftForm.classNum"></el-input>
  63. </el-form-item>
  64. <el-form-item label="每课时长">
  65. <el-input type='number'
  66. disabled
  67. v-model="leftForm.classTime"></el-input>
  68. </el-form-item>
  69. <el-form-item label="报名开始时间"
  70. v-if="leftForm.signUpStart">
  71. <el-date-picker v-model="leftForm.signUpStart"
  72. disabled
  73. type="date"
  74. value-format="yyyy-MM-dd HH:mm:ss"
  75. placeholder="请选择时间">
  76. </el-date-picker>
  77. </el-form-item>
  78. <el-form-item label="报名结束时间"
  79. v-if="leftForm.signUpEnd">
  80. <el-date-picker v-model="leftForm.signUpEnd"
  81. disabled
  82. type="date"
  83. value-format="yyyy-MM-dd HH:mm:ss"
  84. placeholder="请选择时间">
  85. </el-date-picker>
  86. </el-form-item>
  87. <el-form-item label="课程开始时间"
  88. v-if="leftForm.courseStart">
  89. <el-date-picker v-model="leftForm.courseStart"
  90. disabled
  91. type="date"
  92. value-format="yyyy-MM-dd HH:mm:ss"
  93. placeholder="请选择时间">
  94. </el-date-picker>
  95. </el-form-item>
  96. <el-form-item label="课程结束时间"
  97. v-if="leftForm.courseEnd">
  98. <el-date-picker v-model="leftForm.courseEnd"
  99. disabled
  100. type="date"
  101. value-format="yyyy-MM-dd HH:mm:ss"
  102. placeholder="请选择时间">
  103. </el-date-picker>
  104. </el-form-item>
  105. </el-form>
  106. </div>
  107. <div class="center">
  108. <h4>排课设置</h4>
  109. <el-form :model='centerForm'
  110. label-width="100px"
  111. :label-position="labelPosition">
  112. <el-form-item label="线上课数"
  113. v-if="hasOnline">
  114. <el-input type='number'
  115. v-model="centerForm.onlineCourseNum"></el-input>
  116. </el-form-item>
  117. <el-form-item label="线下课数"
  118. v-if="hasOffline">
  119. <el-input type='number'
  120. v-model="centerForm.offlineCourseNum"></el-input>
  121. </el-form-item>
  122. <el-form-item label="待排课数">
  123. <el-input disabled
  124. v-model="allCourseCount"></el-input>
  125. </el-form-item>
  126. <el-form-item label="赠课课程类型"
  127. v-if="hotType=='GIVE_CLASS'">
  128. <el-radio v-model="centerForm.radio"
  129. label="ONLINE">线上课</el-radio>
  130. <el-radio v-model="centerForm.radio"
  131. label="OFFLINE">线下课</el-radio>
  132. </el-form-item>
  133. </el-form>
  134. <!-- 排课列表开始 -->
  135. <div class="planList">
  136. <div class="planTop">
  137. <p>已排课程</p>
  138. <el-button type='text'
  139. @click="dialogFormVisible = true">点击排课</el-button>
  140. </div>
  141. <div class="planCore">
  142. <div class="row"
  143. v-for="(item,index) in this.lookList">
  144. <div class="name">{{ item.type }}</div>
  145. <div class="week">{{ item.week }}</div>
  146. <div class="time">{{ item.time }}</div>
  147. <div class="operation">
  148. <el-button type='text'
  149. @click="removeWeekCourse(item.id)">删除</el-button>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. <div class="right">
  156. <h4>课酬设置</h4>
  157. <el-form :model="rightForm"
  158. label-width="100px"
  159. :label-position="labelPosition">
  160. <el-form-item label="线上课课酬"
  161. v-if="hasOnline">
  162. <el-input v-model="rightForm.onlineCourse"
  163. :disabled="salaryReadonlyFlag==0 || onlineSalary!='TEACHER_DEFAULT'"></el-input>
  164. </el-form-item>
  165. <el-form-item label="线下课课酬"
  166. v-if="hasOffline">
  167. <el-input v-model="rightForm.offlineCourse"
  168. :disabled="salaryReadonlyFlag==0 || offlineSalary!='TEACHER_DEFAULT'"></el-input>
  169. </el-form-item>
  170. <el-form-item label="线上课单价"
  171. v-if="hasOnline">
  172. <el-input v-model="rightForm.onlinePrice"
  173. :disabled="salaryReadonlyFlag==0"></el-input>
  174. </el-form-item>
  175. <el-form-item label="线下课单价"
  176. v-if="hasOffline">
  177. <el-input v-model="rightForm.offlinePrice"
  178. :disabled="salaryReadonlyFlag==0"></el-input>
  179. </el-form-item>
  180. <el-form-item label="课程总价">
  181. <el-input v-model="rightForm.allPrice"
  182. disabled></el-input>
  183. </el-form-item>
  184. </el-form>
  185. <el-button type="primary"
  186. style="float:right"
  187. @click="computational">计算</el-button>
  188. </div>
  189. </div>
  190. <!-- 弹窗 -->
  191. <el-dialog title="VIP排课"
  192. width="500px"
  193. ref='maskForm'
  194. :visible.sync="dialogFormVisible">
  195. <el-form :model="maskForm">
  196. <el-form-item label="课程类型"
  197. prop="type">
  198. <el-radio v-model="maskForm.type"
  199. v-if="hasOnline"
  200. label="ONLINE">线上课</el-radio>
  201. <el-radio v-model="maskForm.type"
  202. v-if="hasOffline"
  203. label="OFFLINE">线下课</el-radio>
  204. </el-form-item>
  205. <el-form-item label="循环周次"
  206. prop="week">
  207. <el-select v-model="maskForm.week">
  208. <el-option label="星期日"
  209. value="0"></el-option>
  210. <el-option label="星期一"
  211. value="1"></el-option>
  212. <el-option label="星期二"
  213. value="2"></el-option>
  214. <el-option label="星期三"
  215. value="3"></el-option>
  216. <el-option label="星期四"
  217. value="4"></el-option>
  218. <el-option label="星期五"
  219. value="5"></el-option>
  220. <el-option label="星期六"
  221. value="6"></el-option>
  222. </el-select>
  223. </el-form-item>
  224. <el-form-item label="上课时间"
  225. prop="startTime">
  226. <el-time-picker v-model="maskForm.startTime"
  227. format='HH:mm'
  228. value-format='HH:mm'
  229. :picker-options="{
  230. selectableRange: '00:00:00 - 23:59:00'
  231. }"
  232. placeholder="选择时间">
  233. </el-time-picker>
  234. </el-form-item>
  235. </el-form>
  236. <div class="btnWrap">
  237. <div class="okBtn"
  238. @click='addWeek'>确认</div>
  239. </div>
  240. <div class="planList">
  241. <div class="planTop">
  242. <p>已排课程</p>
  243. </div>
  244. <div class="planCore">
  245. <div class="row"
  246. v-for="(item,index) in this.lookList">
  247. <div class="name">{{ item.type }}</div>
  248. <div class="week">{{ item.week }}</div>
  249. <div class="time">{{ item.time }}</div>
  250. <div class="operation">
  251. <el-button type='text'
  252. @click="removeWeekCourse(item.id)">删除</el-button>
  253. </div>
  254. </div>
  255. </div>
  256. <div style="margin:20px 0">
  257. <el-date-picker v-model="maskForm.courseStart"
  258. type="date"
  259. :picker-options="courseOption"
  260. placeholder="请选择开课时间">
  261. </el-date-picker>
  262. </div>
  263. <div slot="footer"
  264. class="dialog-footer">
  265. <el-button @click="dialogFormVisible = false">取 消</el-button>
  266. <el-button type="primary"
  267. @click="setTimeTable">确 定</el-button>
  268. </div>
  269. </div>
  270. </el-dialog>
  271. <div class="btnWrap">
  272. <div class="closeBtn">取消</div>
  273. <div class="okBtn"
  274. @click="submitInfo">确定</div>
  275. </div>
  276. </div>
  277. </template>
  278. <script>
  279. import { getTeacher, getSubject } from '@/api/buildTeam'
  280. import { vipGroupCategory, vipGroupActivityFind, getVipGroupCostCount, createVip } from '@/api/vipSeting'
  281. export default {
  282. data () {
  283. return {
  284. dialogFormVisible: false,
  285. labelPosition: 'right',
  286. leftForm: {
  287. name: '',
  288. teacher: '',
  289. subject: '',
  290. courseType: '',
  291. activeType: '',
  292. classNum: '',
  293. classTime: '',
  294. signUpStart: '',
  295. signUpEnd: '',
  296. courseStart: '',
  297. courseEnd: ''
  298. },
  299. centerForm: {
  300. allCourseNum: '',
  301. onlineCourseNum: 0,
  302. offlineCourseNum: 0,
  303. radio: ''
  304. },
  305. maskForm: {
  306. type: '',
  307. week: '',
  308. startTime: ''
  309. },
  310. rightForm: {
  311. onlineCourse: '',
  312. offlineCourse: '',
  313. onlinePrice: '',
  314. offlinePrice: '',
  315. allPrice: ''
  316. },
  317. subjectList: [], // 科目列表
  318. teacherList: [], // 老师列表
  319. courseTypeList: [], // 课程类型集合
  320. activeList: [], //活动集合
  321. hasOnline: false,
  322. hasOffline: false,
  323. onlineSalary: '', // 线上课课酬结算方式
  324. offlineSalary: '',// 线下课课酬结算方式
  325. hotType: '',
  326. attribute1: '',
  327. attribute2: '',
  328. salaryReadonlyFlag: '', // 老师工资是否可配
  329. lookList: [], // 展示课表
  330. timeTable: [], // 真正的课表
  331. giveNum: '',
  332. weekDay: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
  333. courseOption: {
  334. disabledDate: time => {
  335. let startTime = this.leftForm.courseStart;
  336. if (startTime) {
  337. let date = new Date(startTime.replace(/-/, "/"))
  338. return time.getTime() < date.getTime()
  339. }
  340. return;
  341. }
  342. },
  343. leftFormRules: {
  344. /**?
  345. * teacher: '',
  346. subject: '',
  347. courseType: '',
  348. activeType: '',
  349. */
  350. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  351. teacher: [
  352. { required: true, message: '请选择老师', trigger: 'blur' },],
  353. subject: [{
  354. required: true, message: '请选择科目', trigger: 'blur'
  355. }],
  356. courseType: [{
  357. required: true, message: '请选择课程类型', trigger: 'blur'
  358. }],
  359. activeType: [{
  360. required: true, message: '请选择活动', trigger: 'blur'
  361. }]
  362. }
  363. }
  364. },
  365. mounted () {
  366. // 获取所有科目的接口
  367. getSubject().then(res => {
  368. if (res.code == 200) {
  369. this.subjectList = res.data.rows;
  370. }
  371. })
  372. // 获取所有老师的接口
  373. getTeacher().then(res => {
  374. if (res.code == 200) {
  375. this.teacherList = res.data;
  376. }
  377. })
  378. // 获取课程类型的接口
  379. vipGroupCategory({ organId: this.$store.getters.organ }).then(res => {
  380. if (res.code == 200) {
  381. this.courseTypeList = res.data;
  382. }
  383. })
  384. },
  385. computed: {
  386. allCourseCount () {
  387. let online, offline;
  388. this.centerForm.onlineCourseNum ? online = this.centerForm.onlineCourseNum : online = 0;
  389. this.centerForm.offlineCourseNum ? offline = this.centerForm.offlineCourseNum : offline = 0;
  390. let giveNum;
  391. if (this.hotType == 'GIVE_CLASS') {
  392. // this.attribute1 从多少节开始送
  393. // this.attribute2 送多少节
  394. giveNum = parseInt((parseInt(offline) + parseInt(online)) - this.attribute1 >= 0 ? giveNum = this.attribute2 : giveNum = 0);
  395. this.giveNum = giveNum || 0;
  396. return (parseInt(offline) + parseInt(online) + '+' + giveNum) || '';
  397. }
  398. return parseInt(offline) + parseInt(online) || ''
  399. }
  400. },
  401. methods: {
  402. // 选择课程类型
  403. changeType (val) {
  404. for (let i in this.courseTypeList) {
  405. if (this.courseTypeList[i].id == val) {
  406. // 学生人数
  407. this.leftForm.classNum = this.courseTypeList[i].studentNum;
  408. // 每课时长
  409. this.leftForm.classTime = this.courseTypeList[i].singleClassMinutes;
  410. // 线上课单节价格
  411. this.rightForm.onlinePrice = this.courseTypeList[i].onlineClassesUnitPrice;
  412. // 线下课单节价格
  413. this.rightForm.offlinePrice = this.courseTypeList[i].offlineClassesUnitPrice;
  414. }
  415. }
  416. // 根据课程类型获取活动方案
  417. if (this.leftForm.courseType) {
  418. vipGroupActivityFind({ 'categoryId': this.leftForm.courseType }).then(res => {
  419. if (res.code == 200) {
  420. this.activeList = res.data;
  421. }
  422. })
  423. }
  424. },
  425. // 选择活动方案
  426. chioseActive (val) {
  427. this.attribute1 = ''
  428. this.attribute2 = '';
  429. // console.log(val);
  430. // 根须活动id获取 相应的值
  431. for (let i in this.activeList) {
  432. if (this.activeList[i].id == val) {
  433. // 报名开始 报名结束 课程开始 课程结束 // 判断是否有线上,线下课 并同步状态
  434. this.leftForm.signUpStart = this.activeList[i].startTime;
  435. this.leftForm.signUpEnd = this.activeList[i].endTime;
  436. this.leftForm.courseStart = this.activeList[i].coursesStartTime;
  437. this.leftForm.courseEnd = this.activeList[i].coursesEndTime;
  438. // 获取活动种类并保存
  439. this.hotType = this.activeList[i].type;
  440. // 获取买赠必要参数
  441. this.attribute1 = this.activeList[i].attribute1;
  442. this.attribute2 = this.activeList[i].attribute2;
  443. // 存储课酬是否可配置
  444. this.salaryReadonlyFlag = this.activeList[i].salaryReadonlyFlag
  445. // hasOnline: false, hasOffline: false 还需要判断type类型 根据活动id获取
  446. if (this.activeList[i].salarySettlementJson) {
  447. let obj = JSON.parse(this.activeList[i].salarySettlementJson)
  448. if (obj && obj.onlineSalarySettlement) {
  449. // 有线上课
  450. this.hasOnline = true;
  451. this.onlineSalary = obj.onlineSalarySettlement.salarySettlementType;
  452. console.log('线上:' + this.onlineSalary)
  453. } else {
  454. this.hasOnline = false;
  455. }
  456. if (obj && obj.offlineSalarySettlement) {
  457. // 有线下课
  458. this.hasOffline = true;
  459. this.offlineSalary = obj.offlineSalarySettlement.salarySettlementType;
  460. console.log('线下:' + this.offlineSalary)
  461. } else {
  462. this.hasOffline = false;
  463. }
  464. }
  465. }
  466. }
  467. },
  468. // 点击确插入课表
  469. addWeek () {
  470. let courseType = this.maskForm.type;
  471. // let week = ;this.maskForm.week
  472. let startTime = this.maskForm.startTime;
  473. if (!courseType || !this.maskForm.week || !startTime) {
  474. this.$message({
  475. type: 'error',
  476. message: '请填写完成信息'
  477. })
  478. return;
  479. }
  480. // 拿到相应的值插入数组
  481. let endTime = this.MinutesTest(startTime, this.leftForm.classTime);
  482. let str;
  483. switch (courseType) {
  484. case 'ONLINE': {
  485. str = '线上课'
  486. break;
  487. }
  488. case 'OFFLINE': {
  489. str = '线下课'
  490. break;
  491. }
  492. }
  493. let flag = false;
  494. for (let i in this.lookList) {
  495. if (this.lookList[i].weekDay == this.maskForm.week) {
  496. flag = true;
  497. }
  498. }
  499. // true=> 说明有这一周 那么循环找到这一周 在判断时间
  500. // flase=> 说明没有这一周的时间 直接添加
  501. if (flag) {
  502. // 有相同的周日
  503. let arr = [];
  504. for (let i in this.lookList) {
  505. if (this.lookList[i].weekDay == this.maskForm.week) { // 找到这一天的所有元素
  506. // && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, startTime) && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, endTime)
  507. let isStartTime = this.timeIsrange(startTime, endTime, this.lookList[i].startTime);
  508. let isEndTime = this.timeIsrange(startTime, endTime, this.lookList[i].endTime);
  509. arr.push(!isEndTime && !isStartTime)
  510. }
  511. }
  512. let isAdd = true;
  513. for (let j = 0; j < arr.length; j++) {
  514. isAdd = isAdd && arr[j]
  515. }
  516. if (isAdd) {
  517. this.lookList.push({
  518. 'type': str,
  519. 'week': this.weekDay[this.maskForm.week],
  520. 'weekDay': this.maskForm.week,
  521. 'startTime': startTime,
  522. 'endTime': endTime,
  523. 'time': startTime + '-' + endTime,
  524. 'id': Date.now()
  525. })
  526. } else {
  527. this.$message({
  528. type: 'error',
  529. message: '该时间段已排课请重选时间'
  530. })
  531. }
  532. } else {
  533. this.lookList.push({
  534. 'type': str,
  535. 'week': this.weekDay[this.maskForm.week],
  536. 'weekDay': this.maskForm.week,
  537. 'startTime': startTime,
  538. 'endTime': endTime,
  539. 'time': startTime + '-' + endTime,
  540. 'id': Date.now()
  541. })
  542. }
  543. // let courseType = this.maskForm.type;
  544. // // let week = ;this.maskForm.week
  545. // let startTime = this.maskForm.startTime;
  546. this.maskForm.type = '';
  547. this.maskForm.week = '';
  548. this.maskForm.startTime = '';
  549. },
  550. // 分钟小时相加减
  551. MinutesTest (str, interval) {
  552. let houer = str.split(':')[0];
  553. let min = str.split(':')[1];
  554. let sdate1 = new Date(1900, 1, 1, houer, min);
  555. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  556. let H = sdate1.getHours();
  557. let M = sdate1.getMinutes();
  558. if (H < 10) H = '0' + H;
  559. if (M < 10) M = '0' + M;
  560. return H + ':' + M
  561. },
  562. // 判断时间是否在时间段内
  563. timeIsrange (beginTime, endTime, nowTime) {
  564. var strb = beginTime.split(":");
  565. if (strb.length != 2) {
  566. return false;
  567. }
  568. var stre = endTime.split(":");
  569. if (stre.length != 2) {
  570. return false;
  571. }
  572. var strn = nowTime.split(":");
  573. if (stre.length != 2) {
  574. return false;
  575. }
  576. var b = new Date();
  577. var e = new Date();
  578. var n = new Date();
  579. b.setHours(strb[0]);
  580. b.setMinutes(strb[1]);
  581. e.setHours(stre[0]);
  582. e.setMinutes(stre[1]);
  583. n.setHours(strn[0]);
  584. n.setMinutes(strn[1]);
  585. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  586. // 在时间范围内
  587. return true;
  588. } else {
  589. // 不在时间范围内
  590. return false;
  591. }
  592. },
  593. removeWeekCourse (id) {
  594. for (let i in this.lookList) {
  595. if (this.lookList[i].id == id) {
  596. this.lookList.splice(i, 1);
  597. }
  598. }
  599. },
  600. setTimeTable () {
  601. if (!this.maskForm.courseStart) {
  602. this.$message.error('请选择开课时间')
  603. return;
  604. }
  605. // 拿到线上课数与线下课数 以及
  606. let online = parseInt(this.centerForm.onlineCourseNum);
  607. let offline = parseInt(this.centerForm.offlineCourseNum);
  608. let giveNum = this.giveNum;
  609. let giveClassType = this.centerForm.radio;
  610. if (giveClassType == 'ONLINE') {
  611. // 线上
  612. online += giveNum;
  613. } else if (giveClassType == 'OFFLINE') {
  614. offline += giveNum;
  615. }
  616. let date = this.maskForm.courseStart;
  617. let date1 = this.maskForm.courseStart;
  618. let startWeekday = this.maskForm.courseStart.getDay();
  619. let onlineList = [];
  620. let offlineList = [];
  621. for (let i in this.lookList) {
  622. if (this.lookList[i].type == '线上课') {
  623. onlineList.push({ week: this.lookList[i].weekDay, date: this.lookList[i] })
  624. }
  625. if (this.lookList[i].type == '线下课') {
  626. offlineList.push({ week: this.lookList[i].weekDay, date: this.lookList[i] })
  627. }
  628. }
  629. // 获取要排课的总数 获取每周要排多少次
  630. while (online && online > 0) {
  631. // 排线上课g
  632. for (let i in onlineList) {
  633. let num;
  634. onlineList[i].week - date.getDay() >= 0 ? num = onlineList[i].week - date.getDay() : num = onlineList[i].week - date.getDay() + 7// +差值的天数://差值的天数+7
  635. // console.log(num);
  636. let dataStr = this.getThinkDate(date, num);
  637. this.timeTable.push({
  638. 'classDate': dataStr + ' 00:00:00',
  639. 'actualTeacherId': this.leftForm.teacher,
  640. 'startClassTime': onlineList[i].date.startTime,
  641. "endClassTime": onlineList[i].date.endTime,
  642. "teachMode": 'ONLINE'
  643. })
  644. online--;
  645. if (online == 0) break
  646. }
  647. // 加一周
  648. date.setDate(date.getDate() + 7);
  649. }
  650. while (offline && offline > 0) {
  651. // 排线下课
  652. for (let i in offlineList) {
  653. let num;
  654. offlineList[i].week - date1.getDay() >= 0 ? num = offlineList[i].week - date1.getDay() : num = offlineList[i].week - date1.getDay() + 7// +差值的天数://差值的天数+7
  655. let dataStr = this.getThinkDate(date1, num);
  656. console.log(dataStr);
  657. this.timeTable.push({
  658. 'classDate': dataStr + ' 00:00:00',
  659. 'actualTeacherId': this.leftForm.teacher,
  660. 'startClassTime': offlineList[i].date.startTime,
  661. "endClassTime": offlineList[i].date.endTime,
  662. "teachMode": 'OFFNLINE'
  663. })
  664. offline--;
  665. if (offline == 0) break
  666. }
  667. // 加一周
  668. date1.setDate(date1.getDate() + 7);
  669. }
  670. this.dialogFormVisible = false;
  671. },
  672. getThinkDate (date, num) {
  673. let Stamp = date;
  674. Stamp.setDate(date.getDate() + num) // 获取当前月数的第几天
  675. // console.log(date.getMonth() + 1)
  676. // console.log(Stamp.getMonth() + 1)
  677. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  678. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  679. var mvar = '';
  680. if (month < 10) {
  681. mvar = '0' + month;
  682. } else {
  683. mvar = month + '';
  684. }
  685. var day = Stamp.getDate();
  686. var dvar = '';
  687. if (day < 10) {
  688. dvar = '0' + day;
  689. } else {
  690. dvar = day + '';
  691. }
  692. // console.log(year + "-" + mvar + '-' + dvar);
  693. return year + "-" + mvar + '-' + dvar;
  694. },
  695. // 计算课酬
  696. computational () {
  697. let userId = this.leftForm.teacher;
  698. let giveTeachMode = this.centerForm.radio;
  699. let vipGroupCategoryId = this.leftForm.courseType;
  700. let vipGroupActivityId = this.leftForm.activeType;
  701. let onlineClassesUnitPrice = this.rightForm.onlinePrice;
  702. let offlineClassesUnitPrice = this.rightForm.offlinePrice;
  703. let onlineClassesNum = this.centerForm.onlineCourseNum;
  704. let offlineClassesNum = this.centerForm.offlineCourseNum;
  705. if (this.hotType == 'GIVE_CLASS') {
  706. if (this.centerForm.radio == 'ONLINE') {
  707. onlineClassesNum = parseInt(onlineClassesNum) + parseInt(this.giveNum)
  708. } else if (this.centerForm.radio == 'OFFLINE') {
  709. offlineClassesNum = parseInt(offlineClassesNum) + parseInt(this.giveNum)
  710. }
  711. }
  712. getVipGroupCostCount({ vipGroupActivityId, onlineClassesUnitPrice, vipGroupCategoryId, offlineClassesUnitPrice, onlineClassesNum, offlineClassesNum, userId, giveTeachMode }).then(res => {
  713. if (res.code == 200) {
  714. this.rightForm.onlineCourse = res.data.onlineTeacherSalary;
  715. this.rightForm.offlineCourse = res.data.offlineTeacherSalary;
  716. this.rightForm.allPrice = res.data.totalPrice;
  717. }
  718. })
  719. },
  720. submitInfo () {
  721. let online = parseInt(this.centerForm.onlineCourseNum);
  722. let offline = parseInt(this.centerForm.offlineCourseNum);
  723. let giveNum = this.giveNum;
  724. let giveClassType = this.centerForm.radio;
  725. if (giveClassType == 'ONLINE') {
  726. // 线上
  727. online += giveNum;
  728. } else if (giveClassType == 'OFFLINE') {
  729. offline += giveNum;
  730. }
  731. let obj = {};
  732. obj.courseSchedules = this.timeTable;
  733. /**
  734. *
  735. * teacher: '',
  736. subject: '',
  737. courseType: '',
  738. activeType: '',
  739. classNum: '',
  740. classTime: '',
  741. signUpStart: '',
  742. signUpEnd: '',
  743. courseStart: '',
  744. courseEnd: ''
  745. */
  746. obj.vipGroupApplyBaseInfo = {
  747. coursesExpireDate: this.leftForm.courseEnd,
  748. name: this.leftForm.name,
  749. offlineClassesNum: offline,
  750. onlineClassesNum: online,
  751. offlineClassesUnitPrice: this.rightForm.offlinePrice,
  752. onlineClassesUnitPrice: this.rightForm.onlinePrice,
  753. paymentExpireDate: this.leftForm.signUpEnd,
  754. registrationStartTime: this.leftForm.signUpStart,
  755. singleClassMinutes: this.leftForm.classTime,
  756. studentNum: this.leftForm.classNum,
  757. userId: this.leftForm.teacher,
  758. vipGroupActivityId: this.leftForm.activeType,
  759. vipGroupCategoryId: this.leftForm.courseType,
  760. onlineTeacherSalary: this.rightForm.onlineCourse,
  761. offlineTeacherSalary: this.rightForm.offlineCourse,
  762. giveTeachMode: this.centerForm.radio,
  763. subjectIdList: this.leftForm.subject,
  764. }
  765. createVip(obj).then(res => { })
  766. }
  767. },
  768. }
  769. </script>
  770. <style lang="scss" scoped>
  771. .m-core {
  772. margin-top: 30px;
  773. display: flex;
  774. flex-direction: row;
  775. justify-content: space-around;
  776. .el-input {
  777. width: 180px;
  778. }
  779. h4 {
  780. font-size: 16px;
  781. background-color: #ccc;
  782. color: #fff;
  783. text-align: center;
  784. width: 100%;
  785. height: 40px;
  786. line-height: 40px;
  787. margin-bottom: 20px;
  788. }
  789. .vipLeft {
  790. width: 400px;
  791. // h4 {
  792. // font-size: 16px;
  793. // background-color: #ccc;
  794. // color: #fff;
  795. // text-align: center;
  796. // width: 100%;
  797. // height: 40px;
  798. // line-height: 40px;
  799. // margin-bottom: 20px;
  800. // }
  801. }
  802. .center {
  803. width: 400px;
  804. }
  805. .right {
  806. width: 400px;
  807. }
  808. }
  809. .planList {
  810. padding: 0 25px;
  811. .planTop {
  812. height: 40px;
  813. line-height: 40px;
  814. display: flex;
  815. flex-direction: row;
  816. justify-content: space-between;
  817. border-bottom: 1px solid #ccc;
  818. margin-top: 20px;
  819. > p {
  820. font-size: 14px;
  821. }
  822. }
  823. .planCore {
  824. .row {
  825. width: 100%;
  826. display: flex;
  827. flex-direction: row;
  828. justify-content: space-between;
  829. flex-wrap: nowrap;
  830. height: 40px;
  831. line-height: 40px;
  832. font-size: 14px;
  833. }
  834. }
  835. }
  836. .okBtn {
  837. width: 120px;
  838. height: 40px;
  839. line-height: 40px;
  840. text-align: center;
  841. color: #fff;
  842. border-radius: 4px;
  843. margin-right: 20px;
  844. cursor: pointer;
  845. background-color: #f97215;
  846. float: right;
  847. }
  848. </style>