vipCourse.vue 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729
  1. <template>
  2. <div class="vipCourse">
  3. <div>
  4. <van-divider
  5. content-position="center"
  6. :style="{ padding: '0 16px', margin: '.05rem 0' }"
  7. >课程信息</van-divider
  8. >
  9. <van-field
  10. label="课程声部"
  11. input-align="right"
  12. placeholder="请选择课程声部"
  13. v-model="formName.subjectListName"
  14. @click="onSelect('subjectList')"
  15. readonly
  16. is-link
  17. />
  18. <van-field
  19. label="课程形式"
  20. v-model="formName.vipGroupCategoryName"
  21. input-align="right"
  22. placeholder="请选择课程形式"
  23. @click="onSelect('vipGroupCategory')"
  24. readonly
  25. is-link
  26. />
  27. <van-cell
  28. class="courseStudent"
  29. title="上课学员"
  30. @click="onCheckStudent"
  31. :readonly="true"
  32. input-align="right"
  33. :is-link="checkboxSelectDataList.length > 0 ? false : true"
  34. :value="checkboxSelectDataList.length > 0 ? '重新选择' : '请选择上课学员'"
  35. :value-class="checkboxSelectDataList.length > 0 ? 'studentColor' : null"
  36. />
  37. <div
  38. v-if="checkboxSelectDataList.length > 0"
  39. style="
  40. text-align: center;
  41. line-height: 1.8;
  42. padding: 0.05rem 0;
  43. background: #fafbff;
  44. "
  45. >
  46. <p
  47. style="color: #323233"
  48. v-for="(item, index) in checkboxSelectDataList"
  49. :key="index"
  50. >
  51. {{ item.username }} - {{ item.parentsPhone }}
  52. </p>
  53. </div>
  54. <van-field
  55. label="活动方案"
  56. v-model="formName.vipGroupActivityName"
  57. input-align="right"
  58. placeholder="请选择活动方案"
  59. @click="onSelect('vipGroupActivity')"
  60. readonly
  61. is-link
  62. />
  63. <van-divider
  64. content-position="center"
  65. :style="{ padding: '0 16px', margin: '.05rem 0' }"
  66. >课时组成</van-divider
  67. >
  68. <van-field
  69. label="课时总数"
  70. input-align="right"
  71. placeholder="请输入课时总数"
  72. readonly
  73. :value="
  74. loadData.vipGroupActivitySelect.maxCourseNum
  75. ? loadData.vipGroupActivitySelect.maxCourseNum + '节'
  76. : 0 + '节'
  77. "
  78. />
  79. <van-field
  80. label="课程时长"
  81. v-model="form.singleClassMinutes"
  82. input-align="right"
  83. placeholder="请选择课程时长"
  84. @click="onClickSingleClass"
  85. readonly
  86. is-link
  87. />
  88. <van-field
  89. v-if="statusList.hasOnline"
  90. v-model="form.onlineClassesNums"
  91. @keyup="onClassKeyUp"
  92. label="线上课"
  93. input-align="right"
  94. placeholder="请输入次数"
  95. type="number"
  96. />
  97. <van-field
  98. v-if="statusList.hasOffline"
  99. v-model="form.offlineClassesNums"
  100. @keyup="onClassKeyUp('offLine')"
  101. label="线下课"
  102. input-align="right"
  103. placeholder="请输入次数"
  104. type="number"
  105. />
  106. <van-field
  107. v-if="form.offlineClassesNums > 0"
  108. v-model="formName.teacherSchoolName"
  109. @click="onSelect('teacherSchool')"
  110. label="线下课地址"
  111. :readonly="true"
  112. input-align="right"
  113. is-link
  114. placeholder="请选择"
  115. />
  116. <van-field
  117. @click="dataForm.status = true"
  118. v-model="form.courseStart"
  119. label="排课开始时间"
  120. :readonly="true"
  121. input-align="right"
  122. is-link
  123. placeholder="请选择"
  124. />
  125. <van-cell
  126. title-class="title-time"
  127. v-for="(item, index) in scheduleList"
  128. :key="index"
  129. >
  130. <template slot="title">
  131. <span class="online">{{ item.type }}</span>
  132. <span class="week">{{ item.weekStr }}</span>
  133. <span class="timer">{{ item.startTime + "-" + item.endTime }}</span>
  134. </template>
  135. <template slot="default">
  136. <van-button
  137. type="warning"
  138. @click="onScheduleRemove(item)"
  139. round
  140. size="small"
  141. plain
  142. >删除</van-button
  143. >
  144. </template>
  145. </van-cell>
  146. <div class="add-plan van-cell" @click="onCourseShedule">
  147. <van-icon name="add-o" />课时安排
  148. </div>
  149. <van-field
  150. label="排课列表"
  151. v-if="scheduleList.length > 0"
  152. disabled
  153. input-align="right"
  154. @click="onShowTimeTable"
  155. is-link
  156. />
  157. <div style="margin: 16px">
  158. <van-button round block type="info" @click="onSubmit"
  159. >确认排课</van-button
  160. >
  161. </div>
  162. </div>
  163. <!-- 每课时长 -->
  164. <van-action-sheet
  165. v-model="statusList.classTimerStatus"
  166. :actions="loadData.classTimer"
  167. cancel-text="取消"
  168. @cancel="statusList.classTimerStatus = false"
  169. @select="onClassTimerSelect"
  170. />
  171. <!-- 报名开始时间&报名结束时间 -->
  172. <van-popup v-model="enlistForm.status" position="bottom">
  173. <van-datetime-picker
  174. v-model="enlistForm.currentDate"
  175. type="date"
  176. :min-date="enlistForm.minDate"
  177. :formatter="formatter"
  178. @cancel="enlistForm.status = false"
  179. @confirm="onEnlistConfirm"
  180. />
  181. </van-popup>
  182. <!-- 赠课类型 -->
  183. <van-action-sheet
  184. v-model="statusList.giveTeachModeStatus"
  185. :actions="loadData.giveTeachMode"
  186. cancel-text="取消"
  187. @cancel="statusList.giveTeachModeStatus = false"
  188. @select="onModeSelect"
  189. />
  190. <!-- 课程信息所用 :close-on-click-overlay="false" -->
  191. <van-popup v-model="sheetForm.sheetStatus" position="bottom">
  192. <van-picker
  193. :loading="sheetForm.loading"
  194. :default-index="sheetForm.index"
  195. :columns="sheetForm.columns"
  196. show-toolbar
  197. @cancel="sheetForm.sheetStatus = false"
  198. @confirm="onSheetConfirm"
  199. />
  200. </van-popup>
  201. <!-- 课时安排 -->
  202. <van-popup v-model="dataForm.status" position="bottom">
  203. <van-datetime-picker
  204. v-model="dataForm.currentDate"
  205. type="date"
  206. :min-date="dataForm.minDate"
  207. :formatter="formatter"
  208. @cancel="dataForm.status = false"
  209. @confirm="onCurrentConfirm"
  210. />
  211. </van-popup>
  212. <!-- 课时安排 -->
  213. <van-popup v-model="courseForm.teachingStatus" position="bottom">
  214. <van-picker
  215. :columns="courseForm.columns"
  216. show-toolbar
  217. @cancel="courseForm.teachingStatus = false"
  218. @confirm="onTeachinConfirm"
  219. />
  220. </van-popup>
  221. <!-- 选择上课学生 -->
  222. <van-popup
  223. v-model="statusList.studentStatus"
  224. :lock-scroll="true"
  225. position="bottom"
  226. :style="{ height: '180%' }"
  227. class="studentChiose"
  228. >
  229. <div v-if="statusList.studentStatus">
  230. <van-sticky>
  231. <van-search
  232. show-action
  233. shape="round"
  234. @search="onSearch"
  235. v-model="params.search"
  236. placeholder="请输入学生名或手机号"
  237. >
  238. <template #action>
  239. <div @click="onSearch">搜索</div>
  240. </template>
  241. </van-search>
  242. </van-sticky>
  243. <div class="paddingB80">
  244. <van-list
  245. v-model="loading"
  246. class="studentContainer"
  247. v-if="dataShow"
  248. key="data"
  249. :finished="finished"
  250. finished-text=""
  251. @load="getStudent"
  252. >
  253. <van-checkbox-group v-model="checkboxSelect">
  254. <van-cell-group>
  255. <van-cell
  256. v-for="(item, index) in dataList"
  257. :key="index"
  258. @click="onCheckboxSelect(item)"
  259. class="input-cell"
  260. :center="true"
  261. >
  262. <template slot="icon">
  263. <img
  264. class="logo"
  265. v-if="item.avatar"
  266. :src="item.avatar"
  267. alt=""
  268. />
  269. <img
  270. class="logo"
  271. v-else
  272. src="@/assets/images/icon_student.png"
  273. alt=""
  274. />
  275. </template>
  276. <template slot="title">
  277. {{ item.username }}
  278. </template>
  279. <template slot="label">
  280. <span>{{ desensitPhone(item.parentsPhone) }}</span>
  281. </template>
  282. <template slot="default">
  283. <van-checkbox :name="item.userId.toString()"></van-checkbox>
  284. </template>
  285. </van-cell>
  286. </van-cell-group>
  287. </van-checkbox-group>
  288. </van-list>
  289. <m-empty class="empty" msg="暂无学生" v-else key="data" />
  290. </div>
  291. <div class="button-group-popup">
  292. <span class="btn" @click="onPopupCancel">取消</span>
  293. <span class="btn primary" @click="onPopupSubmit">确定</span>
  294. </div>
  295. </div>
  296. </van-popup>
  297. <!-- 课表展示 -->
  298. <van-popup v-model="statusList.classTime" position="bottom">
  299. <van-row>
  300. <van-col span="12">上课类型</van-col>
  301. <van-col span="12">上课时间</van-col>
  302. </van-row>
  303. <div class="tableContainer">
  304. <van-row v-for="(item, index) in timeTable" :key="index">
  305. <van-col span="12">
  306. {{ item.teachMode == "ONLINE" ? "线上" : "线下" }}
  307. </van-col>
  308. <van-col span="12">
  309. {{ item.classDate }} {{ item.startClassTimeStr }}
  310. </van-col>
  311. </van-row>
  312. </div>
  313. </van-popup>
  314. </div>
  315. </template>
  316. <script>
  317. import dayjs from "dayjs";
  318. import cleanDeep from 'clean-deep'
  319. import { browser } from "@/common/common";
  320. import {
  321. findSubSubjects,
  322. vipGroupCategory,
  323. findVipSchoolByTeacher2
  324. } from "@/api/teacher";
  325. import { getStudents, createActivityVipGroup, getChildrenDayActivity } from "../api";
  326. import setLoading from "@/utils/loading";
  327. import MEmpty from "@/components/MEmpty";
  328. let minutes = []; // 分钟数
  329. for (let i = 0; i < 60; i++) {
  330. let mi = i < 10 ? "0" + i : i;
  331. minutes.push(mi + "分");
  332. }
  333. export default {
  334. components: {
  335. MEmpty },
  336. name: "apply",
  337. data() {
  338. return {
  339. dayjs,
  340. activityCourseType: null,
  341. subjectId: null,
  342. dataForm: {
  343. // 时间下拉框
  344. status: false,
  345. minDate: new Date(),
  346. currentDate: new Date(),
  347. },
  348. enlistForm: {
  349. // 时间下拉框
  350. updateStatus: "", // 修改哪个状态
  351. status: false,
  352. minDate: new Date(),
  353. currentDate: new Date(),
  354. },
  355. statusList: {
  356. // 散状态集合
  357. giveTeachModeStatus: false, // 赠课弹窗状态
  358. teachOnOrOff: false, // 是否显示赠课
  359. hasOnline: false, // 是否显示线上
  360. hasOffline: false, // 是否显示线下
  361. classTime: false, // 课表展示
  362. headerStatus: false, // 头部是否展示
  363. classTimerStatus: false, // 每课时长状态
  364. studentStatus: false, // 上课学生状态
  365. },
  366. loadData: {
  367. // 下拉加载数据
  368. subjectList: [], // 声部列表
  369. subjectListSelect: [], // 选中的声部JSON
  370. vipGroupCategory: [], // 课程形式
  371. vipGroupCategorySelect: [], // 选中的课程形式JSON
  372. vipGroupActivity: [], // 活动文案
  373. vipGroupActivitySelect: [], // 选中的活动文案JSON
  374. teacherSchool: [], // 线下课地址
  375. teacherSchoolSelect: [], // 选中的线下课地址JSON
  376. teacherList: [], // 线下课地址
  377. teacherListSelect: [], // 选中的线下课地址JSON
  378. giveTeachMode: [
  379. {
  380. name: "线上课",
  381. value: "ONLINE",
  382. },
  383. {
  384. name: "线下课",
  385. value: "OFFLINE",
  386. },
  387. ], // 赠课
  388. giveTeachModeSelect: [], // 选中的赠课JSON
  389. teacherCategory: [], // 老师课酬信息
  390. classTimer: [], // 每课时长
  391. },
  392. sheetForm: {
  393. // 上拉弹窗
  394. currentType: null, // 当前选择的类型
  395. sheetStatus: false,
  396. loading: true, // 加载数据
  397. index: 0, // 选中的索引值
  398. columns: [],
  399. },
  400. courseForm: {
  401. // 排课弹窗
  402. teachingStatus: false, // 课时安排状态
  403. columns: [
  404. {
  405. // 课程选项
  406. values: ["线上", "线下"],
  407. className: "type",
  408. },
  409. {
  410. values: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
  411. className: "week",
  412. },
  413. {
  414. values: [
  415. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  416. 20, 21, 22, 23,
  417. ],
  418. className: "hours",
  419. defaultIndex: 7,
  420. },
  421. {
  422. values: minutes,
  423. className: "minutes",
  424. },
  425. ],
  426. },
  427. form: {
  428. subjectIdList: null,
  429. vipGroupCategoryId: null,
  430. vipGroupActivityId: null,
  431. teacherSchoolId: null,
  432. educationalTeacherId: null,
  433. studentNum: null,
  434. singleClassMinutes: null,
  435. onlineClassesNums: null,
  436. offlineClassesNums: null,
  437. registrationStartTime: null,
  438. coursesExpireDate: null,
  439. totalClassTime: null,
  440. courseStart: null,
  441. giveTeachMode: null,
  442. onlineClassesUnitPrice: null,
  443. offlineClassesUnitPrice: null,
  444. onlineTeacherSalary: null,
  445. offlineTeacherSalary: null,
  446. totalCount: null,
  447. },
  448. formName: {
  449. subjectListName: null, // 声部名称
  450. subjectListIndex: 0, // 声部名称
  451. vipGroupCategoryName: null, // 课程形式
  452. vipGroupCategoryIndex: 0, // 课程形式
  453. vipGroupActivityName: null, // 活动文案
  454. vipGroupActivityIndex: 0, // 活动文案
  455. teacherSchoolName: null, // 线下课地址
  456. teacherSchoolIndex: 0, // 线下课地址
  457. giveTeachModeName: null, // 赠课类型
  458. },
  459. other: {
  460. onlineSalary: null, // 线上课课酬结算方式
  461. offlineSalary: null, // 线下课课酬结算方式
  462. giveNum: 0, // 赠送课时
  463. },
  464. scheduleList: [], // 课时安排
  465. timeTable: [], // 生成的课表
  466. onSubmitStatus: true, // 点击
  467. checkboxSelect: [],
  468. checkboxSelectIds: [],
  469. checkboxSelectList: [], //选中学生列表
  470. checkboxSelectDataList: [],
  471. loading: false,
  472. finished: false,
  473. params: {
  474. search: null,
  475. page: 1,
  476. rows: 20,
  477. },
  478. dataShow: true, // 是否有数据
  479. dataList: [],
  480. };
  481. },
  482. async mounted() {
  483. },
  484. methods: {
  485. onCheckStudent() {
  486. if(!this.form.subjectIdList) {
  487. this.$toast('请选择课程声部')
  488. return
  489. }
  490. if (!this.form.vipGroupCategoryId) {
  491. // 判断是否选择了课程形式
  492. this.$toast("请选择课程形式");
  493. return;
  494. }
  495. this.statusList.studentStatus = true;
  496. },
  497. onSelect(name) {
  498. let sheetForm = this.sheetForm;
  499. sheetForm.columns = [];
  500. if (!this.form.vipGroupCategoryId && name == "vipGroupActivity") {
  501. this.$toast("请选择课程形式");
  502. return;
  503. } else if (
  504. (!this.checkboxSelectDataList ||
  505. (this.checkboxSelectDataList &&
  506. this.checkboxSelectDataList.length <= 0)) &&
  507. name == "vipGroupActivity"
  508. ) {
  509. // 判断是否选择了课程形式
  510. this.$toast("请选择上课学生");
  511. return;
  512. }
  513. sheetForm.sheetStatus = true;
  514. sheetForm.loading = true;
  515. sheetForm.currentType = name;
  516. sheetForm.index = 0;
  517. let arr = this.loadData[name];
  518. if (arr && arr.length > 0) {
  519. sheetForm.columns = arr;
  520. sheetForm.index = this.formName[name + "Index"];
  521. sheetForm.loading = false;
  522. } else {
  523. this.onLoadingData(name);
  524. }
  525. this.sheetForm.status = true;
  526. },
  527. formatter(type, val) {
  528. if (type === "year") {
  529. return `${val}年`;
  530. } else if (type === "month") {
  531. return `${val}月`;
  532. } else if (type == "day") {
  533. return `${val}日`;
  534. }
  535. return val;
  536. },
  537. async onLoadingData() {
  538. // 加载数据
  539. let sheetForm = this.sheetForm;
  540. if (sheetForm.currentType == "subjectList") {
  541. // 请求声部
  542. await findSubSubjects().then((res) => {
  543. let result = res.data;
  544. if (result.code == 200 && result.data.length > 0) {
  545. let tempArr = [];
  546. result.data.forEach((item) => {
  547. item.value = item.id;
  548. item.text = item.name;
  549. tempArr.push(item);
  550. });
  551. this.loadData.subjectList = tempArr;
  552. sheetForm.columns = tempArr;
  553. sheetForm.loading = false;
  554. } else {
  555. this.$toast("暂无科目列表");
  556. sheetForm.loading = false;
  557. }
  558. });
  559. } else if (sheetForm.currentType == "vipGroupCategory") {
  560. // 课程形式
  561. vipGroupCategory().then((res) => {
  562. let result = res.data;
  563. if (result.code == 200 && result.data.length > 0) {
  564. let tempArr = [];
  565. result.data.forEach((item) => {
  566. if (item.name == "1v1" || item.name == "1v2") {
  567. item.value = item.id;
  568. item.text = item.name;
  569. tempArr.push(item);
  570. }
  571. });
  572. this.loadData.vipGroupCategory = tempArr;
  573. sheetForm.columns = tempArr;
  574. sheetForm.loading = false;
  575. } else {
  576. this.$toast("暂无课程形式");
  577. sheetForm.loading = false;
  578. }
  579. });
  580. } else if (sheetForm.currentType == "vipGroupActivity") {
  581. // 活动文案
  582. let studentIds = [];
  583. if (
  584. this.checkboxSelectDataList &&
  585. this.checkboxSelectDataList.length > 0
  586. ) {
  587. this.checkboxSelectDataList.forEach((item) => {
  588. studentIds.push(item.userId);
  589. });
  590. }
  591. getChildrenDayActivity({
  592. categoryId: this.form.vipGroupCategoryId,
  593. studentIds: studentIds.join(",")
  594. }).then((res) => {
  595. let result = res.data;
  596. if (result.code == 200 && result.data.length > 0) {
  597. let tempArr = [];
  598. let regStr = new RegExp("双十一");
  599. result.data.forEach((item) => {
  600. if (!regStr.test(item.name)) {
  601. item.value = item.id;
  602. item.text = item.name;
  603. (item.startTime = item.startTime
  604. ? item.startTime.split(" ")[0]
  605. : null), // 报名开始时间
  606. (item.endTime = item.endTime
  607. ? item.endTime.split(" ")[0]
  608. : null); // 报名结束时间
  609. tempArr.push(item);
  610. }
  611. });
  612. this.loadData.vipGroupActivity = tempArr;
  613. sheetForm.columns = tempArr;
  614. sheetForm.loading = false;
  615. } else {
  616. this.$toast("暂无活动方案");
  617. sheetForm.loading = false;
  618. }
  619. });
  620. } else if(sheetForm.currentType == "teacherSchool") {
  621. // 教师教学点
  622. findVipSchoolByTeacher2({ userId: this.teacherId }).then((res) => {
  623. let result = res.data;
  624. if (result.code == 200 && result.data.length > 0) {
  625. let tempArr = [];
  626. result.data.forEach((item) => {
  627. item.value = item.id;
  628. item.text = item.name;
  629. tempArr.push(item);
  630. });
  631. this.loadData.teacherSchool = tempArr;
  632. sheetForm.columns = tempArr;
  633. sheetForm.loading = false;
  634. } else {
  635. this.$toast("暂无教学点");
  636. sheetForm.loading = false;
  637. }
  638. });
  639. }
  640. },
  641. onSheetConfirm(value, index) {
  642. // 上拉弹窗
  643. let sheetForm = this.sheetForm,
  644. form = this.form,
  645. formName = this.formName,
  646. loadData = this.loadData;
  647. if (sheetForm.currentType == "subjectList") {
  648. // 科目名称赋值
  649. form.subjectIdList = value.value;
  650. formName.subjectListName = value.text;
  651. formName.subjectListIndex = index;
  652. loadData.subjectListSelect = value;
  653. // 重置上课学生
  654. this.dataList = []
  655. this.params.search = null
  656. this.loading = false
  657. this.finished = false
  658. this.dataShow = true
  659. this.params.page = 1
  660. this.checkboxSelect = [];
  661. this.checkboxSelectIds = [];
  662. this.checkboxSelectList = []; //选中学生列表
  663. this.checkboxSelectDataList = [];
  664. } else if(sheetForm.currentType == "vipGroupCategory") {
  665. form.vipGroupCategoryId = value.value;
  666. formName.vipGroupCategoryName = value.text;
  667. if(value.studentNum == 1){
  668. this.activityCourseType = 'vip1'
  669. }else if(value.studentNum == 2){
  670. this.activityCourseType = 'vip2'
  671. }
  672. formName.vipGroupCategoryIndex = index;
  673. loadData.vipGroupCategorySelect = value;
  674. form.studentNum = value.studentNum; // 每班人数
  675. // form.singleClassMinutes = value.singleClassMinutes // 每课时长
  676. form.onlineClassesUnitPrice = Math.ceil(value.onlineClassesUnitPrice);
  677. form.offlineClassesUnitPrice = Math.ceil(value.offlineClassesUnitPrice);
  678. // 每课时长赋值
  679. form.singleClassMinutes = null;
  680. loadData.classTimer = [];
  681. let tempSingle = value.singleClassMinutes.split(",");
  682. form.singleClassMinutes = tempSingle.length > 0 ? tempSingle[0] : null
  683. tempSingle.forEach((item) => {
  684. this.loadData.classTimer.push({
  685. name: item,
  686. value: item,
  687. });
  688. });
  689. // 重置上课学生
  690. this.dataList = []
  691. this.params.search = null
  692. this.loading = false
  693. this.finished = false
  694. this.dataShow = true
  695. this.params.page = 1
  696. this.checkboxSelect = [];
  697. this.checkboxSelectIds = [];
  698. this.checkboxSelectList = []; //选中学生列表
  699. this.checkboxSelectDataList = [];
  700. // 重置活动文案
  701. form.vipGroupActivityId = null;
  702. formName.vipGroupActivityName = null;
  703. formName.vipGroupActivityIndex = 0;
  704. loadData.vipGroupActivity = [];
  705. loadData.vipGroupActivitySelect = [];
  706. this.scheduleList = []
  707. this.timeTable = []
  708. } else if (sheetForm.currentType == "vipGroupActivity") {
  709. // 活动方案赋值
  710. // 重置线上课,线下课次数
  711. if (form.vipGroupActivityId != value.value) {
  712. form.offlineClassesNums = null;
  713. form.onlineClassesNums = null;
  714. }
  715. form.vipGroupActivityId = value.value;
  716. formName.vipGroupActivityName = value.text;
  717. formName.vipGroupActivityIndex = index;
  718. if(value.maxCourseNum <= 0) {
  719. value.maxCourseNum = 0
  720. }
  721. loadData.vipGroupActivitySelect = value;
  722. // 换活动之后单价重置
  723. form.onlineClassesUnitPrice = Math.ceil(
  724. loadData.vipGroupCategorySelect.onlineClassesUnitPrice
  725. );
  726. form.offlineClassesUnitPrice = Math.ceil(
  727. loadData.vipGroupCategorySelect.offlineClassesUnitPrice
  728. );
  729. this.onCalcClassTimes(value); // 计算时间等.........
  730. // this.getCalcClass(); // 课酬计算
  731. this.setTimeTable(); // 重新排课
  732. // 时间安排
  733. // form.registrationStartTime = value.startTime
  734. // form.coursesExpireDate = value.endTime
  735. } else if (sheetForm.currentType == "teacherSchool") {
  736. // 线下课地址
  737. form.teacherSchoolId = value.value;
  738. formName.teacherSchoolName = value.text;
  739. formName.teacherSchoolIndex = index;
  740. }
  741. sheetForm.sheetStatus = false;
  742. },
  743. onClassKeyUp(type) {
  744. // 线上课&线下课修改时
  745. if (type == "offLine" && this.form.offlineClassesNums <= 0) {
  746. this.form.teacherSchoolId = null;
  747. this.formName.teacherSchoolName = null;
  748. this.formName.teacherSchoolIndex = 0;
  749. }
  750. let vas = this.loadData.vipGroupActivitySelect;
  751. this.onCalcClassTimes(vas);
  752. // this.getCalcClass();
  753. this.setTimeTable();
  754. },
  755. onCalcClassTimes(vas) {
  756. // 计算课时总数
  757. let form = this.form,
  758. other = this.other,
  759. statusList = this.statusList;
  760. let totalCount =
  761. Number(form.onlineClassesNums) + Number(form.offlineClassesNums);
  762. // ...
  763. if (vas.salarySettlementJson) {
  764. let obj = JSON.parse(vas.salarySettlementJson);
  765. if (obj && obj.onlineSalarySettlement) {
  766. // 有线上课
  767. statusList.hasOnline = true;
  768. } else {
  769. statusList.hasOnline = false;
  770. }
  771. if (obj && obj.offlineSalarySettlement) {
  772. // 有线下课
  773. statusList.hasOffline = true;
  774. } else {
  775. statusList.hasOffline = false;
  776. }
  777. }
  778. if (vas.type == "GIVE_CLASS") {
  779. // 买赠活动
  780. this.statusList.teachOnOrOff = true; // 显示赠课
  781. if (totalCount >= Number(vas.attribute1)) {
  782. form.totalClassTime = totalCount + "+" + vas.attribute2;
  783. other.giveNum = vas.attribute2;
  784. } else {
  785. form.totalClassTime = totalCount;
  786. other.giveNum = 0;
  787. }
  788. } else {
  789. // 折扣活动
  790. form.totalClassTime = totalCount;
  791. other.giveNum = 0;
  792. this.statusList.teachOnOrOff = false; // 隐藏赠课
  793. }
  794. },
  795. onModeSelect(value) {
  796. // 赠课确认
  797. this.form.giveTeachMode = value.value;
  798. this.formName.giveTeachModeName = value.name;
  799. this.statusList.giveTeachModeStatus = false;
  800. // this.getCalcClass();
  801. },
  802. onClickSingleClass() {
  803. if (!this.formName.vipGroupCategoryName) {
  804. this.$toast("请选择课程形式");
  805. return;
  806. }
  807. this.statusList.classTimerStatus = true;
  808. },
  809. onClassTimerSelect(value) {
  810. // 每课时长设置
  811. if(this.form.singleClassMinutes != value.value) {
  812. this.timeTable = [] // 生成的课表
  813. this.scheduleList = []
  814. }
  815. this.form.singleClassMinutes = value.value;
  816. this.statusList.classTimerStatus = false;
  817. // this.getCalcClass();
  818. },
  819. onCurrentConfirm(value) {
  820. // 排课开始时间
  821. let selectDate = new Date(value);
  822. let tempMonth =
  823. selectDate.getMonth() + 1 >= 10
  824. ? selectDate.getMonth() + 1
  825. : "0" + (selectDate.getMonth() + 1);
  826. let tempDay =
  827. selectDate.getDate() >= 10
  828. ? selectDate.getDate()
  829. : "0" + selectDate.getDate();
  830. this.form.courseStart =
  831. selectDate.getFullYear() + "-" + tempMonth + "-" + tempDay;
  832. this.dataForm.status = false;
  833. },
  834. onEnlistConfirm(value) {
  835. // 报名开始/结束时间
  836. let selectDate = new Date(value);
  837. let tempMonth =
  838. selectDate.getMonth() + 1 >= 10
  839. ? selectDate.getMonth() + 1
  840. : "0" + (selectDate.getMonth() + 1);
  841. let tempDay =
  842. selectDate.getDate() >= 10
  843. ? selectDate.getDate()
  844. : "0" + selectDate.getDate();
  845. let enlistForm = this.enlistForm;
  846. let form = this.form;
  847. if (enlistForm.updateStatus == "start") {
  848. form.registrationStartTime =
  849. selectDate.getFullYear() + "-" + tempMonth + "-" + tempDay;
  850. if (form.coursesExpireDate) {
  851. let temps = new Date(
  852. form.registrationStartTime.replace(/-/gi, "/")
  853. ).getTime();
  854. let tempe = new Date(
  855. form.coursesExpireDate.replace(/-/gi, "/")
  856. ).getTime();
  857. // 如果开始时间大于结束时间,结束时间制空
  858. if (temps > tempe) {
  859. form.coursesExpireDate = null;
  860. }
  861. }
  862. } else if (enlistForm.updateStatus == "end") {
  863. form.coursesExpireDate =
  864. selectDate.getFullYear() + "-" + tempMonth + "-" + tempDay;
  865. }
  866. enlistForm.status = false;
  867. },
  868. onEnListShow(type, value) {
  869. // 报名开始/截止时间
  870. let enlistForm = this.enlistForm;
  871. if (type == "end") {
  872. if (this.form.registrationStartTime) {
  873. enlistForm.minDate = new Date(
  874. this.form.registrationStartTime.replace(/-/gi, "/")
  875. );
  876. } else {
  877. enlistForm.minDate = new Date();
  878. }
  879. } else if (type == "start") {
  880. // 开始时默认为当前时间
  881. enlistForm.minDate = new Date();
  882. }
  883. if (value) {
  884. enlistForm.currentDate = new Date(value.replace(/-/gi, "/"));
  885. } else {
  886. enlistForm.currentDate = new Date();
  887. }
  888. enlistForm.updateStatus = type;
  889. enlistForm.status = true;
  890. },
  891. onCourseShedule() {
  892. // 课时安排
  893. if (!this.form.singleClassMinutes) {
  894. this.$toast("请选每课时长");
  895. return;
  896. }
  897. if (this.other.giveNum > 0 && !this.form.giveTeachMode) {
  898. this.$toast("请选择赠课类型");
  899. return;
  900. }
  901. if (!this.form.courseStart) {
  902. this.$toast("请选择排课开始时间");
  903. return;
  904. }
  905. this.courseForm.teachingStatus = true;
  906. },
  907. onScheduleRemove(item) {
  908. // 删除课程安排
  909. let index = this.scheduleList.indexOf(item);
  910. if (index !== -1) {
  911. this.scheduleList.splice(index, 1);
  912. }
  913. },
  914. onTeachinConfirm(value) {
  915. // 添加课程
  916. let scheduleList = this.scheduleList;
  917. let startTime =
  918. (value[2] >= 10 ? value[2] : "0" + value[2]) +
  919. ":" +
  920. value[3].split("分")[0];
  921. let endTime = this.MinutesTest(
  922. value[2],
  923. value[3],
  924. this.form.singleClassMinutes
  925. );
  926. let isAdd = true;
  927. scheduleList.forEach((item) => {
  928. let isStartTime = this.timeIsrange(startTime, endTime, item.startTime);
  929. let isEndTime = this.timeIsrange(startTime, endTime, item.endTime);
  930. if (isAdd) {
  931. //
  932. if (value[1] == item.weekStr) {
  933. if (isStartTime || isEndTime) {
  934. isAdd = false;
  935. } else {
  936. isAdd = true;
  937. }
  938. } else if (value[1] != item.weekStr) {
  939. isAdd = true;
  940. }
  941. }
  942. });
  943. if (isAdd) {
  944. // 判断时间范围是否有重复
  945. scheduleList.push({
  946. type: value[0], // 线上还是线下
  947. weekStr: value[1],
  948. weekIndex: this.getWeek(value[1]),
  949. startTime: startTime,
  950. endTime: endTime,
  951. id: Date.now(),
  952. });
  953. this.courseForm.teachingStatus = false;
  954. this.setTimeTable();
  955. } else {
  956. this.$toast("该时间段已排课请重选时间");
  957. return;
  958. }
  959. },
  960. onShowTimeTable() {
  961. // 显示排课列表
  962. if (!this.checkCourseList()) {
  963. return;
  964. }
  965. this.statusList.classTime = true;
  966. this.setTimeTable();
  967. },
  968. setTimeTable() {
  969. if (!this.checkCourseList(false)) {
  970. return;
  971. }
  972. // return
  973. // 重置排课列表
  974. this.timeTable = [];
  975. let form = this.form,
  976. scheduleList = this.scheduleList;
  977. // if(!form.courseStart) {
  978. // this.$toast('请选择排课开始时间')
  979. // return
  980. // }
  981. // 拿到线上课数与线下课数 以及
  982. let online = parseInt(
  983. form.onlineClassesNums ? form.onlineClassesNums : 0
  984. );
  985. let offline = parseInt(
  986. form.offlineClassesNums ? form.offlineClassesNums : 0
  987. );
  988. let giveNum = parseInt(this.other.giveNum);
  989. let giveClassType = form.giveTeachMode;
  990. if (giveClassType == "ONLINE") {
  991. // 线上
  992. online += giveNum;
  993. } else if (giveClassType == "OFFLINE") {
  994. offline += giveNum;
  995. }
  996. // 判断是否有课程安排
  997. if (scheduleList.length <= 0) {
  998. return;
  999. }
  1000. let totalCount = Number(online) + Number(offline);
  1001. let tempCourseStart = form.courseStart.replace(/-/gi, "/");
  1002. let dateOperation = new Date(tempCourseStart);
  1003. let forMark = 0;
  1004. while (totalCount && totalCount > 0) {
  1005. for (let i = 0; i < scheduleList.length; i++) {
  1006. // console.log(totalCount, scheduleList)
  1007. if (online == 0 && offline == 0) break;
  1008. let num = scheduleList[i].weekIndex - dateOperation.getDay();
  1009. // 如果是同一天一个周期会出现排课都排到一天
  1010. if (forMark > 0 && num == 0 && i == 0) {
  1011. num = num + 7;
  1012. }
  1013. if (num < 0) {
  1014. // 如果为负数则为下周
  1015. num = num + 7;
  1016. }
  1017. let dataStr = this.getThinkDate(dateOperation, num);
  1018. // 判断是否大于当前时间
  1019. let nowGetTime = new Date().getTime();
  1020. let courseTime = new Date(
  1021. dataStr.replace(/-/gi, "/") +
  1022. " " +
  1023. scheduleList[i].startTime +
  1024. ":00"
  1025. ).getTime();
  1026. if (nowGetTime < courseTime) {
  1027. let tempArr = {
  1028. classDate: dataStr,
  1029. startClassTimeStr: scheduleList[i].startTime,
  1030. endClassTimeStr: scheduleList[i].endTime,
  1031. };
  1032. // console.log(scheduleList[i].type, online, offline)
  1033. if (scheduleList[i].type == "线上" && online > 0) {
  1034. tempArr.teachMode = "ONLINE";
  1035. this.timeTable.push(tempArr);
  1036. online--;
  1037. totalCount--;
  1038. } else if (scheduleList[i].type == "线下" && offline > 0) {
  1039. tempArr.teachMode = "OFFLINE";
  1040. this.timeTable.push(tempArr);
  1041. offline--;
  1042. totalCount--;
  1043. }
  1044. }
  1045. }
  1046. // 加一周
  1047. if (scheduleList.length == 1) {
  1048. dateOperation.setDate(dateOperation.getDate() + 7);
  1049. } else if (
  1050. scheduleList.every((item) => item.weekStr === scheduleList[0].weekStr)
  1051. ) {
  1052. // 标记循环次数(标记判断课程安排是不是同一天)
  1053. forMark++;
  1054. }
  1055. }
  1056. this.timeTable.sort((a, b) => {
  1057. let aStr = dayjs(
  1058. dayjs(a.classDate).format("YYYY-MM-DD") +
  1059. " " +
  1060. a.startClassTimeStr +
  1061. ":00"
  1062. ).valueOf();
  1063. let bStr = dayjs(
  1064. dayjs(b.classDate).format("YYYY-MM-DD") +
  1065. " " +
  1066. b.startClassTimeStr +
  1067. ":00"
  1068. ).valueOf();
  1069. return aStr - bStr;
  1070. });
  1071. },
  1072. onGiveMode() {
  1073. // 赠送课改变时
  1074. this.statusList.giveTeachModeStatus = true;
  1075. // this.getCalcClass();
  1076. },
  1077. getCalcClass() {
  1078. // 计算课酬
  1079. let loadData = this.loadData;
  1080. let form = this.form;
  1081. let vas = loadData.vipGroupActivitySelect, // 活动
  1082. // vcs = loadData.vipGroupCategorySelect, // 课程形式
  1083. tc = loadData.teacherCategory, // 老师基本信息
  1084. oncn = form.onlineClassesNums ? form.onlineClassesNums : 0, // 线上课次数
  1085. offcn = form.offlineClassesNums ? form.offlineClassesNums : 0, // 线下课次数
  1086. giveNum = parseInt(this.other.giveNum),
  1087. giveTeachMode = form.giveTeachMode; // 线下或线下
  1088. // 优惠活动
  1089. // ...
  1090. if (vas.salarySettlementJson) {
  1091. let obj = JSON.parse(vas.salarySettlementJson);
  1092. // 获取每课时长
  1093. // 每45Min计算一些课酬
  1094. // let b = form.singleClassMinutes ? (form.singleClassMinutes / 45) : 0
  1095. let tempPrice = 0;
  1096. if (Number(oncn) + Number(offcn) > 0) {
  1097. let countPrice =
  1098. oncn * form.onlineClassesUnitPrice +
  1099. offcn * form.offlineClassesUnitPrice;
  1100. if (giveNum > 0 && !giveTeachMode) {
  1101. countPrice = 0;
  1102. }
  1103. tempPrice =
  1104. (countPrice * form.studentNum) /
  1105. (Number(oncn) + Number(offcn) + Number(giveNum));
  1106. if (vas.type == "DISCOUNT") {
  1107. tempPrice =
  1108. (tempPrice * (vas.attribute1 ? Number(vas.attribute1) : 100)) /
  1109. 100;
  1110. }
  1111. }
  1112. // 课程按课来计算
  1113. if (obj && obj.onlineSalarySettlement) {
  1114. let onss = obj.onlineSalarySettlement;
  1115. // 有线上课
  1116. if (onss.salarySettlementType == "TEACHER_DEFAULT") {
  1117. form.onlineTeacherSalary = Math.round(tc.offlineClassesSalary); // 线上课酬
  1118. } else if (onss.salarySettlementType == "RATIO_DISCOUNT") {
  1119. // 老师课酬的折扣 如果有则不打折
  1120. // form.onlineTeacherSalary = Math.round(vcs.onlineClassesUnitPrice * (onss.settlementValue ? onss.settlementValue : 100) / 100)
  1121. form.onlineTeacherSalary = Math.round(
  1122. tempPrice
  1123. ? (tempPrice *
  1124. (onss.settlementValue ? onss.settlementValue : 100)) /
  1125. 100
  1126. : 0
  1127. );
  1128. } else if (onss.salarySettlementType == "FIXED_SALARY") {
  1129. form.onlineTeacherSalary = Math.round(onss.settlementValue);
  1130. }
  1131. form.onlineTeacherSalary = Number(form.onlineTeacherSalary);
  1132. } else {
  1133. form.onlineTeacherSalary = Math.round(tc.offlineClassesSalary);
  1134. }
  1135. if (obj && obj.offlineSalarySettlement) {
  1136. let offss = obj.offlineSalarySettlement;
  1137. // 有线下课
  1138. if (offss.salarySettlementType == "TEACHER_DEFAULT") {
  1139. form.offlineTeacherSalary = Math.round(tc.offlineClassesSalary); // 线上课酬
  1140. } else if (offss.salarySettlementType == "RATIO_DISCOUNT") {
  1141. // 老师课酬的折扣
  1142. // form.offlineTeacherSalary = Math.round((vcs.offlineClassesUnitPrice * (offss.settlementValue ? offss.settlementValue : 100) / 100))
  1143. form.offlineTeacherSalary = Math.round(
  1144. tempPrice
  1145. ? (tempPrice *
  1146. (offss.settlementValue ? offss.settlementValue : 100)) /
  1147. 100
  1148. : 0
  1149. );
  1150. } else if (offss.salarySettlementType == "FIXED_SALARY") {
  1151. form.offlineTeacherSalary = Math.round(offss.settlementValue);
  1152. }
  1153. form.offlineTeacherSalary = Number(form.offlineTeacherSalary);
  1154. } else {
  1155. form.offlineTeacherSalary = Math.round(tc.offlineClassesSalary);
  1156. }
  1157. }
  1158. if (vas.type == "GIVE_CLASS" || vas.type == "BASE_ACTIVITY") {
  1159. form.totalCount = Math.round(
  1160. oncn * form.onlineClassesUnitPrice +
  1161. offcn * form.offlineClassesUnitPrice
  1162. );
  1163. } else if (vas.type == "DISCOUNT") {
  1164. form.totalCount = Math.round(
  1165. ((oncn * form.onlineClassesUnitPrice +
  1166. offcn * form.offlineClassesUnitPrice) *
  1167. Number(vas.attribute1)) /
  1168. 100
  1169. );
  1170. }
  1171. form.totalCount = Number(form.totalCount);
  1172. },
  1173. getThinkDate(date, num) {
  1174. let Stamp = date;
  1175. Stamp.setDate(date.getDate() + num); // 获取当前月数的第几天
  1176. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  1177. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  1178. var mvar = "";
  1179. if (month < 10) {
  1180. mvar = "0" + month;
  1181. } else {
  1182. mvar = month + "";
  1183. }
  1184. var day = Stamp.getDate();
  1185. var dvar = "";
  1186. if (day < 10) {
  1187. dvar = "0" + day;
  1188. } else {
  1189. dvar = day + "";
  1190. }
  1191. return year + "-" + mvar + "-" + dvar;
  1192. },
  1193. // 分钟小时相加减
  1194. MinutesTest(houer, mins, interval) {
  1195. let min = mins.split("分")[0];
  1196. let sdate1 = new Date(1900, 1, 1, houer, min);
  1197. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  1198. let H = sdate1.getHours();
  1199. let M = sdate1.getMinutes();
  1200. if (H < 10) H = "0" + H;
  1201. if (M < 10) M = "0" + M;
  1202. return H + ":" + M;
  1203. },
  1204. // 判断时间是否在时间段内
  1205. timeIsrange(beginTime, endTime, nowTime) {
  1206. var strb = beginTime.split(":");
  1207. if (strb.length != 2) {
  1208. return false;
  1209. }
  1210. var stre = endTime.split(":");
  1211. if (stre.length != 2) {
  1212. return false;
  1213. }
  1214. var strn = nowTime.split(":");
  1215. if (stre.length != 2) {
  1216. return false;
  1217. }
  1218. var b = new Date();
  1219. var e = new Date();
  1220. var n = new Date();
  1221. b.setHours(strb[0]);
  1222. b.setMinutes(strb[1]);
  1223. e.setHours(stre[0]);
  1224. e.setMinutes(stre[1]);
  1225. n.setHours(strn[0]);
  1226. n.setMinutes(strn[1]);
  1227. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  1228. // 在时间范围内
  1229. return true;
  1230. } else {
  1231. // 不在时间范围内
  1232. return false;
  1233. }
  1234. },
  1235. getWeek(str) {
  1236. // 获取周几索引值
  1237. let template = {
  1238. '周一': 1,
  1239. '周二': 2,
  1240. '周三': 3,
  1241. '周四': 4,
  1242. '周五': 5,
  1243. '周六': 6,
  1244. '周日': 0,
  1245. };
  1246. return template[str];
  1247. },
  1248. async onSubmit() {
  1249. // 次数限制是否可以继续创建
  1250. let form = this.form;
  1251. let statusList = this.statusList;
  1252. if (!form.subjectIdList) {
  1253. this.$toast("请选择课程声部");
  1254. return false;
  1255. }
  1256. if (!form.vipGroupCategoryId) {
  1257. this.$toast("请选择课程形式");
  1258. return false;
  1259. }
  1260. if (this.checkboxSelectIds.length <= 0) {
  1261. this.$toast("请选择上课学生");
  1262. return;
  1263. }
  1264. if (!form.vipGroupActivityId) {
  1265. this.$toast("请选择活动方案");
  1266. return false;
  1267. }
  1268. if (!form.singleClassMinutes) {
  1269. this.$toast("请选择每课时长");
  1270. return false;
  1271. }
  1272. let onlineClassesStatus =
  1273. !form.onlineClassesNums && form.onlineClassesNums <= 0 ? true : false
  1274. let offlineClassesStatus =
  1275. !form.offlineClassesNums && form.offlineClassesNums <= 0 ? true : false
  1276. if (statusList.hasOnline) {
  1277. if (onlineClassesStatus) {
  1278. this.$toast("请输入线上课次数");
  1279. return false;
  1280. }
  1281. }
  1282. if (statusList.hasOffline) {
  1283. if (offlineClassesStatus) {
  1284. this.$toast("请输入线下课次数");
  1285. return false;
  1286. }
  1287. // 判断是否有线下
  1288. if (form.offlineClassesNums > 0 && !form.teacherSchoolId) {
  1289. this.$toast("请选择线下课地址");
  1290. return false;
  1291. }
  1292. }
  1293. let vipGroupActivitySelect = this.loadData.vipGroupActivitySelect
  1294. if (vipGroupActivitySelect.type == "GIVE_CLASS" && !form.giveTeachMode) {
  1295. this.$toast("请选择赠课类型");
  1296. return false;
  1297. }
  1298. if (this.scheduleList.length <= 0) {
  1299. this.$toast("课时安排不能为空");
  1300. return false;
  1301. }
  1302. if(vipGroupActivitySelect.maxCourseNum > 0) {
  1303. let tempCourseCount = parseInt(form.onlineClassesNums) + parseInt(form.offlineClassesNums);
  1304. if(tempCourseCount != vipGroupActivitySelect.maxCourseNum) {
  1305. this.$toast(`课时总数为${vipGroupActivitySelect.maxCourseNum}节`)
  1306. return
  1307. }
  1308. }
  1309. if(vipGroupActivitySelect.maxCourseNum <= 0) {
  1310. this.$toast('当前选择活动有误,请选择其它活动')
  1311. return
  1312. }
  1313. if (!this.checkCourseList()) {
  1314. return;
  1315. }
  1316. // 排课
  1317. this.setTimeTable();
  1318. if (form.giveTeachMode == "ONLINE") {
  1319. form.onlineClassesNum =
  1320. Number(form.onlineClassesNums) + Number(this.other.giveNum);
  1321. form.offlineClassesNum = Number(form.offlineClassesNums);
  1322. } else {
  1323. form.onlineClassesNum = Number(form.onlineClassesNums);
  1324. form.offlineClassesNum =
  1325. Number(form.offlineClassesNums) + Number(this.other.giveNum);
  1326. }
  1327. form.totalClassTimes =
  1328. Number(form.onlineClassesNums) +
  1329. Number(form.offlineClassesNums) +
  1330. Number(this.other.giveNum);
  1331. form.paymentExpireDate = form.coursesExpireDate;
  1332. form.studentIdList = this.checkboxSelectIds.join(",");
  1333. form.firstStudentId =
  1334. this.checkboxSelectDataList.length > 0
  1335. ? this.checkboxSelectDataList[0].userId
  1336. : null;
  1337. let params = {
  1338. courseSchedules: this.timeTable,
  1339. vipGroupApplyBaseInfo: {
  1340. ...form,
  1341. userId: this.teacherId,
  1342. activityCourseType: this.activityCourseType,
  1343. },
  1344. };
  1345. if (!this.onSubmitStatus) {
  1346. return;
  1347. }
  1348. this.onSubmitStatus = false;
  1349. setLoading(true);
  1350. await createActivityVipGroup(params)
  1351. .then((res) => {
  1352. let result = res.data;
  1353. setLoading(false);
  1354. if (result.code == 200) {
  1355. this.$toast("申请成功");
  1356. setTimeout(() => {
  1357. this.onSubmitStatus = true;
  1358. if (browser().iPhone) {
  1359. window.webkit.messageHandlers.DAYA.postMessage(
  1360. JSON.stringify({
  1361. api: "back",
  1362. })
  1363. );
  1364. } else if (browser().android) {
  1365. DAYA.postMessage(
  1366. JSON.stringify({
  1367. api: "back",
  1368. })
  1369. );
  1370. } else {
  1371. this.$router.push("/business");
  1372. }
  1373. }, 500);
  1374. } else {
  1375. this.onSubmitStatus = true;
  1376. this.$toast(result.msg);
  1377. }
  1378. })
  1379. .catch(() => {
  1380. this.onSubmitStatus = true;
  1381. setLoading(false);
  1382. });
  1383. },
  1384. checkCourseList(isShowToast = true) {
  1385. let form = this.form;
  1386. let scheduleList = this.scheduleList || [];
  1387. let hasOnLine = false; // 是否有线上课时安排
  1388. let hasOffLine = false;
  1389. scheduleList.forEach((item) => {
  1390. if (item.type == "线上") {
  1391. hasOnLine = true;
  1392. }
  1393. if (item.type == "线下") {
  1394. hasOffLine = true;
  1395. }
  1396. });
  1397. let statusList = this.statusList;
  1398. let onlineClassesStatus =
  1399. !form.onlineClassesNums && form.onlineClassesNums <= 0 ? true : false;
  1400. let offlineClassesStatus =
  1401. !form.offlineClassesNums && form.offlineClassesNums <= 0 ? true : false;
  1402. if (statusList.hasOnline) {
  1403. if (onlineClassesStatus) {
  1404. if (isShowToast) {
  1405. this.$toast("请输入线上课次数");
  1406. }
  1407. return false;
  1408. }
  1409. if (!onlineClassesStatus && !hasOnLine && form.onlineClassesNums > 0) {
  1410. if (isShowToast) {
  1411. this.$toast("课时安排缺少线上课类型");
  1412. }
  1413. return false;
  1414. }
  1415. } else {
  1416. return false;
  1417. }
  1418. if (statusList.hasOffline) {
  1419. if (offlineClassesStatus) {
  1420. if (isShowToast) {
  1421. this.$toast("请输入线下课次数");
  1422. }
  1423. return false;
  1424. }
  1425. if (
  1426. !offlineClassesStatus &&
  1427. !hasOffLine &&
  1428. form.offlineClassesNums > 0
  1429. ) {
  1430. if (isShowToast) {
  1431. this.$toast("课时安排缺少线下课类型");
  1432. }
  1433. return false;
  1434. }
  1435. } else {
  1436. return false;
  1437. }
  1438. return true;
  1439. },
  1440. // 搜索
  1441. onSearch() {
  1442. this.params.page = 1;
  1443. this.dataList = [];
  1444. this.dataShow = true;
  1445. this.loading = true;
  1446. this.finished = false;
  1447. this.getStudent();
  1448. },
  1449. getStudent() {
  1450. let params = this.params;
  1451. getStudents(cleanDeep({
  1452. ...params,
  1453. activityCourseType: this.activityCourseType,
  1454. subjectId:this.form.subjectIdList
  1455. })).then((res) => {
  1456. let result = res.data;
  1457. this.loading = false;
  1458. if (result.code == 200) {
  1459. if(this.dataList.length > 0 && result.data.pageNo == 1) {
  1460. return
  1461. }
  1462. params.page = result.data.pageNo;
  1463. this.dataList = this.dataList.concat(result.data.rows);
  1464. if (params.page >= result.data.totalPage) {
  1465. this.finished = true;
  1466. }
  1467. this.params.page++;
  1468. } else {
  1469. this.finished = true;
  1470. }
  1471. // 判断是否有数据
  1472. if (this.dataList.length <= 0) {
  1473. this.dataShow = false;
  1474. }
  1475. });
  1476. },
  1477. onPopupCancel() {
  1478. // 关闭弹窗
  1479. this.statusList.studentStatus = false;
  1480. // this.params.search = null
  1481. this.checkboxSelect = [];
  1482. this.checkboxSelectList = [];
  1483. },
  1484. onPopupSubmit() {
  1485. const vipGroupCategorySelect = this.loadData.vipGroupCategorySelect;
  1486. if (this.checkboxSelect.length != vipGroupCategorySelect.studentNum) {
  1487. this.$toast(
  1488. `请选择学生${vipGroupCategorySelect.studentNum}名,当前选择${this.checkboxSelect.length}名`
  1489. );
  1490. return;
  1491. }
  1492. this.checkboxSelectDataList = JSON.parse(
  1493. JSON.stringify(this.checkboxSelectList)
  1494. );
  1495. this.checkboxSelectIds = JSON.parse(JSON.stringify(this.checkboxSelect));
  1496. this.checkboxSelect = [];
  1497. this.checkboxSelectList = [];
  1498. this.loadData.vipGroupActivity = [];
  1499. this.formName.vipGroupActivityName = null;
  1500. this.formName.vipGroupCategoryIndex = 0;
  1501. this.form.vipGroupActivityId = null;
  1502. this.statusList.studentStatus = false;
  1503. },
  1504. onCheckboxSelect(value) {
  1505. if (this.checkboxSelect.includes(value.userId.toString())) {
  1506. this.checkboxSelect.forEach((item, index) => {
  1507. if (item == value.userId.toString()) {
  1508. this.checkboxSelect.splice(index, 1);
  1509. }
  1510. });
  1511. this.checkboxSelectList.forEach((item, index) => {
  1512. if (item.userId == value.userId) {
  1513. this.checkboxSelectList.splice(index, 1);
  1514. }
  1515. });
  1516. } else {
  1517. this.checkboxSelect.push(value.userId.toString());
  1518. this.checkboxSelectList.push(value);
  1519. }
  1520. // checkboxSelect = item.userId
  1521. },
  1522. desensitPhone(phone) {
  1523. // 手机号脱敏
  1524. let first = phone.substr(0, 3);
  1525. let last = phone.substr(-4);
  1526. return first + "****" + last;
  1527. },
  1528. }
  1529. };
  1530. </script>
  1531. <style lang="less" scoped>
  1532. // .vipCourse {
  1533. // min-height: calc(100vh - 44px - 0.44rem);
  1534. // }
  1535. @import url("../../../assets/commonLess/variable.less");
  1536. .studentContainer {
  1537. /deep/.van-cell__title {
  1538. font-size: 0.14rem;
  1539. color: @mFontColor;
  1540. flex: 1 auto;
  1541. }
  1542. .logo {
  1543. width: 0.35rem;
  1544. height: 0.35rem;
  1545. margin-right: 0.12rem;
  1546. border-radius: 100%;
  1547. }
  1548. .input-cell {
  1549. padding: 0.12rem 0.16rem 0.2rem;
  1550. .van-checkbox {
  1551. justify-content: flex-end;
  1552. }
  1553. }
  1554. /deep/.van-cell__value {
  1555. height: 0.2rem;
  1556. }
  1557. /deep/.van-checkbox__icon .van-icon {
  1558. border-color: @sFontColor;
  1559. }
  1560. /deep/.van-checkbox__icon--checked .van-icon {
  1561. border-color: #01C1B5;
  1562. }
  1563. .van-tag {
  1564. margin-left: 0.08rem;
  1565. }
  1566. }
  1567. .title-time {
  1568. display: flex;
  1569. align-items: center;
  1570. flex: 1 auto;
  1571. color: #4a4a4a;
  1572. .online {
  1573. color: @tFontColor;
  1574. }
  1575. .week {
  1576. padding-left: 0.4rem;
  1577. padding-right: 0.15rem;
  1578. }
  1579. }
  1580. .van-row {
  1581. line-height: 0.4rem;
  1582. border-top: 1px solid #edeef0;
  1583. text-align: center;
  1584. font-size: 0.14rem;
  1585. &:first-child {
  1586. border-top: 0;
  1587. background: #edeef0;
  1588. color: #444;
  1589. font-size: 0.15rem;
  1590. }
  1591. }
  1592. .tableContainer {
  1593. max-height: 2.44rem;
  1594. overflow: auto;
  1595. .van-row {
  1596. color: #444;
  1597. &:first-child {
  1598. border-top: 0;
  1599. background: #fff;
  1600. font-size: 0.14rem;
  1601. }
  1602. }
  1603. }
  1604. .button-group-popup {
  1605. position: fixed;
  1606. bottom: 0;
  1607. padding: 0.2rem 0;
  1608. width: 100%;
  1609. text-align: center;
  1610. background-color: #ffffff;
  1611. .btn {
  1612. padding: 0 0.45rem;
  1613. line-height: 0.4rem;
  1614. display: inline-block;
  1615. border: 1px solid @mColor;
  1616. border-radius: 1rem;
  1617. color: @mColor;
  1618. background: #fff;
  1619. font-size: 0.18rem;
  1620. &.primary {
  1621. color: #fff;
  1622. background: @mColor;
  1623. }
  1624. }
  1625. .btn + .btn {
  1626. margin-left: 0.1rem;
  1627. }
  1628. }
  1629. .add-plan {
  1630. display: flex;
  1631. align-items: center;
  1632. justify-content: center;
  1633. padding: 0.2rem 0;
  1634. font-size: 0.16rem;
  1635. color: @tFontColor;
  1636. .van-icon {
  1637. margin-right: 0.05rem;
  1638. font-size: 0.2rem;
  1639. }
  1640. }
  1641. /deep/.van-cell__title {
  1642. -webkit-box-flex: 0;
  1643. -webkit-flex: none;
  1644. flex: none;
  1645. box-sizing: border-box;
  1646. margin-right: 12px;
  1647. color: #646566;
  1648. text-align: left;
  1649. word-wrap: break-word;
  1650. font-size: 14px;
  1651. }
  1652. .studentColor {
  1653. color: @mColor !important;
  1654. }
  1655. .courseStudent {
  1656. .van-cell__value {
  1657. color: #c8c9cc;
  1658. }
  1659. }
  1660. .paddingB80 {
  1661. padding-bottom: .8rem;
  1662. }
  1663. /deep/.van-field__control {
  1664. font-size: 14px;
  1665. }
  1666. /deep/.studentChiose {
  1667. border-radius: 0 0 0px 0px;
  1668. overflow: auto;
  1669. }
  1670. </style>