theoryCourse.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  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. if(endTime1 > 20){
  602. this.$toast("课程安排结束时间超过21:00");
  603. return;
  604. }
  605. if (isAdd) {
  606. // 判断时间范围是否有重复
  607. scheduleList.push({
  608. type: value[0], // 线上还是线下
  609. weekStr: value[1],
  610. weekIndex: this.getWeek(value[1]),
  611. startTime: startTime,
  612. endTime: endTime,
  613. id: Date.now(),
  614. });
  615. this.courseForm.teachingStatus = false;
  616. this.setTimeTable();
  617. } else {
  618. this.$toast("该时间段已排课请重选时间");
  619. return;
  620. }
  621. },
  622. checkCourseList(isShowToast = true) {
  623. let scheduleList = this.scheduleList || [];
  624. let hasOnLine = false; // 是否有线上课时安排
  625. scheduleList.forEach((item) => {
  626. if (item.type == "线上") {
  627. hasOnLine = true;
  628. }
  629. });
  630. if (!hasOnLine) {
  631. if (isShowToast) {
  632. this.$toast("课时安排缺少线上课类型");
  633. }
  634. return false;
  635. }
  636. return true;
  637. },
  638. // 分钟小时相加减
  639. MinutesTest(houer, mins, interval) {
  640. let min = mins.split("分")[0];
  641. let sdate1 = new Date(1900, 1, 1, houer, min);
  642. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  643. let H = sdate1.getHours();
  644. let M = sdate1.getMinutes();
  645. if (H < 10) H = "0" + H;
  646. if (M < 10) M = "0" + M;
  647. return H + ":" + M;
  648. },
  649. // 判断时间是否在时间段内
  650. timeIsrange(beginTime, endTime, nowTime) {
  651. var strb = beginTime.split(":");
  652. if (strb.length != 2) {
  653. return false;
  654. }
  655. var stre = endTime.split(":");
  656. if (stre.length != 2) {
  657. return false;
  658. }
  659. var strn = nowTime.split(":");
  660. if (stre.length != 2) {
  661. return false;
  662. }
  663. var b = new Date();
  664. var e = new Date();
  665. var n = new Date();
  666. b.setHours(strb[0]);
  667. b.setMinutes(strb[1]);
  668. e.setHours(stre[0]);
  669. e.setMinutes(stre[1]);
  670. n.setHours(strn[0]);
  671. n.setMinutes(strn[1]);
  672. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  673. // 在时间范围内
  674. return true;
  675. } else {
  676. // 不在时间范围内
  677. return false;
  678. }
  679. },
  680. getWeek(str) {
  681. // 获取周几索引值
  682. let template = {
  683. '周一': 1,
  684. '周二': 2,
  685. '周三': 3,
  686. '周四': 4,
  687. '周五': 5,
  688. '周六': 6,
  689. '周日': 0,
  690. };
  691. return template[str];
  692. },
  693. // 搜索
  694. onSearch() {
  695. this.params.page = 1;
  696. this.dataList = [];
  697. this.dataShow = true;
  698. this.loading = true;
  699. this.finished = false;
  700. this.getStudent();
  701. },
  702. async getStudent() {
  703. let params = this.params;
  704. await getStudents(cleanDeep({
  705. ...params,
  706. activityCourseType: 'music_theory'
  707. // subjectId:this.form.subjectIdList
  708. })).then((res) => {
  709. let result = res.data;
  710. this.loading = false;
  711. if (result.code == 200) {
  712. if(this.dataList.length > 0 && result.data.pageNo == 1) {
  713. return
  714. }
  715. params.page = result.data.pageNo;
  716. this.dataList = this.dataList.concat(result.data.rows);
  717. if (params.page >= result.data.totalPage) {
  718. this.finished = true;
  719. }
  720. this.params.page++;
  721. } else {
  722. this.finished = true;
  723. }
  724. // 判断是否有数据
  725. if (this.dataList.length <= 0) {
  726. this.dataShow = false;
  727. }
  728. });
  729. },
  730. onPopupCancel() {
  731. // 关闭弹窗
  732. this.statusList.studentStatus = false;
  733. // this.params.search = null
  734. this.checkboxSelect = [];
  735. this.checkboxSelectList = [];
  736. },
  737. onPopupSubmit() {
  738. const vipGroupCategorySelect = this.loadData.vipGroupCategorySelect;
  739. let len = this.checkboxSelect.length
  740. if(len < 1 || len > vipGroupCategorySelect.studentNum) {
  741. this.$toast(`请选择学生1~${vipGroupCategorySelect.studentNum}名,当前选择${len}名`)
  742. return
  743. }
  744. this.checkboxSelectDataList = JSON.parse(
  745. JSON.stringify(this.checkboxSelectList)
  746. );
  747. this.checkboxSelectIds = JSON.parse(JSON.stringify(this.checkboxSelect));
  748. this.checkboxSelect = [];
  749. this.checkboxSelectList = [];
  750. this.statusList.studentStatus = false;
  751. },
  752. onCheckboxSelect(value) {
  753. if (this.checkboxSelect.includes(value.userId.toString())) {
  754. this.checkboxSelect.forEach((item, index) => {
  755. if (item == value.userId.toString()) {
  756. this.checkboxSelect.splice(index, 1);
  757. }
  758. });
  759. this.checkboxSelectList.forEach((item, index) => {
  760. if (item.userId == value.userId) {
  761. this.checkboxSelectList.splice(index, 1);
  762. }
  763. });
  764. } else {
  765. this.checkboxSelect.push(value.userId.toString());
  766. this.checkboxSelectList.push(value);
  767. }
  768. },
  769. onSelect(name) {
  770. let sheetForm = this.sheetForm;
  771. sheetForm.columns = [];
  772. sheetForm.sheetStatus = true;
  773. sheetForm.loading = true;
  774. sheetForm.currentType = name;
  775. sheetForm.index = 0;
  776. let arr = this.loadData[name];
  777. if (arr && arr.length > 0) {
  778. sheetForm.columns = arr;
  779. sheetForm.index = this.formName[name + "Index"];
  780. sheetForm.loading = false;
  781. } else {
  782. this.onLoadingData(name);
  783. }
  784. this.sheetForm.status = true;
  785. },
  786. async onLoadingData() {
  787. // 加载数据
  788. let sheetForm = this.sheetForm;
  789. if (sheetForm.currentType == "subjectList") {
  790. // 请求声部
  791. await findSubSubjects().then((res) => {
  792. let result = res.data;
  793. if (result.code == 200 && result.data.length > 0) {
  794. let tempArr = [];
  795. result.data.forEach((item) => {
  796. item.value = item.id;
  797. item.text = item.name;
  798. tempArr.push(item);
  799. });
  800. this.loadData.subjectList = tempArr;
  801. sheetForm.columns = tempArr;
  802. sheetForm.loading = false;
  803. } else {
  804. this.$toast("暂无科目列表");
  805. sheetForm.loading = false;
  806. }
  807. });
  808. } else if (sheetForm.currentType == "vipGroupCategory") {
  809. // 课程形式
  810. vipGroupCategory({ includeMusicTheory: 1 }).then((res) => {
  811. let result = res.data;
  812. if (result.code == 200 && result.data.length > 0) {
  813. let tempArr = [];
  814. result.data.forEach((item) => {
  815. if (item.musicTheory) {
  816. item.value = item.id;
  817. item.text = item.name;
  818. tempArr.push(item);
  819. }
  820. });
  821. if(!tempArr || tempArr.length <= 0) {
  822. this.$toast("暂无课程形式");
  823. }
  824. this.loadData.vipGroupCategory = tempArr;
  825. sheetForm.columns = tempArr;
  826. sheetForm.loading = false;
  827. } else {
  828. this.$toast("暂无课程形式");
  829. sheetForm.loading = false;
  830. }
  831. });
  832. }
  833. },
  834. onClassTimerSelect(value) {
  835. // 每课时长设置
  836. if(this.form.singleClassMinutes != value.value) {
  837. this.timeTable = [] // 生成的课表
  838. this.scheduleList = []
  839. }
  840. this.form.singleClassMinutes = value.value;
  841. this.statusList.classTimerStatus = false;
  842. },
  843. onSheetConfirm(value, index) {
  844. // 上拉弹窗
  845. let sheetForm = this.sheetForm,
  846. form = this.form,
  847. formName = this.formName,
  848. loadData = this.loadData;
  849. if (sheetForm.currentType == "subjectList") {
  850. // 科目名称赋值
  851. form.subjectIdList = value.value;
  852. formName.subjectListName = value.text;
  853. formName.subjectListIndex = index;
  854. loadData.subjectListSelect = value;
  855. // 重置上课学生
  856. this.dataList = []
  857. this.params.search = null
  858. this.loading = false
  859. this.finished = false
  860. this.dataShow = true
  861. this.params.page = 1
  862. this.checkboxSelect = [];
  863. this.checkboxSelectIds = [];
  864. this.checkboxSelectList = []; //选中学生列表
  865. this.checkboxSelectDataList = [];
  866. } else if(sheetForm.currentType == "vipGroupCategory") {
  867. form.vipGroupCategoryId = value.value;
  868. formName.vipGroupCategoryName = value.text;
  869. formName.vipGroupCategoryIndex = index;
  870. loadData.vipGroupCategorySelect = value;
  871. form.studentNum = value.studentNum; // 每班人数
  872. // form.singleClassMinutes = value.singleClassMinutes // 每课时长
  873. form.onlineClassesUnitPrice = Math.ceil(value.onlineClassesUnitPrice);
  874. form.offlineClassesUnitPrice = Math.ceil(value.offlineClassesUnitPrice);
  875. // 每课时长赋值
  876. form.singleClassMinutes = null;
  877. loadData.classTimer = [];
  878. let tempSingle = value.singleClassMinutes.split(",");
  879. form.singleClassMinutes = tempSingle.length > 0 ? tempSingle[0] : null
  880. tempSingle.forEach((item) => {
  881. this.loadData.classTimer.push({
  882. name: item,
  883. value: item,
  884. });
  885. });
  886. this.scheduleList = []
  887. this.timeTable = []
  888. }
  889. sheetForm.sheetStatus = false;
  890. },
  891. onCurrentConfirm(value) {
  892. // 排课开始时间
  893. let selectDate = new Date(value);
  894. let tempMonth =
  895. selectDate.getMonth() + 1 >= 10
  896. ? selectDate.getMonth() + 1
  897. : "0" + (selectDate.getMonth() + 1);
  898. let tempDay =
  899. selectDate.getDate() >= 10
  900. ? selectDate.getDate()
  901. : "0" + selectDate.getDate();
  902. this.form.courseStart =
  903. selectDate.getFullYear() + "-" + tempMonth + "-" + tempDay;
  904. this.dataForm.status = false;
  905. },
  906. formatter(type, val) {
  907. if (type === "year") {
  908. return `${val}年`;
  909. } else if (type === "month") {
  910. return `${val}月`;
  911. } else if (type == "day") {
  912. return `${val}日`;
  913. }
  914. return val;
  915. },
  916. desensitPhone(phone) {
  917. // 手机号脱敏
  918. let first = phone.substr(0, 3);
  919. let last = phone.substr(-4);
  920. return first + "****" + last;
  921. },
  922. }
  923. }
  924. </script>
  925. <style lang="less" scoped>
  926. @import url("../../../assets/commonLess/variable.less");
  927. .studentColor {
  928. color: @mColor !important;
  929. }
  930. .studentContainer {
  931. /deep/.van-cell__title {
  932. font-size: 0.16rem;
  933. color: @mFontColor;
  934. flex: 1 auto;
  935. }
  936. .logo {
  937. width: 0.35rem;
  938. height: 0.35rem;
  939. margin-right: 0.12rem;
  940. border-radius: 100%;
  941. }
  942. .input-cell {
  943. padding: 0.12rem 0.16rem 0.2rem;
  944. .van-checkbox {
  945. justify-content: flex-end;
  946. }
  947. }
  948. /deep/.van-cell__value {
  949. height: 0.2rem;
  950. }
  951. /deep/.van-checkbox__icon .van-icon {
  952. border-color: @sFontColor;
  953. }
  954. /deep/.van-checkbox__icon--checked .van-icon {
  955. border-color: #01C1B5;
  956. }
  957. .van-tag {
  958. margin-left: 0.08rem;
  959. }
  960. }
  961. .button-group-popup {
  962. position: fixed;
  963. bottom: 0;
  964. padding: 0.2rem 0;
  965. width: 100%;
  966. text-align: center;
  967. background-color: #ffffff;
  968. .btn {
  969. padding: 0 0.45rem;
  970. line-height: 0.4rem;
  971. display: inline-block;
  972. border: 1px solid @mColor;
  973. border-radius: 1rem;
  974. color: @mColor;
  975. background: #fff;
  976. font-size: 0.18rem;
  977. &.primary {
  978. color: #fff;
  979. background: @mColor;
  980. }
  981. }
  982. .btn + .btn {
  983. margin-left: 0.1rem;
  984. }
  985. }
  986. .vip-title {
  987. padding: .06rem .14rem .04rem;
  988. font-size: .14rem;
  989. color: #808080;
  990. }
  991. .courseStudent {
  992. .van-cell__value {
  993. color: #c8c9cc;
  994. font-size: .16rem;
  995. }
  996. }
  997. .add-plan {
  998. display: flex;
  999. align-items: center;
  1000. justify-content: center;
  1001. padding: .1rem 0;
  1002. font-size: .16rem;
  1003. .van-icon {
  1004. margin-right: .05rem;
  1005. font-size: .20rem;
  1006. }
  1007. }
  1008. /deep/.van-cell__title {
  1009. -webkit-box-flex: 0;
  1010. -webkit-flex: none;
  1011. flex: none;
  1012. box-sizing: border-box;
  1013. margin-right: 12px;
  1014. color: #646566;
  1015. text-align: left;
  1016. word-wrap: break-word;
  1017. font-size: 16px;
  1018. }
  1019. .title-time {
  1020. display: flex;
  1021. align-items: center;
  1022. flex: 1 auto;
  1023. color: #4a4a4a;
  1024. .online {
  1025. color: @tFontColor;
  1026. }
  1027. .week {
  1028. padding-left: 0.4rem;
  1029. padding-right: 0.15rem;
  1030. }
  1031. }
  1032. .van-row {
  1033. line-height: 0.4rem;
  1034. border-top: 1px solid #edeef0;
  1035. text-align: center;
  1036. font-size: 0.14rem;
  1037. &:first-child {
  1038. border-top: 0;
  1039. background: #edeef0;
  1040. color: #444;
  1041. font-size: 0.15rem;
  1042. }
  1043. }
  1044. .tableContainer {
  1045. max-height: 2.44rem;
  1046. overflow: auto;
  1047. .van-row {
  1048. color: #444;
  1049. &:first-child {
  1050. border-top: 0;
  1051. background: #fff;
  1052. font-size: 0.14rem;
  1053. }
  1054. }
  1055. }
  1056. .paddingB80 {
  1057. padding-bottom: .8rem;
  1058. }
  1059. /deep/.studentChiose {
  1060. border-radius: 0 0 0px 0px;
  1061. overflow: auto;
  1062. }
  1063. </style>