123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <template>
- <div>
- <el-dialog
- title="排课"
- append-to-body
- width="1050px"
- :visible.sync="transPlanVisible"
- >
- <el-form :model="activeRow" :inline="true" ref="form" label-suffix=": ">
- <div v-if="activeRow.classs['HIGH_ONLINE']">
- <p class="title">
- <span style="font-weight: 600">线上基础技能课</span>
- 可排课时长:<span style="color: red">{{
- form.courseConvertSum.courseMinute
- }}</span
- >分钟
- <span style="color: #333"
- >已排课时长:
- <span style="color: red"> {{ this.alltime }}分钟</span></span
- >
- </p>
- <courseItem
- :form="activeRow.classs['HIGH_ONLINE']"
- :teacherList="teacherList"
- :surplustime="form.courseConvertSum.courseMinute"
- :activeType="'HIGH_ONLINE'"
- :coreid="activeRow.coreTeacher"
- :type="'HIGH_ONLINE'"
- :prices="prices"
- :holidays="holidays"
- @setUserTime="setUserTime"
- />
- <!--
- :cooperationList="teacherList" -->
- </div>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="transClassVisible = false">取 消</el-button>
- <el-button type="primary" @click="submit">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getSysTenantConfig } from "@/views/courseRulersManager/api";
- import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
- import courseItem from "../modals/classroom-setting-item.vue";
- import { isEmpty } from "lodash";
- const formatClassGroupTeacherMapperList = (core, ass) => {
- const list = [];
- if (core) {
- list.push({ userId: core, teacherRole: "BISHOP" });
- }
- if (ass) {
- for (const item of ass) {
- list.push({ userId: item, teacherRole: "TEACHING" });
- }
- }
- return list;
- };
- export default {
- props: ["form", "teacherList", "activeRow"],
- data() {
- return {
- prices: [],
- holidays: [],
- transPlanVisible: false,
- allClasss: {},
- courseTypeListByName: {},
- courseTypeList: [{ value: "HIGH_ONLINE", label: "线上基础技能课" }],
- alltime: 0,
- };
- },
- components: {
- courseItem,
- },
- methods: {
- async init() {
- try {
- const res = await queryByOrganIdAndCourseType({
- organId: this.$route.query.organId,
- });
- const res1 = await getSysTenantConfig({
- group: "holiday",
- });
- this.holidays = JSON.parse(
- res1.data[0].paranValue ? res1.data[0].paranValue : "[]"
- );
- this.prices = res.data;
- let arr = [];
- if (JSON.stringify(this.prices) == "{}") {
- // 课程时长
- arr.push("teamCourseTimer");
- }
- if (this.holidays.length <= 0) {
- arr.push("holiday");
- }
- //
- if (arr.length > 0) {
- this.$bus.$emit("showguide", arr);
- return;
- }
- } catch (error) {
- console.log(error);
- }
- },
- async openDialog() {
- // 获取列表
- this.init();
- console.log(
- this.activeRow,
- this.form,
- "初始化",
- this.activeRow.classs["HIGH_ONLINE"]
- );
- this.transPlanVisible = true;
- },
- setCourseTypeListByName() {
- const courseTypeListByName = {};
- for (const item of this.courseTypeList) {
- courseTypeListByName[item.value] = item.label;
- }
- this.courseTypeListByName = courseTypeListByName;
- },
- setUserTime(time, type) {
- this.alltime = time;
- },
- formatTeacher(row) {
- let arr = [];
- if (row.coreTeacher) {
- let obj = {};
- obj.teacherRole = "BISHOP";
- obj.userId = row.coreTeacher;
- arr.push(obj);
- }
- if (row.assistant?.length > 0) {
- row.assistant.forEach((ass) => {
- arr.push({ teacherRole: "TEACHING", userId: ass });
- });
- }
- return arr;
- },
- submit() {
- if (this.alltime > this.form.courseConvertSum.courseMinute) {
- this.$message.error("课程时长不足");
- return;
- }
- console.log(this.form)
- this.$refs.form.validate(async (valid) => {
- let key = 'HIGH_ONLINE'
- if (valid) {
- const item = this.activeRow.classs[key];
- const data = {
- courseTimeDtoList: item.cycle.map((_) => ({
- classGroupTeacherMapperList: this.formatTeacher(_),
- courseType: key,
- dayOfWeek: _.dayOfWeek,
- endClassTime: _.endClassTime,
- startClassTime: _.startClassTime,
- startDate: _.startDate,
- endDate: _.endDate,
- holiday: _.holiday,
- expectCourseNum: _.expectCourseNum,
- })),
- };
- console.log(data)
- } else {
- this.$message.error("请先填写所有表单");
- }
- });
- },
- workOut (date, classCount, weekArr, id, startTime = '', endTime = '') {
- // 这里是一天排一节课 现在要改成一天排多节
- while (classCount && classCount > 0) {
- for (let i in weekArr) {
- let date1 = new Date(date.getTime());
- let num; // 下次上课上几天后
- // 星期4 - 当前是星期几 =>
- weekArr[i].weekNum - date.getDay() >= 0 ? num = weekArr[i].weekNum - date.getDay() : num = weekArr[i].weekNum - date.getDay() + 7
- let dataStr = this.getThinkDate(date, num);
- let monthDay = this.getThinkDate(date1, num, 2)
- if (this.isholiday) {
- if (this.holidayList.indexOf(monthDay) != -1) {
- // 这里说明有节假日
- continue
- }
- }
- // 排的是合奏班
- let nowStartTime = this.week[i].startTime || startTime;
- let nowEndTime = this.week[i].endTime || endTime;
- // date: this.getNowFormatDate(date),
- this.tableList.push({
- 'classDate': dataStr,
- 'week': this.weekDay[weekArr[i].weekNum],
- 'type': courseType,
- 'id': id,
- 'name': className,
- 'classTime': nowStartTime + '-' + nowEndTime,
- 'startClassTimeStr': nowStartTime,
- 'endClassTimeStr': nowEndTime,
- 'weekNum': weekArr[i].weekNum,
- })
- // 这里我排声部课
- // date: this.getNowFormatDate(date),
- for (let j in this.activeSingleList) {
- this.classCardList.push({
- 'classDate': dataStr,
- 'classGroupId': this.activeSingleList[j].id,
- 'startClassTimeStr': nowStartTime,
- 'endClassTimeStr': nowEndTime,
- 'type': courseType,
- 'mixid': this.activeSingleList[j].mixid,
- 'weekNum': weekArr[i].weekNum,
- 'name': this.activeSingleList[j].name,
- 'option': 1
- })
- }
- classCount--
- if (classCount == 0) break
- }
- date.setDate(date.getDate() + 7);
- }
- // 请求排课
- },
- },
- watch: {
- courseTypeList() {
- this.setCourseTypeListByName();
- },
- },
- computed: {
- isEmpty() {
- return isEmpty(this.form.classs);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- </style>
|