teamResetSound.vue 21 KB

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