startPlanCourse.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="排课"
  5. append-to-body
  6. width="1050px"
  7. :visible.sync="transPlanVisible"
  8. >
  9. <el-form :model="activeRow" :inline="true" ref="form" label-suffix=": ">
  10. <div v-if="activeRow.classs['HIGH_ONLINE']">
  11. <p class="title">
  12. <span style="font-weight: 600">线上基础技能课</span>
  13. 可排课时长:<span style="color: red">{{
  14. form.courseConvertSum.courseMinute
  15. }}</span
  16. >分钟
  17. <span style="color: #333"
  18. >已排课时长:
  19. <span style="color: red"> {{ this.alltime }}分钟</span></span
  20. >
  21. </p>
  22. <courseItem
  23. :form="activeRow.classs['HIGH_ONLINE']"
  24. :teacherList="teacherList"
  25. :surplustime="form.courseConvertSum.courseMinute"
  26. :activeType="'HIGH_ONLINE'"
  27. :coreid="activeRow.coreTeacher"
  28. :type="'HIGH_ONLINE'"
  29. :prices="prices"
  30. :holidays="holidays"
  31. @setUserTime="setUserTime"
  32. />
  33. <!--
  34. :cooperationList="teacherList" -->
  35. </div>
  36. </el-form>
  37. <div slot="footer" class="dialog-footer">
  38. <el-button @click="transClassVisible = false">取 消</el-button>
  39. <el-button type="primary" @click="submit">确 定</el-button>
  40. </div>
  41. </el-dialog>
  42. </div>
  43. </template>
  44. <script>
  45. import { getSysTenantConfig } from "@/views/courseRulersManager/api";
  46. import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
  47. import courseItem from "../modals/classroom-setting-item.vue";
  48. import { isEmpty } from "lodash";
  49. const formatClassGroupTeacherMapperList = (core, ass) => {
  50. const list = [];
  51. if (core) {
  52. list.push({ userId: core, teacherRole: "BISHOP" });
  53. }
  54. if (ass) {
  55. for (const item of ass) {
  56. list.push({ userId: item, teacherRole: "TEACHING" });
  57. }
  58. }
  59. return list;
  60. };
  61. export default {
  62. props: ["form", "teacherList", "activeRow"],
  63. data() {
  64. return {
  65. prices: [],
  66. holidays: [],
  67. transPlanVisible: false,
  68. allClasss: {},
  69. courseTypeListByName: {},
  70. courseTypeList: [{ value: "HIGH_ONLINE", label: "线上基础技能课" }],
  71. alltime: 0,
  72. };
  73. },
  74. components: {
  75. courseItem,
  76. },
  77. methods: {
  78. async init() {
  79. try {
  80. const res = await queryByOrganIdAndCourseType({
  81. organId: this.$route.query.organId,
  82. });
  83. const res1 = await getSysTenantConfig({
  84. group: "holiday",
  85. });
  86. this.holidays = JSON.parse(
  87. res1.data[0].paranValue ? res1.data[0].paranValue : "[]"
  88. );
  89. this.prices = res.data;
  90. let arr = [];
  91. if (JSON.stringify(this.prices) == "{}") {
  92. // 课程时长
  93. arr.push("teamCourseTimer");
  94. }
  95. if (this.holidays.length <= 0) {
  96. arr.push("holiday");
  97. }
  98. //
  99. if (arr.length > 0) {
  100. this.$bus.$emit("showguide", arr);
  101. return;
  102. }
  103. } catch (error) {
  104. console.log(error);
  105. }
  106. },
  107. async openDialog() {
  108. // 获取列表
  109. this.init();
  110. console.log(
  111. this.activeRow,
  112. this.form,
  113. "初始化",
  114. this.activeRow.classs["HIGH_ONLINE"]
  115. );
  116. this.transPlanVisible = true;
  117. },
  118. setCourseTypeListByName() {
  119. const courseTypeListByName = {};
  120. for (const item of this.courseTypeList) {
  121. courseTypeListByName[item.value] = item.label;
  122. }
  123. this.courseTypeListByName = courseTypeListByName;
  124. },
  125. setUserTime(time, type) {
  126. this.alltime = time;
  127. },
  128. formatTeacher(row) {
  129. let arr = [];
  130. if (row.coreTeacher) {
  131. let obj = {};
  132. obj.teacherRole = "BISHOP";
  133. obj.userId = row.coreTeacher;
  134. arr.push(obj);
  135. }
  136. if (row.assistant?.length > 0) {
  137. row.assistant.forEach((ass) => {
  138. arr.push({ teacherRole: "TEACHING", userId: ass });
  139. });
  140. }
  141. return arr;
  142. },
  143. submit() {
  144. if (this.alltime > this.form.courseConvertSum.courseMinute) {
  145. this.$message.error("课程时长不足");
  146. return;
  147. }
  148. console.log(this.form)
  149. this.$refs.form.validate(async (valid) => {
  150. let key = 'HIGH_ONLINE'
  151. if (valid) {
  152. const item = this.activeRow.classs[key];
  153. const data = {
  154. courseTimeDtoList: item.cycle.map((_) => ({
  155. classGroupTeacherMapperList: this.formatTeacher(_),
  156. courseType: key,
  157. dayOfWeek: _.dayOfWeek,
  158. endClassTime: _.endClassTime,
  159. startClassTime: _.startClassTime,
  160. startDate: _.startDate,
  161. endDate: _.endDate,
  162. holiday: _.holiday,
  163. expectCourseNum: _.expectCourseNum,
  164. })),
  165. };
  166. console.log(data)
  167. } else {
  168. this.$message.error("请先填写所有表单");
  169. }
  170. });
  171. },
  172. workOut (date, classCount, weekArr, id, startTime = '', endTime = '') {
  173. // 这里是一天排一节课 现在要改成一天排多节
  174. while (classCount && classCount > 0) {
  175. for (let i in weekArr) {
  176. let date1 = new Date(date.getTime());
  177. let num; // 下次上课上几天后
  178. // 星期4 - 当前是星期几 =>
  179. weekArr[i].weekNum - date.getDay() >= 0 ? num = weekArr[i].weekNum - date.getDay() : num = weekArr[i].weekNum - date.getDay() + 7
  180. let dataStr = this.getThinkDate(date, num);
  181. let monthDay = this.getThinkDate(date1, num, 2)
  182. if (this.isholiday) {
  183. if (this.holidayList.indexOf(monthDay) != -1) {
  184. // 这里说明有节假日
  185. continue
  186. }
  187. }
  188. // 排的是合奏班
  189. let nowStartTime = this.week[i].startTime || startTime;
  190. let nowEndTime = this.week[i].endTime || endTime;
  191. // date: this.getNowFormatDate(date),
  192. this.tableList.push({
  193. 'classDate': dataStr,
  194. 'week': this.weekDay[weekArr[i].weekNum],
  195. 'type': courseType,
  196. 'id': id,
  197. 'name': className,
  198. 'classTime': nowStartTime + '-' + nowEndTime,
  199. 'startClassTimeStr': nowStartTime,
  200. 'endClassTimeStr': nowEndTime,
  201. 'weekNum': weekArr[i].weekNum,
  202. })
  203. // 这里我排声部课
  204. // date: this.getNowFormatDate(date),
  205. for (let j in this.activeSingleList) {
  206. this.classCardList.push({
  207. 'classDate': dataStr,
  208. 'classGroupId': this.activeSingleList[j].id,
  209. 'startClassTimeStr': nowStartTime,
  210. 'endClassTimeStr': nowEndTime,
  211. 'type': courseType,
  212. 'mixid': this.activeSingleList[j].mixid,
  213. 'weekNum': weekArr[i].weekNum,
  214. 'name': this.activeSingleList[j].name,
  215. 'option': 1
  216. })
  217. }
  218. classCount--
  219. if (classCount == 0) break
  220. }
  221. date.setDate(date.getDate() + 7);
  222. }
  223. // 请求排课
  224. },
  225. },
  226. watch: {
  227. courseTypeList() {
  228. this.setCourseTypeListByName();
  229. },
  230. },
  231. computed: {
  232. isEmpty() {
  233. return isEmpty(this.form.classs);
  234. },
  235. },
  236. };
  237. </script>
  238. <style lang="scss" scoped>
  239. </style>