theoryCourse.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. <template>
  2. <div class="vipCourse">
  3. <div>
  4. <!-- <van-divider content-position="center"
  5. :style="{ padding: '0 16px', margin: '.05rem 0' }">课程信息</van-divider> -->
  6. <div class="vip-title">课程信息</div>
  7. <van-field
  8. label="课程声部"
  9. input-align="right"
  10. placeholder="请选择课程声部"
  11. v-model="formName.subjectListName"
  12. @click="onSelect('subjectList')"
  13. readonly
  14. is-link
  15. />
  16. <van-field
  17. label="课程形式"
  18. v-model="formName.vipGroupCategoryName"
  19. input-align="right"
  20. placeholder="请选择课程形式"
  21. @click="onSelect('vipGroupCategory')"
  22. readonly
  23. is-link
  24. />
  25. <van-cell
  26. class="courseStudent"
  27. title="上课学员"
  28. @click="onCheckStudent"
  29. readonly
  30. input-align="right"
  31. :is-link="checkboxSelectDataList.length > 0 ? false : true"
  32. :value="checkboxSelectDataList.length > 0 ? '重新选择' : '请选择上课学员'"
  33. :value-class="checkboxSelectDataList.length > 0 ? 'studentColor' : null"
  34. />
  35. <div
  36. v-if="checkboxSelectDataList.length > 0"
  37. style="
  38. text-align: center;
  39. line-height: 1.8;
  40. padding: 0.05rem 0;
  41. background: #fafbff;
  42. "
  43. >
  44. <p
  45. style="color: #323233"
  46. v-for="(item, index) in checkboxSelectDataList"
  47. :key="index"
  48. >
  49. {{ item.username }} - {{ item.parentsPhone }}
  50. </p>
  51. </div>
  52. <!-- <van-divider content-position="center" :style="{ padding: '0 16px', margin: '.05rem 0' }">课时组成</van-divider> -->
  53. <div class="vip-title">课时组成</div>
  54. <van-field
  55. label="课时总数"
  56. input-align="right"
  57. placeholder="输选择课时总数"
  58. readonly value="10节" />
  59. <van-field
  60. label="课程时长"
  61. v-model="form.singleClassMinutes"
  62. input-align="right"
  63. placeholder="请选择课程时长"
  64. @click="onClickSingleClass"
  65. readonly
  66. is-link
  67. />
  68. <van-field
  69. @click="dataForm.status = true"
  70. v-model="form.courseStart"
  71. label="排课开始时间"
  72. :readonly="true"
  73. input-align="right"
  74. is-link
  75. placeholder="请选择"
  76. />
  77. <van-cell
  78. title-class="title-time"
  79. v-for="(item, index) in scheduleList"
  80. :key="index"
  81. >
  82. <template slot="title">
  83. <span class="online">{{ item.type }}</span>
  84. <span class="week">{{ item.weekStr }}</span>
  85. <span class="timer">{{ item.startTime + "-" + item.endTime }}</span>
  86. </template>
  87. <template slot="default">
  88. <van-button type="warning"
  89. @click="onScheduleRemove(item)"
  90. round size="small" plain
  91. >删除</van-button>
  92. </template>
  93. </van-cell>
  94. <div class="add-plan van-cell" @click="onCourseSchedule">
  95. <van-icon name="add-o" />课时安排
  96. </div>
  97. <van-field
  98. label="排课列表"
  99. v-if="scheduleList.length > 0"
  100. readonly
  101. input-align="right"
  102. @click="onShowTimeTable"
  103. is-link
  104. />
  105. <div style="margin: 16px;">
  106. <van-button round block type="info" @click="onSubmit">确认排课</van-button>
  107. </div>
  108. </div>
  109. <!-- 每课时长 -->
  110. <van-action-sheet
  111. v-model="statusList.classTimerStatus"
  112. :actions="loadData.classTimer"
  113. cancel-text="取消"
  114. @cancel="statusList.classTimerStatus = false"
  115. @select="onClassTimerSelect"
  116. />
  117. <!-- 课时安排 -->
  118. <van-popup v-model="dataForm.status" position="bottom">
  119. <van-datetime-picker
  120. v-model="dataForm.currentDate"
  121. type="date"
  122. :min-date="dataForm.minDate"
  123. :formatter="formatter"
  124. @cancel="dataForm.status = false"
  125. @confirm="onCurrentConfirm"
  126. />
  127. </van-popup>
  128. <!-- 课程信息所用 :close-on-click-overlay="false" -->
  129. <van-popup v-model="sheetForm.sheetStatus" position="bottom">
  130. <van-picker
  131. :loading="sheetForm.loading"
  132. :default-index="sheetForm.index"
  133. :columns="sheetForm.columns"
  134. show-toolbar
  135. @cancel="sheetForm.sheetStatus = false"
  136. @confirm="onSheetConfirm"
  137. />
  138. </van-popup>
  139. <!-- 课时安排 -->
  140. <van-popup v-model="courseForm.teachingStatus" position="bottom">
  141. <van-picker
  142. :columns="courseForm.columns"
  143. show-toolbar
  144. @cancel="courseForm.teachingStatus = false"
  145. @confirm="onTeachinConfirm"
  146. />
  147. </van-popup>
  148. <!-- 选择上课学生 -->
  149. <van-popup
  150. v-model="statusList.studentStatus"
  151. :lock-scroll="true"
  152. position="bottom"
  153. :style="{ height: '180%' }"
  154. class="studentChiose"
  155. >
  156. <div v-if="statusList.studentStatus">
  157. <van-sticky>
  158. <van-search
  159. show-action
  160. shape="round"
  161. @search="onSearch"
  162. v-model="params.search"
  163. placeholder="请输入学生名或手机号"
  164. >
  165. <template #action>
  166. <div @click="onSearch">搜索</div>
  167. </template>
  168. </van-search>
  169. </van-sticky>
  170. <div class="paddingB80">
  171. <van-list
  172. v-model="loading"
  173. class="studentContainer"
  174. v-if="dataShow"
  175. key="data"
  176. :finished="finished"
  177. finished-text=""
  178. @load="getStudent"
  179. >
  180. <van-checkbox-group v-model="checkboxSelect">
  181. <van-cell-group>
  182. <van-cell
  183. v-for="(item, index) in dataList"
  184. :key="index"
  185. @click="onCheckboxSelect(item)"
  186. class="input-cell"
  187. :center="true"
  188. >
  189. <template slot="icon">
  190. <img class="logo" v-if="item.avatar" :src="item.avatar" alt="" />
  191. <img class="logo" v-else src="@/assets/images/icon_student.png" alt="" />
  192. </template>
  193. <template slot="title">
  194. {{ item.username }}
  195. </template>
  196. <template slot="label">
  197. <span>{{ desensitPhone(item.parentsPhone) }}</span>
  198. </template>
  199. <template slot="default">
  200. <van-checkbox :name="item.userId.toString()"></van-checkbox>
  201. </template>
  202. </van-cell>
  203. </van-cell-group>
  204. </van-checkbox-group>
  205. </van-list>
  206. <m-empty class="empty" msg="暂无学生" v-else key="data" />
  207. </div>
  208. <div class="button-group-popup">
  209. <span class="btn" @click="onPopupCancel">取消</span>
  210. <span class="btn primary" @click="onPopupSubmit">确定</span>
  211. </div>
  212. </div>
  213. </van-popup>
  214. <!-- 课表展示 -->
  215. <van-popup v-model="statusList.classTime" position="bottom">
  216. <van-row>
  217. <van-col span="12">上课类型</van-col>
  218. <van-col span="12">上课时间</van-col>
  219. </van-row>
  220. <div class="tableContainer">
  221. <van-row v-for="(item, index) in timeTable" :key="index">
  222. <van-col span="12">
  223. {{ item.teachMode == "ONLINE" ? "线上" : "线下" }}
  224. </van-col>
  225. <van-col span="12">
  226. {{ item.classDate }} {{ item.startClassTimeStr }}
  227. </van-col>
  228. </van-row>
  229. </div>
  230. </van-popup>
  231. </div>
  232. </template>
  233. <script>
  234. import dayjs from 'dayjs'
  235. import setLoading from "@/utils/loading";
  236. import { browser } from "@/common/common";
  237. import {
  238. findSubSubjects,
  239. vipGroupCategory,
  240. } from "@/api/teacher";
  241. import { getStudents, createActivityVipGroup } from "../api";
  242. import cleanDeep from 'clean-deep'
  243. import MEmpty from "@/components/MEmpty";
  244. let minutes = []; // 分钟数
  245. for (let i = 0; i < 60; i++) {
  246. let mi = i < 10 ? "0" + i : i;
  247. minutes.push(mi + "分");
  248. }
  249. export default {
  250. name: 'apply',
  251. components: {
  252. MEmpty,
  253. },
  254. data() {
  255. return {
  256. subjectId: null,
  257. selectTeacher: {
  258. status: false
  259. },
  260. dataForm: {
  261. // 时间下拉框
  262. status: false,
  263. minDate: new Date(),
  264. currentDate: new Date(),
  265. },
  266. statusList: {
  267. classTimerStatus: false,
  268. studentStatus: false, // 上课学生状态
  269. classTime: false,
  270. },
  271. form: {
  272. vipGroupCategoryId: null,
  273. courseStart: null,
  274. studentNum: null,
  275. onlineClassesUnitPrice: null,
  276. offlineClassesUnitPrice: null,
  277. singleClassMinutes: null,
  278. onlineClassesNum: 10,
  279. offlineClassesNum: 0,
  280. subjectIdList: null,
  281. vipGroupActivityId: null
  282. },
  283. formName: {
  284. vipGroupCategoryName: null,
  285. vipGroupCategoryIndex: 0,
  286. subjectListName: null,
  287. subjectListIndex: 0, // 声部名称
  288. },
  289. courseForm: {
  290. // 排课弹窗
  291. teachingStatus: false, // 课时安排状态
  292. columns: [
  293. {
  294. // 课程选项 , "线下"
  295. values: ["线上"],
  296. className: "type",
  297. },
  298. {
  299. values: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
  300. className: "week",
  301. },
  302. {
  303. values: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
  304. className: "hours",
  305. defaultIndex: 7,
  306. },
  307. {
  308. values: minutes,
  309. className: "minutes",
  310. }],
  311. },
  312. loadData: {
  313. // 下拉加载数据
  314. subjectList: [],
  315. vipGroupCategory: [], // 课程形式
  316. vipGroupCategorySelect: [], // 选中的课程形式JSON
  317. classTimer: [],
  318. },
  319. sheetForm: {
  320. // 上拉弹窗
  321. currentType: null, // 当前选择的类型
  322. sheetStatus: false,
  323. loading: true, // 加载数据
  324. index: 0, // 选中的索引值
  325. columns: [],
  326. },
  327. timeTable: [], // 生成的课表
  328. scheduleList: [],
  329. checkboxSelect: [],
  330. checkboxSelectIds: [],
  331. checkboxSelectList: [], //选中学生列表
  332. checkboxSelectDataList: [],
  333. loading: false,
  334. finished: false,
  335. params: {
  336. search: null,
  337. page: 1,
  338. rows: 20,
  339. },
  340. dataShow: true, // 是否有数据
  341. dataList: [],
  342. }
  343. },
  344. mounted() {
  345. },
  346. watch: {
  347. 'form.singleClassMinutes'() {
  348. this.scheduleList = []
  349. }
  350. },
  351. methods: {
  352. async onSubmit() {
  353. let form = this.form;
  354. if (!form.subjectIdList) {
  355. this.$toast("请选课程声部");
  356. return false;
  357. }
  358. if (!form.vipGroupCategoryId) {
  359. this.$toast("请选择课程形式");
  360. return false;
  361. }
  362. if (this.checkboxSelectIds.length <= 0) {
  363. this.$toast("请选择上课学生");
  364. return;
  365. }
  366. if (this.scheduleList.length <= 0) {
  367. this.$toast("课时安排不能为空");
  368. return false;
  369. }
  370. if (!this.checkCourseList()) {
  371. return;
  372. }
  373. // 排课
  374. this.setTimeTable();
  375. form.studentIdList = this.checkboxSelectIds.join(",");
  376. form.firstStudentId = this.checkboxSelectDataList.length > 0 ? this.checkboxSelectDataList[0].userId : null;
  377. let params = {
  378. courseSchedules: this.timeTable,
  379. vipGroupApplyBaseInfo: {
  380. ...form,
  381. userId: this.teacherId,
  382. activityCourseType: 'music_theory',
  383. },
  384. };
  385. setLoading(true);
  386. await createActivityVipGroup(params)
  387. .then((res) => {
  388. let result = res.data;
  389. setLoading(false);
  390. if (result.code == 200) {
  391. this.$toast("申请成功");
  392. setTimeout(() => {
  393. this.onSubmitStatus = true;
  394. if (browser().iPhone) {
  395. window.webkit.messageHandlers.DAYA.postMessage(
  396. JSON.stringify({
  397. api: "back",
  398. })
  399. );
  400. } else if (browser().android) {
  401. DAYA.postMessage(
  402. JSON.stringify({
  403. api: "back",
  404. })
  405. );
  406. } else {
  407. this.$router.push("/business");
  408. }
  409. }, 500);
  410. } else {
  411. this.$toast(result.msg);
  412. }
  413. })
  414. .catch(() => {
  415. setLoading(false);
  416. });
  417. },
  418. onCourseSchedule() {
  419. // 课时安排
  420. if (!this.form.singleClassMinutes) {
  421. this.$toast("请选课程时长");
  422. return;
  423. }
  424. if (!this.form.courseStart) {
  425. this.$toast("请选择排课开始时间");
  426. return;
  427. }
  428. this.courseForm.teachingStatus = true;
  429. },
  430. onScheduleRemove(item) { // 删除课程安排
  431. let index = this.scheduleList.indexOf(item)
  432. if (index !== -1) {
  433. this.scheduleList.splice(index, 1)
  434. }
  435. },
  436. setTimeTable() {
  437. if (!this.checkCourseList(false)) {
  438. return;
  439. }
  440. // return
  441. // 重置排课列表
  442. this.timeTable = [];
  443. let form = this.form,
  444. scheduleList = this.scheduleList;
  445. // if(!form.courseStart) {
  446. // this.$toast('请选择排课开始时间')
  447. // return
  448. // }
  449. // 拿到线上课数与线下课数 以及
  450. let online = 10;
  451. let offline = 0;
  452. // 判断是否有课程安排
  453. if (scheduleList.length <= 0) {
  454. return;
  455. }
  456. let totalCount = Number(online) + Number(offline);
  457. let tempCourseStart = form.courseStart.replace(/-/gi, "/");
  458. let dateOperation = new Date(tempCourseStart);
  459. let forMark = 0;
  460. while (totalCount && totalCount > 0) {
  461. for (let i = 0; i < scheduleList.length; i++) {
  462. // console.log(totalCount, scheduleList)
  463. if (online == 0 && offline == 0) break;
  464. let num = scheduleList[i].weekIndex - dateOperation.getDay();
  465. // 如果是同一天一个周期会出现排课都排到一天
  466. if (forMark > 0 && num == 0 && i == 0) {
  467. num = num + 7;
  468. }
  469. if (num < 0) {
  470. // 如果为负数则为下周
  471. num = num + 7;
  472. }
  473. let dataStr = this.getThinkDate(dateOperation, num);
  474. // 判断是否大于当前时间
  475. let nowGetTime = new Date().getTime();
  476. let courseTime = new Date(
  477. dataStr.replace(/-/gi, "/") +
  478. " " +
  479. scheduleList[i].startTime +
  480. ":00"
  481. ).getTime();
  482. if (nowGetTime < courseTime) {
  483. let tempArr = {
  484. classDate: dataStr,
  485. startClassTimeStr: scheduleList[i].startTime,
  486. endClassTimeStr: scheduleList[i].endTime,
  487. };
  488. // console.log(scheduleList[i].type, online, offline)
  489. if (scheduleList[i].type == "线上" && online > 0) {
  490. tempArr.teachMode = "ONLINE";
  491. this.timeTable.push(tempArr);
  492. online--;
  493. totalCount--;
  494. } else if (scheduleList[i].type == "线下" && offline > 0) {
  495. tempArr.teachMode = "OFFLINE";
  496. this.timeTable.push(tempArr);
  497. offline--;
  498. totalCount--;
  499. }
  500. }
  501. }
  502. // 加一周
  503. if (scheduleList.length == 1) {
  504. dateOperation.setDate(dateOperation.getDate() + 7);
  505. } else if (
  506. scheduleList.every((item) => item.weekStr === scheduleList[0].weekStr)
  507. ) {
  508. // 标记循环次数(标记判断课程安排是不是同一天)
  509. forMark++;
  510. }
  511. }
  512. this.timeTable.sort((a, b) => {
  513. let aStr = dayjs(
  514. dayjs(a.classDate).format("YYYY-MM-DD") +
  515. " " +
  516. a.startClassTimeStr +
  517. ":00"
  518. ).valueOf();
  519. let bStr = dayjs(
  520. dayjs(b.classDate).format("YYYY-MM-DD") +
  521. " " +
  522. b.startClassTimeStr +
  523. ":00"
  524. ).valueOf();
  525. return aStr - bStr;
  526. });
  527. },
  528. onClickSingleClass() {
  529. if (!this.formName.vipGroupCategoryName) {
  530. this.$toast("请选择课程形式");
  531. return;
  532. }
  533. this.statusList.classTimerStatus = true;
  534. },
  535. onCheckStudent() {
  536. if(!this.form.subjectIdList) {
  537. this.$toast('请选择课程声部')
  538. return
  539. }
  540. this.statusList.studentStatus = true;
  541. },
  542. onShowTimeTable() {
  543. // 显示排课列表
  544. if (!this.checkCourseList()) {
  545. return;
  546. }
  547. this.statusList.classTime = true;
  548. this.setTimeTable();
  549. },
  550. getThinkDate(date, num) {
  551. let Stamp = date;
  552. Stamp.setDate(date.getDate() + num); // 获取当前月数的第几天
  553. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  554. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  555. var mvar = "";
  556. if (month < 10) {
  557. mvar = "0" + month;
  558. } else {
  559. mvar = month + "";
  560. }
  561. var day = Stamp.getDate();
  562. var dvar = "";
  563. if (day < 10) {
  564. dvar = "0" + day;
  565. } else {
  566. dvar = day + "";
  567. }
  568. return year + "-" + mvar + "-" + dvar;
  569. },
  570. onTeachinConfirm(value) {
  571. // 添加课程
  572. let scheduleList = this.scheduleList;
  573. let startTime =
  574. (value[2] >= 10 ? value[2] : "0" + value[2]) +
  575. ":" +
  576. value[3].split("分")[0];
  577. let endTime = this.MinutesTest(
  578. value[2],
  579. value[3],
  580. this.form.singleClassMinutes
  581. );
  582. let isAdd = true;
  583. scheduleList.forEach((item) => {
  584. let isStartTime = this.timeIsrange(startTime, endTime, item.startTime);
  585. let isEndTime = this.timeIsrange(startTime, endTime, item.endTime);
  586. if (isAdd) {
  587. //
  588. if (value[1] == item.weekStr) {
  589. if (isStartTime || isEndTime) {
  590. isAdd = false;
  591. } else {
  592. isAdd = true;
  593. }
  594. } else if (value[1] != item.weekStr) {
  595. isAdd = true;
  596. }
  597. }
  598. });
  599. // 判断结束时间
  600. const endTime1 = endTime ? Number(endTime.split(":")[0]) : 0
  601. const endTime2 = endTime ? Number(endTime.split(":")[1]) : 0
  602. if(endTime1 >= 21 && endTime2 > 0) {
  603. this.$toast("课程安排结束时间不可超过21:00");
  604. return;
  605. }
  606. if (isAdd) {
  607. // 判断时间范围是否有重复
  608. scheduleList.push({
  609. type: value[0], // 线上还是线下
  610. weekStr: value[1],
  611. weekIndex: this.getWeek(value[1]),
  612. startTime: startTime,
  613. endTime: endTime,
  614. id: Date.now(),
  615. });
  616. this.courseForm.teachingStatus = false;
  617. this.setTimeTable();
  618. } else {
  619. this.$toast("该时间段已排课请重选时间");
  620. return;
  621. }
  622. },
  623. checkCourseList(isShowToast = true) {
  624. let scheduleList = this.scheduleList || [];
  625. let hasOnLine = false; // 是否有线上课时安排
  626. scheduleList.forEach((item) => {
  627. if (item.type == "线上") {
  628. hasOnLine = true;
  629. }
  630. });
  631. if (!hasOnLine) {
  632. if (isShowToast) {
  633. this.$toast("课时安排缺少线上课类型");
  634. }
  635. return false;
  636. }
  637. return true;
  638. },
  639. // 分钟小时相加减
  640. MinutesTest(houer, mins, interval) {
  641. let min = mins.split("分")[0];
  642. let sdate1 = new Date(1900, 1, 1, houer, min);
  643. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  644. let H = sdate1.getHours();
  645. let M = sdate1.getMinutes();
  646. if (H < 10) H = "0" + H;
  647. if (M < 10) M = "0" + M;
  648. return H + ":" + M;
  649. },
  650. // 判断时间是否在时间段内
  651. timeIsrange(beginTime, endTime, nowTime) {
  652. var strb = beginTime.split(":");
  653. if (strb.length != 2) {
  654. return false;
  655. }
  656. var stre = endTime.split(":");
  657. if (stre.length != 2) {
  658. return false;
  659. }
  660. var strn = nowTime.split(":");
  661. if (stre.length != 2) {
  662. return false;
  663. }
  664. var b = new Date();
  665. var e = new Date();
  666. var n = new Date();
  667. b.setHours(strb[0]);
  668. b.setMinutes(strb[1]);
  669. e.setHours(stre[0]);
  670. e.setMinutes(stre[1]);
  671. n.setHours(strn[0]);
  672. n.setMinutes(strn[1]);
  673. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  674. // 在时间范围内
  675. return true;
  676. } else {
  677. // 不在时间范围内
  678. return false;
  679. }
  680. },
  681. getWeek(str) {
  682. // 获取周几索引值
  683. let template = {
  684. '周一': 1,
  685. '周二': 2,
  686. '周三': 3,
  687. '周四': 4,
  688. '周五': 5,
  689. '周六': 6,
  690. '周日': 0,
  691. };
  692. return template[str];
  693. },
  694. // 搜索
  695. onSearch() {
  696. this.params.page = 1;
  697. this.dataList = [];
  698. this.dataShow = true;
  699. this.loading = true;
  700. this.finished = false;
  701. this.getStudent();
  702. },
  703. async getStudent() {
  704. let params = this.params;
  705. await getStudents(cleanDeep({
  706. ...params,
  707. activityCourseType: 'music_theory'
  708. // subjectId:this.form.subjectIdList
  709. })).then((res) => {
  710. let result = res.data;
  711. this.loading = false;
  712. if (result.code == 200) {
  713. if(this.dataList.length > 0 && result.data.pageNo == 1) {
  714. return
  715. }
  716. params.page = result.data.pageNo;
  717. this.dataList = this.dataList.concat(result.data.rows);
  718. if (params.page >= result.data.totalPage) {
  719. this.finished = true;
  720. }
  721. this.params.page++;
  722. } else {
  723. this.finished = true;
  724. }
  725. // 判断是否有数据
  726. if (this.dataList.length <= 0) {
  727. this.dataShow = false;
  728. }
  729. });
  730. },
  731. onPopupCancel() {
  732. // 关闭弹窗
  733. this.statusList.studentStatus = false;
  734. // this.params.search = null
  735. this.checkboxSelect = [];
  736. this.checkboxSelectList = [];
  737. },
  738. onPopupSubmit() {
  739. const vipGroupCategorySelect = this.loadData.vipGroupCategorySelect;
  740. let len = this.checkboxSelect.length
  741. if(len < 1 || len > vipGroupCategorySelect.studentNum) {
  742. this.$toast(`请选择学生1~${vipGroupCategorySelect.studentNum}名,当前选择${len}名`)
  743. return
  744. }
  745. this.checkboxSelectDataList = JSON.parse(
  746. JSON.stringify(this.checkboxSelectList)
  747. );
  748. this.checkboxSelectIds = JSON.parse(JSON.stringify(this.checkboxSelect));
  749. this.checkboxSelect = [];
  750. this.checkboxSelectList = [];
  751. this.statusList.studentStatus = false;
  752. },
  753. onCheckboxSelect(value) {
  754. if (this.checkboxSelect.includes(value.userId.toString())) {
  755. this.checkboxSelect.forEach((item, index) => {
  756. if (item == value.userId.toString()) {
  757. this.checkboxSelect.splice(index, 1);
  758. }
  759. });
  760. this.checkboxSelectList.forEach((item, index) => {
  761. if (item.userId == value.userId) {
  762. this.checkboxSelectList.splice(index, 1);
  763. }
  764. });
  765. } else {
  766. this.checkboxSelect.push(value.userId.toString());
  767. this.checkboxSelectList.push(value);
  768. }
  769. },
  770. onSelect(name) {
  771. let sheetForm = this.sheetForm;
  772. sheetForm.columns = [];
  773. sheetForm.sheetStatus = true;
  774. sheetForm.loading = true;
  775. sheetForm.currentType = name;
  776. sheetForm.index = 0;
  777. let arr = this.loadData[name];
  778. if (arr && arr.length > 0) {
  779. sheetForm.columns = arr;
  780. sheetForm.index = this.formName[name + "Index"];
  781. sheetForm.loading = false;
  782. } else {
  783. this.onLoadingData(name);
  784. }
  785. this.sheetForm.status = true;
  786. },
  787. async onLoadingData() {
  788. // 加载数据
  789. let sheetForm = this.sheetForm;
  790. if (sheetForm.currentType == "subjectList") {
  791. // 请求声部
  792. await findSubSubjects().then((res) => {
  793. let result = res.data;
  794. if (result.code == 200 && result.data.length > 0) {
  795. let tempArr = [];
  796. result.data.forEach((item) => {
  797. item.value = item.id;
  798. item.text = item.name;
  799. tempArr.push(item);
  800. });
  801. this.loadData.subjectList = tempArr;
  802. sheetForm.columns = tempArr;
  803. sheetForm.loading = false;
  804. } else {
  805. this.$toast("暂无科目列表");
  806. sheetForm.loading = false;
  807. }
  808. });
  809. } else if (sheetForm.currentType == "vipGroupCategory") {
  810. // 课程形式
  811. vipGroupCategory({ includeMusicTheory: 1 }).then((res) => {
  812. let result = res.data;
  813. if (result.code == 200 && result.data.length > 0) {
  814. let tempArr = [];
  815. result.data.forEach((item) => {
  816. if (item.musicTheory) {
  817. item.value = item.id;
  818. item.text = item.name;
  819. tempArr.push(item);
  820. }
  821. });
  822. if(!tempArr || tempArr.length <= 0) {
  823. this.$toast("暂无课程形式");
  824. }
  825. this.loadData.vipGroupCategory = tempArr;
  826. sheetForm.columns = tempArr;
  827. sheetForm.loading = false;
  828. } else {
  829. this.$toast("暂无课程形式");
  830. sheetForm.loading = false;
  831. }
  832. });
  833. }
  834. },
  835. onClassTimerSelect(value) {
  836. // 每课时长设置
  837. if(this.form.singleClassMinutes != value.value) {
  838. this.timeTable = [] // 生成的课表
  839. this.scheduleList = []
  840. }
  841. this.form.singleClassMinutes = value.value;
  842. this.statusList.classTimerStatus = false;
  843. },
  844. onSheetConfirm(value, index) {
  845. // 上拉弹窗
  846. let sheetForm = this.sheetForm,
  847. form = this.form,
  848. formName = this.formName,
  849. loadData = this.loadData;
  850. if (sheetForm.currentType == "subjectList") {
  851. // 科目名称赋值
  852. form.subjectIdList = value.value;
  853. formName.subjectListName = value.text;
  854. formName.subjectListIndex = index;
  855. loadData.subjectListSelect = value;
  856. // 重置上课学生
  857. this.dataList = []
  858. this.params.search = null
  859. this.loading = false
  860. this.finished = false
  861. this.dataShow = true
  862. this.params.page = 1
  863. this.checkboxSelect = [];
  864. this.checkboxSelectIds = [];
  865. this.checkboxSelectList = []; //选中学生列表
  866. this.checkboxSelectDataList = [];
  867. } else if(sheetForm.currentType == "vipGroupCategory") {
  868. form.vipGroupCategoryId = value.value;
  869. formName.vipGroupCategoryName = value.text;
  870. formName.vipGroupCategoryIndex = index;
  871. loadData.vipGroupCategorySelect = value;
  872. form.studentNum = value.studentNum; // 每班人数
  873. // form.singleClassMinutes = value.singleClassMinutes // 每课时长
  874. form.onlineClassesUnitPrice = Math.ceil(value.onlineClassesUnitPrice);
  875. form.offlineClassesUnitPrice = Math.ceil(value.offlineClassesUnitPrice);
  876. // 每课时长赋值
  877. form.singleClassMinutes = null;
  878. loadData.classTimer = [];
  879. let tempSingle = value.singleClassMinutes.split(",");
  880. form.singleClassMinutes = tempSingle.length > 0 ? tempSingle[0] : null
  881. tempSingle.forEach((item) => {
  882. this.loadData.classTimer.push({
  883. name: item,
  884. value: item,
  885. });
  886. });
  887. this.scheduleList = []
  888. this.timeTable = []
  889. }
  890. sheetForm.sheetStatus = false;
  891. },
  892. onCurrentConfirm(value) {
  893. // 排课开始时间
  894. let selectDate = new Date(value);
  895. let tempMonth =
  896. selectDate.getMonth() + 1 >= 10
  897. ? selectDate.getMonth() + 1
  898. : "0" + (selectDate.getMonth() + 1);
  899. let tempDay =
  900. selectDate.getDate() >= 10
  901. ? selectDate.getDate()
  902. : "0" + selectDate.getDate();
  903. this.form.courseStart =
  904. selectDate.getFullYear() + "-" + tempMonth + "-" + tempDay;
  905. this.dataForm.status = false;
  906. },
  907. formatter(type, val) {
  908. if (type === "year") {
  909. return `${val}年`;
  910. } else if (type === "month") {
  911. return `${val}月`;
  912. } else if (type == "day") {
  913. return `${val}日`;
  914. }
  915. return val;
  916. },
  917. desensitPhone(phone) {
  918. // 手机号脱敏
  919. let first = phone.substr(0, 3);
  920. let last = phone.substr(-4);
  921. return first + "****" + last;
  922. },
  923. }
  924. }
  925. </script>
  926. <style lang="less" scoped>
  927. @import url("../../../assets/commonLess/variable.less");
  928. .studentColor {
  929. color: @mColor !important;
  930. }
  931. .studentContainer {
  932. /deep/.van-cell__title {
  933. font-size: 0.16rem;
  934. color: @mFontColor;
  935. flex: 1 auto;
  936. }
  937. .logo {
  938. width: 0.35rem;
  939. height: 0.35rem;
  940. margin-right: 0.12rem;
  941. border-radius: 100%;
  942. }
  943. .input-cell {
  944. padding: 0.12rem 0.16rem 0.2rem;
  945. .van-checkbox {
  946. justify-content: flex-end;
  947. }
  948. }
  949. /deep/.van-cell__value {
  950. height: 0.2rem;
  951. }
  952. /deep/.van-checkbox__icon .van-icon {
  953. border-color: @sFontColor;
  954. }
  955. /deep/.van-checkbox__icon--checked .van-icon {
  956. border-color: #01C1B5;
  957. }
  958. .van-tag {
  959. margin-left: 0.08rem;
  960. }
  961. }
  962. .button-group-popup {
  963. position: fixed;
  964. bottom: 0;
  965. padding: 0.2rem 0;
  966. width: 100%;
  967. text-align: center;
  968. background-color: #ffffff;
  969. .btn {
  970. padding: 0 0.45rem;
  971. line-height: 0.4rem;
  972. display: inline-block;
  973. border: 1px solid @mColor;
  974. border-radius: 1rem;
  975. color: @mColor;
  976. background: #fff;
  977. font-size: 0.18rem;
  978. &.primary {
  979. color: #fff;
  980. background: @mColor;
  981. }
  982. }
  983. .btn + .btn {
  984. margin-left: 0.1rem;
  985. }
  986. }
  987. .vip-title {
  988. padding: .06rem .14rem .04rem;
  989. font-size: .14rem;
  990. color: #808080;
  991. }
  992. .courseStudent {
  993. .van-cell__value {
  994. color: #c8c9cc;
  995. font-size: .16rem;
  996. }
  997. }
  998. .add-plan {
  999. display: flex;
  1000. align-items: center;
  1001. justify-content: center;
  1002. padding: .1rem 0;
  1003. font-size: .16rem;
  1004. .van-icon {
  1005. margin-right: .05rem;
  1006. font-size: .20rem;
  1007. }
  1008. }
  1009. /deep/.van-cell__title {
  1010. -webkit-box-flex: 0;
  1011. -webkit-flex: none;
  1012. flex: none;
  1013. box-sizing: border-box;
  1014. margin-right: 12px;
  1015. color: #646566;
  1016. text-align: left;
  1017. word-wrap: break-word;
  1018. font-size: 16px;
  1019. }
  1020. .title-time {
  1021. display: flex;
  1022. align-items: center;
  1023. flex: 1 auto;
  1024. color: #4a4a4a;
  1025. .online {
  1026. color: @tFontColor;
  1027. }
  1028. .week {
  1029. padding-left: 0.4rem;
  1030. padding-right: 0.15rem;
  1031. }
  1032. }
  1033. .van-row {
  1034. line-height: 0.4rem;
  1035. border-top: 1px solid #edeef0;
  1036. text-align: center;
  1037. font-size: 0.14rem;
  1038. &:first-child {
  1039. border-top: 0;
  1040. background: #edeef0;
  1041. color: #444;
  1042. font-size: 0.15rem;
  1043. }
  1044. }
  1045. .tableContainer {
  1046. max-height: 2.44rem;
  1047. overflow: auto;
  1048. .van-row {
  1049. color: #444;
  1050. &:first-child {
  1051. border-top: 0;
  1052. background: #fff;
  1053. font-size: 0.14rem;
  1054. }
  1055. }
  1056. }
  1057. .paddingB80 {
  1058. padding-bottom: .8rem;
  1059. }
  1060. /deep/.studentChiose {
  1061. border-radius: 0 0 0px 0px;
  1062. overflow: auto;
  1063. }
  1064. </style>