improvementClass.vue 14 KB

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