classCompound.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="fixedBox">
  3. <el-card>
  4. <div class="boxWrap">
  5. <p>
  6. 班级合并<span style="color: red"> {{ compoundList.length }} </span>
  7. </p>
  8. <el-popover placement="top" v-model="isLook" trigger="manual">
  9. <div>
  10. <p class="title">
  11. 班级合并列表
  12. <i class="el-icon-minus minus" @click="isLook = false"></i>
  13. </p>
  14. <el-divider></el-divider>
  15. </div>
  16. <el-button type="text" style="float: right" @click="clearCom"
  17. >清空列表</el-button
  18. >
  19. <div>
  20. <el-radio-group v-model="radio" @change="changeMasterClass">
  21. <el-table
  22. :data="dataList"
  23. height="300px"
  24. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  25. >
  26. <el-table-column align="center" label="主班" width="110">
  27. <template slot-scope="scope">
  28. <el-radio :label="scope.row.id"></el-radio>
  29. </template>
  30. </el-table-column>
  31. <el-table-column
  32. align="center"
  33. width="180px"
  34. label="班级名称"
  35. prop="name"
  36. ></el-table-column>
  37. <el-table-column align="center" label="班级类型">
  38. <template slot-scope="scope">
  39. <div>{{ scope.row.type | coursesType }}</div>
  40. </template>
  41. </el-table-column>
  42. <el-table-column
  43. align="center"
  44. width="180px"
  45. prop="teacherName"
  46. label="已选学生数"
  47. >
  48. <!-- -->
  49. <template slot-scope="scope">
  50. <div>
  51. {{
  52. scope.row.studentList ? scope.row.studentList.length : 0
  53. }}
  54. </div>
  55. </template>
  56. </el-table-column>
  57. <el-table-column align="center" label="操作" width="200px">
  58. <template slot-scope="scope">
  59. <el-button type="text" @click="cancleCom(scope.row)"
  60. >取消</el-button
  61. >
  62. <el-button
  63. type="text"
  64. @click="showStudentList(scope.row)"
  65. :disabled="scope.row.id == radio"
  66. >添加学生</el-button
  67. >
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. </el-radio-group>
  72. </div>
  73. <el-button
  74. type="primary"
  75. size="mini"
  76. style="float: right; margin-top: 20px"
  77. @click="submitClass"
  78. >确定</el-button
  79. >
  80. <i
  81. class="el-icon-copy-document"
  82. slot="reference"
  83. @click="isLook = true"
  84. ></i>
  85. </el-popover>
  86. </div>
  87. </el-card>
  88. <el-dialog
  89. :visible.sync="studentListModalVisible"
  90. title="学员列表"
  91. append-to-body
  92. width="800px"
  93. >
  94. <viewStudentList
  95. :classId="activeRow.id"
  96. :disabledList="allStudentList"
  97. :list="studentList"
  98. :chioseList="activeRow.studentList"
  99. v-if="studentListModalVisible"
  100. :showOk="true"
  101. :isChiose="true"
  102. @close="closeStudentView"
  103. />
  104. </el-dialog>
  105. <el-dialog
  106. :visible.sync="calenderStudentVisible"
  107. title="学员缴费列表"
  108. append-to-body
  109. width="800px"
  110. >
  111. <!-- studentIds:[],
  112. masterClassGroupId:'',
  113. classGroupStudents:[] -->
  114. <calenderStudentList
  115. ref='calenderStudentList'
  116. v-if="calenderStudentVisible"
  117. :classList="dataList"
  118. :studentIds="studentIds"
  119. :masterClassGroupId="masterClassGroupId"
  120. :classGroupStudents="classGroupStudents"
  121. :mergeInfo="mergeInfo"
  122. />
  123. <span slot="footer" class="dialog-footer">
  124. <el-button @click="calenderStudentVisible = false">取 消</el-button>
  125. <el-button type="primary" @click="submitInfo"
  126. >确 定</el-button
  127. >
  128. </span>
  129. </el-dialog>
  130. </div>
  131. </template>
  132. <script>
  133. // import compoundClass from './compoundClass' compoundClass
  134. import viewStudentList from "./student-list";
  135. import calenderStudentList from "./calenderStudentList";
  136. import { getClassAllStudent } from "@/api/studentManager";
  137. import { getStudentPaymentCalenders } from "@/api/buildTeam";
  138. let that;
  139. export default {
  140. props: ["compoundList"],
  141. components: { viewStudentList, calenderStudentList },
  142. data() {
  143. return {
  144. radio: "",
  145. dataList: this.compoundList,
  146. isLook: false,
  147. show: false,
  148. idList: "",
  149. studentList: [],
  150. studentListModalVisible: false,
  151. activeRow: null,
  152. calenderStudentVisible: false,
  153. studentIds: [],
  154. masterClassGroupId: "",
  155. classGroupStudents: [],
  156. mergeInfo: {},
  157. };
  158. },
  159. created() {
  160. that = this;
  161. },
  162. methods: {
  163. cancleCom(row) {
  164. this.$emit("cancleCompound", row);
  165. },
  166. clearCom() {
  167. this.$emit("clearCom");
  168. },
  169. async submitClass() {
  170. if (!this.radio) {
  171. this.$message.error("请选择一个主班");
  172. return;
  173. }
  174. // let arr = []
  175. // 主班id
  176. // 第一个是所有学员 this.radio
  177. // 班级和学生id的键值对
  178. // 第三个是主班编号 this.radio
  179. let idList = []; // 所有的班级id
  180. this.classGroupStudents = [];
  181. let flag = false;
  182. this.dataList.forEach((com) => {
  183. // arr.push(com.type)
  184. if (
  185. (!com.studentList && com.id != this.radio) ||
  186. (com.studentList?.length <= 0 && com.id != this.radio)
  187. ) {
  188. flag = true;
  189. }
  190. if (com.id != this.radio) {
  191. this.classGroupStudents.push({
  192. [com.id]: com.studentList.map((stu) => stu.userId).join(","),
  193. });
  194. }
  195. idList.push(com.id);
  196. });
  197. if (this.dataList.length <= 1) {
  198. this.$message.error("请至少选择2个班级");
  199. return;
  200. }
  201. if (flag) {
  202. this.$message.error("请保证每个班至少勾选一名学员");
  203. return;
  204. }
  205. // 做判断
  206. this.show = true;
  207. this.isLook = false;
  208. this.masterClassGroupId = this.radio;
  209. this.studentIds = this.allStudentList.map((stu) => {
  210. return stu.userId;
  211. });
  212. try {
  213. const rest = await getStudentPaymentCalenders({
  214. studentIds: this.studentIds,
  215. masterClassGroupId: this.masterClassGroupId,
  216. classGroupStudents: this.classGroupStudents,
  217. });
  218. this.mergeInfo = rest.data;
  219. this.calenderStudentVisible = true;
  220. } catch (e) {
  221. console.log(e);
  222. }
  223. // 试着请求
  224. },
  225. getList() {},
  226. closeReset() {
  227. this.clearCom();
  228. this.show = false;
  229. this.$emit("getList");
  230. },
  231. showStudentList(row) {
  232. // row.id
  233. this.activeRow = row;
  234. getClassAllStudent({ classGroupId: row.id }).then((res) => {
  235. if (res.code == 200) {
  236. this.studentList = res.data.map((item) => {
  237. return {
  238. userId: item.userId,
  239. nickName: item.name,
  240. gender: item.gender,
  241. phone: item.parentsPhone,
  242. subjectNames: item.subjectName,
  243. };
  244. });
  245. this.studentListModalVisible = true;
  246. }
  247. });
  248. },
  249. closeStudentView(list) {
  250. this.activeRow.studentList = list;
  251. this.dataList.splice(1, 0);
  252. this.studentListModalVisible = false;
  253. },
  254. changeMasterClass(val) {
  255. this.dataList.forEach((classes) => {
  256. if (classes.id == val) {
  257. classes.studentList = null;
  258. this.dataList.splice(1, 0);
  259. }
  260. });
  261. },
  262. submitInfo(){
  263. this.$refs.calenderStudentList.submit()
  264. }
  265. },
  266. watch: {
  267. compoundList(val) {
  268. this.dataList = val;
  269. },
  270. },
  271. computed: {
  272. allStudentList() {
  273. let arr = [];
  274. that.dataList.forEach((classes) => {
  275. if (classes.studentList) {
  276. arr = arr.concat(
  277. classes.studentList.map((stu) => {
  278. stu.classId = classes.id;
  279. return stu;
  280. })
  281. );
  282. }
  283. });
  284. return arr;
  285. },
  286. },
  287. };
  288. </script>
  289. <style lang="scss" scoped>
  290. .title {
  291. line-height: 44px;
  292. }
  293. .fixedBox {
  294. position: fixed;
  295. bottom: 20px;
  296. right: 10px;
  297. z-index: 100;
  298. width: 200px;
  299. background-color: #fff;
  300. font-size: 14px;
  301. .boxWrap {
  302. display: flex;
  303. flex-direction: row;
  304. justify-content: space-between;
  305. i {
  306. font-size: 18px;
  307. cursor: pointer;
  308. }
  309. }
  310. }
  311. /deep/.el-divider--horizontal {
  312. margin: 0 !important;
  313. }
  314. .minus {
  315. float: right;
  316. line-height: 44px;
  317. padding-right: 20px;
  318. font-size: 20px;
  319. cursor: pointer;
  320. }
  321. </style>