index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div class="student-list">
  3. <div class="search">
  4. <el-input v-model.trim="student_name" prefix-icon="el-icon-search" @change="queryCourseStudentList">
  5. <el-button slot="append" @click="queryCourseStudentList">
  6. {{ $t('Key131') }}
  7. </el-button>
  8. </el-input>
  9. </div>
  10. <div class="student-list-container">
  11. <div class="tabs">
  12. <div class="tabs-left">
  13. <span
  14. v-for="item in tabList"
  15. :key="item.type"
  16. :class="['tabs-item', { active: item.type === curTab }]"
  17. @click="changeTab(item.type)"
  18. >
  19. {{ $t(item.name) }}
  20. </span>
  21. </div>
  22. <div v-if="curTab === tabList[1].type" class="tabs-right">
  23. <el-button @click="sendMessage('all')">
  24. <span><svg-icon icon-class="send-message" /> {{ $t('Key299') }}</span>
  25. </el-button>
  26. </div>
  27. </div>
  28. <div class="student-table">
  29. <el-table :data="list">
  30. <el-table-column width="280">
  31. <template slot-scope="{ row }">
  32. <el-avatar icon="el-icon-user" size="small" :src="row.image_url" />
  33. <span class="student-name">{{ row.student_name }}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="age" width="120">
  37. <template slot-scope="scope"> {{ scope.row.age }}岁 </template>
  38. </el-table-column>
  39. <el-table-column prop="org_name" width="280" />
  40. <el-table-column prop="country_name" width="180" />
  41. <el-table-column>
  42. <template slot-scope="{ row }">
  43. <span>{{ row.is_pay === 'true' ? $t('Key306') : $t('Key307') }}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column fixed="right" width="160">
  47. <template slot-scope="{ row }">
  48. <template v-if="curTab === tabList[0].type">
  49. <span class="agree" @click="auditCourseStudent(row.course_student_id, 'true')">
  50. {{ $t('Key303') }}
  51. </span>
  52. <span class="refuse" @click="auditCourseStudent(row.course_student_id, 'false')">
  53. {{ $t('Key304') }}
  54. </span>
  55. </template>
  56. <template v-if="curTab === tabList[1].type">
  57. <span class="agree" @click="sendMessage('single', row.student_id, row.student_name)">
  58. {{ $t('Key305') }}
  59. </span>
  60. <span class="refuse" @click="deleteStudent(row.course_student_id)">{{ $t('Key172') }}</span>
  61. </template>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. </div>
  66. </div>
  67. <el-pagination
  68. background
  69. :page-sizes="[10, 20, 30, 40, 50]"
  70. :page-size="page_capacity"
  71. layout="prev, pager, next, total, sizes, jumper"
  72. :total="total_count"
  73. :current-page="cur_page"
  74. @prev-click="changePage"
  75. @next-click="changePage"
  76. @current-change="changePage"
  77. @size-change="changePageSize"
  78. />
  79. <SendMessage :visible.sync="visible" :title-name="titleName" @sendMessage="sendMessageToCourseStudent" />
  80. </div>
  81. </template>
  82. <script>
  83. export default {
  84. name: 'StudentList'
  85. };
  86. </script>
  87. <script setup>
  88. import { ref, inject } from 'vue';
  89. import { PageQueryCourseStudentList, DeleteStudent } from '@/api/list';
  90. import { AuditCourseStudent, SendMessageToCourseStudent } from '@/api/course';
  91. import { useList } from '@/utils/list';
  92. import { useRoute } from 'vue-router/composables';
  93. import { Loading, Message, MessageBox } from 'element-ui';
  94. import SendMessage from './SendMessage.vue';
  95. const route = useRoute();
  96. let curTab = ref('new');
  97. const tabList = [
  98. {
  99. type: 'new',
  100. name: 'Key298'
  101. },
  102. {
  103. type: 'list',
  104. name: 'Key296'
  105. }
  106. ];
  107. let { page_capacity, cur_page, total_count, list, changePage, changePageSize } = useList();
  108. let course_id = ref(route.params.id);
  109. let student_name = ref('');
  110. function queryCourseStudentList() {
  111. PageQueryCourseStudentList({
  112. student_name: student_name.value,
  113. course_id: course_id.value,
  114. page_capacity: page_capacity.value,
  115. cur_page: cur_page.value,
  116. audit_status_list: curTab.value === 'new' ? [0] : [1]
  117. }).then(({ student_list, total_count: total, cur_page: page }) => {
  118. list.value = student_list;
  119. total_count.value = total;
  120. cur_page.value = page;
  121. });
  122. }
  123. queryCourseStudentList();
  124. function changeTab(tab) {
  125. list.value = [];
  126. curTab.value = tab;
  127. queryCourseStudentList();
  128. }
  129. let type = ref('');
  130. let student_id = ref('');
  131. let visible = ref(false);
  132. let titleName = ref('');
  133. function sendMessage(types, studentId, student_name) {
  134. type.value = types;
  135. student_id.value = studentId;
  136. titleName.value = type.value === 'all' ? '全部' : student_name;
  137. visible.value = true;
  138. }
  139. const $t = inject('$t');
  140. function sendMessageToCourseStudent(content) {
  141. const loading = Loading.service({ text: $t('Key624') });
  142. SendMessageToCourseStudent({
  143. course_id: course_id.value,
  144. content,
  145. type: type.value,
  146. student_id: student_id.value
  147. })
  148. .then(() => {
  149. visible.value = false;
  150. Message.success($t('Key626'));
  151. })
  152. .finally(() => {
  153. loading.close();
  154. });
  155. }
  156. function auditCourseStudent(course_student_id, is_audited) {
  157. AuditCourseStudent({ course_student_id, is_audited }).then(() => {
  158. Message.success($t('Key625'));
  159. queryCourseStudentList();
  160. });
  161. }
  162. function deleteStudent(course_student_id) {
  163. MessageBox.confirm('确定要删除该学生吗?', $t('Key361'), {
  164. confirmButtonText: $t('Key94'),
  165. cancelButtonText: $t('Key83'),
  166. type: 'warning'
  167. }).then(() => {
  168. DeleteStudent({ course_student_id }).then(() => {
  169. Message.success('删除成功');
  170. queryCourseStudentList();
  171. });
  172. });
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. @import '~@/styles/mixin';
  177. .student-list {
  178. @include container;
  179. @include pagination;
  180. .search .el-input {
  181. width: 528px;
  182. }
  183. &-container {
  184. width: 100%;
  185. min-height: calc(100vh - 240px);
  186. margin-top: 16px;
  187. background-color: #fff;
  188. border-radius: 8px;
  189. // 标签
  190. .tabs {
  191. display: flex;
  192. justify-content: space-between;
  193. height: 68px;
  194. padding: 16px 16px 0 32px;
  195. border-bottom: 1px solid #d9d9d9;
  196. &-left {
  197. display: flex;
  198. align-items: flex-end;
  199. .tabs-item {
  200. padding-bottom: 16px;
  201. font-size: 18px;
  202. cursor: pointer;
  203. &.active {
  204. font-weight: 600;
  205. box-shadow: 0 1px 0 $basic-color, 0 -1px 0 $basic-color inset;
  206. }
  207. &:not(:first-child) {
  208. margin-left: 24px;
  209. }
  210. }
  211. }
  212. &-right {
  213. .el-button {
  214. height: 40px;
  215. padding: 8px 16px;
  216. .svg-icon {
  217. width: 24px;
  218. height: 24px;
  219. margin-right: 8px;
  220. vertical-align: middle;
  221. }
  222. }
  223. }
  224. }
  225. // 学员列表
  226. .student-table {
  227. @include list;
  228. min-height: calc(100vh - 343px);
  229. margin-top: 0;
  230. :deep .el-table__header {
  231. display: none;
  232. }
  233. .agree {
  234. margin-right: 32px;
  235. color: #2a99ff;
  236. cursor: pointer;
  237. }
  238. .refuse {
  239. color: #ff3c3c;
  240. cursor: pointer;
  241. }
  242. .el-avatar {
  243. margin-left: 22px;
  244. vertical-align: sub;
  245. }
  246. .student-name {
  247. display: inline-block;
  248. margin-left: 16px;
  249. vertical-align: super;
  250. }
  251. }
  252. }
  253. }
  254. </style>