83 lines
1.7 KiB
TypeScript
83 lines
1.7 KiB
TypeScript
import { ref } from "vue";
|
|
import {
|
|
queryInviteList
|
|
} from "@/api/modules/invite";
|
|
export function useData() {
|
|
const loading = ref(true);
|
|
const tableList = ref([]);
|
|
const isShow = ref(false);
|
|
const pagination = ref({
|
|
total: 0,
|
|
pageSize: 10,
|
|
pageSizes: [10, 20, 50, 100, 500, 1000, 2000],
|
|
currentPage: 1,
|
|
background: true
|
|
});
|
|
const tableLabel = ref([
|
|
{
|
|
label: "邀请列表ID",
|
|
prop: "id"
|
|
},
|
|
{
|
|
label: "邀请用户ID",
|
|
prop: "user_id"
|
|
},
|
|
{
|
|
label: "下级用户ID",
|
|
prop: "sub_user_id"
|
|
},
|
|
{
|
|
label: "邀请码",
|
|
prop: "init_code"
|
|
},
|
|
{
|
|
label: "创建时间",
|
|
prop: "createtime"
|
|
},
|
|
{
|
|
label: "邀请者昵称",
|
|
prop: "parent_username"
|
|
},
|
|
{
|
|
label: "下级用户昵称",
|
|
prop: "username"
|
|
}
|
|
]);
|
|
const onSearch = async () => {
|
|
loading.value = true;
|
|
const { data, code } = await queryInviteList({
|
|
page: pagination.value.currentPage,
|
|
page_limit: pagination.value.pageSize,
|
|
|
|
});
|
|
if (code) {
|
|
tableList.value = data.lists.map(ele => {
|
|
return {
|
|
...ele, ...data.total
|
|
}
|
|
});
|
|
pagination.value.total = data.count;
|
|
pagination.value.currentPage = data.page;
|
|
}
|
|
loading.value = false;
|
|
};
|
|
const handleSizeChange = (val: number) => {
|
|
pagination.value.pageSize = val;
|
|
onSearch();
|
|
};
|
|
const handleCurrentChange = (val: number) => {
|
|
pagination.value.currentPage = val;
|
|
onSearch();
|
|
};
|
|
return {
|
|
onSearch,
|
|
isShow,
|
|
tableList,
|
|
tableLabel,
|
|
pagination,
|
|
handleSizeChange,
|
|
handleCurrentChange,
|
|
loading
|
|
};
|
|
}
|