user-pay-form.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. <template>
  2. <div>
  3. <el-alert
  4. title="课程信息设置"
  5. :closable="false"
  6. class="alert"
  7. v-if="paymentTypeString !== 'SPAN_GROUP_CLASS_ADJUST'&&courseViewType!=1"
  8. type="info"
  9. >
  10. </el-alert>
  11. <userBaseinfo
  12. :form.sync="form"
  13. :isCommon="isCommon"
  14. v-if="paymentTypeString !== 'SPAN_GROUP_CLASS_ADJUST'"
  15. :isUserType="isUserType"
  16. @getCharges="getCharges"
  17. @changeActive="changeActive"
  18. :typeList="typeList"
  19. :charges="charges"
  20. :rowDetail="rowDetail"
  21. :chargeTypeName="chargeTypeName"
  22. :paymentType="paymentType"
  23. :courseViewType="courseViewType"
  24. ref="base"
  25. />
  26. <template v-if="paymentTypeString === 'SPAN_GROUP_CLASS_ADJUST'">
  27. <el-alert
  28. title="加课信息设置"
  29. :closable="false"
  30. class="alert"
  31. type="info"
  32. >
  33. </el-alert>
  34. <extraClassUser
  35. :form.sync="eclassuser"
  36. ref="eclass"
  37. :isUserType="isUserType"
  38. :courseUnitPriceSettingsByType="
  39. organizationCourseUnitPriceSettingsByType
  40. "
  41. @priceChange="priceChange"
  42. :clearable="true"
  43. @moneyChange="syncAllMoney"
  44. />
  45. </template>
  46. <template v-else-if="!isCommon">
  47. <el-alert
  48. title="加课信息设置"
  49. :closable="false"
  50. class="alert"
  51. type="info"
  52. >
  53. </el-alert>
  54. <extraClass
  55. :form.sync="eclass"
  56. ref="eclass"
  57. @create="addExtraClass"
  58. @remove="removeExtraClass"
  59. :isUserType="isUserType"
  60. :courseUnitPriceSettingsByType="
  61. organizationCourseUnitPriceSettingsByType
  62. "
  63. @priceChange="priceChange"
  64. :clearable="true"
  65. @moneyChange="syncAllMoney"
  66. />
  67. </template>
  68. <extraClass
  69. v-else-if="(!isCommon && eclass.length) || isCommon"
  70. :form="eclass"
  71. ref="eclass"
  72. :isCommon="isCommon"
  73. @create="addExtraClass"
  74. @remove="removeExtraClass"
  75. @moneyChange="syncAllMoney"
  76. :courseUnitPriceSettingsByType="organizationCourseUnitPriceSettingsByType"
  77. :isUserType="isUserType"
  78. :isDisabled="
  79. form.leixing === '1' || form.leixing === '2' || paymentType == '0'
  80. "
  81. />
  82. <template>
  83. <el-alert
  84. title="会员设置"
  85. :closable="false"
  86. class="alert"
  87. style="margin-top: 20px"
  88. type="info"
  89. v-if="courseViewType == 1&&paymentType !== undefined"
  90. >
  91. </el-alert>
  92. <memberSetting
  93. v-if="courseViewType == 1&&paymentType !== undefined"
  94. :form="memberForm"
  95. :isUserType="isUserType"
  96. :organId="baseInfo.organId"
  97. :showTime="false"
  98. />
  99. <el-alert title="缴费设置" :closable="false" class="alert" type="info">
  100. </el-alert>
  101. <el-form ref="payment" :model="payment">
  102. <el-form-item
  103. label-width="160px"
  104. label="系统缴费金额"
  105. v-if="
  106. !paymentType &&
  107. type == 'user' &&
  108. (courseViewType == 2 || courseViewType == 3)
  109. "
  110. >
  111. <el-input :disabled="true" v-model="cloudFee"></el-input>
  112. </el-form-item>
  113. <el-form-item
  114. label-width="160px"
  115. label="缴费方式"
  116. prop="paymentPattern"
  117. :rules="[
  118. { required: true, message: '请选择缴费方式', trigger: 'change' },
  119. ]"
  120. >
  121. <el-select
  122. style="width: 100% !important"
  123. v-model="payment.paymentPattern"
  124. placeholder="请选择缴费方式"
  125. :disabled="courseViewType == 1&&paymentType !== undefined"
  126. >
  127. <el-option
  128. v-for="item in paymentPatternTypeOptions"
  129. :key="item.value"
  130. :label="item.label"
  131. :value="item.value"
  132. >
  133. </el-option>
  134. </el-select>
  135. </el-form-item>
  136. </el-form>
  137. <template
  138. v-if="isMulticycle && paymentTypeString !== 'SPAN_GROUP_CLASS_ADJUST'"
  139. >
  140. <el-collapse :value="collapse" @change="collapseChange">
  141. <el-collapse-item
  142. v-for="(item, index) in cycles"
  143. :key="index"
  144. :name="index"
  145. >
  146. <template slot="title">
  147. <div class="collapse-title">
  148. <span>缴费周期 {{ index + 1 }}</span>
  149. <i
  150. v-if="cycles.length > 1"
  151. class="el-icon-circle-close"
  152. @click.stop="removeCycle(index)"
  153. ></i>
  154. </div>
  155. </template>
  156. <paymentCycle
  157. ref="cycles"
  158. :form="item"
  159. :paymentType="paymentType"
  160. :hidePaymentPattern="true"
  161. :isCommon="isCommon"
  162. :isUserType="isUserType"
  163. :isDisabled="
  164. form.leixing === '1' ||
  165. form.leixing === '2' ||
  166. paymentType == '0'
  167. "
  168. />
  169. </el-collapse-item>
  170. </el-collapse>
  171. <el-button
  172. icon="el-icon-circle-plus-outline"
  173. plain
  174. type="info"
  175. size="small"
  176. style="width: 100%; margin: 20px 0"
  177. @click="addCycle"
  178. >新增缴费周期</el-button
  179. >
  180. </template>
  181. <paymentCycle
  182. ref="cycle"
  183. :form.sync="cycle"
  184. :isCommon="isCommon"
  185. :hidePaymentPattern="true"
  186. :isUserType="isUserType"
  187. :isDisabled="
  188. form.leixing === '1' || form.leixing === '2' || paymentType == '0'
  189. "
  190. :courseViewType="courseViewType"
  191. v-else
  192. />
  193. </template>
  194. <el-alert title="其它" :closable="false" class="alert" type="info">
  195. </el-alert>
  196. <otherform :form="other" ref="other" />
  197. <div slot="footer" class="dialog-footer">
  198. <el-button @click="$listeners.close">取 消</el-button>
  199. <el-button type="primary" @click="submit">确认</el-button>
  200. </div>
  201. <el-dialog
  202. :title="nextTitle"
  203. :visible.sync="nextVisible"
  204. width="600px"
  205. append-to-body
  206. >
  207. <classrooms @close="closeNext" />
  208. </el-dialog>
  209. </div>
  210. </template>
  211. <script>
  212. import {
  213. chargeTypeList,
  214. musicGroupOrganizationCourseSettingsQueryPage,
  215. } from "@/api/specialSetting";
  216. import { getMusicGroupPaymentCalenderDetail } from "@/api/buildTeam";
  217. import {
  218. musicGroupPaymentCalenderAdd,
  219. musicGroupPaymentCalenderDetailBatchUpdate,
  220. queryByMusicGroupOrganizationCourseSettingsId,
  221. musicGroupPaymentCalenderView,
  222. } from "../api";
  223. import { paymentPatternType } from "@/constant";
  224. import { getTimes, objectToOptions } from "@/utils";
  225. import userBaseinfo from "./user-baseinfo";
  226. import paymentCycle from "./payment-cycle";
  227. import extraClass from "./extra-class";
  228. import extraClassUser from "./extra-class-user";
  229. import classrooms from "./classrooms";
  230. import otherform from "./other";
  231. import memberSetting from "./member-setting";
  232. import baseInfoVue from "../../teamDetail/components/baseInfo.vue";
  233. import merge from "webpack-merge";
  234. import numeral from "numeral";
  235. import { organizationCloudTeacherFeeQueryPage } from "@/api/specialSetting";
  236. const paymentTypeFormat = {
  237. 0: "MUSIC_APPLY",
  238. 1: "MUSIC_RENEW",
  239. 2: "ADD_COURSE",
  240. 3: "ADD_STUDENT",
  241. 4: "SPAN_GROUP_CLASS_ADJUST",
  242. };
  243. export default {
  244. props: [
  245. "type",
  246. "musicGroupId",
  247. "baseInfo",
  248. "paymentType",
  249. "rowDetail",
  250. "organizationCourseUnitPriceSettings",
  251. ],
  252. components: {
  253. userBaseinfo,
  254. paymentCycle,
  255. extraClass,
  256. extraClassUser,
  257. classrooms,
  258. otherform,
  259. memberSetting,
  260. },
  261. data() {
  262. return {
  263. options: [],
  264. form: {
  265. payUserType: this.type === "user" ? "STUDENT" : "SCHOOL",
  266. leixing: "1",
  267. musicGroupOrganizationCourseSettingId: null,
  268. },
  269. chargeTypeName: "",
  270. other: {},
  271. cycles: [{}],
  272. cycle: {},
  273. eclass: [],
  274. eclassuser: [],
  275. collapse: [0],
  276. nextVisible: false,
  277. typeList: [],
  278. charges: [],
  279. studentIds: "",
  280. payment: {
  281. paymentPattern: null,
  282. },
  283. viewDetail: null,
  284. organizationCourseUnitPriceSettingsByType: {},
  285. paymentPatternTypeOptions: objectToOptions(paymentPatternType),
  286. cloudFee: "",
  287. courseViewType: "",
  288. memberForm: {
  289. memberRankSettingId: "",
  290. memberValidDate: "",
  291. memberPaymentAmount: "",
  292. originalMemberPaymentAmount: "",
  293. paymentDate: [],
  294. },
  295. };
  296. },
  297. computed: {
  298. musicGroup() {
  299. return this.baseInfo?.musicGroup;
  300. },
  301. isCommon() {
  302. return this.form.leixing === "1";
  303. },
  304. isDisabled() {
  305. return this.form.leixing === "1" || String(this.paymentType) === "0";
  306. },
  307. isUserType() {
  308. return this.type === "user";
  309. },
  310. nextTitle() {
  311. return this.isCommon ? "乐团课程-班级选择" : "临时加课-班级选择";
  312. },
  313. chargesById() {
  314. const data = {};
  315. for (const item of this.charges) {
  316. data[item.id] = item;
  317. }
  318. return data;
  319. },
  320. paymentAmountDisabled() {
  321. return (
  322. (this.isUserType || (this.isCommon && this.isUserType)) &&
  323. this.isDisabled
  324. );
  325. },
  326. isMulticycle() {
  327. let editMulticycle = false;
  328. let paymentType = "";
  329. if (this.viewDetail) {
  330. const { musicGroupPaymentCalenders, auditDto } = this.viewDetail;
  331. paymentType = musicGroupPaymentCalenders[0]?.paymentType;
  332. editMulticycle =
  333. musicGroupPaymentCalenders.length > 1 || paymentType != "ADD_COURSE";
  334. if (editMulticycle) {
  335. this.cycles = musicGroupPaymentCalenders.map((item) => ({
  336. paymentAmount: item.paymentAmount,
  337. paymentDate: [item?.startPaymentDate, item?.deadlinePaymentDate],
  338. paymentValid: [
  339. item?.paymentValidStartDate,
  340. item?.paymentValidEndDate,
  341. ],
  342. }));
  343. }
  344. }
  345. return (
  346. (this.payment.paymentPattern == 0 &&
  347. this.form.leixing !== "2" &&
  348. paymentType !== "ADD_COURSE") ||
  349. (this.payment.paymentPattern == 0 && editMulticycle)
  350. );
  351. },
  352. paymentTypeString() {
  353. let paymentType = "";
  354. if (this.viewDetail) {
  355. const { musicGroupPaymentCalenders } = this.viewDetail;
  356. paymentType = musicGroupPaymentCalenders[0]?.paymentType;
  357. }
  358. return paymentType;
  359. },
  360. },
  361. watch: {
  362. type() {
  363. this.$set(
  364. this.form,
  365. "payUserType",
  366. this.type === "user" ? "STUDENT" : "SCHOOL"
  367. );
  368. },
  369. baseInfo(val) {
  370. this.formatCourse();
  371. this.getCharges();
  372. },
  373. organizationCourseUnitPriceSettings() {
  374. this.formatCourse();
  375. },
  376. "form.leixing"(val) {
  377. this.cycles = [{}];
  378. this.collapse = [0];
  379. this.cycle = {};
  380. this.$set(this.form, "musicGroupOrganizationCourseSettingId", undefined);
  381. this.$set(this.cycle, "paymentAmount", undefined);
  382. if (val === "1") {
  383. this.eclass = [];
  384. } else if (val === "2") {
  385. this.eclass = [{}];
  386. }
  387. },
  388. async "form.musicGroupOrganizationCourseSettingId"(val) {
  389. // && !this.rowDetail
  390. if (val ) {
  391. try {
  392. const res = await queryByMusicGroupOrganizationCourseSettingsId({
  393. id: val,
  394. });
  395. this.eclass = res.data.filter((item) => {
  396. return !item.isStudentOptional || this.paymentType !== undefined;
  397. }) || [{}];
  398. this.syncAllMoney();
  399. } catch (error) {}
  400. }
  401. },
  402. "payment.paymentPattern"() {
  403. this.syncAllMoney();
  404. },
  405. },
  406. mounted() {
  407. this.formatCourse();
  408. this.init();
  409. },
  410. activated() {
  411. this.formatCourse();
  412. this.init();
  413. },
  414. methods: {
  415. async init() {
  416. let organId = this.baseInfo?.musicGroup?.organId;
  417. this.courseViewType = this.baseInfo?.musicGroup?.courseViewType;
  418. if(this.courseViewType == 1){
  419. this.$set(this.form,'leixing',2)
  420. // console.log('paymentType',this.paymentType)
  421. this.addExtraClass()
  422. }
  423. // 如果为学员缴费且是乐团缴费则显示云教练的价格
  424. if (
  425. !this.paymentType &&
  426. this.type == "user" &&
  427. organId &&
  428. (this.courseViewType == 2 || this.courseViewType == 3)
  429. ) {
  430. try {
  431. const res = await organizationCloudTeacherFeeQueryPage({ organId });
  432. this.courseViewType == 2
  433. ? (this.cloudFee = res.data.rows[0].price)
  434. : (this.cloudFee = res.data.rows[0].plusPrice);
  435. } catch (e) {
  436. console.log(e);
  437. }
  438. // 获取乐团云教练费用
  439. // this.cloudFee
  440. }
  441. this.getCharges();
  442. if (this.rowDetail) {
  443. console.log("this.rowDetail", this.rowDetail);
  444. for (const key in paymentTypeFormat) {
  445. if (paymentTypeFormat.hasOwnProperty(key)) {
  446. const item = paymentTypeFormat[key];
  447. if (item === this.rowDetail.paymentType) {
  448. this.paymentType = key;
  449. }
  450. }
  451. }
  452. this.$set(
  453. this.other,
  454. "isGiveMusicNetwork",
  455. this.rowDetail.isGiveMusicNetwork
  456. );
  457. this.$set(this.other, "memo", this.rowDetail.memo);
  458. try {
  459. const res = await musicGroupPaymentCalenderView({
  460. musicGroupId: this.musicGroupId,
  461. batchNo: this.rowDetail.batchNo,
  462. });
  463. this.viewDetail = res.data;
  464. const firstPayment = res.data.musicGroupPaymentCalenders[0] || {};
  465. this.eclass = (
  466. res.data.musicGroupPaymentCalenderCourseSettings || []
  467. ).filter((item) => {
  468. return !item.isStudentOptional || this.paymentType !== undefined;
  469. });
  470. this.eclassuser =
  471. res.data.musicGroupPaymentCalenderStudentDetails.map((item) => {
  472. if (this.paymentTypeString === "SPAN_GROUP_CLASS_ADJUST") {
  473. return {
  474. ...item,
  475. courseOriginalPrice: item.masterSubCoursePrice,
  476. };
  477. }
  478. return item;
  479. });
  480. this.$set(
  481. this.payment,
  482. "paymentPattern",
  483. String(this.viewDetail.auditDto?.paymentPattern)
  484. );
  485. // 添加会员缴费信息
  486. this.$set(
  487. this.memberForm,
  488. "memberRankSettingId",
  489. this.viewDetail.musicGroupPaymentCalenders[0].memberRankSettingId||null
  490. );
  491. this.$set(
  492. this.memberForm,
  493. "memberValidDate",
  494. this.viewDetail.musicGroupPaymentCalenders[0].memberValidDate||null
  495. );
  496. this.$set(
  497. this.memberForm,
  498. "memberPaymentAmount",
  499. this.viewDetail.musicGroupPaymentCalenders[0].memberPaymentAmount
  500. );
  501. this.$set(
  502. this.memberForm,
  503. "originalMemberPaymentAmount",
  504. this.viewDetail.musicGroupPaymentCalenders[0]
  505. .originalMemberPaymentAmount
  506. );
  507. if (this.$refs.cycle) {
  508. this.$set(
  509. this.cycle,
  510. "paymentPattern",
  511. firstPayment.paymentPattern + ""
  512. );
  513. let arr = [
  514. firstPayment.paymentValidStartDate,
  515. firstPayment.paymentValidEndDate,
  516. ];
  517. // paymentDate startPaymentDate deadlinePaymentDate
  518. this.$set(this.cycle, "paymentDate", [
  519. firstPayment.startPaymentDate,
  520. firstPayment.deadlinePaymentDate,
  521. ]);
  522. this.$set(this.cycle, "paymentValid", arr);
  523. }
  524. this.studentIds = firstPayment.studentIds;
  525. this.$set(
  526. this.form,
  527. "musicGroupOrganizationCourseSettingId",
  528. res.data.auditDto?.musicGroupOrganizationCourseSettingsId
  529. );
  530. this.syncAllMoney();
  531. } catch (error) {}
  532. }
  533. },
  534. formatCourse() {
  535. const organId = this.musicGroup?.organId;
  536. const chargeTypeId = this.musicGroup?.chargeTypeId;
  537. const _ = {};
  538. const list = (this.organizationCourseUnitPriceSettings || []).filter(
  539. (item) =>
  540. organId &&
  541. organId == item.organId &&
  542. chargeTypeId &&
  543. chargeTypeId == item.chargeTypeId
  544. );
  545. for (const item of list) {
  546. _[item.courseType] = item;
  547. }
  548. this.organizationCourseUnitPriceSettingsByType = _;
  549. return _;
  550. },
  551. priceChange(item, index) {
  552. const _ = [...this.eclass];
  553. const active =
  554. this.organizationCourseUnitPriceSettingsByType[item.courseType] || {};
  555. const price = Math.round(
  556. numeral(active.unitPrice || 1)
  557. .multiply(item.courseTotalMinuties || 1)
  558. .value()
  559. );
  560. item.courseCurrentPrice = price;
  561. item.courseOriginalPrice = price;
  562. _[index] = item;
  563. this.eclass = [..._];
  564. this.syncAllMoney();
  565. },
  566. syncAllMoney() {
  567. if (this.paymentTypeString === "SPAN_GROUP_CLASS_ADJUST") {
  568. const money =
  569. this.viewDetail?.musicGroupPaymentCalenders[0].paymentAmount;
  570. this.$set(this.cycle, "paymentAmount", money);
  571. return money;
  572. }
  573. let money = 0;
  574. let first = 0;
  575. let other = 0;
  576. let classs =
  577. this.paymentTypeString === "SPAN_GROUP_CLASS_ADJUST"
  578. ? this.eclassuser
  579. : this.eclass;
  580. for (const item of classs) {
  581. money += item.courseCurrentPrice;
  582. if (this.cycles && this.cycles.length) {
  583. if (item.isStudentOptional) {
  584. first += item.courseCurrentPrice;
  585. } else {
  586. const floorMoney = Math.floor(
  587. item.courseCurrentPrice / this.cycles.length
  588. );
  589. const remainder = item.courseCurrentPrice % this.cycles.length;
  590. first += floorMoney + remainder;
  591. other += floorMoney;
  592. }
  593. }
  594. }
  595. if (this.cycles && this.cycles.length) {
  596. this.cycles = this.cycles.map((item, index) => {
  597. return {
  598. ...item,
  599. paymentAmount: index === 0 ? first : other,
  600. };
  601. });
  602. }
  603. // if (!money) {
  604. // this.$set(this.cycle, "paymentAmount", undefined);
  605. // } else {
  606. this.$set(this.cycle, "paymentAmount", money);
  607. // }
  608. return money;
  609. },
  610. async getChargeTypeList() {
  611. try {
  612. const res = await chargeTypeList({
  613. row: 9999,
  614. });
  615. this.typeList = res.data.rows;
  616. } catch (error) {}
  617. },
  618. async getCharges() {
  619. const organId = this.musicGroup?.organId;
  620. const chargeTypeId = this.musicGroup?.chargeTypeId;
  621. this.chargeTypeName = this.musicGroup?.chargeTypeName;
  622. try {
  623. const res = await musicGroupOrganizationCourseSettingsQueryPage({
  624. row: 9999,
  625. chargeTypeId,
  626. organId,
  627. });
  628. const ids = res.data.rows.map((item) => item.id);
  629. if (!ids.includes(this.form.musicGroupOrganizationCourseSettingId)) {
  630. this.$set(this.form, "musicGroupOrganizationCourseSettingId", null);
  631. }
  632. this.charges = res.data.rows;
  633. } catch (error) {}
  634. },
  635. addExtraClass() {
  636. this.eclass.push({});
  637. },
  638. removeExtraClass(index) {
  639. this.eclass[index] = null;
  640. this.eclass = this.eclass.filter((item) => !!item);
  641. },
  642. addCycle() {
  643. this.cycles.push({});
  644. this.collapse.push(this.cycles.length - 1);
  645. this.syncAllMoney();
  646. },
  647. removeCycle(index) {
  648. this.cycles[index] = null;
  649. this.cycles = this.cycles.filter((item) => !!item);
  650. if (this.collapse.includes(index)) {
  651. this.collapse.splice(index, 1);
  652. this.collapse = this.collapse.map((item, _index) =>
  653. _index - 1 >= index ? item-- : item
  654. );
  655. }
  656. this.syncAllMoney();
  657. },
  658. collapseChange(val) {
  659. this.collapse = val;
  660. },
  661. closeNext() {
  662. this.nextVisible = false;
  663. },
  664. getForms() {
  665. const { $refs: refs } = this;
  666. return [
  667. refs.base,
  668. refs.eclass,
  669. refs.cycle,
  670. ...(refs.cycles || []),
  671. refs.other,
  672. refs.payment,
  673. ]
  674. .filter((item) => !!item)
  675. .map((item) => item.$refs.form || item);
  676. },
  677. changeActive(val) {
  678. if (this.$listeners.changeActive) {
  679. this.$listeners.changeActive(val);
  680. }
  681. },
  682. async submit() {
  683. const forms = this.getForms();
  684. const valided = [];
  685. for (const form of forms) {
  686. form.validate((valid) => {
  687. if (valid) {
  688. valided.push(form);
  689. }
  690. });
  691. }
  692. if (this.eclass.length < 1 && this.eclassuser.length < 1&&this.courseViewType !=1) {
  693. return this.$message.error("请至少选择一条加课信息");
  694. }
  695. if (valided.length === forms.length) {
  696. const { leixing, ...rest } = {
  697. ...this.form,
  698. ...this.other,
  699. paymentPattern: this.payment.paymentPattern,
  700. musicGroupPaymentDateRangeList: [
  701. ...this.cycles.map((item) => {
  702. const { paymentDate, paymentValid, ...other } = item;
  703. return {
  704. ...other,
  705. ...getTimes(paymentDate, [
  706. "startPaymentDate",
  707. "deadlinePaymentDate",
  708. ]),
  709. ...getTimes(paymentValid, [
  710. "paymentValidStartDate",
  711. "paymentValidEndDate",
  712. ]),
  713. };
  714. }),
  715. ],
  716. musicGroupPaymentCalenderCourseSettingsList: this.eclass,
  717. musicGroupPaymentCalenderStudentDetails: this.eclassuser,
  718. };
  719. if (this.$refs.cycle) {
  720. const { paymentDate, paymentValid, ...other } = this.cycle;
  721. rest.musicGroupPaymentDateRangeList = [
  722. {
  723. ...other,
  724. ...getTimes(paymentDate, [
  725. "startPaymentDate",
  726. "deadlinePaymentDate",
  727. ]),
  728. ...getTimes(paymentValid, [
  729. "paymentValidStartDate",
  730. "paymentValidEndDate",
  731. ]),
  732. },
  733. ];
  734. }
  735. const data = {
  736. ...rest,
  737. ...this.memberForm,
  738. isGiveMusicNetwork: false,
  739. studentIds: this.studentIds,
  740. paymentType:
  741. paymentTypeFormat[
  742. this.paymentType == 0 ? this.paymentType : leixing
  743. ],
  744. musicGroupId: this.musicGroupId,
  745. };
  746. const info = this.viewDetail?.musicGroupPaymentCalenders[0];
  747. if (info && this.viewDetail?.auditDto.paymentType === "ADD_STUDENT") {
  748. data.attribute1 = info.attribute1;
  749. }
  750. // courseViewType == 1&&paymentType !== undefined
  751. let hasCourseFee = false;
  752. for (const item of data.musicGroupPaymentCalenderCourseSettingsList) {
  753. if (item.courseCurrentPrice > 0 || item.isStudentOptional == true) {
  754. hasCourseFee = true;
  755. break;
  756. }
  757. }
  758. // console.log(this.baseInfo?.musicGroup?.courseViewType, this.paymentType, hasCourseFee, this.type)
  759. if (
  760. (this.baseInfo?.musicGroup?.courseViewType == 2 ||
  761. this.baseInfo?.musicGroup?.courseViewType == 3) &&
  762. this.paymentType == 0 &&
  763. hasCourseFee &&
  764. this.type === "user"
  765. ) {
  766. this.$message.error(
  767. "报名缴费云教练收费模式课程费用不得大于0且不可选"
  768. );
  769. return;
  770. }
  771. if (!this.rowDetail?.batchNo) {
  772. try {
  773. const res = await musicGroupPaymentCalenderAdd(data);
  774. if (this.$route.query.team_status == "PRE_BUILD_FEE") {
  775. this.$message.success("创建成功");
  776. this.$store.dispatch("delVisitedViews", this.$route);
  777. this.$router.push({
  778. path: "/teamList",
  779. });
  780. }
  781. this.$listeners.close();
  782. this.$listeners.submited(res.data);
  783. // 在这里
  784. } catch (error) {}
  785. } else {
  786. try {
  787. data.batchNo = this.rowDetail.batchNo;
  788. // 缴费类型无法修改,按照之前覆盖
  789. data.paymentType =
  790. this.viewDetail.musicGroupPaymentCalenders[0]?.paymentType;
  791. const res = await musicGroupPaymentCalenderDetailBatchUpdate(data);
  792. this.$listeners.close();
  793. this.$listeners.submited(res.data);
  794. if (this.$route.query.type == "teamDraft") {
  795. this.$router.push({
  796. query: merge(this.$route.query, { type: "feeAudit" }),
  797. });
  798. }
  799. } catch (error) {}
  800. }
  801. }
  802. },
  803. },
  804. };
  805. </script>
  806. <style lang="less" scoped>
  807. .dialog-footer {
  808. margin-top: 20px;
  809. display: block;
  810. text-align: right;
  811. }
  812. .alert {
  813. margin-bottom: 10px;
  814. }
  815. .collapse-title {
  816. display: flex;
  817. justify-content: space-between;
  818. align-items: center;
  819. width: 100%;
  820. .el-icon-circle-close {
  821. font-size: 16px;
  822. margin-right: 10px;
  823. }
  824. }
  825. /deep/ .el-collapse-item__wrap {
  826. padding-top: 20px;
  827. }
  828. </style>