更新
This commit is contained in:
@@ -151,3 +151,12 @@ export const getBanDay = () => {
|
||||
"/adminapi/User/getBanDay"
|
||||
);
|
||||
};
|
||||
|
||||
// 用户CP列表
|
||||
export const userCpList = params => {
|
||||
return http.request<Result>(
|
||||
"get",
|
||||
"/adminapi/User/user_cp_list",
|
||||
{ params }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ export function useData() {
|
||||
const loading = ref(true);
|
||||
const tableList = ref([]);
|
||||
const isShow = ref(false);
|
||||
const totalRow = ref({});
|
||||
const pagination = ref({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
@@ -70,6 +71,7 @@ export function useData() {
|
||||
});
|
||||
if (code) {
|
||||
tableList.value = data.lists || data.data || [];
|
||||
totalRow.value = data.totalRow;
|
||||
pagination.value.total = data.count || data.total || 0;
|
||||
pagination.value.currentPage = data.page || pagination.value.currentPage;
|
||||
}
|
||||
@@ -127,6 +129,7 @@ export function useData() {
|
||||
handleCurrentChange,
|
||||
loading,
|
||||
viewInvestRecord,
|
||||
viewWinnerList
|
||||
viewWinnerList,
|
||||
totalRow
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ const {
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
loading,
|
||||
totalRow,
|
||||
viewInvestRecord,
|
||||
viewWinnerList
|
||||
} = useData();
|
||||
@@ -32,6 +33,13 @@ defineOptions({
|
||||
<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
|
||||
<PureTableBar v-if="!loading" title="期数列表" :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']"
|
||||
:columns="tableLabel" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<span>当前总投入:
|
||||
<span style="color: red">{{ totalRow.out_amount || 0 }}</span>
|
||||
当前总支出:
|
||||
<span style="color: red">{{ totalRow.in_amount || 0 }}</span>
|
||||
</span>
|
||||
</template>
|
||||
<template v-slot="{ size, dynamicColumns }">
|
||||
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" default-expand-all
|
||||
:loading="loading" :size="size" row-key="id" adaptive :adaptiveConfig="{ offsetBottom: 108 }"
|
||||
|
||||
169
src/views/newuser/newuserList/cpList.vue
Normal file
169
src/views/newuser/newuserList/cpList.vue
Normal file
@@ -0,0 +1,169 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, h } from "vue";
|
||||
import { userCpList } from "@/api/modules/newuserList";
|
||||
import { utils, writeFile } from "xlsx";
|
||||
import ExportForm from "@/components/exportDialog/index.vue";
|
||||
import { addDialog } from "@/components/ReDialog";
|
||||
import { message } from "@/utils/message";
|
||||
|
||||
const props = defineProps(["userId"]);
|
||||
const exportFormRef = ref(null);
|
||||
const loading = ref(true);
|
||||
const tableList = ref([]);
|
||||
const pagination = ref({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
background: true
|
||||
});
|
||||
|
||||
const cpColumns = ref([
|
||||
{
|
||||
label: "ID",
|
||||
prop: "id"
|
||||
},
|
||||
{
|
||||
label: "用户1",
|
||||
prop: "user1_nickname"
|
||||
},
|
||||
{
|
||||
label: "用户2",
|
||||
prop: "user2_nickname"
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status_str"
|
||||
},
|
||||
{
|
||||
label: "建立时间",
|
||||
prop: "createtime"
|
||||
}
|
||||
]);
|
||||
|
||||
const getCpData = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data, code } = await userCpList({
|
||||
user_id: props.userId,
|
||||
page: pagination.value.currentPage,
|
||||
page_limit: pagination.value.pageSize
|
||||
});
|
||||
if (code) {
|
||||
tableList.value = data.lists || [];
|
||||
pagination.value.total = data.count || 0;
|
||||
pagination.value.pageSize = +data.page_limit || 10;
|
||||
pagination.value.currentPage = +data.page || 1;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取CP列表失败:", error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleSizeChange = (val: number) => {
|
||||
pagination.value.pageSize = val;
|
||||
getCpData();
|
||||
};
|
||||
|
||||
const handleCurrentChange = (val: number) => {
|
||||
pagination.value.currentPage = val;
|
||||
getCpData();
|
||||
};
|
||||
|
||||
const exportTable = () => {
|
||||
if (tableList.value.length === 0) {
|
||||
message("暂无数据导出", { type: "error" });
|
||||
return;
|
||||
}
|
||||
|
||||
addDialog({
|
||||
title: `导出数据`,
|
||||
props: {
|
||||
formInline: {
|
||||
time: ""
|
||||
}
|
||||
},
|
||||
width: "40%",
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () =>
|
||||
h(ExportForm, { ref: exportFormRef, formInline: null }),
|
||||
beforeSure: (done, { options }) => {
|
||||
const FormRef = exportFormRef.value.getRef();
|
||||
const curData = options.props.formInline;
|
||||
|
||||
const exportData = async formData => {
|
||||
const { data, code } = await userCpList({
|
||||
user_id: props.userId,
|
||||
page: 1,
|
||||
page_limit: 10000
|
||||
});
|
||||
|
||||
if (code) {
|
||||
const exportTableList = data.lists || [];
|
||||
const res = exportTableList.map(item => {
|
||||
const arr = [];
|
||||
cpColumns.value.forEach(column => {
|
||||
arr.push(item[column.prop as string]);
|
||||
});
|
||||
return arr;
|
||||
});
|
||||
|
||||
const titleList = [];
|
||||
cpColumns.value.forEach(column => {
|
||||
titleList.push(column.label);
|
||||
});
|
||||
res.unshift(titleList);
|
||||
|
||||
const workSheet = utils.aoa_to_sheet(res);
|
||||
const workBook = utils.book_new();
|
||||
utils.book_append_sheet(workBook, workSheet, "数据报表");
|
||||
writeFile(
|
||||
workBook,
|
||||
`用户CP列表统计——${formData.start_time} - ${formData.end_time}.xlsx`
|
||||
);
|
||||
message("导出成功", { type: "success" });
|
||||
done();
|
||||
} else {
|
||||
message("获取数据失败,请重试!", { type: "error" });
|
||||
}
|
||||
};
|
||||
|
||||
FormRef.validate(valid => {
|
||||
if (valid) {
|
||||
if (curData.time && curData.time.length) {
|
||||
exportData({
|
||||
start_time: curData.time[0] || "",
|
||||
end_time: curData.time[1] || ""
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getCpData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cp-list-container">
|
||||
<div class="mb-5" style="float: right">
|
||||
<el-button type="primary" @click="exportTable">导出当前表格</el-button>
|
||||
</div>
|
||||
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" :loading="loading"
|
||||
:adaptiveConfig="{ offsetBottom: 108 }" :data="tableList" :columns="cpColumns" :pagination="pagination"
|
||||
:header-cell-style="{
|
||||
background: 'var(--el-fill-color-light)',
|
||||
color: 'var(--el-text-color-primary)'
|
||||
}" @page-size-change="handleSizeChange" @page-current-change="handleCurrentChange" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.cp-list-container {
|
||||
padding: 10px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
bandFamilyUser,
|
||||
userRelationList
|
||||
} from "@/api/modules/newuserList";
|
||||
import cpListView from "./cpList.vue";
|
||||
const userData = ref({
|
||||
...props.userInfo.user_info,
|
||||
...props.userInfo.follow_num,
|
||||
@@ -216,6 +217,8 @@ const handleClick = tab => {
|
||||
getFamilyData();
|
||||
} else if (name == "5") {
|
||||
getRelationData();
|
||||
} else if (name == "6") {
|
||||
// 用户CP列表 - 由子组件自己处理
|
||||
}
|
||||
};
|
||||
const handleSizeChange = (val: number) => {
|
||||
@@ -459,6 +462,9 @@ const exportTable = async activeIndex => {
|
||||
</template>
|
||||
</pure-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="用户CP" name="6">
|
||||
<cpListView v-if="activeIndex === '6'" :userId="userData.userId" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -178,6 +178,10 @@ export function useData() {
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: "禁用理由",
|
||||
prop: "user_block_reason"
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
fixed: "right",
|
||||
|
||||
Reference in New Issue
Block a user