classCompound.vue 9.9 KB

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