vipStudentList.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. <template>
  2. <div>
  3. <div class="btnWrap">
  4. <div>
  5. <el-button
  6. v-permission="'vipGroupManage/addVipGroupStudents'"
  7. @click="addStudentList"
  8. type="primary"
  9. >
  10. 新增学员
  11. </el-button>
  12. <el-button
  13. style="margin-right: 15px"
  14. v-permission="'vipGroupManage/update'"
  15. @click="expireVisible = true"
  16. type="primary"
  17. >
  18. 有效期调整
  19. </el-button>
  20. </div>
  21. <el-popover placement="left" width="500" trigger="click">
  22. <div class="popoverWrap">
  23. <p>VIP退费规则:</p>
  24. <p>(预计课程单价*课时数-课程标准单价*已完成课时数)*0.8</p>
  25. </div>
  26. <el-button
  27. type="text"
  28. style="color: red"
  29. icon="el-icon-question"
  30. slot="reference"
  31. >退费说明</el-button
  32. >
  33. </el-popover>
  34. </div>
  35. <div class="tableWrap">
  36. <el-table
  37. :data="tableList"
  38. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  39. >
  40. <el-table-column
  41. label="学员姓名"
  42. prop="userName"
  43. align="center"
  44. width="180"
  45. >
  46. </el-table-column>
  47. <el-table-column label="手机号" align="center" prop="phone" width="180">
  48. </el-table-column>
  49. <el-table-column prop="studentStatus" align="center" label="学员状态">
  50. <template slot-scope="scope">
  51. <div>
  52. {{ scope.row.studentStatus | studentStatus }}
  53. </div>
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="courseSalary" align="center" label="课程余额">
  57. <template slot-scope="scope">
  58. <div>
  59. {{ scope.row.courseSalary | moneyFormat }}
  60. </div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="applyDate" align="center" label="报名时间">
  64. <template slot-scope="scope">
  65. <div>
  66. {{ scope.row.applyDate | formatTimer }}
  67. </div>
  68. </template>
  69. </el-table-column>
  70. <el-table-column prop="refundDate" align="center" label="退课时间">
  71. <template slot-scope="scope">
  72. <div>
  73. {{ scope.row.refundDate | formatTimer }}
  74. </div>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="操作" align="center">
  78. <template slot-scope="scope">
  79. <div>
  80. <el-button
  81. type="text"
  82. v-if="
  83. scope.row.studentStatus == 0 || scope.row.studentStatus == 3
  84. "
  85. v-permission="'vipGroupManage/applyRefundForStudent'"
  86. @click="lookFee(scope)"
  87. >退学</el-button
  88. >
  89. <el-button
  90. type="text"
  91. v-if="scope.row.studentStatus == 0"
  92. @click="stopCourse(scope)"
  93. >休学</el-button
  94. >
  95. <el-button
  96. type="text"
  97. v-if="scope.row.studentStatus == 3"
  98. @click="recoveryCourse(scope)"
  99. >恢复</el-button
  100. >
  101. </div>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. </div>
  106. <el-dialog
  107. title="学员列表"
  108. width="70%"
  109. :visible.sync="maskVisible"
  110. v-if="maskVisible"
  111. >
  112. <el-form :model="maskForm" :inline="true" @submit.native.prevent>
  113. <el-form-item>
  114. <el-input
  115. placeholder="请输入学生姓名或手机号"
  116. @keyup.enter.native="search"
  117. v-model.trim="maskForm.search"
  118. ></el-input>
  119. </el-form-item>
  120. <el-form-item>
  121. <el-button type="danger" @click="search">搜索</el-button>
  122. </el-form-item>
  123. <el-form-item>
  124. <el-button type="primary" @click="reset">重置</el-button>
  125. </el-form-item>
  126. </el-form>
  127. <el-table
  128. :data="maskStudentList"
  129. ref="maskStudentList"
  130. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  131. @selection-change="handleSelectionChange"
  132. @select="onTableSelect"
  133. row-key="id"
  134. >
  135. <!-- <el-table-column label="" width="55">
  136. <template slot-scope="scope">
  137. <el-radio
  138. v-model.trim="activeStudent"
  139. :label="scope.row.id"
  140. @change.native="getTemplateRow(scope.$index, scope.row)"
  141. >&nbsp</el-radio
  142. >
  143. </template>
  144. </el-table-column> -->
  145. <el-table-column type="selection" width="55"> </el-table-column>
  146. <el-table-column
  147. prop="userName"
  148. align="center"
  149. label="学生姓名"
  150. width="150"
  151. ></el-table-column>
  152. <el-table-column
  153. prop="phone"
  154. align="center"
  155. label="手机号"
  156. width="200"
  157. ></el-table-column>
  158. <el-table-column prop="courseSalary" label="课程余额" width="150">
  159. <template slot-scope="scope">
  160. <div>
  161. {{ scope.row.courseSalary | moneyFormat }}
  162. </div>
  163. </template>
  164. </el-table-column>
  165. <el-table-column prop="balance" label="账户余额">
  166. <template slot-scope="scope">
  167. <div>
  168. {{ scope.row.balance | moneyFormat }}
  169. </div>
  170. </template>
  171. </el-table-column>
  172. <el-table-column
  173. label="剩余排课数"
  174. align="center"
  175. prop="totalClassTimes"
  176. >
  177. <template slot-scope="scope">
  178. <div>{{ scope.row.totalClassTimes }}节</div>
  179. </template>
  180. </el-table-column>
  181. <el-table-column prop="studentId" label="线上课单价">
  182. <!-- v-if="activeStudent == scope.row.id" 202109/10跟辜经理确认过所有乐理课也不能改钱-->
  183. <template slot-scope="scope">
  184. <el-input-number
  185. style="width: 90% !important"
  186. class="number-input"
  187. v-model="scope.row.onlineClassesUnitPrice"
  188. :disabled="true"
  189. :controls="false"
  190. :min="0"
  191. placeholder="线上课单价"
  192. />
  193. </template>
  194. </el-table-column>
  195. <el-table-column prop="studentId" label="线下课单价">
  196. <!-- v-if="activeStudent == scope.row.id" -->
  197. <template slot-scope="scope">
  198. <el-input-number
  199. style="width: 90% !important"
  200. class="number-input"
  201. v-model="scope.row.offlineClassesUnitPrice"
  202. :disabled="true"
  203. :controls="false"
  204. :min="0"
  205. placeholder="线下课单价"
  206. />
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. <pagination
  211. :total.sync="rules.total"
  212. :page.sync="rules.page"
  213. :limit="rules.limit"
  214. :page-sizes="rules.page_size"
  215. @pagination="getList"
  216. />
  217. <div slot="footer" class="dialog-footer">
  218. <el-button @click="maskVisible = false">取 消</el-button>
  219. <el-button type="primary" @click="addStudent">确 定</el-button>
  220. </div>
  221. </el-dialog>
  222. <el-dialog title="学员复学" width="800px" :visible.sync="adjustmentVisible">
  223. <el-form
  224. :model="adjustmentForm"
  225. label-position="right"
  226. label-width="120px"
  227. ref="adjustmentForm"
  228. :rules="adjustmentRules"
  229. :inline="true"
  230. >
  231. <el-form-item label="剩余课时">
  232. <el-input
  233. disabled
  234. v-model.trim="adjustmentForm.count"
  235. style="width: 200px !important"
  236. ></el-input>
  237. </el-form-item>
  238. <el-form-item label="任课老师" prop="teacher">
  239. <el-select
  240. v-model.trim="adjustmentForm.teacher"
  241. clearable
  242. filterable
  243. style="width: 200px !important"
  244. >
  245. <el-option
  246. v-for="(item, index) in teacherList"
  247. :key="index"
  248. :label="item.realName"
  249. :value="item.id"
  250. ></el-option>
  251. </el-select>
  252. </el-form-item>
  253. <!-- <br /> -->
  254. <el-form-item label="排课起始时间" prop="courseTime">
  255. <el-date-picker
  256. v-model.trim="adjustmentForm.courseTime"
  257. :picker-options="pickerOptions"
  258. style="width: 200px !important"
  259. type="date"
  260. value-format="yyyy-MM-dd"
  261. placeholder="选择日期"
  262. >
  263. </el-date-picker>
  264. </el-form-item>
  265. <el-form-item label="有效期截止" prop="expireDate">
  266. <el-date-picker
  267. :disabled="true"
  268. v-model.trim="adjustmentForm.expireDate"
  269. :picker-options="pickerOptions"
  270. style="width: 200px !important"
  271. type="date"
  272. value-format="yyyy-MM-dd"
  273. placeholder="选择日期"
  274. >
  275. </el-date-picker>
  276. </el-form-item>
  277. <el-form-item>
  278. <el-checkbox
  279. style="margin-left: 10px"
  280. v-model.trim="adjustmentForm.checked"
  281. >是否跳过节假日</el-checkbox
  282. >
  283. </el-form-item>
  284. </el-form>
  285. <div class="WeekWrap">
  286. <h3 style="margin-bottom: 20px">
  287. 循环次数
  288. <el-button type="text" style="margin-left: 10px" @click="addWeek"
  289. >添加</el-button
  290. >
  291. </h3>
  292. <div class="countWrap" style="margin-bottom: 10px">
  293. <div
  294. class="countItem"
  295. style="margin-bottom: 20px"
  296. v-for="(item, index) in weekList"
  297. :key="index"
  298. >
  299. <span class="title">循环周期: </span>
  300. <el-select
  301. v-model.trim="item.dayOfWeek"
  302. filterable
  303. clearable
  304. style="width: 200px !important"
  305. >
  306. <el-option
  307. v-for="(item, index) in weekDateList"
  308. :key="index"
  309. :label="item.label"
  310. :value="item.value"
  311. ></el-option>
  312. </el-select>
  313. <span style="margin-left: 10px">开始时间</span>
  314. <el-time-select
  315. style="margin-left: 10px; width: 100px"
  316. placeholder=""
  317. v-model.trim="item.startClassTime"
  318. :picker-options="{
  319. start: '04:30',
  320. step: '00:05',
  321. end: '23:55'
  322. }"
  323. >
  324. </el-time-select>
  325. <el-button
  326. style="margin-left: 10px"
  327. type="danger"
  328. @click="removeWeek(item)"
  329. icon="el-icon-delete"
  330. circle
  331. ></el-button>
  332. </div>
  333. </div>
  334. </div>
  335. <div slot="footer" class="dialog-footer">
  336. <el-button @click="adjustmentVisible = false">取 消</el-button>
  337. <el-button type="primary" @click="submieRecover">确 定</el-button>
  338. </div>
  339. </el-dialog>
  340. <!-- 有效期调整 -->
  341. <el-dialog title="有效期调整" width="400px" :visible.sync="expireVisible">
  342. <el-form
  343. :model="expireForm"
  344. ref="expireForm"
  345. :rules="expireRules"
  346. label-position="right"
  347. label-width="80px;"
  348. :inline="true"
  349. >
  350. <el-form-item label="课程结束时间" prop="coursesExpireDate">
  351. <el-date-picker
  352. v-model.trim="expireForm.coursesExpireDate"
  353. style="width: 200px !important"
  354. type="date"
  355. :picker-options="pickerOptions"
  356. value-format="yyyy-MM-dd"
  357. placeholder="选择日期"
  358. ></el-date-picker>
  359. </el-form-item>
  360. <!-- <div style="padding-left: 15px; color: red;">课程结束时间不得晚于,{{ expireForm.tempCoursesExpireDate }}</div> -->
  361. </el-form>
  362. <div slot="footer" class="dialog-footer">
  363. <el-button @click="expireVisible = false">取 消</el-button>
  364. <el-button type="primary" @click="submitExpireDate">确 定</el-button>
  365. </div>
  366. </el-dialog>
  367. </div>
  368. </template>
  369. <script>
  370. import pagination from "@/components/Pagination/index";
  371. import dayjs from "dayjs";
  372. import {
  373. findVipGroupStudents,
  374. leaveSchool,
  375. getStudentSurplusCourseFee,
  376. getHaveCourseBalanceStudents,
  377. addVipGroupStudents,
  378. vipPauseForStudent,
  379. getStudentPauseInfo,
  380. recoverForStudent,
  381. findTeacherWithVipGroupOrganAndSubject,
  382. vipGroupManageUpdate,
  383. getVipGroupDetail
  384. } from "@/api/vipSeting";
  385. import { permission } from "@/utils/directivePage";
  386. export default {
  387. components: { pagination },
  388. data() {
  389. return {
  390. expireVisible: false,
  391. expireForm: {
  392. coursesExpireDate: ""
  393. },
  394. expireRules: {
  395. coursesExpireDate: [
  396. { required: true, message: "请选择课程结束时间", trigger: "blur" }
  397. ]
  398. },
  399. adjustmentVisible: false,
  400. tableList: [],
  401. id: "",
  402. maskStudentList: [],
  403. maskVisible: false,
  404. rules: {
  405. // 分页规则
  406. limit: 10, // 限制显示条数
  407. page: 1, // 当前页
  408. total: 0, // 总条数
  409. page_size: [10, 20, 40, 50] // 选择限制显示条数
  410. },
  411. activeStudent: "",
  412. maskForm: {
  413. search: ""
  414. },
  415. adjustmentForm: {
  416. count: "",
  417. courseTime: "",
  418. checked: false,
  419. addCount: "",
  420. courseType: "",
  421. fee: "",
  422. teacher: "",
  423. expireDate: ""
  424. },
  425. adjustmentRules: {
  426. courseTime: [{ required: true, message: "请选择开始时间" }],
  427. addCount: [{ required: true, message: "请输入加课次数" }],
  428. courseType: [{ required: true, message: "请选择课程类型" }],
  429. fee: [{ required: true, message: "请输入费用" }],
  430. teacher: [{ required: true, message: "请选择老师" }],
  431. expireDate: [{ required: true, message: "请输入有效期截止" }]
  432. },
  433. weekDateList: [
  434. { value: "1", label: "星期一" },
  435. { value: "2", label: "星期二" },
  436. { value: "3", label: "星期三" },
  437. { value: "4", label: "星期四" },
  438. { value: "5", label: "星期五" },
  439. { value: "6", label: "星期六" },
  440. { value: "7", label: "星期日" }
  441. ],
  442. weekList: [
  443. {
  444. dayOfWeek: "",
  445. startTime: "",
  446. endTime: "",
  447. moid: new Date().getTime()
  448. }
  449. ],
  450. pickerOptions: {
  451. firstDayOfWeek: 1,
  452. disabledDate(time) {
  453. return time.getTime() + 86400000 <= new Date().getTime();
  454. }
  455. },
  456. teacherList: [],
  457. vipDetail: {},
  458. deleteList: [],
  459. isDetele: false
  460. };
  461. },
  462. mounted() {
  463. this.__init();
  464. },
  465. activated() {
  466. this.__init();
  467. },
  468. methods: {
  469. permission(str) {
  470. console.log(permission(str));
  471. return permission(str);
  472. },
  473. __init() {
  474. let id = this.$route.query.id;
  475. this.id = id;
  476. this.rules.page = 1;
  477. this.getStudents();
  478. findTeacherWithVipGroupOrganAndSubject({ vipGroupId: this.id }).then(
  479. res => {
  480. if (res.code == 200) {
  481. this.teacherList = res.data;
  482. }
  483. }
  484. );
  485. getVipGroupDetail({ vipGroupId: id }).then(res => {
  486. if (res.code == 200) {
  487. this.vipDetail = res.data;
  488. }
  489. });
  490. },
  491. search() {
  492. this.rules.page = 1;
  493. this.getList();
  494. },
  495. reset() {
  496. this.rules.page = 1;
  497. this.maskForm.search = null;
  498. this.activeStudent = "";
  499. this.getList();
  500. },
  501. getStudents() {
  502. findVipGroupStudents({ vipGroupId: this.id, groupType: "VIP" }).then(
  503. res => {
  504. if (res.code == 200) {
  505. this.tableList = res.data.rows;
  506. for (let i in this.tableList) {
  507. this.tableList[i].fee = 0;
  508. this.tableList[i].visible = false;
  509. }
  510. }
  511. }
  512. );
  513. },
  514. // 删除循环周
  515. removeWeek(item) {
  516. for (let i in this.weekList) {
  517. if (this.weekList[i].id == item.id) {
  518. this.weekList.splice(i, 1);
  519. }
  520. }
  521. },
  522. leaveSchool(scope) {
  523. let studentId = scope.row.id;
  524. let vipGroupId = this.id;
  525. let amount = scope.row.fee;
  526. leaveSchool({ studentId, vipGroupId, amount }).then(res => {
  527. if (res.code == 200) {
  528. this.$message.success("退学成功");
  529. this.getStudents();
  530. }
  531. if (res.code == 206) {
  532. this.$confirm(res.msg, "提示", {
  533. confirmButtonText: "确定",
  534. cancelButtonText: "取消"
  535. }).then(() => {
  536. leaveSchool({
  537. studentId,
  538. vipGroupId,
  539. amount,
  540. confirmReturnActivityGive: true
  541. }).then(res => {
  542. if (res.code == 200) {
  543. this.$message.success("退学成功");
  544. this.getStudents();
  545. }
  546. });
  547. });
  548. }
  549. });
  550. },
  551. lookFee(scope) {
  552. this.$confirm(`确定是否退学?`, "提示", {
  553. confirmButtonText: "确定",
  554. cancelButtonText: "取消",
  555. type: "warning"
  556. })
  557. .then(() => {
  558. let id = scope.row.id;
  559. if (scope.row.studentStatus == 3) {
  560. this.leaveSchool(scope);
  561. } else {
  562. getStudentSurplusCourseFee({
  563. studentId: id,
  564. vipGroupId: this.id
  565. }).then(res => {
  566. if (res.code == 200) {
  567. // this.$prompt("请输入退课金额", "提示", {
  568. // confirmButtonText: "确定",
  569. // cancelButtonText: "取消",
  570. // inputValue: res.data.suplusCourseFee,
  571. // })
  572. // .then(({ value }) => {
  573. // scope.row.fee = value;
  574. // this.leaveSchool(scope);
  575. // })
  576. // .catch((res) => {});
  577. scope.row.fee = res.data.suplusCourseFee;
  578. const h = this.$createElement;
  579. this.$msgbox({
  580. title: "消息",
  581. closeOnClickModal: false,
  582. message: h("p", null, [
  583. h("p", null, "请输入退课金额 "),
  584. h("input", {
  585. class: "el-input__inner",
  586. attrs: { value: res.data.suplusCourseFee },
  587. on: {
  588. input: function(event) {
  589. scope.row.fee = event.target.value;
  590. this.$emit("input", event.target.value);
  591. }.bind(this)
  592. }
  593. }),
  594. h(
  595. "p",
  596. { style: "color: red;marginTop:20px" },
  597. "退费金额暂不进入账户余额"
  598. )
  599. ]),
  600. showCancelButton: true,
  601. confirmButtonText: "确定",
  602. cancelButtonText: "取消"
  603. }).then(action => {
  604. this.leaveSchool(scope);
  605. });
  606. }
  607. });
  608. }
  609. })
  610. .catch(() => {});
  611. },
  612. addStudentList() {
  613. // 发请求 搜索学生
  614. if (this.tableList.length <= 0) {
  615. this.$confirm(
  616. "添加学员后,该课程组将无法通过购买途径加入,是否确认该操作?",
  617. "提示",
  618. {
  619. confirmButtonText: "确定",
  620. cancelButtonText: "取消",
  621. type: "warning"
  622. }
  623. )
  624. .then(() => {
  625. this.getList();
  626. })
  627. .catch(() => {});
  628. } else {
  629. this.getList();
  630. }
  631. },
  632. getList() {
  633. let search = this.maskForm.search || null;
  634. getHaveCourseBalanceStudents({
  635. vipGroupId: this.id,
  636. organId: null,
  637. page: this.rules.page,
  638. rows: this.rules.limit,
  639. search
  640. }).then(res => {
  641. if (res.code == 200) {
  642. this.rules.total = res.data.total;
  643. this.maskStudentList = res.data.rows;
  644. let idList = this.deleteList.map(course => {
  645. return course.id;
  646. });
  647. this.isDetele = true;
  648. this.$nextTick(() => {
  649. this.maskStudentList.forEach(course => {
  650. if (idList.indexOf(course.id) != -1) {
  651. this.$refs.maskStudentList.toggleRowSelection(course, true);
  652. }
  653. });
  654. this.isDetele = false;
  655. });
  656. this.maskStudentList.forEach(stu => {
  657. stu.offlineClassesUnitPrice
  658. ? stu.offlineClassesUnitPrice
  659. : (stu.offlineClassesUnitPrice = this.vipDetail?.offlineClassesUnitPrice);
  660. stu.onlineClassesUnitPrice
  661. ? stu.onlineClassesUnitPrice
  662. : (stu.onlineClassesUnitPrice = this.vipDetail?.onlineClassesUnitPrice);
  663. });
  664. this.maskVisible = true;
  665. }
  666. });
  667. },
  668. handleSelectionChange(arr) {
  669. if (arr.length > 0) {
  670. // 有可能加 有可能减
  671. this.deleteList = this.deleteList.concat(arr);
  672. // 去重
  673. this.deleteList = this.$helpers.lodash.uniqBy(this.deleteList, "id");
  674. }
  675. // else if(){}
  676. else {
  677. if (this.isDetele) return;
  678. // 有2种 1是新页
  679. // 2是点击反选
  680. let idList = this.deleteList.map(course => {
  681. return course.id;
  682. });
  683. this.$nextTick(() => {
  684. let tableIdList = [];
  685. this.maskStudentList.forEach(course => {
  686. tableIdList.push(course.id);
  687. if (idList.indexOf(course.id) != -1) {
  688. this.$refs.maskStudentList.toggleRowSelection(course, false);
  689. // 删除这个元素
  690. }
  691. });
  692. this.deleteList = this.$helpers.lodash.remove(
  693. this.deleteList,
  694. function(item) {
  695. return tableIdList.indexOf(item.id) == -1;
  696. }
  697. );
  698. if (this.deleteList.length <= 0) {
  699. this.clearCom();
  700. }
  701. });
  702. }
  703. },
  704. onTableSelect(rows, row) {
  705. let idList = this.deleteList.map(course => {
  706. return course.id;
  707. });
  708. if (idList.indexOf(row.id) != -1) {
  709. this.deleteList.splice(idList.indexOf(row.id), 1);
  710. if (this.deleteList.length <= 0) {
  711. this.clearCom();
  712. }
  713. }
  714. },
  715. clearCom() {
  716. // this.deleteList = [];
  717. this.$set(this, "deleteList", []);
  718. if (this.$refs.maskStudentList) {
  719. this.$refs.maskStudentList.clearSelection();
  720. }
  721. // this.$refs.addCompound.isLook = false;
  722. },
  723. getTemplateRow(index, row) {
  724. this.activeStudent = row.id;
  725. },
  726. addStudent() {
  727. if (!this.deleteList < 0) {
  728. this.$message.error("请选择一名学生");
  729. return;
  730. }
  731. let str = "";
  732. let arr = this.deleteList.map(stu => {
  733. str += stu.userName + ",";
  734. return {
  735. vipGroupId: this.id,
  736. studentId: stu.id,
  737. offlineClassesUnitPrice: stu.offlineClassesUnitPrice,
  738. onlineClassesUnitPrice: stu.onlineClassesUnitPrice
  739. };
  740. });
  741. str = str.slice(0, str.length - 1);
  742. // return;
  743. // let offlineClassesUnitPrice, onlineClassesUnitPrice;
  744. // this.maskStudentList.forEach((stu) => {
  745. // if (stu.id == this.activeStudent) {
  746. // offlineClassesUnitPrice = stu.offlineClassesUnitPrice;
  747. // onlineClassesUnitPrice = stu.onlineClassesUnitPrice;
  748. // }
  749. // });
  750. // if(!offlineClassesUnitPrice || !onlineClassesUnitPrice){
  751. // this.$message.error("请填写线上课单价或线下课单价");
  752. // return
  753. // }
  754. // [
  755. // {
  756. // vipGroupId: this.id,
  757. // studentId: this.activeStudent,
  758. // onlineClassesUnitPrice,
  759. // offlineClassesUnitPrice,
  760. // },
  761. // ]
  762. this.$confirm(`是否将${str}加入课程组?`, "提示", {
  763. confirmButtonText: "确定",
  764. cancelButtonText: "取消",
  765. type: "warning"
  766. })
  767. .then(async res => {
  768. addVipGroupStudents(arr).then(res => {
  769. if (res.code == 200) {
  770. this.$message.success("添加成功");
  771. this.getStudents();
  772. this.clearCom();
  773. }
  774. });
  775. })
  776. .catch(e => {
  777. console.log(e);
  778. });
  779. },
  780. stopCourse(scope) {
  781. this.$confirm("是否休学?", "提示", {
  782. confirmButtonText: "确定",
  783. cancelButtonText: "取消",
  784. type: "warning"
  785. })
  786. .then(() => {
  787. // 发请求 申请休学
  788. vipPauseForStudent({
  789. vipGroupId: this.id,
  790. studentId: scope.row.id
  791. }).then(res => {
  792. if (res.code == 200) {
  793. this.$message.success("休学成功");
  794. this.getStudents();
  795. }
  796. });
  797. })
  798. .catch(() => {});
  799. },
  800. recoveryCourse(scope) {
  801. getStudentPauseInfo({
  802. studentId: scope.row.id,
  803. vipGroupId: this.id
  804. }).then(res => {
  805. if (res.code == 200) {
  806. if (res.data.isPause == 0) {
  807. // vip状态没暂停 不需要排课
  808. // 课程编号 学生编号
  809. const h = this.$createElement;
  810. this.$msgbox({
  811. title: "提示",
  812. message: h("p", null, [
  813. h("p", null, "将按照当前剩余课时安排上课")
  814. // h("span", null, `排课截至时间:`),
  815. // h("span", { style: "color: red" }, `${res.data.expireDate}`), 辜经理同意注释
  816. ]),
  817. confirmButtonText: "确定",
  818. cancelButtonText: "取消",
  819. showCancelButton: true
  820. })
  821. .then(() => {
  822. // 发请求 恢复上课
  823. recoverForStudent({
  824. vipGroupId: this.id,
  825. userId: scope.row.id
  826. }).then(res => {
  827. if (res.code == 200) {
  828. this.adjustmentVisible = false;
  829. this.getStudents();
  830. }
  831. });
  832. })
  833. .catch(() => {});
  834. } else {
  835. this.activeStudent = res.data.studentId;
  836. this.adjustmentVisible = true;
  837. this.adjustmentForm.teacher = res.data.teacherId;
  838. this.adjustmentForm.count = `${res.data.totalCourseTimes}+${
  839. res.data.giveCourseTimes
  840. }`;
  841. this.adjustmentForm.expireDate = res.data.expireDate;
  842. }
  843. }
  844. });
  845. // this.$confirm('是否休学?', '提示', {
  846. // confirmButtonText: '确定',
  847. // cancelButtonText: '取消',
  848. // type: 'warning'
  849. // }).then(() => {
  850. // // 发请求 申请休学
  851. // vipPauseForStudent({ vipGroupId: this.id, studentId: scope.row.id }).then(res => {
  852. // if (res.code == 200) {
  853. // this.$message.success('休学成功')
  854. // this.getList()
  855. // }
  856. // })
  857. // }).catch(() => {
  858. // });
  859. },
  860. addWeek() {
  861. // 添加循环周期
  862. this.weekList.push({
  863. dayOfWeek: "",
  864. startClassTime: "",
  865. endClassTime: "",
  866. id: new Date()
  867. });
  868. },
  869. submieRecover() {
  870. if (this.weekList.length <= 0) {
  871. this.$message.error("排课循环次数不能为空");
  872. return;
  873. }
  874. this.$refs["adjustmentForm"].validate(res => {
  875. if (res) {
  876. // 发请求
  877. let obj = {};
  878. obj.courseCreateStartTime = this.adjustmentForm.courseTime;
  879. obj.skipHoliday = this.adjustmentForm.checked;
  880. obj.teacherId = this.adjustmentForm.teacher;
  881. obj.userId = this.activeStudent;
  882. obj.courseTimes = [];
  883. obj.courseTimes = this.weekList;
  884. obj.vipGroupId = this.id;
  885. obj.expireDate = this.adjustmentForm.expireDate;
  886. recoverForStudent(obj).then(res => {
  887. if (res.code == 200) {
  888. this.adjustmentVisible = false;
  889. this.getStudents();
  890. }
  891. });
  892. } else {
  893. this.$message.error("请填写必要参数");
  894. }
  895. });
  896. this.activeStudent;
  897. },
  898. submitExpireDate() {
  899. this.$refs.expireForm.validate(some => {
  900. if (some) {
  901. vipGroupManageUpdate({
  902. id: this.id,
  903. coursesExpireDate: this.expireForm.coursesExpireDate
  904. }).then(res => {
  905. if (res.code == 200) {
  906. this.$message.success("有效期修改成功");
  907. this.expireVisible = false;
  908. this.getStudents();
  909. } else {
  910. this.$message.error(res.msg);
  911. }
  912. });
  913. } else {
  914. return;
  915. }
  916. });
  917. }
  918. },
  919. watch: {
  920. maskVisible(val) {
  921. if (!val) {
  922. this.clearCom();
  923. this.rules = {
  924. // 分页规则
  925. limit: 10, // 限制显示条数
  926. page: 1, // 当前页
  927. total: 0, // 总条数
  928. page_size: [10, 20, 40, 50] // 选择限制显示条数
  929. };
  930. }
  931. }
  932. }
  933. };
  934. </script>
  935. <style lang="scss" scoped>
  936. .title {
  937. display: inline-block;
  938. width: 108px;
  939. text-align: right;
  940. margin-right: 10px;
  941. }
  942. ::v-deep .el-input-number .el-input__inner {
  943. text-align: left !important;
  944. }
  945. .btnWrap {
  946. display: flex;
  947. flex-direction: row;
  948. justify-content: space-between;
  949. margin-bottom: 15px;
  950. }
  951. </style>