index.vue 50 KB

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