compoundClass.vue 14 KB

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