member-class-setting.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. v-if="studentListModalVisible"
  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 { getSysTenantConfig } from "@/views/courseRulersManager/api";
  114. import viewStudentList from "@/views/teamDetail/componentClass/student-list";
  115. const formatClassGroupTeacherMapperList = (core, ass) => {
  116. const list = [];
  117. if (core) {
  118. list.push({ userId: core, teacherRole: "BISHOP" });
  119. }
  120. if (ass) {
  121. for (const item of ass) {
  122. list.push({ userId: item, teacherRole: "TEACHING" });
  123. }
  124. }
  125. return list;
  126. };
  127. export default {
  128. components: { courseItem, viewStudentList },
  129. props: [
  130. "activeType",
  131. "courseTypeList",
  132. "musicGroupId",
  133. "detail",
  134. "studentSubmitedData",
  135. "classType",
  136. "musicGroupPaymentCalenderDtos",
  137. "classIdList",
  138. "classGroupStudents",
  139. "selectPrices",
  140. "classCouresTimeList",
  141. "teacherList",
  142. "cooperationList",
  143. "endSchoolTerm",
  144. "startCourseDate",
  145. "musicGroupSchoolTermCourseDetailId",
  146. ],
  147. data() {
  148. return {
  149. form: { coreTeacher: "", assistant: "", classs: {} },
  150. allClasss: {},
  151. prices: {},
  152. collapses: [0],
  153. courseTimes: {},
  154. courseTypeListByName: {},
  155. musicCourseSettings: 0, // 可排课时长
  156. musicSurplus: 0, //已排课时长
  157. courseTimeList: {}, // 每种课程类型已排课
  158. previewVisible: false,
  159. previewList: [],
  160. holidays: [],
  161. studentListModalVisible: false,
  162. studentList: [],
  163. };
  164. },
  165. async mounted() {
  166. try {
  167. await MusicStore.dispatch("getBaseInfo", {
  168. data: { musicGroupId: this.musicGroupId },
  169. });
  170. } catch (error) {}
  171. // console.log('courseTypeList',this.courseTypeList)
  172. // 获取班级的学生列表
  173. getClassAllStudent({ classGroupId: this.detail.id }).then((res) => {
  174. if (res.code == 200) {
  175. this.studentList = res.data.map((item) => {
  176. return {
  177. userId: item.userId,
  178. nickName: item.name,
  179. gender: item.gender,
  180. phone: item.parentsPhone,
  181. subjectNames: item.subjectName,
  182. };
  183. });
  184. }
  185. });
  186. this.setCourseTypeListByName(); // 获取课程名称和枚举的键值对
  187. this.formatClasss(); // 初始化班级
  188. this.FetchHoliday(); // 设置节假日
  189. },
  190. methods: {
  191. async FetchHoliday() {
  192. try {
  193. const res1 = await getSysTenantConfig({
  194. group: "holiday",
  195. });
  196. const res = await queryByOrganIdAndCourseType({
  197. organId: this.musicGroup.organId,
  198. });
  199. this.holidays = JSON.parse(res1.data[0].paranValue);
  200. this.prices = res.data;
  201. let arr = [];
  202. if (JSON.stringify(this.prices) == "{}") {
  203. // 课程时长
  204. arr.push("teamCourseTimer");
  205. }
  206. if (this.holidays.length <= 0) {
  207. arr.push("holiday");
  208. }
  209. //
  210. if (arr.length > 0) {
  211. this.$bus.$emit("showguide", arr);
  212. return;
  213. }
  214. } catch (error) {
  215. console.log(error);
  216. }
  217. },
  218. setCourseTypeListByName() {
  219. const courseTypeListByName = {};
  220. for (const item of this.courseTypeList) {
  221. if (item.value == "HIGH" || item.value == "HIGH_ONLINE") {
  222. } else {
  223. courseTypeListByName[item.value] = item.label;
  224. }
  225. }
  226. this.courseTypeListByName = courseTypeListByName;
  227. },
  228. async formatClasss() {
  229. this.coreid = "";
  230. this.assistant = [];
  231. if (this.detail) {
  232. const { classGroupTeacherMapperList } = this.detail;
  233. for (const item of classGroupTeacherMapperList || []) {
  234. if (item.teacherRole === "BISHOP") {
  235. this.coreid = String(item.userId);
  236. }
  237. if (item.teacherRole === "TEACHING") {
  238. this.assistant.push(item.userId);
  239. }
  240. }
  241. this.$set(this.form, "coreTeacher", String(this.coreid));
  242. this.$set(this.form, "assistant", this.assistant);
  243. }
  244. const classGroupId = this.detail?.id;
  245. if (!classGroupId) {
  246. this.$message.error("班级信息错误");
  247. return;
  248. }
  249. this.musicCourseSettings = this.detail.preSubMinutes;
  250. const classs = {};
  251. for (const item of this.courseTypeList) {
  252. const key = item.value;
  253. if (item.value == "HIGH" || item.value == "HIGH_ONLINE") {
  254. } else {
  255. this.courseTimeList[key] = 0;
  256. classs[key] = {
  257. courseTotalMinuties: this.musicCourseSettings,
  258. cycle: [
  259. {
  260. time: this.selectPrices ? this.selectPrices[key] : undefined,
  261. coreTeacher: this.coreid,
  262. assistant: this.assistant,
  263. },
  264. ],
  265. };
  266. }
  267. }
  268. // console.log(classs,this.courseTypeList[0].value)
  269. let key = this.courseTypeList[0].value;
  270. this.allClasss = { ...classs };
  271. let onlyClass = { [key]: classs[this.courseTypeList[0].value] };
  272. this.$set(this.form, "classs", onlyClass);
  273. },
  274. collapseChange(val) {
  275. this.collapses = val;
  276. },
  277. async submit() {
  278. if (this.activeCourseTime < 0) {
  279. this.$message.error("课程使用时长超过最大预排课数");
  280. return;
  281. }
  282. this.$refs.form.validate(async (valid) => {
  283. if (valid) {
  284. const list = [];
  285. for (const key in this.form.classs) {
  286. if (this.form.classs.hasOwnProperty(key)) {
  287. const item = this.form.classs[key];
  288. const data = {
  289. confirmGenerate: true,
  290. type: this.detail ? undefined : this.activeType,
  291. courseType: key,
  292. classGroupName:
  293. this.studentSubmitedData?.name ||
  294. this.detail?.name ||
  295. this.form.className,
  296. classGroupId: this.detail?.id,
  297. musicGroupId: this.musicGroupId,
  298. startDate: item.courseTime,
  299. classGroupTeacherMapperList: formatClassGroupTeacherMapperList(
  300. this.form.coreTeacher,
  301. this.form.assistant
  302. ),
  303. holiday: item.holiday,
  304. students: this.studentSubmitedData?.seleched,
  305. courseTimes: item.cycle.length,
  306. courseTimeDtoList: item.cycle.map((_) => ({
  307. classGroupTeacherMapperList: this.formatTeacher(_),
  308. courseType: key,
  309. dayOfWeek: _.dayOfWeek,
  310. endClassTime: _.endClassTime,
  311. startClassTime: _.startClassTime,
  312. startDate: _.startDate,
  313. endDate: _.endDate,
  314. holiday: _.holiday,
  315. expectCourseNum: _.expectCourseNum,
  316. expectCourseMinutes: _.time,
  317. })),
  318. musicGroupSchoolTermCourseDetailId:
  319. this.musicGroupSchoolTermCourseDetailId,
  320. };
  321. list.push(data);
  322. }
  323. }
  324. try {
  325. const res = await preCourseSchedule(list);
  326. if (res.code == 207) {
  327. await this.$confirm(
  328. res.msg || `当前课程课酬预计为0,是否继续`,
  329. "提示",
  330. {
  331. type: "warning",
  332. }
  333. );
  334. // obj.allowZeroSalary = true;
  335. list.forEach((item) => {
  336. item.allowZeroSalary = true;
  337. });
  338. await preCourseSchedule(list);
  339. this.$listeners.submited();
  340. this.$listeners.close();
  341. return;
  342. }
  343. this.$message.success("排课成功");
  344. this.$listeners.submited();
  345. this.$listeners.close();
  346. } catch (e) {
  347. console.log(e);
  348. }
  349. }
  350. });
  351. },
  352. setUserTime(time, type) {
  353. this.$set(this.courseTimeList, type, time || 0);
  354. this.musicSurplus = 0;
  355. for (let key in this.courseTimeList) {
  356. this.musicSurplus += this.courseTimeList[key];
  357. }
  358. this.$forceUpdate();
  359. },
  360. changeTag(key) {
  361. const clas = { ...this.form.classs };
  362. if (clas[key]) {
  363. delete clas[key];
  364. } else {
  365. clas[key] = this.allClasss[key];
  366. }
  367. this.$set(this.form, "classs", clas);
  368. },
  369. formatTeacher(row) {
  370. let arr = [];
  371. if (row.coreTeacher) {
  372. let obj = {};
  373. obj.teacherRole = "BISHOP";
  374. obj.userId = row.coreTeacher;
  375. arr.push(obj);
  376. }
  377. if (row.assistant?.length > 0) {
  378. row.assistant.forEach((ass) => {
  379. arr.push({ teacherRole: "TEACHING", userId: ass });
  380. });
  381. }
  382. return arr;
  383. },
  384. },
  385. watch: {
  386. watch: {
  387. courseTypeList() {
  388. this.setCourseTypeListByName();
  389. },
  390. detail() {
  391. this.formatClasss();
  392. },
  393. },
  394. },
  395. computed: {
  396. musicGroup() {
  397. return MusicStore.state.musicGroup;
  398. },
  399. isEmpty() {
  400. return isEmpty(this.form.classs);
  401. },
  402. surplustime() {
  403. return this.detail.preSubMinutes;
  404. },
  405. activeCourseTime() {
  406. let time = this.detail.preSubMinutes - this.musicSurplus;
  407. return time;
  408. },
  409. },
  410. };
  411. </script>
  412. <style lang="scss" scoped>
  413. .coursetitle {
  414. padding: 0 20px;
  415. font-size: 14px;
  416. color: #606266;
  417. line-height: 40px;
  418. }
  419. .title {
  420. color: red;
  421. margin-bottom: 30px;
  422. font-size: 16px;
  423. font-weight: bold;
  424. }
  425. .tag {
  426. margin-right: 5px;
  427. cursor: pointer;
  428. }
  429. .dialog-footer {
  430. margin-top: 20px;
  431. display: block;
  432. text-align: right;
  433. }
  434. </style>