setClass.vue 19 KB

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