classCompound.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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 | classType }}</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. @refresh='refresh'
  123. />
  124. <span slot="footer" class="dialog-footer">
  125. <el-button @click="calenderStudentVisible = false">取 消</el-button>
  126. <el-button type="primary" @click="submitInfo"
  127. >确 定</el-button
  128. >
  129. </span>
  130. </el-dialog>
  131. </div>
  132. </template>
  133. <script>
  134. // import compoundClass from './compoundClass' compoundClass
  135. import viewStudentList from "./student-list";
  136. import calenderStudentList from "./calenderStudentList";
  137. import { getClassAllStudent } from "@/api/studentManager";
  138. import { getStudentPaymentCalenders } from "@/api/buildTeam";
  139. let that;
  140. export default {
  141. props: ["compoundList"],
  142. components: { viewStudentList, calenderStudentList },
  143. data() {
  144. return {
  145. radio: "",
  146. dataList: this.compoundList,
  147. isLook: false,
  148. show: false,
  149. idList: "",
  150. studentList: [],
  151. studentListModalVisible: false,
  152. activeRow: null,
  153. calenderStudentVisible: false,
  154. studentIds: [],
  155. masterClassGroupId: "",
  156. classGroupStudents: [],
  157. mergeInfo: {},
  158. };
  159. },
  160. created() {
  161. that = this;
  162. },
  163. methods: {
  164. cancleCom(row) {
  165. this.$emit("cancleCompound", row);
  166. },
  167. clearCom() {
  168. this.$emit("clearCom");
  169. },
  170. async submitClass() {
  171. if (!this.radio) {
  172. this.$message.error("请选择一个主班");
  173. return;
  174. }
  175. // let arr = []
  176. // 主班id
  177. // 第一个是所有学员 this.radio
  178. // 班级和学生id的键值对
  179. // 第三个是主班编号 this.radio
  180. let idList = []; // 所有的班级id
  181. this.classGroupStudents = [];
  182. let flag = false;
  183. this.dataList.forEach((com) => {
  184. // arr.push(com.type)
  185. if (
  186. (!com.studentList && com.id != this.radio) ||
  187. (com.studentList?.length <= 0 && com.id != this.radio)
  188. ) {
  189. flag = true;
  190. }
  191. if (com.id != this.radio&&com.studentList?.length>0) {
  192. this.classGroupStudents.push({
  193. [com.id]: com.studentList.map((stu) => stu.userId).join(","),
  194. });
  195. }
  196. idList.push(com.id);
  197. });
  198. if (this.dataList.length <= 1) {
  199. this.$message.error("请至少选择2个班级");
  200. return;
  201. }
  202. if (flag) {
  203. this.$message.error("请保证每个班至少勾选一名学员");
  204. return;
  205. }
  206. // 做判断
  207. this.show = true;
  208. this.isLook = false;
  209. this.masterClassGroupId = this.radio;
  210. this.studentIds = this.allStudentList.map((stu) => {
  211. return stu.userId;
  212. });
  213. try {
  214. const rest = await getStudentPaymentCalenders({
  215. studentIds: this.studentIds,
  216. masterClassGroupId: this.masterClassGroupId,
  217. classGroupStudents: this.classGroupStudents,
  218. });
  219. this.mergeInfo = rest.data;
  220. this.calenderStudentVisible = true;
  221. } catch (e) {
  222. console.log(e);
  223. }
  224. // 试着请求
  225. },
  226. getList() {
  227. this.$emit("getList");
  228. },
  229. refresh(){
  230. this.calenderStudentVisible = false;
  231. this.clearCom()
  232. this.getList()
  233. },
  234. closeReset() {
  235. this.clearCom();
  236. this.show = false;
  237. this.$emit("getList");
  238. },
  239. showStudentList(row) {
  240. // row.id
  241. this.activeRow = row;
  242. getClassAllStudent({ classGroupId: row.id }).then((res) => {
  243. if (res.code == 200) {
  244. this.studentList = res.data.map((item) => {
  245. return {
  246. userId: item.userId,
  247. nickName: item.name,
  248. gender: item.gender,
  249. phone: item.parentsPhone,
  250. subjectNames: item.subjectName,
  251. };
  252. });
  253. this.studentListModalVisible = true;
  254. }
  255. });
  256. },
  257. closeStudentView(list) {
  258. this.activeRow.studentList = list;
  259. this.dataList.splice(1, 0);
  260. this.studentListModalVisible = false;
  261. },
  262. changeMasterClass(val) {
  263. this.dataList.forEach((classes) => {
  264. if (classes.id == val) {
  265. classes.studentList = null;
  266. this.dataList.splice(1, 0);
  267. }
  268. });
  269. },
  270. submitInfo(){
  271. this.$refs.calenderStudentList.submit()
  272. }
  273. },
  274. watch: {
  275. compoundList(val) {
  276. this.dataList = val;
  277. },
  278. },
  279. computed: {
  280. allStudentList() {
  281. let arr = [];
  282. that.dataList.forEach((classes) => {
  283. if (classes.studentList) {
  284. arr = arr.concat(
  285. classes.studentList.map((stu) => {
  286. stu.classId = classes.id;
  287. return stu;
  288. })
  289. );
  290. }
  291. });
  292. return arr;
  293. },
  294. },
  295. };
  296. </script>
  297. <style lang="scss" scoped>
  298. .title {
  299. line-height: 44px;
  300. }
  301. .fixedBox {
  302. position: fixed;
  303. bottom: 20px;
  304. right: 10px;
  305. z-index: 100;
  306. width: 200px;
  307. background-color: #fff;
  308. font-size: 14px;
  309. .boxWrap {
  310. display: flex;
  311. flex-direction: row;
  312. justify-content: space-between;
  313. i {
  314. font-size: 18px;
  315. cursor: pointer;
  316. }
  317. }
  318. }
  319. /deep/.el-divider--horizontal {
  320. margin: 0 !important;
  321. }
  322. .minus {
  323. float: right;
  324. line-height: 44px;
  325. padding-right: 20px;
  326. font-size: 20px;
  327. cursor: pointer;
  328. }
  329. </style>