fix: reward page
This commit is contained in:
55
src/api/spring/avatar/category.js
Normal file
55
src/api/spring/avatar/category.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: '/management/api/spring/avatar-category/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
export function doAdd(data) {
|
||||
return request({
|
||||
url: '/management/api/spring/avatar-category',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function doEdit(id, data) {
|
||||
return request({
|
||||
url: `/management/api/spring/avatar-category/${id}`,
|
||||
method: 'put',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function doDelete(data) {
|
||||
return request({
|
||||
url: '/management/api/spring/avatar-category/delete',
|
||||
method: 'put',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function doMoveUp(id) {
|
||||
return request({
|
||||
url: `/management/api/spring/avatar-category/moveUp/${id}`,
|
||||
method: 'patch',
|
||||
})
|
||||
}
|
||||
|
||||
export function doMoveDown(id) {
|
||||
return request({
|
||||
url: `/management/api/spring/avatar-category/moveDown/${id}`,
|
||||
method: 'patch',
|
||||
})
|
||||
}
|
||||
|
||||
export function toggleEnable(id, isEnabled) {
|
||||
return request({
|
||||
url: `/management/api/spring/avatar-category/enable/${id}`,
|
||||
method: 'patch',
|
||||
data: { isEnabled },
|
||||
})
|
||||
}
|
||||
40
src/api/system/ability.js
Normal file
40
src/api/system/ability.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: 'management/api/ability/rule/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
export function doAdd(data) {
|
||||
return request({
|
||||
url: 'management/api/ability/rule',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function doEdit(id, data) {
|
||||
return request({
|
||||
url: `/management/api/ability/rule/${id}`,
|
||||
method: 'put',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function doDelete(data) {
|
||||
return request({
|
||||
url: `/management/api/ability/rule`,
|
||||
method: 'delete',
|
||||
data,
|
||||
})
|
||||
}
|
||||
export function toggleEnable(id, isEnabled) {
|
||||
return request({
|
||||
url: `/management/api/ability/rule/enable/${id}`,
|
||||
method: 'patch',
|
||||
data: { isEnabled },
|
||||
})
|
||||
}
|
||||
@@ -329,6 +329,51 @@ export const asyncRoutes = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/systemManagement',
|
||||
component: Layout,
|
||||
redirect: 'noRedirect',
|
||||
name: 'SystemManagement',
|
||||
meta: { title: '系统', icon: 'users-cog', permissions: ['admin'] },
|
||||
children: [
|
||||
{
|
||||
path: 'deviceManagement',
|
||||
name: 'DeviceManagement',
|
||||
component: () => import('@/views/systemManagement/device/index'),
|
||||
meta: { title: '设备管理' },
|
||||
},
|
||||
{
|
||||
path: 'rewardManagement',
|
||||
name: 'RewardManagement',
|
||||
component: () => import('@/views/systemManagement/reward/index'),
|
||||
meta: { title: '奖励管理' },
|
||||
},
|
||||
{
|
||||
path: 'abilityManagement',
|
||||
name: 'AbilityManagement',
|
||||
component: () => import('@/views/systemManagement/ability/index'),
|
||||
meta: { title: '用户能力管理' },
|
||||
},
|
||||
{
|
||||
path: 'accessLogManagement',
|
||||
name: 'AccessLogManagement',
|
||||
component: () => import('@/views/personnelManagement/accessLogManagement/index'),
|
||||
meta: { title: '访问日志' },
|
||||
},
|
||||
{
|
||||
path: 'suspiciousRequest',
|
||||
name: 'SuspiciousRequest',
|
||||
component: () => import('@/views/personnelManagement/suspiciousRequest/index'),
|
||||
meta: { title: '异常请求' },
|
||||
},
|
||||
{
|
||||
path: 'uploadedFileManagement',
|
||||
name: 'UploadedFileManagement',
|
||||
component: () => import('@/views/personnelManagement/uploadedFileManagement/index'),
|
||||
meta: { title: '已上传文件' },
|
||||
},
|
||||
],
|
||||
},
|
||||
// {
|
||||
// path: '/maomaotou',
|
||||
// component: Layout,
|
||||
@@ -694,45 +739,7 @@ export const asyncRoutes = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/systemManagement',
|
||||
component: Layout,
|
||||
redirect: 'noRedirect',
|
||||
name: 'SystemManagement',
|
||||
meta: { title: '系统', icon: 'users-cog', permissions: ['admin'] },
|
||||
children: [
|
||||
{
|
||||
path: 'deviceManagement',
|
||||
name: 'DeviceManagement',
|
||||
component: () => import('@/views/systemManagement/device/index'),
|
||||
meta: { title: '设备管理' },
|
||||
},
|
||||
{
|
||||
path: 'rewardManagement',
|
||||
name: 'RewardManagement',
|
||||
component: () => import('@/views/systemManagement/reward/index'),
|
||||
meta: { title: '奖励管理' },
|
||||
},
|
||||
{
|
||||
path: 'accessLogManagement',
|
||||
name: 'AccessLogManagement',
|
||||
component: () => import('@/views/personnelManagement/accessLogManagement/index'),
|
||||
meta: { title: '访问日志' },
|
||||
},
|
||||
{
|
||||
path: 'suspiciousRequest',
|
||||
name: 'SuspiciousRequest',
|
||||
component: () => import('@/views/personnelManagement/suspiciousRequest/index'),
|
||||
meta: { title: '异常请求' },
|
||||
},
|
||||
{
|
||||
path: 'uploadedFileManagement',
|
||||
name: 'UploadedFileManagement',
|
||||
component: () => import('@/views/personnelManagement/uploadedFileManagement/index'),
|
||||
meta: { title: '已上传文件' },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// {
|
||||
// path: '/mall',
|
||||
// component: Layout,
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
|
||||
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
|
||||
<el-form-item label="应用" prop="appId">
|
||||
<el-select v-model="form.appId" placeholder="请选择应用" style="width: 100%">
|
||||
<el-option v-for="item in applicationList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="规则名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入规则名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="功能场景" prop="scene">
|
||||
<el-input v-model="form.scene" placeholder="请输入功能场景标识" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消耗积分" prop="costPoints">
|
||||
<el-input-number v-model="form.costPoints" :min="0" placeholder="本次行为消耗的积分值" style="width: 100%" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="增加经验" prop="gainExp">
|
||||
<el-input-number v-model="form.gainExp" :min="0" placeholder="本次行为增加的经验值" style="width: 100%" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="每日限制" prop="limitCount">
|
||||
<el-input-number v-model="form.limitCount" :min="-1" placeholder="每日经验增长限制次数 (-1为无限制)" style="width: 100%" />
|
||||
<div style="font-size: 12px; color: #909399; margin-top: 4px">-1 表示无限制</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="规则描述" prop="description">
|
||||
<el-input v-model="form.description" placeholder="请输入规则描述" :rows="3" type="textarea" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="是否启用" prop="isEnabled">
|
||||
<el-switch v-model="form.isEnabled" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { doAdd, doEdit } from '@/api/system/ability'
|
||||
import { getList as getApplicationList } from '@/api/appManagement'
|
||||
|
||||
export default {
|
||||
name: 'AbilityManagementEdit',
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
appId: '',
|
||||
name: '',
|
||||
scene: '',
|
||||
costPoints: 0,
|
||||
gainExp: 0,
|
||||
limitCount: -1,
|
||||
description: '',
|
||||
isEnabled: true,
|
||||
},
|
||||
rules: {
|
||||
appId: [{ required: true, trigger: 'blur', message: '请选择应用' }],
|
||||
name: [{ required: true, trigger: 'blur', message: '请输入规则名称' }],
|
||||
scene: [{ required: true, trigger: 'blur', message: '请输入功能场景' }],
|
||||
},
|
||||
title: '',
|
||||
dialogFormVisible: false,
|
||||
applicationList: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchApplicationList()
|
||||
},
|
||||
methods: {
|
||||
async fetchApplicationList() {
|
||||
try {
|
||||
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
|
||||
this.applicationList = data.list
|
||||
} catch (error) {
|
||||
console.error('获取应用列表失败', error)
|
||||
}
|
||||
},
|
||||
showEdit(row) {
|
||||
if (!row || !row.id) {
|
||||
this.title = '添加'
|
||||
this.form = Object.assign({}, this.$options.data().form)
|
||||
if (row) {
|
||||
this.form = Object.assign(this.form, row)
|
||||
}
|
||||
} else {
|
||||
this.title = '编辑'
|
||||
this.form = Object.assign({}, row)
|
||||
}
|
||||
this.dialogFormVisible = true
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.form = this.$options.data().form
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
if (this.title === '添加') {
|
||||
const { msg } = await doAdd(this.form)
|
||||
this.$baseMessage(msg, 'success')
|
||||
} else {
|
||||
const { msg } = await doEdit(this.form.id, this.form)
|
||||
this.$baseMessage(msg, 'success')
|
||||
}
|
||||
this.$refs['form'].resetFields()
|
||||
this.dialogFormVisible = false
|
||||
this.$emit('fetch-data')
|
||||
this.form = this.$options.data().form
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
189
src/views/systemManagement/ability/index.vue
Normal file
189
src/views/systemManagement/ability/index.vue
Normal file
@@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<div class="ability-management-container">
|
||||
<el-tabs v-model="queryForm.appId" type="card" @tab-click="handleTabClick">
|
||||
<el-tab-pane v-for="item in applicationList" :key="item.id" :label="item.name" :name="item.id" />
|
||||
</el-tabs>
|
||||
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel :span="12">
|
||||
<el-button icon="el-icon-plus" type="primary" @click="handleEdit">添加</el-button>
|
||||
<el-button icon="el-icon-delete" type="danger" @click="handleDelete">批量删除</el-button>
|
||||
</vab-query-form-left-panel>
|
||||
<vab-query-form-right-panel :span="12">
|
||||
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
|
||||
<el-form-item>
|
||||
<el-input v-model.trim="queryForm.name" clearable placeholder="请输入规则名称" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</vab-query-form-right-panel>
|
||||
</vab-query-form>
|
||||
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" label="规则名称" min-width="150" prop="name" show-overflow-tooltip />
|
||||
<el-table-column align="center" label="场景" prop="scene" show-overflow-tooltip width="120" />
|
||||
<el-table-column align="center" label="描述" min-width="200" prop="description" show-overflow-tooltip />
|
||||
|
||||
<el-table-column align="center" label="数值设置" width="180">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.costPoints">消耗积分: {{ row.costPoints }}</div>
|
||||
<div v-if="row.gainExp">增加经验: {{ row.gainExp }}</div>
|
||||
<div>每日限制: {{ row.limitCount === -1 ? '无限制' : row.limitCount }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="状态" prop="isEnabled" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.isEnabled" @change="handleStatusChange(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="创建时间" prop="createdAt" width="160">
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" fixed="right" label="操作" show-overflow-tooltip width="150">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button type="text" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
background
|
||||
:current-page="queryForm.pageNo"
|
||||
:layout="layout"
|
||||
:page-size="queryForm.pageSize"
|
||||
:total="total"
|
||||
@current-change="handleCurrentChange"
|
||||
@size-change="handleSizeChange"
|
||||
/>
|
||||
|
||||
<edit ref="edit" @fetch-data="fetchData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList, doDelete, toggleEnable } from '@/api/system/ability'
|
||||
import { getList as getApplicationList } from '@/api/appManagement'
|
||||
import { formatTime } from '@/utils'
|
||||
import Edit from './components/AbilityManagementEdit'
|
||||
|
||||
export default {
|
||||
name: 'AbilityManagement',
|
||||
components: { Edit },
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
listLoading: true,
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
total: 0,
|
||||
selectRows: [],
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
name: '',
|
||||
appId: '',
|
||||
},
|
||||
applicationList: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchApplicationList()
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
async fetchApplicationList() {
|
||||
try {
|
||||
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
|
||||
this.applicationList = data.list
|
||||
} catch (error) {
|
||||
console.error('获取应用列表失败', error)
|
||||
}
|
||||
},
|
||||
handleTabClick(tab) {
|
||||
this.queryForm.appId = tab.name
|
||||
this.queryForm.pageNo = 1
|
||||
this.fetchData()
|
||||
},
|
||||
setSelectRows(val) {
|
||||
this.selectRows = val
|
||||
},
|
||||
handleEdit(row) {
|
||||
if (row.id) {
|
||||
this.$refs['edit'].showEdit(row)
|
||||
} else {
|
||||
// 如果当前选中了某个应用,自动填入 appId
|
||||
const defaultData = this.queryForm.appId ? { appId: this.queryForm.appId } : null
|
||||
this.$refs['edit'].showEdit(defaultData)
|
||||
}
|
||||
},
|
||||
handleDelete(row) {
|
||||
if (row.id) {
|
||||
this.$baseConfirm('你确定要删除当前项吗', null, async () => {
|
||||
const { msg } = await doDelete({ ids: [row.id] })
|
||||
this.$baseMessage(msg, 'success')
|
||||
this.fetchData()
|
||||
})
|
||||
} else {
|
||||
if (this.selectRows.length > 0) {
|
||||
const ids = this.selectRows.map((item) => item.id).join()
|
||||
this.$baseConfirm('你确定要删除选中项吗', null, async () => {
|
||||
const { msg } = await doDelete({ ids: ids.split(',') })
|
||||
this.$baseMessage(msg, 'success')
|
||||
this.fetchData()
|
||||
})
|
||||
} else {
|
||||
this.$baseMessage('未选中任何行', 'error')
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
async handleStatusChange(row) {
|
||||
try {
|
||||
const { msg } = await toggleEnable(row.id, row.isEnabled)
|
||||
this.$baseMessage(msg, 'success')
|
||||
} catch (error) {
|
||||
row.isEnabled = !row.isEnabled
|
||||
}
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val
|
||||
this.fetchData()
|
||||
},
|
||||
queryData() {
|
||||
this.queryForm.pageNo = 1
|
||||
this.fetchData()
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await getList(this.queryForm)
|
||||
this.list = data.list
|
||||
this.total = data.totalCount
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.ability-management-container {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user