Auto Commit

上级 3e65edb0
...@@ -9,12 +9,13 @@ import { defineProps, reactive, watch } from 'vue'; ...@@ -9,12 +9,13 @@ import { defineProps, reactive, watch } from 'vue';
import { exportExcelFunc } from './exportExcel'; import { exportExcelFunc } from './exportExcel';
const props = defineProps({ const props = defineProps({
tableData: [], tableData: [],
userId:'' userId: ''
}) })
const state = reactive({ const state = reactive({
exportLoading: false, exportLoading: false,
dataSource: [] dataSource: [],
userId: ''
}) })
const onExport = () => { const onExport = () => {
...@@ -24,7 +25,7 @@ const onExport = () => { ...@@ -24,7 +25,7 @@ const onExport = () => {
return return
} }
state.exportLoading = true state.exportLoading = true
exportExcelFunc(state.dataSource, props.userId).then(res => { exportExcelFunc(state.dataSource, state.userId).then(res => {
state.exportLoading = false state.exportLoading = false
console.log('res', res) console.log('res', res)
}).catch(r => { }).catch(r => {
...@@ -39,4 +40,11 @@ watch(() => props.tableData, ...@@ -39,4 +40,11 @@ watch(() => props.tableData,
deep: true, deep: true,
immediate: true immediate: true
}) })
watch(() => props.userId,
(val) => {
state.userId = val
}, {
deep: true,
immediate: true
})
</script> </script>
\ No newline at end of file
...@@ -76,13 +76,13 @@ const onSearch = () => { ...@@ -76,13 +76,13 @@ const onSearch = () => {
onMounted(() => { onMounted(() => {
const storageUid = localStorage.getItem('csdnUid') // const storageUid = localStorage.getItem('csdnUid')
console.log('window.localStorage', localStorage) console.log('window.localStorage', localStorage)
console.log('storageUid', storageUid) // console.log('storageUid', storageUid)
if (storageUid) { // if (storageUid) {
state.searchValue = storageUid // state.searchValue = storageUid
onSearch() // onSearch()
} // }
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
console.log(e, 'e') console.log(e, 'e')
if (e.ctrlKey && e.keyCode === 89) { if (e.ctrlKey && e.keyCode === 89) {
...@@ -117,7 +117,7 @@ onUnmounted(() => { ...@@ -117,7 +117,7 @@ onUnmounted(() => {
</div> </div>
<div> <div>
<ExportBtn :table-data="state.dataSource" :userId="state.searchValue" /> <ExportBtn :table-data="state.dataSource" :user-id="state.searchValue" />
<a-table :scroll="{ x: 800, y: 600 }" :columns="state.columns" :data-source="state.dataSource" <a-table :scroll="{ x: 800, y: 600 }" :columns="state.columns" :data-source="state.dataSource"
:loading="state.loading" :pagination="state.pagination" bordered style="border-bottom:1px solid #f0f0f0;"> :loading="state.loading" :pagination="state.pagination" bordered style="border-bottom:1px solid #f0f0f0;">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
......
...@@ -52,10 +52,10 @@ const tableToExcel = async (jsonData, fileName) => { ...@@ -52,10 +52,10 @@ const tableToExcel = async (jsonData, fileName) => {
}; };
export const exportExcelFunc = async (tableData) => { export const exportExcelFunc = async (tableData,name) => {
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
try { try {
await tableToExcel(tableData) await tableToExcel(tableData,name)
resolve(true) resolve(true)
} }
catch (r) { catch (r) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册