resetSound.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. collapse-tags>
  42. <el-option v-for="(item,index) in scope.row.goodsList"
  43. :key='index'
  44. :label="item.name"
  45. :value="item.id"></el-option>
  46. </el-select>
  47. <div style="text-align: right; margin-top: 20px">
  48. <!-- <el-button size="mini"
  49. type="text"
  50. @click="closechioseType(scope.row)">取消</el-button> -->
  51. <el-button type="primary"
  52. size="mini"
  53. @click="scope.row.typeVisible = false">确定</el-button>
  54. </div>
  55. </el-popover>
  56. </div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="乐器提供方式"
  60. align="center"
  61. prop="fangshi"
  62. width="180">
  63. <template slot-scope="scope">
  64. <div>
  65. <!-- <div class="chiose"
  66. >选择</div> -->
  67. <span v-if="scope.row.fangshi">{{scope.row.fangshi | fangshiFilter(scope.row.fangshiprice)}}</span>
  68. <el-popover placement="bottom"
  69. v-model="scope.row.provideVisible"
  70. v-if='scope.row.type == 1'>
  71. <i class='el-icon-edit'
  72. slot='reference'>
  73. </i>
  74. <el-select v-model="scope.row.fangshi"
  75. clearable>
  76. <el-option label="团购"
  77. value="GROUP"></el-option>
  78. <el-option label="借用"
  79. value="LEASE"></el-option>
  80. <el-option label="免费"
  81. value="FREE"></el-option>
  82. </el-select>
  83. <el-input placeholder="请输入费用"
  84. v-if='scope.row.fangshi == "LEASE"'
  85. v-model="scope.row.fangshiprice"
  86. style='width:180px; margin-top:20px'></el-input>
  87. <div style="text-align: right; margin-top: 20px">
  88. <!-- <el-button size="mini"
  89. type="text"
  90. @click="scope.row.provideVisible = false">取消</el-button> -->
  91. <el-button type="primary"
  92. size="mini"
  93. @click="scope.row.provideVisible = false">确定</el-button>
  94. </div>
  95. </el-popover>
  96. </div>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="教辅组合"
  100. align="center"
  101. prop="jiaopu">
  102. <template slot-scope="scope">
  103. <div>
  104. <el-dialog :visible.sync="scope.row.markVisible"
  105. style="text-align:left;"
  106. width="60%">
  107. <el-button type='text'
  108. @click="addMark(scope.row)">添加教辅</el-button>
  109. <div class="markWrap">
  110. <div class="markItem"
  111. v-for="(item, index) in scope.row.markList"
  112. :key='index'>
  113. <el-form :model="item"
  114. :inline="true">
  115. <el-form-item label="教辅名称">
  116. <el-input type="text"
  117. v-model="item.name"></el-input>
  118. </el-form-item>
  119. <el-form-item label="教辅商品">
  120. <el-select v-model="item.goods"
  121. multiple
  122. collapse-tags>
  123. <el-option v-for='(item,index) in scope.row.markChioseList'
  124. :key='index'
  125. :label="item.name"
  126. :value="item.id"></el-option>
  127. </el-select>
  128. </el-form-item>
  129. <el-form-item label="教辅打包价">
  130. <el-input type='number'
  131. v-model="item.price"></el-input>
  132. </el-form-item>
  133. <el-form-item>
  134. <el-button type="danger"
  135. icon="el-icon-delete"
  136. circle
  137. @click='removeMartItem(scope.row,index)'>
  138. </el-button>
  139. </el-form-item>
  140. </el-form>
  141. </div>
  142. </div>
  143. <span slot="footer"
  144. class="dialog-footer">
  145. <!-- <el-button @click="scope.row.markVisible = false">取 消</el-button> -->
  146. <el-button type="primary"
  147. @click="scope.row.markVisible = false">确 定</el-button>
  148. </span>
  149. </el-dialog>
  150. <span>
  151. <span v-for='(item,index) in scope.row.markList'
  152. v-if="item.name && scope.row.markChioseList.length>0"
  153. :key='index'>{{item.name+':'}}{{item.goods|goodsFilter(scope.row.markChioseList)}}{{' 价格 '+item.price }} </span>
  154. </span>
  155. <i class='el-icon-edit'
  156. slot='reference'
  157. @click="chioseMark(scope.row)">
  158. </i>
  159. </div>
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. <div class="btnWrap"
  164. style="margin-top:30px">
  165. <div class="closeBtn"
  166. @click="getSound">取消</div>
  167. <div class="okBtn"
  168. @click="saveInfo">保存</div>
  169. </div>
  170. </div>
  171. </template>
  172. <script>
  173. import { findMusicGroupSubjectInfo, resetSubjectPlan, getSoundTree, getGoods, updateSubjectInfo } from '@/api/buildTeam'
  174. export default {
  175. data () {
  176. return {
  177. tableList: [],
  178. teamid: '',
  179. activeSoundList: [],
  180. soundList: [],
  181. checkList: [],
  182. multipleSelection: [], // 列表选择的集合
  183. }
  184. },
  185. mounted () {
  186. // 获取声部信息
  187. this.teamid = this.$route.query.id
  188. this.getSound();
  189. sessionStorage.setItem('resetCode', '2');
  190. },
  191. methods: {
  192. getSound () {
  193. findMusicGroupSubjectInfo({ musicGroupId: this.teamid }).then(res => {
  194. if (res.code == 200) {
  195. this.activeSoundList = res.data.musicGroupSubjectPlans.map(item => {
  196. // this.soundLists[0].push(item.subjectId)
  197. 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': [{ 'name': '', 'goods': [], 'price': '' }], 'markChioseList': [] }
  198. return obj;
  199. })
  200. // 循环列表里的声部 拿取商品
  201. for (let i in this.activeSoundList) {
  202. for (let j in res.data.musicGroupSubjectGoodsGroups) {
  203. if (this.activeSoundList[i].id == res.data.musicGroupSubjectGoodsGroups[j].subjectId) {
  204. //
  205. if (res.data.musicGroupSubjectGoodsGroups[j].type == 'INSTRUMENT') {
  206. this.activeSoundList[i].zhonglei = this.activeSoundList[i].zhonglei.concat(res.data.musicGroupSubjectGoodsGroups[j].goodsIdList)
  207. // console.log(this.activeSoundList[i].zhonglei)
  208. this.activeSoundList[i].zhonglei = this.activeSoundList[i].zhonglei.map(item => {
  209. return parseInt(item);
  210. })
  211. this.activeSoundList[i].goodsList = this.activeSoundList[i].goodsList.concat(res.data.musicGroupSubjectGoodsGroups[j].goodsList);
  212. // goodsList
  213. }
  214. // 拿辅件
  215. if (res.data.musicGroupSubjectGoodsGroups[j].type == 'ACCESSORIES') {
  216. if (res.data.musicGroupSubjectGoodsGroups[j].goodsList.length >= 0) {
  217. this.activeSoundList[i].markList = [];
  218. let obj = {};
  219. obj.goods = res.data.musicGroupSubjectGoodsGroups[j].goodsIdList.split(',');
  220. obj.goods = obj.goods.map(item => {
  221. return parseInt(item);
  222. })
  223. obj.name = res.data.musicGroupSubjectGoodsGroups[j].name
  224. obj.price = res.data.musicGroupSubjectGoodsGroups[j].price;
  225. this.activeSoundList[i].markList.push(obj);
  226. // this.activeSoundList[i].markList.goodsList.goods = JSON.parse(res.data.musicGroupSubjectGoodsGroups[j].goodsIdList)
  227. this.activeSoundList[i].markChioseList = this.activeSoundList[i].markChioseList.concat(res.data.musicGroupSubjectGoodsGroups[j].goodsList);
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. })
  235. },
  236. saveInfo () {
  237. // 只提交第二页的数据
  238. let obj = {};
  239. let activeSoundList = this.activeSoundList
  240. // 添加商品以及教辅
  241. obj.musicGroupId = this.teamid
  242. obj.musicGroupStatus = 'PROGRESS';
  243. obj.musicGroupSubjectGoodsGroups = []
  244. obj.musicGroupSubjectPlans = []
  245. activeSoundList.forEach(active => {
  246. // 乐器
  247. active.zhonglei.forEach(zl => {
  248. let goodsItem = []
  249. active.goodsList.forEach(goods => {
  250. if (goods.id == zl) {
  251. goodsItem = goods
  252. }
  253. })
  254. let some = {
  255. subjectId: active.id,
  256. type: 'INSTRUMENT',
  257. goodsIdList: zl,
  258. name: goodsItem.name,
  259. price: goodsItem.groupPurchasePrice
  260. }
  261. obj.musicGroupSubjectGoodsGroups.push(some);
  262. })
  263. // 遍历声部里的教辅
  264. active.markList.forEach(mark => {
  265. if (mark.goods.length >= 1) {
  266. let some = {
  267. subjectId: active.id,
  268. type: 'ACCESSORIES',
  269. goodsIdList: mark.goods.join(','),
  270. name: mark.name,
  271. price: mark.price
  272. }
  273. obj.musicGroupSubjectGoodsGroups.push(some);
  274. }
  275. })
  276. // 添加声部
  277. let item = {
  278. expectedStudentNum: active.jihua,
  279. fee: active.yuji,
  280. kitGroupPurchaseType: active.fangshi,
  281. subName: active.sound,
  282. subjectId: active.id,
  283. depositFee: active.fangshiprice // depositFee 只有租赁才有
  284. }
  285. obj.musicGroupSubjectPlans.push(item);
  286. })
  287. // 发请求修改声部信息
  288. updateSubjectInfo(obj).then(res => {
  289. if (res.code == 200) {
  290. this.$message.success('提交成功')
  291. // this.$router.push({ path: '/business/teamDetail' })
  292. this.getSound();
  293. }
  294. })
  295. },
  296. // 根据声部id查询可选教辅
  297. chioseMark (row) {
  298. row.markVisible = true
  299. let id = row.id;
  300. getGoods({ 'subjectId': id, 'type': 'ACCESSORIES' }).then(res => {
  301. if (res.code == 200) {
  302. row.markChioseList = res.data;
  303. }
  304. })
  305. }, // 根据声部id获取可选乐器种类
  306. chioseType (row) {
  307. // 根据id查询可选类型种类
  308. let id = row.id;
  309. // 'subjectId': id, ' type'='INSTRUMENT'
  310. getGoods({ 'subjectId': id, 'type': 'INSTRUMENT' }).then(res => {
  311. if (res.code == 200) {
  312. row.goodsList = res.data;
  313. }
  314. })
  315. },
  316. }, filters: {
  317. zhongleiFilter (val, list) {
  318. if (list && list.length <= 0) {
  319. return;
  320. }
  321. let arr = []
  322. for (let i = 0; i < list.length; i++) {
  323. for (let j = 0; j < val.length; j++) {
  324. if (val[j] == list[i].id) {
  325. arr.push(list[i].name)
  326. }
  327. }
  328. }
  329. if (arr.length > 0) {
  330. return arr.join(',')
  331. } else {
  332. return ''
  333. }
  334. },
  335. fangshiFilter (val, price) {
  336. let str = ''
  337. if (val == 'FREE') {
  338. str = '免费'
  339. return str;
  340. } else if (val == 'GROUP') {
  341. str = '团购'
  342. return str
  343. } else if (val == 'LEASE') {
  344. str = '借用'
  345. }
  346. return str + '费用:' + price
  347. },
  348. goodsFilter (val, list) {
  349. if (list && list.length <= 0) {
  350. return '';
  351. }
  352. let arr = [];
  353. for (let i = 0; i < val.length; i++) {
  354. for (let j = 0; j < list.length; j++) {
  355. if (val[i] == list[j].id) {
  356. arr.push(list[j].name);
  357. }
  358. }
  359. }
  360. if (arr.length > 0) {
  361. return arr.join(',')
  362. } else {
  363. return ''
  364. }
  365. }
  366. // markFilter(val){
  367. // for
  368. // let name = val.name;
  369. // let goods = val.goods.join(',');
  370. // let price = val.price
  371. // }
  372. },
  373. }
  374. </script>
  375. <style lang="scss">
  376. </style>