member-class-setting.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div>
  3. <el-form
  4. :model="form"
  5. inline
  6. ref="form"
  7. label-suffix=": "
  8. label-width="130px"
  9. >
  10. <el-form-item
  11. v-if="!!Object.keys(allClasss).length"
  12. style="display: block"
  13. label="排课类型"
  14. label-width="88px"
  15. >
  16. <el-tag
  17. class="tag"
  18. :effect="form.classs[key] ? 'dark' : 'plain'"
  19. v-for="(item, key) in allClasss"
  20. :key="key"
  21. @click="changeTag(key)"
  22. >{{ courseTypeListByName[key] }}</el-tag
  23. >
  24. <el-button
  25. type="text"
  26. @click="studentListModalVisible = true"
  27. :disabled="detail.id ? false : true"
  28. class="studentTitle"
  29. >学员列表>></el-button
  30. >
  31. </el-form-item>
  32. <empty v-if="isEmpty" desc="暂无可排课时长" />
  33. <p class="title">
  34. <span
  35. >该班级截止到{{ endSchoolTerm }}可预排课时长:{{
  36. activeCourseTime
  37. }}分钟</span
  38. >
  39. <span
  40. >已排课时长:{{
  41. musicSurplus
  42. }}分钟,请根据教学规划安排各类型课程的课时数
  43. <el-tooltip placement="top" popper-class="mTooltip">
  44. <div slot="content">开课日期至本学期截止日期周次*4*45</div>
  45. <i
  46. class="el-icon-question micon el-tooltip"
  47. style="font-size: 18px; color: #f56c6c"
  48. v-permission="'export/teacherSalary'"
  49. ></i> </el-tooltip
  50. ></span>
  51. </p>
  52. <el-collapse v-model="collapses" @change="collapseChange">
  53. <el-collapse-item
  54. v-for="(item, key, index) in form.classs"
  55. :name="index"
  56. :key="key"
  57. >
  58. <template #title>
  59. <p class="coursetitle">
  60. {{ courseTypeListByName[key] }}
  61. <span>已排课时长:{{ courseTimeList[key] }}分钟</span>
  62. </p>
  63. </template>
  64. <courseItem
  65. :endSchoolTerm="endSchoolTerm"
  66. :startCourseDate="startCourseDate"
  67. :surplustime="activeCourseTime"
  68. @setUserTime="setUserTime"
  69. :teacherList="teacherList"
  70. :activeType="activeType"
  71. :cooperationList="cooperationList"
  72. :coreid="coreid"
  73. :assistant="assistant"
  74. :type="key"
  75. :form="item"
  76. :prices="prices"
  77. :holidays="holidays"
  78. :selectPrice="selectPrices ? selectPrices[key] : ''"
  79. />
  80. </el-collapse-item>
  81. </el-collapse>
  82. </el-form>
  83. <div slot="footer" class="dialog-footer" v-if="classType != 5">
  84. <el-button @click="$listeners.close">取 消</el-button>
  85. <el-button type="primary" :disabled="isEmpty" @click="submit"
  86. >确定</el-button
  87. >
  88. </div>
  89. <el-dialog
  90. title="学员列表"
  91. width="700px"
  92. :visible.sync="studentListModalVisible"
  93. append-to-body
  94. destroy-on-close
  95. >
  96. <viewStudentList
  97. :list="studentList"
  98. v-if="studentListModalVisible"
  99. :showOk="true"
  100. :isChiose="false"
  101. @close="studentListModalVisible = false"
  102. />
  103. </el-dialog>
  104. </div>
  105. </template>
  106. <script>
  107. import courseItem from "./classroom-setting-item";
  108. import MusicStore from "@/views/resetTeaming/store"; // 乐团的基本信息
  109. import { isEmpty } from "lodash";
  110. import { preCourseSchedule } from "@/api/buildTeam";
  111. import { getClassAllStudent } from "@/api/studentManager";
  112. import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
  113. import viewStudentList from "@/views/teamDetail/componentClass/student-list";
  114. const formatClassGroupTeacherMapperList = (core, ass) => {
  115. const list = [];
  116. if (core) {
  117. list.push({ userId: core, teacherRole: "BISHOP" });
  118. }
  119. if (ass) {
  120. for (const item of ass) {
  121. list.push({ userId: item, teacherRole: "TEACHING" });
  122. }
  123. }
  124. return list;
  125. };
  126. export default {
  127. components: { courseItem, viewStudentList },
  128. props: [
  129. "activeType",
  130. "courseTypeList",
  131. "musicGroupId",
  132. "detail",
  133. "studentSubmitedData",
  134. "classType",
  135. "musicGroupPaymentCalenderDtos",
  136. "classIdList",
  137. "classGroupStudents",
  138. "selectPrices",
  139. "classCouresTimeList",
  140. "teacherList",
  141. "cooperationList",
  142. "endSchoolTerm",
  143. "startCourseDate",
  144. "musicGroupSchoolTermCourseDetailId",
  145. ],
  146. data() {
  147. return {
  148. form: { coreTeacher: "", assistant: "", classs: {} },
  149. allClasss: {},
  150. prices: {},
  151. collapses: [0],
  152. courseTimes: {},
  153. courseTypeListByName: {},
  154. musicCourseSettings: 0, // 可排课时长
  155. musicSurplus: 0, //已排课时长
  156. courseTimeList: {}, // 每种课程类型已排课
  157. previewVisible: false,
  158. previewList: [],
  159. holidays: [],
  160. studentListModalVisible: false,
  161. studentList: [],
  162. };
  163. },
  164. async mounted() {
  165. try {
  166. await MusicStore.dispatch("getBaseInfo", {
  167. data: { musicGroupId: this.musicGroupId },
  168. });
  169. const res = await queryByOrganIdAndCourseType({
  170. organId: this.musicGroup.organId,
  171. });
  172. this.prices = res.data;
  173. } catch (error) {}
  174. // console.log('courseTypeList',this.courseTypeList)
  175. // 获取班级的学生列表
  176. getClassAllStudent({ classGroupId: this.detail.id }).then((res) => {
  177. if (res.code == 200) {
  178. this.studentList = res.data.map((item) => {
  179. return {
  180. userId: item.userId,
  181. nickName: item.name,
  182. gender: item.gender,
  183. phone: item.parentsPhone,
  184. subjectNames: item.subjectName,
  185. };
  186. });
  187. }
  188. });
  189. this.setCourseTypeListByName(); // 获取课程名称和枚举的键值对
  190. this.formatClasss(); // 初始化班级
  191. this.FetchHoliday(); // 设置节假日
  192. },
  193. methods: {
  194. async FetchHoliday() {
  195. try {
  196. const res = await sysConfigList({
  197. group: "holiday",
  198. });
  199. this.holidays = JSON.parse(res.data[0].paranValue);
  200. } catch (error) {}
  201. },
  202. setCourseTypeListByName() {
  203. const courseTypeListByName = {};
  204. for (const item of this.courseTypeList) {
  205. if (item.value == "HIGH" || item.value == "HIGH_ONLINE") {
  206. } else {
  207. courseTypeListByName[item.value] = item.label;
  208. }
  209. }
  210. this.courseTypeListByName = courseTypeListByName;
  211. console.log(this.courseTypeListByName);
  212. },
  213. async formatClasss() {
  214. this.coreid = "";
  215. this.assistant = [];
  216. if (this.detail) {
  217. const { classGroupTeacherMapperList } = this.detail;
  218. for (const item of classGroupTeacherMapperList || []) {
  219. if (item.teacherRole === "BISHOP") {
  220. this.coreid = String(item.userId);
  221. }
  222. if (item.teacherRole === "TEACHING") {
  223. this.assistant.push(item.userId);
  224. }
  225. }
  226. this.$set(this.form, "coreTeacher", String(this.coreid));
  227. this.$set(this.form, "assistant", this.assistant);
  228. }
  229. const classGroupId = this.detail?.id;
  230. if (!classGroupId) {
  231. this.$message.error("班级信息错误");
  232. return;
  233. }
  234. this.musicCourseSettings = this.detail.preSubMinutes;
  235. const classs = {};
  236. for (const item of this.courseTypeList) {
  237. const key = item.value;
  238. if (item.value == "HIGH" || item.value == "HIGH_ONLINE") {
  239. } else {
  240. this.courseTimeList[key] = 0;
  241. classs[key] = {
  242. courseTotalMinuties: this.musicCourseSettings,
  243. cycle: [
  244. {
  245. time: this.selectPrices ? this.selectPrices[key] : undefined,
  246. coreTeacher: this.coreid,
  247. assistant: this.assistant,
  248. },
  249. ],
  250. };
  251. }
  252. }
  253. // console.log(classs,this.courseTypeList[0].value)
  254. let key = this.courseTypeList[0].value;
  255. this.allClasss = { ...classs };
  256. console.log("allClasss", this.allClasss);
  257. let onlyClass = { [key]: classs[this.courseTypeList[0].value] };
  258. this.$set(this.form, "classs", onlyClass);
  259. },
  260. collapseChange(val) {
  261. this.collapses = val;
  262. },
  263. async submit() {
  264. if (this.activeCourseTime < 0) {
  265. this.$message.error("课程使用时长超过最大预排课数");
  266. return;
  267. }
  268. this.$refs.form.validate(async (valid) => {
  269. if (valid) {
  270. const list = [];
  271. for (const key in this.form.classs) {
  272. if (this.form.classs.hasOwnProperty(key)) {
  273. const item = this.form.classs[key];
  274. const data = {
  275. confirmGenerate: true,
  276. type: this.detail ? undefined : this.activeType,
  277. courseType: key,
  278. classGroupName:
  279. this.studentSubmitedData?.name ||
  280. this.detail?.name ||
  281. this.form.className,
  282. classGroupId: this.detail?.id,
  283. musicGroupId: this.musicGroupId,
  284. startDate: item.courseTime,
  285. classGroupTeacherMapperList: formatClassGroupTeacherMapperList(
  286. this.form.coreTeacher,
  287. this.form.assistant
  288. ),
  289. holiday: item.holiday,
  290. students: this.studentSubmitedData?.seleched,
  291. courseTimes: item.cycle.length,
  292. courseTimeDtoList: item.cycle.map((_) => ({
  293. classGroupTeacherMapperList: this.formatTeacher(_),
  294. courseType: key,
  295. dayOfWeek: _.dayOfWeek,
  296. endClassTime: _.endClassTime,
  297. startClassTime: _.startClassTime,
  298. startDate: _.startDate,
  299. endDate: _.endDate,
  300. holiday: _.holiday,
  301. expectCourseNum: _.expectCourseNum,
  302. expectCourseMinutes: _.time,
  303. })),
  304. musicGroupSchoolTermCourseDetailId:
  305. this.musicGroupSchoolTermCourseDetailId,
  306. };
  307. list.push(data);
  308. }
  309. }
  310. try {
  311. const res = await preCourseSchedule(list);
  312. if (res.code == 207) {
  313. await this.$confirm(
  314. res.msg || `当前课程课酬预计为0,是否继续`,
  315. "提示",
  316. {
  317. type: "warning",
  318. }
  319. );
  320. // obj.allowZeroSalary = true;
  321. list.forEach((item) => {
  322. item.allowZeroSalary = true;
  323. });
  324. await preCourseSchedule(list);
  325. this.$listeners.submited();
  326. this.$listeners.close();
  327. return;
  328. }
  329. this.$message.success("排课成功");
  330. this.$listeners.submited();
  331. this.$listeners.close();
  332. } catch (e) {
  333. console.log(e);
  334. }
  335. }
  336. });
  337. },
  338. setUserTime(time, type) {
  339. this.$set(this.courseTimeList, type, time || 0);
  340. this.musicSurplus = 0;
  341. for (let key in this.courseTimeList) {
  342. this.musicSurplus += this.courseTimeList[key];
  343. }
  344. this.$forceUpdate();
  345. },
  346. changeTag(key) {
  347. const clas = { ...this.form.classs };
  348. if (clas[key]) {
  349. delete clas[key];
  350. } else {
  351. clas[key] = this.allClasss[key];
  352. }
  353. this.$set(this.form, "classs", clas);
  354. },
  355. formatTeacher(row) {
  356. let arr = [];
  357. if (row.coreTeacher) {
  358. let obj = {};
  359. obj.teacherRole = "BISHOP";
  360. obj.userId = row.coreTeacher;
  361. arr.push(obj);
  362. }
  363. if (row.assistant?.length > 0) {
  364. row.assistant.forEach((ass) => {
  365. arr.push({ teacherRole: "TEACHING", userId: ass });
  366. });
  367. }
  368. return arr;
  369. },
  370. },
  371. watch: {
  372. watch: {
  373. courseTypeList() {
  374. this.setCourseTypeListByName();
  375. },
  376. detail() {
  377. this.formatClasss();
  378. },
  379. },
  380. },
  381. computed: {
  382. musicGroup() {
  383. return MusicStore.state.musicGroup;
  384. },
  385. isEmpty() {
  386. return isEmpty(this.form.classs);
  387. },
  388. surplustime() {
  389. return this.detail.preSubMinutes;
  390. },
  391. activeCourseTime() {
  392. let time = this.detail.preSubMinutes - this.musicSurplus;
  393. return time;
  394. },
  395. },
  396. };
  397. </script>
  398. <style lang="scss" scoped>
  399. .coursetitle {
  400. padding: 0 20px;
  401. font-size: 14px;
  402. color: #606266;
  403. line-height: 40px;
  404. }
  405. .title {
  406. color: red;
  407. margin-bottom: 30px;
  408. font-size: 16px;
  409. font-weight: bold;
  410. }
  411. .tag {
  412. margin-right: 5px;
  413. cursor: pointer;
  414. }
  415. .dialog-footer {
  416. margin-top: 20px;
  417. display: block;
  418. text-align: right;
  419. }
  420. </style>