This commit is contained in:
Mrx
2026-05-27 12:11:25 +08:00
parent f6e7ec7ae8
commit 244459f79a
3 changed files with 48 additions and 11 deletions

View File

@@ -8,7 +8,7 @@
>
<div class="space-y-4">
<!-- 企业选择 -->
<div v-if="showCompanySelect">
<div v-if="showCompanySelect && !isSingleUserMode">
<label class="block text-sm font-medium text-gray-700 mb-2">选择企业</label>
<el-select
v-model="exportOptions.companyIds"
@@ -33,6 +33,14 @@
</el-select>
</div>
<!-- 单用户模式提示 -->
<div v-if="isSingleUserMode" class="bg-blue-50 border border-blue-200 rounded-lg p-3">
<div class="flex items-center gap-2">
<User class="w-4 h-4 text-blue-600 flex-shrink-0" />
<span class="text-sm text-blue-800">当前为单用户模式将只导出该用户的数据</span>
</div>
</div>
<!-- 产品选择 -->
<div v-if="showProductSelect">
<label class="block text-sm font-medium text-gray-700 mb-2">选择产品</label>
@@ -136,9 +144,10 @@
</template>
<script setup>
import { productApi, userApi } from '@/api'
import { productAdminApi, userApi } from '@/api'
import { useMobileTable } from '@/composables/useMobileTable'
import { reactive, ref, watch } from 'vue'
import { User } from '@element-plus/icons-vue'
// 移动端检测
const { isMobile } = useMobileTable()
@@ -177,6 +186,15 @@ const props = defineProps({
showDateRange: {
type: Boolean,
default: true
},
// 单用户模式相关
isSingleUserMode: {
type: Boolean,
default: false
},
currentUserId: {
type: String,
default: ''
}
})
@@ -250,7 +268,8 @@ const loadProductOptions = async () => {
try {
productLoading.value = true
const response = await productApi.getProducts({
// 使用管理员产品API
const response = await productAdminApi.getProducts({
page: 1,
page_size: 1000,
name: productSearchKeyword.value

View File

@@ -329,11 +329,12 @@
v-model="exportDialogVisible"
title="导出钱包交易记录"
:loading="exportLoading"
:show-company-select="true"
:show-company-select="!singleUserMode"
:show-product-select="true"
:show-recharge-type-select="false"
:show-status-select="false"
:show-date-range="true"
:is-single-user-mode="singleUserMode"
@confirm="handleExport"
/>
</template>
@@ -543,7 +544,12 @@ const handleViewDetail = (transaction) => {
// 导出相关方法
const showExportDialog = () => {
exportDialogVisible.value = true
// 如果是单用户模式,默认选中当前用户
if (singleUserMode.value && currentUser.value?.id) {
exportDialogVisible.value = true
} else {
exportDialogVisible.value = true
}
}
const handleExport = async (options) => {
@@ -555,8 +561,11 @@ const handleExport = async (options) => {
format: options.format
}
// 添加企业筛选
if (options.companyIds.length > 0) {
// 单用户模式自动添加当前用户ID筛选
if (singleUserMode.value && currentUser.value?.id) {
params.user_ids = currentUser.value.id
} else if (options.companyIds.length > 0) {
// 多用户模式:使用用户选择的企业筛选
params.user_ids = options.companyIds.join(',')
}

View File

@@ -337,11 +337,12 @@
v-model="exportDialogVisible"
title="导出API调用记录"
:loading="exportLoading"
:show-company-select="true"
:show-company-select="!singleUserMode"
:show-product-select="true"
:show-recharge-type-select="false"
:show-status-select="false"
:show-date-range="true"
:is-single-user-mode="singleUserMode"
@confirm="handleExport"
/>
</template>
@@ -589,7 +590,12 @@ watch(() => route.query.user_id, async (newUserId) => {
// 导出相关方法
const showExportDialog = () => {
exportDialogVisible.value = true
// 如果是单用户模式,默认选中当前用户
if (singleUserMode.value && currentUser.value?.id) {
exportDialogVisible.value = true
} else {
exportDialogVisible.value = true
}
}
const handleExport = async (options) => {
@@ -601,8 +607,11 @@ const handleExport = async (options) => {
format: options.format
}
// 添加企业筛选
if (options.companyIds.length > 0) {
// 单用户模式自动添加当前用户ID筛选
if (singleUserMode.value && currentUser.value?.id) {
params.user_ids = currentUser.value.id
} else if (options.companyIds.length > 0) {
// 多用户模式:使用用户选择的企业筛选
params.user_ids = options.companyIds.join(',')
}