This commit is contained in:
yziiy
2025-09-28 15:58:13 +08:00
parent c8a023ef31
commit fba111a140
4 changed files with 163 additions and 85 deletions

View File

@@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import RichText from '@/components/RichText/index.vue';
const ruleFormRef = ref(); const ruleFormRef = ref();
const formRules = ref({ const formRules = ref({
version: [{ required: true, message: "版本号为必填项", trigger: "blur" }], version: [{ required: true, message: "版本号为必填项", trigger: "blur" }],
@@ -31,7 +32,9 @@ const newFormInline = ref(
function getRef() { function getRef() {
return ruleFormRef.value; return ruleFormRef.value;
} }
function chanageEditorValue(val) {
newFormInline.value.content = val
}
defineExpose({ getRef }); defineExpose({ getRef });
</script> </script>
@@ -53,7 +56,9 @@ defineExpose({ getRef });
<el-input v-model="newFormInline.downloadurl" clearable placeholder="请输入下载链接" /> <el-input v-model="newFormInline.downloadurl" clearable placeholder="请输入下载链接" />
</el-form-item> </el-form-item>
<el-form-item label="更新内容" prop="content"> <el-form-item label="更新内容" prop="content">
<el-input v-model="newFormInline.content" type="textarea" clearable placeholder="请输入更新内容" /> <RichText style="border: 1px solid #ccc;" :echoValue="newFormInline.content" @changeValue="chanageEditorValue">
</RichText>
<!-- <el-input v-model="newFormInline.content" type="textarea" clearable placeholder="请输入更新内容" /> -->
</el-form-item> </el-form-item>
<el-form-item label="强制更新" prop="enforce"> <el-form-item label="强制更新" prop="enforce">
<el-radio-group v-model="newFormInline.enforce"> <el-radio-group v-model="newFormInline.enforce">

View File

@@ -1,5 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from "vue"; import { ref, onMounted, h } from "vue";
import ExportForm from '@/components/exportDialog/index.vue';
import { utils, writeFile } from "xlsx";
const exportFormRef = ref(null)
import { addDialog } from "@/components/ReDialog";
import { message } from "@/utils/message";
const props = defineProps(["userInfo"]); const props = defineProps(["userInfo"]);
import { import {
userLogData, userLogData,
@@ -44,7 +49,6 @@ const getLogData = async (type) => {
} }
const getPhotoAlbum = async () => { const getPhotoAlbum = async () => {
const { data, code } = await userPhotoAlbum({ user_id: userData.value.userId }) const { data, code } = await userPhotoAlbum({ user_id: userData.value.userId })
// console.log(data, code, '相册')
photoAlbums.value = code ? data : [] photoAlbums.value = code ? data : []
} }
const deleteAlbum = async (rowData) => { const deleteAlbum = async (rowData) => {
@@ -102,6 +106,64 @@ const handleCurrentChange = (val: number) => {
getLogData(activeIndex.value == '1' ? 1 : 2) getLogData(activeIndex.value == '1' ? 1 : 2)
}; };
// //
const exportTable = (activeIndex) => {
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 userLogData({
user_id: userData.value.userId, type: activeIndex.value == '1' ? 1 : 2, page: 1, page_limit: 10000
})
if (code) {
exportTableList = data.lists;
const res = exportTableList.map(item => {
const arr = [];
dynamicColumns.value.forEach(column => {
arr.push(item[column.prop as string]);
});
return arr;
});
const titleList = [];
dynamicColumns.value.forEach(column => {
titleList.push(column.label);
});
res.unshift(titleList);
console.log(titleList)
const workSheet = utils.aoa_to_sheet(res);
const workBook = utils.book_new();
utils.book_append_sheet(workBook, workSheet, "数据报表");
writeFile(workBook, `${activeIndex.value == '1' ? '金币' : '钻石'}统计——${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] || '' })
}
}
});
}
});
}
</script> </script>
<template> <template>
<div class="viewPage"> <div class="viewPage">
@@ -124,9 +186,13 @@ const handleCurrentChange = (val: number) => {
</div> </div>
<div style="margin-top: 20px;"> <div style="margin-top: 20px;">
<el-tabs v-model="activeIndex" @tab-click="handleClick"> <el-tabs v-model="activeIndex" @tab-click="handleClick">
<el-tab-pane label="金币收支" name="1"> <el-tab-pane label="金币收支" name="1">
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" <div class="mb-5" style="float: right;">
:adaptiveConfig="{ offsetBottom: 108 }" :data="tableList" :columns="dynamicColumns" <el-button @click="exportTable(activeIndex)" type="primary">导出当前表格</el-button>
</div>
<pure-table v-if="activeIndex == 1" ref="tableRef" align-whole="center" showOverflowTooltip
table-layout="auto" :adaptiveConfig="{ offsetBottom: 108 }" :data="tableList" :columns="dynamicColumns"
:pagination="{ ...pagination }" @page-size-change="handleSizeChange" :pagination="{ ...pagination }" @page-size-change="handleSizeChange"
@page-current-change="handleCurrentChange" :header-cell-style="{ @page-current-change="handleCurrentChange" :header-cell-style="{
background: 'var(--el-fill-color-light)', background: 'var(--el-fill-color-light)',
@@ -135,8 +201,11 @@ const handleCurrentChange = (val: number) => {
</pure-table> </pure-table>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="钻石收支" name="2"> <el-tab-pane label="钻石收支" name="2">
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" <div class="mb-5" style="float: right;">
:adaptiveConfig="{ offsetBottom: 108 }" @page-size-change="handleSizeChange" <el-button @click="exportTable(activeIndex)" type="primary">导出当前表格</el-button>
</div>
<pure-table v-if="activeIndex == 2" ref="tableRef" align-whole="center" showOverflowTooltip
table-layout="auto" :adaptiveConfig="{ offsetBottom: 108 }" @page-size-change="handleSizeChange"
@page-current-change="handleCurrentChange" :data="tableList" :columns="dynamicColumns" @page-current-change="handleCurrentChange" :data="tableList" :columns="dynamicColumns"
:pagination="{ ...pagination }" :header-cell-style="{ :pagination="{ ...pagination }" :header-cell-style="{
background: 'var(--el-fill-color-light)', background: 'var(--el-fill-color-light)',
@@ -146,6 +215,7 @@ const handleCurrentChange = (val: number) => {
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="ta的相册" name="3"> <el-tab-pane label="ta的相册" name="3">
<!-- {{ photoAlbums }} --> <!-- {{ photoAlbums }} -->
<template v-if="activeIndex == 3">
<div v-if="photoAlbums.length > 0" class="albums-container"> <div v-if="photoAlbums.length > 0" class="albums-container">
<div v-for="(album, index) in photoAlbums" :key="index" class="album-card" @click="openAlbum(album)"> <div v-for="(album, index) in photoAlbums" :key="index" class="album-card" @click="openAlbum(album)">
<img :src="album.image" class="album-cover" alt="Album cover"> <img :src="album.image" class="album-cover" alt="Album cover">
@@ -166,8 +236,11 @@ const handleCurrentChange = (val: number) => {
<h3>暂无相册</h3> <h3>暂无相册</h3>
<p>该用户还没有创建任何相册</p> <p>该用户还没有创建任何相册</p>
</div> </div>
</template>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
</div> </div>
</template> </template>

View File

@@ -1,5 +1,6 @@
import { h, ref, nextTick } from "vue"; import { h, ref, nextTick } from "vue";
import editForm from "./form.vue"; import editForm from "./form.vue";
import { ElMessageBox } from "element-plus";
import ExportForm from '@/components/exportDialog/index.vue'; import ExportForm from '@/components/exportDialog/index.vue';
import { utils, writeFile } from "xlsx"; import { utils, writeFile } from "xlsx";
import detailView from './detail.vue'; import detailView from './detail.vue';
@@ -399,67 +400,64 @@ export function useData() {
const exportFormRef = ref(null) const exportFormRef = ref(null)
const exportExcel = () => { const exportExcel = () => {
let exportTableList = [] let exportTableList = []
addDialog({ // addDialog({
title: `导出数据`, // title: `导出数据`,
props: { // props: {
formInline: { // formInline: {
time: '' // time: ''
} // }
}, // },
width: "40%", // width: "40%",
closeOnClickModal: false, // closeOnClickModal: false,
contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }), // contentRenderer: () => h(ExportForm, { ref: exportFormRef, formInline: null }),
beforeSure: (done, { options }) => { // beforeSure: (done, { options }) => {
const FormRef = exportFormRef.value.getRef(); // const FormRef = exportFormRef.value.getRef();
const curData = options.props.formInline; // const curData = options.props.formInline;
const exportData = async (formData) => { // const exportData = async (formData) => {
const { data, code } = await queryGiftGiveList({ // const { data, code } = await queryList({
...formData, // ...searchForm.value,
send_user: searchForm.value.send_user, // coin1: searchForm.value.coin1 ? searchForm.value.coin1 : '',
gift_user: searchForm.value.gift_user, // coin2: searchForm.value.coin2 ? searchForm.value.coin2 : '',
from_id: searchForm.value.from_id, // page: pagination.value.currentPage,
gift_id: searchForm.value.gift_id, // page_limit: pagination.value.pageSize
from: searchForm.value.from, // });
page: 1, // if (code) {
page_limit: 20000 // exportTableList = data.lists;
}); // const res = exportTableList.map(item => {
if (code) { // const arr = [];
exportTableList = data.lists; // tableLabel.value.forEach(column => {
const res = exportTableList.map(item => { // arr.push(item[column.prop as string]);
const arr = []; // });
tableLabel.value.forEach(column => { // return arr;
arr.push(item[column.prop as string]); // });
}); // const titleList = [];
return arr; // tableLabel.value.forEach(column => {
}); // titleList.push(column.label);
const titleList = []; // });
tableLabel.value.forEach(column => { // res.unshift(titleList);
titleList.push(column.label); // const workSheet = utils.aoa_to_sheet(res);
}); // const workBook = utils.book_new();
res.unshift(titleList); // utils.book_append_sheet(workBook, workSheet, "数据报表");
const workSheet = utils.aoa_to_sheet(res); // writeFile(workBook, `礼物记录列表统计${formData.start_time} - ${formData.end_time}.xlsx`);
const workBook = utils.book_new(); // message("导出成功", {
utils.book_append_sheet(workBook, workSheet, "数据报表"); // type: "success"
writeFile(workBook, `礼物记录列表统计${formData.start_time} - ${formData.end_time}.xlsx`); // });
message("导出成功", { // done()
type: "success" // } else {
}); // message("获取数据失败,请重试!", {
done() // type: "error"
} else { // });
message("获取数据失败,请重试!", { // }
type: "error" // }
}); // FormRef.validate(valid => {
} // if (valid) {
} // if (curData.time && curData.time.length) {
FormRef.validate(valid => { // exportData({ start_time: curData.time[0] || '', end_time: curData.time[1] || '' })
if (valid) { // }
if (curData.time && curData.time.length) { // }
exportData({ start_time: curData.time[0] || '', end_time: curData.time[1] || '' }) // });
} // }
} // });
});
}
});
} }
// 修改密码 // 修改密码

View File

@@ -36,8 +36,10 @@ const statisticsList = ref([
label: "总礼物价值(收入)", prop: "total_gift_money" label: "总礼物价值(收入)", prop: "total_gift_money"
}, },
{ label: "统计(收入/支出)", prop: "ratio", tip: "%" }, { label: "统计(收入/支出)", prop: "ratio", tip: "%" },
{ label: "盈亏(收入-支出)", prop: "profit_loss" }, { label: "用户盈亏", prop: "profit_loss" },
{ label: "盈亏比(盈亏/支出)", prop: "profit_loss_ratio", tip: "%" }, { label: "用户盈亏比", prop: "profit_loss_ratio", tip: "%" },
{ label: "平台盈亏", prop: "platform_profit_loss" },
{ label: "平台盈亏比", prop: "platform_profit_loss_ratio", tip: "%" },
]) ])
const dynamicflowColumns = ref([ const dynamicflowColumns = ref([
{ {