improvementClass.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class='imc'>
  3. <el-form :inline="true"
  4. :model="topForm"
  5. ref='topForm'
  6. :rules="topFormRules">
  7. <el-form-item>
  8. <div class="addBtn"
  9. @click="addClass">添加班级</div>
  10. </el-form-item>
  11. <el-form-item label="提高班参考数量">
  12. <el-input disabled
  13. v-model="topForm.improventClassesNum"></el-input>
  14. </el-form-item>
  15. <el-form-item label="排课数量"
  16. prop="count">
  17. <el-input v-model="topForm.count"></el-input>
  18. </el-form-item>
  19. <el-form-item label="排课开始时间"
  20. prop="timer">
  21. <el-date-picker v-model="topForm.timer"
  22. align="right"
  23. type="date"
  24. placeholder="选择日期"
  25. value-format="yyyy-MM-dd">
  26. </el-date-picker>
  27. </el-form-item>
  28. </el-form>
  29. <div class="tableWrap">
  30. <el-table :data="tableList">
  31. <el-table-column prop="name"
  32. label="提高班名称">
  33. </el-table-column>
  34. <el-table-column prop="subjectIdList"
  35. label="声部">
  36. <template slot-scope="scope">
  37. <div>
  38. {{ scope.row.subjectIdList | fitterSound }}
  39. </div>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="userId"
  43. label="主教老师">
  44. <template slot-scope="scope">
  45. <div>
  46. {{ scope.row.userId | fitterTeacher }}
  47. </div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="courseTimes"
  51. label="班级人数">
  52. </el-table-column>
  53. <el-table-column prop="date"
  54. label="上课时间">
  55. <template slot-scope="scope">
  56. <div>
  57. <p>{{scope.row.startClassTime+'-'+scope.row.endClassTime}}</p>
  58. </div>
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="date"
  62. label="操作">
  63. <template slot-scope="scope">
  64. <div>
  65. <el-button type="text"
  66. @click="removeClass(scope.row)">删除</el-button>
  67. </div>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. <!-- 确认取消 -->
  73. <div class="btnWrap"
  74. style="margin-top:40px;">
  75. <div class="nextBtn"
  76. @click='gotoNext'>下一步</div>
  77. <div class="okBtn">返回</div>
  78. </div>
  79. <el-dialog title="添加提高班"
  80. :visible.sync="raiseVisible"
  81. width="40%">
  82. <el-form :model="maskForm"
  83. ref='maskForm'
  84. :rules="maskRules"
  85. :label-position="labelPosition"
  86. label-width="100px">
  87. <el-form-item label="提高班名称"
  88. prop="name">
  89. <el-input v-model="maskForm.name"
  90. style='width:180px;'></el-input>
  91. </el-form-item>
  92. <el-form-item label="提高班声部"
  93. prop="sound">
  94. <el-select v-model="maskForm.sound">
  95. <el-option v-for="(item,index) in soundList"
  96. :key='index'
  97. :label="item.name"
  98. :value="item.id"></el-option>
  99. </el-select>
  100. </el-form-item>
  101. <el-form-item label="主教老师"
  102. prop="teacher">
  103. <el-select v-model="maskForm.teacher">
  104. <el-option v-for="(item,index) in teacherList"
  105. :key="index"
  106. :label="item.name"
  107. :value="item.userId"></el-option>
  108. </el-select>
  109. </el-form-item>
  110. <el-form-item label="班级人数"
  111. prop="count">
  112. <el-input v-model="maskForm.count"
  113. type="number"
  114. style='width:180px;'></el-input>
  115. </el-form-item>
  116. <el-form-item label="星期几"
  117. prop="week">
  118. <el-select v-model="maskForm.week">
  119. <el-option value="1"
  120. label="星期一"></el-option>
  121. <el-option value="2"
  122. label="星期二"></el-option>
  123. <el-option value="3"
  124. label="星期三"></el-option>
  125. <el-option value="4"
  126. label="星期四"></el-option>
  127. <el-option value="5"
  128. label="星期五"></el-option>
  129. <el-option value="6"
  130. label="星期六"></el-option>
  131. <el-option value="7"
  132. label="星期天"></el-option>
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item label="时间段"
  136. prop="startTime">
  137. <el-time-select placeholder="起始时间"
  138. v-model="maskForm.startTime"
  139. :picker-options="{
  140. start: '06:30',
  141. step: '00:15',
  142. end: '23:30'
  143. }">
  144. </el-time-select>
  145. <el-time-select placeholder="结束时间"
  146. v-model="maskForm.endTime"
  147. :picker-options="{
  148. start: '06:30',
  149. step: '00:15',
  150. end: '23:30',
  151. minTime: maskForm.endTime
  152. }">
  153. </el-time-select>
  154. </el-form-item>
  155. </el-form>
  156. <span slot="footer"
  157. class="dialog-footer">
  158. <el-button @click="raiseVisible = false">取 消</el-button>
  159. <el-button type="primary"
  160. @click="addraiseClass">确 定</el-button>
  161. </span>
  162. </el-dialog>
  163. </div>
  164. </template>
  165. <script>
  166. import { findSound, findMusicGroupClassTeacher, getTeacher, getTeamDetail, addHighClass } from '@/api/buildTeam'
  167. let that;
  168. export default {
  169. props: {
  170. teamid: {
  171. type: String,
  172. required: true
  173. }
  174. },
  175. beforeCreate () {
  176. that = this;
  177. },
  178. data () {
  179. return {
  180. labelPosition: 'right',
  181. topForm: {
  182. count: '',
  183. improventClassesNum: '',
  184. timer: ''
  185. },
  186. maskForm: {
  187. name: '',
  188. sound: '',
  189. count: '',
  190. teacher: '',
  191. startTime: '',
  192. endTime: '',
  193. week: ''
  194. },
  195. raiseVisible: false,
  196. tableList: [],
  197. soundList: [],
  198. teacherList: [],
  199. maskRules: {
  200. name: [{ required: true, message: '请输入姓名', trigger: 'blur' },
  201. { min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }],
  202. sound: [{ required: true, message: '请选择声部', trigger: 'blur' },],
  203. count: [{ required: true, message: '请输入学生数', trigger: 'blur' }],
  204. teacher: [{ required: true, message: '请选择老师', trigger: 'blur' }],
  205. startTime: [{ required: true, message: '请选择开始时间', trigger: 'blur' }],
  206. endTime: '',
  207. week: [{ required: true, message: '请选择星期几', trigger: 'blur' }]
  208. },
  209. topFormRules: {
  210. count: [{ required: true, message: '请输入排课数量', trigger: 'blur' }],
  211. timer: [{ required: true, message: '请选择开课时间', trigger: 'blur' }]
  212. }
  213. }
  214. },
  215. mounted () {
  216. // 获取乐团声部
  217. findSound({ musicGroupId: this.teamid }).then(res => {
  218. if (res.code == 200) {
  219. this.soundList = res.data;
  220. }
  221. })
  222. findMusicGroupClassTeacher({ musicGroupId: this.teamid }).then(res => {
  223. if (res.code == 200) {
  224. this.teacherList = res.data
  225. // console.log(res.data);
  226. }
  227. })
  228. // 获取乐团老师
  229. // findMusicGroupClassTeacher({ musicGroupId: this.teamid }).then()
  230. getTeamDetail({ musicGroupId: this.teamid }).then(res => {
  231. if (res.code == 200) {
  232. this.topForm.improventClassesNum = res.data.improventClassesNum;
  233. }
  234. });
  235. },
  236. methods: {
  237. addraiseClass () {
  238. this.$refs['maskForm'].validate(res => {
  239. if (res) {
  240. // 验证成功组成数组
  241. let obj = {
  242. 'userId': this.maskForm.teacher, // 老师id
  243. 'dayOfWeek': this.maskForm.week, // 周几
  244. 'startClassTime': this.maskForm.startTime,
  245. 'endClassTime': this.maskForm.endTime,
  246. 'courseTimes': this.topForm.count,
  247. 'type': 'HIGH',
  248. 'expectStudentNum': this.maskForm.count,
  249. 'musicGroupId': this.teamid,
  250. 'teachMode': 'OFFLINE',
  251. 'name': this.maskForm.name,
  252. 'subjectIdList': this.maskForm.sound,
  253. 'moid': new Date().getTime(),
  254. 'startDate': this.topForm.timer
  255. }
  256. this.tableList.push(obj);
  257. this.raiseVisible = false;
  258. this.$refs['maskForm'].resetFields();
  259. this.maskForm.endTime = '';
  260. } else {
  261. this.$message.error('请填写必要信息')
  262. }
  263. })
  264. },
  265. removeClass (row) {
  266. for (let i in this.tableList) {
  267. if (this.tableList[i].moid == row.moid) {
  268. this.tableList.splice(i, 1);
  269. }
  270. }
  271. },
  272. addClass () {
  273. this.$refs['topForm'].validate(res => {
  274. if (res) {
  275. this.raiseVisible = true;
  276. } else {
  277. // this.$message.error('请先输入排课数量')
  278. }
  279. })
  280. },
  281. gotoNext () {
  282. addHighClass(this.tableList).then(res => {
  283. if (res.code == 200) {
  284. this.$message.success('恭喜您创建成功')
  285. }
  286. })
  287. }
  288. },
  289. filters: {
  290. fitterSound (val) {
  291. if (that.soundList) {
  292. for (let i in that.soundList) {
  293. if (that.soundList[i].id == val) {
  294. return that.soundList[i].name
  295. }
  296. }
  297. } else {
  298. return ''
  299. }
  300. },
  301. fitterTeacher (val) {
  302. if (that.teacherList) {
  303. for (let i in that.teacherList) {
  304. if (that.teacherList[i].userId == val) {
  305. return that.teacherList[i].name
  306. }
  307. }
  308. } else {
  309. return ''
  310. }
  311. }
  312. }
  313. }
  314. </script>
  315. <style lang="scss" scoped>
  316. .imc {
  317. box-sizing: border-box;
  318. padding: 30px 42px;
  319. background-color: #fff;
  320. min-height: 80vh;
  321. .addBtn {
  322. line-height: 40px;
  323. text-align: center;
  324. color: #fff;
  325. border-radius: 4px;
  326. margin-right: 20px;
  327. cursor: pointer;
  328. width: 120px;
  329. height: 40px;
  330. background-color: #4eada7;
  331. }
  332. }
  333. </style>