f
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
|
||||
<div v-else-if="subscriptions.length === 0" class="text-center py-12">
|
||||
<el-empty description="暂无订阅数据">
|
||||
<el-button type="primary" @click="$router.push('/products')">
|
||||
<el-button v-if="!isSubordinate" type="primary" @click="$router.push('/products')">
|
||||
去数据大厅订阅产品
|
||||
</el-button>
|
||||
</el-empty>
|
||||
@@ -122,6 +122,7 @@
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
v-if="!isSubordinate"
|
||||
prop="price"
|
||||
label="订阅价格"
|
||||
:width="isMobile ? 100 : 120"
|
||||
@@ -131,6 +132,16 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
v-if="isSubordinate"
|
||||
label="剩余额度"
|
||||
:width="isMobile ? 110 : 130"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold text-blue-600">{{ getRemainingQuota(row) }} 次</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<!-- <el-table-column prop="api_used" label="API调用次数" width="140">
|
||||
<template #default="{ row }">
|
||||
<span class="font-medium">{{ row.api_used || 0 }}</span>
|
||||
@@ -258,7 +269,7 @@
|
||||
<div class="usage-stat-value">{{ usageData?.api_used || 0 }}</div>
|
||||
<div class="usage-stat-label">API调用次数</div>
|
||||
</div>
|
||||
<div class="usage-stat-card">
|
||||
<div v-if="!isSubordinate" class="usage-stat-card">
|
||||
<div class="usage-stat-value">¥{{ formatPrice(selectedSubscription.price) }}</div>
|
||||
<div class="usage-stat-label">订阅价格</div>
|
||||
</div>
|
||||
@@ -281,16 +292,19 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { subscriptionApi } from '@/api'
|
||||
import { subordinateApi, subscriptionApi } from '@/api'
|
||||
import FilterItem from '@/components/common/FilterItem.vue'
|
||||
import FilterSection from '@/components/common/FilterSection.vue'
|
||||
import ListPageLayout from '@/components/common/ListPageLayout.vue'
|
||||
import { useMobileTable } from '@/composables/useMobileTable'
|
||||
import { ArrowDown } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const router = useRouter()
|
||||
const { isMobile } = useMobileTable()
|
||||
const userStore = useUserStore()
|
||||
const isSubordinate = computed(() => userStore.accountKind === 'subordinate')
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false)
|
||||
@@ -302,6 +316,7 @@ const usageDialogVisible = ref(false)
|
||||
const selectedSubscription = ref(null)
|
||||
const usageData = ref(null)
|
||||
const loadingUsage = ref(false)
|
||||
const myQuotaMap = ref({})
|
||||
|
||||
// 统计数据
|
||||
const stats = ref({
|
||||
@@ -344,6 +359,9 @@ const loadSubscriptions = async () => {
|
||||
const response = await subscriptionApi.getMySubscriptions(params)
|
||||
subscriptions.value = response.data?.items || []
|
||||
total.value = response.data?.total || 0
|
||||
if (isSubordinate.value) {
|
||||
await loadMyQuotas()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载订阅失败:', error)
|
||||
ElMessage.error('加载订阅失败')
|
||||
@@ -352,6 +370,30 @@ const loadSubscriptions = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载我的额度账户(子账号按次数扣减时展示剩余额度)
|
||||
const loadMyQuotas = async () => {
|
||||
try {
|
||||
const res = await subordinateApi.listMyQuotas()
|
||||
const items = res?.data || []
|
||||
const map = {}
|
||||
items.forEach((item) => {
|
||||
map[item.product_id] = item.available_quota
|
||||
})
|
||||
myQuotaMap.value = map
|
||||
} catch (error) {
|
||||
console.error('加载我的额度账户失败:', error)
|
||||
myQuotaMap.value = {}
|
||||
}
|
||||
}
|
||||
|
||||
const getRemainingQuota = (row) => {
|
||||
const productID = row?.product_id || row?.product?.id
|
||||
if (!productID) return '-'
|
||||
const value = myQuotaMap.value[productID]
|
||||
if (value === undefined || value === null) return '0'
|
||||
return String(value)
|
||||
}
|
||||
|
||||
// 加载统计数据
|
||||
const loadStats = async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user