calenderStudentList.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div>
  3. <paymentCycle
  4. ref="cycle"
  5. :form="cycle"
  6. :isUserType="true"
  7. :isCommon="true"
  8. :isDisabled="true"
  9. :hideMoney="true"
  10. />
  11. <otherform :form="other" ref="other" />
  12. <div style="margin-bottom: 20px">
  13. <el-button type="primary" @click="dialogVisible = true">一键修改差价</el-button>
  14. <el-button type="primary" @click="init">还原差价</el-button>
  15. </div>
  16. <el-table
  17. :data="dataList"
  18. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  19. max-height="300px"
  20. >
  21. <el-table-column
  22. prop="userId"
  23. align="center"
  24. width="120"
  25. label="学员编号"
  26. ></el-table-column>
  27. <el-table-column
  28. prop="username"
  29. align="center"
  30. width="120"
  31. label="学员姓名"
  32. ></el-table-column>
  33. <el-table-column prop="phone" align="center" width="120" label="课程类型">
  34. <template slot-scope="scope">
  35. <div
  36. v-for="(item, index) in scope.row.courseList"
  37. :key="index"
  38. class="courseDiv"
  39. >
  40. {{ item.courseType | coursesType }}
  41. </div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column align="center" label="原班级剩余课程价值">
  45. <template slot-scope="scope">
  46. <div>
  47. <div
  48. class="courseDiv"
  49. v-for="(item, index) in scope.row.courseList"
  50. :key="index"
  51. >
  52. {{ item.subCourseAmount }}
  53. <!-- <el-input v-model="item.courseCurrentPrice"></el-input> -->
  54. </div>
  55. </div>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. prop="subjectNames"
  60. align="center"
  61. label="主班级剩余课程价值"
  62. >
  63. <template slot-scope="scope">
  64. <div>
  65. <div
  66. class="courseDiv"
  67. v-for="(item, index) in scope.row.courseList"
  68. :key="index"
  69. >
  70. <!-- <el-input v-model="item.courseOriginalPrice"></el-input> -->
  71. {{ item.masterSubCoursePrice}}
  72. </div>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop="subjectNames" align="center" label="需补交差价">
  77. <template slot-scope="scope">
  78. <div>
  79. <div
  80. class="courseDiv"
  81. v-for="(item, index) in scope.row.courseList"
  82. :key="index"
  83. >
  84. <el-input v-model="item.courseCurrentPrice"></el-input>
  85. <!-- {{item.courseOriginalPrice}} -->
  86. </div>
  87. </div>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <el-dialog title="一键修改差价" :visible.sync="dialogVisible" append-to-body width="500px" v-if="dialogVisible">
  92. <calenderStudentList :conrseTypeList='conrseTypeList' ref='calenderStudentList'/>
  93. <span slot="footer" class="dialog-footer">
  94. <el-button @click="dialogVisible = false">取 消</el-button>
  95. <el-button type="primary" @click="setAllprice"
  96. >确 定</el-button
  97. >
  98. </span>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script>
  103. import Vue from "vue";
  104. import paymentCycle from "@/views/resetTeaming/modals/payment-cycle";
  105. import otherform from "@/views/resetTeaming/modals/other";
  106. import { getTimes } from "@/utils";
  107. import { spanGroupMergeClassSplitClassAffirm } from "@/api/buildTeam";
  108. import { courseType, filterCourseType } from "@/constant";
  109. import descriptions from "@/components/Descriptions";
  110. Vue.use(descriptions);
  111. import calenderStudentList from './resetCourseMasker'
  112. export default {
  113. props: [
  114. "studentIds",
  115. "masterClassGroupId",
  116. "classGroupStudents",
  117. "classList",
  118. "mergeInfo",
  119. ],
  120. components: {
  121. paymentCycle,
  122. otherform,
  123. calenderStudentList
  124. },
  125. data() {
  126. return {
  127. activeNames: [],
  128. mergeInfoList: [],
  129. cycle: {
  130. paymentAmount: null,
  131. paymentPattern: null,
  132. },
  133. other: {},
  134. dataList: [],
  135. copyList: {},
  136. conrseTypeList: [],
  137. filterCourseType,
  138. dialogVisible:false
  139. };
  140. },
  141. mounted() {
  142. // console.log(this.studentIds, this.masterClassGroupId, this.classGroupStudents)
  143. // for (let item in this.mergeInfo) {
  144. // this.activeNames.push(item);
  145. // }
  146. this.init();
  147. },
  148. methods: {
  149. init() {
  150. this.coypList = this.$helpers.lodash.cloneDeep(this.mergeInfo);
  151. this.mergeInfoList = [];
  152. for (let merge in this.coypList) {
  153. this.mergeInfoList = this.mergeInfoList.concat(this.coypList[merge]);
  154. }
  155. this.concatCourseLst(this.mergeInfoList);
  156. },
  157. getCLassName(key) {
  158. let str = "";
  159. this.classList.forEach((classes) => {
  160. if (classes.id == key) {
  161. str = classes.name;
  162. }
  163. });
  164. return str;
  165. },
  166. async submit() {
  167. let obj = {};
  168. let some = this.getData();
  169. if (some) {
  170. obj.musicGroupPaymentCalenderDtos = [some];
  171. } else {
  172. return;
  173. }
  174. obj.classGroupIds = this.classList.map((classes) => {
  175. return classes.id;
  176. });
  177. obj.masterClassGroupId = this.masterClassGroupId;
  178. obj.classGroupStudents = this.classGroupStudents;
  179. obj.studentIds = this.studentIds;
  180. try {
  181. const reset = await spanGroupMergeClassSplitClassAffirm(obj);
  182. this.$message.success(reset.msg);
  183. // 1.关闭弹窗
  184. // 2.清空合并班
  185. // 3.刷新列表
  186. this.$emit("refresh");
  187. } catch (e) {
  188. console.log(e);
  189. }
  190. },
  191. getForms() {
  192. const { $refs: refs } = this;
  193. // [refs.base, refs.eclass, refs.cycle, ...(refs.cycles || []), refs.other, refs.payment]
  194. return [refs.cycle, refs.other]
  195. .filter((item) => !!item)
  196. .map((item) => item.$refs.form || item);
  197. },
  198. getData() {
  199. const forms = this.getForms();
  200. const valided = [];
  201. for (const form of forms) {
  202. form.validate((valid) => {
  203. if (valid) {
  204. valided.push(form);
  205. }
  206. });
  207. }
  208. if (valided.length === forms.length) {
  209. const { leixing, ...rest } = {
  210. ...this.form,
  211. ...this.other,
  212. };
  213. if (this.$refs.cycle) {
  214. const {
  215. paymentDate,
  216. paymentValid,
  217. paymentPattern,
  218. ...other
  219. } = this.cycle;
  220. rest.paymentPattern = paymentPattern;
  221. rest.payUserType = "STUDENT";
  222. rest.paymentType = "SPAN_GROUP_CLASS_ADJUST";
  223. rest.musicGroupPaymentCalenderStudentDetails = this.mergeInfoList;
  224. rest.musicGroupPaymentDateRangeList = [
  225. {
  226. ...other,
  227. ...getTimes(paymentDate, [
  228. "startPaymentDate",
  229. "deadlinePaymentDate",
  230. ]),
  231. ...getTimes(paymentValid, [
  232. "paymentValidStartDate",
  233. "paymentValidEndDate",
  234. ]),
  235. },
  236. ];
  237. }
  238. const data = {
  239. ...rest,
  240. };
  241. return data;
  242. // 说明验证通过
  243. } else {
  244. this.$message.error("请填写必要信息");
  245. return null;
  246. }
  247. },
  248. concatCourseLst(arr) {
  249. let data = {};
  250. arr.forEach((some) => {
  251. if (data[some.userId]) {
  252. // data[some.userId].push(some)
  253. data[some.userId].courseList.push(some);
  254. } else {
  255. data[some.userId] = {};
  256. data[some.userId].userId = some.userId;
  257. data[some.userId].username = some.username;
  258. data[some.userId].courseList = [];
  259. data[some.userId].courseList.push(some);
  260. }
  261. });
  262. this.dataList = Object.values(data);
  263. this.getNewClassType(this.dataList[0]?.courseList);
  264. },
  265. getNewClassType(arr) {
  266. this.conrseTypeList = arr.map((item) => {
  267. return {
  268. type:item.courseType,
  269. typeName:this.filterCourseType[item.courseType]+'补缴',
  270. price:''
  271. }
  272. });
  273. },
  274. setAllprice(){
  275. this.$refs.calenderStudentList.$refs.visitForm.validate(res=>{
  276. if(res){
  277. this.mergeInfoList.forEach(merge=>{
  278. this.conrseTypeList.forEach(courseType=>{
  279. if(merge.courseType == courseType.type){
  280. // 修改为新值
  281. merge.courseCurrentPrice = courseType.price
  282. }
  283. })
  284. })
  285. this.$refs.calenderStudentList.$refs.visitForm.resetFields();
  286. this.dialogVisible = false
  287. // this.conrseTypeList
  288. // this.mergeInfoList
  289. }
  290. })
  291. }
  292. },
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. .courseDiv {
  297. height: 45px;
  298. line-height: 45px;
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. }
  303. /deep/ .header {
  304. display: flex;
  305. align-items: center;
  306. width: 100%;
  307. justify-content: space-between;
  308. // margin-bottom: 10px;
  309. > span:first-child {
  310. display: flex;
  311. &::before {
  312. content: "";
  313. display: block;
  314. width: 5px;
  315. background-color: #14928a;
  316. margin-right: 10px;
  317. border-radius: 2px;
  318. height: 48px;
  319. }
  320. }
  321. .icon {
  322. font-size: 18px;
  323. font-weight: normal;
  324. margin-right: 20px;
  325. }
  326. /deep/.el-collapse-item__wrap {
  327. border-bottom: none !important;
  328. }
  329. }
  330. </style>