|
|
@ -7,6 +7,14 @@ import moment from 'moment' |
|
|
import { useI18n } from 'vue-i18n' |
|
|
import { useI18n } from 'vue-i18n' |
|
|
import { useAdminStore } from "@/store/index.js" |
|
|
import { useAdminStore } from "@/store/index.js" |
|
|
import { storeToRefs } from "pinia" |
|
|
import { storeToRefs } from "pinia" |
|
|
|
|
|
import { selectWalletRecords } from "@/api/cash/cash.js" |
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
|
|
type: { |
|
|
|
|
|
type: Number, |
|
|
|
|
|
required: true |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
const { t } = useI18n() |
|
|
const route = useRoute() |
|
|
const route = useRoute() |
|
|
@ -61,6 +69,7 @@ const format3 = (num) => { |
|
|
|
|
|
|
|
|
// 统一获取数据的方法 |
|
|
// 统一获取数据的方法 |
|
|
const getWalletData = async () => { |
|
|
const getWalletData = async () => { |
|
|
|
|
|
console.log('walletId:', selectData.value.walletId) |
|
|
if (!selectData.value.walletId) return; |
|
|
if (!selectData.value.walletId) return; |
|
|
|
|
|
|
|
|
if (selectData.value.jwcode) { |
|
|
if (selectData.value.jwcode) { |
|
|
@ -78,15 +87,10 @@ const getWalletData = async () => { |
|
|
pageSize: getObj.value.pageSize, |
|
|
pageSize: getObj.value.pageSize, |
|
|
userWalletRecord: { |
|
|
userWalletRecord: { |
|
|
walletId: selectData.value.walletId, |
|
|
walletId: selectData.value.walletId, |
|
|
jwcode: selectData.value.jwcode ? Number(selectData.value.jwcode) : null |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const result = await API({ |
|
|
|
|
|
url: '/cashCollection/selectWalletRecords', |
|
|
|
|
|
method: 'post', |
|
|
|
|
|
data: params |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const result = await selectWalletRecords(params) |
|
|
|
|
|
|
|
|
if (result.code === 200) { |
|
|
if (result.code === 200) { |
|
|
tableData.value = result.data.list.map(item => ({ |
|
|
tableData.value = result.data.list.map(item => ({ |
|
|
@ -144,9 +148,9 @@ watch(flag, (newFlag, oldFlag) => { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// 核心:监听路由参数变化 |
|
|
|
|
|
|
|
|
// 核心:监听父组件传入的 props 参数变化 |
|
|
watch( |
|
|
watch( |
|
|
() => route.query.type, |
|
|
|
|
|
|
|
|
() => props.type, |
|
|
(newType) => { |
|
|
(newType) => { |
|
|
if (newType) { |
|
|
if (newType) { |
|
|
selectData.value.walletId = newType |
|
|
selectData.value.walletId = newType |
|
|
@ -156,6 +160,110 @@ watch( |
|
|
}, |
|
|
}, |
|
|
{ immediate: true } |
|
|
{ immediate: true } |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 导出逻辑 ==================== |
|
|
|
|
|
const exportListVisible = ref(false) |
|
|
|
|
|
const exportList = ref([]) |
|
|
|
|
|
const exportListLoading = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const exportExcelOnlyOne = async function () { |
|
|
|
|
|
if (!selectData.value.walletId) { |
|
|
|
|
|
ElMessage.error(t('elmessage.selectCompanyWallet')) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const params = { |
|
|
|
|
|
pageNum: 1, // 导出通常从第一页开始 |
|
|
|
|
|
pageSize: 10000, // 导出大量数据 |
|
|
|
|
|
userWalletRecord: { |
|
|
|
|
|
walletId: selectData.value.walletId, |
|
|
|
|
|
jwcode: selectData.value.jwcode ? Number(selectData.value.jwcode) : null |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const res = await API({ |
|
|
|
|
|
url: '/export/exportUserWalletRecord', |
|
|
|
|
|
method: 'post', |
|
|
|
|
|
data: params |
|
|
|
|
|
}) |
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
ElMessage.success(t('elmessage.exportSuccess')) |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage.error(res.msg || t('elmessage.exportFailed')) |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('导出失败:', error) |
|
|
|
|
|
ElMessage.error(t('elmessage.exportFailed')) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 打开导出列表弹窗 |
|
|
|
|
|
const openExportList = () => { |
|
|
|
|
|
getExportList() |
|
|
|
|
|
exportListVisible.value = true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取导出列表 |
|
|
|
|
|
const getExportList = async () => { |
|
|
|
|
|
exportListLoading.value = true |
|
|
|
|
|
try { |
|
|
|
|
|
const result = await API({ url: '/export/export' }) |
|
|
|
|
|
if (result.code === 200) { |
|
|
|
|
|
// 过滤只显示 type 为 16 和 17 的导出记录(保持和 WalletBalance 页面一致) |
|
|
|
|
|
const filteredData = result.data.filter(item => { |
|
|
|
|
|
return item.type === 16 || item.type === 17; |
|
|
|
|
|
}); |
|
|
|
|
|
exportList.value = filteredData |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage.error(result.msg || t('elmessage.getExportListError')) |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('获取导出列表出错:', error) |
|
|
|
|
|
ElMessage.error(t('elmessage.getExportListError')) |
|
|
|
|
|
} finally { |
|
|
|
|
|
exportListLoading.value = false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 下载导出文件 |
|
|
|
|
|
const downloadExportFile = (item) => { |
|
|
|
|
|
if (item.state === 2) { |
|
|
|
|
|
const link = document.createElement('a') |
|
|
|
|
|
link.href = item.url |
|
|
|
|
|
link.download = item.fileName |
|
|
|
|
|
link.click() |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage.warning(t('elmessage.exportingInProgress')) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据状态返回对应的标签类型 |
|
|
|
|
|
const getTagType = (state) => { |
|
|
|
|
|
switch (state) { |
|
|
|
|
|
case 0: return 'info'; |
|
|
|
|
|
case 1: return 'primary'; |
|
|
|
|
|
case 2: return 'success'; |
|
|
|
|
|
case 3: return 'danger'; |
|
|
|
|
|
default: return 'info'; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据状态返回对应的标签文案 |
|
|
|
|
|
const getTagText = (state) => { |
|
|
|
|
|
switch (state) { |
|
|
|
|
|
case 0: return t('elmessage.pendingExecution'); |
|
|
|
|
|
case 1: return t('elmessage.executing'); |
|
|
|
|
|
case 2: return t('elmessage.executed'); |
|
|
|
|
|
case 3: return t('elmessage.errorExecution'); |
|
|
|
|
|
default: return t('elmessage.unknownStatus'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
|
selectData.value.walletId = props.type |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<template> |
|
|
<template> |
|
|
@ -164,11 +272,13 @@ watch( |
|
|
<div class="head-card"> |
|
|
<div class="head-card"> |
|
|
<div class="head-card-element"> |
|
|
<div class="head-card-element"> |
|
|
<el-text class="mx-1" size="large">{{ $t('common_list.jwcode') }}:</el-text> |
|
|
<el-text class="mx-1" size="large">{{ $t('common_list.jwcode') }}:</el-text> |
|
|
<el-input v-model="selectData.jwcode" style="width: 240px" :placeholder="$t('common_list.jwcodePlaceholder')" clearable /> |
|
|
|
|
|
|
|
|
<el-input v-model="selectData.jwcode" style="width: 240px" placeholder="请输入精网号" clearable /> |
|
|
</div> |
|
|
</div> |
|
|
<div class="head-card-btn"> |
|
|
<div class="head-card-btn"> |
|
|
<el-button type="default" @click="reset">{{ $t('common.reset') }}</el-button> |
|
|
|
|
|
|
|
|
<el-button type="success" @click="reset">{{ $t('common.reset') }}</el-button> |
|
|
<el-button type="primary" @click="search">{{ $t('common.search') }}</el-button> |
|
|
<el-button type="primary" @click="search">{{ $t('common.search') }}</el-button> |
|
|
|
|
|
<el-button type="primary" @click="exportExcelOnlyOne">{{ $t('common.exportExcel') }}</el-button> |
|
|
|
|
|
<el-button type="primary" @click="openExportList">{{ $t('common.viewExportList') }}</el-button> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</el-card> |
|
|
</el-card> |
|
|
@ -213,6 +323,38 @@ watch( |
|
|
@current-change="handleCurrentChange"></el-pagination> |
|
|
@current-change="handleCurrentChange"></el-pagination> |
|
|
</div> |
|
|
</div> |
|
|
</el-card> |
|
|
</el-card> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 导出列表弹窗 --> |
|
|
|
|
|
<el-dialog v-model="exportListVisible" :title="$t('common_export.exportList')" width="80%"> |
|
|
|
|
|
<el-table :data="exportList" style="width: 100% ;height: 60vh;" :loading="exportListLoading"> |
|
|
|
|
|
<el-table-column prop="fileName" :label="$t('common_export.fileName')" /> |
|
|
|
|
|
<el-table-column prop="state" :label="$t('common_export.status')"> |
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
|
<el-tag :type="getTagType(scope.row.state)" :effect="scope.row.state === 3 ? 'light' : 'plain'"> |
|
|
|
|
|
{{ getTagText(scope.row.state) }} |
|
|
|
|
|
</el-tag> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column prop="createTime" :label="$t('common_export.createTime')"> |
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
|
{{ moment(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }} |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column :label="$t('common_export.operation')"> |
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
|
<el-button type="primary" size="small" @click="downloadExportFile(scope.row)" |
|
|
|
|
|
:disabled="scope.row.state !== 2"> |
|
|
|
|
|
{{ $t('common_export.download') }} |
|
|
|
|
|
</el-button> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
</el-table> |
|
|
|
|
|
<template #footer> |
|
|
|
|
|
<div class="dialog-footer"> |
|
|
|
|
|
<el-button text @click="exportListVisible = false">{{ $t('common_export.close') }}</el-button> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-dialog> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
|