user-pay-form.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div>
  3. <el-alert title="课程信息设置"
  4. :closable="false"
  5. class="alert"
  6. type="info">
  7. </el-alert>
  8. <userBaseinfo :form.sync="form"
  9. :isCommon="isCommon"
  10. :isUserType="isUserType"
  11. @getCharges="getCharges"
  12. @changeActive="$listeners.changeActive"
  13. :typeList="typeList"
  14. :charges="charges"
  15. :chargeTypeName="chargeTypeName"
  16. :paymentType="paymentType"
  17. ref="base" />
  18. <template v-if="!isCommon">
  19. <el-alert title="加课信息设置"
  20. :closable="false"
  21. class="alert"
  22. type="info">
  23. </el-alert>
  24. <extraClass :form.sync="eclass"
  25. ref="eclass"
  26. :organizationCourseUnitPriceSettings="organizationCourseUnitPriceSettings"
  27. @create="addExtraClass"
  28. @remove="removeExtraClass"
  29. @priceChange="priceChange"
  30. @moneyChange="syncAllMoney" />
  31. </template>
  32. <extraClass v-else-if="(!isCommon && eclass.length) || isCommon"
  33. :form="eclass"
  34. ref="eclass"
  35. :isCommon="isCommon"
  36. @create="addExtraClass"
  37. @remove="removeExtraClass"
  38. @moneyChange="syncAllMoney"
  39. :isUserType="isUserType"
  40. :isDisabled="form.leixing === '1' || paymentType == '0'" />
  41. <template>
  42. <el-alert title="缴费设置"
  43. :closable="false"
  44. class="alert"
  45. type="info">
  46. </el-alert>
  47. <paymentCycle ref="cycle"
  48. :isUserType="isUserType"
  49. :form.sync="cycle"
  50. :isCommon="isCommon"
  51. :isDisabled="form.leixing === '1' || paymentType == '0'" />
  52. </template>
  53. <el-alert title="其它"
  54. :closable="false"
  55. class="alert"
  56. type="info">
  57. </el-alert>
  58. <otherform :form="other"
  59. ref="other" />
  60. <div slot="footer"
  61. class="dialog-footer">
  62. <el-button @click="$listeners.close">取 消</el-button>
  63. <el-button type="primary"
  64. @click="submit">确认</el-button>
  65. </div>
  66. <el-dialog :title="nextTitle"
  67. :visible.sync="nextVisible"
  68. width="600px"
  69. append-to-body>
  70. <classrooms @close="closeNext" />
  71. </el-dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import {
  76. chargeTypeList,
  77. musicGroupOrganizationCourseSettingsQueryPage,
  78. } from "@/api/specialSetting";
  79. import {
  80. musicGroupPaymentCalenderAdd,
  81. musicGroupPaymentCalenderDetailBatchUpdate,
  82. queryByMusicGroupOrganizationCourseSettingsId,
  83. } from "../api";
  84. import { getTimes } from "@/utils";
  85. import userBaseinfo from "./user-baseinfo";
  86. import paymentCycle from "./payment-cycle";
  87. import extraClass from "./extra-class";
  88. import classrooms from "./classrooms";
  89. import otherform from "./other";
  90. import baseInfoVue from '../../teamDetail/components/baseInfo.vue';
  91. const paymentTypeFormat = {
  92. 0: "MUSIC_APPLY",
  93. 1: "MUSIC_RENEW",
  94. 2: "ADD_COURSE",
  95. 3: "ADD_STUDENT",
  96. };
  97. export default {
  98. props: ["type", "musicGroupId", "baseInfo", "paymentType", "rowDetail", 'organizationCourseUnitPriceSettings'],
  99. components: {
  100. userBaseinfo,
  101. paymentCycle,
  102. extraClass,
  103. classrooms,
  104. otherform,
  105. },
  106. data () {
  107. return {
  108. options: [],
  109. form: {
  110. payUserType: this.type === "user" ? "STUDENT" : "SCHOOL",
  111. leixing: "1",
  112. musicGroupOrganizationCourseSettingId: null,
  113. },
  114. chargeTypeName: '',
  115. other: {},
  116. cycles: [{}],
  117. cycle: {},
  118. eclass: [],
  119. collapse: [],
  120. nextVisible: false,
  121. typeList: [],
  122. charges: [],
  123. };
  124. },
  125. computed: {
  126. isCommon () {
  127. return this.form.leixing === "1";
  128. },
  129. isDisabled () {
  130. return this.form.leixing === "1" || String(this.paymentType) === "0";
  131. },
  132. isUserType () {
  133. return this.type === "user";
  134. },
  135. nextTitle () {
  136. return this.isCommon ? "乐团课程-班级选择" : "临时加课-班级选择";
  137. },
  138. chargesById () {
  139. const data = {};
  140. for (const item of this.charges) {
  141. data[item.id] = item;
  142. }
  143. return data;
  144. },
  145. organizationCourseUnitPriceSettingsByType () {
  146. const _ = {}
  147. for (const item of this.organizationCourseUnitPriceSettings) {
  148. _[item.courseType] = item
  149. }
  150. return _
  151. }
  152. },
  153. watch: {
  154. type () {
  155. this.$set(
  156. this.form,
  157. "payUserType",
  158. this.type === "user" ? "STUDENT" : "SCHOOL"
  159. );
  160. },
  161. baseInfo (val) {
  162. this.getCharges();
  163. },
  164. "form.leixing" (val) {
  165. this.cycles = [{}];
  166. this.collapse = [0];
  167. this.cycle = {};
  168. this.$set(this.form, "musicGroupOrganizationCourseSettingId", undefined);
  169. this.$set(this.cycle, "paymentAmount", undefined);
  170. if (val === "1") {
  171. this.eclass = [];
  172. } else if (val === "2") {
  173. this.eclass = [];
  174. }
  175. },
  176. async "form.musicGroupOrganizationCourseSettingId" (val) {
  177. try {
  178. const res = await queryByMusicGroupOrganizationCourseSettingsId({
  179. id: val
  180. })
  181. this.eclass = res.data.filter(item => {
  182. return !item.isStudentOptional || this.paymentType !== undefined
  183. }) || [{}];
  184. this.syncAllMoney();
  185. } catch (error) { }
  186. },
  187. },
  188. mounted () {
  189. this.init();
  190. },
  191. activated () {
  192. this.init();
  193. },
  194. methods: {
  195. init () {
  196. this.getCharges();
  197. if (this.rowDetail) {
  198. this.form.musicGroupOrganizationCourseSettingId = this.rowDetail.musicGroupOrganizationCourseSettingId;
  199. this.$set(
  200. this.other,
  201. "isGiveMusicNetwork",
  202. this.rowDetail.isGiveMusicNetwork
  203. );
  204. this.$set(this.other, "memo", this.rowDetail.memo);
  205. }
  206. },
  207. priceChange (item, index) {
  208. const _ = [...this.eclass]
  209. const active = this.organizationCourseUnitPriceSettingsByType[item.courseType] || {}
  210. const price = Math.ceil((item.courseTotalMinuties || 1) * (active.unitPrice || 1))
  211. item.courseCurrentPrice = price
  212. item.courseOriginalPrice = price
  213. _[index] = item
  214. this.eclass = [..._]
  215. },
  216. syncAllMoney () {
  217. let money = 0;
  218. for (const item of this.eclass) {
  219. money += item.courseCurrentPrice;
  220. }
  221. if (!money) {
  222. this.$set(this.cycle, "paymentAmount", undefined);
  223. } else {
  224. this.$set(this.cycle, "paymentAmount", money);
  225. }
  226. if (this.rowDetail) {
  227. this.$set(
  228. this.cycle,
  229. "paymentPattern",
  230. this.rowDetail?.paymentPattern + ""
  231. );
  232. let arr = [
  233. this.rowDetail?.paymentValidStartDate,
  234. this.rowDetail?.paymentValidEndDate,
  235. ];
  236. // paymentDate startPaymentDate deadlinePaymentDate
  237. this.$set(this.cycle, "paymentDate", [this.rowDetail?.startPaymentDate, this.rowDetail?.deadlinePaymentDate]);
  238. this.$set(this.cycle, "paymentValid", arr);
  239. }
  240. return money;
  241. },
  242. async getChargeTypeList () {
  243. try {
  244. const res = await chargeTypeList({
  245. row: 9999,
  246. });
  247. this.typeList = res.data.rows;
  248. } catch (error) { }
  249. },
  250. async getCharges () {
  251. const organId = this.baseInfo?.musicGroup?.organId;
  252. const chargeTypeId = this.baseInfo?.musicGroup?.chargeTypeId;
  253. this.chargeTypeName = this.baseInfo?.musicGroup?.chargeTypeName;
  254. try {
  255. const res = await musicGroupOrganizationCourseSettingsQueryPage({
  256. row: 9999,
  257. chargeTypeId,
  258. organId,
  259. });
  260. this.charges = res.data.rows;
  261. } catch (error) { }
  262. },
  263. addExtraClass () {
  264. this.eclass.push({});
  265. },
  266. removeExtraClass (index) {
  267. this.eclass[index] = null;
  268. this.eclass = this.eclass.filter((item) => !!item);
  269. },
  270. addCycle () {
  271. this.cycles.push({});
  272. this.collapse.push(this.collapse.length);
  273. },
  274. removeCycle (index) {
  275. this.cycles[index] = null;
  276. this.cycles = this.cycles.filter((item) => !!item);
  277. this.collapse.pop();
  278. },
  279. collapseChange (val) {
  280. this.collapse = val;
  281. },
  282. closeNext () {
  283. this.nextVisible = false;
  284. },
  285. getForms () {
  286. const { $refs: refs } = this;
  287. return [refs.base, refs.eclass, refs.cycle, refs.other]
  288. .filter((item) => !!item)
  289. .map((item) => item.$refs.form);
  290. },
  291. async submit () {
  292. const forms = this.getForms();
  293. const valided = [];
  294. for (const form of forms) {
  295. form.validate((valid) => {
  296. if (valid) {
  297. valided.push(form);
  298. }
  299. });
  300. }
  301. if (this.eclass.length < 1) {
  302. return this.$message.error('请至少选择一条加课信息')
  303. }
  304. if (valided.length === forms.length) {
  305. const { paymentDate, paymentValid, leixing, ...rest } = {
  306. ...this.form,
  307. ...this.other,
  308. ...this.cycle,
  309. musicGroupPaymentCalenderCourseSettingsList: this.eclass,
  310. };
  311. const data = {
  312. ...rest,
  313. paymentType:
  314. paymentTypeFormat[
  315. this.paymentType == 0 ? this.paymentType : leixing
  316. ],
  317. musicGroupId: this.musicGroupId,
  318. ...getTimes(paymentDate, ["startPaymentDate", "deadlinePaymentDate"]),
  319. ...getTimes(paymentValid, [
  320. "paymentValidStartDate",
  321. "paymentValidEndDate",
  322. ]),
  323. };
  324. if (!this.rowDetail?.id) {
  325. try {
  326. const res = await musicGroupPaymentCalenderAdd(data);
  327. this.$listeners.close();
  328. this.$listeners.submited(res.data);
  329. // 在这里
  330. if (this.$route.query.type == "teamDraft") {
  331. console.log('来了')
  332. let query = this.$route.query;
  333. query.type = "feeAudit";
  334. query = JSON.parse(JSON.stringify(query))
  335. this.$router.push({
  336. query: {
  337. ...query,
  338. },
  339. });
  340. console.log(query)
  341. }
  342. } catch (error) { }
  343. } else {
  344. try {
  345. data.id = this.rowDetail.id
  346. const res = await musicGroupPaymentCalenderDetailBatchUpdate(data);
  347. this.$listeners.close();
  348. this.$listeners.submited(res.data);
  349. if (this.$route.query.type == "teamDraft") {
  350. console.log('来了')
  351. let query = this.$route.query;
  352. query.type = "feeAudit";
  353. query = JSON.parse(JSON.stringify(query))
  354. console.log(query)
  355. this.$router.push({
  356. query: {
  357. ...query
  358. },
  359. });
  360. }
  361. } catch (error) { }
  362. }
  363. }
  364. },
  365. },
  366. };
  367. </script>
  368. <style lang="less" scoped>
  369. .dialog-footer {
  370. margin-top: 20px;
  371. display: block;
  372. text-align: right;
  373. }
  374. .alert {
  375. margin-bottom: 10px;
  376. }
  377. .collapse-title {
  378. display: flex;
  379. justify-content: space-between;
  380. align-items: center;
  381. width: 100%;
  382. .el-icon-circle-close {
  383. font-size: 16px;
  384. margin-right: 10px;
  385. }
  386. }
  387. /deep/ .el-collapse-item__wrap {
  388. padding-top: 20px;
  389. }
  390. </style>