teamSoundSet.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <div class="sound-container">
  3. <div class="topMsg">
  4. <p>当前选择声部数(个):{{chioseSoundNum}}</p>
  5. <p style="margin-left:30px;">计划招生人数(个):{{PlannedCount}}</p>
  6. </div>
  7. <div class="soundBtnWrap">
  8. <el-button type="primary"
  9. @click="allin">全选</el-button>
  10. <el-button type="danger"
  11. @click="deleteRow">删除</el-button>
  12. <el-button type="primary"
  13. @click="soundVisible = true">添加</el-button>
  14. </div>
  15. <div class="coreWrap">
  16. <el-checkbox-group v-model="checkList"
  17. @change='lookCheck'>
  18. <el-collapse v-model="chioseActiveSound"
  19. accordion
  20. @change="changeActiveSound">
  21. <el-collapse-item v-for="(item,index) in activeSoundList"
  22. :name="item.id"
  23. :key="index">
  24. <template slot="title">
  25. <div class="coreItemTitle">
  26. <el-checkbox :label="item.id">{{item.sound}}</el-checkbox>
  27. </div>
  28. </template>
  29. <div class="coreItem">
  30. <div class="coreItemRow">
  31. <p class="title">计划招生人数:</p>
  32. <el-input style="width:180px"
  33. v-model="item.expectedStudentNum"></el-input>
  34. </div>
  35. </div>
  36. <chioseMusic :item="item"
  37. @lookMusic="lookMusic" />
  38. <div class="coreItemRow">
  39. <p class="title">教辅:</p>
  40. <el-select style="width:558px!important;"
  41. v-model="item.markChioseList"
  42. clearable
  43. filterable
  44. multiple>
  45. <el-option v-for="(item,index) in item.markList"
  46. :key="index"
  47. :label="item.name"
  48. :value="item.id"></el-option>
  49. </el-select>
  50. </div>
  51. </el-collapse-item>
  52. </el-collapse>
  53. </el-checkbox-group>
  54. </div>
  55. <div class="btnWrap">
  56. <div class="PrevBtn"
  57. @click="goback">上一步</div>
  58. <!-- v-if="teamStatus != 'teamAudit'" -->
  59. <div class="submitBtn"
  60. v-permission="{child: 'musicGroup/createGroup', parent: '/teamBuild/soundMoney'}"
  61. @click="submitInfo()">下一步</div>
  62. </div>
  63. <el-dialog title="声部选择"
  64. :visible.sync="soundVisible">
  65. <chioseSoundList :soundList="soundList"
  66. :activeSound='activeSound'
  67. @chioseSound="chioseSound" />
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import store from "@/store";
  73. import { formatData } from '@/utils/utils'
  74. import {
  75. getSubject,
  76. getDefaultSubject,
  77. getGoods,
  78. createTeam,
  79. getSoundTree,
  80. findMusicGroupSubjectInfo,
  81. updateSubjectInfo,
  82. auditSuccess,
  83. auditFailed,
  84. getSubjectGoods
  85. } from "@/api/buildTeam";
  86. import dayjs from 'dayjs'
  87. import chioseMusic from './soundSetComponents/chioseMusic'
  88. import chioseAccessory from './soundSetComponents/chioseAccessory'
  89. import chioseSoundList from './soundSetComponents/chioseSoundList'
  90. import { findIndex } from 'lodash'
  91. export default {
  92. components: { chioseMusic, chioseAccessory, chioseSoundList },
  93. data () {
  94. return {
  95. topfor: null, // 第一页的数据
  96. checkList: [],
  97. Fsearch: null,
  98. Frules: null,
  99. soundList: [], // 接口返回的一级二级声部
  100. soundVisible: false, // 设置声部弹窗
  101. childSoundList: [],
  102. teamStatus: '',// 乐团状态
  103. activeSoundList: [], //列表上的声部
  104. activeSound: null, // 展开的列表
  105. chioseActiveSound: null
  106. }
  107. },
  108. mounted () {
  109. this.init()
  110. },
  111. activated () { },
  112. methods: {
  113. init () {
  114. // 获取第一页的数据
  115. this.topfor = this.$store.getters.topinfo;
  116. let type = this.topfor.type;
  117. this.teamStatus = this.$route.query.type;
  118. if (this.$route.query.search) {
  119. this.Fsearch = this.$route.query.search;
  120. }
  121. if (this.$route.query.rules) {
  122. this.Frules = this.$route.query.rules;
  123. }
  124. getSoundTree({ tenantId: 1 }).then(res => {
  125. if (res.code == 200) {
  126. this.soundList = res.data.rows
  127. if (this.teamStatus == "newTeam") {
  128. getDefaultSubject({
  129. chargeTypeId: type,
  130. organId: this.topfor.section,
  131. number: 1
  132. }).then(res => {
  133. if (res.code == 200) {
  134. let activeSound = []
  135. this.activeSoundList = res.data.map(item => {
  136. activeSound.push(item.id)
  137. return this.initSound(item);
  138. });
  139. this.activeSound = activeSound;
  140. this.chioseActiveSound = activeSound[0]
  141. this.changeActiveSound(activeSound[0])
  142. }
  143. });
  144. } else {
  145. this.$nextTick(res => {
  146. this.teamid = this.$route.query.id;
  147. findMusicGroupSubjectInfo({ musicGroupId: this.teamid }).then(
  148. res => {
  149. if (res.code == 200) {
  150. let activeSound = []
  151. this.activeSoundList = res.data?.musicGroupSubjectPlans.map(item => {
  152. activeSound.push(item.subjectId)
  153. return {
  154. id: parseInt(item.subjectId),
  155. sound: item.subName,
  156. expectedStudentNum: item.expectedStudentNum,
  157. chioseMusic: [],
  158. markChioseList: [],
  159. goodsList: [],
  160. markList: [],
  161. }
  162. })
  163. this.activeSound = activeSound;
  164. console.log(this.activeSound)
  165. // 格式化商品和教辅
  166. res.data.musicGroupSubjectGoodsGroups.forEach(shop => {
  167. let index = findIndex(this.activeSoundList, (o) => {
  168. return o.id == shop.subjectId
  169. })
  170. if (index != -1) {
  171. if (shop.type == 'ACCESSORIES') {
  172. shop.goodsIdList.split(',').forEach(item => {
  173. this.activeSoundList[index].markChioseList.push(parseInt(item))
  174. })
  175. } else if (shop.type == 'INSTRUMENT') {
  176. // 商品
  177. let typeJson = Object.keys(JSON.parse(shop.kitGroupPurchaseTypeJson))
  178. this.activeSoundList[index].chioseMusic.push({
  179. musical: parseInt(shop.goodsIdList),
  180. type: typeJson,
  181. groupPrice: shop.price,
  182. borrowPrice: shop.depositFee
  183. })
  184. }
  185. }
  186. })
  187. }
  188. })
  189. })
  190. }
  191. }
  192. });
  193. getSubject({ tenantId: 1 }).then(res => {
  194. if (res.code == 200) {
  195. this.childSoundList = res.data
  196. }
  197. })
  198. },
  199. lookCheck (val) {
  200. this.checkList = [...new Set(val)]
  201. },
  202. chioseSound (activeSound) {
  203. // 同步数据
  204. this.activeSound = [...new Set(activeSound)];
  205. let newSoundList = []
  206. for (let i in this.childSoundList) {
  207. if (this.activeSound.includes(this.childSoundList[i].id)) {
  208. newSoundList.push(this.initSound(this.childSoundList[i]))
  209. }
  210. }
  211. let idList = this.activeSoundList.map(item => {
  212. return item.id
  213. })
  214. for (let x in newSoundList) {
  215. const indexof = idList.indexOf(newSoundList[x]?.id)
  216. if (indexof > -1) {
  217. newSoundList[x] = this.activeSoundList[indexof]
  218. }
  219. }
  220. this.activeSoundList = newSoundList
  221. this.soundVisible = false
  222. },
  223. initSound (item) {
  224. let obj = {
  225. id: item.id,
  226. sound: item.name,
  227. expectedStudentNum: item.expectedStudentNum,
  228. chioseMusic: [{ musical: '', type: ["GROUP"], groupPrice: 0, borrowPrice: 1500 }],
  229. markChioseList: [],
  230. goodsList: [],
  231. markList: [],
  232. }
  233. return obj
  234. },
  235. changeActiveSound (val) {
  236. this.activeSoundList.forEach(item => {
  237. if (item.id == val) {
  238. if (item.goodsList.length < 1 || item.markList.length < 1) {
  239. getSubjectGoods({ subjectId: item.id, chargeTypeId: this.topfor.type }).then(res => {
  240. if (res.code == 200) {
  241. let goodList = []
  242. let markList = []
  243. res.data.forEach(item => {
  244. if (item.type == 'INSTRUMENT') {
  245. goodList.push(item)
  246. } else if (item.type == 'ACCESSORIES') {
  247. markList.push(item)
  248. }
  249. })
  250. item.goodsList = goodList;
  251. item.markList = markList;
  252. }
  253. });
  254. }
  255. }
  256. })
  257. },
  258. lookMusic () {
  259. },
  260. goback () {
  261. this.$emit("chiosetab", 0);
  262. },
  263. submitInfo () {
  264. // 计划招生人数
  265. // 可选乐器
  266. // 教辅
  267. this.activeSoundList.forEach(item => {
  268. if (!item.expectedStudentNum) {
  269. this.$message.error(`请填写${item.sound}的预计招生人数`)
  270. return
  271. }
  272. if (!item.chioseMusic[0].musical) {
  273. this.$message.error(`请至少一个选择${item.sound}的可选乐器`)
  274. return
  275. }
  276. })
  277. // 新建团
  278. let obj = {}
  279. if (this.teamStatus == "newTeam") {
  280. this.initCreateTeam(obj)
  281. }
  282. // 初始化声部
  283. obj.musicGroupSubjectGoodsGroups = [];
  284. obj.musicGroupSubjectPlans = [];
  285. this.activeSoundList.forEach(active => {
  286. // 格式化声部数据
  287. let item = {
  288. expectedStudentNum: active.expectedStudentNum,
  289. subName: active.sound,
  290. subjectId: active.id
  291. };
  292. obj.musicGroupSubjectPlans.push(item);
  293. // 格式化商品数据 chioseMusic: [{ musical: '', type: ["GROUP"], groupPrice: 0, borrowPrice: 1500 }],
  294. active.chioseMusic.forEach(music => {
  295. let goodsItem = null;
  296. let depositFee = music.borrowPrice
  297. let price = music.groupPrice
  298. let index = findIndex(active.goodsList, (o) => {
  299. return o.id == music.musical
  300. })
  301. if (index != -1) {
  302. goodsItem = active.goodsList[index]
  303. }
  304. let kitGroupPurchaseTypeJson = {}
  305. music.type.forEach(type => {
  306. kitGroupPurchaseTypeJson[type] = 0
  307. })
  308. kitGroupPurchaseTypeJson = JSON.stringify(kitGroupPurchaseTypeJson)
  309. if (goodsItem) {
  310. let some = {
  311. subjectId: active.id,
  312. type: "INSTRUMENT",
  313. goodsIdList: music.musical,
  314. name: goodsItem.name,
  315. kitGroupPurchaseTypeJson,
  316. depositFee,
  317. price
  318. };
  319. obj.musicGroupSubjectGoodsGroups.push(some);
  320. }
  321. })
  322. // 格式化辅件
  323. // markChioseList: [],
  324. // goodsList: [],
  325. // markList: [],
  326. active.markChioseList.forEach(ass => {
  327. let index = findIndex(active.markList, (o) => {
  328. return o.id == ass
  329. })
  330. let goodsItem = null;
  331. if (index != -1) {
  332. goodsItem = active.markList[index]
  333. }
  334. if (goodsItem) {
  335. let some = {
  336. subjectId: active.id,
  337. type: "ACCESSORIES",
  338. goodsIdList: ass,
  339. name: goodsItem.name,
  340. price: goodsItem.groupPurchasePrice,
  341. };
  342. obj.musicGroupSubjectGoodsGroups.push(some);
  343. }
  344. })
  345. if (this.teamStatus == 'newTeam') {
  346. createTeam(obj).then(res => {
  347. if (res.code == 200) {
  348. // 成功 跳转到乐团报名详情
  349. }
  350. });
  351. } else {
  352. obj.musicGroupId = this.teamid
  353. obj.musicGroupStatus = "DRAFT"
  354. updateSubjectInfo(obj).then(res => {
  355. if (res.code == 200) {
  356. this.$message.success("提交成功");
  357. }
  358. });
  359. }
  360. })
  361. },
  362. deleteRow () {
  363. if (this.checkList.length < 1) {
  364. this.$message.error('请至少勾选一个')
  365. return
  366. }
  367. for (let i = 0; i < this.activeSoundList.length; i++) {
  368. let index = this.checkList.indexOf(this.activeSoundList[i].id)
  369. if (index != -1) {
  370. this.activeSoundList.splice(i, 1)
  371. this.activeSound.splice(i, 1)
  372. i--
  373. }
  374. }
  375. this.checkList = []
  376. },
  377. allin () {
  378. this.checkList = []
  379. this.activeSoundList.forEach((item, index) => {
  380. this.checkList.push(item.id)
  381. })
  382. },
  383. initCreateTeam (obj) {
  384. let enrollClasses;
  385. this.topfor.startClass
  386. ? (enrollClasses = this.topfor.startClass.join(","))
  387. : (enrollClasses = null);
  388. obj.musicGroup = {
  389. settlementType: this.topfor.salary,
  390. applyExpireDate: dayjs(this.topfor.time).format('YYYY-MM-DD HH:mm:ss'),
  391. chargeTypeId: this.topfor.type,
  392. cooperationOrganId: this.topfor.school,
  393. teamTeacherId: this.topfor.boss,
  394. educationalTeacherId: this.topfor.teacher,
  395. enrollClasses,
  396. name: this.topfor.name,
  397. organId: this.topfor.section,
  398. paymentPattern: this.topfor.paymentPattern,
  399. paymentValidStartDate: this.topfor.paymentValidStartDate ? dayjs(this.topfor.paymentValidStartDate).format('YYYY-MM-DD') : this.topfor.paymentValidStartDate,
  400. paymentValidEndDate: this.topfor.paymentValidEndDate ? dayjs(this.topfor.paymentValidEndDate).format('YYYY-MM-DD') : this.topfor.paymentValidEndDate,
  401. // paymentMonths:obj.months 有待确认
  402. schoolId: this.topfor.address,
  403. expectStartGroupDate: this.topfor.startTime,
  404. isClassroomLessons: this.topfor.isClass,
  405. status,
  406. ownershipType: this.topfor.ownershipType,
  407. repairUserId: this.topfor.repairUserId,
  408. feeType: this.topfor.feeType
  409. };
  410. return obj
  411. }
  412. },
  413. computed: {
  414. PlannedCount () {
  415. let Count = 0;
  416. if (this.activeSoundList.length > 0) {
  417. for (let item in this.activeSoundList) {
  418. Count += parseInt(this.activeSoundList[item]?.expectedStudentNum) || 0;
  419. }
  420. }
  421. return Count;
  422. }, chioseSoundNum () {
  423. return this.activeSoundList.length;
  424. },
  425. }
  426. }
  427. </script>
  428. <style lang="scss" scoped>
  429. .topMsg {
  430. padding: 0 25px;
  431. display: flex;
  432. flex-direction: row;
  433. justify-content: flex-start;
  434. font-size: 14px;
  435. color: #444;
  436. margin-bottom: 20px;
  437. }
  438. .soundBtnWrap {
  439. margin-bottom: 20px;
  440. }
  441. /deep/.el-collapse-item__header {
  442. background-color: #edeef0;
  443. }
  444. .coreItemTitle {
  445. background-color: #edeef0;
  446. height: 46px;
  447. line-height: 46px;
  448. padding: 0 20px;
  449. }
  450. .coreItem {
  451. padding: 25px 0 0;
  452. }
  453. .coreItemRow {
  454. padding: 0 20px;
  455. line-height: 50px;
  456. display: flex;
  457. flex-direction: row;
  458. align-items: center;
  459. p {
  460. margin-right: 10px;
  461. }
  462. .title {
  463. width: 100px;
  464. text-align: right;
  465. }
  466. }
  467. .marginLeft10 {
  468. margin-left: 10px;
  469. }
  470. /deep/.el-collapse-item__header {
  471. border-bottom: 1px solid #fff;
  472. }
  473. .btnWrap {
  474. margin-top: 40px;
  475. .PrevBtn {
  476. background-color: #13817a;
  477. width: 120px;
  478. }
  479. .submitBtn {
  480. background-color: #13817a;
  481. width: 120px;
  482. }
  483. }
  484. </style>