view-student-list.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <div>
  3. <el-form :modal="searchForm" ref="searchFormRef" class="forms" inline>
  4. <el-form-item prop="search">
  5. <el-input
  6. v-model="searchForm.search"
  7. placeholder="请输入姓名/手机号"
  8. clearable
  9. ></el-input>
  10. </el-form-item>
  11. <el-form-item prop="subjectId">
  12. <el-select
  13. v-model="searchForm.subjectId"
  14. clearable
  15. placeholder="请选择专业"
  16. >
  17. <el-option
  18. v-for="item in soundList"
  19. :value="item.id"
  20. :label="item.name"
  21. :key="item.id"
  22. ></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item prop="courseType">
  26. <el-select
  27. v-model="searchForm.courseType"
  28. clearable
  29. placeholder="请选择课程剩余时长"
  30. >
  31. <el-option
  32. v-for="item in courseTypeList"
  33. :key="item.id"
  34. :value="item.id"
  35. :label="item.name"
  36. ></el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button @click="onSearch" type="primary">搜索</el-button>
  41. <el-button @click="onReset" type="danger">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-table
  45. :data="list"
  46. ref="studentTable"
  47. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  48. tooltip-effect="dark"
  49. @selection-change="handleSelectionChange"
  50. @select="onTableSelect"
  51. @select-all="onTableSelectALL"
  52. max-height="300px"
  53. @sort-change="sortChang"
  54. >
  55. <el-table-column
  56. v-if="isChiose"
  57. type="selection"
  58. :selectable="checkSelectable"
  59. width="55"
  60. >
  61. </el-table-column>
  62. <el-table-column
  63. prop="userId"
  64. align="center"
  65. width="80"
  66. label="学员编号"
  67. ></el-table-column>
  68. <el-table-column
  69. prop="nickName"
  70. align="center"
  71. width="120"
  72. label="学员姓名"
  73. ></el-table-column>
  74. <el-table-column prop="name" align="center" width="80" label="性别">
  75. <template slot-scope="scope">
  76. <div>
  77. {{ scope.row.gender | sex }}
  78. </div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. prop="phone"
  83. align="center"
  84. width="120"
  85. label="联系电话"
  86. ></el-table-column>
  87. <el-table-column
  88. prop="subjectNames"
  89. align="center"
  90. width="80"
  91. label="专业"
  92. ></el-table-column>
  93. <el-table-column
  94. prop="single"
  95. align="center"
  96. label="声部课"
  97. sortable
  98. >
  99. <template slot-scope="scope">
  100. {{ scope.row.single || 0 }}分钟
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. prop="mix"
  105. align="center"
  106. label="合奏课"
  107. sortable
  108. >
  109. <template slot-scope="scope">
  110. {{ scope.row.mix || 0 }}分钟
  111. </template>
  112. </el-table-column>
  113. <el-table-column
  114. prop="trainingSingle"
  115. align="center"
  116. label="集训声部课"
  117. sortable
  118. >
  119. <template slot-scope="scope">
  120. {{ scope.row.trainingSingle || 0 }}分钟
  121. </template>
  122. </el-table-column>
  123. <el-table-column
  124. prop="trainingMix"
  125. align="center"
  126. label="集训合奏课"
  127. sortable
  128. >
  129. <template slot-scope="scope">
  130. {{ scope.row.trainingMix || 0 }}分钟
  131. </template>
  132. </el-table-column>
  133. <el-table-column
  134. prop="high"
  135. align="center"
  136. label="基础技能课"
  137. sortable
  138. >
  139. <template slot-scope="scope">
  140. {{ scope.row.high || 0 }}分钟
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. prop="highOnline"
  145. align="center"
  146. label="线上基础技能课"
  147. sortable
  148. >
  149. <template slot-scope="scope">
  150. {{ scope.row.highOnline || 0 }}分钟
  151. </template>
  152. </el-table-column>
  153. <el-table-column
  154. prop="comprehensive"
  155. align="center"
  156. label="综合课"
  157. sortable
  158. >
  159. <template slot-scope="scope">
  160. {{ scope.row.comprehensive || 0 }}分钟
  161. </template>
  162. </el-table-column>
  163. <el-table-column
  164. prop="classroom"
  165. align="center"
  166. label="课堂课"
  167. sortable
  168. >
  169. <template slot-scope="scope">
  170. {{ scope.row.classroom || 0 }}分钟
  171. </template>
  172. </el-table-column>
  173. </el-table>
  174. <div slot="footer" class="dialog-footer" v-if="showOk">
  175. <span style="display: flex;align-items: center; font-size: 16px;padding-right: 8px">当前选中:<span style="color: red;">{{ selectList.length || 0 }}</span>人</span>
  176. <el-button type="primary" @click="$listeners.close(selectList)"
  177. >确 定</el-button
  178. >
  179. </div>
  180. <div style="clear: both;" v-if="showOk"></div>
  181. </div>
  182. </template>
  183. <script>
  184. import { getClassAllStudent } from "@/api/studentManager";
  185. export default {
  186. props: ["isChiose", "chioseList", "showOk", "disabledList", "soundList", "search", "classId"],
  187. data() {
  188. return {
  189. list: [],
  190. searchForm: {
  191. search: "",
  192. courseType: null,
  193. subjectId: null,
  194. sortField: null,
  195. sortType: null,
  196. },
  197. // classroom,comprehensive,high,high_online,mix,single,training_mix,training_single,no_course
  198. // 课堂 综合 基础技能 线上基础技能 合奏 声部 集训合奏 集训声部 无排课时长
  199. courseTypeList: [{
  200. id: 'no_course',
  201. name: '无排课时长'
  202. }, {
  203. id: 'single',
  204. name: '声部课'
  205. }, {
  206. id: 'mix',
  207. name: '合奏课'
  208. }, {
  209. id: 'trainingSingle',
  210. name: '集训声部课'
  211. }, {
  212. id: 'trainingMix',
  213. name: '集训合奏课'
  214. }, {
  215. id: 'high',
  216. name: '基础技能课'
  217. }, {
  218. id: 'highOnline',
  219. name: '线上基础技能课'
  220. }, {
  221. id: 'comprehensive',
  222. name: '综合课'
  223. }, {
  224. id: 'classroom',
  225. name: '课堂课'
  226. }],
  227. selectList: this.chioseList || [],
  228. loading: false,
  229. };
  230. },
  231. mounted() {
  232. this.getList()
  233. },
  234. methods: {
  235. getList() {
  236. getClassAllStudent({ classGroupId: this.classId, ...this.searchForm }).then(res => {
  237. if (res.code == 200) {
  238. this.loading = true;
  239. this.list = res.data?.map(item => {
  240. return {
  241. userId: item.userId,
  242. nickName: item.name,
  243. gender: item.gender,
  244. phone: item.parentsPhone,
  245. subjectNames: item.subjectName,
  246. single: item.single,
  247. mix: item.mix,
  248. classroom: item.classroom,
  249. comprehensive: item.comprehensive,
  250. highOnline: item.highOnline,
  251. trainingSingle: item.trainingSingle,
  252. trainingMix: item.trainingMix,
  253. high: item.high
  254. };
  255. });
  256. this.$nextTick(() => {
  257. if (this.selectList) {
  258. let idList = this.selectList.map((item, index) => {
  259. return item.userId;
  260. });
  261. this.list.forEach((item, index) => {
  262. if (idList.indexOf(item.userId) != -1) {
  263. console.log(idList, item.userId)
  264. this.$refs.studentTable.toggleRowSelection(item, true);
  265. }
  266. });
  267. this.loading = false
  268. }
  269. })
  270. }
  271. });
  272. },
  273. sortChang(val) {
  274. const dates = {
  275. ascending: "ASC",
  276. descending: "DESC",
  277. };
  278. if(val.prop && val.order) {
  279. this.searchForm.sortField = val.prop
  280. this.searchForm.sortType = dates[val.order]
  281. } else {
  282. this.searchForm.sortField = null
  283. this.searchForm.sortType = null
  284. }
  285. this.getList();
  286. },
  287. onSearch() {
  288. this.getList()
  289. },
  290. onReset() {
  291. // this.$refs.searchFormRef.resetFields()
  292. this.searchForm.search = ""
  293. this.searchForm.courseType = null
  294. this.searchForm.subjectId = null
  295. this.getList()
  296. },
  297. handleSelectionChange(val) {
  298. // if(this.loading) {
  299. // return
  300. // }
  301. // // console.log(val, 'val', val2)
  302. // // let idList = val.map((group) => {
  303. // // return group.userId;
  304. // // });
  305. // this.selectList = val;
  306. },
  307. onTableSelectALL(val) {
  308. this.selectList = val
  309. },
  310. onTableSelect(rows, row) {
  311. let idList = this.selectList.map((group) => {
  312. return group.userId;
  313. });
  314. let inIdList = rows.map((group) => {
  315. return group.userId;
  316. });
  317. const isAdd = inIdList.indexOf(row.userId) === -1 ? false : true
  318. if(isAdd) {
  319. if(idList.indexOf(row.userId) === -1) {
  320. this.selectList.push(row)
  321. }
  322. } else {
  323. if(idList.indexOf(row.userId) !== -1) {
  324. this.selectList.splice(idList.indexOf(row.userId), 1)
  325. }
  326. }
  327. },
  328. clearCom() {
  329. this.selectList = [];
  330. this.$refs.studentTable.clearSelection();
  331. },
  332. checkSelectable(row) {
  333. let flag = true;
  334. if (this.disabledList && this.disabledList.length > 0) {
  335. this.disabledList.forEach(stu => {
  336. if (stu.userId == row.userId) {
  337. flag = false;
  338. }
  339. });
  340. }
  341. return flag;
  342. }
  343. }
  344. };
  345. </script>
  346. <style lang="scss" scoped>
  347. ::v-deep .dialog-footer {
  348. margin-top: 10px;
  349. }
  350. .dialog-footer {
  351. float: right;
  352. }
  353. </style>