compoundClass.vue 12 KB

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