This commit is contained in:
zzc
2026-05-27 23:35:27 +08:00
parent 6322b0962b
commit 9928bc3329
3 changed files with 175 additions and 0 deletions

17
src/api/system/robot.js Normal file
View File

@@ -0,0 +1,17 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: 'management/api/system/robot/list',
method: 'get',
params: data,
})
}
export function generate(appId) {
return request({
url: 'management/api/system/robot',
method: 'post',
data: { appId },
})
}

View File

@@ -360,6 +360,12 @@ export const asyncRoutes = [
component: () => import('@/views/systemManagement/reward/index'),
meta: { title: '奖励管理' },
},
{
path: 'robotManagement',
name: 'RobotManagement',
component: () => import('@/views/systemManagement/robot/index'),
meta: { title: '机器人' },
},
{
path: 'abilityManagement',
name: 'AbilityManagement',

View File

@@ -0,0 +1,152 @@
<template>
<div class="robot-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="handleGenerate">生成机器人</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.keyword" 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="left" label="用户信息" width="150">
<template #default="{ row }">
<div v-if="row" style="display: flex; align-items: center; justify-content: flex-start">
<el-image
v-if="row.avatar"
:src="getThumbUrl(row.avatar)"
style="width: 40px; height: 40px; border-radius: 50%; margin-right: 10px"
/>
<div>
<div>{{ row.nickname }}</div>
</div>
</div>
<div v-else>-</div>
</template>
</el-table-column>
<el-table-column align="left" label="用户ID" prop="id" show-overflow-tooltip width="220" />
<el-table-column align="center" label="创建时间" prop="createdAt" width="160">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</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"
/>
</div>
</template>
<script>
import { getList, generate } from '@/api/system/robot'
import { getList as getApplicationList } from '@/api/appManagement'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RobotManagement',
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
appId: '',
pageNo: 1,
pageSize: 10,
keyword: '',
},
applicationList: [],
}
},
created() {
this.fetchApplicationList()
},
methods: {
formatTime,
getThumbUrl,
async fetchApplicationList() {
try {
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
this.applicationList = data.list
if (this.applicationList.length > 0) {
this.queryForm.appId = this.applicationList[0].id
this.fetchData()
}
} catch (error) {
console.error(error)
}
},
handleTabClick() {
this.queryForm.pageNo = 1
this.fetchData()
},
async handleGenerate() {
if (!this.queryForm.appId) {
this.$baseMessage('请先选择应用', 'error')
return
}
try {
const { msg } = await generate(this.queryForm.appId)
this.$baseMessage(msg || '生成成功', 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
},
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() {
if (!this.queryForm.appId) return
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>
.robot-management-container {
padding: 20px;
}
</style>