index.vue 38 KB

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