标准化后台逻辑

This commit is contained in:
lingling 2025-02-19 18:11:12 +08:00
parent cdd52dadcb
commit c0f414b6c9
2 changed files with 66 additions and 50 deletions

View File

@ -48,24 +48,24 @@ export interface ListParams {
* @param data
* @returns
*/
export function lists(params: ListParams) {
return axios.post<jobuser>('/api/v1/jobuser/lists',params);
export function lists() {
return axios.post<jobuser>('/admin/api/v1/jobuser/lists');
}
/**
*
* @param id
* @param id
* @returns
*/
export function getBlack(id: string) {
return axios.post<Black>('/api/v1/jobuser/getBlack', { id });
export function black(id: string) {
return axios.post<Black>('/admin/api/v1/jobuser/black', { id });
}
/**
*
* @param id
* @param id
* @returns
*/
export function getOutBlack(id: string) {
return axios.post<Black>('/api/v1/jobuser/getOutBlack', { id });
export function OutBlack(id: string) {
return axios.post<Black>('/admin/api/v1/jobuser/outblack', { id });
}

View File

@ -5,20 +5,20 @@
<a-card class="general-card" :title="$t('menu.jobuser.userlist')">
<a-table :data="data">
<template #columns>
<a-table-column title="用户id" data-index="user_id"></a-table-column>
<a-table-column title="用户id" data-index="id"></a-table-column>
<a-table-column title="用户名称" data-index="username"></a-table-column>
<a-table-column title="用户积分" data-index="money"></a-table-column>
<a-table-column title="累计在线时长/分" data-index="time"></a-table-column>
<a-table-column title="注册时间" data-index="time"></a-table-column>
<a-table-column title="是否封禁" data-index="black"><template #cell="{ record }">
{{ record.black == 1 ? '是' : '否' }}
<a-table-column title="注册时间" data-index="created_at"></a-table-column>
<a-table-column title="是否封禁" data-index="status"><template #cell="{ record }">
{{ record.status == 0 ? '是' : '否' }}
</template></a-table-column>
<a-table-column title="操作">
<template #cell="{ record }">
<!-- <a-button @click="create(record.id)">编辑</a-button> -->
<a-space>
<a-button v-show="record.black != 1" status="danger" @click="showConfirm(record.id)">封禁</a-button>
<a-button v-show="record.black == 1" status="danger" @click="showConfirm(record.id)">解禁</a-button>
<a-button v-if="record.status == 1" status="danger" @click="showConfirm(record.id)">封禁</a-button>
<a-button v-if="record.status == 0" status="danger" @click="showConfirm_out(record.id)">解禁</a-button>
<a-button @click="show_group(record.id)">查看团队</a-button>
</a-space>
</template>
@ -38,13 +38,14 @@
<script lang="ts" setup>
import { computed, ref, reactive, watch, nextTick, onMounted } from 'vue';
import { lists, getBlack, ListParams } from '@/api/jobuser';
import { lists, black, ListParams,OutBlack } from '@/api/jobuser';
import { Modal } from '@arco-design/web-vue';
import { Message } from '@arco-design/web-vue';
import showgroup from './components/showgroup.vue';
interface DataItem {
id: number;
username: string;
password: string;
time: Date;
@ -65,31 +66,46 @@ const showConfirm = (id: string) => {
title: '操作提醒',
content: '请确认是否要拉黑该用户',
onOk: () => handleBlock(id),
onCancel: () => Message.info('取消操作'),
// onCancel: () => Message.info(''),
});
};
const showConfirm_out = (id: string) => {
Modal.confirm({
title: '操作提醒',
content: '请确认是否要解禁该用户',
onOk: () => OutBlock(id),
// onCancel: () => Message.info(''),
});
};
const OutBlock = async (id: string) => {
const res = await OutBlack(id);
if (res.code == 200) {
getAll()
}
};
const handleBlock = (id: string) => {
getBlack(id).then(res => {
console.log(res.status)
if (res.status == 'success') {
getAll();
const handleBlock = async (id: string) => {
const res = await black(id);
if (res.code == 200) {
Message.success('拉黑成功')
getAll()
} else {
Message.error('拉黑失败')
}
})
};
const queryParams = ref({
black: null,
username: null
});
const getAll = () => {
lists(queryParams.value).then(res => {
/**
* 获取所有的用户列表
*/
const getAll = async () => {
const res= await lists();
if(res.code==200){
data.value = res.data;
})
}
};
onMounted(async () => {
getAll()