标准化后台逻辑

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

@ -14,20 +14,20 @@ export interface jobuser {
message: string;
data: {
jobuser: {
username: string; // 账号
password: string; // 密码
time: Date; // 注册时间
type: number; // 累计在线时间
username: string; // 账号
password: string; // 密码
time: Date; // 注册时间
type: number; // 累计在线时间
}[]
};
}
export interface Black {
status: string;
code: number;
message: string;
data: {};
status: string;
code: number;
message: string;
data: {};
}
export interface Refresh {
status: string;
@ -40,32 +40,32 @@ export interface Refresh {
}
export interface ListParams {
black?: string;
username?: string;
}
black?: string;
username?: string;
}
/**
*
* @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,22 +5,22 @@
<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 @click="show_group(record.id)">查看团队</a-button>
</a-space>
<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>
</a-table-column>
</template>
@ -32,19 +32,20 @@
团队关系展示
</template>
<showgroup :id="show_group_id"></showgroup>
</a-modal>
</a-modal>
</div>
</template>
<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;
@ -52,12 +53,12 @@ interface DataItem {
}
let data = ref<DataItem[]>([])
//
const modal_visible=ref(false)
const modal_visible = ref(false)
//id
const show_group_id=ref(0)
const show_group=(id:number)=>{
show_group_id.value=id
modal_visible.value=true
const show_group_id = ref(0)
const show_group = (id: number) => {
show_group_id.value = id
modal_visible.value = true
}
const showConfirm = (id: string) => {
@ -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();
Message.success('拉黑成功')
} else {
Message.error('拉黑失败')
}
})
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()