compoundClass.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. @close="studentListModalVisible = false" />
  161. </el-dialog>
  162. </div>
  163. </template>
  164. <script>
  165. import { diffTimerFormMinute, addTimerFormMinute } from '@/utils/date'
  166. import { getTeacher, resetCourse, getCourseScheduleDetail,getCourseStudents } from "@/api/buildTeam";
  167. import viewStudentList from '../components/modals/view-student-list'
  168. import { getTeachSchool } from "@/api/teacherManager";
  169. import cleanDeep from 'clean-deep'
  170. import dayjs from 'dayjs';
  171. export default {
  172. props: ["show", "id", "isDisabled","idList"],
  173. components: { viewStudentList },
  174. data () {
  175. return {
  176. courseVisible: false,
  177. studentListModalVisible: false,
  178. maskForm: {
  179. teacher: null,
  180. assistant: null,
  181. date: null,
  182. timer: null,
  183. startTime: null,
  184. endTime: null,
  185. name: null
  186. },
  187. maskRules: {
  188. name: [{ required: true, message: "请输入课程名称", trigger: "blur" }],
  189. teacher: [
  190. { required: true, message: "请选择主教老师名称", trigger: "blur" }
  191. ],
  192. date: [{ required: true, message: "请选择上课时间", trigger: "blur" }],
  193. startTime: [{ required: true, message: '请选择上课开始时间', trigger: 'blur' },],
  194. endTime: [{ required: true, message: '请选择上课结束时间', trigger: 'blur' },],
  195. },
  196. teacherList: [],
  197. schoolList: [],
  198. studentListModal: []
  199. }
  200. },
  201. mounted () {
  202. getTeacher().then(res => {
  203. if (res.code == 200) {
  204. this.teacherList = res.data;
  205. }
  206. });
  207. this.getDetail(this.id)
  208. },
  209. methods: {
  210. submitResetClass () {
  211. let maskForm = this.maskForm;
  212. if (!maskForm.startTime || !maskForm.endTime) {
  213. this.$message.error("请填写开始时间或结束时间");
  214. return;
  215. }
  216. this.$confirm("是否确定?", "提示", {
  217. confirmButtonText: "确定",
  218. cancelButtonText: "取消",
  219. type: "warning"
  220. })
  221. .then(() => {
  222. let teachingTeacherIdList = maskForm.assistant.join(",");
  223. if (teachingTeacherIdList.length <= 0) {
  224. let teachingTeacherIdList = null;
  225. }
  226. let obj = {
  227. actualTeacherId: maskForm.teacher,
  228. startClassTimeStr: maskForm.startTime,
  229. endClassTimeStr: maskForm.endTime,
  230. id: maskForm.id,
  231. teachingTeacherIdList,
  232. classDate: maskForm.date,
  233. type: maskForm.type,
  234. groupType: maskForm.groupType,
  235. schoolId: this.maskForm.address,
  236. teachMode: this.maskForm.teachMode,
  237. };
  238. resetCourse(cleanDeep(obj)).then(res => {
  239. if (res.code == 200) {
  240. this.$message.success("修改成功");
  241. this.$emit('getList')
  242. this.$emit('closeReset')
  243. // this.getList();
  244. // this.courseVisible = false;
  245. }
  246. });
  247. })
  248. .catch(() => { });
  249. },
  250. changeStartTime (val) {
  251. this.$nextTick(res => {
  252. console.log(addTimerFormMinute(this.maskForm.date, val, this.maskForm.timer))
  253. if (val) {
  254. this.$set(this.maskForm, 'endTime', addTimerFormMinute(this.maskForm.date, val, this.maskForm.timer))
  255. } else {
  256. this.$set(this.maskForm, 'endTime', '')
  257. }
  258. })
  259. },
  260. changeTeacher (val) {
  261. if (val) {
  262. getTeachSchool({
  263. userId: val
  264. }).then(res => {
  265. if (res.code == 200) {
  266. this.schoolList = res.data;
  267. }
  268. })
  269. this.maskForm.address = ''
  270. }
  271. },
  272. getDetail (id) {
  273. getCourseScheduleDetail({ courseScheduleId: id }).then(res => {
  274. if (res.code == 200) {
  275. console.log(res.data.groupType)
  276. this.maskForm = {
  277. id: res.data.id,
  278. teacher: res.data.actualTeacherId,
  279. assistant: [],
  280. date: dayjs(res.data.classDate).format('YYYY-MM-DD'),
  281. startTime: dayjs(res.data.startClassTime).format('HH:mm'),
  282. endTime: dayjs(res.data.endClassTime).format('HH:mm'),
  283. timer: null,
  284. type: res.data.type,
  285. groupType: res.data.groupType,
  286. schoolId: res.data.schoolId,
  287. teachMode: res.data.teachMode,
  288. name: res.data.name
  289. }
  290. this.maskForm.assistant = [];
  291. for (let i in res.data.teachingTeachers) {
  292. if (res.data.teachingTeachers[i].teacherRole == "TEACHING") {
  293. this.maskForm.assistant.push(res.data.teachingTeachers[i].userId);
  294. }
  295. }
  296. 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'))
  297. console.log(dayjs(res.data.startClassTime).format('HH:mm'))
  298. this.maskForm.timer = time;
  299. if (this.maskForm.teacher) {
  300. getTeachSchool({
  301. userId: this.maskForm.teacher
  302. }).then(res => {
  303. if (res.code == 200) {
  304. this.schoolList = res.data;
  305. }
  306. })
  307. }
  308. }
  309. })
  310. },
  311. lookStudentList(){
  312. getCourseStudents({courseIds:this.idList}).then(res=>{
  313. if(res.code == 200){
  314. this.studentListModal = res.data;
  315. this.studentListModalVisible = true;
  316. }
  317. })
  318. }
  319. },
  320. watch: {
  321. id (val) {
  322. if (val) {
  323. this.getDetail(val)
  324. }
  325. },
  326. 'maskForm.timer' (val) {
  327. this.$nextTick(res => {
  328. if (val) {
  329. this.$set(this.maskForm, 'endTime', addTimerFormMinute(this.maskForm.date, this.maskForm.startTime, val))
  330. } else {
  331. this.$set(this.maskForm, 'endTime', '')
  332. }
  333. })
  334. }
  335. }
  336. }
  337. </script>
  338. <style lang="scss" scoped>
  339. /deep/.dialog-footer {
  340. display: flex;
  341. flex-direction: row;
  342. justify-content: flex-end;
  343. }
  344. .studentTitle {
  345. width: 120px !important;
  346. text-align: right;
  347. display: inline-block;
  348. color: #409eff;
  349. }
  350. </style>