将代码更新到羽声代码库
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import { ref } from "vue";
|
||||
import { ref, h } from "vue";
|
||||
import {
|
||||
queryList
|
||||
} from "@/api/modules/backpack";
|
||||
import { utils, writeFile } from "xlsx";
|
||||
import { message } from "@/utils/message";
|
||||
import ExportForm from '@/components/exportDialog/index.vue';
|
||||
import { addDialog } from "@/components/ReDialog";
|
||||
export function useData() {
|
||||
const loading = ref(true);
|
||||
const tableList = ref([]);
|
||||
@@ -10,6 +14,7 @@ export function useData() {
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
background: true
|
||||
});
|
||||
const searchForm = ref({
|
||||
@@ -93,6 +98,67 @@ export function useData() {
|
||||
pagination.value.currentPage = val;
|
||||
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 queryList({
|
||||
...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.begin_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({ begin_time: curData.time[0] || '', end_time: curData.time[1] || '' })
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return {
|
||||
searchForm,
|
||||
searchLabel,
|
||||
@@ -103,6 +169,7 @@ export function useData() {
|
||||
pagination,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
exportExcel,
|
||||
loading,
|
||||
detailData
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ const {
|
||||
tableList,
|
||||
pagination,
|
||||
tableLabel,
|
||||
exportExcel,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
loading
|
||||
@@ -33,7 +34,12 @@ defineOptions({
|
||||
<PureTableBar title="背包列表" :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']" :columns="tableLabel"
|
||||
@refresh="onSearch">
|
||||
<template #buttons>
|
||||
<div v-if="detailData">总计:礼物 {{ detailData.gift_count }} 个,价值 {{ detailData.gift_total }} 金币</div>
|
||||
<div v-if="detailData" style="display:inline-flex;align-items: center;" class="mr-5">总计:礼物 {{
|
||||
detailData.gift_count }} 个,价值
|
||||
{{ detailData.gift_total }} 金币</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
|
||||
|
||||
@@ -15,6 +15,7 @@ export function useData() {
|
||||
const pagination = ref({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
currentPage: 1,
|
||||
background: true
|
||||
});
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<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"]);
|
||||
import {
|
||||
userLogData,
|
||||
@@ -44,7 +49,6 @@ const getLogData = async (type) => {
|
||||
}
|
||||
const getPhotoAlbum = async () => {
|
||||
const { data, code } = await userPhotoAlbum({ user_id: userData.value.userId })
|
||||
// console.log(data, code, '相册')
|
||||
photoAlbums.value = code ? data : []
|
||||
}
|
||||
const deleteAlbum = async (rowData) => {
|
||||
@@ -102,6 +106,64 @@ const handleCurrentChange = (val: number) => {
|
||||
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>
|
||||
<template>
|
||||
<div class="viewPage">
|
||||
@@ -124,9 +186,13 @@ const handleCurrentChange = (val: number) => {
|
||||
</div>
|
||||
<div style="margin-top: 20px;">
|
||||
<el-tabs v-model="activeIndex" @tab-click="handleClick">
|
||||
|
||||
<el-tab-pane label="金币收支" name="1">
|
||||
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto"
|
||||
:adaptiveConfig="{ offsetBottom: 108 }" :data="tableList" :columns="dynamicColumns"
|
||||
<div class="mb-5" style="float: right;">
|
||||
<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"
|
||||
@page-current-change="handleCurrentChange" :header-cell-style="{
|
||||
background: 'var(--el-fill-color-light)',
|
||||
@@ -135,8 +201,11 @@ const handleCurrentChange = (val: number) => {
|
||||
</pure-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="钻石收支" name="2">
|
||||
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto"
|
||||
:adaptiveConfig="{ offsetBottom: 108 }" @page-size-change="handleSizeChange"
|
||||
<div class="mb-5" style="float: right;">
|
||||
<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"
|
||||
:pagination="{ ...pagination }" :header-cell-style="{
|
||||
background: 'var(--el-fill-color-light)',
|
||||
@@ -146,28 +215,32 @@ const handleCurrentChange = (val: number) => {
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="ta的相册" name="3">
|
||||
<!-- {{ photoAlbums }} -->
|
||||
<div v-if="photoAlbums.length > 0" class="albums-container">
|
||||
<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">
|
||||
<div class="album-info">
|
||||
<div class="album-title">{{ album.name }}</div>
|
||||
<div class="album-stats">
|
||||
<span><i class="fas fa-images"></i> {{ album.img_num }} 张照片</span>
|
||||
<!-- <el-popconfirm title="确定删除吗?" @confirm="deleteAlbum(album)">
|
||||
<template v-if="activeIndex == 3">
|
||||
<div v-if="photoAlbums.length > 0" class="albums-container">
|
||||
<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">
|
||||
<div class="album-info">
|
||||
<div class="album-title">{{ album.name }}</div>
|
||||
<div class="album-stats">
|
||||
<span><i class="fas fa-images"></i> {{ album.img_num }} 张照片</span>
|
||||
<!-- <el-popconfirm title="确定删除吗?" @confirm="deleteAlbum(album)">
|
||||
<el-button size="small">删除</el-button>
|
||||
</el-popconfirm> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-album">
|
||||
<i class="fas fa-images"></i>
|
||||
<h3>暂无相册</h3>
|
||||
<p>该用户还没有创建任何相册</p>
|
||||
</div>
|
||||
<div v-else class="empty-album">
|
||||
<i class="fas fa-images"></i>
|
||||
<h3>暂无相册</h3>
|
||||
<p>该用户还没有创建任何相册</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { h, ref, nextTick } from "vue";
|
||||
import editForm from "./form.vue";
|
||||
import { ElMessageBox } from "element-plus";
|
||||
import ExportForm from '@/components/exportDialog/index.vue';
|
||||
import { utils, writeFile } from "xlsx";
|
||||
import detailView from './detail.vue';
|
||||
import banUserView from './banUser.vue';
|
||||
import changePassView from './password.vue';
|
||||
@@ -34,6 +37,7 @@ export function useData() {
|
||||
const pagination = ref({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
currentPage: 1,
|
||||
background: true
|
||||
});
|
||||
@@ -150,10 +154,14 @@ export function useData() {
|
||||
const onSearch = async (formData) => {
|
||||
loading.value = true;
|
||||
searchForm.value = { ...formData }
|
||||
// console.log(searchForm.value, formData, 111)
|
||||
if (!formData) {
|
||||
resetFieldsSearch()
|
||||
}
|
||||
const { data, code } = await queryList({
|
||||
...formData,
|
||||
coin1: formData.coin1 ? formData.coin1 : '',
|
||||
coin2: formData.coin2 ? formData.coin2 : '',
|
||||
// coin1: searchForm.value.coin1 ? searchForm.value.coin1 : '',
|
||||
// coin2: searchForm.value.coin2 ? searchForm.value.coin2 : '',
|
||||
page: pagination.value.currentPage,
|
||||
page_limit: pagination.value.pageSize
|
||||
});
|
||||
@@ -393,7 +401,69 @@ 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) => {
|
||||
// const { data, code } = await queryList({
|
||||
// ...searchForm.value,
|
||||
// coin1: searchForm.value.coin1 ? searchForm.value.coin1 : '',
|
||||
// coin2: searchForm.value.coin2 ? searchForm.value.coin2 : '',
|
||||
// page: pagination.value.currentPage,
|
||||
// page_limit: pagination.value.pageSize
|
||||
// });
|
||||
// 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] || '' })
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
// 修改密码
|
||||
const changePassword = async (rowData: any) => {
|
||||
addDialog({
|
||||
@@ -431,6 +501,7 @@ export function useData() {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
searchForm,
|
||||
searchLabel,
|
||||
@@ -450,6 +521,7 @@ export function useData() {
|
||||
changePassword,
|
||||
setUserFund,
|
||||
onSeniorSearch,
|
||||
resetFieldsSearch
|
||||
resetFieldsSearch,
|
||||
exportExcel
|
||||
};
|
||||
}
|
||||
@@ -23,7 +23,8 @@ const {
|
||||
changePassword,
|
||||
setUserFund,
|
||||
onSeniorSearch,
|
||||
resetFieldsSearch
|
||||
resetFieldsSearch,
|
||||
exportExcel
|
||||
} = useData();
|
||||
defineOptions({
|
||||
name: "newuserList"
|
||||
@@ -50,6 +51,11 @@ onMounted(() => {
|
||||
<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
|
||||
<PureTableBar 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" :loading="loading"
|
||||
:size="size" adaptive :adaptiveConfig="{ offsetBottom: 108 }" :data="tableList" :columns="dynamicColumns"
|
||||
|
||||
@@ -17,6 +17,7 @@ export function useData() {
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
background: true
|
||||
});
|
||||
const tableLabel = ref([
|
||||
|
||||
@@ -14,6 +14,7 @@ export function useData() {
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
background: true
|
||||
});
|
||||
const searchForm = ref({
|
||||
|
||||
Reference in New Issue
Block a user