更新中奖统计
This commit is contained in:
@@ -53,4 +53,12 @@ export const taskRankList = params => {
|
|||||||
"/adminapi/Statistical/task_statistics",
|
"/adminapi/Statistical/task_statistics",
|
||||||
{ params }
|
{ params }
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
// 中奖记录统计
|
||||||
|
export const getLuckyRank = params => {
|
||||||
|
return http.request<Result>(
|
||||||
|
"get",
|
||||||
|
"/adminapi/Lottery/record_list",
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
162
src/views/Statistical/luckycoinRank/hook.tsx
Normal file
162
src/views/Statistical/luckycoinRank/hook.tsx
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
import { ref, h } from "vue";
|
||||||
|
import {
|
||||||
|
getLuckyRank
|
||||||
|
} from "@/api/modules/statistics";
|
||||||
|
import { utils, writeFile } from "xlsx";
|
||||||
|
import ExportForm from '@/components/exportDialog/index.vue';
|
||||||
|
import { addDialog } from "@/components/ReDialog";
|
||||||
|
import { message } from "@/utils/message";
|
||||||
|
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 searchForm = ref({
|
||||||
|
stime: "",
|
||||||
|
etime: ""
|
||||||
|
});
|
||||||
|
const searchLabel = ref([
|
||||||
|
{ label: "开始时间", prop: "stime", type: "date" },
|
||||||
|
{ label: "结束时间", prop: "etime", type: "date" },
|
||||||
|
]);
|
||||||
|
const tableLabel = ref([
|
||||||
|
{
|
||||||
|
label: "用户名称",
|
||||||
|
prop: "nickname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "中奖类型",
|
||||||
|
prop: "prize_type_str"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "中奖比例(%)",
|
||||||
|
prop: "radio"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "中奖金额",
|
||||||
|
prop: "prize_amount"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "开奖时奖金总金额",
|
||||||
|
prop: "pool_amount"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "剩余金额",
|
||||||
|
prop: "release_amount"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "生成时间",
|
||||||
|
prop: "createtime"
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
const onSearch = async (formData) => {
|
||||||
|
loading.value = true;
|
||||||
|
searchForm.value = { ...formData }
|
||||||
|
const { data, code } = await getLuckyRank({
|
||||||
|
...formData,
|
||||||
|
page: pagination.value.currentPage,
|
||||||
|
page_limit: pagination.value.pageSize,
|
||||||
|
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
tableList.value = data.lists.map(ele => {
|
||||||
|
return {
|
||||||
|
...ele,
|
||||||
|
pool_amount: parseFloat(ele.pool_amount),
|
||||||
|
prize_amount: parseFloat(ele.prize_amount)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pagination.value.currentPage = parseFloat(data.page);
|
||||||
|
}
|
||||||
|
loading.value = false;
|
||||||
|
};
|
||||||
|
const handleSizeChange = (val: number) => {
|
||||||
|
pagination.value.pageSize = val;
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
};
|
||||||
|
const handleCurrentChange = (val: number) => {
|
||||||
|
pagination.value.currentPage = val;
|
||||||
|
// console.log(searchForm.value, 'yzy')
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
};
|
||||||
|
const exportFormRef = ref(null)
|
||||||
|
const exportExcel = () => {
|
||||||
|
let exportTableList = []
|
||||||
|
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 getLuckyRank({
|
||||||
|
...formData,
|
||||||
|
page: 1,
|
||||||
|
page_limit: 20000
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
exportTableList = data.lists;
|
||||||
|
const res = exportTableList.map(item => {
|
||||||
|
const arr = [];
|
||||||
|
tableLabel.value.forEach(column => {
|
||||||
|
arr.push(item[column.prop as string]);
|
||||||
|
});
|
||||||
|
return arr;
|
||||||
|
});
|
||||||
|
const titleList = [];
|
||||||
|
tableLabel.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, `幸运币中奖记录列表统计${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] || '' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
searchForm,
|
||||||
|
searchLabel,
|
||||||
|
onSearch,
|
||||||
|
isShow,
|
||||||
|
tableList,
|
||||||
|
tableLabel,
|
||||||
|
pagination,
|
||||||
|
exportExcel,
|
||||||
|
handleSizeChange,
|
||||||
|
handleCurrentChange,
|
||||||
|
loading
|
||||||
|
};
|
||||||
|
}
|
||||||
62
src/views/Statistical/luckycoinRank/index.vue
Normal file
62
src/views/Statistical/luckycoinRank/index.vue
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onBeforeMount } from "vue";
|
||||||
|
import { useData } from "./hook";
|
||||||
|
import SearchForm from "@/components/SearchForm/index.vue";
|
||||||
|
import { PureTableBar } from "@/components/RePureTableBar";
|
||||||
|
import { deviceDetection } from "@pureadmin/utils";
|
||||||
|
const {
|
||||||
|
searchLabel,
|
||||||
|
searchForm,
|
||||||
|
onSearch,
|
||||||
|
isShow,
|
||||||
|
tableList,
|
||||||
|
pagination,
|
||||||
|
tableLabel,
|
||||||
|
exportExcel,
|
||||||
|
handleSizeChange,
|
||||||
|
handleCurrentChange,
|
||||||
|
loading
|
||||||
|
} = useData();
|
||||||
|
onBeforeMount(() => {
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
});
|
||||||
|
defineOptions({
|
||||||
|
name: "giftRecord"
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="main">
|
||||||
|
<SearchForm class="pb-2" :LabelList="searchLabel" :formData="searchForm" @handleSearch="onSearch" />
|
||||||
|
<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>
|
||||||
|
<el-button type="primary" @click="exportExcel">
|
||||||
|
导出
|
||||||
|
</el-button>
|
||||||
|
</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 }"
|
||||||
|
:data="tableList" :columns="dynamicColumns" :pagination="{ ...pagination, size }" :header-cell-style="{
|
||||||
|
background: 'var(--el-fill-color-light)',
|
||||||
|
color: 'var(--el-text-color-primary)'
|
||||||
|
}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange">
|
||||||
|
</pure-table>
|
||||||
|
</template>
|
||||||
|
</PureTableBar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.content-flex {
|
||||||
|
width: 100%;
|
||||||
|
display: inline-flex;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user