soundSetCore.vue 15 KB

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