index.vue 43 KB

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