setClass.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. },
  217. data () {
  218. return {
  219. classVisible: false, // 班级设置弹窗
  220. allVisible: false, // 合奏班弹窗设置
  221. teacherVisible: false,
  222. leftList: [],
  223. centerList: [],
  224. rightList: [],
  225. maskList: {
  226. subjectCheckList: [],
  227. checkList: [],
  228. checkAll: false,
  229. isIndeterminate: [],
  230. studentsGroup: []
  231. },
  232. allMaskList: {
  233. signClassList: []
  234. },
  235. soundSize: 0,
  236. activeStudents: [], // 选中的所有学生
  237. studentsGroup: {}, // 存储所有声部 所有学生的集合表
  238. className: {
  239. name: '',
  240. sound: ''
  241. },
  242. classNameRules: {
  243. name: [
  244. { required: true, message: '请输入班级名称', trigger: 'blur' },
  245. { min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur' }
  246. ]
  247. },
  248. allList: { //合奏班名字确认
  249. name: ''
  250. },
  251. allRules: {
  252. name: [
  253. { required: true, message: '请输入班级名称', trigger: 'blur' },
  254. { min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur' }
  255. ]
  256. },
  257. NoClassSingle: [],
  258. teacherList: [],
  259. teacherForm: {
  260. name: ''
  261. },
  262. hightNum: ''
  263. }
  264. },
  265. mounted () {
  266. sessionStorage.setItem('setStep', 0)
  267. getTeamRecruit({ musicGroupId: this.teamid }).then(res => {
  268. // 获取乐团声部集合
  269. if (res.code == 200) {
  270. this.leftList = res.data;
  271. }
  272. })
  273. this.getSingleClass();
  274. this.getAllClass();
  275. // 获取所有老师的列表
  276. queryEmployByOrganId({ organId: this.$store.getters.organ, rows: 1000 }).then(res => {
  277. if (res.code == 200) {
  278. this.teacherList = res.data.rows;
  279. // console.log(this.teacherList)
  280. }
  281. })
  282. getTeamBaseInfo({ musicGroupId: this.teamid }).then(res => {
  283. if (res.code == 200) {
  284. this.teacherForm.name = res.data.musicGroup.directorUserId
  285. }
  286. })
  287. }, methods: {
  288. getAllClass () {
  289. getAllClass({ musicGroupId: this.teamid }).then(res => {
  290. if (res.code == 200) {
  291. this.rightList = res.data;
  292. }
  293. })
  294. },
  295. getSingleClass () {
  296. getSingleClass({ musicGroupId: this.teamid }).then(res => {
  297. if (res.code == 200) {
  298. // 单技班列表
  299. this.centerList = res.data;
  300. }
  301. })
  302. },
  303. handleCheckAllChange (val, index) {
  304. // 全选
  305. // 1.val:选项框里的所有选项
  306. // 2.哪一个
  307. // console.log(this.maskList.studentsGroup[index])
  308. if (this.maskList.studentsGroup[index]) {
  309. this.maskList.checkList[index] = []
  310. for (let i in val) {
  311. // 存储的数组
  312. this.maskList.checkList[index].push(val[i].userId);
  313. // console.log(this.activeStudents)
  314. this.activeStudents.push(val[i].userId)
  315. // 并且把所有的学生 添加到勾选的学生列表
  316. // console.log(this.maskList.checkList[index])
  317. }
  318. } else {
  319. for (let i in this.activeStudents) {
  320. for (let j in this.maskList.checkList[index]) {
  321. if (this.maskList.checkList[index][j] == this.activeStudents[i]) {
  322. this.activeStudents.splice(i, 1);
  323. }
  324. }
  325. }
  326. this.maskList.checkList[index] = []
  327. }
  328. },
  329. handleCheckedCitiesChange (index, list) {
  330. // 单选学生触发事件
  331. // 此处需要同步全选按钮状态
  332. // maskList.studentsGroup[index]
  333. if (list.length == this.maskList.checkList[index].length) {
  334. //全选选中
  335. this.maskList.studentsGroup[index] = true;
  336. } else {
  337. this.maskList.studentsGroup[index] = false;
  338. }
  339. let arr = [];
  340. for (let i in this.maskList.checkList) {
  341. for (let j in this.maskList.checkList[i]) {
  342. arr.push(this.maskList.checkList[i][j])
  343. }
  344. }
  345. this.activeStudents = arr;
  346. },
  347. setSingleClass () {
  348. this.classVisible = true;
  349. },
  350. chioseSound (val) {
  351. // 清空选中学生
  352. this.activeStudents = [];
  353. // 清空全选
  354. // this.maskList.studentsGroup
  355. for (let i in this.maskList.studentsGroup) {
  356. this.maskList.studentsGroup[i] = false;
  357. }
  358. for (let j in this.maskList.checkList) {
  359. this.maskList.checkList[j] = []
  360. }
  361. this.soundSize = val.length;
  362. getNoClassStudent({
  363. musicGroupId: this.teamid,
  364. actualSubjectId: val.join(',')
  365. }).then(res => {
  366. if (res.code == 200) {
  367. this.studentsGroup = res.data
  368. let str = ''
  369. // 生成动态的checkList
  370. for (let key in this.studentsGroup) {
  371. this.$set(this.maskList.checkList, key, []);
  372. str += this.studentsGroup[key].subjectName + '+';
  373. }
  374. str = str.substring(0, str.length - 1);
  375. this.className.sound = str;
  376. }
  377. })
  378. },
  379. // 添加单技班
  380. addNewClass () {
  381. this.$refs['className'].validate(valid => {
  382. if (valid) {
  383. addSingleClass({
  384. musicGroupId: this.teamid,
  385. name: this.className.name,
  386. subjectIdList: this.maskList.subjectCheckList.join(','),
  387. teachMode: 'OFFLINE',
  388. userIds: this.activeStudents.join(','),
  389. studentNum: this.activeStudents.length,
  390. type: 'NORMAL'
  391. }).then(res => {
  392. if (res.code == 200) {
  393. // 成功刷新班级列表 清空数据
  394. this.$message.success('添加成功');
  395. this.classVisible = false;
  396. this.maskList.subjectCheckList = [];
  397. this.studentsGroup = [];
  398. this.activeStudents = [];
  399. this.$refs['className'].resetFields();
  400. this.getSingleClass();
  401. getTeamRecruit({ musicGroupId: this.teamid }).then(res => {
  402. // 获取乐团声部集合
  403. if (res.code == 200) {
  404. this.leftList = res.data;
  405. }
  406. })
  407. }
  408. })
  409. } else {
  410. this.$message.error('请输入班级名称')
  411. }
  412. })
  413. return;
  414. },
  415. removeSingleClass (row) {
  416. removeSingleClass({ classGroupId: row.id }).then(res => {
  417. if (res.code == 200) {
  418. this.$message.success('删除成功');
  419. this.getSingleClass();
  420. getTeamRecruit({ musicGroupId: this.teamid }).then(res => {
  421. // 获取乐团声部集合
  422. if (res.code == 200) {
  423. this.leftList = res.data;
  424. }
  425. })
  426. }
  427. })
  428. },
  429. getNoclassSign () {
  430. this.allMaskList.signClassList = [];
  431. findNoClassSingle({ musicGroupId: this.teamid }).then(res => {
  432. if (res.code == 200) {
  433. this.NoClassSingle = res.data;
  434. this.allVisible = true;
  435. }
  436. })
  437. },
  438. // 添加合奏班
  439. addAllClass () {
  440. //
  441. if (!this.allMaskList.signClassList.join(',')) {
  442. this.$message.error('请至少选择一个单技班')
  443. return;
  444. }
  445. addAllClass({
  446. musicGroupId: this.teamid,
  447. name: this.allList.name,
  448. classGroupIds: this.allMaskList.signClassList.join(',') || null
  449. }).then(res => {
  450. if (res.code == 200) {
  451. this.$message.success('恭喜您创建成功');
  452. this.allVisible = false;
  453. this.getAllClass();
  454. this.$refs['allRules'].resetFields();
  455. }
  456. })
  457. },
  458. // 删除合奏班
  459. removeAllClass (row) {
  460. removeAllClass({ classGroupId: row.id }).then(res => {
  461. if (res.code == 200) {
  462. this.$message.success('删除成功')
  463. this.getAllClass();
  464. }
  465. });
  466. },
  467. setBossTeacher () {
  468. this.teacherVisible = true;
  469. },
  470. gotoNext () {
  471. // 跳转到下一步
  472. // if (!this.hightNum) {
  473. // this.$message.error('基础技能班数必填');
  474. // return
  475. // }
  476. this.$refs['teacherForm'].validate(res => {
  477. if (res) {
  478. // 发请求
  479. checkAllStudent({ musicGroupId: this.teamid, teacherId: this.teacherForm.name, improventClassesNum: this.hightNum }).then(res => {
  480. if (res.code == 200) {
  481. this.$refs['teacherForm'].resetFields()
  482. this.teacherVisible = false;
  483. this.$emit('gotoNav', 1);
  484. }
  485. }).catch(res => {
  486. this.teacherVisible = false;
  487. this.teacherForm.name = '';
  488. })
  489. }
  490. });
  491. },
  492. }
  493. }
  494. </script>
  495. <style lang="scss" scoped>
  496. .classWrap {
  497. display: flex;
  498. flex-direction: row;
  499. justify-content: flex-start;
  500. .left {
  501. width: 275px;
  502. background-color: #fff;
  503. height: 80vh;
  504. overflow: auto;
  505. }
  506. .center {
  507. // background-color: #fff;
  508. width: 400px;
  509. margin-left: 12px;
  510. .centerInfo {
  511. background-color: #fff;
  512. color: #444;
  513. padding: 15px;
  514. .btnWrap {
  515. margin-top: 38px;
  516. display: flex;
  517. flex-direction: row;
  518. justify-content: space-around;
  519. .setBtn {
  520. width: 120px;
  521. height: 40px;
  522. background: rgba(68, 68, 68, 1);
  523. border-radius: 4px;
  524. color: #fff;
  525. line-height: 40px;
  526. text-align: center;
  527. cursor: pointer;
  528. }
  529. .okBtn {
  530. width: 120px;
  531. height: 40px;
  532. background: rgba(249, 114, 21, 1);
  533. border-radius: 4px;
  534. color: #fff;
  535. line-height: 40px;
  536. text-align: center;
  537. cursor: pointer;
  538. }
  539. }
  540. }
  541. }
  542. .right {
  543. flex-grow: 1;
  544. margin-left: 12px;
  545. .centerInfo {
  546. background-color: #fff;
  547. color: #444;
  548. padding: 15px;
  549. .btnWrap {
  550. margin-top: 38px;
  551. display: flex;
  552. flex-direction: row;
  553. justify-content: flex-end;
  554. .setBtn {
  555. width: 120px;
  556. height: 40px;
  557. background: rgba(68, 68, 68, 1);
  558. border-radius: 4px;
  559. color: #fff;
  560. line-height: 40px;
  561. text-align: center;
  562. cursor: pointer;
  563. }
  564. .okBtn {
  565. width: 120px;
  566. height: 40px;
  567. background: rgba(249, 114, 21, 1);
  568. border-radius: 4px;
  569. color: #fff;
  570. line-height: 40px;
  571. text-align: center;
  572. cursor: pointer;
  573. }
  574. }
  575. }
  576. }
  577. .classMaskWrap {
  578. display: flex;
  579. flex-direction: row;
  580. justify-content: flex-start;
  581. max-height: 350px;
  582. overflow: auto;
  583. .maskLeft {
  584. width: 200px;
  585. h3 {
  586. height: 40px;
  587. line-height: 40px;
  588. background-color: #edeef0;
  589. font-size: 16px;
  590. font-weight: normal;
  591. color: #444;
  592. padding-left: 25px;
  593. }
  594. .checkGroup {
  595. .el-checkbox {
  596. padding-left: 25px;
  597. height: 30px;
  598. line-height: 30px;
  599. width: 100%;
  600. }
  601. }
  602. }
  603. .maskRight {
  604. margin-left: 30px;
  605. flex: 1;
  606. .rightGroup {
  607. h3 {
  608. height: 40px;
  609. line-height: 40px;
  610. background-color: #edeef0;
  611. font-size: 16px;
  612. font-weight: normal;
  613. color: #444;
  614. padding-left: 25px;
  615. display: flex;
  616. flex-direction: row;
  617. justify-content: space-between;
  618. padding-right: 15px;
  619. }
  620. .checkGroup {
  621. padding-left: 25px;
  622. .el-checkbox {
  623. height: 30px;
  624. line-height: 30px;
  625. width: 75px;
  626. }
  627. }
  628. }
  629. }
  630. }
  631. .classMaskbottom {
  632. h3 {
  633. height: 40px;
  634. line-height: 40px;
  635. background-color: #edeef0;
  636. margin-bottom: 30px;
  637. }
  638. }
  639. }
  640. </style>