index.vue 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header
  5. @back="onCancel"
  6. content="VIP/乐理课申请"
  7. ></el-page-header>
  8. <!-- <div class="squrt" /> -->
  9. </h2>
  10. <div class="m-core">
  11. <div class="vipLeft">
  12. <el-alert
  13. title="课程信息"
  14. type="info"
  15. :closable="false"
  16. class="vipMsg"
  17. ></el-alert>
  18. <el-form
  19. ref="leftForm"
  20. :inline="true"
  21. :rules="leftFormRules"
  22. :label-position="labelPosition"
  23. label-width="110px"
  24. :model="leftForm"
  25. >
  26. <!-- <el-form-item label="课程名称" prop="name">
  27. <el-input v-model.trim="leftForm.name" />
  28. </el-form-item> -->
  29. <!-- :disabled="!leftForm.teacher || !leftForm.educationalTeacherId" -->
  30. <el-form-item label="课程分部" prop="classOrganId">
  31. <el-select
  32. v-model.trim="leftForm.classOrganId"
  33. filterable
  34. clearable
  35. @change="onClassChange"
  36. >
  37. <el-option
  38. v-for="(item, index) in selects.branchs"
  39. :key="index"
  40. :label="item.name"
  41. :value="item.id"
  42. />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="科目名称" prop="subject">
  46. <el-select
  47. v-model.trim="leftForm.subject"
  48. filterable
  49. clearable
  50. @change="changeSubject"
  51. :disabled="!leftForm.classOrganId"
  52. >
  53. <el-option
  54. v-for="(item, index) in subjectList"
  55. :key="index"
  56. :value="item.id"
  57. :label="item.name"
  58. />
  59. </el-select>
  60. </el-form-item>
  61. <!-- -->
  62. <el-form-item label="指导老师" prop="teacher">
  63. <el-select
  64. v-model.trim="leftForm.teacher"
  65. filterable
  66. clearable
  67. :disabled="!leftForm.subject"
  68. @change="setSection($event)"
  69. >
  70. <el-option
  71. v-for="(item, index) in teacherList"
  72. :key="index"
  73. :label="item.realName"
  74. :value="item.id"
  75. />
  76. </el-select>
  77. </el-form-item>
  78. <!-- @change="getClassOrgan()" -->
  79. <el-form-item label="乐团主管" prop="educationalTeacherId">
  80. <el-select
  81. v-model.trim="leftForm.educationalTeacherId"
  82. filterable
  83. clearable
  84. :disabled="!leftForm.subject"
  85. >
  86. <el-option
  87. v-for="(item, index) in educationList"
  88. :key="index"
  89. :label="item.userName"
  90. :value="item.userId"
  91. />
  92. </el-select>
  93. </el-form-item>
  94. <el-form-item label="课程形式" prop="courseType">
  95. <el-select
  96. v-model.trim="leftForm.courseType"
  97. clearable
  98. filterable
  99. :disabled="!leftForm.classOrganId || !leftForm.teacher"
  100. @change="changeType"
  101. >
  102. <el-option
  103. v-for="(item, index) in courseTypeList"
  104. :key="index"
  105. :label="item.name"
  106. :value="item.id"
  107. />
  108. </el-select>
  109. </el-form-item>
  110. <el-form-item label="教学点">
  111. <el-select
  112. v-model.trim="leftForm.section"
  113. filterable
  114. clearable
  115. :disabled="!leftForm.teacher"
  116. >
  117. <el-option
  118. v-for="(item, index) in scetionList"
  119. :key="index"
  120. :value="item.id"
  121. :label="item.name"
  122. />
  123. </el-select>
  124. </el-form-item>
  125. <el-form-item label="活动方案" prop="activeType" v-if="isMusicTheory">
  126. <el-select
  127. v-model.trim="leftForm.activeType"
  128. filterable
  129. clearable
  130. :disabled="!leftForm.courseType || isMusicTheory"
  131. @change="chioseActive"
  132. >
  133. <el-option
  134. v-for="(item, index) in activeList"
  135. :key="index"
  136. :value="item.id"
  137. :label="item.name"
  138. />
  139. </el-select>
  140. </el-form-item>
  141. <el-form-item
  142. label="活动方案"
  143. prop="activeType"
  144. v-else
  145. :rules="[
  146. {
  147. required: true,
  148. message: '请选择活动方案',
  149. trigger: 'change',
  150. },
  151. ]"
  152. >
  153. <el-select
  154. v-model.trim="leftForm.activeType"
  155. filterable
  156. clearable
  157. :disabled="!leftForm.courseType"
  158. @change="chioseActive"
  159. >
  160. <el-option
  161. v-for="(item, index) in activeList"
  162. :key="index"
  163. :value="item.id"
  164. :label="item.name"
  165. />
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item label="每课时长">
  169. <el-select
  170. v-model.trim="leftForm.classTime"
  171. :disabled="timeTable.length > 0"
  172. >
  173. <el-option
  174. v-for="(item, index) in this.classTimeList"
  175. :key="index"
  176. :value="item"
  177. :label="item"
  178. ></el-option>
  179. </el-select>
  180. </el-form-item>
  181. <el-form-item label="报名开始时间" prop="signUpStart">
  182. <!-- @change="changeStartTime" -->
  183. <el-date-picker
  184. v-model.trim="leftForm.signUpStart"
  185. type="date"
  186. :picker-options="pickerOptions"
  187. value-format="yyyy-MM-dd HH:mm:ss"
  188. placeholder="请选择时间"
  189. />
  190. <!-- <el-date-picker
  191. v-model="leftForm.signTimer"
  192. type="daterange"
  193. range-separator="至"
  194. start-placeholder="开始日期"
  195. end-placeholder="结束日期"
  196. >
  197. </el-date-picker> -->
  198. </el-form-item>
  199. <el-form-item label="报名结束时间" prop="signUpEnd">
  200. <el-date-picker
  201. v-model.trim="leftForm.signUpEnd"
  202. type="date"
  203. :picker-options="pickerOptions1"
  204. value-format="yyyy-MM-dd HH:mm:ss"
  205. placeholder="请选择时间"
  206. />
  207. </el-form-item>
  208. <el-form-item label="上课学员" prop="students">
  209. <el-select
  210. v-model.trim="leftForm.students"
  211. collapse-tags
  212. multiple
  213. clearable
  214. placeholder="请输入上课学员"
  215. remote
  216. reserve-keyword
  217. @change="changeStudent"
  218. filterable
  219. :multiple-limit="studentLimit"
  220. :disabled="!leftForm.classOrganId || !leftForm.courseType"
  221. :remote-method="remoteMethod"
  222. :loading="remoteLoading"
  223. >
  224. <el-option
  225. v-for="item in studentList"
  226. :key="item.userId"
  227. :label="item.username"
  228. :value="item.userId"
  229. >
  230. <span style="float: left">{{ item.username }}</span>
  231. <span style="float: right; color: #8492a6; font-size: 13px">{{
  232. item.parentsPhone
  233. }}</span>
  234. </el-option>
  235. </el-select>
  236. </el-form-item>
  237. </el-form>
  238. </div>
  239. <div class="center">
  240. <el-alert
  241. title="排课设置"
  242. type="info"
  243. :closable="false"
  244. class="vipMsg"
  245. ></el-alert>
  246. <p class="submitP" v-if="minCourseNum&&maxCourseNum&&this.hotType == 'DISCOUNT'">
  247. 该活动最小课时数:<span style="color: red">{{ minCourseNum }}</span
  248. >节 最大课时数:<span style="color: red">{{ maxCourseNum }}</span
  249. >节
  250. </p>
  251. <el-form
  252. :inline="true"
  253. :model="centerForm"
  254. label-width="100px"
  255. :label-position="labelPosition"
  256. >
  257. <el-form-item v-if="leftForm.courseStart" label="最早排课时间">
  258. <el-date-picker
  259. v-model.trim="leftForm.courseStart"
  260. disabled
  261. type="date"
  262. value-format="yyyy-MM-dd HH:mm:ss"
  263. placeholder="请选择时间"
  264. />
  265. </el-form-item>
  266. <el-form-item v-if="leftForm.courseEnd" label="最晚排课时间">
  267. <el-date-picker
  268. v-model.trim="leftForm.courseEnd"
  269. disabled
  270. type="date"
  271. value-format="yyyy-MM-dd HH:mm:ss"
  272. placeholder="请选择时间"
  273. />
  274. </el-form-item>
  275. <el-form-item v-if="hasOnline" label="线上课数">
  276. <el-input
  277. v-model.trim="centerForm.onlineCourseNum"
  278. @mousewheel.native.prevent
  279. @input="onCourseNumChange('online')"
  280. type="number"
  281. >
  282. <template slot="append">节</template>
  283. </el-input>
  284. </el-form-item>
  285. <el-form-item v-if="hasOffline" label="线下课数">
  286. <el-input
  287. v-model.trim="centerForm.offlineCourseNum"
  288. @mousewheel.native.prevent
  289. @input="onCourseNumChange('offline')"
  290. type="number"
  291. >
  292. <template slot="append">节</template>
  293. </el-input>
  294. </el-form-item>
  295. <el-form-item label="待排课数">
  296. <el-input v-model.trim="allCourseCount" disabled>
  297. <template slot="append">节</template>
  298. </el-input>
  299. </el-form-item>
  300. <el-form-item
  301. v-if="hotType == 'GIVE_CLASS' && isGiveClass"
  302. label="赠课课程类型"
  303. >
  304. <el-radio v-model.trim="centerForm.radio" label="ONLINE"
  305. >线上课</el-radio
  306. >
  307. <el-radio v-model.trim="centerForm.radio" label="OFFLINE"
  308. >线下课</el-radio
  309. >
  310. </el-form-item>
  311. <el-form-item label="">
  312. <el-button type="danger" @click="setCourse">点击排课</el-button>
  313. </el-form-item>
  314. </el-form>
  315. <!-- 排课列表开始 planList-->
  316. <div class="">
  317. <!-- <div class="planTop">
  318. <p>已排课程</p>
  319. <el-button type="text" @click="setCourse">{{
  320. id ? "新增排课" : "点击排课"
  321. }}</el-button>
  322. </div> -->
  323. <!-- <div class="planCore"> -->
  324. <el-table
  325. style="width: 100%"
  326. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  327. :data="timeTable"
  328. >
  329. <el-table-column align="center" prop="studentId" label="课程时间">
  330. <template slot-scope="scope">
  331. <div>{{ scope.row.classDate | formatTimer }}</div>
  332. </template>
  333. </el-table-column>
  334. <el-table-column
  335. align="center"
  336. prop="studentId"
  337. label="课程开始时间"
  338. >
  339. <template slot-scope="scope">
  340. <div>{{ scope.row.startClassTimeStr }}</div>
  341. </template>
  342. </el-table-column>
  343. <el-table-column
  344. align="center"
  345. prop="studentId"
  346. label="课程结束时间"
  347. >
  348. <template slot-scope="scope">
  349. <div>{{ scope.row.endClassTimeStr }}</div>
  350. </template>
  351. </el-table-column>
  352. <el-table-column align="center" prop="studentId" label="课程类型">
  353. <template slot-scope="scope">
  354. <div>{{ scope.row.teachMode | teachMode }}</div>
  355. </template>
  356. </el-table-column>
  357. </el-table>
  358. <!-- <div class="row">
  359. <div class="name">时间</div>
  360. <div class="week">开始时间</div>
  361. <div class="time">结束时间</div>
  362. <div class="time">课程类型</div>
  363. </div> -->
  364. <!-- <div
  365. v-for="(item, index) in this.timeTable"
  366. :key="index"
  367. class="row"
  368. >
  369. <div class="name">{{ item.classDate | formatTimer }}</div>
  370. <div class="week">{{ item.startClassTimeStr }}</div>
  371. <div class="time">{{ item.endClassTimeStr }}</div>
  372. <div class="time">{{ item.teachMode | teachMode }}</div>
  373. </div> -->
  374. <!-- </div> -->
  375. </div>
  376. </div>
  377. <div class="right">
  378. <el-alert
  379. title="课酬&缴费设置"
  380. type="info"
  381. :closable="false"
  382. class="vipMsg"
  383. ></el-alert>
  384. <el-form
  385. :model="rightForm"
  386. label-width="100px"
  387. :label-position="labelPosition"
  388. :inline="true"
  389. >
  390. <el-form-item v-if="hasOnline" label="线上课课酬">
  391. <el-input v-model.trim="rightForm.onlineCourse" :disabled="true">
  392. <template slot="append" v-if="!isMusicTheory">元/节</template>
  393. <template slot="append" v-else>元/人</template>
  394. </el-input>
  395. <!-- || onlineSalary!='TEACHER_DEFAULT' salaryReadonlyFlag==0 -->
  396. </el-form-item>
  397. <el-form-item v-if="hasOffline" label="线下课课酬">
  398. <el-input v-model.trim="rightForm.offlineCourse" :disabled="true">
  399. <template slot="append" v-if="!isMusicTheory">元/节</template>
  400. <template slot="append" v-else>元/人</template>
  401. </el-input>
  402. <!-- || offlineSalary!='TEACHER_DEFAULT' salaryReadonlyFlag==0 -->
  403. </el-form-item>
  404. <!-- <el-form-item v-if="hasOnline" label="线上课单价">
  405. <el-input
  406. v-model.trim="rightForm.onlinePrice"
  407. :disabled="paymentReadonlyFlag == 0"
  408. />
  409. </el-form-item>
  410. <el-form-item v-if="hasOffline" label="线下课单价">
  411. <el-input
  412. v-model.trim="rightForm.offlinePrice"
  413. :disabled="paymentReadonlyFlag == 0"
  414. />
  415. </el-form-item> -->
  416. <!-- <el-form-item label="课程总价">
  417. <el-input v-model.trim="rightForm.allPrice" disabled />
  418. </el-form-item> -->
  419. </el-form>
  420. <div style="width: 700px; clear: both">
  421. <el-table
  422. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  423. :data="activeStudentList"
  424. >
  425. <el-table-column align="center" prop="studentId" label="学员编号">
  426. </el-table-column>
  427. <el-table-column align="center" prop="userName" label="学员名称">
  428. </el-table-column>
  429. <el-table-column
  430. align="center"
  431. prop="studentId"
  432. v-if="hasOnline"
  433. label="线上课单价"
  434. >
  435. <template slot-scope="scope">
  436. <el-input-number
  437. :disabled="!isMusicTheory"
  438. size="mini"
  439. @change="changeStudentMoney"
  440. style="width: 90% !important"
  441. class="number-input"
  442. v-model="scope.row.onlineClassesUnitPrice"
  443. :controls="false"
  444. :min="0"
  445. placeholder="线上课单价"
  446. />
  447. </template>
  448. </el-table-column>
  449. <el-table-column
  450. align="center"
  451. prop="studentId"
  452. v-if="hasOffline"
  453. label="线下课单价"
  454. >
  455. <template slot-scope="scope">
  456. <el-input-number
  457. @change="changeStudentMoney"
  458. size="mini"
  459. style="width: 90% !important"
  460. class="number-input"
  461. :disabled="!isMusicTheory"
  462. v-model="scope.row.offlineClassesUnitPrice"
  463. :controls="false"
  464. :min="0"
  465. placeholder="线下课单价"
  466. />
  467. </template>
  468. </el-table-column>
  469. <el-table-column align="center" prop="studentId" label="缴费总额">
  470. <template slot-scope="scope">
  471. <el-input-number
  472. size="mini"
  473. style="width: 90% !important"
  474. class="number-input"
  475. v-model="scope.row.paymentPrice"
  476. :controls="false"
  477. :min="0"
  478. :disabled="true"
  479. placeholder="缴费总额"
  480. />
  481. </template>
  482. </el-table-column>
  483. </el-table>
  484. <!-- class="computeMoney" -->
  485. <div style="overflow: hidden">
  486. <el-button
  487. type="primary"
  488. class="computeMoney"
  489. @click="computational"
  490. >计算</el-button
  491. >
  492. </div>
  493. </div>
  494. </div>
  495. </div>
  496. <!-- 弹窗 -->
  497. <el-dialog
  498. title="VIP排课"
  499. ref="maskForm"
  500. width="500px"
  501. destroy-on-close
  502. :visible.sync="dialogFormVisible"
  503. >
  504. <el-form :model="maskForm" label-position="right" label-width="150px">
  505. <el-form-item label="开课时间">
  506. <el-date-picker
  507. v-model.trim="maskForm.courseStartOnline"
  508. type="date"
  509. :picker-options="courseOption"
  510. placeholder="请选择开课时间"
  511. />
  512. </el-form-item>
  513. <!-- <el-form-item label="线下课开课时间">
  514. <el-date-picker
  515. v-model.trim="maskForm.courseStartOffline"
  516. type="date"
  517. :picker-options="courseOption"
  518. placeholder="请选择开课时间"
  519. />
  520. </el-form-item> -->
  521. <div
  522. class="line"
  523. style="height: 1px; background: #ccc; margin: 0 25px"
  524. ></div>
  525. <el-form-item label="课程类型" prop="type">
  526. <el-radio v-if="hasOnline" v-model.trim="maskForm.type" label="ONLINE"
  527. >线上课</el-radio
  528. >
  529. <el-radio
  530. v-if="hasOffline"
  531. v-model.trim="maskForm.type"
  532. label="OFFLINE"
  533. >线下课</el-radio
  534. >
  535. </el-form-item>
  536. <el-form-item label="循环周次" prop="week">
  537. <el-select
  538. v-model.trim="maskForm.week"
  539. style="width: 220px !important"
  540. >
  541. <el-option label="星期日" value="0" />
  542. <el-option label="星期一" value="1" />
  543. <el-option label="星期二" value="2" />
  544. <el-option label="星期三" value="3" />
  545. <el-option label="星期四" value="4" />
  546. <el-option label="星期五" value="5" />
  547. <el-option label="星期六" value="6" />
  548. </el-select>
  549. </el-form-item>
  550. <el-form-item label="上课时间" prop="startTime">
  551. <el-time-picker
  552. v-model.trim="maskForm.startTime"
  553. @change="getStartTime"
  554. format="HH:mm"
  555. value-format="HH:mm"
  556. placeholder="选择时间"
  557. />
  558. </el-form-item>
  559. <el-form-item label="下课时间" prop="endTime">
  560. <el-time-picker
  561. v-model.trim="maskForm.endTime"
  562. disabled
  563. format="HH:mm"
  564. value-format="HH:mm"
  565. :picker-options="{
  566. start: '04:30',
  567. step: '00:05',
  568. end: '23:30',
  569. }"
  570. placeholder="选择时间"
  571. />
  572. </el-form-item>
  573. </el-form>
  574. <div class="btnWrap">
  575. <div class="okBtn" @click="addWeek">确认</div>
  576. </div>
  577. <div class="planList">
  578. <div class="planTop">
  579. <p>已排课程</p>
  580. </div>
  581. <div class="planCore">
  582. <div v-for="(item, index) in this.lookList" class="row" :key="index">
  583. <div class="name">{{ item.type }}</div>
  584. <div class="week">{{ item.week }}</div>
  585. <div class="time">{{ item.time }}</div>
  586. <div class="operation">
  587. <el-button type="text" @click="removeWeekCourse(item.id)"
  588. >删除</el-button
  589. >
  590. </div>
  591. </div>
  592. </div>
  593. <div slot="footer" style="margin-top: 20px" class="dialog-footer">
  594. <el-button @click="dialogFormVisible = false">取 消</el-button>
  595. <el-button type="primary" @click="setTimeTable">确 定</el-button>
  596. </div>
  597. </div>
  598. </el-dialog>
  599. <el-row>
  600. <el-col>
  601. <div class="okBtn" @click="submitInfo">{{ id ? "修改" : "确定" }}</div>
  602. </el-col>
  603. </el-row>
  604. <!-- <div class="btnWrap"> -->
  605. <!-- <div class="closeBtn">
  606. 取消
  607. </div>-->
  608. <!-- </div> -->
  609. </div>
  610. </template>
  611. <script>
  612. import {
  613. findTeacherByOrganId,
  614. getSubject,
  615. findEducationUsers,
  616. } from "@/api/buildTeam";
  617. import {
  618. vipGroupCategory,
  619. vipGroupActivityFind,
  620. getVipGroupCostCount,
  621. createVip,
  622. updateVipBaseInfo,
  623. } from "@/api/vipSeting";
  624. import { getTeachSchool, getTeacherBySubject } from "@/api/teacherManager";
  625. import axios from "axios";
  626. import { getToken } from "@/utils/auth";
  627. import { diffTimerFormMinute, addTimerFormMinute } from "@/utils/date";
  628. import dayjs from "dayjs";
  629. export default {
  630. name: "buildVip",
  631. data() {
  632. return {
  633. dialogFormVisible: false,
  634. labelPosition: "right",
  635. leftForm: {
  636. // name: "",
  637. teacher: "",
  638. subject: "",
  639. courseType: "",
  640. activeType: "",
  641. classNum: "",
  642. classTime: "",
  643. // signTimer:[],
  644. signUpStart: "",
  645. signUpEnd: "",
  646. courseStartOnline: "",
  647. courseStartOffline: "",
  648. section: "",
  649. courseStart: "",
  650. courseEnd: "",
  651. educationalTeacherId: "",
  652. students: [],
  653. classOrganId: "", // 课程分部
  654. },
  655. activeStudentList: [],
  656. studentLimit: 0,
  657. classTimeList: [],
  658. centerForm: {
  659. allCourseNum: "",
  660. onlineCourseNum: 0,
  661. offlineCourseNum: 0,
  662. radio: "",
  663. },
  664. maskForm: {
  665. type: "",
  666. week: "",
  667. startTime: "",
  668. endTime: "",
  669. },
  670. rightForm: {
  671. onlineCourse: "",
  672. offlineCourse: "",
  673. onlinePrice: "",
  674. offlinePrice: "",
  675. allPrice: "",
  676. },
  677. remoteLoading: false,
  678. computationalBtn: false,
  679. subjectList: [], // 科目列表
  680. teacherList: [], // 老师列表
  681. educationList: [], // 教务
  682. // classOrganList: [], // 公用分部
  683. courseTypeList: [], // 课程类型集合
  684. activeList: [], //活动集合
  685. hasOnline: true,
  686. hasOffline: true,
  687. onlineSalary: "", // 线上课课酬结算方式
  688. offlineSalary: "", // 线下课课酬结算方式
  689. hotType: "",
  690. attribute1: "",
  691. attribute2: "",
  692. attribute3: "",
  693. maxCourseNum: 0,
  694. minCourseNum: 0,
  695. salaryReadonlyFlag: "", // 老师课酬是否可配
  696. paymentReadonlyFlag: "", // 课程单价是否可配
  697. lookList: [],
  698. onlinelookList: [], // 展示课表线上
  699. offlineLookList: [], // 展示课表线下
  700. timeTable: [], // 真正的课表
  701. giveNum: "",
  702. weekDay: [
  703. "星期日",
  704. "星期一",
  705. "星期二",
  706. "星期三",
  707. "星期四",
  708. "星期五",
  709. "星期六",
  710. ],
  711. scetionList: [],
  712. isGiveClass: false,
  713. activeStartTime: null,
  714. courseOption: null,
  715. pickerOptions: null,
  716. pickerOptions1: null,
  717. leftFormRules: {
  718. /**?
  719. * teacher: '',
  720. subject: '',
  721. courseType: '',
  722. activeType: '',
  723. */
  724. name: [
  725. {
  726. required: true,
  727. message: "请输入名称",
  728. trigger: "blur",
  729. },
  730. ],
  731. teacher: [
  732. {
  733. required: true,
  734. message: "请选择老师",
  735. trigger: "change",
  736. },
  737. ],
  738. educationalTeacherId: [
  739. {
  740. required: true,
  741. message: "请选择教务",
  742. trigger: "change",
  743. },
  744. ],
  745. classOrganId: [
  746. {
  747. required: true,
  748. message: "请选择课程分部",
  749. trigger: "change",
  750. },
  751. ],
  752. subject: [
  753. {
  754. required: true,
  755. message: "请选择科目",
  756. trigger: "change",
  757. },
  758. ],
  759. courseType: [
  760. {
  761. required: true,
  762. message: "请选择课程类型",
  763. trigger: "change",
  764. },
  765. ],
  766. students: [
  767. {
  768. required: true,
  769. message: "请选择上课学生",
  770. trigger: "change",
  771. },
  772. ],
  773. // activeType: [
  774. // {
  775. // required: true,
  776. // message: "请选择活动",
  777. // trigger: "change",
  778. // },
  779. // ],
  780. signUpStart: [
  781. {
  782. required: true,
  783. message: "请选择报名开始时间",
  784. trigger: "change",
  785. },
  786. ],
  787. signUpEnd: [
  788. {
  789. required: true,
  790. message: "请选择报名结束时间",
  791. trigger: "change",
  792. },
  793. ],
  794. },
  795. id: "",
  796. studentList: [],
  797. courseTimeList: [],
  798. isMusicTheory: false,
  799. };
  800. },
  801. computed: {
  802. allCourseCount() {
  803. let online, offline;
  804. this.centerForm.onlineCourseNum
  805. ? (online = this.centerForm.onlineCourseNum)
  806. : (online = 0);
  807. this.centerForm.offlineCourseNum
  808. ? (offline = this.centerForm.offlineCourseNum)
  809. : (offline = 0);
  810. let giveNum;
  811. if (this.hotType == "GIVE_CLASS") {
  812. // this.attribute1 从多少节开始送
  813. // this.attribute2 送多少节
  814. giveNum = parseInt(
  815. parseInt(offline) + parseInt(online) - this.attribute1 >= 0
  816. ? (giveNum = this.attribute2)
  817. : (giveNum = 0)
  818. );
  819. if (giveNum) {
  820. // 有赠送课时
  821. this.isGiveClass = true;
  822. }
  823. this.giveNum = giveNum || 0;
  824. return parseInt(offline) + parseInt(online) + "+" + giveNum || "";
  825. }
  826. return parseInt(offline) + parseInt(online) || "";
  827. },
  828. },
  829. created() {
  830. // this.init();
  831. },
  832. mounted() {
  833. // 获取所有老师的接口 根据声部id获取老师
  834. // 获取课程类型的接口
  835. // 获取学生列表
  836. Object.assign(this.$data, this.$options.data());
  837. setTimeout(() => {
  838. this.$refs["leftForm"].resetFields();
  839. }, 100);
  840. this.init();
  841. },
  842. activated() {
  843. // Object.assign(this.$data, this.$options.data());
  844. // setTimeout(() => {
  845. // this.$refs["leftForm"].resetFields();
  846. // }, 100);
  847. // this.init();
  848. },
  849. methods: {
  850. async init() {
  851. if (this.$route.query.rules) {
  852. this.rules = this.$route.query.rules;
  853. }
  854. if (this.$route.query.searchForm) {
  855. this.searchForm = this.$route.query.searchForm;
  856. }
  857. // 获取所有科目的接口
  858. await this.$store.dispatch("setBranchs");
  859. getSubject({
  860. tenantId: 1,
  861. }).then((res) => {
  862. if (res.code == 200) {
  863. this.subjectList = res.data;
  864. }
  865. });
  866. // 获取乐团主管
  867. this.pickerOptions = this.beginDate();
  868. this.pickerOptions1 = this.processDate();
  869. this.courseOption = this.coursesDate();
  870. },
  871. onCourseNumChange(type) {
  872. // 折扣类型,并且设置的排课数有值
  873. let centerForm = this.centerForm;
  874. if (
  875. this.hotType == "DISCOUNT" &&
  876. this.maxCourseNum &&
  877. this.minCourseNum
  878. ) {
  879. // 判断线上或线下总和大于排课次数
  880. let onlineNum = centerForm.onlineCourseNum || 0;
  881. let offlineNum = centerForm.offlineCourseNum || 0;
  882. let allNUm = parseInt(onlineNum) + parseInt(offlineNum);
  883. if (allNUm > this.maxCourseNum || allNUm < this.minCourseNum) {
  884. this.$message.error("待排课数不可超过该活动限制");
  885. return;
  886. }
  887. }
  888. },
  889. coursesDate() {
  890. let self = this;
  891. return {
  892. firstDayOfWeek: 1,
  893. disabledDate: (time) => {
  894. if (self.leftForm.courseStart) {
  895. let date = new Date(self.leftForm.courseStart.replace(/-/, "/"));
  896. return time.getTime() < date.getTime();
  897. }
  898. return;
  899. },
  900. };
  901. },
  902. beginDate() {
  903. let self = this;
  904. return {
  905. firstDayOfWeek: 1,
  906. disabledDate(time) {
  907. return time.getTime() + 86400000 <= new Date().getTime(); //开始时间不选时,结束时间最大值小于等于当天
  908. },
  909. };
  910. },
  911. processDate() {
  912. //提出结束时间必须大于提出开始时间
  913. let self = this;
  914. return {
  915. firstDayOfWeek: 1,
  916. disabledDate(time) {
  917. if (self.leftForm.signUpStart) {
  918. return (
  919. new Date(self.leftForm.signUpStart).getTime() > time.getTime()
  920. );
  921. } else {
  922. return time.getTime() > Date.now();
  923. //开始时间不选时,结束时间最大值小于等于当天
  924. }
  925. },
  926. };
  927. },
  928. changeSubject(val) {
  929. this.leftForm.teacher = "";
  930. this.leftForm.section = "";
  931. // 根据科目id获取相应的老师
  932. findTeacherByOrganId({
  933. subjectIds: val,
  934. organId: this.leftForm.classOrganId,
  935. }).then((res) => {
  936. if (res.code == 200) {
  937. this.teacherList = res.data;
  938. }
  939. });
  940. // getTeacherBySubject({ subjecId: val }).then(res => {
  941. // if (res.code == 200) {
  942. // this.teacherList = res.data;
  943. // }
  944. // })
  945. },
  946. // 选择课程类型
  947. changeType(val) {
  948. // 在这里清空默认课酬
  949. this.rightForm.offlineCourse = "";
  950. this.rightForm.onlineCourse = "";
  951. this.leftForm.activeType = "";
  952. this.leftForm.students = []; // 重置所选学生
  953. for (let i in this.courseTypeList) {
  954. if (this.courseTypeList[i].id == val) {
  955. // 学生人数
  956. this.leftForm.classNum = this.courseTypeList[i].studentNum;
  957. this.studentLimit = this.courseTypeList[i].studentNum;
  958. // 每课时长
  959. this.classTimeList = this.courseTypeList[i].singleClassMinutes.split(
  960. ","
  961. );
  962. // this.leftForm.classTime = this.courseTypeList[i].singleClassMinutes;
  963. this.leftForm.classTime = this.classTimeList[0];
  964. // 线上课单节价格
  965. this.rightForm.onlinePrice = this.courseTypeList[
  966. i
  967. ].onlineClassesUnitPrice;
  968. // 线下课单节价格
  969. this.rightForm.offlinePrice = this.courseTypeList[
  970. i
  971. ].offlineClassesUnitPrice;
  972. this.isMusicTheory = this.courseTypeList[i].musicTheory;
  973. }
  974. }
  975. // teacherId
  976. if (this.leftForm.courseType && this.leftForm.teacher) {
  977. // 根据课程类型获取活动方案
  978. vipGroupActivityFind({
  979. categoryId: this.leftForm.courseType,
  980. teacherId: this.leftForm.teacher,
  981. }).then((res) => {
  982. if (res.code == 200) {
  983. this.activeList = res.data;
  984. }
  985. });
  986. }
  987. },
  988. // 选择活动方案
  989. chioseActive(val) {
  990. console.log(val)
  991. this.rightForm.offlineCourse = "";
  992. this.rightForm.onlineCourse = "";
  993. // this.rightForm.onlinePrice = '';
  994. // this.rightForm.offlinePrice = '';
  995. this.lookList = [];
  996. this.timeTable = [];
  997. this.attribute1 = "";
  998. this.attribute2 = "";
  999. this.attribute3 = "";
  1000. this.giveNum = 0;
  1001. this.isGiveClass = false;
  1002. this.leftForm.courseStart = "";
  1003. this.leftForm.courseEnd = "";
  1004. this.hasOnline = true;
  1005. this.hasOffline = true;
  1006. if (val) {
  1007. for (let i in this.courseTypeList) {
  1008. if (this.courseTypeList[i].id == this.leftForm.courseType) {
  1009. // 学生人数
  1010. this.leftForm.classNum = this.courseTypeList[i].studentNum;
  1011. // 每课时长
  1012. this.classTimeList = this.courseTypeList[
  1013. i
  1014. ].singleClassMinutes.split(",");
  1015. // this.leftForm.classTime = this.courseTypeList[i].singleClassMinutes;
  1016. this.leftForm.classTime = this.classTimeList[0];
  1017. // 线上课单节价格
  1018. this.rightForm.onlinePrice = this.courseTypeList[
  1019. i
  1020. ].onlineClassesUnitPrice;
  1021. // 线下课单节价格
  1022. this.rightForm.offlinePrice = this.courseTypeList[
  1023. i
  1024. ].offlineClassesUnitPrice;
  1025. }
  1026. }
  1027. // 根须活动id获取 相应的值
  1028. for (let i in this.activeList) {
  1029. if (this.activeList[i].id == val) {
  1030. // 如果是买赠就必须选择赠课类型
  1031. // 报名开始 报名结束 课程开始 课程结束 // 判断是否有线上,线下课 并同步状态
  1032. // this.leftForm.signUpStart = this.activeList[i].startTime;
  1033. // this.leftForm.signUpEnd = this.activeList[i].endTime;
  1034. this.maxCourseNum = this.activeList[i].maxCourseNum || 0;
  1035. this.minCourseNum = this.activeList[i].minCourseNum || 0;
  1036. this.leftForm.courseStart = this.activeList[i].coursesStartTime;
  1037. this.leftForm.courseEnd = this.activeList[i].coursesEndTime;
  1038. // 获取活动种类并保存
  1039. this.hotType = this.activeList[i].type;
  1040. // 获取买赠必要参数
  1041. this.attribute1 = this.activeList[i].attribute1;
  1042. this.attribute2 = this.activeList[i].attribute2;
  1043. this.attribute3 = this.activeList[i].attribute3;
  1044. // 存储课酬是否可配置
  1045. this.salaryReadonlyFlag = this.activeList[i].salaryReadonlyFlag;
  1046. this.paymentReadonlyFlag = this.activeList[i].paymentReadonlyFlag;
  1047. // hasOnline: false, hasOffline: false 还需要判断type类型 根据活动id获取
  1048. if (this.activeList[i].salarySettlementJson) {
  1049. let obj = JSON.parse(this.activeList[i].salarySettlementJson);
  1050. if (obj && obj.onlineSalarySettlement) {
  1051. // 有线上课
  1052. this.hasOnline = true;
  1053. this.onlineSalary =
  1054. obj.onlineSalarySettlement.salarySettlementType;
  1055. // console.log('线上:' + this.onlineSalary)
  1056. } else {
  1057. this.hasOnline = false;
  1058. }
  1059. if (obj && obj.offlineSalarySettlement) {
  1060. // 有线下课
  1061. this.hasOffline = true;
  1062. this.offlineSalary =
  1063. obj.offlineSalarySettlement.salarySettlementType;
  1064. // console.log('线下:' + this.offlineSalary)
  1065. } else {
  1066. this.hasOffline = false;
  1067. }
  1068. }
  1069. }
  1070. }
  1071. }
  1072. // 重置课程单价
  1073. },
  1074. // 点击确插入课表
  1075. addWeek() {
  1076. let courseType = this.maskForm.type;
  1077. // let week = ;this.maskForm.week
  1078. let startTime = this.maskForm.startTime;
  1079. if (!courseType || !this.maskForm.week || !startTime) {
  1080. this.$message.error("请填写完成信息");
  1081. return;
  1082. }
  1083. // 拿到相应的值插入数组
  1084. let endTime = this.MinutesTest(startTime, this.leftForm.classTime);
  1085. let str;
  1086. switch (courseType) {
  1087. case "ONLINE": {
  1088. str = "线上课";
  1089. break;
  1090. }
  1091. case "OFFLINE": {
  1092. str = "线下课";
  1093. break;
  1094. }
  1095. }
  1096. let flag = false;
  1097. for (let i in this.lookList) {
  1098. if (this.lookList[i].weekDay == this.maskForm.week) {
  1099. flag = true;
  1100. }
  1101. }
  1102. // true=> 说明有这一周 那么循环找到这一周 在判断时间
  1103. // flase=> 说明没有这一周的时间 直接添加
  1104. if (flag) {
  1105. // 有相同的周日
  1106. let arr = [];
  1107. for (let i in this.lookList) {
  1108. if (this.lookList[i].weekDay == this.maskForm.week) {
  1109. // 找到这一天的所有元素
  1110. // && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, startTime) && !this.timeIsrange(this.lookList[i].startTime, this.lookList[i].endTime, endTime)
  1111. let isStartTime = this.timeIsrange(
  1112. startTime,
  1113. endTime,
  1114. this.lookList[i].startTime
  1115. );
  1116. let isEndTime = this.timeIsrange(
  1117. startTime,
  1118. endTime,
  1119. this.lookList[i].endTime
  1120. );
  1121. arr.push(!isEndTime && !isStartTime);
  1122. }
  1123. }
  1124. let isAdd = true;
  1125. for (let j = 0; j < arr.length; j++) {
  1126. isAdd = isAdd && arr[j];
  1127. }
  1128. if (isAdd) {
  1129. this.lookList.push({
  1130. type: str,
  1131. week: this.weekDay[this.maskForm.week],
  1132. weekDay: this.maskForm.week,
  1133. startTime: startTime,
  1134. endTime: endTime,
  1135. time: startTime + "-" + endTime,
  1136. id: Date.now(),
  1137. });
  1138. } else {
  1139. this.$message.error("该时间段已排课请重选时间");
  1140. return;
  1141. }
  1142. } else {
  1143. this.lookList.push({
  1144. type: str,
  1145. week: this.weekDay[this.maskForm.week],
  1146. weekDay: this.maskForm.week,
  1147. startTime: startTime,
  1148. endTime: endTime,
  1149. time: startTime + "-" + endTime,
  1150. id: Date.now(),
  1151. });
  1152. }
  1153. // console.log(this.lookList)
  1154. // let courseType = this.maskForm.type;
  1155. // // let week = ;this.maskForm.week
  1156. // let startTime = this.maskForm.startTime;
  1157. this.maskForm.type = "";
  1158. this.maskForm.week = "";
  1159. this.maskForm.startTime = "";
  1160. this.maskForm.endTime = "";
  1161. },
  1162. // 分钟小时相加减
  1163. MinutesTest(str, interval) {
  1164. let houer = str.split(":")[0];
  1165. let min = str.split(":")[1];
  1166. let sdate1 = new Date(1900, 1, 1, houer, min);
  1167. sdate1.setMinutes(sdate1.getMinutes() + parseInt(interval));
  1168. let H = sdate1.getHours();
  1169. let M = sdate1.getMinutes();
  1170. if (H < 10) H = "0" + H;
  1171. if (M < 10) M = "0" + M;
  1172. return H + ":" + M;
  1173. },
  1174. // 判断时间是否在时间段内
  1175. timeIsrange(beginTime, endTime, nowTime) {
  1176. var strb = beginTime.split(":");
  1177. if (strb.length != 2) {
  1178. return false;
  1179. }
  1180. var stre = endTime.split(":");
  1181. if (stre.length != 2) {
  1182. return false;
  1183. }
  1184. var strn = nowTime.split(":");
  1185. if (stre.length != 2) {
  1186. return false;
  1187. }
  1188. var b = new Date();
  1189. var e = new Date();
  1190. var n = new Date();
  1191. b.setHours(strb[0]);
  1192. b.setMinutes(strb[1]);
  1193. e.setHours(stre[0]);
  1194. e.setMinutes(stre[1]);
  1195. n.setHours(strn[0]);
  1196. n.setMinutes(strn[1]);
  1197. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  1198. // 在时间范围内
  1199. return true;
  1200. } else {
  1201. // 不在时间范围内
  1202. return false;
  1203. }
  1204. },
  1205. removeWeekCourse(id) {
  1206. for (let i in this.lookList) {
  1207. if (this.lookList[i].id == id) {
  1208. this.lookList.splice(i, 1);
  1209. }
  1210. }
  1211. },
  1212. setTimeTable() {
  1213. // 拿到线上课数与线下课数 以及
  1214. this.timeTable = [];
  1215. let online = parseInt(this.centerForm.onlineCourseNum) || 0;
  1216. let offline = parseInt(this.centerForm.offlineCourseNum) || 0;
  1217. let giveNum = this.giveNum;
  1218. let giveClassType = this.centerForm.radio;
  1219. if (giveClassType == "ONLINE") {
  1220. // 线上
  1221. online += giveNum;
  1222. } else if (giveClassType == "OFFLINE") {
  1223. offline += giveNum;
  1224. }
  1225. if( !this.maskForm.courseStartOnline){
  1226. this.$message.error("请选择课程开始时间");
  1227. return;
  1228. }
  1229. // 这里判断是否选择了排课开始时间
  1230. // if (online && !this.maskForm.courseStartOnline) {
  1231. // this.$message.error("选择了线上课 但没有线上课开始时间");
  1232. // return;
  1233. // }
  1234. // if (offline && !this.maskForm.courseStartOffline) {
  1235. // this.$message.error("选择了线下课 但没有线下课开始时间");
  1236. // return;
  1237. // }
  1238. let date, date1;
  1239. date = new Date(this.maskForm.courseStartOnline.getTime());
  1240. date1 = new Date(this.maskForm.courseStartOnline.getTime());
  1241. // if (this.maskForm.courseStartOnline) {
  1242. // date = new Date(this.maskForm.courseStartOnline.getTime());
  1243. // }
  1244. // if (this.maskForm.courseStartOffline) {
  1245. // date1 = new Date(this.maskForm.courseStartOffline.getTime());
  1246. // }
  1247. // let startWeekday = this.maskForm.courseStart.getDay();
  1248. let onlineList = []; // 装线上课的数组
  1249. let offlineList = []; //装线下课的数组
  1250. if (this.lookList.length <= 0) {
  1251. this.$message.error("请先排课后再点击确认按钮");
  1252. return;
  1253. }
  1254. for (let i in this.lookList) {
  1255. if (this.lookList[i].type == "线上课") {
  1256. onlineList.push({
  1257. week: this.lookList[i].weekDay,
  1258. date: this.lookList[i],
  1259. });
  1260. }
  1261. if (this.lookList[i].type == "线下课") {
  1262. offlineList.push({
  1263. week: this.lookList[i].weekDay,
  1264. date: this.lookList[i],
  1265. });
  1266. }
  1267. }
  1268. // console.log(onlineList + '----------------------------------------------------------------------------------');
  1269. // console.log(offlineList);
  1270. if (online > 0 && onlineList.length <= 0) {
  1271. this.$message.error("选择了线上课但未排线上课");
  1272. this.timeTable = [];
  1273. return;
  1274. }
  1275. if (offline > 0 && offlineList.length <= 0) {
  1276. this.$message.error("选择了线下课但未排线下课");
  1277. this.timeTable = [];
  1278. return;
  1279. }
  1280. // 获取要排课的总数 获取每周要排多少次
  1281. while (online && online > 0) {
  1282. // 排线上课g
  1283. for (let i in onlineList) {
  1284. let num;
  1285. onlineList[i].week - date.getDay() >= 0
  1286. ? (num = onlineList[i].week - date.getDay())
  1287. : (num = onlineList[i].week - date.getDay() + 7); // +差值的天数://差值的天数+7
  1288. // console.log(num);
  1289. let dataStr = this.getThinkDate(date, num);
  1290. this.timeTable.push({
  1291. classDate: dataStr + " 00:00:00",
  1292. actualTeacherId: this.leftForm.teacher,
  1293. startClassTimeStr: onlineList[i].date.startTime,
  1294. endClassTimeStr: onlineList[i].date.endTime,
  1295. teachMode: "ONLINE",
  1296. });
  1297. online--;
  1298. if (online == 0) break;
  1299. }
  1300. if (onlineList.length == 1 || this.isAllEqual(onlineList)) {
  1301. date.setDate(date.getDate() + 7);
  1302. }
  1303. // 加一周
  1304. }
  1305. // console.log(date1)
  1306. while (offline && offline > 0) {
  1307. // 排线下课
  1308. for (let i in offlineList) {
  1309. let num;
  1310. offlineList[i].week - date1.getDay() >= 0
  1311. ? (num = offlineList[i].week - date1.getDay())
  1312. : (num = offlineList[i].week - date1.getDay() + 7); // +差值的天数://差值的天数+7
  1313. let dataStr = this.getThinkDate(date1, num);
  1314. this.timeTable.push({
  1315. classDate: dataStr + " 00:00:00",
  1316. actualTeacherId: this.leftForm.teacher,
  1317. startClassTimeStr: offlineList[i].date.startTime,
  1318. endClassTimeStr: offlineList[i].date.endTime,
  1319. teachMode: "OFFLINE",
  1320. });
  1321. offline--;
  1322. if (offline == 0) break;
  1323. }
  1324. // 加一周
  1325. if (offlineList.length == 1 || this.isAllEqual(offlineList)) {
  1326. date1.setDate(date1.getDate() + 7);
  1327. }
  1328. }
  1329. // console.log(this.timeTable);
  1330. this.dialogFormVisible = false;
  1331. },
  1332. getThinkDate(date, num) {
  1333. let Stamp = date;
  1334. Stamp.setDate(date.getDate() + num); // 获取当前月数的第几天
  1335. // console.log(date.getMonth() + 1)
  1336. // console.log(Stamp.getMonth() + 1)
  1337. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  1338. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  1339. var mvar = "";
  1340. if (month < 10) {
  1341. mvar = "0" + month;
  1342. } else {
  1343. mvar = month + "";
  1344. }
  1345. var day = Stamp.getDate();
  1346. var dvar = "";
  1347. if (day < 10) {
  1348. dvar = "0" + day;
  1349. } else {
  1350. dvar = day + "";
  1351. }
  1352. // console.log(year + "-" + mvar + '-' + dvar);
  1353. return year + "-" + mvar + "-" + dvar;
  1354. },
  1355. // 计算课酬
  1356. computational() {
  1357. console.log("lai");
  1358. this.computationalBtn = true;
  1359. let userId = this.leftForm.teacher || null;
  1360. let giveTeachMode = this.centerForm.radio || null;
  1361. let vipGroupCategoryId = this.leftForm.courseType || null;
  1362. let vipGroupActivityId = this.leftForm.activeType || null;
  1363. let onlineClassesUnitPrice = this.rightForm.onlinePrice || null;
  1364. let offlineClassesUnitPrice = this.rightForm.offlinePrice || null;
  1365. let onlineClassesNum = this.centerForm.onlineCourseNum || 0;
  1366. let offlineClassesNum = this.centerForm.offlineCourseNum || 0;
  1367. let singleClassMinutes = this.leftForm.classTime;
  1368. if (this.hotType == "GIVE_CLASS") {
  1369. if (this.centerForm.radio == "ONLINE") {
  1370. onlineClassesNum =
  1371. parseInt(onlineClassesNum) + parseInt(this.giveNum);
  1372. } else if (this.centerForm.radio == "OFFLINE") {
  1373. offlineClassesNum =
  1374. parseInt(offlineClassesNum) + parseInt(this.giveNum);
  1375. }
  1376. }
  1377. let onlineTeacherSalary = this.rightForm.onlineCourse || null;
  1378. let offlineTeacherSalary = this.rightForm.offlineCourse || null;
  1379. getVipGroupCostCount({
  1380. vipGroupActivityId,
  1381. onlineClassesUnitPrice,
  1382. onlineTeacherSalary,
  1383. offlineTeacherSalary,
  1384. vipGroupCategoryId,
  1385. offlineClassesUnitPrice,
  1386. onlineClassesNum,
  1387. offlineClassesNum,
  1388. userId,
  1389. giveTeachMode,
  1390. singleClassMinutes,
  1391. vipGroupStudentCoursePrices: this.activeStudentList,
  1392. }).then((res) => {
  1393. if (res.code == 200) {
  1394. this.rightForm.onlineCourse = res.data.onlineTeacherSalary;
  1395. this.rightForm.offlineCourse = res.data.offlineTeacherSalary;
  1396. this.rightForm.allPrice = res.data.totalPrice;
  1397. this.activeStudentList.forEach((stu) => {
  1398. if (res.data.hasOwnProperty(stu.studentId)) {
  1399. stu.paymentPrice = res.data[stu.studentId];
  1400. }
  1401. });
  1402. }
  1403. });
  1404. },
  1405. isAllEqual(array) {
  1406. if (array.length > 0) {
  1407. return !array.some((val, index) => {
  1408. return val.week != array[0].week;
  1409. });
  1410. } else {
  1411. return true;
  1412. }
  1413. },
  1414. submitInfo() {
  1415. if (!this.computationalBtn) {
  1416. this.$message.error("请点击计算按钮计算课酬");
  1417. return;
  1418. }
  1419. // let activeCourseType;
  1420. let flag = false;
  1421. // console.log(this.courseTypeList,)
  1422. // this.courseTypeList.forEach((courseType) => {
  1423. // if (courseType.id == this.leftForm.courseType) {
  1424. // activeCourseType = courseType;
  1425. // }
  1426. // });
  1427. // console.log(activeCourseType)
  1428. if (this.isMusicTheory) {
  1429. if (
  1430. this.leftForm.students.length > this.studentLimit ||
  1431. this.leftForm.students.length < 3
  1432. ) {
  1433. this.$message.error(`请选择上课学生为3-${this.studentLimit}人`);
  1434. flag = true;
  1435. }
  1436. } else {
  1437. if (this.leftForm.students.length !== this.studentLimit) {
  1438. this.$message.error(`请选择上课学生为${this.studentLimit}人`);
  1439. flag = true;
  1440. }
  1441. }
  1442. if (flag) return;
  1443. // 获取活动方案
  1444. // 判断线上课课酬和线下课课酬
  1445. let online = parseInt(this.centerForm.onlineCourseNum);
  1446. let offline = parseInt(this.centerForm.offlineCourseNum);
  1447. let giveNum = this.giveNum;
  1448. let giveClassType = this.centerForm.radio;
  1449. if (giveClassType == "ONLINE") {
  1450. // 线上
  1451. online += giveNum;
  1452. } else if (giveClassType == "OFFLINE") {
  1453. offline += giveNum;
  1454. }
  1455. let obj = {};
  1456. obj.courseSchedules = this.timeTable;
  1457. /**
  1458. *
  1459. * teacher: '',
  1460. subject: '',
  1461. courseType: '',
  1462. activeType: '',
  1463. classNum: '',
  1464. classTime: '',
  1465. signUpStart: '',
  1466. signUpEnd: '',
  1467. courseStart: '',
  1468. courseEnd: ''
  1469. */
  1470. let studentIdList = this.leftForm.students.join(",") || null;
  1471. obj.vipGroupApplyBaseInfo = {
  1472. studentIdList, // 这个不要了
  1473. vipGroupStudentCoursePrices: this.activeStudentList,
  1474. coursesExpireDate: this.leftForm.courseEnd,
  1475. teacherSchoolId: this.leftForm.section,
  1476. // name: this.leftForm.name,
  1477. offlineClassesNum: offline || 0,
  1478. onlineClassesNum: online || 0,
  1479. offlineClassesUnitPrice: this.rightForm.offlinePrice || 0,
  1480. onlineClassesUnitPrice: this.rightForm.onlinePrice || 0,
  1481. paymentExpireDate: this.leftForm.signUpEnd,
  1482. registrationStartTime: this.leftForm.signUpStart,
  1483. singleClassMinutes: this.leftForm.classTime,
  1484. studentNum: this.leftForm.classNum,
  1485. userId: this.leftForm.teacher,
  1486. vipGroupActivityId: this.leftForm.activeType,
  1487. vipGroupCategoryId: this.leftForm.courseType,
  1488. onlineTeacherSalary: this.rightForm.onlineCourse || 0,
  1489. offlineTeacherSalary: this.rightForm.offlineCourse || 0,
  1490. giveTeachMode: this.centerForm.radio,
  1491. subjectIdList: this.leftForm.subject,
  1492. educationalTeacherId: this.leftForm.educationalTeacherId,
  1493. organId: this.leftForm.classOrganId,
  1494. };
  1495. // 调接前判断是新增还是修改
  1496. if (!this.id) {
  1497. // 新增
  1498. createVip(obj).then((res) => {
  1499. if (res.code == 200) {
  1500. if (res.data == "ING") {
  1501. this.$confirm(
  1502. "课程提交成功,已提交运营主管审批,审批通过后,课程后创建成功!",
  1503. "提示",
  1504. {
  1505. confirmButtonText: "确定",
  1506. type: "warning",
  1507. }
  1508. ).then(() => {
  1509. // this.$message({
  1510. // type: 'success',
  1511. // message: '提交成功!'
  1512. // });
  1513. this.$message.success("提交成功");
  1514. this.$store.dispatch("delVisitedViews", this.$route);
  1515. this.$router.push({
  1516. path: "/vipManager/vipList",
  1517. query: {
  1518. rules: this.rules,
  1519. searchForm: this.searchForm,
  1520. },
  1521. });
  1522. });
  1523. } else {
  1524. this.$message.success("恭喜您创建成功");
  1525. this.$store.dispatch("delVisitedViews", this.$route);
  1526. this.$router.push({
  1527. path: "/vipManager/vipList",
  1528. query: {
  1529. rules: this.rules,
  1530. searchForm: this.searchForm,
  1531. },
  1532. });
  1533. }
  1534. }
  1535. });
  1536. } else {
  1537. // 修改
  1538. obj.vipGroupApplyBaseInfo.id = this.id;
  1539. updateVipBaseInfo(obj.vipGroupApplyBaseInfo).then((res) => {});
  1540. }
  1541. },
  1542. setSection(val) {
  1543. this.leftForm.section = "";
  1544. this.rightForm.offlineCourse = "";
  1545. this.rightForm.onlineCourse = "";
  1546. // this.leftForm.courseType = "";
  1547. if (val) {
  1548. getTeachSchool({
  1549. userId: val,
  1550. }).then((res) => {
  1551. if (res.code == 200) {
  1552. this.scetionList = res.data;
  1553. }
  1554. });
  1555. }
  1556. // for (let i in this.teacherList) {
  1557. // if (this.teacherList[i].id == val) {
  1558. // // 根据分部id去获取课程形式
  1559. // vipGroupCategory({ organId: this.teacherList[i].organId }).then(
  1560. // res => {
  1561. // if (res.code == 200) {
  1562. // this.courseTypeList = res.data;
  1563. // }
  1564. // }
  1565. // );
  1566. // }
  1567. // }
  1568. // this.getClassOrgan(); // 获取公用部分
  1569. },
  1570. // getClassOrgan() {
  1571. // // 获取公用分部
  1572. // const leftForm = this.leftForm;
  1573. // let teacher = leftForm.teacher ? leftForm.teacher : null;
  1574. // let educationalTeacherId = leftForm.educationalTeacherId
  1575. // ? leftForm.educationalTeacherId
  1576. // : null;
  1577. // leftForm.classOrganId = null; // 重置课程分部数据
  1578. // this.classOrganList = [];
  1579. // // 初始化上课学生
  1580. // this.studentList = [];
  1581. // this.leftForm.students = [];
  1582. // if (!teacher || !educationalTeacherId) {
  1583. // // 如果没有选择指导老师和乐团主管则不请求
  1584. // return;
  1585. // }
  1586. // getPublicOrgans({
  1587. // teacherId: teacher,
  1588. // eduTeacherId: educationalTeacherId,
  1589. // }).then((res) => {
  1590. // if (res.code == 200) {
  1591. // let result = res.data ? res.data : [];
  1592. // this.classOrganList = result;
  1593. // }
  1594. // });
  1595. // },
  1596. onClassChange(val) {
  1597. // 课程分部改变时
  1598. // 老师 乐团主管 都要重置
  1599. this.studentList = [];
  1600. this.$set(this.leftForm, "students", []);
  1601. this.$set(this.leftForm, "teacher", "");
  1602. this.$set(this.leftForm, "educationalTeacherId", "");
  1603. this.$set(this.leftForm, "section", "");
  1604. this.$set(this.leftForm, "activeType", "");
  1605. this.$set(this.leftForm, "classTime", "");
  1606. this.$set(this.leftForm, "subject", "");
  1607. // this.leftForm.students = [];
  1608. // this.leftForm.teacherId = "";
  1609. // this.leftForm.educationalTeacherId = "";
  1610. this.courseTypeList = [];
  1611. if (this.leftForm.courseType) {
  1612. this.$set(this.leftForm, "courseType", null);
  1613. }
  1614. // this.leftForm.courseType = null;
  1615. if (val) {
  1616. vipGroupCategory({
  1617. organId: val,
  1618. }).then((res) => {
  1619. if (res.code == 200) {
  1620. this.courseTypeList = res.data;
  1621. }
  1622. });
  1623. // 获取老师
  1624. // 获取乐团主管
  1625. findEducationUsers({ organId: val }).then((res) => {
  1626. if (res.code == 200) {
  1627. this.educationList = res.data;
  1628. }
  1629. });
  1630. }
  1631. },
  1632. onCancel() {
  1633. this.$store.dispatch("delVisitedViews", this.$route);
  1634. this.$router.push({
  1635. path: "/vipManager/vipList",
  1636. query: {
  1637. rules: this.rules,
  1638. searchForm: this.searchForm,
  1639. },
  1640. });
  1641. },
  1642. setCourse() {
  1643. if (
  1644. this.hotType == "GIVE_CLASS" &&
  1645. this.isGiveClass &&
  1646. !this.centerForm.radio
  1647. ) {
  1648. this.$message.error("您还未选择赠课类型");
  1649. return;
  1650. }
  1651. this.$refs["leftForm"].validate((vali) => {
  1652. if (vali) {
  1653. let centerForm = this.centerForm;
  1654. if (
  1655. this.hotType == "DISCOUNT" &&
  1656. this.maxCourseNum &&
  1657. this.minCourseNum
  1658. ) {
  1659. // 判断线上或线下总和大于排课次数
  1660. let onlineNum = centerForm.onlineCourseNum || 0;
  1661. let offlineNum = centerForm.offlineCourseNum || 0;
  1662. let allNUm = parseInt(onlineNum) + parseInt(offlineNum);
  1663. if (allNUm > this.maxCourseNum || allNUm < this.minCourseNum) {
  1664. this.$message.error("待排课数不可超过该活动限制");
  1665. return;
  1666. }
  1667. }
  1668. this.dialogFormVisible = true;
  1669. }
  1670. });
  1671. },
  1672. setVipInfo(data) {
  1673. // this.leftForm.name = data.name;
  1674. this.leftForm.subject = parseInt(data.subjectIdList);
  1675. // 激活声部下的所有老师
  1676. this.changeSubject(parseInt(data.subjectIdList));
  1677. // 设置老师
  1678. this.leftForm.teacher = data.userId;
  1679. this.setSection(data.userId);
  1680. // 课程形式
  1681. this.leftForm.courseType = data.vipGroupCategoryId;
  1682. // 获取课程形式下的活动方案
  1683. this.changeType(this.leftForm.courseType);
  1684. // 根据课程形式获取活动方案
  1685. this.leftForm.activeType = data.vipGroupActivityId;
  1686. setTimeout((res) => {
  1687. this.chioseActive(data.vipGroupActivityId);
  1688. }, 1000);
  1689. this.leftForm.section = data.teacherSchoolId;
  1690. this.leftForm.classNum = data.studentNum;
  1691. this.leftForm.classTime = data.singleClassMinutes;
  1692. this.leftForm.signUpStart = data.registrationStartTime;
  1693. this.leftForm.signUpEnd = data.paymentExpireDate;
  1694. this.centerForm.onlineCourseNum = data.onlineClassesNum;
  1695. this.centerForm.offlineCourseNum = data.offlineCourseNum;
  1696. /**
  1697. * rightForm: {
  1698. onlineCourse: '',
  1699. offlineCourse: '',
  1700. onlinePrice: '',
  1701. offlinePrice: '',
  1702. allPrice: ''
  1703. },
  1704. *
  1705. */
  1706. this.rightForm.onlineCourse = data.onlineTeacherSalary;
  1707. this.rightForm.onlinePrice = data.onlineClassesUnitPrice;
  1708. this.rightForm.offlineCourse = data.offlineTeacherSalary;
  1709. this.rightForm.offlinePrice = data.offlineClassesUnitPrice;
  1710. this.rightForm.allPrice = data.totalPrice;
  1711. //subjectIdList
  1712. },
  1713. remoteMethod(query) {
  1714. if (query !== "") {
  1715. this.remoteLoading = true;
  1716. // 发请求搜索
  1717. const url = "/api-web/studentManage/queryOrganStudentList";
  1718. const options = {
  1719. method: "get",
  1720. headers: {
  1721. Authorization: getToken(),
  1722. },
  1723. params: {
  1724. rows: 9999,
  1725. search: query,
  1726. organId: this.leftForm.classOrganId,
  1727. },
  1728. url,
  1729. };
  1730. this.remoteLoading = true;
  1731. // this.studentList = []
  1732. axios(options).then((res) => {
  1733. this.remoteLoading = false;
  1734. let result = res.data;
  1735. if (result.code == 200) {
  1736. // Array.prototype.splice.apply(this.studentList, result.data.rows);
  1737. if (result.data.rows && result.data.rows.length > 0) {
  1738. result.data.rows.forEach((item) => {
  1739. this.studentList.unshift(item);
  1740. });
  1741. this.studentList = this.deweight(this.studentList, "userId");
  1742. }
  1743. // this.studentList = this.studentList.concat(result.data.rows);
  1744. }
  1745. });
  1746. // queryStudentList({ rows: 100, search: query }).then(res => {
  1747. // if (res.code == 200) {
  1748. // this.remoteLoading = false;
  1749. // this.studentList = this.studentList.concat(res.data.rows);
  1750. // this.unique(this.studentList, "userId");
  1751. // }
  1752. // });
  1753. }
  1754. },
  1755. changeStudent(val) {
  1756. this.activeStudentList = [];
  1757. this.studentList.forEach((stu) => {
  1758. if (val.indexOf(stu.userId) != -1) {
  1759. this.activeStudentList.push({
  1760. studentId: stu.userId,
  1761. userName: stu.username,
  1762. onlineClassesUnitPrice: this.rightForm.onlinePrice,
  1763. offlineClassesUnitPrice: this.rightForm.offlinePrice,
  1764. paymentPrice: "",
  1765. });
  1766. }
  1767. });
  1768. },
  1769. // 制定属性去重
  1770. deweight(arr, key) {
  1771. let res = [];
  1772. arr.forEach((item) => {
  1773. let list = [];
  1774. res.forEach((resitem) => {
  1775. list.push(resitem[key]);
  1776. });
  1777. if (list.indexOf(item[key]) === -1) {
  1778. res.push(item);
  1779. }
  1780. });
  1781. return res;
  1782. },
  1783. getStartTime(val) {
  1784. if (val) {
  1785. let date = dayjs(new Date()).format("YYYY-MM-DD");
  1786. this.maskForm.endTime = addTimerFormMinute(
  1787. date,
  1788. val,
  1789. this.leftForm.classTime
  1790. );
  1791. } else {
  1792. this.maskForm.endTime = "";
  1793. }
  1794. if (!this.maskForm.endTime) {
  1795. this.maskForm.startTime = "";
  1796. }
  1797. },
  1798. changeStudentMoney(val) {
  1799. if (val) {
  1800. this.computationalBtn = false;
  1801. }
  1802. },
  1803. },
  1804. // watch: {
  1805. // rightForm: {
  1806. // handler (newName, oldName) {
  1807. // this.computationalBtn = false
  1808. // },
  1809. // deep: true
  1810. // }
  1811. // }
  1812. };
  1813. </script>
  1814. <style lang="scss" scoped>
  1815. .computeMoney {
  1816. margin-top: 10px;
  1817. float: right;
  1818. }
  1819. .m-core {
  1820. margin-top: 30px;
  1821. // display: flex;
  1822. // flex-direction: row;
  1823. // justify-content: space-around;
  1824. .el-input {
  1825. width: 180px;
  1826. }
  1827. h4 {
  1828. font-size: 16px;
  1829. background-color: #ccc;
  1830. color: #fff;
  1831. // text-align: center;
  1832. width: 100%;
  1833. height: 40px;
  1834. line-height: 40px;
  1835. margin-bottom: 20px;
  1836. padding: 0 20px;
  1837. }
  1838. // .vipLeft {
  1839. // width: 400px;
  1840. // // h4 {
  1841. // // font-size: 16px;
  1842. // // background-color: #ccc;
  1843. // // color: #fff;
  1844. // // text-align: center;
  1845. // // width: 100%;
  1846. // // height: 40px;
  1847. // // line-height: 40px;
  1848. // // margin-bottom: 20px;
  1849. // // }
  1850. // }
  1851. // .center {
  1852. // width: 400px;
  1853. // }
  1854. // .right {
  1855. // width: 400px;
  1856. // }
  1857. }
  1858. .vipMsg {
  1859. margin-bottom: 20px;
  1860. }
  1861. .planList {
  1862. padding: 0 25px;
  1863. .planTop {
  1864. height: 40px;
  1865. line-height: 40px;
  1866. display: flex;
  1867. flex-direction: row;
  1868. justify-content: space-between;
  1869. border-bottom: 1px solid #ccc;
  1870. margin-top: 20px;
  1871. > p {
  1872. font-size: 14px;
  1873. }
  1874. }
  1875. .planCore {
  1876. .row {
  1877. width: 100%;
  1878. display: flex;
  1879. flex-direction: row;
  1880. justify-content: space-between;
  1881. flex-wrap: nowrap;
  1882. height: 40px;
  1883. line-height: 40px;
  1884. font-size: 14px;
  1885. text-align: center;
  1886. div {
  1887. width: 87px;
  1888. }
  1889. // div {
  1890. // &:nth-child(1) {
  1891. // text-align: left;
  1892. // }
  1893. // }
  1894. }
  1895. }
  1896. }
  1897. .okBtn {
  1898. width: 120px;
  1899. height: 40px;
  1900. line-height: 40px;
  1901. text-align: center;
  1902. color: #fff;
  1903. border-radius: 4px;
  1904. margin-right: 20px;
  1905. cursor: pointer;
  1906. background-color: #f97215;
  1907. float: right;
  1908. }
  1909. .submitP {
  1910. margin-bottom: 20px;
  1911. font-size: 14px;
  1912. padding-left: 24px;
  1913. }
  1914. </style>