coursePlan.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. <template>
  2. <div class='father-Wrap'>
  3. <div class="topWrap" v-if="type != 'resetTeam'">
  4. <el-page-header @back="goback"
  5. style='padding-bottom:30px;'
  6. content="批量排课">
  7. </el-page-header>
  8. </div>
  9. <div class='course-container'>
  10. <div class="left">
  11. <el-form :model="leftFrom"
  12. ref='leftFrom'
  13. :rules="leftRules"
  14. :inline="true">
  15. <el-form-item label="合奏班"
  16. prop='all'>
  17. <el-select v-model="leftFrom.all"
  18. @change="changeMixClass">
  19. <el-option v-for="(item,index) in maxClassList"
  20. :key='index'
  21. :value="item.id"
  22. :label="item.name"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="排课时间"
  26. prop="time">
  27. <!-- value-format="yyyy-MM-dd" -->
  28. <el-date-picker v-model="leftFrom.time"
  29. style="width:180px;"
  30. align="right"
  31. type="date"
  32. placeholder="选择日期">
  33. </el-date-picker>
  34. </el-form-item>
  35. <el-form-item label="排课次数"
  36. prop="num">
  37. <el-input type="number"
  38. v-model="leftFrom.num"></el-input>
  39. </el-form-item>
  40. </el-form>
  41. <p>周次循环<span style="margin-left:10px;">
  42. <el-button type="text"
  43. @click="addWeekDay">添加</el-button>
  44. </span></p>
  45. <div class="checkWrap">
  46. <el-checkbox-group v-model="checkList">
  47. <div class="chioseday"
  48. v-for="(item,index) in week"
  49. :key="index">
  50. <!-- <el-checkbox :label="index"
  51. v-model="item.isCheck">{{item.name}}</el-checkbox> -->
  52. <el-select class='weekSelect'
  53. style="width:100px!important"
  54. placeholder="星期几"
  55. v-model="item.weekNum">
  56. <el-option v-for='(item,index) in weekList'
  57. :key="index"
  58. :label="item.label"
  59. :value="item.value"></el-option>
  60. </el-select>
  61. <el-time-select placeholder="起始"
  62. @change='changeTimer(item)'
  63. v-model="item.startTime"
  64. :picker-options="{
  65. start: '06:30',
  66. step: '00:05',
  67. end: '23:30'
  68. }">
  69. </el-time-select>
  70. <el-time-select placeholder="结束"
  71. v-model="item.endTime"
  72. :picker-options="{
  73. start: '06:30',
  74. step: '00:15',
  75. end: '23:30',
  76. minTime: item.startTime
  77. }">
  78. </el-time-select>
  79. <el-button style="margin-left:10px;"
  80. type="text"
  81. @click="removeWeek(item)">删除</el-button>
  82. </div>
  83. </el-checkbox-group>
  84. <div class="holidayWrap">
  85. <el-checkbox v-model="isholiday">跳过节假日</el-checkbox>
  86. <div class="quickBtn"
  87. @click="classCard">一键排课</div>
  88. </div>
  89. <!-- <div class="btnWrap">
  90. <div class="closeBtn"
  91. @click='resetaLL'>取消排课</div>
  92. <div class="okBtn"
  93. @click="classCard">一键排课</div>
  94. </div> -->
  95. </div>
  96. </div>
  97. <div class="right">
  98. <div class="newBand"
  99. style='float:right'
  100. @click="multipleReset">批量修改</div>
  101. <el-table :data='tableList'
  102. style="width: 1160px"
  103. :header-cell-style="{background:'#EDEEF0',color:'#444'}"
  104. @selection-change="handleSelectionChange">
  105. <el-table-column type="selection"
  106. width="55">
  107. </el-table-column>
  108. <el-table-column label="课次"
  109. width="55">
  110. <template slot-scope="scope">
  111. <div>
  112. {{ scope.$index+1 }}
  113. </div>
  114. </template>
  115. </el-table-column>
  116. <el-table-column prop="classDate"
  117. align="center"
  118. label="日期">
  119. </el-table-column>
  120. <el-table-column prop="week"
  121. align="center"
  122. label="星期">
  123. </el-table-column>
  124. <el-table-column label="课程类型"
  125. align="center">
  126. <template slot-scope="scope">
  127. <div>
  128. {{scope.row.type |coursesType }}
  129. </div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column prop="name"
  133. align="center"
  134. label="合奏班名称">
  135. </el-table-column>
  136. <!-- <el-table-column prop="classTime"
  137. label="上课时间"
  138. width="180">
  139. </el-table-column> -->
  140. <el-table-column label="操作"
  141. width="310">
  142. <template slot-scope="scope">
  143. <div>
  144. <el-button type="text"
  145. @click="OpenSign(scope.row)">查看</el-button>
  146. <el-button type="text"
  147. @click='resetMixCourse(scope.row)'>变更</el-button>
  148. <el-button type="text"
  149. @click='skipClass(scope.row)'>跳过此天</el-button>
  150. </div>
  151. </template>
  152. </el-table-column>
  153. </el-table>
  154. <div class="btnWrap"
  155. style="margin-top:40px;">
  156. <div class="nextBtn"
  157. @click="resetaLL">取消排课</div>
  158. <div class="okBtn"
  159. @click='submitInfo'>确定排课</div>
  160. </div>
  161. </div>
  162. <el-dialog :visible.sync="resetAllClassVisible"
  163. width="450px">
  164. <p style='margin-bottom:20px'>{{resetAllTitle}}</p>
  165. <div class="resetWrap">
  166. <el-select v-model="chioseType">
  167. <el-option v-for='(item,index) in courseTypeList'
  168. :key="index"
  169. :label="item.name"
  170. :value="item.value"></el-option>
  171. </el-select>
  172. <!-- signBtnActive: false,
  173. skipBtnActive: false -->
  174. <!-- <div class="restBtn"
  175. :class="signBtnActive?'active':''"
  176. v-if='buttonType == "SINGLE"'
  177. @click="resetClass">修改为合奏课</div>
  178. <div class="restBtn"
  179. v-if='buttonType == "MIX"'
  180. :class="signBtnActive?'active':''"
  181. @click="resetClass">修改为单技课</div> -->
  182. <!-- <div class="restBtn"
  183. @click='skipClass'
  184. :class="skipBtnActive?'active':''">跳过此天</div> -->
  185. </div>
  186. <span slot="footer"
  187. class="dialog-footer">
  188. <div class="okBtns"
  189. v-if="!isMultiple"
  190. @click="resetMix(tableActive)">确定</div>
  191. <div class="okBtns"
  192. v-if="isMultiple"
  193. @click="multipleResetMix">确定</div>
  194. </span>
  195. </el-dialog>
  196. <el-dialog :visible.sync="openSignListVisible"
  197. width="450px">
  198. <el-table :data='SignList'>
  199. <el-table-column prop="name"
  200. label="班级">
  201. </el-table-column>
  202. <el-table-column prop="startClassTimeStr"
  203. label="开始时间">
  204. <!-- <template slot-scope="scope">
  205. <div>
  206. <p v-if="scope.row.option == 1">{{scope.row.startClassTimeStr}}</p>
  207. <el-input v-if="scope.row.option == 2"
  208. v-model="scope.row.startClassTimeStr"></el-input>
  209. </div>
  210. </template> -->
  211. </el-table-column>
  212. <el-table-column prop="endClassTimeStr"
  213. label="结束时间">
  214. <!-- <template slot-scope="scope">
  215. <div>
  216. <p v-if="scope.row.option == 1">{{scope.row.endClassTimeStr}}</p>
  217. <el-input v-if="scope.row.option == 2"
  218. v-model="scope.row.endClassTimeStr"></el-input>
  219. </div>
  220. </template> -->
  221. </el-table-column>
  222. <!-- <el-table-column prop="date"
  223. label="操作">
  224. <template slot-scope="scope">
  225. <div>
  226. <el-button type="text"
  227. v-if="scope.row.option == 2"
  228. @click="savecolumn(scope.row)">保存</el-button>
  229. <el-button type="text"
  230. v-if="scope.row.option == 1"
  231. @click="savecolumn(scope.row)">修改</el-button>
  232. </div>
  233. </template>
  234. </el-table-column> -->
  235. </el-table>
  236. <span slot="footer"
  237. class="dialog-footer">
  238. <div class="okBtns"
  239. @click="resetSiginClass">确定</div>
  240. </span>
  241. </el-dialog>
  242. </div>
  243. <!-- <div class="btnWrap"
  244. style="margin-top:20px;">
  245. <div class="nextBtn"
  246. @click="goback">返回</div>
  247. <div class="okBtn"
  248. style="margin-right:30px;"
  249. @click="gotoNext">确定</div>
  250. </div> -->
  251. </div>
  252. </template>
  253. <script>
  254. import { Loading } from 'element-ui';
  255. import { getAllClass, getAllSignClass, workOut, checkCourse } from '@/api/buildTeam'
  256. import axios from 'axios'
  257. import qs from 'qs'
  258. export default {
  259. // props: {
  260. // teamid: {
  261. // type: String,
  262. // required: true
  263. // }
  264. // },
  265. data () {
  266. return {
  267. type: this.$route.query.type, // 当前页面类型
  268. resetAllClassVisible: false, //修改合奏课弹窗
  269. openSignListVisible: false, // 修改单个单技课的弹窗
  270. first: true,
  271. leftFrom: {
  272. all: '',
  273. time: '',
  274. num: ''
  275. },
  276. tableList: [],
  277. checkList: [], // 选中的周几
  278. week: [
  279. {
  280. startTime: '',
  281. endTime: '',
  282. weekNum: '',
  283. id: new Date().getTime()
  284. }
  285. ],
  286. weekList: [
  287. {
  288. label: '星期日',
  289. value: 0
  290. },
  291. {
  292. label: '星期一',
  293. value: 1
  294. },
  295. {
  296. label: '星期二',
  297. value: 2
  298. },
  299. {
  300. label: '星期三',
  301. value: 3
  302. },
  303. {
  304. label: '星期四',
  305. value: 4
  306. },
  307. {
  308. label: '星期五',
  309. value: 5
  310. },
  311. {
  312. label: '星期六',
  313. value: 6
  314. },
  315. ],
  316. weekDay: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
  317. maxClassList: [], // 所有的合奏班
  318. activeSingleList: [], // 合奏班下的所有单技班
  319. isholiday: false,
  320. classCardList: [], //这个是传给后台的真正数据集合
  321. allChioseDate: [], // 记录所有准备排课的日期
  322. holidayList: [],
  323. leftRules: {
  324. all: [{ required: true, message: '请输选择合奏班', trigger: 'blur' }],
  325. time: [{ required: true, message: '请选择排课时间', trigger: 'blur' }],
  326. num: [{ required: true, message: '请输入排课次数', trigger: 'blur' }]
  327. },
  328. resetAllTitle: '', // 弹窗名
  329. buttonType: '',
  330. activeTime: '', // 选中的当前时间课
  331. signBtnActive: false,
  332. skipBtnActive: false,
  333. SignList: [], // 存储当前合奏课里当天的所有单机课
  334. courseTypeList: [
  335. { name: '单技课', value: 'SINGLE' },
  336. { name: '集训单技课', value: 'TRAINING_SINGLE' },
  337. { name: '合奏课', value: 'MIX' },
  338. { name: '集训合奏课', value: 'TRAINING_MIX' },
  339. { name: '课堂课', value: 'CLASSROOM' },
  340. ],
  341. chioseType: '',
  342. tableActive: null, // 当前操作的行
  343. startClassTimeStr: '',
  344. endClassTimeStr: '',
  345. teamid: '',
  346. activeList: [], // 勾选中的项
  347. isMultiple: false
  348. }
  349. },
  350. created () {
  351. this.teamid = this.$route.query.id;
  352. sessionStorage.setItem('resetCode', 3)
  353. sessionStorage.setItem('setStep', 2)
  354. },
  355. mounted () {
  356. // 根据乐团id 查询 此乐团所有的合奏班
  357. getAllClass({ musicGroupId: this.teamid }).then(res => {
  358. if (res.code == 200) {
  359. this.maxClassList = res.data;
  360. }
  361. })
  362. let year = new Date().getFullYear();
  363. axios.post('/jiari/', qs.stringify({ d: year })).then(res => {
  364. if (res) {
  365. this.holidayList = Object.keys(res.data[year])
  366. }
  367. })
  368. },
  369. methods: {
  370. changeTimer (item) {
  371. item.endTime = '';
  372. },
  373. // 勾选table触发
  374. handleSelectionChange (val) {
  375. this.activeList = val;
  376. },
  377. // 确定排课
  378. submitInfo () {
  379. this.$confirm('课表无误,确定排课', '提示', {
  380. confirmButtonText: '确定',
  381. cancelButtonText: '取消',
  382. type: 'warning'
  383. }).then(() => {
  384. workOut({ musicGroupID: this.teamid, courseSchedules: this.classCardList }).then(res => {
  385. if (res.code == 200) {
  386. this.$message.success('恭喜您排课成功')
  387. this.classCardList = [];
  388. this.SignList = [];
  389. this.tableList = [];
  390. }
  391. }).catch(res => {
  392. // this.tableList = [];
  393. this.classCardList = [];
  394. this.SignList = [];
  395. this.tableList = [];
  396. })
  397. }).catch(() => {
  398. });
  399. },
  400. // 一键排课
  401. classCard () {
  402. // 验证合奏班里等数据是否填写
  403. let flag = false
  404. this.$refs['leftFrom'].validate(val => {
  405. if (val) {
  406. flag = true
  407. }
  408. })
  409. if (!flag) {
  410. this.$message.error('请填写必要参数在进行排课')
  411. return;
  412. }
  413. // 验证周次循环里数据是否完成与有效
  414. // this.checkTime();
  415. let classCount = parseInt(this.leftFrom.num);
  416. let date = this.leftFrom.time;
  417. // 1 排课时间 2.排课次数 3.排课周期集合 4.排课合奏班的信息
  418. this.workOut(date, classCount, this.week, this.leftFrom.all)
  419. this.$refs['leftFrom'].resetFields();
  420. this.week = this.$options.data().week;
  421. this.checkList = [];
  422. },
  423. chioseWeek (val) {
  424. },
  425. getThinkDate (date, num, type = 1) {
  426. let Stamp = new Date(date.getTime());
  427. Stamp.setDate(Stamp.getDate() + parseInt(num)) // 获取当前月数的第几天
  428. var year = Stamp.getFullYear(); //获取完整的年份(4位,1970-????)
  429. var month = Stamp.getMonth() + 1; //获取当前月份(0-11,0代表1月)
  430. var mvar = '';
  431. if (month < 10) {
  432. mvar = '0' + month;
  433. } else {
  434. mvar = month + '';
  435. }
  436. var day = Stamp.getDate();
  437. var dvar = '';
  438. if (day < 10) {
  439. dvar = '0' + day;
  440. } else {
  441. dvar = day + '';
  442. }
  443. if (type == 2) {
  444. return mvar + dvar;
  445. } else {
  446. return year + "-" + mvar + '-' + dvar;
  447. }
  448. },
  449. changeMixClass (val) {
  450. // 根据合奏班id获取合奏班下的所有单技班
  451. console.log(this.first);
  452. let activeVal = val;
  453. if (!this.first) {
  454. // Object.assign(this.$data, this.$options.data());
  455. // getAllClass({ musicGroupId: this.teamid }).then(res => {
  456. // if (res.code == 200) {
  457. // this.maxClassList = res.data;
  458. // }
  459. // })
  460. this.classCardList = [];
  461. this.SignList = [];
  462. this.tableList = [];
  463. this.leftFrom.all = activeVal
  464. }
  465. this.first = false;
  466. this.activeSingleList = [];
  467. getAllSignClass({ musicGroupId: this.teamid, mixClassGroupId: val }).then(res => {
  468. if (res.code == 200) {
  469. this.activeSingleList = res.data.map(item => {
  470. item.mixid = val
  471. return item;
  472. });
  473. }
  474. })
  475. },
  476. // 修改
  477. resetMixCourse (row) {
  478. // console.log(row);
  479. this.resetAllClassVisible = true;
  480. this.resetAllTitle = `将${row.classDate} ,${row.week}修改`;
  481. this.buttonType = row.type;
  482. this.activeTime = row.classDate; // 选中那一行的日期
  483. this.startClassTimeStr = row.startClassTimeStr
  484. this.endClassTimeStr = row.endClassTimeStr;
  485. this.chioseType = row.type;
  486. this.tableActive = row;
  487. },
  488. resetClass () {
  489. this.signBtnActive = !this.signBtnActive;
  490. },
  491. // 批量修改
  492. multipleReset () {
  493. if (this.activeList.length < 1) {
  494. this.$message.error('请至少选择一节已上课时')
  495. return
  496. }
  497. this.isMultiple = true;
  498. this.resetAllClassVisible = true;
  499. this.resetAllTitle = `批量修改`;
  500. // this.resetMixCourse()
  501. },
  502. skipClass () {
  503. // 这里是跳过此天
  504. let loadingInstance = Loading.service({
  505. lock: true,
  506. text: '加载中……',
  507. background: 'rgba(0, 0, 0, 0.7)'
  508. });
  509. setTimeout(res => {
  510. loadingInstance.close();
  511. }, 1000)
  512. let lastTime = this.tableList[this.tableList.length - 1].classDate;
  513. let id = this.tableList[this.tableList.length - 1].id;
  514. let startClassTime;
  515. let endClassTime;
  516. let weekNum;
  517. for (let i in this.tableList) {
  518. if (row.classDate == this.tableList[i].classDate && row.startClassTimeStr == this.tableList[i].startClassTimeStr && row.endClassTimeStr == this.tableList[i].endClassTimeStr) {
  519. weekNum = this.tableList[i].weekNum;
  520. startClassTime = this.tableList[i].startClassTimeStr;
  521. endClassTime = this.tableList[i].endClassTimeStr;
  522. this.tableList.splice(i, 1);
  523. }
  524. }
  525. for (let j = 0; j < this.classCardList.length; j++) {
  526. if (this.classCardList[j].classDate == row.classDate && row.startClassTimeStr == this.classCardList[j].startClassTimeStr && row.endClassTimeStr == this.classCardList[j].endClassTimeStr) {
  527. this.classCardList.splice(j, 1);
  528. j--;
  529. }
  530. }
  531. // console.log(lastTime, weekNum, id);
  532. // 这里要往后面排一天
  533. let obj = {
  534. startTime: endClassTime,
  535. endTime: startClassTime,
  536. weekNum: weekNum,
  537. id: new Date().getTime()
  538. }
  539. lastTime = lastTime.replace(/-/g, '/')
  540. var newdate = new Date(lastTime);
  541. newdate.setDate(newdate.getDate() + 1);
  542. // console.log(newdate);
  543. // 最后一堂课加一天
  544. // newdate.setDate(newdate.getDate() + 7);
  545. this.workOut(newdate, 1, [obj], id, 2, startClassTime, endClassTime);
  546. // this.$message.success('修改成功');
  547. },
  548. multipleResetMix () {
  549. this.isMultiple = false;
  550. // 批量更变课程类型
  551. console.log('点击批量修改')
  552. for (let i in this.activeList) {
  553. this.resetMix(this.activeList[i])
  554. }
  555. },
  556. resetMix (row) {
  557. // 当前行的课程类型
  558. this.activeTime = row.classDate; // 选中那一行的日期
  559. this.startClassTimeStr = row.startClassTimeStr
  560. this.endClassTimeStr = row.endClassTimeStr;
  561. console.log(row.classDate);
  562. // let activeTpye = this.tableActive.type;
  563. let startClassTime;
  564. let endClassTime;
  565. if (this.chioseType.indexOf('MIX') != -1) {
  566. // 改合奏
  567. // 删除真实课表里的所有相关单技课
  568. for (let i = 0; i < this.classCardList.length; i++) {
  569. if (row.classDate == this.classCardList[i].classDate && this.startClassTimeStr == this.classCardList[i].startClassTimeStr && this.endClassTimeStr == this.classCardList[i].endClassTimeStr) {
  570. this.classCardList.splice(i, 1);
  571. i--;
  572. }
  573. }
  574. // 修改提交表里的时间
  575. // 单技改合奏
  576. for (let i in this.tableList) {
  577. if (row.classDate == this.tableList[i].classDate && this.startClassTimeStr == this.tableList[i].startClassTimeStr && this.endClassTimeStr == this.tableList[i].endClassTimeStr) {
  578. console.log('修改合奏课的类型')
  579. this.tableList[i].type = this.chioseType;
  580. startClassTime = this.tableList[i].startClassTime;
  581. endClassTime = this.tableList[i].endClassTime;
  582. // this.tableList[i].classGroupId = this.tableList[i].id;
  583. this.classCardList.push(this.tableList[i]);
  584. }
  585. }
  586. //
  587. } else if (this.chioseType.indexOf('SINGLE') != -1 || this.chioseType.indexOf('CLASSROOM') != -1) {
  588. console.log(this.tableList)
  589. // 合奏改单技
  590. for (let i in this.tableList) {
  591. if (row.classDate == this.tableList[i].classDate && this.startClassTimeStr == this.tableList[i].startClassTimeStr && this.endClassTimeStr == this.tableList[i].endClassTimeStr) {
  592. this.tableList[i].type = this.chioseType;
  593. startClassTime = this.tableList[i].startClassTime;
  594. endClassTime = this.tableList[i].endClassTime;
  595. }
  596. }
  597. let activeTableItem = {};
  598. // 修改提交表里的状态
  599. for (let j = 0; j < this.classCardList.length; j++) {
  600. for (let i in this.tableList) {
  601. if (row.classDate == this.classCardList[j].classDate && this.startClassTimeStr == this.classCardList[j].startClassTimeStr && this.endClassTimeStr == this.classCardList[j].endClassTimeStr) {
  602. this.classCardList.splice(j, 1);
  603. j--
  604. }
  605. if (row.classDate == this.tableList[i].classDate && this.startClassTimeStr == this.tableList[i].startClassTimeStr && this.endClassTimeStr == this.tableList[i].endClassTimeStr) {
  606. activeTableItem = this.tableList[i];
  607. }
  608. }
  609. }
  610. //添加单机班课
  611. for (let z in this.activeSingleList) {
  612. let obj = {
  613. 'classDate': activeTableItem.classDate,
  614. 'week': activeTableItem.week,
  615. 'type': this.chioseType,
  616. 'mixid': activeTableItem.mixid,
  617. 'id': this.activeSingleList[z].id,
  618. 'name': this.activeSingleList[z].name,
  619. 'classTime': activeTableItem.classTime,
  620. 'startClassTimeStr': activeTableItem.startClassTimeStr,
  621. 'endClassTimeStr': activeTableItem.endClassTimeStr,
  622. 'weekNum': activeTableItem.weekNum,
  623. 'classGroupId': this.activeSingleList[z].id,
  624. }
  625. this.classCardList.push(obj);
  626. }
  627. }
  628. console.log(this.classCardList)
  629. this.resetAllClassVisible = false;
  630. },
  631. // 排课逻辑
  632. workOut (date, classCount, weekArr, id, type = 1, startTime = '', endTime = '') {
  633. // 这里是一天排一节课 现在要改成一天排多节
  634. while (classCount && classCount > 0) {
  635. for (let i in weekArr) {
  636. let date1 = new Date(date.getTime());
  637. let num; // 下次上课上几天后
  638. // 星期4 - 当前是星期几 =>
  639. weekArr[i].weekNum - date.getDay() >= 0 ? num = weekArr[i].weekNum - date.getDay() : num = weekArr[i].weekNum - date.getDay() + 7
  640. let dataStr = this.getThinkDate(date, num);
  641. let monthDay = this.getThinkDate(date1, num, 2)
  642. if (this.isholiday) {
  643. if (this.holidayList.indexOf(monthDay) != -1) {
  644. // 这里说明有节假日
  645. continue
  646. }
  647. }
  648. let className;
  649. this.maxClassList.map(item => {
  650. if (item.id == id) {
  651. className = item.name;
  652. return item.name
  653. }
  654. })
  655. // 排的是合奏班
  656. if (!startTime) {
  657. // 有这个说明是修改=> 没有说明是添加
  658. if (!this.week[i].startTime || !this.week[i].endTime) {
  659. // 提示 上课时间必填
  660. // console.log('进入时间判断')
  661. this.$message.error('勾选日期的上课时间段必填');
  662. return;
  663. }
  664. }
  665. let nowStartTime = this.week[i].startTime || startTime;
  666. let nowEndTime = this.week[i].endTime || endTime;
  667. // date: this.getNowFormatDate(date),
  668. this.tableList.push({
  669. 'classDate': dataStr,
  670. 'week': this.weekDay[weekArr[i].weekNum],
  671. 'type': 'SINGLE',
  672. 'id': id,
  673. 'mixid': id,
  674. 'name': className,
  675. 'classTime': nowStartTime + '-' + nowEndTime,
  676. 'startClassTimeStr': nowStartTime,
  677. 'endClassTimeStr': nowEndTime,
  678. 'weekNum': weekArr[i].weekNum,
  679. 'classGroupId': id
  680. })
  681. // 这里我排单技课
  682. // date: this.getNowFormatDate(date),
  683. for (let j in this.activeSingleList) {
  684. this.classCardList.push({
  685. 'classDate': dataStr,
  686. 'classGroupId': this.activeSingleList[j].id,
  687. 'startClassTimeStr': nowStartTime,
  688. 'endClassTimeStr': nowEndTime,
  689. 'type': 'SINGLE',
  690. 'mixid': this.activeSingleList[j].mixid,
  691. 'weekNum': weekArr[i].weekNum,
  692. 'name': this.activeSingleList[j].name,
  693. 'option': 1
  694. })
  695. }
  696. classCount--
  697. if (classCount == 0) break
  698. }
  699. date.setDate(date.getDate() + 7);
  700. }
  701. // 请求排课
  702. },
  703. resetaLL () {
  704. Object.assign(this.$data, this.$options.data());
  705. this.teamid = this.$route.query.id;
  706. getAllClass({ musicGroupId: this.teamid }).then(res => {
  707. if (res.code == 200) {
  708. this.maxClassList = res.data;
  709. }
  710. })
  711. let year = new Date().getFullYear();
  712. axios.post('/jiari/', qs.stringify({ d: year })).then(res => {
  713. this.holidayList = Object.keys(res.data[year])
  714. })
  715. },
  716. // 点击查看
  717. OpenSign (row) {
  718. this.SignList = [];
  719. console.log(this.classCardList)
  720. for (let i in this.classCardList) {
  721. if (this.classCardList[i].mixid == row.mixid && this.classCardList[i].classDate == row.classDate && row.startClassTimeStr == this.classCardList[i].startClassTimeStr && row.endClassTimeStr == this.classCardList[i].endClassTimeStr) {
  722. this.SignList.push(this.classCardList[i])
  723. }
  724. }
  725. console.log(this.SignList);
  726. this.openSignListVisible = true;
  727. },
  728. savecolumn (row) {
  729. // console.log(row);
  730. row.option == 1 ? row.option = 2 : row.option = 1
  731. // console.log(this.SignList);
  732. },
  733. // 重置单技课
  734. resetSiginClass () {
  735. this.openSignListVisible = false;
  736. // for (let i in this.classCardList) {
  737. // for (let j in this.SignList) {
  738. // if (this.SignList[j].classDate == this.classCardList[i].classDate && this.SignList[j].classGroupId == this.classCardList[i].classGroupId) {
  739. // this.classCardList[i] = this.SignList[j];
  740. // this.$message.success('修改成功');
  741. // }
  742. // }
  743. // }
  744. },
  745. submitCardList () {
  746. },
  747. gotoNext () {
  748. checkCourse({ musicGroupId: this.teamid }).then(res => {
  749. if (res.code == 200) {
  750. // ...跳转
  751. }
  752. }).catch(res => {
  753. this.$message.error(res.msg)
  754. })
  755. },
  756. addWeekDay () {
  757. // 添加
  758. this.week.push({
  759. startTime: '',
  760. endTime: '',
  761. weekNum: '',
  762. id: new Date().getTime()
  763. })
  764. },
  765. //删除
  766. removeWeek (item) {
  767. for (let i in this.week) {
  768. if (item.id == this.week[i].id) {
  769. this.week.splice(i, 1);
  770. }
  771. }
  772. },
  773. // 判断时间是否在时间段内
  774. timeIsrange (beginTime, endTime, nowTime) {
  775. var strb = beginTime.split(":");
  776. if (strb.length != 2) {
  777. return false;
  778. }
  779. var stre = endTime.split(":");
  780. if (stre.length != 2) {
  781. return false;
  782. }
  783. var strn = nowTime.split(":");
  784. if (stre.length != 2) {
  785. return false;
  786. }
  787. var b = new Date();
  788. var e = new Date();
  789. var n = new Date();
  790. b.setHours(strb[0]);
  791. b.setMinutes(strb[1]);
  792. e.setHours(stre[0]);
  793. e.setMinutes(stre[1]);
  794. n.setHours(strn[0]);
  795. n.setMinutes(strn[1]);
  796. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() <= 0) {
  797. // 在时间范围内
  798. return true;
  799. } else {
  800. // 不在时间范围内
  801. return false;
  802. }
  803. },
  804. checkTime () {
  805. if (this.week.length <= 0) {
  806. this.$message.error('至少填写一个排课周期')
  807. return false;
  808. }
  809. for (let i in this.week) {
  810. if (!this.week[i].startTime || !this.week[i].endTime || !this.week[i].weekNum) {
  811. this.$message.error('请填写完整的排课周期')
  812. return false;
  813. }
  814. }
  815. },
  816. getNowFormatDate (date) {
  817. var seperator1 = "-";
  818. var year = date.getFullYear();
  819. var month = date.getMonth() + 1;
  820. var strDate = date.getDate();
  821. if (month >= 1 && month <= 9) {
  822. month = "0" + month;
  823. }
  824. if (strDate >= 0 && strDate <= 9) {
  825. strDate = "0" + strDate;
  826. }
  827. var currentdate = year + seperator1 + month + seperator1 + strDate;
  828. return currentdate;
  829. },
  830. goback () {
  831. this.$router.go(-1);
  832. }
  833. },
  834. watch: {
  835. resetAllClassVisible (val) {
  836. if (!val) {
  837. this.signBtnActive = false;
  838. this.skipBtnActive = false;
  839. }
  840. }
  841. }
  842. }
  843. </script>
  844. <style lang="scss" scoped>
  845. .father-Wrap {
  846. padding: 47px 30px;
  847. background-color: #fff;
  848. .topWrap {
  849. display: flex;
  850. flex-direction: row;
  851. justify-content: space-between;
  852. }
  853. }
  854. .course-container {
  855. // border-bottom: 1px solid #ccc;
  856. // height: 600px;
  857. overflow-y: auto;
  858. background-color: #fff;
  859. display: flex;
  860. flex-direction: row;
  861. justify-content: flex-start;
  862. .left {
  863. border-right: 1px solid #ccc;
  864. width: 380px;
  865. min-width: 380px;
  866. margin-right: 40px;
  867. .chioseday {
  868. margin-top: 20px;
  869. .el-date-editor.el-input,
  870. .el-date-editor.el-input__inner {
  871. width: 100px;
  872. margin-left: 10px;
  873. }
  874. }
  875. .holidayWrap {
  876. margin-top: 34px;
  877. margin-bottom: 40px;
  878. display: flex;
  879. flex-direction: row;
  880. justify-content: space-between;
  881. align-items: center;
  882. .quickBtn {
  883. font-size: 16px;
  884. color: #f85043;
  885. text-decoration: underline;
  886. padding-right: 25px;
  887. cursor: pointer;
  888. }
  889. }
  890. .btnWrap {
  891. display: flex;
  892. flex-direction: row;
  893. justify-content: space-around;
  894. div {
  895. width: 120px;
  896. height: 40px;
  897. border-radius: 4px;
  898. text-align: center;
  899. line-height: 40px;
  900. cursor: pointer;
  901. color: #fff;
  902. }
  903. .closeBtn {
  904. background-color: #777;
  905. }
  906. }
  907. }
  908. .right {
  909. width: 1160px;
  910. .is-selected {
  911. color: #1989fa;
  912. }
  913. .btnWrap {
  914. display: flex;
  915. flex-direction: row;
  916. justify-content: flex-end;
  917. div {
  918. width: 120px;
  919. height: 40px;
  920. line-height: 40px;
  921. text-align: center;
  922. color: #fff;
  923. border-radius: 4px;
  924. margin-right: 20px;
  925. cursor: pointer;
  926. }
  927. .nextBtn {
  928. background-color: #444;
  929. }
  930. .okBtn {
  931. background-color: #f97215;
  932. }
  933. }
  934. }
  935. .resetWrap {
  936. display: flex;
  937. flex-direction: row;
  938. justify-content: space-around;
  939. .restBtn {
  940. width: 150px;
  941. height: 40px;
  942. background: rgba(255, 255, 255, 1);
  943. border-radius: 5px;
  944. border: 1px solid rgba(20, 146, 138, 1);
  945. text-align: center;
  946. cursor: pointer;
  947. line-height: 40px;
  948. color: #14928a;
  949. }
  950. .restBtn.active {
  951. background-color: #14928a;
  952. color: #fff;
  953. }
  954. }
  955. .okBtns {
  956. background-color: #f97215;
  957. width: 120px;
  958. height: 40px;
  959. line-height: 40px;
  960. text-align: center;
  961. color: #fff;
  962. border-radius: 4px;
  963. margin-right: 20px;
  964. cursor: pointer;
  965. margin: 0 auto;
  966. }
  967. }
  968. </style>