teamResetSound.vue 20 KB

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