setClass.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <div class="classWrap">
  3. <div class="left">
  4. <el-table :data='leftList'
  5. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  6. <el-table-column label="乐团声部"
  7. prop="subName"
  8. align='center'>
  9. </el-table-column>
  10. <el-table-column label="实际缴费人数"
  11. prop="paidStudentNum"
  12. align='center'>
  13. </el-table-column>
  14. <el-table-column label="未分班人数"
  15. prop="noClassStudentNum"
  16. align='center'>
  17. </el-table-column>
  18. </el-table>
  19. </div>
  20. <div class="center">
  21. <el-table :data='centerList'
  22. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  23. <el-table-column label="
  24. 班级名称"
  25. prop="name"
  26. align='center'>
  27. </el-table-column>
  28. <el-table-column label="声部"
  29. prop="subjectName"
  30. align='center'>
  31. </el-table-column>
  32. <el-table-column label="班级人数"
  33. prop="studentNum"
  34. align='center'>
  35. </el-table-column>
  36. <el-table-column label="操作"
  37. align='center'>
  38. <template slot-scope="scope">
  39. <div>
  40. <el-button type="text"
  41. @click="removeSingleClass(scope.row)">删除</el-button>
  42. </div>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <div class="centerInfo">
  47. <p>当前班级总数(个):{{ centerList.length }}</p>
  48. <div class="btnWrap">
  49. <div class="setBtn"
  50. @click="setSingleClass">学员分班</div>
  51. <!-- <div class="okBtn">确定</div> -->
  52. </div>
  53. </div>
  54. </div>
  55. <!-- v-if="centertList.length>0 " -->
  56. <div class="right">
  57. <el-table :data='rightList'
  58. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  59. <el-table-column label="
  60. 合奏班"
  61. prop="name"
  62. align='center'>
  63. </el-table-column>
  64. <el-table-column label="班级组成"
  65. prop="classNames"
  66. align='center'>
  67. </el-table-column>
  68. <el-table-column label="操作"
  69. align='center'>
  70. <template slot-scope="scope">
  71. <div>
  72. <el-button type="text"
  73. @click="removeAllClass(scope.row)">删除</el-button>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <div class="centerInfo">
  79. <div class="btnWrap">
  80. <!-- <el-form :inline="true">
  81. <el-form-item label="基础技能班数">
  82. <el-input v-model="hightNum"></el-input>
  83. </el-form-item>
  84. </el-form> -->
  85. <div class="okBtn"
  86. @click="getNoclassSign">添加</div>
  87. <div class="setBtn"
  88. @click="setBossTeacher">下一步</div>
  89. </div>
  90. </div>
  91. </div>
  92. <el-dialog title="班级设置"
  93. :visible.sync="classVisible">
  94. <div class="classMaskWrap">
  95. <div class="maskLeft">
  96. <h3>声部 已选{{ soundSize }}
  97. </h3>
  98. <el-checkbox-group v-model="maskList.subjectCheckList"
  99. class='checkGroup'
  100. @change="chioseSound">
  101. <el-checkbox v-for="(item,index) in leftList"
  102. :key="index"
  103. :label="item.subjectId">{{ item.subName }}</el-checkbox>
  104. </el-checkbox-group>
  105. </div>
  106. <div class="maskRight">
  107. <div class="rightGroup"
  108. v-for="(item,index) in studentsGroup"
  109. :key='index'>
  110. <!-- @change="handleCheckAllChange(item.rows,index)" -->
  111. <h3>{{item.subjectName}}的学员名单 <el-checkbox v-model="maskList.studentsGroup[index]"
  112. @change="handleCheckAllChange(item.rows,index)">全选</el-checkbox>
  113. </h3>
  114. <el-checkbox-group v-model="maskList.checkList[index]"
  115. @change="handleCheckedCitiesChange(index,item.rows)"
  116. class='checkGroup'>
  117. <el-checkbox v-for="(stu,num) in item.rows"
  118. :key='num'
  119. :label="stu.userId">{{ stu.name }}</el-checkbox>
  120. </el-checkbox-group>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="classMaskbottom">
  125. <h3></h3>
  126. <el-form :inline="true"
  127. :model="className"
  128. :rules="classNameRules"
  129. ref='className'>
  130. <el-form-item label="班级名称"
  131. prop='name'>
  132. <el-input v-model="className.name"></el-input>
  133. </el-form-item>
  134. <el-form-item label="已选声部"
  135. prop="sound">
  136. <el-input :disabled="true"
  137. v-model="className.sound"></el-input>
  138. </el-form-item>
  139. <el-form-item label="班级人数">
  140. <el-input :disabled="true"
  141. v-model="activeStudents.length"></el-input>
  142. </el-form-item>
  143. </el-form>
  144. </div>
  145. <div slot="footer"
  146. class="dialog-footer">
  147. <el-button @click="classVisible = false">取 消</el-button>
  148. <el-button type="primary"
  149. @click="addNewClass">确 定</el-button>
  150. </div>
  151. </el-dialog>
  152. <el-dialog title="合奏班设置"
  153. width="600px"
  154. :visible.sync="allVisible">
  155. <el-checkbox-group v-model="allMaskList.signClassList"
  156. class='checkGroup'>
  157. <el-checkbox v-for="(item,index) in NoClassSingle"
  158. :key='index'
  159. :label="item.id">{{ item.name }}</el-checkbox>
  160. </el-checkbox-group>
  161. <el-form :model="allList"
  162. ref="allRules"
  163. style="margin-top:30px;"
  164. :rules="allRules"
  165. :inline="true">
  166. <el-form-item label="请输入合奏班名称"
  167. prop="name">
  168. <el-input type="text"
  169. v-model="allList.name"></el-input>
  170. </el-form-item>
  171. </el-form>
  172. <div slot="footer"
  173. class="dialog-footer">
  174. <el-button @click="allVisible = false">取 消</el-button>
  175. <el-button type="primary"
  176. @click="addAllClass">确 定</el-button>
  177. </div>
  178. </el-dialog>
  179. <el-dialog title="乐队指导"
  180. width="600px"
  181. :visible.sync="teacherVisible">
  182. <el-form :inline="true"
  183. ref='teacherForm'
  184. :model="teacherForm">
  185. <el-form-item label="乐队指导"
  186. prop='name'
  187. :rules="[{required: true, message: '请选择乐队指导', trigger: 'blur'}]">
  188. <el-select v-model="teacherForm.name"
  189. filterable
  190. clearable>
  191. <el-option v-for="(item,index) in teacherList"
  192. :key="index"
  193. :value="item.id"
  194. :label="item.realName"></el-option>
  195. </el-select>
  196. </el-form-item>
  197. </el-form>
  198. <div slot="footer"
  199. class="dialog-footer">
  200. <el-button @click="teacherVisible = false">取 消</el-button>
  201. <el-button type="primary"
  202. @click="gotoNext">确 定</el-button>
  203. </div>
  204. </el-dialog>
  205. </div>
  206. </template>
  207. <script>
  208. import { queryEmployByOrganId } from '@/api/systemManage'
  209. import { getTeamRecruit, getSingleClass, getNoClassStudent, addSingleClass, removeSingleClass, addAllClass, getAllClass, findNoClassSingle, removeAllClass, getTeacher, checkAllStudent, getTeamBaseInfo } from "@/api/buildTeam"
  210. export default {
  211. props: {
  212. teamid: {
  213. type: String,
  214. required: true
  215. },
  216. isSetSalary: {
  217. type: Boolean,
  218. required: true
  219. }
  220. },
  221. data () {
  222. return {
  223. classVisible: false, // 班级设置弹窗
  224. allVisible: false, // 合奏班弹窗设置
  225. teacherVisible: false,
  226. leftList: [],
  227. centerList: [],
  228. rightList: [],
  229. maskList: {
  230. subjectCheckList: [],
  231. checkList: [],
  232. checkAll: false,
  233. isIndeterminate: [],
  234. studentsGroup: []
  235. },
  236. allMaskList: {
  237. signClassList: []
  238. },
  239. soundSize: 0,
  240. activeStudents: [], // 选中的所有学生
  241. studentsGroup: {}, // 存储所有声部 所有学生的集合表
  242. className: {
  243. name: '',
  244. sound: ''
  245. },
  246. classNameRules: {
  247. name: [
  248. { required: true, message: '请输入班级名称', trigger: 'blur' },
  249. { min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur' }
  250. ]
  251. },
  252. allList: { //合奏班名字确认
  253. name: ''
  254. },
  255. allRules: {
  256. name: [
  257. { required: true, message: '请输入班级名称', trigger: 'blur' },
  258. { min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur' }
  259. ]
  260. },
  261. NoClassSingle: [],
  262. teacherList: [],
  263. teacherForm: {
  264. name: ''
  265. },
  266. hightNum: ''
  267. }
  268. },
  269. watch: {
  270. classVisible (val) {
  271. if (!val) {
  272. this.classVisible = false;
  273. this.maskList.subjectCheckList = [];
  274. this.studentsGroup = [];
  275. this.activeStudents = [];
  276. this.$refs['className'].resetFields();
  277. this.getSingleClass();
  278. }
  279. }
  280. },
  281. mounted () {
  282. sessionStorage.setItem('setStep', 0)
  283. getTeamRecruit({ musicGroupId: this.teamid }).then(res => {
  284. // 获取乐团声部集合
  285. if (res.code == 200) {
  286. this.leftList = res.data;
  287. }
  288. })
  289. this.getSingleClass();
  290. this.getAllClass();
  291. // 获取所有老师的列表
  292. queryEmployByOrganId({ organId: this.$store.getters.organ, rows: 1000 }).then(res => {
  293. if (res.code == 200) {
  294. this.teacherList = res.data.rows;
  295. // console.log(this.teacherList)
  296. }
  297. })
  298. getTeamBaseInfo({ musicGroupId: this.teamid }).then(res => {
  299. if (res.code == 200) {
  300. res.data.musicGroup.directorUserId ? this.teacherForm.name = '' : this.teacherForm.name = res.data.musicGroup.directorUserId
  301. }
  302. })
  303. }, methods: {
  304. getAllClass () {
  305. getAllClass({ musicGroupId: this.teamid }).then(res => {
  306. if (res.code == 200) {
  307. this.rightList = res.data;
  308. }
  309. })
  310. },
  311. getSingleClass () {
  312. getSingleClass({ musicGroupId: this.teamid }).then(res => {
  313. if (res.code == 200) {
  314. // 单技班列表
  315. this.centerList = res.data;
  316. }
  317. })
  318. },
  319. handleCheckAllChange (val, index) {
  320. // 全选
  321. // 1.val:选项框里的所有选项
  322. // 2.哪一个
  323. // console.log(this.maskList.studentsGroup[index])
  324. if (this.maskList.studentsGroup[index]) {
  325. this.maskList.checkList[index] = []
  326. for (let i in val) {
  327. // 存储的数组
  328. this.maskList.checkList[index].push(val[i].userId);
  329. // console.log(this.activeStudents)
  330. this.activeStudents.push(val[i].userId)
  331. // 并且把所有的学生 添加到勾选的学生列表
  332. // console.log(this.maskList.checkList[index])
  333. }
  334. } else {
  335. for (let i in this.activeStudents) {
  336. for (let j in this.maskList.checkList[index]) {
  337. if (this.maskList.checkList[index][j] == this.activeStudents[i]) {
  338. this.activeStudents.splice(i, 1);
  339. }
  340. }
  341. }
  342. this.maskList.checkList[index] = []
  343. }
  344. },
  345. handleCheckedCitiesChange (index, list) {
  346. // 单选学生触发事件
  347. // 此处需要同步全选按钮状态
  348. // maskList.studentsGroup[index]
  349. if (list.length == this.maskList.checkList[index].length) {
  350. //全选选中
  351. this.maskList.studentsGroup[index] = true;
  352. } else {
  353. this.maskList.studentsGroup[index] = false;
  354. }
  355. let arr = [];
  356. for (let i in this.maskList.checkList) {
  357. for (let j in this.maskList.checkList[i]) {
  358. arr.push(this.maskList.checkList[i][j])
  359. }
  360. }
  361. this.activeStudents = arr;
  362. },
  363. // 设置单技课
  364. setSingleClass () {
  365. if (this.isSetSalary) {
  366. this.$message.error('课酬确认后无法编辑')
  367. return;
  368. }
  369. this.classVisible = true;
  370. },
  371. chioseSound (val) {
  372. // 清空选中学生
  373. this.activeStudents = [];
  374. // 清空全选
  375. // this.maskList.studentsGroup
  376. for (let i in this.maskList.studentsGroup) {
  377. this.maskList.studentsGroup[i] = false;
  378. }
  379. for (let j in this.maskList.checkList) {
  380. this.maskList.checkList[j] = []
  381. }
  382. this.soundSize = val.length;
  383. getNoClassStudent({
  384. musicGroupId: this.teamid,
  385. actualSubjectId: val.join(',')
  386. }).then(res => {
  387. if (res.code == 200) {
  388. this.studentsGroup = res.data
  389. let str = ''
  390. // 生成动态的checkList
  391. for (let key in this.studentsGroup) {
  392. this.$set(this.maskList.checkList, key, []);
  393. str += this.studentsGroup[key].subjectName + '+';
  394. }
  395. str = str.substring(0, str.length - 1);
  396. this.className.sound = str;
  397. }
  398. })
  399. },
  400. // 添加单技班
  401. addNewClass () {
  402. this.$refs['className'].validate(valid => {
  403. if (valid) {
  404. addSingleClass({
  405. musicGroupId: this.teamid,
  406. name: this.className.name,
  407. subjectIdList: this.maskList.subjectCheckList.join(','),
  408. teachMode: 'OFFLINE',
  409. userIds: this.activeStudents.join(','),
  410. studentNum: this.activeStudents.length,
  411. type: 'NORMAL'
  412. }).then(res => {
  413. if (res.code == 200) {
  414. // 成功刷新班级列表 清空数据
  415. this.$message.success('添加成功');
  416. this.classVisible = false;
  417. this.maskList.subjectCheckList = [];
  418. this.studentsGroup = [];
  419. this.activeStudents = [];
  420. this.$refs['className'].resetFields();
  421. this.getSingleClass();
  422. getTeamRecruit({ musicGroupId: this.teamid }).then(res => {
  423. // 获取乐团声部集合
  424. if (res.code == 200) {
  425. this.leftList = res.data;
  426. }
  427. })
  428. }
  429. })
  430. } else {
  431. this.$message.error('请输入班级名称')
  432. }
  433. })
  434. return;
  435. },
  436. removeSingleClass (row) {
  437. if (this.isSetSalary) {
  438. this.$message.error('课酬确认后无法编辑')
  439. return;
  440. }
  441. removeSingleClass({ classGroupId: row.id }).then(res => {
  442. if (res.code == 200) {
  443. this.$message.success('删除成功');
  444. this.getSingleClass();
  445. getTeamRecruit({ musicGroupId: this.teamid }).then(res => {
  446. // 获取乐团声部集合
  447. if (res.code == 200) {
  448. this.leftList = res.data;
  449. }
  450. })
  451. }
  452. })
  453. },
  454. getNoclassSign () {
  455. if (this.isSetSalary) {
  456. this.$message.error('课酬确认后无法编辑')
  457. return;
  458. }
  459. this.allMaskList.signClassList = [];
  460. findNoClassSingle({ musicGroupId: this.teamid }).then(res => {
  461. if (res.code == 200) {
  462. this.NoClassSingle = res.data;
  463. this.allVisible = true;
  464. }
  465. })
  466. },
  467. // 添加合奏班
  468. addAllClass () {
  469. if (!this.allMaskList.signClassList.join(',')) {
  470. this.$message.error('请至少选择一个单技班')
  471. return;
  472. }
  473. addAllClass({
  474. musicGroupId: this.teamid,
  475. name: this.allList.name,
  476. classGroupIds: this.allMaskList.signClassList.join(',') || null
  477. }).then(res => {
  478. if (res.code == 200) {
  479. this.$message.success('恭喜您创建成功');
  480. this.allVisible = false;
  481. this.getAllClass();
  482. this.$refs['allRules'].resetFields();
  483. }
  484. })
  485. },
  486. // 删除合奏班
  487. removeAllClass (row) {
  488. if (this.isSetSalary) {
  489. this.$message.error('课酬确认后无法编辑')
  490. return;
  491. }
  492. removeAllClass({ classGroupId: row.id }).then(res => {
  493. if (res.code == 200) {
  494. this.$message.success('删除成功')
  495. this.getAllClass();
  496. }
  497. });
  498. },
  499. setBossTeacher () {
  500. if (this.isSetSalary) {
  501. this.$message.error('课酬确认后无法编辑')
  502. return;
  503. }
  504. this.teacherVisible = true;
  505. },
  506. gotoNext () {
  507. // 跳转到下一步
  508. // if (!this.hightNum) {
  509. // this.$message.error('基础技能班数必填');
  510. // return
  511. // }
  512. this.$refs['teacherForm'].validate(res => {
  513. if (res) {
  514. // 发请求
  515. checkAllStudent({ musicGroupId: this.teamid, teacherId: this.teacherForm.name, improventClassesNum: this.hightNum }).then(res => {
  516. if (res.code == 200) {
  517. this.$refs['teacherForm'].resetFields()
  518. this.teacherVisible = false;
  519. this.$emit('gotoNav', 1);
  520. }
  521. }).catch(res => {
  522. this.teacherVisible = false;
  523. this.teacherForm.name = '';
  524. })
  525. }
  526. });
  527. },
  528. },
  529. }
  530. </script>
  531. <style lang="scss" scoped>
  532. .classWrap {
  533. display: flex;
  534. flex-direction: row;
  535. justify-content: flex-start;
  536. .left {
  537. width: 275px;
  538. background-color: #fff;
  539. height: 80vh;
  540. overflow: auto;
  541. }
  542. .center {
  543. // background-color: #fff;
  544. width: 400px;
  545. margin-left: 12px;
  546. .centerInfo {
  547. background-color: #fff;
  548. color: #444;
  549. padding: 15px;
  550. .btnWrap {
  551. margin-top: 38px;
  552. display: flex;
  553. flex-direction: row;
  554. justify-content: space-around;
  555. .setBtn {
  556. width: 120px;
  557. height: 40px;
  558. background: rgba(68, 68, 68, 1);
  559. border-radius: 4px;
  560. color: #fff;
  561. line-height: 40px;
  562. text-align: center;
  563. cursor: pointer;
  564. }
  565. .okBtn {
  566. width: 120px;
  567. height: 40px;
  568. background: rgba(249, 114, 21, 1);
  569. border-radius: 4px;
  570. color: #fff;
  571. line-height: 40px;
  572. text-align: center;
  573. cursor: pointer;
  574. }
  575. }
  576. }
  577. }
  578. .right {
  579. flex-grow: 1;
  580. margin-left: 12px;
  581. .centerInfo {
  582. background-color: #fff;
  583. color: #444;
  584. padding: 15px;
  585. .btnWrap {
  586. margin-top: 38px;
  587. display: flex;
  588. flex-direction: row;
  589. justify-content: flex-end;
  590. .setBtn {
  591. width: 120px;
  592. height: 40px;
  593. background: rgba(68, 68, 68, 1);
  594. border-radius: 4px;
  595. color: #fff;
  596. line-height: 40px;
  597. text-align: center;
  598. cursor: pointer;
  599. }
  600. .okBtn {
  601. width: 120px;
  602. height: 40px;
  603. background: rgba(249, 114, 21, 1);
  604. border-radius: 4px;
  605. color: #fff;
  606. line-height: 40px;
  607. text-align: center;
  608. cursor: pointer;
  609. }
  610. }
  611. }
  612. }
  613. .classMaskWrap {
  614. display: flex;
  615. flex-direction: row;
  616. justify-content: flex-start;
  617. max-height: 350px;
  618. overflow: auto;
  619. .maskLeft {
  620. width: 200px;
  621. h3 {
  622. height: 40px;
  623. line-height: 40px;
  624. background-color: #edeef0;
  625. font-size: 16px;
  626. font-weight: normal;
  627. color: #444;
  628. padding-left: 25px;
  629. }
  630. .checkGroup {
  631. .el-checkbox {
  632. padding-left: 25px;
  633. height: 30px;
  634. line-height: 30px;
  635. width: 100%;
  636. }
  637. }
  638. }
  639. .maskRight {
  640. margin-left: 30px;
  641. flex: 1;
  642. .rightGroup {
  643. h3 {
  644. height: 40px;
  645. line-height: 40px;
  646. background-color: #edeef0;
  647. font-size: 16px;
  648. font-weight: normal;
  649. color: #444;
  650. padding-left: 25px;
  651. display: flex;
  652. flex-direction: row;
  653. justify-content: space-between;
  654. padding-right: 15px;
  655. }
  656. .checkGroup {
  657. padding-left: 25px;
  658. .el-checkbox {
  659. height: 30px;
  660. line-height: 30px;
  661. width: 75px;
  662. }
  663. }
  664. }
  665. }
  666. }
  667. .classMaskbottom {
  668. h3 {
  669. height: 40px;
  670. line-height: 40px;
  671. background-color: #edeef0;
  672. margin-bottom: 30px;
  673. }
  674. }
  675. }
  676. </style>