compoundClass.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div>
  3. <el-form
  4. :model="maskForm"
  5. class="maskForm"
  6. ref="maskForm"
  7. :rules="maskRules"
  8. label-position="right"
  9. label-width="120px"
  10. :inline="true"
  11. >
  12. <el-row>
  13. <el-col :span="12">
  14. <el-form-item label="课程名称" prop="teacher">
  15. <el-input
  16. v-model.trim="maskForm.name"
  17. style="width: 220px !important"
  18. placeholder="请输入课程名称"
  19. ></el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="12">
  23. <el-form-item>
  24. <div style="width: 220px !important">
  25. <a href="#" class="studentTitle" @click="lookStudentList">
  26. 学生列表>></a
  27. >
  28. </div>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. <el-row>
  33. <el-col :span="12">
  34. <el-form-item label="主教老师" prop="teacher">
  35. <el-select
  36. v-model.trim="maskForm.teacher"
  37. style="width: 220px !important"
  38. @change="changeTeacher"
  39. clearable
  40. filterable
  41. >
  42. <el-option
  43. v-for="(item, index) in teacherList"
  44. :key="index"
  45. :value="item.id"
  46. :label="item.realName"
  47. ></el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="12">
  52. <el-form-item
  53. label="助教老师"
  54. v-if="
  55. maskForm.type != 'MUSIC_NETWORK' &&
  56. maskForm.type != 'HIGH_ONLINE' &&
  57. maskForm.groupType == 'MUSIC'
  58. "
  59. prop="assistant"
  60. >
  61. <el-select
  62. v-model.trim="maskForm.assistant"
  63. style="width: 220px !important"
  64. clearable
  65. filterable
  66. multiple
  67. collapse-tags
  68. >
  69. <el-option
  70. v-for="(item, index) in teacherList"
  71. :key="index"
  72. :value="item.id"
  73. :label="item.realName"
  74. ></el-option>
  75. </el-select>
  76. </el-form-item>
  77. </el-col>
  78. </el-row>
  79. <el-row>
  80. <el-col :span="12">
  81. <el-form-item label="上课日期" prop="date">
  82. <el-date-picker
  83. v-model.trim="maskForm.date"
  84. type="date"
  85. :picker-options="{
  86. firstDayOfWeek: 1,
  87. }"
  88. value-format="yyyy-MM-dd"
  89. placeholder="选择日期"
  90. ></el-date-picker>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="12">
  94. <el-form-item label="课程时长(分钟)" prop="timer">
  95. <el-input
  96. type="number"
  97. :disabled="isDisabled"
  98. style="width: 220px !important"
  99. v-model="maskForm.timer"
  100. ></el-input>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. <el-row>
  105. <el-col :span="12">
  106. <el-form-item label="开始时间" prop="startTime">
  107. <el-time-picker
  108. placeholder="起始时间"
  109. v-model.trim="maskForm.startTime"
  110. @change="changeStartTime"
  111. format="HH:mm"
  112. value-format="HH:mm"
  113. :picker-options="{
  114. selectableRange: '04:30:00 - 23:30:00',
  115. }"
  116. ></el-time-picker>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="12">
  120. <el-form-item label="结束时间" prop="endTime">
  121. <el-time-picker
  122. placeholder="结束时间"
  123. v-model.trim="maskForm.endTime"
  124. disabled
  125. format="HH:mm"
  126. value-format="HH:mm"
  127. :picker-options="{
  128. start: '04:30',
  129. step: '00:05',
  130. end: '23:30',
  131. minTime: maskForm.startTime,
  132. }"
  133. ></el-time-picker>
  134. </el-form-item>
  135. </el-col>
  136. </el-row>
  137. <el-row>
  138. <el-col :span="12">
  139. <el-form-item
  140. label="课程类型"
  141. v-if="maskForm.type == 'VIP'"
  142. prop="courseType"
  143. >
  144. <el-select
  145. clearable
  146. style="width: 220px !important"
  147. v-model.trim="maskForm.teachMode"
  148. >
  149. <el-option label="线上课" value="ONLINE"></el-option>
  150. <el-option label="线下课" value="OFFLINE"></el-option>
  151. </el-select>
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="12">
  155. <el-form-item
  156. label="教学地点"
  157. v-if="maskForm.teachMode == 'OFFLINE' && maskForm.type == 'VIP'"
  158. >
  159. <el-select
  160. v-model.trim="maskForm.address"
  161. style="width: 220px !important"
  162. filterable
  163. clearable
  164. >
  165. <el-option
  166. v-for="(item, index) in schoolList"
  167. :key="index"
  168. :value="item.id"
  169. :label="item.name"
  170. ></el-option>
  171. </el-select>
  172. </el-form-item>
  173. </el-col>
  174. </el-row>
  175. </el-form>
  176. <div slot="footer" class="dialog-footer">
  177. <el-button @click="$listeners.closeReset">取 消</el-button>
  178. <el-button type="primary" @click="submitResetClass">确 定</el-button>
  179. </div>
  180. <el-dialog
  181. title="学员列表"
  182. width="650px"
  183. append-to-body
  184. :visible.sync="studentListModalVisible"
  185. destroy-on-close
  186. >
  187. <viewStudentList
  188. :list="studentListModal"
  189. :showOk="true"
  190. @close="studentListModalVisible = false"
  191. />
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import { diffTimerFormMinute, addTimerFormMinute } from "@/utils/date";
  197. import {
  198. getTeacher,
  199. courseMerge,
  200. getCourseScheduleDetail,
  201. getCourseStudents,
  202. } from "@/api/buildTeam";
  203. import viewStudentList from "../components/modals/view-student-list";
  204. import { getTeachSchool } from "@/api/teacherManager";
  205. import cleanDeep from "clean-deep";
  206. import dayjs from "dayjs";
  207. export default {
  208. props: ["show", "id", "isDisabled", "idList"],
  209. components: { viewStudentList },
  210. data() {
  211. return {
  212. courseVisible: false,
  213. studentListModalVisible: false,
  214. maskForm: {
  215. teacher: null,
  216. assistant: null,
  217. date: null,
  218. timer: null,
  219. startTime: null,
  220. endTime: null,
  221. name: null,
  222. },
  223. maskRules: {
  224. name: [{ required: true, message: "请输入课程名称", trigger: "blur" }],
  225. teacher: [
  226. { required: true, message: "请选择主教老师名称", trigger: "blur" },
  227. ],
  228. date: [{ required: true, message: "请选择上课时间", trigger: "blur" }],
  229. startTime: [
  230. { required: true, message: "请选择上课开始时间", trigger: "blur" },
  231. ],
  232. endTime: [
  233. { required: true, message: "请选择上课结束时间", trigger: "blur" },
  234. ],
  235. },
  236. teacherList: [],
  237. schoolList: [],
  238. studentListModal: [],
  239. };
  240. },
  241. mounted() {
  242. getTeacher().then((res) => {
  243. if (res.code == 200) {
  244. this.teacherList = res.data;
  245. }
  246. });
  247. this.getDetail(this.id);
  248. },
  249. methods: {
  250. submitResetClass() {
  251. let maskForm = this.maskForm;
  252. if (!maskForm.startTime || !maskForm.endTime) {
  253. this.$message.error("请填写开始时间或结束时间");
  254. return;
  255. }
  256. this.$confirm("是否确定?", "提示", {
  257. confirmButtonText: "确定",
  258. cancelButtonText: "取消",
  259. type: "warning",
  260. })
  261. .then(() => {
  262. let teachingTeacherIdList = maskForm.assistant.join(",");
  263. if (teachingTeacherIdList.length <= 0) {
  264. let teachingTeacherIdList = null;
  265. }
  266. let arr = this.idList.split(",");
  267. for (let i in arr) {
  268. if (arr[i] == this.id) {
  269. arr.splice(i, 1);
  270. }
  271. }
  272. let ids = arr.join(",");
  273. let obj = {
  274. actualTeacherId: maskForm.teacher,
  275. startClassTimeStr: maskForm.startTime,
  276. endClassTimeStr: maskForm.endTime,
  277. id: maskForm.id,
  278. teachingTeacherIdList,
  279. classDate: maskForm.date,
  280. type: maskForm.type,
  281. groupType: maskForm.groupType,
  282. schoolId: this.maskForm.address,
  283. teachMode: this.maskForm.teachMode,
  284. mergeCourseIds: ids,
  285. };
  286. courseMerge(obj).then((res) => {
  287. if (res.code == 200) {
  288. this.$message.success("修改成功");
  289. // this.$emit('getList')
  290. this.$emit("closeReset");
  291. // this.getList();
  292. // this.courseVisible = false;
  293. }
  294. if (res.code == 206) {
  295. this.$confirm(`当前课程课酬预计为0,是否继续`, "提示", {
  296. confirmButtonText: "确定",
  297. cancelButtonText: "取消",
  298. type: "warning",
  299. }).then((res) => {
  300. obj.allowZeroSalary = true;
  301. courseMerge(obj).then((res) => {
  302. if (res.code == 200) {
  303. this.$message.success("修改成功");
  304. // this.$emit('getList')
  305. this.$emit("closeReset");
  306. // this.getList();
  307. // this.courseVisible = false;
  308. }
  309. });
  310. });
  311. }
  312. });
  313. })
  314. .catch(() => {});
  315. },
  316. changeStartTime(val) {
  317. this.$nextTick((res) => {
  318. console.log(
  319. addTimerFormMinute(this.maskForm.date, val, this.maskForm.timer)
  320. );
  321. if (val) {
  322. this.$set(
  323. this.maskForm,
  324. "endTime",
  325. addTimerFormMinute(this.maskForm.date, val, this.maskForm.timer)
  326. );
  327. } else {
  328. this.$set(this.maskForm, "endTime", "");
  329. }
  330. });
  331. },
  332. changeTeacher(val) {
  333. if (val) {
  334. getTeachSchool({
  335. userId: val,
  336. }).then((res) => {
  337. if (res.code == 200) {
  338. this.schoolList = res.data;
  339. }
  340. });
  341. this.maskForm.address = "";
  342. }
  343. },
  344. getDetail(id) {
  345. getCourseScheduleDetail({ courseScheduleId: id }).then((res) => {
  346. if (res.code == 200) {
  347. console.log(res.data.groupType);
  348. this.maskForm = {
  349. id: res.data.id,
  350. teacher: res.data.actualTeacherId,
  351. assistant: [],
  352. date: dayjs(res.data.classDate).format("YYYY-MM-DD"),
  353. startTime: dayjs(res.data.startClassTime).format("HH:mm"),
  354. endTime: dayjs(res.data.endClassTime).format("HH:mm"),
  355. timer: null,
  356. type: res.data.type,
  357. groupType: res.data.groupType,
  358. schoolId: res.data.schoolId,
  359. teachMode: res.data.teachMode,
  360. name: res.data.name,
  361. };
  362. this.maskForm.assistant = [];
  363. for (let i in res.data.teachingTeachers) {
  364. if (res.data.teachingTeachers[i].teacherRole == "TEACHING") {
  365. this.maskForm.assistant.push(res.data.teachingTeachers[i].userId);
  366. }
  367. }
  368. let time = diffTimerFormMinute(
  369. dayjs(res.data.classDate).format("YYYY-MM-DD"),
  370. dayjs(res.data.startClassTime).format("HH:mm"),
  371. dayjs(res.data.endClassTime).format("HH:mm")
  372. );
  373. console.log(dayjs(res.data.startClassTime).format("HH:mm"));
  374. this.maskForm.timer = time;
  375. if (this.maskForm.teacher) {
  376. getTeachSchool({
  377. userId: this.maskForm.teacher,
  378. }).then((res) => {
  379. if (res.code == 200) {
  380. this.schoolList = res.data;
  381. }
  382. });
  383. }
  384. }
  385. });
  386. },
  387. lookStudentList() {
  388. getCourseStudents({ courseIds: this.idList }).then((res) => {
  389. if (res.code == 200) {
  390. this.studentListModal = res.data;
  391. this.studentListModalVisible = true;
  392. }
  393. });
  394. },
  395. },
  396. watch: {
  397. id(val) {
  398. if (val) {
  399. this.getDetail(val);
  400. }
  401. },
  402. "maskForm.timer"(val) {
  403. this.$nextTick((res) => {
  404. if (val) {
  405. this.$set(
  406. this.maskForm,
  407. "endTime",
  408. addTimerFormMinute(this.maskForm.date, this.maskForm.startTime, val)
  409. );
  410. } else {
  411. this.$set(this.maskForm, "endTime", "");
  412. }
  413. });
  414. },
  415. },
  416. };
  417. </script>
  418. <style lang="scss" scoped>
  419. /deep/.dialog-footer {
  420. display: flex;
  421. flex-direction: row;
  422. justify-content: flex-end;
  423. }
  424. .studentTitle {
  425. width: 120px !important;
  426. text-align: right;
  427. display: inline-block;
  428. color: #409eff;
  429. }
  430. </style>