improvementClass.vue 12 KB

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