From 1b65ddcb2a8161e95e6eff12b726f1b32f261aa7 Mon Sep 17 00:00:00 2001 From: yziiy <15979918+mayday-yziiy@user.noreply.gitee.com> Date: Tue, 13 Jan 2026 11:29:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Statistical/acceptGiftsRank/hook.tsx | 64 ++++++----- src/views/Statistical/consumerRank/hook.tsx | 73 ++++++++----- src/views/Statistical/giftRank/hook.tsx | 66 +++++++----- src/views/Statistical/giftRecord/hook.tsx | 101 +++++++++++------- src/views/Statistical/luckycoinRank/hook.tsx | 68 +++++++----- src/views/Statistical/rechargeRank/hook.tsx | 69 +++++++----- src/views/Statistical/roomFlowRank/hook.tsx | 72 ++++++++----- src/views/Statistical/taskAssignment/hook.tsx | 77 +++++++------ 8 files changed, 364 insertions(+), 226 deletions(-) diff --git a/src/views/Statistical/acceptGiftsRank/hook.tsx b/src/views/Statistical/acceptGiftsRank/hook.tsx index a8a98a8..0ad2d7c 100644 --- a/src/views/Statistical/acceptGiftsRank/hook.tsx +++ b/src/views/Statistical/acceptGiftsRank/hook.tsx @@ -1,16 +1,16 @@ import { ref, h } from "vue"; import { utils, writeFile } from "xlsx"; import { message } from "@/utils/message"; -import { - queryGiftRankList -} from "@/api/modules/statistics"; -import ExportForm from '@/components/exportDialog/index.vue'; +import { queryGiftRankList } from "@/api/modules/statistics"; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); const isShow = ref(false); - const total_price = ref(0) + const total_price = ref(0); const pagination = ref({ total: 0, pageSize: 10, @@ -18,18 +18,29 @@ export function useData() { currentPage: 1, background: true }); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { begin_time: startOfMonth, end_time: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); + const searchForm = ref({ search_uid: "", - begin_time: "", + begin_time: defaultTime.begin_time, username: "", - end_time: "", + end_time: defaultTime.end_time, type: 2 }); const searchLabel = ref([ { label: "用户ID", prop: "search_uid", type: "input" }, { label: "用户昵称", prop: "username", type: "input" }, { label: "开始时间", prop: "begin_time", type: "date" }, - { label: "结束时间", prop: "end_time", type: "date" }, + { label: "结束时间", prop: "end_time", type: "date" } ]); const tableLabel = ref([ // { @@ -56,20 +67,19 @@ export function useData() { { label: "总收益", prop: "total_price" - }, + } // { // label: "生成时间", // prop: "createtime" // } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryGiftRankList({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists; @@ -87,23 +97,24 @@ export function useData() { pagination.value.currentPage = val; onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await queryGiftRankList({ ...formData, page: 1, @@ -126,28 +137,33 @@ export function useData() { const workSheet = utils.aoa_to_sheet(res); const workBook = utils.book_new(); utils.book_append_sheet(workBook, workSheet, "数据报表"); - writeFile(workBook, `收礼排行统计${formData.begin_time} - ${formData.end_time}.xlsx`); + writeFile( + workBook, + `收礼排行统计${formData.begin_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + done(); } else { message("获取数据失败,请重试!", { type: "error" }); } - } + }; FormRef.validate(valid => { if (valid) { if (curData.time && curData.time.length) { - exportData({ begin_time: curData.time[0] || '', end_time: curData.time[1] || '' }) + exportData({ + begin_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); - - } + }; return { searchForm, searchLabel, diff --git a/src/views/Statistical/consumerRank/hook.tsx b/src/views/Statistical/consumerRank/hook.tsx index fcf277e..056318b 100644 --- a/src/views/Statistical/consumerRank/hook.tsx +++ b/src/views/Statistical/consumerRank/hook.tsx @@ -1,16 +1,16 @@ import { ref, h } from "vue"; import { utils, writeFile } from "xlsx"; -import ExportForm from '@/components/exportDialog/index.vue'; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; -import { - queryConsumerRankList -} from "@/api/modules/statistics"; +import { queryConsumerRankList } from "@/api/modules/statistics"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); const isShow = ref(false); - const total_price = ref(0) + const total_price = ref(0); const pagination = ref({ total: 0, pageSize: 10, @@ -18,17 +18,28 @@ export function useData() { currentPage: 1, background: true }); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { begin_time: startOfMonth, end_time: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); + const searchForm = ref({ search_uid: "", - begin_time: "", - username: '', - end_time: "" + begin_time: defaultTime.begin_time, + username: "", + end_time: defaultTime.end_time }); const searchLabel = ref([ { label: "用户ID", prop: "search_uid", type: "input" }, { label: "用户昵称", prop: "username", type: "input" }, { label: "开始时间", prop: "begin_time", type: "date" }, - { label: "结束时间", prop: "end_time", type: "date" }, + { label: "结束时间", prop: "end_time", type: "date" } ]); const tableLabel = ref([ // { @@ -55,28 +66,28 @@ export function useData() { { label: "消费总额", prop: "change_value" - }, + } // { // label: "消费时间", // prop: "createtime" // } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryConsumerRankList({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { return { - ...ele, ...data.total - } + ...ele, + ...data.total + }; }); - total_price.value = data.total.total_price + total_price.value = data.total.total_price; pagination.value.total = data.count; pagination.value.currentPage = data.page; } @@ -90,23 +101,24 @@ export function useData() { pagination.value.currentPage = val; onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await queryConsumerRankList({ ...formData, page: 1, @@ -129,28 +141,33 @@ export function useData() { const workSheet = utils.aoa_to_sheet(res); const workBook = utils.book_new(); utils.book_append_sheet(workBook, workSheet, "数据报表"); - writeFile(workBook, `消费排行统计${formData.begin_time} - ${formData.end_time}.xlsx`); + writeFile( + workBook, + `消费排行统计${formData.begin_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + done(); } else { message("获取数据失败,请重试!", { type: "error" }); } - } + }; FormRef.validate(valid => { if (valid) { if (curData.time && curData.time.length) { - exportData({ begin_time: curData.time[0] || '', end_time: curData.time[1] || '' }) + exportData({ + begin_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); - - } + }; return { searchForm, searchLabel, diff --git a/src/views/Statistical/giftRank/hook.tsx b/src/views/Statistical/giftRank/hook.tsx index c2ea647..6684ff4 100644 --- a/src/views/Statistical/giftRank/hook.tsx +++ b/src/views/Statistical/giftRank/hook.tsx @@ -1,11 +1,11 @@ import { ref, h } from "vue"; -import { - queryGiftRankList -} from "@/api/modules/statistics"; +import { queryGiftRankList } from "@/api/modules/statistics"; import { utils, writeFile } from "xlsx"; -import ExportForm from '@/components/exportDialog/index.vue'; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); @@ -17,19 +17,30 @@ export function useData() { currentPage: 1, background: true }); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { begin_time: startOfMonth, end_time: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); + const searchForm = ref({ search_uid: "", - begin_time: "", - end_time: "", + begin_time: defaultTime.begin_time, + end_time: defaultTime.end_time, username: "", type: 1 }); - const total_price = ref(0) + const total_price = ref(0); const searchLabel = ref([ { label: "用户ID", prop: "search_uid", type: "input" }, { label: "用户昵称", prop: "username", type: "input" }, { label: "开始时间", prop: "begin_time", type: "date" }, - { label: "结束时间", prop: "end_time", type: "date" }, + { label: "结束时间", prop: "end_time", type: "date" } ]); const tableLabel = ref([ // { @@ -60,24 +71,23 @@ export function useData() { { label: "礼物总量", prop: "number" - }, + } // { // label: "生成时间", // prop: "createtime" // } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryGiftRankList({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { total_price.value = data.total.total_price || 0; - tableList.value = data.lists + tableList.value = data.lists; pagination.value.total = data.count; pagination.value.currentPage = data.page; } @@ -91,23 +101,24 @@ export function useData() { pagination.value.currentPage = val; onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await queryGiftRankList({ ...formData, page: 1, @@ -130,28 +141,33 @@ export function useData() { const workSheet = utils.aoa_to_sheet(res); const workBook = utils.book_new(); utils.book_append_sheet(workBook, workSheet, "数据报表"); - writeFile(workBook, `送礼排行统计${formData.begin_time} - ${formData.end_time}.xlsx`); + writeFile( + workBook, + `送礼排行统计${formData.begin_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + done(); } else { message("获取数据失败,请重试!", { type: "error" }); } - } + }; FormRef.validate(valid => { if (valid) { if (curData.time && curData.time.length) { - exportData({ begin_time: curData.time[0] || '', end_time: curData.time[1] || '' }) + exportData({ + begin_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); - - } + }; return { searchForm, diff --git a/src/views/Statistical/giftRecord/hook.tsx b/src/views/Statistical/giftRecord/hook.tsx index 7ed1226..5c8a611 100644 --- a/src/views/Statistical/giftRecord/hook.tsx +++ b/src/views/Statistical/giftRecord/hook.tsx @@ -1,11 +1,11 @@ import { ref, h } from "vue"; -import { - queryGiftGiveList -} from "@/api/modules/statistics"; +import { queryGiftGiveList } from "@/api/modules/statistics"; import { utils, writeFile } from "xlsx"; -import ExportForm from '@/components/exportDialog/index.vue'; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); @@ -17,17 +17,28 @@ export function useData() { currentPage: 1, background: true }); - const statisticsList = ref() + const statisticsList = ref(); + + const totalData = ref(null); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { start_time: startOfMonth, end_time: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); - const totalData = ref(null) const searchForm = ref({ send_user: "", gift_user: "", from_id: "", gift_id: "", from: "", - start_time: "", - end_time: "" + start_time: defaultTime.start_time, + end_time: defaultTime.end_time }); const searchLabel = ref([ { label: "送礼用户ID", prop: "send_user", type: "input" }, @@ -35,7 +46,9 @@ export function useData() { { label: "房间ID", prop: "from_id", type: "input" }, { label: "礼物ID", prop: "gift_id", type: "input" }, { - label: "来源", prop: "from", type: "select", + label: "来源", + prop: "from", + type: "select", optionList: [ { label: "聊天送礼物", value: 1 }, { label: "房间语聊送礼", value: 2 }, @@ -44,9 +57,9 @@ export function useData() { ] }, { label: "开始时间", prop: "start_time", type: "date" }, - { label: "结束时间", prop: "end_time", type: "date" }, + { label: "结束时间", prop: "end_time", type: "date" } ]); - const tableLabel = ref([]) + const tableLabel = ref([]); const tableLabelS = ref([ { label: "送礼人ID-昵称", @@ -80,22 +93,23 @@ export function useData() { label: "来源", prop: "type", cellRenderer: ({ row }) => ( - {row.type === 1 ? '金币购买' : '背包礼物'} - ), + + {row.type === 1 ? "金币购买" : "背包礼物"} + + ) }, { label: "生成时间", prop: "createtime" } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryGiftGiveList({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { const objLabel = [ @@ -111,7 +125,7 @@ export function useData() { label: `房主收益(${data.total.room_owner_earning_ratio}%)钻石`, prop: "room_owner_earning" } - ] + ]; const objStatistics = [ { label: `平台收益(${data.total.app_earning_ratio}%)钻石`, @@ -125,24 +139,26 @@ export function useData() { label: `房主收益(${data.total.room_owner_earning_ratio}%)钻石`, prop: "room_owner_earning" } - ] - statisticsList.value = [...[ - { label: "礼物总数量", prop: "gift_num" }, - { label: "礼物总价", prop: "total_price" } - ], ...objStatistics] - tableLabel.value = [...tableLabelS.value] - tableLabel.value.splice(7, 0, ...objLabel) - console.log(tableLabel.value) + ]; + statisticsList.value = [ + ...[ + { label: "礼物总数量", prop: "gift_num" }, + { label: "礼物总价", prop: "total_price" } + ], + ...objStatistics + ]; + tableLabel.value = [...tableLabelS.value]; + tableLabel.value.splice(7, 0, ...objLabel); + console.log(tableLabel.value); tableList.value = data.lists.map(ele => { return { ...ele, app_earning: parseFloat(ele.app_earning), room_owner_earning: parseFloat(ele.room_owner_earning), - gift_user_earning: parseFloat(ele.gift_user_earning), - } + gift_user_earning: parseFloat(ele.gift_user_earning) + }; }); - totalData.value = data.total; pagination.value.total = data.count; pagination.value.currentPage = parseFloat(data.page); @@ -158,23 +174,24 @@ export function useData() { // console.log(searchForm.value, 'yzy') onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await queryGiftGiveList({ ...formData, send_user: searchForm.value.send_user, @@ -202,28 +219,34 @@ export function useData() { 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`); + writeFile( + workBook, + `礼物记录列表统计${formData.start_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + 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] || '' }) + exportData({ + start_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); + }; - } return { searchForm, searchLabel, diff --git a/src/views/Statistical/luckycoinRank/hook.tsx b/src/views/Statistical/luckycoinRank/hook.tsx index 4bb8bf8..7b9364e 100644 --- a/src/views/Statistical/luckycoinRank/hook.tsx +++ b/src/views/Statistical/luckycoinRank/hook.tsx @@ -1,12 +1,12 @@ import { ref, h } from "vue"; -import { - getLuckyRank -} from "@/api/modules/statistics"; +import { getLuckyRank } from "@/api/modules/statistics"; import { utils, writeFile } from "xlsx"; -import ExportForm from '@/components/exportDialog/index.vue'; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; -import detailView from './form.vue'; +import detailView from "./form.vue"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); @@ -18,13 +18,24 @@ export function useData() { currentPage: 1, background: true }); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { stime: startOfMonth, etime: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); + const searchForm = ref({ - stime: "", - etime: "" + stime: defaultTime.stime, + etime: defaultTime.etime }); const searchLabel = ref([ { label: "开始时间", prop: "stime", type: "date" }, - { label: "结束时间", prop: "etime", type: "date" }, + { label: "结束时间", prop: "etime", type: "date" } ]); const tableLabel = ref([ { @@ -56,14 +67,13 @@ export function useData() { prop: "createtime" } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await getLuckyRank({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { @@ -71,9 +81,9 @@ export function useData() { ...ele, pool_amount: parseFloat(ele.pool_amount), prize_amount: parseFloat(ele.prize_amount) - } + }; }); - pagination.value.total = data.count + pagination.value.total = data.count; pagination.value.currentPage = parseFloat(data.page); } loading.value = false; @@ -87,23 +97,24 @@ export function useData() { // console.log(searchForm.value, 'yzy') onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await getLuckyRank({ ...formData, page: 1, @@ -126,28 +137,33 @@ export function useData() { 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`); + writeFile( + workBook, + `幸运币中奖记录列表统计${formData.start_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + 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] || '' }) + exportData({ + start_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); - - } + }; // 实时状态查询 const openDiglog = () => { addDialog({ @@ -157,7 +173,7 @@ export function useData() { closeOnClickModal: false, contentRenderer: () => h(detailView) }); - } + }; return { searchForm, searchLabel, diff --git a/src/views/Statistical/rechargeRank/hook.tsx b/src/views/Statistical/rechargeRank/hook.tsx index 69311c8..26dacb7 100644 --- a/src/views/Statistical/rechargeRank/hook.tsx +++ b/src/views/Statistical/rechargeRank/hook.tsx @@ -1,11 +1,11 @@ import { ref, h } from "vue"; -import { - queryRechargeRankList -} from "@/api/modules/statistics"; +import { queryRechargeRankList } from "@/api/modules/statistics"; import { utils, writeFile } from "xlsx"; import { message } from "@/utils/message"; -import ExportForm from '@/components/exportDialog/index.vue'; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); @@ -17,18 +17,29 @@ export function useData() { currentPage: 1, background: true }); - const total_price = ref(0) + const total_price = ref(0); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { begin_time: startOfMonth, end_time: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); + const searchForm = ref({ search_uid: "", - begin_time: "", + begin_time: defaultTime.begin_time, username: "", - end_time: "" + end_time: defaultTime.end_time }); const searchLabel = ref([ { label: "用户ID", prop: "search_uid", type: "input" }, { label: "用户昵称", prop: "username", type: "input" }, { label: "开始时间", prop: "begin_time", type: "date" }, - { label: "结束时间", prop: "end_time", type: "date" }, + { label: "结束时间", prop: "end_time", type: "date" } ]); const tableLabel = ref([ // { @@ -59,26 +70,26 @@ export function useData() { { label: "总获取金币", prop: "coin" - }, + } // { // label: "充值时间", // prop: "createtime" // } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryRechargeRankList({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { return { - ...ele, ...data.total - } + ...ele, + ...data.total + }; }); total_price.value = data.total.total_price || 0; pagination.value.total = data.count; @@ -94,23 +105,24 @@ export function useData() { pagination.value.currentPage = val; onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await queryRechargeRankList({ ...formData, page: 1, @@ -133,28 +145,33 @@ export function useData() { const workSheet = utils.aoa_to_sheet(res); const workBook = utils.book_new(); utils.book_append_sheet(workBook, workSheet, "数据报表"); - writeFile(workBook, `充值排行统计${formData.begin_time} - ${formData.end_time}.xlsx`); + writeFile( + workBook, + `充值排行统计${formData.begin_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + done(); } else { message("获取数据失败,请重试!", { type: "error" }); } - } + }; FormRef.validate(valid => { if (valid) { if (curData.time && curData.time.length) { - exportData({ begin_time: curData.time[0] || '', end_time: curData.time[1] || '' }) + exportData({ + begin_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); - - } + }; return { searchForm, searchLabel, diff --git a/src/views/Statistical/roomFlowRank/hook.tsx b/src/views/Statistical/roomFlowRank/hook.tsx index 895f88b..17a5cf6 100644 --- a/src/views/Statistical/roomFlowRank/hook.tsx +++ b/src/views/Statistical/roomFlowRank/hook.tsx @@ -1,16 +1,16 @@ import { ref, h } from "vue"; import { utils, writeFile } from "xlsx"; -import ExportForm from '@/components/exportDialog/index.vue'; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; -import { - queryRoomFlowRankList -} from "@/api/modules/statistics"; +import { queryRoomFlowRankList } from "@/api/modules/statistics"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); const isShow = ref(false); - const total_price = ref(0) + const total_price = ref(0); const pagination = ref({ total: 0, pageSize: 10, @@ -18,17 +18,28 @@ export function useData() { currentPage: 1, background: true }); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { begin_time: startOfMonth, end_time: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); + const searchForm = ref({ search_room_id: "", - begin_time: "", - room_name: '', - end_time: "" + begin_time: defaultTime.begin_time, + room_name: "", + end_time: defaultTime.end_time }); const searchLabel = ref([ { label: "房间ID", prop: "search_room_id", type: "input" }, { label: "房间名称", prop: "room_name", type: "input" }, { label: "开始时间", prop: "begin_time", type: "date" }, - { label: "结束时间", prop: "end_time", type: "date" }, + { label: "结束时间", prop: "end_time", type: "date" } ]); const tableLabel = ref([ // { @@ -54,7 +65,7 @@ export function useData() { preview-src-list={Array.of(row.room_cover)} class="w-[35px] h-[35px] align-middle" /> - ), + ) }, { label: "幸运值流水", @@ -63,28 +74,27 @@ export function useData() { { label: "房间流水", prop: "total_price" - }, + } // { // label: "生成时间", // prop: "createtime" // } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryRoomFlowRankList({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { return { ...ele - } + }; }); - total_price.value = data.total + total_price.value = data.total; pagination.value.total = data.count; pagination.value.currentPage = data.page; } @@ -98,23 +108,24 @@ export function useData() { pagination.value.currentPage = val; onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await queryRoomFlowRankList({ ...formData, page: 1, @@ -137,28 +148,33 @@ export function useData() { const workSheet = utils.aoa_to_sheet(res); const workBook = utils.book_new(); utils.book_append_sheet(workBook, workSheet, "数据报表"); - writeFile(workBook, `房间流水统计${formData.begin_time} - ${formData.end_time}.xlsx`); + writeFile( + workBook, + `房间流水统计${formData.begin_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + done(); } else { message("获取数据失败,请重试!", { type: "error" }); } - } + }; FormRef.validate(valid => { if (valid) { if (curData.time && curData.time.length) { - exportData({ begin_time: curData.time[0] || '', end_time: curData.time[1] || '' }) + exportData({ + begin_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); - - } + }; return { searchForm, searchLabel, diff --git a/src/views/Statistical/taskAssignment/hook.tsx b/src/views/Statistical/taskAssignment/hook.tsx index b1ffe78..1cc5f96 100644 --- a/src/views/Statistical/taskAssignment/hook.tsx +++ b/src/views/Statistical/taskAssignment/hook.tsx @@ -1,17 +1,16 @@ import { ref, h } from "vue"; import { utils, writeFile } from "xlsx"; -import ExportForm from '@/components/exportDialog/index.vue'; +import ExportForm from "@/components/exportDialog/index.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; -import { - taskRankList, - taskRewardPriceData -} from "@/api/modules/statistics"; +import { taskRankList, taskRewardPriceData } from "@/api/modules/statistics"; +import dayjs from "dayjs"; + export function useData() { const loading = ref(true); const tableList = ref([]); const isShow = ref(false); - const total_price = ref(0) + const total_price = ref(0); const pagination = ref({ total: 0, pageSize: 10, @@ -19,13 +18,24 @@ export function useData() { currentPage: 1, background: true }); + + // 获取当月第一天 00:00:00 和当前时间 + const getDefaultTimeRange = () => { + const now = dayjs(); + const startOfMonth = now.startOf("month").format("YYYY-MM-DD HH:mm:ss"); + const currentTime = now.format("YYYY-MM-DD HH:mm:ss"); + return { begin_time: startOfMonth, end_time: currentTime }; + }; + + const defaultTime = getDefaultTimeRange(); + const searchForm = ref({ search_uid: "", search_name: "", - search_task_id: '', - search_task_name: '', - begin_time: "", - end_time: "" + search_task_id: "", + search_task_name: "", + begin_time: defaultTime.begin_time, + end_time: defaultTime.end_time }); const searchLabel = ref([ { label: "用户ID", prop: "search_uid", type: "input" }, @@ -33,7 +43,7 @@ export function useData() { { label: "任务ID", prop: "search_task_id", type: "input" }, { label: "任务昵称", prop: "search_task_name", type: "input" }, { label: "开始时间", prop: "begin_time", type: "date" }, - { label: "结束时间", prop: "end_time", type: "date" }, + { label: "结束时间", prop: "end_time", type: "date" } ]); const tableLabel = ref([ { @@ -60,7 +70,9 @@ export function useData() { label: "领取状态", prop: "is_completed_str", cellRenderer: ({ row }) => ( - {row.is_completed == 0 ? '未领取' : '已领取'} + + {row.is_completed == 0 ? "未领取" : "已领取"} + ) }, { @@ -72,28 +84,27 @@ export function useData() { prop: "reward_price" } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await taskRankList({ ...formData, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { return { ...ele - } + }; }); // total_price.value = data.total_reward_price pagination.value.total = data.count; pagination.value.currentPage = data.page; } - const res = await taskRewardPriceData({ ...formData }) + const res = await taskRewardPriceData({ ...formData }); // console.log(res) - total_price.value = res.code ? res.data.total_reward_price : 0 + total_price.value = res.code ? res.data.total_reward_price : 0; loading.value = false; }; const handleSizeChange = (val: number) => { @@ -104,23 +115,24 @@ export function useData() { pagination.value.currentPage = val; onSearch(searchForm.value); }; - const exportFormRef = ref(null) + const exportFormRef = ref(null); const exportExcel = () => { - let exportTableList = [] + let exportTableList = []; addDialog({ title: `导出数据`, props: { formInline: { - time: '' + time: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), + 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 exportData = async formData => { const { data, code } = await taskRankList({ ...formData, page: 1, @@ -143,28 +155,33 @@ export function useData() { const workSheet = utils.aoa_to_sheet(res); const workBook = utils.book_new(); utils.book_append_sheet(workBook, workSheet, "数据报表"); - writeFile(workBook, `任务领取记录统计${formData.begin_time} - ${formData.end_time}.xlsx`); + writeFile( + workBook, + `任务领取记录统计${formData.begin_time} - ${formData.end_time}.xlsx` + ); message("导出成功", { type: "success" }); - done() + done(); } else { message("获取数据失败,请重试!", { type: "error" }); } - } + }; FormRef.validate(valid => { if (valid) { if (curData.time && curData.time.length) { - exportData({ begin_time: curData.time[0] || '', end_time: curData.time[1] || '' }) + exportData({ + begin_time: curData.time[0] || "", + end_time: curData.time[1] || "" + }); } } }); } }); - - } + }; return { searchForm, searchLabel,