[admin] change uploaded + downloaded + bonus + invites

This commit is contained in:
xiaomlove
2022-05-10 20:12:11 +08:00
parent eccc182e33
commit 3b9125d236
43 changed files with 251 additions and 82 deletions
+31 -14
View File
@@ -29,7 +29,7 @@
<tr>
<td>Email</td>
<td>{{baseInfo.email}}</td>
<td><el-button size="small">Change</el-button></td>
<td></td>
</tr>
<tr>
<td>Enabled</td>
@@ -67,24 +67,29 @@
<td>{{baseInfo.inviter && baseInfo.inviter.username}}</td>
<td><el-button size="small" @click="handleViewInviteInfo">View</el-button></td>
</tr>
<tr>
<td>Uploaded</td>
<td>{{baseInfo.uploaded_text}}</td>
<td><el-button size="small">Add</el-button></td>
</tr>
<tr>
<td>Downloaded</td>
<td>{{baseInfo.downloaded_text}}</td>
<td><el-button size="small">Add</el-button></td>
</tr>
<tr>
<td>Seed points</td>
<td>{{baseInfo.seed_points}}</td>
</tr>
<tr>
<td>Invites</td>
<td>{{baseInfo.invites}}</td>
<td><el-button size="small" @click="handleIncrementDecrement('invites')">Change</el-button></td>
</tr>
<tr>
<td>Uploaded</td>
<td>{{baseInfo.uploaded_text}}</td>
<td><el-button size="small" @click="handleIncrementDecrement('uploaded')">Change</el-button></td>
</tr>
<tr>
<td>Downloaded</td>
<td>{{baseInfo.downloaded_text}}</td>
<td><el-button size="small" @click="handleIncrementDecrement('downloaded')">Change</el-button></td>
</tr>
<tr>
<td>Bonus</td>
<td>{{baseInfo.bonus}}</td>
<td><el-button size="small">Add</el-button></td>
<td><el-button size="small" @click="handleIncrementDecrement('bonus')">Change</el-button></td>
</tr>
</table>
</el-card>
@@ -223,6 +228,7 @@
<DialogDisableUser ref="disableUser" :reload="fetchPageData" />
<DialogModComment ref="modComment" />
<DialogResetPassword ref="resetPassword" />
<DialogIncrementDecrement ref="incrementDecrement" :reload="fetchPageData" :title="dialogTitle" />
</template>
<script>
@@ -236,11 +242,13 @@ import DialogDisableUser from './dialog-disable-user.vue'
import DialogModComment from './dialog-mod-comment.vue'
import DialogResetPassword from './dialog-reset-password.vue'
import DialogGrantMedal from './dialog-grant-medal.vue'
import DialogIncrementDecrement from './dialog-increment-decrement.vue'
export default {
name: "UserDetail",
components: {
DialogAssignExam, DialogViewInviteInfo, DialogDisableUser, DialogModComment, DialogResetPassword, DialogGrantMedal
DialogAssignExam, DialogViewInviteInfo, DialogDisableUser, DialogModComment, DialogResetPassword, DialogGrantMedal,
DialogIncrementDecrement
},
setup() {
const route = useRoute()
@@ -252,10 +260,13 @@ export default {
const disableUser = ref(null)
const modComment = ref(null)
const resetPassword = ref(null)
const incrementDecrement = ref(null)
const state = reactive({
loading: false,
baseInfo: {},
examInfo: null,
dialogTitle: '',
toChangeField: '',
})
onMounted(() => {
fetchPageData()
@@ -297,6 +308,11 @@ export default {
const handleDisableUser = async () => {
disableUser.value.open(id)
}
const handleIncrementDecrement = async (field) => {
state.dialogTitle = 'Change ' + field
state.toChangeField = field
incrementDecrement.value.open(id, field)
}
const handleEnableUser = async () => {
let res = await api.enableUser({uid: id})
ElMessage.success(res.msg)
@@ -328,13 +344,14 @@ export default {
handleResetPassword,
fetchPageData,
handleRemoveUserMedal,
handleIncrementDecrement,
assignExam,
grantMedal,
viewInviteInfo,
disableUser,
modComment,
resetPassword,
incrementDecrement,
}
}
}
@@ -0,0 +1,92 @@
<template>
<el-dialog
:title="title"
v-model="visible"
center
:close-on-click-modal="false"
>
<el-form
:model="formData"
label-width="100px"
v-loading="loading"
ref="formRef"
:rules="rules">
<el-form-item label="Action" prop="action">
<el-radio-group v-model="formData.action">
<el-radio label="Increment" />
<el-radio label="Decrement" />
</el-radio-group>
</el-form-item>
<el-form-item label="Value" prop="value">
<el-input v-model="formData.value" type="number" />
</el-form-item>
<el-form-item label="Reason" prop="reason">
<el-input type="textarea" v-model="formData.reason"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">Cancel</el-button>
<el-button type="primary" @click="handleSubmit">Save</el-button>
</span>
</template>
</el-dialog>
</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: "DialogIncrementDecrement",
props: {
reload: Function,
title: String
},
setup(props, context) {
const formRef = ref(null)
const state = reactive({
loading: false,
visible: false,
formData: {
uid: 0,
field: '',
reason: '',
value: '',
action: '',
},
rules: {
value: [{ required: 'true'}],
action: [{ required: 'true'}],
}
})
const open = (uid, field) => {
state.formData.uid = uid
state.formData.field = field
state.visible = true
}
const handleSubmit = () => {
formRef.value.validate(async (valid) => {
if (valid) {
let res = await api.incrementDecrementUserField(state.formData)
state.visible = false
ElMessage.success(res.msg)
if (props.reload) {
props.reload()
}
}
})
}
return {
...toRefs(state),
handleSubmit,
formRef,
open,
}
}
}
</script>
+3 -5
View File
@@ -37,11 +37,9 @@ export default {
}
const open = (uid) => {
state.uid = uid
if (!state.modComment) {
state.loading = true
getUserModComment()
state.loading = false
}
state.loading = true
getUserModComment()
state.loading = false
state.visible = true
}