teamResetSound.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <div>
  3. <div class="listWrap">
  4. <el-table :data='activeSoundList'
  5. ref="multipleTable"
  6. @selection-change="handleSelectionChange"
  7. :header-cell-style="{background:'#EDEEF0',color:'#444'}"
  8. highlight-current-row>
  9. <el-table-column type="selection"
  10. width="55">
  11. </el-table-column>
  12. <el-table-column label="声部"
  13. width="150"
  14. prop="sound">
  15. </el-table-column>
  16. <el-table-column label="预计收费"
  17. width="150"
  18. prop="yuji">
  19. <template slot-scope="scope">
  20. <div>
  21. <el-input type="number"
  22. v-model="scope.row.yuji"></el-input>
  23. </div>
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="声部学员">
  27. <template slot-scope="scope">
  28. <div>
  29. <el-button type="text"
  30. @click="resetStudent(scope.row)">添加</el-button>
  31. <!-- <el-button type="text">删除</el-button> -->
  32. </div>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <div class="floor">
  37. <div class="remove"
  38. @click="removeListItem">删除</div>
  39. <div class='add'
  40. @click="addListItem">添加</div>
  41. </div>
  42. </div>
  43. <el-dialog title="声部选择"
  44. :visible.sync="dialogTableVisible"
  45. :modal-append-to-body="false">
  46. <div class="soundWrap">
  47. <div class="itemList">
  48. <div class="categroy"
  49. v-for="(item,index) in soundList"
  50. :key="index">
  51. <p>{{item.name }}</p>
  52. <el-checkbox-group v-model="soundLists[index]"
  53. @change='changeList'>
  54. <!-- sound: this.activeSoundList[item].name, // id
  55. jihua: '10', //计划招生人数
  56. yuji: '10', // 预计收费
  57. zhonglei: [], // 可选乐器种类
  58. fangshi: 2, // 乐器提供方式
  59. jiaopu: 'jiaopu1', // 教辅组合
  60. type: 1, // 操作
  61. id: this.activeSoundList[item].id, //声部id
  62. visible: false, // 当前乐器提供方式的pop提示框显示隐藏 -->
  63. <el-checkbox :label="sound.id"
  64. @change="checkinlist({'id':sound.id,'sound':sound.name,'yuji':0,studentList:[]})"
  65. v-for="(sound,indexs) in item.subjects"
  66. :key="indexs">{{sound.name }}</el-checkbox>
  67. </el-checkbox-group>
  68. </div>
  69. </div>
  70. </div>
  71. <p class='soundSubP'>当前选择声部数:{{chioseSoundNum}}</p>
  72. <div class="btnWraps">
  73. <div class="dialogBtn"
  74. @click="generates">确定</div>
  75. </div>
  76. </el-dialog>
  77. <el-dialog title="学员选择"
  78. width="800px"
  79. :visible.sync="studentVisible"
  80. :modal-append-to-body="false">
  81. <div class="studentMask">
  82. <div class="left">
  83. <h4>当前已选学员</h4>
  84. <div class="chioseStudentList">
  85. <div class="studentItem"
  86. v-for="(item,index) in activeListStudent"
  87. :key="index">
  88. {{ item.name }}
  89. <el-button type="text"
  90. @click="removeStudent(item)">删除</el-button>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="right">
  95. <el-select v-model="activeTeam"
  96. filterable
  97. style="width:180px"
  98. clearable
  99. @change="chioseTeam"
  100. placeholder="乐团选择">
  101. <el-option v-for='(item,index) in teamList'
  102. :key="index"
  103. :label="item.name"
  104. :value="item.id"></el-option>
  105. </el-select>
  106. <!-- multiple
  107. collapse-tags -->
  108. <el-select v-model="activeChioseSound"
  109. style="width:180px"
  110. :disabled="!activeTeam"
  111. filterable
  112. clearable
  113. placeholder="声部选择">
  114. <el-option v-for='(item,index) in chioseSoundList'
  115. :key='index'
  116. :label="item.name"
  117. :value="item.id"></el-option>
  118. </el-select>
  119. <el-button type="danger"
  120. style="margin-left:20px;"
  121. @click="searchStudent">搜索</el-button>
  122. <!-- 列表开始 -->
  123. <div class="tableList">
  124. <el-table tooltip-effect="dark"
  125. style="width: 100%; margin-top:10px;"
  126. :data='studentList'
  127. ref='studentList'
  128. @selection-change="SelectionStudent">
  129. <el-table-column type="selection"
  130. align='center'
  131. width="55">
  132. </el-table-column>
  133. <el-table-column prop="name"
  134. align='center'
  135. width="80"
  136. label="姓名">
  137. </el-table-column>
  138. <el-table-column prop="gender"
  139. align='center'
  140. width="55"
  141. label="性别">
  142. </el-table-column>
  143. <el-table-column prop="musicGroupName"
  144. align='center'
  145. label="所在乐团">
  146. </el-table-column>
  147. <el-table-column prop="soundName"
  148. align='center'
  149. label="学员声部">
  150. </el-table-column>
  151. </el-table>
  152. </div>
  153. </div>
  154. </div>
  155. <div slot="footer"
  156. class="dialog-footer">
  157. <el-button @click="studentVisible = false">取 消</el-button>
  158. <el-button type="primary"
  159. @click="studentVisible = false">确 定</el-button>
  160. </div>
  161. </el-dialog>
  162. <!-- @click="goback1" @click="submitInfo1" -->
  163. <div class="btnWrap">
  164. <div class="PrevBtn"
  165. @click="goback">上一步</div>
  166. <div class="submitBtn"
  167. @click="submitInfo">提交</div>
  168. </div>
  169. </div>
  170. </template>
  171. <script>
  172. import store from '@/store'
  173. import { getSubject, getDefaultSubject, getGoods, createTeam, getSoundTree, findSound, teamSoundStudent } from '@/api/buildTeam'
  174. export default {
  175. props: ['getTeamList'],
  176. data () {
  177. return {
  178. dialogTableVisible: false,
  179. studentVisible: false,
  180. checkList: [],
  181. isLoop: '',
  182. activeSoundList: [],
  183. soundList: [],
  184. soundLists: [],
  185. changeList: [],
  186. multipleSelection: [], // 列表选择的集合 声部
  187. teamList: [], // 选择的乐团集合
  188. activeTeam: '', // 选中的乐团
  189. chioseSoundList: [],//根据选中的乐团id获取的声部集合
  190. activeChioseSound: '', // 选中声部的集合
  191. studentList: [], // 选择列表中的学生 展示中的列表
  192. activeListStudent: [], // 列表中选中的学生,
  193. allActiveStudent: [], // 所有选中的学生 全局
  194. activeSoundId: '', //
  195. }
  196. },
  197. // created () {
  198. // },
  199. mounted () {
  200. this.teamList = this.getTeamList;
  201. this.payfor = this.$store.getters.payList;
  202. getSoundTree().then(res => {
  203. if (res.code == 200) {
  204. this.soundList = res.data.rows;
  205. // // 生成动态的checkList
  206. for (let key in this.soundList) {
  207. this.$set(this.soundLists, key, [])
  208. }
  209. }
  210. })
  211. this.payfor = this.$store.getters.payList;
  212. this.topfor = this.$store.getters.topinfo;
  213. this.checkfor = this.$store.getters.checkinfo;
  214. let type = this.topfor.type;
  215. },
  216. methods: {
  217. // 删除声部
  218. removeListItem () {
  219. this.$confirm(`是否删除该声部?`, '提示', {
  220. confirmButtonText: '确定',
  221. cancelButtonText: '取消',
  222. type: 'warning'
  223. }).then(() => {
  224. // 先获取选择的声部 从全局把 this.allActiveStudent
  225. for (let i = 0; i < this.activeSoundList.length; i++) {
  226. for (let j = 0; j < this.multipleSelection.length; j++) {
  227. if (this.activeSoundList[i].id == this.multipleSelection[j].id) {
  228. // 在这里把(this.activeSoundList[i]的学生释放出来
  229. // console.log(this.activeSoundList[i].studentList)
  230. for (let x in this.allActiveStudent) {
  231. for (let y in this.activeSoundList[i].studentList) {
  232. if (this.allActiveStudent[x].userId == this.activeSoundList[i].studentList[y].userId) {
  233. this.allActiveStudent.splice(x, 1);
  234. }
  235. }
  236. }
  237. console.log('删除');
  238. this.activeSoundList.splice(i, 1);
  239. // 遍历循环所有的group 删除所选id
  240. for (let key in this.soundLists) {
  241. if (this.soundLists[key].indexOf(this.multipleSelection[j].id) != -1) {
  242. // console.log(this.soundLists[key], this.multipleSelection[j].id, this.soundLists[key].indexOf(this.multipleSelection[j].id));
  243. this.soundLists[key].splice(this.soundLists[key].indexOf(this.multipleSelection[j].id), 1)
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }).catch(() => { })
  250. },
  251. addListItem () {
  252. this.dialogTableVisible = true;
  253. },
  254. // 点击确认按钮生成表单
  255. generates () {
  256. this.dialogTableVisible = false;
  257. },
  258. checkinlist (obj) {
  259. let flag = false;
  260. this.activeSoundList.map(item => {
  261. if (item.id == obj.id) {
  262. flag = true
  263. }
  264. })
  265. if (!flag) {
  266. this.activeSoundList.push(obj)
  267. } else {
  268. for (let i = 0; i < this.activeSoundList.length; i++) {
  269. if (this.activeSoundList[i].id == obj.id) {
  270. this.activeSoundList.splice(i, 1);
  271. }
  272. }
  273. }
  274. },
  275. handleSelectionChange (e) {
  276. console.log(e);
  277. // 点击改变勾选
  278. this.multipleSelection = e;
  279. },
  280. // 点击添加学生
  281. resetStudent (row) {
  282. // 乐团id 声部id
  283. this.studentVisible = true;
  284. this.activeSoundId = row.id;
  285. for (let i in this.activeSoundList) {
  286. if (this.activeSoundList[i].id == row.id) {
  287. this.activeListStudent = this.activeSoundList[i].studentList;
  288. }
  289. }
  290. },
  291. chioseTeam () {
  292. // console.log(this.activeTeam)
  293. // 发请求 获取乐团下的所有声部
  294. findSound({ musicGroupId: this.activeTeam }).then(res => {
  295. if (res.code == 200) {
  296. this.chioseSoundList = res.data;
  297. }
  298. })
  299. },
  300. searchStudent () {
  301. // activeTeam activeChioseSound
  302. if (!this.activeTeam || !this.activeChioseSound) {
  303. this.$message.error('请先选择乐团以及声部进行搜索')
  304. return;
  305. }
  306. console.log('开始搜素学生')
  307. // activeSoundId 这个id里面的 studentList
  308. // 在这里要同步当前已选学员的的状态=> chioseStudentList里赋值
  309. // 筛选学生1
  310. for (let i in this.activeSoundList) {
  311. if (this.activeSoundList[i].id == this.activeSoundId) {
  312. // console.log(this.activeSoundList[i].id);
  313. // console.log(this.activeSoundList[i].studentList);
  314. this.activeListStudent = this.activeSoundList[i].studentList;
  315. }
  316. }
  317. teamSoundStudent({ musicGroupId: this.activeTeam, actualSubjectId: this.activeChioseSound }).then(res => {
  318. if (res.code == 200) {
  319. this.studentList = res.data.map(item => {
  320. let teamName;
  321. let soundName;
  322. this.teamList.map(team => {
  323. if (team.id == this.activeTeam) {
  324. teamName = team.name
  325. }
  326. })
  327. item.soundName = this.chioseSoundList.map(sound => {
  328. if (sound.id == this.activeChioseSound) {
  329. soundName = sound.name
  330. }
  331. })
  332. item.soundName = soundName;
  333. item.musicGroupName = teamName;
  334. return item;
  335. });
  336. // console.log(this.studentList)
  337. // 若学生在全局中被选中 则下次更新列表的时候不显示该学生
  338. for (let i in this.studentList) {
  339. for (let j in this.allActiveStudent) {
  340. if (this.allActiveStudent[j].id == this.studentList[i].id) {
  341. this.studentList.splice(i, 1);
  342. }
  343. }
  344. }
  345. }
  346. })
  347. },
  348. SelectionStudent (e) {
  349. // 先找到外面是哪一行的
  350. for (let i in this.activeSoundList) {
  351. if (this.activeSoundList[i].id == this.activeSoundId) {
  352. if (this.activeSoundList[i].studentList.length > 0) {
  353. this.activeSoundList[i].studentList = this.activeSoundList[i].studentList.concat(e);
  354. } else {
  355. this.activeSoundList[i].studentList = e;
  356. }
  357. // 去重
  358. let result = this.objArrayRemoval(this.activeSoundList[i].studentList, 'id')
  359. // console.log(result);
  360. // 不对
  361. this.activeSoundList[i].studentList = result;
  362. this.activeListStudent = result;
  363. // // 添加全局
  364. if (this.allActiveStudent.length <= 0) {
  365. // console.log('第一次添加数据')
  366. this.allActiveStudent = result;
  367. } else {
  368. this.allActiveStudent = this.allActiveStudent.concat(result);
  369. }
  370. this.allActiveStudent = this.objArrayRemoval(this.allActiveStudent, 'id');
  371. }
  372. }
  373. },
  374. // 点击删除按钮 重学生集合里删除
  375. removeStudent (item) {
  376. // 删除全局
  377. for (let i in this.allActiveStudent) {
  378. if (this.allActiveStudent[i].id == item.id) {
  379. this.allActiveStudent.splice(i, 1);
  380. }
  381. }
  382. // 删除当前
  383. for (let i in this.activeSoundList) {
  384. if (this.activeSoundList[i].id == this.activeSoundId) {
  385. for (let j in this.activeSoundList[i].studentList) {
  386. if (item.id == this.activeSoundList[i].studentList[j].id) {
  387. this.activeSoundList[i].studentList.splice(j, 1);
  388. // 这里做判断 this.studentList 里有没有这个学生(没有)=>判断学生的声部是不是和当前搜索的声部一样 添加
  389. // 有.. 则取消勾选
  390. let flag = false;
  391. for (let x in this.studentList) {
  392. if (this.studentList[x].id == item.id) {
  393. flag = true;
  394. }
  395. }
  396. if (flag) {
  397. // 表里有这个学生
  398. this.toggleSelection(item, this.studentList);
  399. } else {
  400. if (item.actualSubjectId == this.activeChioseSound) {
  401. this.studentList.unshift(item)
  402. }
  403. }
  404. this.activeListStudent = this.activeSoundList[i].studentList;
  405. }
  406. }
  407. }
  408. }
  409. },
  410. toggleSelection (item, table) {
  411. table.forEach(row => {
  412. if (row.id == item.id) {
  413. this.$refs['studentList'].toggleRowSelection(row, false);
  414. }
  415. })
  416. },
  417. // 对象数组去重
  418. objArrayRemoval (arr, attr) {
  419. let obj = {};
  420. let result = [];
  421. // console.log(this.allActiveStudent.length);
  422. for (let x in arr) {
  423. if (!obj[arr[x][attr]]) {
  424. result.push(arr[x]);
  425. obj[arr[x][attr]] = true;
  426. }
  427. }
  428. return result;
  429. },
  430. submitInfo () {
  431. let obj = {};
  432. this.payfor.student.chiose == 'loop' ? obj.months = this.payfor.chioseMonth : obj.months = [];
  433. obj.musicGroup = {
  434. status: 'DRAFT',
  435. settlementType: this.topfor.salary,
  436. applyExpireDate: this.topfor.time + ' 00:00:01',
  437. chargeTypeId: this.topfor.type,
  438. cooperationOrganId: this.topfor.school,
  439. teamTeacherId: this.topfor.boss,
  440. educationalTeacherId: this.topfor.teacher,
  441. enrollClasses: this.topfor.startClass.join(','),
  442. name: this.topfor.name,
  443. organId: this.topfor.section,
  444. // paymentMonths:obj.months 有待确认
  445. schoolId: this.topfor.address,
  446. courseForm: JSON.stringify(this.checkfor)
  447. }
  448. obj.musicGroupPaymentEntities = []
  449. // 添加学校主体付费方式
  450. // console.log(this.payfor.company.ischeck)
  451. if (this.payfor.school.ischeck) {
  452. obj.musicGroupPaymentEntities.push({
  453. 'amount': this.payfor.school.price,
  454. 'memo': this.payfor.school.value,
  455. 'paymentMethod': this.payfor.school.chiose,
  456. 'name': '学校'
  457. })
  458. }
  459. // 添加公司主体付费方式
  460. if (this.payfor.company.ischeck) {
  461. obj.musicGroupPaymentEntities.push({
  462. 'amount': this.payfor.company.price,
  463. 'memo': this.payfor.company.value,
  464. 'paymentMethod': this.payfor.company.chiose,
  465. 'name': '公司'
  466. })
  467. }
  468. // 添加商品以及教辅
  469. // 添加声部
  470. obj.musicGroupSubjectPlans = [];
  471. for (let i in this.activeSoundList) {
  472. let item = {};
  473. // expectedStudentNum
  474. item.subName = this.activeSoundList[i].sound;
  475. item.subjectId = this.activeSoundList[i].id;
  476. item.fee = this.activeSoundList[i].yuji;
  477. obj.musicGroupSubjectPlans.push(item);
  478. }
  479. // 添加学员
  480. obj.subjectRegisters = [];
  481. for (let i in this.activeSoundList) {
  482. let item = {};
  483. // expectedStudentNum
  484. item.subjectId = this.activeSoundList[i].id;
  485. item.registerIdList = []
  486. for (let j in this.activeSoundList[i].studentList) {
  487. item.registerIdList.push(this.activeSoundList[i].studentList[j].id)
  488. }
  489. obj.subjectRegisters.push(item);
  490. }
  491. // 发请求修改
  492. createTeam(obj).then(res => {
  493. if (res.code == 200) {
  494. // 成功 跳转到筹备中
  495. let id = res.data;
  496. this.$router.push({ path: '/business/teamDetail' })
  497. }
  498. })
  499. },
  500. goback () {
  501. this.$emit('chiosetab', 0);
  502. }
  503. },
  504. computed: {
  505. // 返回当前选中声部数量
  506. chioseSoundNum () {
  507. let num = 0;
  508. for (let key in this.soundList) {
  509. // console.log(this.soundLists[key])
  510. num += this.soundLists[key].length;
  511. }
  512. return num;
  513. },
  514. },
  515. watch: {
  516. studentVisible (val) {
  517. if (!val) {
  518. // 1.选择的团
  519. this.activeTeam = ''
  520. // 2.选择的声部
  521. this.activeChioseSound = ''
  522. // 3.选择的选中的列表
  523. this.studentList = [];
  524. }
  525. }
  526. }
  527. }
  528. </script>
  529. <style lang="scss">
  530. .chioseWrap {
  531. margin-bottom: 30px;
  532. display: flex;
  533. flex-direction: row;
  534. padding: 0 25px;
  535. p {
  536. font-size: 14px;
  537. margin-right: 30px;
  538. }
  539. }
  540. .subTitle {
  541. // width: 1203px;
  542. height: 40px;
  543. line-height: 40px;
  544. background-color: #fefceb;
  545. padding: 0 25px;
  546. box-sizing: border-box;
  547. font-size: 16px;
  548. color: #474747;
  549. margin-bottom: 20px;
  550. }
  551. .floor {
  552. display: flex;
  553. flex-direction: row;
  554. justify-content: flex-start;
  555. width: 100%;
  556. height: 48px;
  557. line-height: 48px;
  558. background: rgba(237, 238, 240, 1);
  559. font-size: 14px;
  560. color: #444;
  561. align-items: center;
  562. position: relative;
  563. z-index: 1;
  564. .remove {
  565. width: 98px;
  566. height: 32px;
  567. background: rgba(248, 80, 67, 1);
  568. border-radius: 3px;
  569. color: #fff;
  570. line-height: 32px;
  571. text-align: center;
  572. margin-left: 164px;
  573. cursor: pointer;
  574. }
  575. .add {
  576. width: 98px;
  577. height: 32px;
  578. background: rgba(20, 146, 138, 1);
  579. border-radius: 3px;
  580. color: #fff;
  581. line-height: 32px;
  582. text-align: center;
  583. margin-left: 20px;
  584. cursor: pointer;
  585. }
  586. }
  587. .studentMask {
  588. display: flex;
  589. flex-direction: row;
  590. justify-content: flex-start;
  591. .left {
  592. width: 200px;
  593. margin-right: 20px;
  594. h4 {
  595. font-size: 16px;
  596. color: #444;
  597. line-height: 38px;
  598. margin-bottom: 10px;
  599. }
  600. .chioseStudentList {
  601. height: 500px;
  602. overflow-y: auto;
  603. border: 1px solid #ccc;
  604. .studentItem {
  605. padding-left: 10px;
  606. line-height: 25px;
  607. }
  608. }
  609. }
  610. .right {
  611. .tableList {
  612. max-height: 500px;
  613. overflow-y: auto;
  614. }
  615. }
  616. }
  617. </style>