user-pay-form.vue 25 KB

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