Browse Source

添加导出功能

master
MoQingYu 3 months ago
parent
commit
e4f717b4f8
  1. 5
      backmanage/src/api/module/event_detail.ts
  2. 5
      backmanage/src/api/module/statistics_daily_game.ts
  3. 5
      backmanage/src/api/module/statistics_day_total.ts
  4. 5
      backmanage/src/api/module/user_agent_info.ts
  5. 5
      backmanage/src/api/module/verification_code.ts
  6. 3
      backmanage/src/components/global/m_table/src/hooks/useTable.ts
  7. 72
      backmanage/src/components/global/m_table/src/m_table.vue
  8. 2
      backmanage/src/components/global/m_table/src/type.ts
  9. 4
      backmanage/src/views/eventDetail/index.vue
  10. 4
      backmanage/src/views/statistics/dailyGame/index.vue
  11. 1
      backmanage/src/views/statistics/online/index.vue
  12. 1
      backmanage/src/views/statistics/recharge/index.vue
  13. 1
      backmanage/src/views/statistics/register/index.vue
  14. 4
      backmanage/src/views/statistics/total/index.vue
  15. 4
      backmanage/src/views/userAgentDetail/index.vue
  16. 4
      backmanage/src/views/verificationCode/index.vue

5
backmanage/src/api/module/event_detail.ts

@ -31,4 +31,9 @@ export interface IEventDetail {
// 分页查询事件打点数据
export function fetchPageEventDetails(payload: IEventDetail) {
return request.post<IEventDetail>("/event/fetch-page-event-details", payload);
}
// 导出打点数据
export function ExportEventDetails(payload: IEventDetail) {
return request.post("/event/export-event-details", payload, { responseType: 'blob' });
}

5
backmanage/src/api/module/statistics_daily_game.ts

@ -46,6 +46,11 @@ export function fetchPageDailyGameStats(payload: IStatisticsDailyGame) {
return request.post<IStatisticsDailyGame>("/statistics/fetch-page-daily-game-stats", payload);
}
// 导出每日数据统计列表
export function exportDailyGameStats(payload: IStatisticsDailyGame) {
return request.post("/statistics/export-daily-game-stats", payload, { responseType: 'blob' });
}
// 用户在线数据统计列表
export function fetchListStatUserOnline(payload: IStatisticsUserOnline) {
return request.post<IStatisticsUserOnlineList>("/statistics/fetch-list-stat-user-online", payload);

5
backmanage/src/api/module/statistics_day_total.ts

@ -37,4 +37,9 @@ export interface IStatisticsDayTotal {
// 分页天累计统计列表
export function fetchPageStatDayTotals(payload: IStatisticsDayTotal) {
return request.post<IStatisticsDayTotal>("/statistics/fetch-page-stat-day-totals", payload);
}
// 导出天累计统计列表
export function exportStatDayTotals(payload: IStatisticsDayTotal) {
return request.post("/statistics/export-stat-day-totals", payload, { responseType: 'blob' });
}

5
backmanage/src/api/module/user_agent_info.ts

@ -50,3 +50,8 @@ export function modifyUserAgentInfoTotal(payload: IUserAgentInfo) {
export function updateUserAgentInfoOfRate(payload: IUserAgentInfo) {
return request.post("/agent/update-user-agent-info-rate", payload);
}
// 导出用户代理数据
export function exportUserAgentInfos(payload: IUserAgentInfo) {
return request.post("/agent/export-user-agent-infos", payload, { responseType: 'blob' });
}

5
backmanage/src/api/module/verification_code.ts

@ -12,4 +12,9 @@ export interface IVerificationCode {
// 分页验证码列表
export function fetchPageVerificationCodes(payload: IVerificationCode) {
return request.post<IVerificationCode>("/sub-mail/fetch-page-verification-codes", payload);
}
// 导出验证码列表
export function exportVerificationCodes(payload: IVerificationCode) {
return request.post("/sub-mail/export-verification-codes", payload, { responseType: 'blob' });
}

3
backmanage/src/components/global/m_table/src/hooks/useTable.ts

@ -10,7 +10,7 @@ export const useTable = (
config: TableType,
pagination_config?: Partial<PaginationType>
) => {
const { handleLoadData, handleProcseeData, isDeepReactive } = config;
const { handleLoadData, handleProcseeData, isDeepReactive, handleLoadDownloadData } = config;
const table_data = isDeepReactive ? ref<any[]>([]) : shallowRef<any[]>([]);
const loading = ref(false);
@ -43,5 +43,6 @@ export const useTable = (
pagination,
handleFetchData,
handleSetPagenation,
handleLoadDownloadData,
};
};

72
backmanage/src/components/global/m_table/src/m_table.vue

@ -40,7 +40,7 @@
<slot name="adcc_ope"> </slot>
</div>
<div class="other__ope">
<div class="other__ope" v-if="show_form_other_btn" >
<slot name="other_ope">
<template v-for="[key, config] in other_ope_list" :key="key">
<el-tooltip :content="key">
@ -163,8 +163,10 @@ import { vBottomLoading } from "./directives";
import { useTable } from "./hooks";
import { useRefs } from "@/hooks/useRefs";
import { debounce } from "lodash";
import { handleExport } from "@/utils/lib/excel";
import request from '@/api/config'
defineOptions({
name: "MTable",
@ -183,6 +185,7 @@ const $props = withDefaults(defineProps<TableConfigPropType<any>>(), {
show_form: true,
show_form_ope_btn: true,
show_pagination: true,
show_form_other_btn: false,
});
const $route = useRoute();
@ -195,6 +198,7 @@ const {
table_data,
pagination,
loading,
handleLoadDownloadData,
} = useTable($props.table_config, $props.pagination_config);
const columnType = ["index", "selection", "expand", "radio"];
@ -217,7 +221,8 @@ const merge_table_config = computed(() => {
"handleLoadData",
"handleProcseeData",
"handleProcessParam",
"defaultValue"
"defaultValue",
"handleLoadDownloadData",
);
});
@ -315,14 +320,65 @@ const handleExportToExcel = () => {
const enums = toRaw(unref(enumMap));
const data = toRaw(unref(table_data));
const sheet_name = title ?? $route.meta.title;
export_loading.value = true;
handleExport(columns, data, enums, sheet_name)
.then((res) => {
const message = res ? "导出成功" : "导出失败";
const type = res ? "success" : "error";
if (handleLoadDownloadData) {
handleFetchDataAAA();
} else {
export_loading.value = true;
handleExport(columns, data, enums, sheet_name)
.then((res) => {
const message = res ? "导出成功" : "导出失败";
const type = res ? "success" : "error";
ElMessage({ type, message });
})
.finally(() => (export_loading.value = false));
};
};
const handleFetchDataAAA = debounce(async (parama = {}) => {
//
const { params, show_pagination, show_form, title } = $props;
const sheet_name = title ?? $route.meta.title;
const { handleProcessParam } = $props.table_config;
const pagination_param: Record<string, any> = show_pagination
? pick(pagination, "currentPage", "pageSize")
: {};
const form_params = show_form ? params : {};
const param = handleProcessParam
? handleProcessParam(toRaw(form_params || {}), toRaw(pagination_param))
: { ...form_params, ...pagination_param };
if (param == false) return;
if (!handleLoadDownloadData) return;
loading.value = true;
try {
const response: any = await handleLoadDownloadData(param);
// const response: any = await request.post(`/event/export-event-details`, param, { responseType: 'blob' })
handleExportDownloadExcel(sheet_name, response)
} catch (error: any) {
const message = error ? "导出成功" : "导出失败";
const type = error ? "success" : "error";
ElMessage({ type, message });
} finally {
loading.value = false;
}
}, 300);
const handleExportDownloadExcel = (title: string, response: any) => {
// let response = handleLoadDownloadData(param);
const blob = new Blob([response], {
type: 'application/octet-stream',
})
.finally(() => (export_loading.value = false));
const link = document.createElement('a') //a
link.download = decodeURIComponent(title + '.xlsx')
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
document.body.appendChild(link)
link.click() //
document.body.removeChild(link)
};
const handleResetFields = () => {

2
backmanage/src/components/global/m_table/src/type.ts

@ -61,6 +61,7 @@ interface TableType<D = any>
) => Record<string, any> | boolean;
defaultValue?: string | number; // cell 无参时默认显示的文案
rowKey?: string;
handleLoadDownloadData?: (...arg: any[]) => Promise<any> | any;
}
type TagType = {
@ -105,6 +106,7 @@ interface TableConfigPropType<D = any> extends FormConfigPropType {
show_pagination?: boolean;
show_form?: boolean;
show_form_ope_btn?: boolean;
show_form_other_btn?:boolean;
}
type MTableInstance = InstanceType<typeof import("./m_table.vue")["default"]>;

4
backmanage/src/views/eventDetail/index.vue

@ -6,6 +6,7 @@
:columns="columns"
:table_config="table_config"
table_height="100%"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item prop="eventId" label="事件ID">
@ -33,7 +34,7 @@ import { onMounted, reactive, ref, unref } from "vue";
import { useRouter } from "vue-router";
import { isArray } from "lodash";
import { IEventDetail, fetchPageEventDetails } from "@/api/module/event_detail";
import { IEventDetail, fetchPageEventDetails, ExportEventDetails } from "@/api/module/event_detail";
import { fetchChannelPromotions } from "@/api/module/channel_promotion";
import { IsEmulatorOptions } from "./enum";
@ -83,6 +84,7 @@ const table_config: TableType<IEventDetail> = {
},
defaultValue: "-",
isDeepReactive: true,
handleLoadDownloadData: ExportEventDetails,
};
//

4
backmanage/src/views/statistics/dailyGame/index.vue

@ -6,6 +6,7 @@
:columns="columns"
:table_config="table_config"
table_height="100%"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item label="起止时间" prop="time_range">
@ -38,7 +39,7 @@ import { useRouter } from "vue-router";
import { isArray } from "lodash";
import moment from "moment";
import { IStatisticsDailyGame, fetchPageDailyGameStats } from "@/api/module/statistics_daily_game";
import { IStatisticsDailyGame, fetchPageDailyGameStats, exportDailyGameStats } from "@/api/module/statistics_daily_game";
import { DEFAULT_TIME_FORMATTER } from "@/enum/formatter";
const $router = useRouter();
@ -84,6 +85,7 @@ const table_config: TableType<IStatisticsDailyGame> = {
return params;
},
defaultValue: "-",
handleLoadDownloadData: exportDailyGameStats,
};

1
backmanage/src/views/statistics/online/index.vue

@ -7,6 +7,7 @@
:table_config="table_config"
table_height="400px"
:show_pagination="false"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item label="日期">

1
backmanage/src/views/statistics/recharge/index.vue

@ -7,6 +7,7 @@
:table_config="table_config"
table_height="400px"
:show_pagination="false"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item label="日期">

1
backmanage/src/views/statistics/register/index.vue

@ -7,6 +7,7 @@
:table_config="table_config"
table_height="400px"
:show_pagination="false"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item label="起止时间" prop="time_range">

4
backmanage/src/views/statistics/total/index.vue

@ -6,6 +6,7 @@
:columns="columns"
:table_config="table_config"
table_height="100%"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item prop="channelId" label="渠道包ID">
@ -30,7 +31,7 @@ import { onMounted, reactive, ref, unref } from "vue";
import { useRouter } from "vue-router";
import { isArray } from "lodash";
import { IStatisticsDayTotal, fetchPageStatDayTotals } from "@/api/module/statistics_day_total";
import { IStatisticsDayTotal, fetchPageStatDayTotals, exportStatDayTotals } from "@/api/module/statistics_day_total";
import { AppTypeOptions, IF_STATUS } from "@/api/module/sys_dict";
import { fetchChannelPromotionsPToken } from "@/api/module/channel_promotion";
@ -80,6 +81,7 @@ const table_config: TableType<IStatisticsDayTotal> = {
},
defaultValue: "-",
isDeepReactive: true,
handleLoadDownloadData: exportStatDayTotals,
};
//

4
backmanage/src/views/userAgentDetail/index.vue

@ -6,6 +6,7 @@
:columns="columns"
:table_config="table_config"
table_height="500px"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item prop="userNo" label="用户ID">
@ -131,7 +132,7 @@ import { useRouter } from "vue-router";
import { isArray } from "lodash";
import moment from "moment";
import { IUserAgentInfo, FetchPageUserAgentInfos, deleteUserAgentInfo } from "@/api/module/user_agent_info";
import { IUserAgentInfo, FetchPageUserAgentInfos, deleteUserAgentInfo, exportUserAgentInfos } from "@/api/module/user_agent_info";
import { RECHARGE_STATUS, IF_STATUS } from "./enum";
import { useHandleData } from "@/hooks/useHandleData";
import { DEFAULT_TIME_FORMATTER } from "@/enum/formatter";
@ -177,6 +178,7 @@ const table_config: TableType<IUserAgentInfo> = {
return params;
},
defaultValue: "-",
handleLoadDownloadData: exportUserAgentInfos,
};
//

4
backmanage/src/views/verificationCode/index.vue

@ -6,6 +6,7 @@
:columns="columns"
:table_config="table_config"
table_height="100%"
:show_form_other_btn="true"
>
<template #table_form_content="{ form_param }">
<el-form-item prop="phone" label="电话">
@ -28,7 +29,7 @@ import { useRouter } from "vue-router";
import { isArray } from "lodash";
import moment from "moment";
import { IVerificationCode, fetchPageVerificationCodes } from "@/api/module/verification_code";
import { IVerificationCode, fetchPageVerificationCodes, exportVerificationCodes } from "@/api/module/verification_code";
import { DEFAULT_TIME_FORMATTER } from "@/enum/formatter";
import { IF_STATUS } from "./enum";
@ -69,6 +70,7 @@ const table_config: TableType<IVerificationCode> = {
return params;
},
defaultValue: "-",
handleLoadDownloadData: exportVerificationCodes,
};

Loading…
Cancel
Save