123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- <template>
- <div>
- <el-form
- :model="form"
- inline
- ref="form"
- label-suffix=": "
- label-width="130px"
- >
- <el-row v-if="classType == 5">
- <el-form-item
- label="班级名称"
- prop="className"
- label-width="88px"
- :rules="[{ required: true, message: '请填写班级名称' }]"
- >
- <el-input
- v-model.trim="form.className"
- placeholder="请输入班级名称"
- style="width: 180px"
- ></el-input>
- </el-form-item>
- </el-row>
- <el-form-item
- label="主教老师"
- prop="coreTeacher"
- label-width="88px"
- :rules="[{ required: true, message: '请选择主教老师' }]"
- >
- <el-select
- v-model.trim="form.coreTeacher"
- placeholder="请选择主教老师"
- clearable
- filterable
- @change="changecoreTeacher"
- >
- <el-option
- v-for="(item, index) in teacherList"
- :key="index"
- :label="item.realName"
- :value="String(item.id)"
- ></el-option>
- </el-select>
- <!-- <remote-search :commit="'setTeachers'" v-model="form.coreTeacher" /> -->
- </el-form-item>
- <el-form-item
- label="助教老师"
- prop="assistant"
- v-if="
- activeType != 'HIGH' &&
- activeType != 'HIGH_ONLINE' &&
- activeType != 'MUSIC_NETWORK'
- "
- >
- <!-- <remote-search :commit="'setTeachers'" v-model="form.assistant" :multiple='true'/> -->
- <el-select
- v-model.trim="form.assistant"
- placeholder="请选择助教老师"
- filterable
- clearable
- multiple
- >
- <el-option
- v-for="(item, index) in cooperationList"
- :key="index"
- :label="item.realName"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- v-if="!!Object.keys(allClasss).length"
- style="display: block"
- label="排课类型"
- label-width="88px"
- >
- <el-tag
- class="tag"
- :effect="form.classs[key] ? 'dark' : 'plain'"
- v-for="(item, key) in allClasss"
- :key="key"
- @click="changeTag(key)"
- >{{ courseTypeListByName[key] }}</el-tag
- >
- </el-form-item>
- <empty v-if="isEmpty" desc="暂无可排课时长" />
- <el-collapse v-model="collapses" @change="collapseChange">
- <el-collapse-item
- v-for="(item, key, index) in form.classs"
- :name="index"
- :key="key"
- >
- <template #title>
- <p class="title">
- {{ courseTypeListByName[key] }},
- <span>可排课时长:{{ musicCourseSettings[key] }}分钟</span>
- <span style="color: #333"
- >已排课时长:{{ musicSurplus[key] }}分钟</span
- >
- </p>
- </template>
- <courseItem
- :surplustime="surplustime[key]"
- @setUserTime="setUserTime"
- :type="key"
- :form="item"
- :prices="prices"
- :holidays="holidays"
- :selectPrice="selectPrices ? selectPrices[key] : ''"
- />
- </el-collapse-item>
- </el-collapse>
- </el-form>
- <div slot="footer" class="dialog-footer" v-if="classType != 5">
- <el-button @click="$listeners.close">取 消</el-button>
- <el-button type="primary" :disabled="isEmpty" @click="submit"
- >确 定</el-button
- >
- </div>
- <el-dialog
- title="班级预览"
- :visible.sync="previewVisible"
- append-to-body
- width="700px"
- >
- <classrome-preview
- :types="form.classs"
- :details="previewList"
- :courseTypeListByName="courseTypeListByName"
- :teacherList="teacherList"
- :cooperationList="cooperationList"
- :coreTeacher="form.coreTeacher"
- :assistant="form.assistant"
- />
- <div slot="footer" class="dialog-footer" v-if="classType != 5">
- <el-button @click="previewVisible = false">取 消</el-button>
- <el-button type="primary" @click="submit('confirmGenerate')"
- >确 定</el-button
- >
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- getMusicCourseSettingsWithStudents,
- classGroupUpdate,
- revisionClassGroup,
- revisionAddClassGroup,
- findClassCourseMinute,
- mergeClassSplitClassAffirm,
- } from "@/api/buildTeam";
- import courseItem from "./classroom-setting-item";
- import { classTimeList } from "@/utils/searchArray";
- import MusicStore from "@/views/resetTeaming/store";
- import { sysConfigList } from '@/api/generalSettings'
- import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
- import { isEmpty } from "lodash";
- import classromePreview from './classroom-preview'
- const classTimeListByType = {};
- for (const item of classTimeList) {
- classTimeListByType[item.value] = item.label;
- }
- 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;
- };
- const plusNum = (items = [], key) => {
- let money = 0;
- for (const item of items) {
- money += parseFloat(parseFloat(item[key] || 0).toFixed(2) || 0);
- }
- return money;
- };
- export default {
- props: [
- "activeType",
- "courseTypeList",
- "musicGroupId",
- "detail",
- "studentSubmitedData",
- "classType",
- "musicGroupPaymentCalenderDtos",
- "classIdList",
- "classGroupStudents",
- "selectPrices",
- "classCouresTimeList",
- "teacherList",
- "cooperationList",
- ],
- components: {
- courseItem,
- 'classrome-preview': classromePreview
- },
- data() {
- return {
- form: {
- coreTeacher: "",
- assistant: "",
- classs: {},
- },
- allClasss: {},
- prices: {},
- collapses: [0],
- courseTimes: {},
- courseTypeListByName: {},
- classTimeListByType,
- musicCourseSettings: {},
- musicSurplus: {},
- previewVisible: false,
- previewList: [],
- holidays: [],
- };
- },
- watch: {
- courseTypeList() {
- this.setCourseTypeListByName();
- },
- studentSubmitedData() {
- this.formatClasss();
- },
- detail() {
- this.formatClasss();
- },
- },
- computed: {
- surplustime() {
- const _ = {};
- for (const key in this.form.classs) {
- if (this.form.classs.hasOwnProperty(key)) {
- const item = this.form.classs[key];
- // - plusNum(item.cycle, "time");
- _[key] = item.courseTotalMinuties;
- }
- }
- return _;
- },
- isEmpty() {
- return isEmpty(this.form.classs);
- },
- musicGroup() {
- return MusicStore.state.musicGroup;
- },
- },
- async mounted() {
- try {
- await MusicStore.dispatch("getBaseInfo", {
- data: { musicGroupId: this.musicGroupId },
- });
- const res = await queryByOrganIdAndCourseType({
- organId: this.musicGroup.organId,
- });
- this.prices = res.data;
- } catch (error) {}
- this.setCourseTypeListByName();
- this.formatClasss();
- this.FetchHoliday()
- },
- methods: {
- async FetchHoliday() {
- try {
- const res = await sysConfigList({
- group: 'holiday'
- })
- this.holidays = JSON.parse(res.data[0].paranValue)
- } catch (error) {}
- },
- setCourseTypeListByName() {
- const courseTypeListByName = {};
- for (const item of this.courseTypeList) {
- courseTypeListByName[item.value] = item.label;
- }
- this.courseTypeListByName = courseTypeListByName;
- },
- async formatClasss() {
- if (this.detail) {
- let coreid = "";
- const assistant = [];
- const { classGroupTeacherMapperList } = this.detail;
- for (const item of classGroupTeacherMapperList || []) {
- if (item.teacherRole === "BISHOP") {
- coreid = String(item.userId);
- }
- if (item.teacherRole === "TEACHING") {
- assistant.push(item.userId);
- }
- }
- this.$set(this.form, "coreTeacher", String(coreid));
- this.$set(this.form, "assistant", assistant);
- }
- const studentIds = this.detail
- ? undefined
- : this.studentSubmitedData?.seleched.join(",");
- const classGroupId = this.detail?.id;
- if (!studentIds && !classGroupId) {
- return;
- }
- let res = {};
- if (this.classType == 5) {
- // res = await findClassCourseMinute(this.classIdList);
- res.data = this.classCouresTimeList;
- } else {
- try {
- res = await getMusicCourseSettingsWithStudents({
- musicGroupId: this.musicGroupId,
- studentIds,
- classGroupId,
- });
- } catch (error) {
- console.log(error);
- }
- }
- // console.log(res);
- if (Object.keys(res).length <= 0) return;
- this.musicCourseSettings = res.data;
- for (let key in this.musicCourseSettings) {
- this.musicSurplus[key] = 0;
- }
- const classs = {};
- for (const item of this.courseTypeList) {
- const key = item.value;
- if (res.data[key]) {
- classs[key] = {
- courseTotalMinuties: res.data[key],
- cycle: [
- {
- time: this.selectPrices ? this.selectPrices[key] : undefined,
- },
- ],
- };
- }
- }
- this.allClasss = { ...classs };
- this.$set(this.form, "classs", classs);
- // this.courseTimes = courseTimes
- },
- changeTag(key) {
- const clas = { ...this.form.classs };
- if (clas[key]) {
- delete clas[key];
- } else {
- clas[key] = this.allClasss[key];
- }
- this.$set(this.form, "classs", clas);
- },
- submit(type) {
- for (const key in this.musicCourseSettings) {
- if (Object.hasOwnProperty.call(this.musicCourseSettings, key)) {
- const allTime = this.musicCourseSettings[key];
- const useTime = this.musicSurplus[key]
- if (useTime > allTime) {
- this.$message.error(this.courseTypeListByName[key] + ' 课程时长不足')
- return
- }
- }
- }
- this.$refs.form.validate(async (valid) => {
- if (valid) {
- const list = [];
- for (const key in this.form.classs) {
- if (this.form.classs.hasOwnProperty(key)) {
- const item = this.form.classs[key];
- const data = {
- type: this.detail ? undefined : this.activeType,
- courseType: key,
- classGroupName:
- this.studentSubmitedData?.name ||
- this.detail?.name ||
- this.form.className,
- classGroupId: this.detail?.id,
- musicGroupId: this.musicGroupId,
- startDate: item.courseTime,
- classGroupTeacherMapperList: formatClassGroupTeacherMapperList(
- this.form.coreTeacher,
- this.form.assistant
- ),
- holiday: item.holiday,
- students: this.studentSubmitedData?.seleched,
- courseTimes: item.cycle.length,
- courseTimeDtoList: item.cycle.map((_) => ({
- courseType: key,
- dayOfWeek: _.dayOfWeek,
- endClassTime: _.endClassTime,
- startClassTime: _.startClassTime,
- startDate:_.startDate,
- endDate:_.endDate,
- holiday: _.holiday,
- expectCourseNum:_.expectCourseNum
- })),
- }
- if (type && typeof type === 'string') {
- data[type] = true
- }
- list.push(data);
- }
- }
- try {
- if (this.detail) {
- let result = await classGroupUpdate(list);
- this.previewVisible = false
- if (result.code == 207) {
- await this.$confirm((result.msg || `当前课程课酬预计为0,是否继续`), "提示", {
- type: "warning",
- })
- // obj.allowZeroSalary = true;
- list.forEach((item) => {
- item.allowZeroSalary = true;
- });
- await classGroupUpdate(list);
- this.$listeners.submited();
- this.$listeners.close();
- return;
- }
- if (result.code == 206) {
- this.previewVisible = true
- this.previewList = result.data
- return;
- }
- this.$message.success("排课修改成功");
- } else {
- if (this.classType == 1) {
- // 0新建班级 2 3 4新增班级修改
- await revisionClassGroup(list);
- this.$message.success("排课成功");
- } else if (
- this.classType == 2 ||
- this.classType == 3 ||
- this.classType == 4
- ) {
- await revisionAddClassGroup(list);
- this.$message.success("排课成功");
- } else if (this.classType == 5) {
- // 这里是合班拆班
- let obj = {};
- obj.musicGroupPaymentCalenderDtos = this.musicGroupPaymentCalenderDtos;
- obj.classGroup4MixDtos = list;
- obj.classGroupIds = this.classIdList;
- obj.studentIds = this.studentSubmitedData.seleched;
- obj.classGroupStudents = this.classGroupStudents;
- obj.classCourseMinuteMap = this.selectPrices;
- await mergeClassSplitClassAffirm(obj);
- let grend = this.$parent.$parent.$parent.$parent.$parent.$parent
- .$parent;
- grend.closeStudentReset();
- grend.getList();
- return;
- }
- }
- this.$listeners.submited();
- this.$listeners.close();
- } catch (error) {
- console.log(error);
- }
- } else {
- this.$message.error("请先填写所有表单");
- }
- });
- },
- collapseChange(val) {
- this.collapses = val;
- },
- changecoreTeacher(val) {},
- updateMusicSurplus() {
- },
- setUserTime(time, type) {
- // console.log(time, type)
- this.$set(this.musicSurplus, type, (time || 0))
- // console.log(this.musicSurplus)
- this.$forceUpdate()
- // this.$nextTick(res=>{
- // this.musicSurplus[type] = time;
- // console.log(this.musicSurplus[type])
- // })
- },
- },
- // watch:{
- // musicSurplus(){
- // deep
- // }
- // }
- };
- </script>
- <style lang="less" scoped>
- .dialog-footer {
- margin-top: 20px;
- display: block;
- text-align: right;
- }
- .title {
- font-size: 16px;
- padding: 10px;
- font-weight: normal;
- > span {
- color: tomato;
- font-size: 14px;
- }
- }
- .tag {
- margin-right: 5px;
- cursor: pointer;
- }
- </style>
|