soundSetCore.vue 17 KB

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