更新导出部分
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { h, ref, nextTick } from "vue";
|
||||
import editForm from "./form.vue";
|
||||
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';
|
||||
@@ -394,7 +396,72 @@ 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 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, `礼物记录列表统计${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({
|
||||
@@ -432,6 +499,7 @@ export function useData() {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
searchForm,
|
||||
searchLabel,
|
||||
@@ -451,6 +519,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"
|
||||
|
||||
Reference in New Issue
Block a user