improvementClass.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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. filterable>
  113. <el-option v-for="(item,index) in teacherList"
  114. :key="index"
  115. :label="item.realName"
  116. :value="item.id"></el-option>
  117. </el-select>
  118. </el-form-item>
  119. <el-form-item label="班级人数"
  120. prop="studentNum">
  121. <el-input v-model="maskForm.count"
  122. type="number"
  123. style='width:180px;'></el-input>
  124. </el-form-item>
  125. <el-form-item label="星期几"
  126. prop="week">
  127. <el-select v-model="maskForm.week">
  128. <el-option value="1"
  129. label="星期一"></el-option>
  130. <el-option value="2"
  131. label="星期二"></el-option>
  132. <el-option value="3"
  133. label="星期三"></el-option>
  134. <el-option value="4"
  135. label="星期四"></el-option>
  136. <el-option value="5"
  137. label="星期五"></el-option>
  138. <el-option value="6"
  139. label="星期六"></el-option>
  140. <el-option value="7"
  141. label="星期天"></el-option>
  142. </el-select>
  143. </el-form-item>
  144. <el-form-item label="时间段"
  145. prop="startTime">
  146. <el-time-select placeholder="起始时间"
  147. value-format='HH:mm:ss'
  148. v-model="maskForm.startTime"
  149. :picker-options="{
  150. start: '06:30',
  151. step: '00:05',
  152. end: '23:30'
  153. }">
  154. </el-time-select>
  155. <el-time-select placeholder="结束时间"
  156. v-model="maskForm.endTime"
  157. value-format='HH:mm:ss'
  158. :picker-options="{
  159. start: '06:30',
  160. step: '00:05',
  161. end: '23:30',
  162. minTime: maskForm.startTime
  163. }">
  164. </el-time-select>
  165. </el-form-item>
  166. </el-form>
  167. <span slot="footer"
  168. class="dialog-footer">
  169. <el-button @click="raiseVisible = false">取 消</el-button>
  170. <el-button type="primary"
  171. @click="addraiseClass">确 定</el-button>
  172. </span>
  173. </el-dialog>
  174. </div>
  175. </template>
  176. <script>
  177. import { findSound, findMusicGroupClassTeacher, getTeacher, getTeamDetail, addHighClass, highClassGroups } from '@/api/buildTeam'
  178. let that;
  179. export default {
  180. props: {
  181. teamid: {
  182. type: String,
  183. required: true
  184. },
  185. isSetSalary: {
  186. type: Boolean,
  187. required: true
  188. }
  189. },
  190. beforeCreate () {
  191. that = this;
  192. },
  193. data () {
  194. return {
  195. labelPosition: 'right',
  196. topForm: {
  197. count: '',
  198. improventClassesNum: '',
  199. timer: ''
  200. },
  201. maskForm: {
  202. name: '',
  203. sound: [],
  204. count: '',
  205. teacher: '',
  206. startTime: '',
  207. endTime: '',
  208. week: ''
  209. },
  210. raiseVisible: false,
  211. tableList: [],
  212. soundList: [],
  213. teacherList: [],
  214. maskRules: {
  215. name: [{ required: true, message: '请输入姓名', trigger: 'blur' },
  216. { min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }],
  217. sound: [{ required: true, message: '请选择声部', trigger: 'blur' },],
  218. count: [{ required: true, message: '请输入学生数', trigger: 'blur' }],
  219. teacher: [{ required: true, message: '请选择老师', trigger: 'blur' }],
  220. startTime: [{ required: true, message: '请选择开始时间', trigger: 'blur' }],
  221. endTime: '',
  222. week: [{ required: true, message: '请选择星期几', trigger: 'blur' }]
  223. },
  224. topFormRules: {
  225. count: [{ required: true, message: '请输入排课数量', trigger: 'blur' }],
  226. timer: [{ required: true, message: '请选择开课时间', trigger: 'blur' }]
  227. }
  228. }
  229. },
  230. mounted () {
  231. // 获取乐团声部
  232. findSound({ musicGroupId: this.teamid }).then(res => {
  233. if (res.code == 200) {
  234. this.soundList = res.data;
  235. }
  236. })
  237. // findMusicGroupClassTeacher({ musicGroupId: this.teamid }).then(res => {
  238. // if (res.code == 200) {
  239. // this.teacherList = res.data
  240. // // console.log(res.data);
  241. // }
  242. // })
  243. getTeacher().then(res => {
  244. if (res.code == 200) {
  245. this.teacherList = res.data
  246. }
  247. })
  248. // 获取乐团老师
  249. // findMusicGroupClassTeacher({ musicGroupId: this.teamid }).then()
  250. getTeamDetail({ musicGroupId: this.teamid }).then(res => {
  251. if (res.code == 200) {
  252. this.topForm.improventClassesNum = res.data.improventClassesNum;
  253. }
  254. });
  255. // 获取提高班列表
  256. highClassGroups({ musicGroupId: this.teamid }).then(res => {
  257. if (res.code == 200) {
  258. this.tableList = res.data;
  259. // for (let i in this.tableList) {
  260. // this.tableList[i].endClassTime = this.tableList[i].endClassTime.substring(0, this.tableList[i].endClassTime.length - 3);
  261. // this.tableList[i].startClassTime = this.tableList[i].startClassTime.substring(0, this.tableList[i].startClassTime.length - 3);
  262. // }
  263. }
  264. })
  265. },
  266. methods: {
  267. addraiseClass () {
  268. this.$refs['maskForm'].validate(res => {
  269. if (res) {
  270. // 验证成功组成数组
  271. let obj = {
  272. 'userId': this.maskForm.teacher, // 老师id
  273. 'dayOfWeek': this.maskForm.week, // 周几
  274. 'startClassTime': this.maskForm.startTime,
  275. 'endClassTime': this.maskForm.endTime,
  276. 'courseTimes': this.topForm.count,
  277. 'type': 'HIGH',
  278. 'expectStudentNum': this.maskForm.count,
  279. 'musicGroupId': this.teamid,
  280. 'teachMode': 'OFFLINE',
  281. 'name': this.maskForm.name,
  282. 'subjectIdList': this.maskForm.sound.join(','),
  283. 'moid': new Date().getTime(),
  284. 'startDate': this.topForm.timer
  285. }
  286. this.tableList.push(obj);
  287. console.log(this.tableList)
  288. this.raiseVisible = false;
  289. this.$refs['maskForm'].resetFields();
  290. this.maskForm.endTime = '';
  291. } else {
  292. this.$message.error('请填写必要信息')
  293. }
  294. })
  295. },
  296. removeClass (row) {
  297. console.log(row.moid)
  298. if (row.moid) {
  299. for (let i in this.tableList) {
  300. if (this.tableList[i].moid == row.moid) {
  301. this.tableList.splice(i, 1);
  302. return
  303. }
  304. }
  305. } else {
  306. for (let i in this.tableList) {
  307. if (this.tableList[i].id == row.id) {
  308. this.tableList.splice(i, 1);
  309. return
  310. }
  311. }
  312. }
  313. },
  314. addClass () {
  315. if (this.isSetSalary) {
  316. this.$message.error('课酬确认后无法编辑')
  317. return;
  318. }
  319. this.raiseVisible = true;
  320. },
  321. gotoNext () {
  322. if (this.isSetSalary) {
  323. this.$message.error('课酬确认后无法编辑')
  324. return;
  325. }
  326. this.$refs['topForm'].validate(res => {
  327. if (res) {
  328. for (let i in this.tableList) {
  329. this.tableList[i].startDate = this.topForm.timer;
  330. this.tableList[i].courseTimes = this.topForm.count;
  331. }
  332. let count = this.tableList.length;
  333. if (count > this.topForm.improventClassesNum) {
  334. this.$message.error(`基础技能班不能超过${this.topForm.improventClassesNum}个`)
  335. return
  336. }
  337. addHighClass(this.tableList).then(res => {
  338. if (res.code == 200) {
  339. this.$message.success('恭喜您创建成功')
  340. this.$emit('gotoNav', 4)
  341. }
  342. })
  343. } else {
  344. this.$message.error('请先输入排课数量和开始时间')
  345. }
  346. })
  347. }
  348. },
  349. filters: {
  350. fitterSound (val) {
  351. let arr = val.split(',');
  352. if (that.soundList) {
  353. let str = ''
  354. for (let i in that.soundList) {
  355. for (let j in arr) {
  356. if (that.soundList[i].id == arr[j]) {
  357. str += that.soundList[i].name + ','
  358. }
  359. }
  360. }
  361. return str.substring(0, str.length - 1);
  362. } else {
  363. return ''
  364. }
  365. },
  366. fitterTeacher (val) {
  367. // console.log(that.teacherList)
  368. if (that.teacherList) {
  369. for (let i in that.teacherList) {
  370. if (that.teacherList[i].id == val) {
  371. return that.teacherList[i].realName
  372. }
  373. }
  374. } else {
  375. return ''
  376. }
  377. }
  378. }
  379. }
  380. </script>
  381. <style lang="scss" scoped>
  382. .imc {
  383. box-sizing: border-box;
  384. padding: 30px 42px;
  385. background-color: #fff;
  386. min-height: 80vh;
  387. .addBtn {
  388. line-height: 40px;
  389. text-align: center;
  390. color: #fff;
  391. border-radius: 4px;
  392. margin-right: 20px;
  393. cursor: pointer;
  394. width: 120px;
  395. height: 40px;
  396. background-color: #4eada7;
  397. }
  398. }
  399. </style>