|
|
@@ -6,25 +6,29 @@
|
|
|
<div class="spacer"></div>
|
|
|
<c-button class="exit" text @click="handleLogout" icon="exit_to_app">注销</c-button>
|
|
|
</div>
|
|
|
+
|
|
|
<div class="sub-title">教师用户审核</div>
|
|
|
- <table class="checking-table">
|
|
|
- <tr>
|
|
|
- <td>邮箱</td>
|
|
|
- <td>姓名</td>
|
|
|
- <td>手机号</td>
|
|
|
- <td>申请时间</td>
|
|
|
- <td class="table-center">操作</td>
|
|
|
- </tr>
|
|
|
- <tr v-for="user of checkingUsers" :key="user.id">
|
|
|
- <td>{{user.email}}</td>
|
|
|
- <td>{{user.name}}</td>
|
|
|
- <td>{{user.phone}}</td>
|
|
|
- <td>{{momentFromNow(user.createAt)}}</td>
|
|
|
- <td class="table-center">
|
|
|
- <c-button text icon="check">审核通过</c-button>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- </table>
|
|
|
+ <checking-users-table :checking-users="checkingUsers" @update="updateData"></checking-users-table>
|
|
|
+
|
|
|
+ <div class="sub-title mt-32">用户管理</div>
|
|
|
+ <search-bar class="mb-16" v-model="searchKey" @input="debounceSearch"></search-bar>
|
|
|
+ <div class="vertical-center mb-16">
|
|
|
+ <c-button icon="face" :theme="searchType === userType.student ? 'green' : 'normal'" class="mr-8"
|
|
|
+ @click="searchType = userType.student">查看学生
|
|
|
+ </c-button>
|
|
|
+ <c-button icon="supervised_user_circle" class="mr-8" :theme="searchType === userType.teacher ? 'blue' : 'normal'"
|
|
|
+ @click="searchType = userType.teacher">查看教师
|
|
|
+ </c-button>
|
|
|
+ <div class="spacer"></div>
|
|
|
+ <c-button :icon="searchState === userState.normal ? 'lock' : 'lock_open'"
|
|
|
+ @click="searchState === userState.normal ? searchState = userState.locked : searchState = userState.normal"
|
|
|
+ :theme="searchState === userState.normal ? 'red' : 'green'">
|
|
|
+ 查看{{searchState === userState.normal ? '封禁' : '正常'}}账号
|
|
|
+ </c-button>
|
|
|
+ </div>
|
|
|
+ <users-table :users="users" @update-users="updateUsers({})"></users-table>
|
|
|
+ <pagination @change="handlePageChange" v-show="users && users.length > 0" :page="page" :size="size"
|
|
|
+ :total-elements="totalElements"></pagination>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -36,33 +40,82 @@ import { getUsers } from '@/server/admin'
|
|
|
import { userState } from '@/server/enums/user-state'
|
|
|
import userType from '@/server/enums/user-type'
|
|
|
import momentFromNow from '@/utils/moment-from-now'
|
|
|
+import CheckingUsersTable from '@/views/admin/CheckingUsersTable'
|
|
|
+import UsersTable from '@/views/admin/UsersTable'
|
|
|
+import SearchBar from '@/components/Basic/SearchBar'
|
|
|
+import debounce from '@/utils/debounce'
|
|
|
+import Pagination from '@/components/Pagination'
|
|
|
|
|
|
export default {
|
|
|
- components: { CButton, CIcon },
|
|
|
+ components: { Pagination, SearchBar, UsersTable, CheckingUsersTable, CButton, CIcon },
|
|
|
data () {
|
|
|
return {
|
|
|
checkingUsers: null,
|
|
|
|
|
|
+ page: 1,
|
|
|
+ totalElements: 10,
|
|
|
+ size: 12,
|
|
|
+ users: null,
|
|
|
+ searchKey: '',
|
|
|
+ searchType: userType.student,
|
|
|
+ searchState: userState.normal,
|
|
|
+
|
|
|
userType,
|
|
|
- userState
|
|
|
+ userState,
|
|
|
+
|
|
|
+ debounceSearch: debounce(() => {
|
|
|
+ this.page = 1
|
|
|
+ this.updateUsers({})
|
|
|
+ }, 300)
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
this.updateData()
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ searchState () {
|
|
|
+ this.page = 1
|
|
|
+ this.updateUsers({})
|
|
|
+ },
|
|
|
+ searchType () {
|
|
|
+ this.page = 1
|
|
|
+ this.updateUsers({})
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
updateData () {
|
|
|
+ this.updateCheckingUsers()
|
|
|
+ this.updateUsers({})
|
|
|
+ },
|
|
|
+ updateCheckingUsers () {
|
|
|
// 获取状态为正在审核中的用户
|
|
|
getUsers({ state: userState.checking, type: userType.teacher, size: 200 })
|
|
|
.then(res => { this.checkingUsers = res.data })
|
|
|
.catch(err => { this.$setErrorMessage(err.response.data.msg) })
|
|
|
},
|
|
|
+ updateUsers ({ page = this.page }) {
|
|
|
+ // 按条件获取所有用户
|
|
|
+ getUsers({ page, key: this.searchKey, state: this.searchState, type: this.searchType, size: this.size })
|
|
|
+ .then(res => {
|
|
|
+ console.log(res)
|
|
|
+ this.users = res.data
|
|
|
+ this.totalElements = res.page.totalElements
|
|
|
+ if (this.page > res.page.totalPages) {
|
|
|
+ this.page = res.page.totalPages
|
|
|
+ this.updateUsers({})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => { this.$setErrorMessage(err.response.data.msg) })
|
|
|
+ },
|
|
|
handleLogout () {
|
|
|
logout()
|
|
|
this.$setSuccessMessage('您已退出登录')
|
|
|
this.$router.push({ name: 'login' })
|
|
|
},
|
|
|
-
|
|
|
+ handlePageChange ({ page }) {
|
|
|
+ this.page = page
|
|
|
+ this.updateUsers({ page })
|
|
|
+ },
|
|
|
momentFromNow
|
|
|
}
|
|
|
}
|
|
|
@@ -70,6 +123,7 @@ export default {
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@import "~@/style/theme.scss";
|
|
|
+
|
|
|
.admin {
|
|
|
margin: 64px auto;
|
|
|
max-width: 800px;
|
|
|
@@ -80,22 +134,4 @@ export default {
|
|
|
width: 1px;
|
|
|
flex: 1;
|
|
|
}
|
|
|
-
|
|
|
-.checking-table {
|
|
|
- width: 100%;
|
|
|
- margin: 8px -8px;
|
|
|
-
|
|
|
- .table-center {
|
|
|
- text-align: center;
|
|
|
- }
|
|
|
-
|
|
|
- tr:first-child {
|
|
|
- color: $theme-blue;
|
|
|
- background-color: $card-background;
|
|
|
- }
|
|
|
-
|
|
|
- td {
|
|
|
- padding: 4px 8px;
|
|
|
- }
|
|
|
-}
|
|
|
</style>
|