teamResetSound.vue 21 KB

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