更新
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
queryMovieRoom,
|
||||
banMovieRoom
|
||||
} from "@/api/modules/room";
|
||||
import { utils, writeFile } from "xlsx";
|
||||
import ExportForm from '@/components/exportDialog/index.vue';
|
||||
export function useData() {
|
||||
const loading = ref(true);
|
||||
const tableList = ref([]);
|
||||
@@ -13,7 +15,9 @@ export function useData() {
|
||||
const searchForm = ref({
|
||||
search_room_number: "",
|
||||
search_onwer_number: "",
|
||||
room_status: ""
|
||||
room_status: "",
|
||||
start_time: "",
|
||||
end_time: ""
|
||||
});
|
||||
const searchLabel = ref([
|
||||
{ label: "房间号", prop: "search_room_number", type: "input" },
|
||||
@@ -25,7 +29,9 @@ export function useData() {
|
||||
{ label: "封禁", value: 2 },
|
||||
{ label: "关闭", value: 3 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label: "开始时间", prop: "start_time", type: "date" },
|
||||
{ label: "结束时间", prop: "end_time", type: "date" },
|
||||
|
||||
]);
|
||||
const pagination = ref({
|
||||
@@ -48,6 +54,14 @@ export function useData() {
|
||||
label: "房主昵称",
|
||||
prop: "user_nickname"
|
||||
},
|
||||
{
|
||||
label: "观众ID",
|
||||
prop: "cp_user_id"
|
||||
},
|
||||
{
|
||||
label: "观众昵称",
|
||||
prop: "cp_nickname"
|
||||
},
|
||||
{
|
||||
label: "房间名称",
|
||||
prop: "room_name"
|
||||
@@ -77,7 +91,10 @@ export function useData() {
|
||||
label: "状态",
|
||||
prop: "room_status_str",
|
||||
},
|
||||
|
||||
{
|
||||
label: "房间总流水",
|
||||
prop: "liushui"
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
prop: "createtime"
|
||||
@@ -135,6 +152,79 @@ export function useData() {
|
||||
}
|
||||
});
|
||||
};
|
||||
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) => {
|
||||
console.log(formData)
|
||||
debugger
|
||||
const { data, code } = await queryMovieRoom({
|
||||
...formData,
|
||||
page: 1,
|
||||
page_limit: 200000
|
||||
});
|
||||
// const { data, code } = await queryGiftGiveList({
|
||||
// ...formData,
|
||||
// send_user: searchForm.value.send_user,
|
||||
// gift_user: searchForm.value.gift_user,
|
||||
// from_id: searchForm.value.from_id,
|
||||
// gift_id: searchForm.value.gift_id,
|
||||
// from: searchForm.value.from,
|
||||
// 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, `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] || '' })
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return {
|
||||
searchForm,
|
||||
searchLabel,
|
||||
@@ -147,6 +237,7 @@ export function useData() {
|
||||
handleCurrentChange,
|
||||
loading,
|
||||
joinMovieRoom,
|
||||
handleBan
|
||||
handleBan,
|
||||
exportExcel
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ const {
|
||||
tableList,
|
||||
pagination,
|
||||
tableLabel,
|
||||
exportExcel,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
handleBan,
|
||||
@@ -33,6 +34,12 @@ onMounted(() => {
|
||||
<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
|
||||
<PureTableBar title="Cp电影房列表" :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']"
|
||||
:columns="tableLabel" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<!-- <div style="display: inline-flex;align-items: center;" class="mr-10">总计:{{ total_price }}</div> -->
|
||||
<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 }"
|
||||
|
||||
Reference in New Issue
Block a user