index.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281
  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.realName"
  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.rightForm.onlinePrice = '';
  639. this.rightForm.offlinePrice = '';
  640. this.lookList = []
  641. this.timeTable = []
  642. this.attribute1 = '';
  643. this.attribute2 = '';
  644. this.giveNum = 0;
  645. this.isGiveClass = false;
  646. // 根须活动id获取 相应的值
  647. for (let i in this.activeList) {
  648. if (this.activeList[i].id == val) {
  649. // 如果是买赠就必须选择赠课类型
  650. // 报名开始 报名结束 课程开始 课程结束 // 判断是否有线上,线下课 并同步状态
  651. // this.leftForm.signUpStart = this.activeList[i].startTime;
  652. // this.leftForm.signUpEnd = this.activeList[i].endTime;
  653. this.leftForm.courseStart = this.activeList[i].coursesStartTime;
  654. this.leftForm.courseEnd = this.activeList[i].coursesEndTime;
  655. // 获取活动种类并保存
  656. this.hotType = this.activeList[i].type;
  657. // 获取买赠必要参数
  658. this.attribute1 = this.activeList[i].attribute1;
  659. this.attribute2 = this.activeList[i].attribute2;
  660. // 存储课酬是否可配置
  661. this.salaryReadonlyFlag = this.activeList[i].salaryReadonlyFlag
  662. this.paymentReadonlyFlag = this.activeList[i].paymentReadonlyFlag
  663. // hasOnline: false, hasOffline: false 还需要判断type类型 根据活动id获取
  664. if (this.activeList[i].salarySettlementJson) {
  665. let obj = JSON.parse(this.activeList[i].salarySettlementJson)
  666. if (obj && obj.onlineSalarySettlement) {
  667. // 有线上课
  668. this.hasOnline = true;
  669. this.onlineSalary = obj.onlineSalarySettlement.salarySettlementType;
  670. // console.log('线上:' + this.onlineSalary)
  671. } else {
  672. this.hasOnline = false;
  673. }
  674. if (obj && obj.offlineSalarySettlement) {
  675. // 有线下课
  676. this.hasOffline = true;
  677. this.offlineSalary = obj.offlineSalarySettlement.salarySettlementType;
  678. // console.log('线下:' + this.offlineSalary)
  679. } else {
  680. this.hasOffline = false;
  681. }
  682. }
  683. }
  684. }
  685. },
  686. // 点击确插入课表
  687. addWeek () {
  688. let courseType = this.maskForm.type;
  689. // let week = ;this.maskForm.week
  690. let startTime = this.maskForm.startTime;
  691. if (!courseType || !this.maskForm.week || !startTime) {
  692. this.$message.error('请填写完成信息')
  693. return;
  694. }
  695. // 拿到相应的值插入数组
  696. let endTime = this.MinutesTest(startTime, this.leftForm.classTime);
  697. let str;
  698. switch (courseType) {
  699. case 'ONLINE': {
  700. str = '线上课'
  701. break;
  702. }
  703. case 'OFFLINE': {
  704. str = '线下课'
  705. break;
  706. }
  707. }
  708. let flag = false;
  709. for (let i in this.lookList) {
  710. if (this.lookList[i].weekDay == this.maskForm.week) {
  711. flag = true;
  712. }
  713. }
  714. // true=> 说明有这一周 那么循环找到这一周 在判断时间
  715. // flase=> 说明没有这一周的时间 直接添加
  716. if (flag) {
  717. // 有相同的周日
  718. let arr = [];
  719. for (let i in this.lookList) {
  720. if (this.lookList[i].weekDay == this.maskForm.week) { // 找到这一天的所有元素
  721. // && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, startTime) && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, endTime)
  722. let isStartTime = this.timeIsrange(startTime, endTime, this.lookList[i].startTime);
  723. let isEndTime = this.timeIsrange(startTime, endTime, this.lookList[i].endTime);
  724. arr.push(!isEndTime && !isStartTime)
  725. }
  726. }
  727. let isAdd = true;
  728. for (let j = 0; j < arr.length; j++) {
  729. isAdd = isAdd && arr[j]
  730. }
  731. if (isAdd) {
  732. this.lookList.push({
  733. 'type': str,
  734. 'week': this.weekDay[this.maskForm.week],
  735. 'weekDay': this.maskForm.week,
  736. 'startTime': startTime,
  737. 'endTime': endTime,
  738. 'time': startTime + '-' + endTime,
  739. 'id': Date.now()
  740. })
  741. } else {
  742. this.$message.error('该时间段已排课请重选时间')
  743. return
  744. }
  745. } else {
  746. this.lookList.push({
  747. 'type': str,
  748. 'week': this.weekDay[this.maskForm.week],
  749. 'weekDay': this.maskForm.week,
  750. 'startTime': startTime,
  751. 'endTime': endTime,
  752. 'time': startTime + '-' + endTime,
  753. 'id': Date.now()
  754. })
  755. }
  756. // console.log(this.lookList)
  757. // let courseType = this.maskForm.type;
  758. // // let week = ;this.maskForm.week
  759. // let startTime = this.maskForm.startTime;
  760. this.maskForm.type = '';
  761. this.maskForm.week = '';
  762. this.maskForm.startTime = '';
  763. },
  764. // 分钟小时相加减
  765. MinutesTest (str, interval) {
  766. let houer = str.split(':')[0];
  767. let min = str.split(':')[1];
  768. let sdate1 = new Date(1900, 1, 1, houer, min);
  769. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  770. let H = sdate1.getHours();
  771. let M = sdate1.getMinutes();
  772. if (H < 10) H = '0' + H;
  773. if (M < 10) M = '0' + M;
  774. return H + ':' + M
  775. },
  776. // 判断时间是否在时间段内
  777. timeIsrange (beginTime, endTime, nowTime) {
  778. var strb = beginTime.split(":");
  779. if (strb.length != 2) {
  780. return false;
  781. }
  782. var stre = endTime.split(":");
  783. if (stre.length != 2) {
  784. return false;
  785. }
  786. var strn = nowTime.split(":");
  787. if (stre.length != 2) {
  788. return false;
  789. }
  790. var b = new Date();
  791. var e = new Date();
  792. var n = new Date();
  793. b.setHours(strb[0]);
  794. b.setMinutes(strb[1]);
  795. e.setHours(stre[0]);
  796. e.setMinutes(stre[1]);
  797. n.setHours(strn[0]);
  798. n.setMinutes(strn[1]);
  799. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  800. // 在时间范围内
  801. return true;
  802. } else {
  803. // 不在时间范围内
  804. return false;
  805. }
  806. },
  807. removeWeekCourse (id) {
  808. for (let i in this.lookList) {
  809. if (this.lookList[i].id == id) {
  810. this.lookList.splice(i, 1);
  811. }
  812. }
  813. },
  814. setTimeTable () {
  815. // 拿到线上课数与线下课数 以及
  816. this.timeTable = [];
  817. let online = parseInt(this.centerForm.onlineCourseNum) || 0;
  818. let offline = parseInt(this.centerForm.offlineCourseNum) || 0;
  819. let giveNum = this.giveNum;
  820. let giveClassType = this.centerForm.radio;
  821. if (giveClassType == 'ONLINE') {
  822. // 线上
  823. online += giveNum;
  824. } else if (giveClassType == 'OFFLINE') {
  825. offline += giveNum;
  826. }
  827. // 这里判断是否选择了排课开始时间
  828. if (online && !this.maskForm.courseStartOnline) {
  829. this.$message.error('选择了线上课 但没有线上课开始时间')
  830. return
  831. }
  832. if (offline && !this.maskForm.courseStartOffline) {
  833. this.$message.error('选择了线下课 但没有线下课开始时间')
  834. return
  835. }
  836. let date, date1;
  837. if (this.maskForm.courseStartOnline) {
  838. date = new Date(this.maskForm.courseStartOnline.getTime());
  839. }
  840. if (this.maskForm.courseStartOffline) {
  841. date1 = new Date(this.maskForm.courseStartOffline.getTime());
  842. }
  843. // let startWeekday = this.maskForm.courseStart.getDay();
  844. let onlineList = []; // 装线上课的数组
  845. let offlineList = []; //装线下课的数组
  846. if (this.lookList.length <= 0) {
  847. this.$message.error('请先排课后再点击确认按钮');
  848. return
  849. }
  850. for (let i in this.lookList) {
  851. if (this.lookList[i].type == '线上课') {
  852. onlineList.push({ week: this.lookList[i].weekDay, date: this.lookList[i] })
  853. }
  854. if (this.lookList[i].type == '线下课') {
  855. offlineList.push({ week: this.lookList[i].weekDay, date: this.lookList[i] })
  856. }
  857. }
  858. // console.log(onlineList + '----------------------------------------------------------------------------------');
  859. // console.log(offlineList);
  860. if (online > 0 && onlineList.length <= 0) {
  861. this.$message.error('选择了线上课但未排线上课');
  862. this.timeTable = [];
  863. return;
  864. }
  865. if (offline > 0 && offlineList.length <= 0) {
  866. this.$message.error('选择了线下课但未排线下课')
  867. this.timeTable = [];
  868. return;
  869. }
  870. // 获取要排课的总数 获取每周要排多少次
  871. while (online && online > 0) {
  872. // 排线上课g
  873. for (let i in onlineList) {
  874. let num;
  875. onlineList[i].week - date.getDay() >= 0 ? num = onlineList[i].week - date.getDay() : num = onlineList[i].week - date.getDay() + 7// +差值的天数://差值的天数+7
  876. // console.log(num);
  877. let dataStr = this.getThinkDate(date, num);
  878. this.timeTable.push({
  879. 'classDate': dataStr + ' 00:00:00',
  880. 'actualTeacherId': this.leftForm.teacher,
  881. 'startClassTimeStr': onlineList[i].date.startTime,
  882. "endClassTimeStr": onlineList[i].date.endTime,
  883. "teachMode": 'ONLINE'
  884. })
  885. online--;
  886. if (online == 0) break
  887. }
  888. if (onlineList.length == 1 || this.isAllEqual(onlineList)) {
  889. date.setDate(date.getDate() + 7);
  890. }
  891. // 加一周
  892. }
  893. // console.log(date1)
  894. while (offline && offline > 0) {
  895. // 排线下课
  896. for (let i in offlineList) {
  897. let num;
  898. offlineList[i].week - date1.getDay() >= 0 ? num = offlineList[i].week - date1.getDay() : num = offlineList[i].week - date1.getDay() + 7// +差值的天数://差值的天数+7
  899. let dataStr = this.getThinkDate(date1, num);
  900. this.timeTable.push({
  901. 'classDate': dataStr + ' 00:00:00',
  902. 'actualTeacherId': this.leftForm.teacher,
  903. 'startClassTimeStr': offlineList[i].date.startTime,
  904. "endClassTimeStr": offlineList[i].date.endTime,
  905. "teachMode": 'OFFLINE'
  906. })
  907. offline--;
  908. if (offline == 0) break
  909. }
  910. // 加一周
  911. if (offlineList.length == 1 || this.isAllEqual(offlineList)) {
  912. date1.setDate(date1.getDate() + 7);
  913. }
  914. }
  915. // console.log(this.timeTable);
  916. this.dialogFormVisible = false;
  917. },
  918. getThinkDate (date, num) {
  919. let Stamp = date;
  920. Stamp.setDate(date.getDate() + num) // 获取当前月数的第几天
  921. // console.log(date.getMonth() + 1)
  922. // console.log(Stamp.getMonth() + 1)
  923. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  924. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  925. var mvar = '';
  926. if (month < 10) {
  927. mvar = '0' + month;
  928. } else {
  929. mvar = month + '';
  930. }
  931. var day = Stamp.getDate();
  932. var dvar = '';
  933. if (day < 10) {
  934. dvar = '0' + day;
  935. } else {
  936. dvar = day + '';
  937. }
  938. // console.log(year + "-" + mvar + '-' + dvar);
  939. return year + "-" + mvar + '-' + dvar;
  940. },
  941. // 计算课酬
  942. computational () {
  943. this.computationalBtn = true;
  944. let userId = this.leftForm.teacher || null;
  945. let giveTeachMode = this.centerForm.radio || null;
  946. let vipGroupCategoryId = this.leftForm.courseType || null;
  947. let vipGroupActivityId = this.leftForm.activeType || null;
  948. let onlineClassesUnitPrice = this.rightForm.onlinePrice || null;
  949. let offlineClassesUnitPrice = this.rightForm.offlinePrice || null;
  950. let onlineClassesNum = this.centerForm.onlineCourseNum || 0;
  951. let offlineClassesNum = this.centerForm.offlineCourseNum || 0;
  952. let singleClassMinutes = this.leftForm.classTime
  953. if (this.hotType == 'GIVE_CLASS') {
  954. if (this.centerForm.radio == 'ONLINE') {
  955. onlineClassesNum = parseInt(onlineClassesNum) + parseInt(this.giveNum)
  956. } else if (this.centerForm.radio == 'OFFLINE') {
  957. offlineClassesNum = parseInt(offlineClassesNum) + parseInt(this.giveNum)
  958. }
  959. }
  960. let onlineTeacherSalary = this.rightForm.onlineCourse || null;
  961. let offlineTeacherSalary = this.rightForm.offlineCourse || null;
  962. getVipGroupCostCount({ vipGroupActivityId, onlineClassesUnitPrice, onlineTeacherSalary, offlineTeacherSalary, vipGroupCategoryId, offlineClassesUnitPrice, onlineClassesNum, offlineClassesNum, userId, giveTeachMode, singleClassMinutes }).then(res => {
  963. if (res.code == 200) {
  964. this.rightForm.onlineCourse = res.data.onlineTeacherSalary;
  965. this.rightForm.offlineCourse = res.data.offlineTeacherSalary;
  966. this.rightForm.allPrice = res.data.totalPrice;
  967. }
  968. })
  969. },
  970. isAllEqual (array) {
  971. if (array.length > 0) {
  972. return !array.some((val, index) => {
  973. return val.week != array[0].week
  974. })
  975. } else {
  976. return true
  977. }
  978. },
  979. submitInfo () {
  980. if (!this.computationalBtn) {
  981. this.$message.error('请点击计算按钮计算课酬')
  982. return
  983. }
  984. // 判断线上课课酬和线下课课酬
  985. let online = parseInt(this.centerForm.onlineCourseNum);
  986. let offline = parseInt(this.centerForm.offlineCourseNum);
  987. let giveNum = this.giveNum;
  988. let giveClassType = this.centerForm.radio;
  989. if (giveClassType == 'ONLINE') {
  990. // 线上
  991. online += giveNum;
  992. } else if (giveClassType == 'OFFLINE') {
  993. offline += giveNum;
  994. }
  995. let obj = {};
  996. obj.courseSchedules = this.timeTable;
  997. /**
  998. *
  999. * teacher: '',
  1000. subject: '',
  1001. courseType: '',
  1002. activeType: '',
  1003. classNum: '',
  1004. classTime: '',
  1005. signUpStart: '',
  1006. signUpEnd: '',
  1007. courseStart: '',
  1008. courseEnd: ''
  1009. */
  1010. let studentIdList = this.rightForm.students.join(',') || null
  1011. obj.vipGroupApplyBaseInfo = {
  1012. studentIdList,
  1013. coursesExpireDate: this.leftForm.courseEnd,
  1014. teacherSchoolId: this.leftForm.section,
  1015. name: this.leftForm.name,
  1016. offlineClassesNum: offline || 0,
  1017. onlineClassesNum: online || 0,
  1018. offlineClassesUnitPrice: this.rightForm.offlinePrice || 0,
  1019. onlineClassesUnitPrice: this.rightForm.onlinePrice || 0,
  1020. paymentExpireDate: this.leftForm.signUpEnd,
  1021. registrationStartTime: this.leftForm.signUpStart,
  1022. singleClassMinutes: this.leftForm.classTime,
  1023. studentNum: this.leftForm.classNum,
  1024. userId: this.leftForm.teacher,
  1025. vipGroupActivityId: this.leftForm.activeType,
  1026. vipGroupCategoryId: this.leftForm.courseType,
  1027. onlineTeacherSalary: this.rightForm.onlineCourse || 0,
  1028. offlineTeacherSalary: this.rightForm.offlineCourse || 0,
  1029. giveTeachMode: this.centerForm.radio,
  1030. subjectIdList: this.leftForm.subject,
  1031. }
  1032. // 调接前判断是新增还是修改
  1033. if (!this.id) {
  1034. // 新增
  1035. createVip(obj).then(res => {
  1036. if (res.code == 200) {
  1037. this.$message.success('恭喜您创建成功');
  1038. this.$router.push({ path: '/business/vipList', query: { rules: this.rules, searchForm: this.searchForm } })
  1039. }
  1040. })
  1041. } else {
  1042. // 修改
  1043. obj.vipGroupApplyBaseInfo.id = this.id;
  1044. updateVipBaseInfo(obj.vipGroupApplyBaseInfo).then(res => {
  1045. })
  1046. }
  1047. },
  1048. setSection (val) {
  1049. this.leftForm.section = '';
  1050. this.rightForm.offlineCourse = '';
  1051. this.rightForm.onlineCourse = '';
  1052. this.leftForm.courseType = ''
  1053. getTeachSchool({ userId: val }).then(res => {
  1054. if (res.code == 200) {
  1055. this.scetionList = res.data;
  1056. }
  1057. })
  1058. for (let i in this.teacherList) {
  1059. if (this.teacherList[i].id == val) {
  1060. // 根据分部id去获取课程形式
  1061. vipGroupCategory({ organId: this.teacherList[i].organId }).then(res => {
  1062. if (res.code == 200) {
  1063. this.courseTypeList = res.data;
  1064. }
  1065. })
  1066. }
  1067. }
  1068. },
  1069. onCancel () {
  1070. this.$router.push({ path: '/business/vipList', query: { rules: this.rules, searchForm: this.searchForm } })
  1071. },
  1072. setCourse () {
  1073. //
  1074. if (this.hotType == 'GIVE_CLASS' && this.isGiveClass && !this.centerForm.radio) {
  1075. this.$message.error('您还未选择赠课类型')
  1076. return
  1077. }
  1078. this.$refs['leftForm'].validate(vali => {
  1079. if (vali) {
  1080. this.dialogFormVisible = true
  1081. }
  1082. })
  1083. },
  1084. setVipInfo (data) {
  1085. this.leftForm.name = data.name;
  1086. this.leftForm.subject = parseInt(data.subjectIdList)
  1087. // 激活声部下的所有老师
  1088. this.changeSubject(parseInt(data.subjectIdList));
  1089. // 设置老师
  1090. this.leftForm.teacher = data.userId;
  1091. this.setSection(data.userId)
  1092. // 课程形式
  1093. this.leftForm.courseType = data.vipGroupCategoryId;
  1094. // 获取课程形式下的活动方案
  1095. this.changeType(this.leftForm.courseType)
  1096. // 根据课程形式获取活动方案
  1097. this.leftForm.activeType = data.vipGroupActivityId;
  1098. setTimeout(res => {
  1099. this.chioseActive(data.vipGroupActivityId)
  1100. }, 1000)
  1101. this.leftForm.section = data.teacherSchoolId;
  1102. this.leftForm.classNum = data.studentNum;
  1103. this.leftForm.classTime = data.singleClassMinutes;
  1104. this.leftForm.signUpStart = data.registrationStartTime;
  1105. this.leftForm.signUpEnd = data.paymentExpireDate;
  1106. this.centerForm.onlineCourseNum = data.onlineClassesNum;
  1107. this.centerForm.offlineCourseNum = data.offlineCourseNum;
  1108. /**
  1109. * rightForm: {
  1110. onlineCourse: '',
  1111. offlineCourse: '',
  1112. onlinePrice: '',
  1113. offlinePrice: '',
  1114. allPrice: ''
  1115. },
  1116. *
  1117. */
  1118. this.rightForm.onlineCourse = data.onlineTeacherSalary
  1119. this.rightForm.onlinePrice = data.onlineClassesUnitPrice;
  1120. this.rightForm.offlineCourse = data.offlineTeacherSalary
  1121. this.rightForm.offlinePrice = data.offlineClassesUnitPrice;
  1122. this.rightForm.allPrice = data.totalPrice;
  1123. //subjectIdList
  1124. },
  1125. remoteMethod (query) {
  1126. if (query !== '') {
  1127. // this.loading = true;
  1128. // 发请求搜索
  1129. queryStudentList({ rows: 100, search: query }).then(res => {
  1130. if (res.code == 200) {
  1131. // this.loading = false;
  1132. this.studentList = this.studentList.concat(res.data.rows);
  1133. // this.studentList = res.data.rows;
  1134. this.unique(this.studentList, 'userId')
  1135. // console.log(this.studentList)
  1136. }
  1137. })
  1138. }
  1139. },
  1140. unique (arr, u_key) {
  1141. let obj = {}
  1142. arr.reduce((prev, next) => {
  1143. obj[next[u_key] + typeof next[u_key]] ? '' :
  1144. obj[next[u_key] + typeof next[u_key]] = true && prev.push(next)
  1145. return prev
  1146. }, [])
  1147. }
  1148. },
  1149. // watch: {
  1150. // rightForm: {
  1151. // handler (newName, oldName) {
  1152. // this.computationalBtn = false
  1153. // },
  1154. // deep: true
  1155. // }
  1156. // }
  1157. }
  1158. </script>
  1159. <style lang="scss" scoped>
  1160. .m-core {
  1161. margin-top: 30px;
  1162. display: flex;
  1163. flex-direction: row;
  1164. justify-content: space-around;
  1165. .el-input {
  1166. width: 180px;
  1167. }
  1168. h4 {
  1169. font-size: 16px;
  1170. background-color: #ccc;
  1171. color: #fff;
  1172. text-align: center;
  1173. width: 100%;
  1174. height: 40px;
  1175. line-height: 40px;
  1176. margin-bottom: 20px;
  1177. }
  1178. .vipLeft {
  1179. width: 400px;
  1180. // h4 {
  1181. // font-size: 16px;
  1182. // background-color: #ccc;
  1183. // color: #fff;
  1184. // text-align: center;
  1185. // width: 100%;
  1186. // height: 40px;
  1187. // line-height: 40px;
  1188. // margin-bottom: 20px;
  1189. // }
  1190. }
  1191. .center {
  1192. width: 400px;
  1193. }
  1194. .right {
  1195. width: 400px;
  1196. }
  1197. }
  1198. .planList {
  1199. padding: 0 25px;
  1200. .planTop {
  1201. height: 40px;
  1202. line-height: 40px;
  1203. display: flex;
  1204. flex-direction: row;
  1205. justify-content: space-between;
  1206. border-bottom: 1px solid #ccc;
  1207. margin-top: 20px;
  1208. > p {
  1209. font-size: 14px;
  1210. }
  1211. }
  1212. .planCore {
  1213. .row {
  1214. width: 100%;
  1215. display: flex;
  1216. flex-direction: row;
  1217. justify-content: space-between;
  1218. flex-wrap: nowrap;
  1219. height: 40px;
  1220. line-height: 40px;
  1221. font-size: 14px;
  1222. text-align: center;
  1223. div {
  1224. width: 87px;
  1225. }
  1226. // div {
  1227. // &:nth-child(1) {
  1228. // text-align: left;
  1229. // }
  1230. // }
  1231. }
  1232. }
  1233. }
  1234. .okBtn {
  1235. width: 120px;
  1236. height: 40px;
  1237. line-height: 40px;
  1238. text-align: center;
  1239. color: #fff;
  1240. border-radius: 4px;
  1241. margin-right: 20px;
  1242. cursor: pointer;
  1243. background-color: #f97215;
  1244. float: right;
  1245. }
  1246. </style>