index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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="student_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. </template>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. </div>
  65. </div>
  66. <el-pagination
  67. background
  68. :page-sizes="[10, 20, 30, 40, 50]"
  69. :page-size="page_capacity"
  70. layout="prev, pager, next, total, sizes, jumper"
  71. :total="total_count"
  72. :current-page="cur_page"
  73. @prev-click="changePage"
  74. @next-click="changePage"
  75. @current-change="changePage"
  76. @size-change="changePageSize"
  77. />
  78. <send-message :visible.sync="visible" :title-name="titleName" @sendMessage="sendMessageToCourseStudent" />
  79. </div>
  80. </template>
  81. <script>
  82. import { PageQueryCourseStudentList } from '@/api/list';
  83. import { AuditCourseStudent, SendMessageToCourseStudent } from '@/api/course';
  84. import SendMessage from './SendMessage.vue';
  85. export default {
  86. components: {
  87. SendMessage
  88. },
  89. data() {
  90. return {
  91. course_id: this.$route.params.id,
  92. student_name: '',
  93. curTab: 'new',
  94. visible: false,
  95. titleName: '',
  96. type: '',
  97. student_id: '',
  98. student_list: [],
  99. page_capacity: 10,
  100. cur_page: 1,
  101. total_count: 0,
  102. tabList: [
  103. {
  104. type: 'new',
  105. name: 'Key298'
  106. },
  107. {
  108. type: 'list',
  109. name: 'Key296'
  110. }
  111. ]
  112. };
  113. },
  114. created() {
  115. this.queryCourseStudentList();
  116. this.updateWordPack({
  117. word_key_list: [
  118. 'Key131',
  119. 'Key299',
  120. 'Key298',
  121. 'Key296',
  122. 'Key303',
  123. 'Key304',
  124. 'Key305',
  125. 'Key306',
  126. 'Key307',
  127. 'Key624',
  128. 'Key625',
  129. 'Key626'
  130. ]
  131. });
  132. },
  133. methods: {
  134. queryCourseStudentList() {
  135. PageQueryCourseStudentList({
  136. student_name: this.student_name,
  137. course_id: this.course_id,
  138. page_capacity: this.page_capacity,
  139. cur_page: this.cur_page,
  140. audit_status_list: this.curTab === 'new' ? [0] : [1]
  141. }).then(({ student_list, total_count, cur_page }) => {
  142. this.student_list = student_list;
  143. this.total_count = total_count;
  144. this.cur_page = cur_page;
  145. });
  146. },
  147. changeTab(tab) {
  148. this.student_list = [];
  149. this.curTab = tab;
  150. this.queryCourseStudentList();
  151. },
  152. changePage(newPage) {
  153. this.cur_page = newPage;
  154. this.queryCourseStudentList();
  155. },
  156. changePageSize(pageSize) {
  157. this.page_capacity = pageSize;
  158. this.queryCourseStudentList();
  159. },
  160. sendMessage(type, student_id, student_name) {
  161. this.type = type;
  162. this.student_id = student_id;
  163. if (type === 'all') {
  164. this.titleName = '全部';
  165. } else {
  166. this.titleName = student_name;
  167. }
  168. this.visible = true;
  169. },
  170. sendMessageToCourseStudent(content) {
  171. let loading = this.$loading(this.$i18n.t('Key624'));
  172. SendMessageToCourseStudent({
  173. course_id: this.course_id,
  174. content,
  175. type: this.type,
  176. student_id: this.student_id
  177. })
  178. .then(() => {
  179. this.visible = false;
  180. this.$message.success(this.$i18n.t('Key626'));
  181. })
  182. .finally(() => {
  183. loading.close();
  184. });
  185. },
  186. auditCourseStudent(course_student_id, is_audited) {
  187. AuditCourseStudent({ course_student_id, is_audited }).then(() => {
  188. this.$message.success(this.$i18n.t('Key625'));
  189. this.queryCourseStudentList();
  190. });
  191. }
  192. }
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. @import '~@/styles/mixin';
  197. .student-list {
  198. @include container;
  199. @include pagination;
  200. .search .el-input {
  201. width: 528px;
  202. }
  203. &-container {
  204. width: 100%;
  205. min-height: calc(100vh - 240px);
  206. margin-top: 16px;
  207. background-color: #fff;
  208. border-radius: 8px;
  209. // 标签
  210. .tabs {
  211. display: flex;
  212. justify-content: space-between;
  213. height: 68px;
  214. padding: 16px 16px 0 32px;
  215. border-bottom: 1px solid #d9d9d9;
  216. &-left {
  217. display: flex;
  218. align-items: flex-end;
  219. .tabs-item {
  220. padding-bottom: 16px;
  221. font-size: 18px;
  222. cursor: pointer;
  223. &.active {
  224. font-weight: 600;
  225. box-shadow: 0 1px 0 $basic-color, 0 -1px 0 $basic-color inset;
  226. }
  227. &:not(:first-child) {
  228. margin-left: 24px;
  229. }
  230. }
  231. }
  232. &-right {
  233. .el-button {
  234. height: 40px;
  235. padding: 8px 16px;
  236. .svg-icon {
  237. width: 24px;
  238. height: 24px;
  239. margin-right: 8px;
  240. vertical-align: middle;
  241. }
  242. }
  243. }
  244. }
  245. // 学员列表
  246. .student-table {
  247. @include list;
  248. min-height: calc(100vh - 343px);
  249. margin-top: 0;
  250. ::v-deep .el-table__header {
  251. display: none;
  252. }
  253. .agree {
  254. margin-right: 32px;
  255. color: #2a99ff;
  256. cursor: pointer;
  257. }
  258. .refuse {
  259. color: #ff3c3c;
  260. cursor: pointer;
  261. }
  262. .el-avatar {
  263. margin-left: 22px;
  264. vertical-align: sub;
  265. }
  266. .student-name {
  267. display: inline-block;
  268. margin-left: 16px;
  269. vertical-align: super;
  270. }
  271. }
  272. }
  273. }
  274. </style>