标准化后台逻辑
This commit is contained in:
parent
cdd52dadcb
commit
c0f414b6c9
|
@ -42,30 +42,30 @@ export interface Refresh {
|
|||
export interface ListParams {
|
||||
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 });
|
||||
}
|
|
@ -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;
|
||||
|
@ -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();
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue