compoundClass.vue 14 KB

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