teamResetSound.vue 18 KB

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