user-detail

This commit is contained in:
xiaomlove
2021-04-27 19:13:32 +08:00
parent d1b7561aae
commit d2e05c812e
20 changed files with 594 additions and 50 deletions
+128
View File
@@ -126,6 +126,16 @@
"resolved": "https://registry.npm.taobao.org/@vue/shared/download/@vue/shared-3.0.11.tgz?cache=0&sync_timestamp=1617321555263&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fshared%2Fdownload%2F%40vue%2Fshared-3.0.11.tgz",
"integrity": "sha1-INIt0Np9NYuyHBf5vehigVJkLHc="
},
"anymatch": {
"version": "3.1.2",
"resolved": "https://registry.npm.taobao.org/anymatch/download/anymatch-3.1.2.tgz",
"integrity": "sha1-wFV8CWrzLxBhmPT04qODU343hxY=",
"dev": true,
"requires": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
}
},
"async-validator": {
"version": "3.5.1",
"resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-3.5.1.tgz?cache=0&sync_timestamp=1605749896979&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fasync-validator%2Fdownload%2Fasync-validator-3.5.1.tgz",
@@ -145,12 +155,43 @@
"integrity": "sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg=",
"dev": true
},
"binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npm.taobao.org/binary-extensions/download/binary-extensions-2.2.0.tgz?cache=0&sync_timestamp=1610299308660&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbinary-extensions%2Fdownload%2Fbinary-extensions-2.2.0.tgz",
"integrity": "sha1-dfUC7q+f/eQvyYgpZFvk6na9ni0=",
"dev": true
},
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npm.taobao.org/bluebird/download/bluebird-3.7.2.tgz?cache=0&sync_timestamp=1589682744631&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbluebird%2Fdownload%2Fbluebird-3.7.2.tgz",
"integrity": "sha1-nyKcFb4nJFT/qXOs4NvueaGww28=",
"dev": true
},
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npm.taobao.org/braces/download/braces-3.0.2.tgz",
"integrity": "sha1-NFThpGLujVmeI23zNs2epPiv4Qc=",
"dev": true,
"requires": {
"fill-range": "^7.0.1"
}
},
"chokidar": {
"version": "3.5.1",
"resolved": "https://registry.npm.taobao.org/chokidar/download/chokidar-3.5.1.tgz?cache=0&sync_timestamp=1610719430924&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fchokidar%2Fdownload%2Fchokidar-3.5.1.tgz",
"integrity": "sha1-7pznu+vSt59J8wR5nVRo4x4U5oo=",
"dev": true,
"requires": {
"anymatch": "~3.1.1",
"braces": "~3.0.2",
"fsevents": "~2.3.1",
"glob-parent": "~5.1.0",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.5.0"
}
},
"colorette": {
"version": "1.2.2",
"resolved": "https://registry.npm.taobao.org/colorette/download/colorette-1.2.2.tgz?cache=0&sync_timestamp=1614259623635&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcolorette%2Fdownload%2Fcolorette-1.2.2.tgz",
@@ -214,6 +255,15 @@
"resolved": "https://registry.npm.taobao.org/estree-walker/download/estree-walker-2.0.2.tgz?cache=0&sync_timestamp=1611956983677&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Festree-walker%2Fdownload%2Festree-walker-2.0.2.tgz",
"integrity": "sha1-UvAQF4wqTBF6d1fP6UKtt9LaTKw="
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npm.taobao.org/fill-range/download/fill-range-7.0.1.tgz",
"integrity": "sha1-GRmmp8df44ssfHflGYU12prN2kA=",
"dev": true,
"requires": {
"to-regex-range": "^5.0.1"
}
},
"follow-redirects": {
"version": "1.13.3",
"resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.13.3.tgz",
@@ -241,6 +291,15 @@
"loader-utils": "^1.1.0"
}
},
"glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npm.taobao.org/glob-parent/download/glob-parent-5.1.2.tgz?cache=0&sync_timestamp=1615065997979&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fglob-parent%2Fdownload%2Fglob-parent-5.1.2.tgz",
"integrity": "sha1-hpgyxYA0/mikCTwX3BXoNA2EAcQ=",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npm.taobao.org/has/download/has-1.0.3.tgz",
@@ -268,6 +327,15 @@
"integrity": "sha1-xr5oWKvQE9do6YNmrkfiXViHsa4=",
"dev": true
},
"is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npm.taobao.org/is-binary-path/download/is-binary-path-2.1.0.tgz",
"integrity": "sha1-6h9/O4DwZCNug0cPhsCcJU+0Wwk=",
"dev": true,
"requires": {
"binary-extensions": "^2.0.0"
}
},
"is-core-module": {
"version": "2.2.0",
"resolved": "https://registry.npm.taobao.org/is-core-module/download/is-core-module-2.2.0.tgz?cache=0&sync_timestamp=1606411622542&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-core-module%2Fdownload%2Fis-core-module-2.2.0.tgz",
@@ -277,6 +345,27 @@
"has": "^1.0.3"
}
},
"is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npm.taobao.org/is-extglob/download/is-extglob-2.1.1.tgz",
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
"dev": true
},
"is-glob": {
"version": "4.0.1",
"resolved": "https://registry.npm.taobao.org/is-glob/download/is-glob-4.0.1.tgz",
"integrity": "sha1-dWfb6fL14kZ7x3q4PEopSCQHpdw=",
"dev": true,
"requires": {
"is-extglob": "^2.1.1"
}
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npm.taobao.org/is-number/download/is-number-7.0.0.tgz",
"integrity": "sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss=",
"dev": true
},
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npm.taobao.org/json5/download/json5-1.0.1.tgz",
@@ -352,6 +441,12 @@
"integrity": "sha1-s1+Pt9FRmQqK69WqUBXAPPcm+EQ=",
"dev": true
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npm.taobao.org/normalize-path/download/normalize-path-3.0.0.tgz",
"integrity": "sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU=",
"dev": true
},
"normalize-wheel": {
"version": "1.0.1",
"resolved": "https://registry.npm.taobao.org/normalize-wheel/download/normalize-wheel-1.0.1.tgz",
@@ -363,6 +458,12 @@
"integrity": "sha1-1i27VnlAXXLEc37FhgDp3c8G0kw=",
"dev": true
},
"picomatch": {
"version": "2.2.3",
"resolved": "https://registry.npm.taobao.org/picomatch/download/picomatch-2.2.3.tgz",
"integrity": "sha1-RlVH81nMwgbTxI5Goby4m/fuYZ0=",
"dev": true
},
"postcss": {
"version": "8.2.10",
"resolved": "https://registry.npm.taobao.org/postcss/download/postcss-8.2.10.tgz?cache=0&sync_timestamp=1618159223724&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpostcss%2Fdownload%2Fpostcss-8.2.10.tgz",
@@ -441,6 +542,15 @@
"integrity": "sha1-RD9qIM7WSBor2k+oUypuVdeJoss=",
"dev": true
},
"readdirp": {
"version": "3.5.0",
"resolved": "https://registry.npm.taobao.org/readdirp/download/readdirp-3.5.0.tgz?cache=0&sync_timestamp=1615717369278&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freaddirp%2Fdownload%2Freaddirp-3.5.0.tgz",
"integrity": "sha1-m6dMAZsV02UnjS6Ru4xI17TULJ4=",
"dev": true,
"requires": {
"picomatch": "^2.2.1"
}
},
"resize-observer-polyfill": {
"version": "1.5.1",
"resolved": "https://registry.npm.taobao.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz",
@@ -465,6 +575,15 @@
"fsevents": "~2.3.1"
}
},
"sass": {
"version": "1.32.11",
"resolved": "https://registry.nlark.com/sass/download/sass-1.32.11.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fsass%2Fdownload%2Fsass-1.32.11.tgz",
"integrity": "sha1-sjaz6lXHZgLC7yvQRF8NtYG6ohg=",
"dev": true,
"requires": {
"chokidar": ">=3.0.0 <4.0.0"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz?cache=0&sync_timestamp=1589682764497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map%2Fdownload%2Fsource-map-0.6.1.tgz",
@@ -487,6 +606,15 @@
"resolved": "https://registry.npm.taobao.org/to-fast-properties/download/to-fast-properties-2.0.0.tgz",
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4="
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npm.taobao.org/to-regex-range/download/to-regex-range-5.0.1.tgz",
"integrity": "sha1-FkjESq58jZiKMmAY7XL1tN0DkuQ=",
"dev": true,
"requires": {
"is-number": "^7.0.0"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz",
+1
View File
@@ -15,6 +15,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^1.2.1",
"@vue/compiler-sfc": "^3.0.5",
"sass": "^1.32.11",
"vite": "^2.1.5"
}
}
+1 -1
View File
@@ -3,5 +3,5 @@ import App from './App.vue'
import ElementPlus from 'element-plus'
import router from './router/index'
import 'element-plus/lib/theme-chalk/index.css'
// import './styles/common.scss'
import './styles/common.scss'
createApp(App).use(ElementPlus).use(router).mount('#app')
+5
View File
@@ -23,6 +23,11 @@ const router = createRouter({
name: 'user-form',
component: () => import('../views/user/form.vue')
},
{
path: '/user-detail',
name: 'user-detail',
component: () => import('../views/user/detail.vue')
},
{
path: '/exam',
name: 'exam',
+4
View File
@@ -0,0 +1,4 @@
.nexus-table-header {
display: flex;
justify-content: space-between;
}
+8 -2
View File
@@ -26,6 +26,9 @@ const api = {
listUser: (params = {}) => {
return axios.get('user', {params: params});
},
getUser: (id, params = {}) => {
return axios.get('user/' + id, {params: params});
},
getUserBase: (params = {}) => {
return axios.get('user-base', {params: params});
},
@@ -37,7 +40,7 @@ const api = {
return axios.get('exam', {params: params});
},
listExamIndex: (params = {}) => {
return axios.get('exam-index', {params: params});
return axios.get('exam-indexes', {params: params});
},
storeExam: (params = {}) => {
return axios.post('exam', params);
@@ -52,11 +55,14 @@ const api = {
return axios.delete('exam/' + id);
},
listClass: (params = {}) => {
return axios.get('class', {params: params});
return axios.get('user-classes', {params: params});
},
listExamUser: (params = {}) => {
return axios.get('exam-users', {params: params});
},
deleteExamUser: (id) => {
return axios.delete('exam-users/' + id);
},
}
export default api
+1
View File
@@ -42,6 +42,7 @@ export const pathMap = {
'agent-allow-form': 'Agent allow form',
'user': 'User',
'user-form': 'User form',
'user-detail': 'User detail',
'exam': 'Exam',
'exam-form': 'Exam form',
'exam-user': 'Exam user',
+7 -2
View File
@@ -1,8 +1,13 @@
<template>
<el-card class="">
<template #header>
<div class="header">
<el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd">Add</el-button>
<div class="nexus-table-header">
<div class="left">
</div>
<div class="right">
<el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd">Add</el-button>
</div>
</div>
</template>
<el-table
+18 -11
View File
@@ -57,17 +57,17 @@
label="Action"
width="100"
>
<!-- <template #default="scope">-->
<!-- <a style="cursor: pointer; margin-right: 10px" @click="handleEdit(scope.row.id)">Edit</a>-->
<!-- <el-popconfirm-->
<!-- title="Confirm Delete ?"-->
<!-- @confirm="handleDelete(scope.row.id)"-->
<!-- >-->
<!-- <template #reference>-->
<!-- <a style="cursor: pointer">Delete</a>-->
<!-- </template>-->
<!-- </el-popconfirm>-->
<!-- </template>-->
<template #default="scope">
<a style="cursor: pointer; margin-right: 10px" @click="handleDetail(scope.row.uid)">Detail</a>
<!-- <el-popconfirm-->
<!-- title="Confirm Delete ?"-->
<!-- @confirm="handleDelete(scope.row.id)"-->
<!-- >-->
<!-- <template #reference>-->
<!-- <a style="cursor: pointer">Delete</a>-->
<!-- </template>-->
<!-- </el-popconfirm>-->
</template>
</el-table-column>
</el-table>
<!--总数超过一页再展示分页器-->
@@ -130,6 +130,12 @@ export default {
resetTableSort(val, state)
fetchTableData()
}
const handleDetail = (id) => {
router.push({
name: 'user-detail',
query: {id: id}
})
}
const formatColumnUser = (row, column) => {
return row.user.username
@@ -148,6 +154,7 @@ export default {
handleAdd,
handleEdit,
handleDelete,
handleDetail,
fetchTableData,
changePage,
handleSortChange,
+182
View File
@@ -0,0 +1,182 @@
<template>
<div class="page-user-detail" v-loading="loading">
<el-card>
<template #header>
<div class="card-header">
<span>Base Info</span>
</div>
</template>
<table class="table-base-info">
<tr>
<th>Field</th>
<th>Value</th>
<th>Actions</th>
<th>Other</th>
</tr>
<tr>
<td>Username</td>
<td>{{baseInfo.username}}</td>
<td></td>
<td colspan="7">
<div class="other-actions">
<el-button type="primary" size="mini">Reset password</el-button>
<el-button type="primary" size="mini">PM</el-button>
<el-button type="primary" size="mini" @click="handleAssignExam">Assign exam</el-button>
</div>
</td>
</tr>
<tr>
<td>Email</td>
<td>{{baseInfo.email}}</td>
<td><el-button size="mini">Change</el-button></td>
</tr>
<tr>
<td>Added</td>
<td>{{baseInfo.added}}</td>
</tr>
<tr>
<td>Class</td>
<td>{{baseInfo.class_text}}</td>
</tr>
<tr>
<td>Uploaded</td>
<td>{{baseInfo.uploaded}}</td>
<td><el-button size="mini">Add</el-button></td>
</tr>
<tr>
<td>Downloaded</td>
<td>{{baseInfo.downloaded}}</td>
<td><el-button size="mini">Add</el-button></td>
</tr>
<tr>
<td>Bonus</td>
<td>{{baseInfo.bonus}}</td>
<td><el-button size="mini">Add</el-button></td>
</tr>
</table>
</el-card>
<el-card v-if="examInfo">
<template #header>
<div class="card-header">
<span>Exam</span>
</div>
</template>
<el-row>
<el-col :span="12">
<table class="table-base-info">
<tr>
<td>Name</td>
<td>{{examInfo.exam && examInfo.exam.name}}</td>
</tr>
<tr>
<td>Created At</td>
<td>{{examInfo.created_at}}</td>
</tr>
<tr>
<td>Exam Time</td>
<td>{{examInfo.begin}} ~ {{examInfo.end}}</td>
</tr>
<tr>
<td>Status</td>
<td>{{examInfo.status_text}}</td>
</tr>
<tr>
<td>Action</td>
<td>
<el-popconfirm
title="Confirm Remove ?"
@confirm="handleRemoveExam(examInfo.id)"
>
<template #reference>
<el-button type="danger" size="small">Remove</el-button>
</template>
</el-popconfirm>
</td>
</tr>
</table>
</el-col>
<el-col :span="12">
<el-table :data="examInfo.progress_formatted">
<el-table-column prop="name" label="Index"></el-table-column>
<el-table-column prop="require_value_formatted" label="Require"></el-table-column>
<el-table-column prop="current_value_formatted" label="Current"></el-table-column>
<el-table-column prop="result" label="Result">
<template #default="scope">
<el-tag v-if="scope.row.passed" type="success">Pass !</el-tag>
<el-tag v-if="!scope.row.passed" type="danger">Not Pass !</el-tag>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script>
import { onMounted, reactive, ref, toRefs } from 'vue'
import { ElMessage } from 'element-plus'
import {useRoute, useRouter} from 'vue-router'
import api from '../../utils/api'
export default {
name: "UserDetail",
setup() {
const route = useRoute()
const router = useRouter()
const { id } = route.query
const state = reactive({
loading: false,
baseInfo: {},
examInfo: {},
matchExams: [],
dialogAssignExamFormVisible: false,
assignExamFormData: {
exam_id: '',
timeRange: []
}
})
onMounted(() => {
fetchPageData()
})
const fetchPageData = async () => {
state.loading = true;
let res = await api.getUser(id)
state.loading = false
state.baseInfo = res.data.base_info
state.examInfo = res.data.exam_info
}
const handleRemoveExam = async (id) => {
let res = await api.deleteExamUser(id)
ElMessage.success(res.msg)
await fetchPageData()
}
const handleAssignExam = async () => {
state.dialogAssignExamFormVisible = true;
}
return {
...toRefs(state),
handleRemoveExam,
handleAssignExam
}
}
}
</script>
<style lang="scss" scoped>
.el-card {
margin-bottom: 20px;
}
.table-base-info {
width: 100%;
text-align: left;
tr {
th {
padding-bottom: 10px;
}
td {
padding: 10px 0;
}
}
}
</style>
@@ -0,0 +1,38 @@
<template>
<el-dialog
title="Assign exam to user"
v-model="dialogAssignExamFormVisible"
center
class="dialog-assign-exam"
>
<el-form :model="assignExamFormData" label-width="150px">
<el-form-item label="Exam">
<el-select v-model="assignExamFormData.exam_id" placeholder="Select an exam...">
<el-option
v-for="item in matchExams"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="Exam time range">
<el-date-picker
v-model="assignExamFormData.timeRange"
type="datetimerange"
format="YYYY-MM-DD HH:mm:ss"
range-separator="to"
start-placeholder="Begin"
end-placeholder="End">
</el-date-picker>
<div class="time-range-help-text">If the time range is not specified, the exam's own configured time range will be used.</div>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogAssignExamFormVisible = false"> </el-button>
<el-button type="primary" @click="dialogAssignExamFormVisible = false"> </el-button>
</span>
</template>
</el-dialog>
</template>
+11 -3
View File
@@ -77,8 +77,8 @@
label="Action"
width="100"
>
<!-- <template #default="scope">-->
<!-- <a style="cursor: pointer; margin-right: 10px" @click="handleEdit(scope.row.id)">Edit</a>-->
<template #default="scope">
<a style="cursor: pointer; margin-right: 10px" @click="handleDetail(scope.row.id)">Detail</a>
<!-- <el-popconfirm-->
<!-- title="Confirm Delete ?"-->
<!-- @confirm="handleDelete(scope.row.id)"-->
@@ -87,7 +87,7 @@
<!-- <a style="cursor: pointer">Delete</a>-->
<!-- </template>-->
<!-- </el-popconfirm>-->
<!-- </template>-->
</template>
</el-table-column>
</el-table>
<!--总数超过一页再展示分页器-->
@@ -151,6 +151,13 @@ export default {
fetchTableData()
}
const handleDetail = (id) => {
router.push({
name: 'user-detail',
query: {id: id}
})
}
const formatColumnClass = (row, column) => {
return row.class_text
}
@@ -168,6 +175,7 @@ export default {
handleAdd,
handleEdit,
handleDelete,
handleDetail,
fetchTableData,
changePage,
handleSortChange,