resetSound.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <template>
  2. <div>
  3. <el-table :data='activeSoundList'
  4. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  5. <el-table-column align='center'
  6. width="180px;"
  7. prop="sound"
  8. label="声部名称">
  9. </el-table-column>
  10. <el-table-column align='center'
  11. width="180px;"
  12. prop="yuji"
  13. label="预计收费">
  14. <template slot-scope="scope">
  15. <div>
  16. <el-input style="width:100px"
  17. v-model="scope.row.yuji"></el-input>
  18. </div>
  19. </template>
  20. </el-table-column>
  21. <el-table-column label="可选乐器规格"
  22. align="center"
  23. prop="zhonglei"
  24. width="300">
  25. <template slot-scope="scope">
  26. <!-- 'typeVisible':false,'provideVisible':false,'markVisible':false -->
  27. <div>
  28. <span>{{scope.row.zhonglei | zhongleiFilter(scope.row.goodsList)}}</span>
  29. <el-popover placement="bottom"
  30. @show='chioseType(scope.row)'
  31. v-model="scope.row.typeVisible"
  32. v-if='scope.row.type == 1'>
  33. <el-button type="text"
  34. slot='reference'>
  35. 修改
  36. </el-button>
  37. <!-- zhonglei -->
  38. <el-select v-model="scope.row.zhonglei"
  39. multiple
  40. clearable
  41. filterable
  42. collapse-tags>
  43. <el-option v-for="(item,index) in scope.row.goodsList"
  44. :key='index'
  45. :label="item.name"
  46. :value="item.id"></el-option>
  47. </el-select>
  48. <div style="text-align: right; margin-top: 20px">
  49. <!-- <el-button size="mini"
  50. type="text"
  51. @click="closechioseType(scope.row)">取消</el-button> -->
  52. <el-button type="primary"
  53. size="mini"
  54. @click="scope.row.typeVisible = false">确定</el-button>
  55. </div>
  56. </el-popover>
  57. </div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="乐器提供方式"
  61. align="center"
  62. prop="fangshi"
  63. width="180">
  64. <template slot-scope="scope">
  65. <div>
  66. <!-- <div class="chiose"
  67. >选择</div> -->
  68. <span v-if="scope.row.fangshi">{{scope.row.fangshi | fangshiFilter(scope.row.fangshiprice)}}</span>
  69. <el-popover placement="bottom"
  70. v-model="scope.row.provideVisible"
  71. v-if='scope.row.type == 1'>
  72. <i class='el-icon-edit'
  73. slot='reference'>
  74. </i>
  75. <el-select v-model="scope.row.fangshi"
  76. filterable
  77. clearable>
  78. <el-option label="团购"
  79. value="GROUP"></el-option>
  80. <el-option label="借用"
  81. value="LEASE"></el-option>
  82. <el-option label="免费"
  83. value="FREE"></el-option>
  84. </el-select>
  85. <el-input placeholder="请输入费用"
  86. v-if='scope.row.fangshi == "LEASE"'
  87. v-model="scope.row.fangshiprice"
  88. style='width:180px; margin-top:20px'></el-input>
  89. <div style="text-align: right; margin-top: 20px">
  90. <!-- <el-button size="mini"
  91. type="text"
  92. @click="scope.row.provideVisible = false">取消</el-button> -->
  93. <el-button type="primary"
  94. size="mini"
  95. @click="scope.row.provideVisible = false">确定</el-button>
  96. </div>
  97. </el-popover>
  98. </div>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="教辅组合"
  102. align="center"
  103. prop="jiaopu">
  104. <template slot-scope="scope">
  105. <div>
  106. <el-dialog :visible.sync="scope.row.markVisible"
  107. style="text-align:left;"
  108. width="60%">
  109. <el-button type='text'
  110. @click="addMark(scope.row)">添加教辅</el-button>
  111. <div class="markWrap">
  112. <div class="markItem"
  113. v-for="(item, index) in scope.row.markList"
  114. :key='index'>
  115. <el-form :model="item"
  116. :inline="true">
  117. <el-form-item label="教辅名称">
  118. <el-input type="text"
  119. v-model="item.name"></el-input>
  120. </el-form-item>
  121. <el-form-item label="教辅商品">
  122. <el-select v-model="item.goods"
  123. filterable
  124. multiple
  125. collapse-tags>
  126. <el-option v-for='(item,index) in scope.row.markChioseList'
  127. :key='index'
  128. :label="item.name"
  129. :value="item.id"></el-option>
  130. </el-select>
  131. </el-form-item>
  132. <el-form-item label="教辅打包价">
  133. <el-input type='number'
  134. @mousewheel.native.prevent
  135. v-model="item.price"></el-input>
  136. </el-form-item>
  137. <el-form-item>
  138. <el-button type="danger"
  139. icon="el-icon-delete"
  140. circle
  141. @click='removeMartItem(scope.row,index)'>
  142. </el-button>
  143. </el-form-item>
  144. </el-form>
  145. </div>
  146. </div>
  147. <span slot="footer"
  148. class="dialog-footer">
  149. <!-- <el-button @click="scope.row.markVisible = false">取 消</el-button> -->
  150. <el-button type="primary"
  151. @click="scope.row.markVisible = false">确 定</el-button>
  152. </span>
  153. </el-dialog>
  154. <span>
  155. <span v-for='(item,index) in scope.row.markList'
  156. v-if="item.name && scope.row.markChioseList.length>0"
  157. :key='index'>{{item.name+':'}}{{item.goods|goodsFilter(scope.row.markChioseList)}}{{' 价格 '+item.price }} </span>
  158. </span>
  159. <i class='el-icon-edit'
  160. slot='reference'
  161. @click="chioseMark(scope.row)">
  162. </i>
  163. </div>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. <!-- <div class="remove"
  168. @click="removeListItem">删除</div> -->
  169. <div class="floor">
  170. <div class='add'
  171. @click="addListItem">添加</div>
  172. </div>
  173. <div class="btnWrap"
  174. style="margin-top:30px">
  175. <div class="closeBtn"
  176. @click="getSound">取消</div>
  177. <div class="okBtn"
  178. v-permission="{child: 'musicGroup/updateSubjectInfo', parent: '/resetTeaming/resetSound'}"
  179. @click="saveInfo">保存</div>
  180. </div>
  181. <el-dialog title="声部选择"
  182. :visible.sync="dialogTableVisible"
  183. :modal-append-to-body="false">
  184. <div class="soundWrap">
  185. <div class="itemList">
  186. <div class="categroy"
  187. v-for="(item,index) in soundList"
  188. :key="index">
  189. <p>{{item.name }}</p>
  190. <el-checkbox-group v-model="soundLists[index]"
  191. @change='changeList'>
  192. <!-- sound: this.activeSoundList[item].name, // id
  193. jihua: '10', //计划招生人数
  194. yuji: '10', // 预计收费
  195. zhonglei: [], // 可选乐器种类
  196. fangshi: 2, // 乐器提供方式
  197. jiaopu: 'jiaopu1', // 教辅组合
  198. type: 1, // 操作
  199. id: this.activeSoundList[item].id, //声部id
  200. visible: false, // 当前乐器提供方式的pop提示框显示隐藏 -->
  201. <el-checkbox :label="sound.id"
  202. @change="checkinlist({'id':sound.id,'sound':sound.name,'jihua':0,'yuji':0,'zhonglei':[],'fangshi':'','fangshiprice':1500,'jiaopu':'','type':1,'typeVisible':false,'provideVisible':false,'markVisible':false,'goodsList':[],'markList':[],'markChioseList':[]})"
  203. v-for="(sound,indexs) in item.subjects"
  204. :key="indexs">{{sound.name }}</el-checkbox>
  205. </el-checkbox-group>
  206. </div>
  207. </div>
  208. </div>
  209. <p class='soundSubP'>当前选择声部数:{{chioseSoundNum}}</p>
  210. <div class="btnWrapss">
  211. <div class="dialogBtn"
  212. @click="generates">确定</div>
  213. </div>
  214. </el-dialog>
  215. </div>
  216. </template>
  217. <script>
  218. import { findMusicGroupSubjectInfo, resetSubjectPlan, getSoundTree, getGoods, updateSubjectInfo } from '@/api/buildTeam'
  219. export default {
  220. data () {
  221. return {
  222. dialogTableVisible: false,
  223. tableList: [],
  224. teamid: '',
  225. activeSoundList: [],
  226. soundList: [],
  227. checkList: [],
  228. multipleSelection: [], // 列表选择的集合
  229. soundList: [],
  230. soundLists: [], // 存储选中项的声部id 记录变量
  231. }
  232. },
  233. mounted () {
  234. // 获取声部信息
  235. this.teamid = this.$route.query.id
  236. sessionStorage.setItem('resetCode', '2');
  237. // 获取所有声部
  238. getSoundTree().then(res => {
  239. if (res.code == 200) {
  240. this.soundList = res.data.rows;
  241. // // 生成动态的checkList
  242. for (let key in this.soundList) {
  243. this.$set(this.soundLists, key, [])
  244. }
  245. this.getSound();
  246. }
  247. })
  248. },
  249. methods: {
  250. changeList (e) {
  251. },
  252. getSound () {
  253. findMusicGroupSubjectInfo({ musicGroupId: this.teamid }).then(res => {
  254. if (res.code == 200) {
  255. this.activeSoundList = res.data.musicGroupSubjectPlans.map(item => {
  256. let obj = { 'id': item.subjectId, 'sound': item.subName, 'jihua': item.expectedStudentNum, 'yuji': item.fee, 'zhonglei': [], 'fangshi': item.kitGroupPurchaseType, 'fangshiprice': item.depositFee, 'jiaopu': '', 'type': 1, 'typeVisible': false, 'provideVisible': false, 'markVisible': false, 'goodsList': [], 'markList': [], 'markChioseList': [] }
  257. return obj;
  258. })
  259. // 这里循环
  260. for (let x = 0; x <= this.soundList.length - 1; x++) {
  261. for (let y = 0; y <= this.soundList[x].subjects.length - 1; y++) {
  262. console.log(`xid=${x}, yid=${y}`)
  263. console.log(this.soundList[x].subjects)
  264. // console.log(this.soundList[x].subjects[y].id, this.soundList[0].subjects[0].id)
  265. // console.log(this.soundList[x].subjects[y].name)
  266. for (let z = 0; z <= this.activeSoundList.length - 1; z++) {
  267. // console.log(this.soundList[x].subjects[y].name + '-' + this.activeSoundList[z].sound)
  268. // console.log(this.soundList[x].subjects[y].id + '-' + this.activeSoundList[z].id)
  269. if (this.soundList[x].subjects[y].id == this.activeSoundList[z].id) {
  270. // console.log(this.soundList[x].subjects[y])
  271. this.soundList[x].subjects.splice(y, 1)
  272. // console.log(1)
  273. // this.soundList[x].subjects[y] = null
  274. // x--
  275. y--
  276. }
  277. }
  278. }
  279. }
  280. // this.soundList.forEach((item, i) => {
  281. // item.subjects.forEach((some, j) => {
  282. // this.activeSoundList.forEach((sub, x) => {
  283. // console.log(some.name + '-' + sub.sound)
  284. // console.log(some.id + '-' + sub.id)
  285. // if (sub.id == some.id) {
  286. // console.log(1)
  287. // item.subjects.splice(x, 1)
  288. // }
  289. // })
  290. // })
  291. // })
  292. // 循环列表里的声部 拿取商品
  293. for (let i in this.activeSoundList) {
  294. for (let j in res.data.musicGroupSubjectGoodsGroups) {
  295. if (this.activeSoundList[i].id == res.data.musicGroupSubjectGoodsGroups[j].subjectId) {
  296. //
  297. if (res.data.musicGroupSubjectGoodsGroups[j].type == 'INSTRUMENT') {
  298. this.activeSoundList[i].zhonglei = this.activeSoundList[i].zhonglei.concat(res.data.musicGroupSubjectGoodsGroups[j].goodsIdList)
  299. this.activeSoundList[i].zhonglei = this.activeSoundList[i].zhonglei.map(item => {
  300. return parseInt(item);
  301. })
  302. this.activeSoundList[i].goodsList = this.activeSoundList[i].goodsList.concat(res.data.musicGroupSubjectGoodsGroups[j].goodsList);
  303. // goodsList
  304. }
  305. // 拿辅件
  306. if (res.data.musicGroupSubjectGoodsGroups[j].type == 'ACCESSORIES') {
  307. if (res.data.musicGroupSubjectGoodsGroups[j].goodsList.length >= 0) {
  308. this.activeSoundList[i].markList ? this.activeSoundList[i].markList : this.activeSoundList[i].markList = []
  309. let obj = {};
  310. obj.goods = res.data.musicGroupSubjectGoodsGroups[j].goodsIdList.split(',');
  311. obj.goods = obj.goods.map(item => {
  312. return parseInt(item);
  313. })
  314. obj.name = res.data.musicGroupSubjectGoodsGroups[j].name
  315. obj.price = res.data.musicGroupSubjectGoodsGroups[j].price;
  316. this.activeSoundList[i].markList.push(obj);
  317. // this.activeSoundList[i].markList.goodsList.goods = JSON.parse(res.data.musicGroupSubjectGoodsGroups[j].goodsIdList)
  318. this.activeSoundList[i].markChioseList = this.activeSoundList[i].markChioseList.concat(res.data.musicGroupSubjectGoodsGroups[j].goodsList);
  319. }
  320. }
  321. }
  322. }
  323. }
  324. }
  325. })
  326. },
  327. // 添加教辅
  328. addMark (row) {
  329. row.markList.push({ 'name': '', 'goods': [], 'price': '' })
  330. },
  331. removeMartItem (row, index) {
  332. row.markList.splice(index, 1);
  333. },
  334. saveInfo () {
  335. // 只提交第二页的数据
  336. let obj = {};
  337. let activeSoundList = this.activeSoundList
  338. // 添加商品以及教辅
  339. obj.musicGroupId = this.teamid
  340. obj.musicGroupStatus = 'PROGRESS';
  341. obj.musicGroupSubjectGoodsGroups = []
  342. obj.musicGroupSubjectPlans = []
  343. activeSoundList.forEach(active => {
  344. // 乐器
  345. active.zhonglei.forEach(zl => {
  346. let goodsItem = []
  347. active.goodsList.forEach(goods => {
  348. if (goods.id == zl) {
  349. goodsItem = goods
  350. }
  351. })
  352. let some = {
  353. subjectId: active.id,
  354. type: 'INSTRUMENT',
  355. goodsIdList: zl,
  356. name: goodsItem.name,
  357. price: goodsItem.groupPurchasePrice
  358. }
  359. obj.musicGroupSubjectGoodsGroups.push(some);
  360. })
  361. // 遍历声部里的教辅
  362. active.markList.forEach(mark => {
  363. if (mark.goods.length >= 1) {
  364. let some = {
  365. subjectId: active.id,
  366. type: 'ACCESSORIES',
  367. goodsIdList: mark.goods.join(','),
  368. name: mark.name,
  369. price: mark.price
  370. }
  371. obj.musicGroupSubjectGoodsGroups.push(some);
  372. }
  373. })
  374. // 添加声部
  375. let item = {
  376. expectedStudentNum: active.jihua,
  377. fee: active.yuji,
  378. kitGroupPurchaseType: active.fangshi,
  379. subName: active.sound,
  380. subjectId: active.id,
  381. depositFee: active.fangshiprice // depositFee 只有租赁才有
  382. }
  383. obj.musicGroupSubjectPlans.push(item);
  384. })
  385. // 发请求修改声部信息
  386. updateSubjectInfo(obj).then(res => {
  387. if (res.code == 200) {
  388. this.$message.success('提交成功')
  389. // this.$router.push({ path: '/business/teamDetail' })
  390. this.getSound();
  391. }
  392. })
  393. },
  394. // 根据声部id查询可选教辅
  395. chioseMark (row) {
  396. row.markVisible = true
  397. let id = row.id;
  398. getGoods({ 'subjectId': id, 'type': 'ACCESSORIES' }).then(res => {
  399. if (res.code == 200) {
  400. row.markChioseList = res.data;
  401. }
  402. })
  403. }, // 根据声部id获取可选乐器种类
  404. chioseType (row) {
  405. // 根据id查询可选类型种类
  406. let id = row.id;
  407. // 'subjectId': id, ' type'='INSTRUMENT'
  408. getGoods({ 'subjectId': id, 'type': 'INSTRUMENT' }).then(res => {
  409. if (res.code == 200) {
  410. row.goodsList = res.data;
  411. }
  412. })
  413. },
  414. // 勾选选中框处理数据,存储勾选过的checkbox值
  415. checkinlist (obj) {
  416. let flag = false;
  417. this.activeSoundList.map(item => {
  418. if (item.id == obj.id) {
  419. flag = true
  420. }
  421. })
  422. if (!flag) {
  423. this.activeSoundList.push(obj)
  424. } else {
  425. for (let i = 0; i < this.activeSoundList.length; i++) {
  426. if (this.activeSoundList[i].id == obj.id) {
  427. this.activeSoundList.splice(i, 1);
  428. }
  429. }
  430. }
  431. },
  432. // 添加声部
  433. // 点击添加按钮
  434. addListItem () {
  435. this.dialogTableVisible = true;
  436. },
  437. // 点击确认按钮生成表单
  438. generates () {
  439. this.dialogTableVisible = false;
  440. },
  441. }, filters: {
  442. zhongleiFilter (val, list) {
  443. if (list && list.length <= 0) {
  444. return;
  445. }
  446. let arr = []
  447. for (let i = 0; i < list.length; i++) {
  448. for (let j = 0; j < val.length; j++) {
  449. if (val[j] == list[i].id) {
  450. arr.push(list[i].name)
  451. }
  452. }
  453. }
  454. if (arr.length > 0) {
  455. return arr.join(',')
  456. } else {
  457. return ''
  458. }
  459. },
  460. fangshiFilter (val, price) {
  461. let str = ''
  462. if (val == 'FREE') {
  463. str = '免费'
  464. return str;
  465. } else if (val == 'GROUP') {
  466. str = '团购'
  467. return str
  468. } else if (val == 'LEASE') {
  469. str = '借用'
  470. }
  471. return str + '费用:' + price
  472. },
  473. goodsFilter (val, list) {
  474. if (list && list.length <= 0) {
  475. return '';
  476. }
  477. let arr = [];
  478. for (let i = 0; i < val.length; i++) {
  479. for (let j = 0; j < list.length; j++) {
  480. if (val[i] == list[j].id) {
  481. arr.push(list[j].name);
  482. }
  483. }
  484. }
  485. if (arr.length > 0) {
  486. return arr.join(',')
  487. } else {
  488. return ''
  489. }
  490. }
  491. // markFilter(val){
  492. // for
  493. // let name = val.name;
  494. // let goods = val.goods.join(',');
  495. // let price = val.price
  496. // }
  497. }, computed: {
  498. // 返回当前选中声部数量
  499. chioseSoundNum () {
  500. let num = 0;
  501. for (let key in this.soundList) {
  502. num += this.soundLists[key].length;
  503. }
  504. return num;
  505. }
  506. }
  507. }
  508. </script>
  509. <style lang="scss">
  510. .floor {
  511. display: flex;
  512. flex-direction: row;
  513. justify-content: flex-start;
  514. width: 100%;
  515. height: 48px;
  516. line-height: 48px;
  517. background: rgba(237, 238, 240, 1);
  518. font-size: 14px;
  519. color: #444;
  520. align-items: center;
  521. position: relative;
  522. z-index: 1;
  523. .remove {
  524. width: 98px;
  525. height: 32px;
  526. background: rgba(248, 80, 67, 1);
  527. border-radius: 3px;
  528. color: #fff;
  529. line-height: 32px;
  530. text-align: center;
  531. margin-left: 164px;
  532. cursor: pointer;
  533. }
  534. .add {
  535. width: 98px;
  536. height: 32px;
  537. background: rgba(20, 146, 138, 1);
  538. border-radius: 3px;
  539. color: #fff;
  540. line-height: 32px;
  541. text-align: center;
  542. margin-left: 20px;
  543. cursor: pointer;
  544. }
  545. }
  546. .soundWrap {
  547. width: 100%;
  548. overflow: auto;
  549. .itemList {
  550. display: flex;
  551. flex-direction: row;
  552. justify-content: flex-start;
  553. flex-wrap: nowrap;
  554. flex-grow: 1;
  555. height: 300px;
  556. max-height: 300px;
  557. overflow: auto;
  558. .categroy {
  559. width: 150px;
  560. min-width: 150px;
  561. .el-checkbox {
  562. height: 30px;
  563. line-height: 30px;
  564. display: block;
  565. padding-left: 20px;
  566. }
  567. p {
  568. height: 40px;
  569. line-height: 40px;
  570. background-color: #edeef0;
  571. margin-bottom: 15px;
  572. text-align: center;
  573. }
  574. }
  575. }
  576. }
  577. .soundSubP {
  578. height: 40px;
  579. line-height: 40px;
  580. background-color: #edeef0;
  581. padding-left: 25px;
  582. }
  583. .btnWrapss {
  584. display: flex;
  585. flex-direction: column;
  586. align-items: center;
  587. margin-top: 150px;
  588. .dialogBtn {
  589. width: 188px;
  590. height: 40px;
  591. background: rgba(249, 114, 21, 1);
  592. border-radius: 4px;
  593. line-height: 40px;
  594. color: #fff;
  595. text-align: center;
  596. cursor: pointer;
  597. }
  598. }
  599. </style>