标准化后台逻辑
This commit is contained in:
parent
cdd52dadcb
commit
c0f414b6c9
|
@ -14,20 +14,20 @@ export interface jobuser {
|
||||||
message: string;
|
message: string;
|
||||||
data: {
|
data: {
|
||||||
jobuser: {
|
jobuser: {
|
||||||
username: string; // 账号
|
username: string; // 账号
|
||||||
password: string; // 密码
|
password: string; // 密码
|
||||||
time: Date; // 注册时间
|
time: Date; // 注册时间
|
||||||
type: number; // 累计在线时间
|
type: number; // 累计在线时间
|
||||||
}[]
|
}[]
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Black {
|
export interface Black {
|
||||||
status: string;
|
status: string;
|
||||||
code: number;
|
code: number;
|
||||||
message: string;
|
message: string;
|
||||||
data: {};
|
data: {};
|
||||||
}
|
}
|
||||||
export interface Refresh {
|
export interface Refresh {
|
||||||
status: string;
|
status: string;
|
||||||
|
@ -40,32 +40,32 @@ export interface Refresh {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListParams {
|
export interface ListParams {
|
||||||
black?: string;
|
black?: string;
|
||||||
username?: string;
|
username?: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param data 获取列表
|
* @param data 获取列表
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function lists(params: ListParams) {
|
export function lists() {
|
||||||
return axios.post<jobuser>('/api/v1/jobuser/lists',params);
|
return axios.post<jobuser>('/admin/api/v1/jobuser/lists');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id 拉黑
|
* @param id 封禁用户
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function getBlack(id: string) {
|
export function black(id: string) {
|
||||||
return axios.post<Black>('/api/v1/jobuser/getBlack', { id });
|
return axios.post<Black>('/admin/api/v1/jobuser/black', { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id 洗白
|
* @param id 解禁用户
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function getOutBlack(id: string) {
|
export function OutBlack(id: string) {
|
||||||
return axios.post<Black>('/api/v1/jobuser/getOutBlack', { id });
|
return axios.post<Black>('/admin/api/v1/jobuser/outblack', { id });
|
||||||
}
|
}
|
|
@ -5,22 +5,22 @@
|
||||||
<a-card class="general-card" :title="$t('menu.jobuser.userlist')">
|
<a-card class="general-card" :title="$t('menu.jobuser.userlist')">
|
||||||
<a-table :data="data">
|
<a-table :data="data">
|
||||||
<template #columns>
|
<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="username"></a-table-column>
|
||||||
<a-table-column title="用户积分" data-index="money"></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="time"></a-table-column>
|
<a-table-column title="注册时间" data-index="created_at"></a-table-column>
|
||||||
<a-table-column title="是否封禁" data-index="black"><template #cell="{ record }">
|
<a-table-column title="是否封禁" data-index="status"><template #cell="{ record }">
|
||||||
{{ record.black == 1 ? '是' : '否' }}
|
{{ record.status == 0 ? '是' : '否' }}
|
||||||
</template></a-table-column>
|
</template></a-table-column>
|
||||||
<a-table-column title="操作">
|
<a-table-column title="操作">
|
||||||
<template #cell="{ record }">
|
<template #cell="{ record }">
|
||||||
<!-- <a-button @click="create(record.id)">编辑</a-button> -->
|
<!-- <a-button @click="create(record.id)">编辑</a-button> -->
|
||||||
<a-space>
|
<a-space>
|
||||||
<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-show="record.black == 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-button @click="show_group(record.id)">查看团队</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
</template>
|
</template>
|
||||||
|
@ -32,19 +32,20 @@
|
||||||
团队关系展示
|
团队关系展示
|
||||||
</template>
|
</template>
|
||||||
<showgroup :id="show_group_id"></showgroup>
|
<showgroup :id="show_group_id"></showgroup>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, reactive, watch, nextTick, onMounted } from 'vue';
|
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 { Modal } from '@arco-design/web-vue';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
|
|
||||||
import showgroup from './components/showgroup.vue';
|
import showgroup from './components/showgroup.vue';
|
||||||
|
|
||||||
interface DataItem {
|
interface DataItem {
|
||||||
|
id: number;
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
time: Date;
|
time: Date;
|
||||||
|
@ -52,12 +53,12 @@ interface DataItem {
|
||||||
}
|
}
|
||||||
let data = ref<DataItem[]>([])
|
let data = ref<DataItem[]>([])
|
||||||
//弹窗控制
|
//弹窗控制
|
||||||
const modal_visible=ref(false)
|
const modal_visible = ref(false)
|
||||||
//传递下去的用户id
|
//传递下去的用户id
|
||||||
const show_group_id=ref(0)
|
const show_group_id = ref(0)
|
||||||
const show_group=(id:number)=>{
|
const show_group = (id: number) => {
|
||||||
show_group_id.value=id
|
show_group_id.value = id
|
||||||
modal_visible.value=true
|
modal_visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const showConfirm = (id: string) => {
|
const showConfirm = (id: string) => {
|
||||||
|
@ -65,31 +66,46 @@ const showConfirm = (id: string) => {
|
||||||
title: '操作提醒',
|
title: '操作提醒',
|
||||||
content: '请确认是否要拉黑该用户',
|
content: '请确认是否要拉黑该用户',
|
||||||
onOk: () => handleBlock(id),
|
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 = async (id: string) => {
|
||||||
const handleBlock = (id: string) => {
|
const res = await black(id);
|
||||||
getBlack(id).then(res => {
|
if (res.code == 200) {
|
||||||
console.log(res.status)
|
Message.success('拉黑成功')
|
||||||
if (res.status == 'success') {
|
getAll()
|
||||||
getAll();
|
} else {
|
||||||
Message.success('拉黑成功')
|
Message.error('拉黑失败')
|
||||||
} else {
|
}
|
||||||
Message.error('拉黑失败')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
black: null,
|
black: null,
|
||||||
username: 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;
|
data.value = res.data;
|
||||||
})
|
}
|
||||||
};
|
};
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
getAll()
|
getAll()
|
||||||
|
|
Loading…
Reference in New Issue