购买功能fix组件样式
This commit is contained in:
2
auto-imports.d.ts
vendored
2
auto-imports.d.ts
vendored
@@ -7,7 +7,7 @@
|
||||
export {}
|
||||
declare global {
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const ElLoading: typeof import('element-plus')['ElLoading']
|
||||
const ElLoading: typeof import('element-plus/es')['ElLoading']
|
||||
const ElMessage: typeof import('element-plus/es')['ElMessage']
|
||||
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
|
||||
const ElNotification: typeof import('element-plus')['ElNotification']
|
||||
|
||||
@@ -63,7 +63,19 @@ export const productApi = {
|
||||
// 下载接口文档(支持PDF和Markdown)
|
||||
downloadProductDocumentation: (productId) => request.get(`/products/${productId}/documentation/download`, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
}),
|
||||
|
||||
// 组件报告下载相关API
|
||||
// 检查产品是否可以下载示例报告
|
||||
checkComponentReportAvailability: (productId) => request.get(`/products/${productId}/component-report/check`),
|
||||
// 获取产品示例报告下载信息和价格计算
|
||||
getComponentReportInfo: (productId) => request.get(`/products/${productId}/component-report/info`),
|
||||
// 创建示例报告下载支付订单
|
||||
createComponentReportPaymentOrder: (productId, data) => request.post(`/products/${productId}/component-report/create-order`, data),
|
||||
// 检查示例报告下载支付状态
|
||||
checkComponentReportPaymentStatus: (orderId) => request.get(`/component-report/check-payment/${orderId}`),
|
||||
// 生成并下载示例报告ZIP文件
|
||||
generateAndDownloadComponentReport: (data) => request.post('/component-report/generate-and-download', data, { responseType: 'blob' })
|
||||
}
|
||||
|
||||
// 分类相关接口 - 数据大厅
|
||||
@@ -130,7 +142,15 @@ export const financeApi = {
|
||||
|
||||
// 充值记录相关接口
|
||||
getUserRechargeRecords: (params) => request.get('/finance/wallet/recharge-records', { params }),
|
||||
getAdminRechargeRecords: (params) => request.get('/admin/finance/recharge-records', { params })
|
||||
getAdminRechargeRecords: (params) => request.get('/admin/finance/recharge-records', { params }),
|
||||
|
||||
// 购买记录相关接口
|
||||
getUserPurchaseRecords: (params) => request.get('/finance/purchase-records', { params }),
|
||||
getAdminPurchaseRecords: (params) => request.get('/admin/finance/purchase-records', { params }),
|
||||
exportAdminPurchaseRecords: (params) => request.get('/admin/finance/purchase-records/export', {
|
||||
params,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
// 认证相关接口
|
||||
|
||||
@@ -114,6 +114,45 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<!-- UI组件配置 - 仅组合包显示 -->
|
||||
<div v-if="form.is_package" class="space-y-4">
|
||||
<h3 class="text-lg font-semibold text-gray-900 mb-4">UI组件配置</h3>
|
||||
<el-alert
|
||||
title="UI组件说明"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-4"
|
||||
>
|
||||
<template #default>
|
||||
<p>配置此组合包的UI组件销售选项,用户可以单独购买此组合包的UI组件示例。</p>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-form-item label="是否出售UI组件" prop="sell_ui_component">
|
||||
<el-switch
|
||||
v-model="form.sell_ui_component"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="form.sell_ui_component"
|
||||
label="UI组件销售价格"
|
||||
prop="ui_component_price"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="form.ui_component_price"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
:step="0.01"
|
||||
placeholder="请输入UI组件销售价格"
|
||||
class="w-full"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 组合包配置 -->
|
||||
@@ -375,6 +414,9 @@ const form = reactive({
|
||||
is_enabled: true,
|
||||
is_visible: true,
|
||||
is_package: false,
|
||||
// UI组件相关字段
|
||||
sell_ui_component: false,
|
||||
ui_component_price: 0,
|
||||
seo_title: '',
|
||||
seo_description: '',
|
||||
seo_keywords: ''
|
||||
@@ -399,6 +441,22 @@ const rules = {
|
||||
cost_price: [
|
||||
{ type: 'number', min: 0, message: '成本价不能小于0', trigger: 'blur' }
|
||||
],
|
||||
ui_component_price: [
|
||||
{
|
||||
type: 'number',
|
||||
min: 0,
|
||||
message: 'UI组件价格不能小于0',
|
||||
trigger: 'blur',
|
||||
validator: (rule, value, callback) => {
|
||||
// 如果是组合包且出售UI组件,则价格必须大于0
|
||||
if (form.is_package && form.sell_ui_component && (!value || value < 0)) {
|
||||
callback(new Error('出售UI组件时,价格不能小于0'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
remark: [
|
||||
{ max: 1000, message: '备注长度不能超过1000个字符', trigger: 'blur' }
|
||||
],
|
||||
@@ -468,6 +526,15 @@ const handleEditMode = async () => {
|
||||
}
|
||||
})
|
||||
|
||||
// 确保UI组件相关字段正确加载
|
||||
// 如果后端返回的字段名不同,这里可以添加映射
|
||||
if (props.product.sell_ui_component !== undefined) {
|
||||
form.sell_ui_component = props.product.sell_ui_component
|
||||
}
|
||||
if (props.product.ui_component_price !== undefined) {
|
||||
form.ui_component_price = props.product.ui_component_price
|
||||
}
|
||||
|
||||
// 如果是组合包,处理子产品数据
|
||||
if (props.product.is_package) {
|
||||
await handlePackageData()
|
||||
@@ -502,8 +569,10 @@ const handleCreateMode = () => {
|
||||
// 保持默认值 true,但允许用户在界面上切换
|
||||
// 注意:这里不强制设置,让用户可以在界面上自由切换
|
||||
// 默认值已经在 form 初始化时设置为 true(第375-376行)
|
||||
} else if (key === 'price' || key === 'cost_price') {
|
||||
} else if (key === 'price' || key === 'cost_price' || key === 'ui_component_price') {
|
||||
form[key] = 0
|
||||
} else if (key === 'sell_ui_component') {
|
||||
form[key] = false
|
||||
} else {
|
||||
form[key] = ''
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ export const userMenuItems = [
|
||||
children: [
|
||||
{ name: '余额充值', path: '/finance/wallet', icon: CreditCard, requiresCertification: true },
|
||||
{ name: '充值记录', path: '/finance/recharge-records', icon: CreditCard, requiresCertification: true },
|
||||
{ name: '购买记录', path: '/finance/purchase-records', icon: ShoppingCart, requiresCertification: true },
|
||||
{ name: '消费记录', path: '/finance/transactions', icon: Clipboard, requiresCertification: true },
|
||||
{ name: '发票申请', path: '/finance/invoice', icon: Wallet, requiresCertification: true }
|
||||
]
|
||||
@@ -124,6 +125,7 @@ export const getUserAccessibleMenuItems = (userType = 'user') => {
|
||||
{ name: '调用记录', path: '/admin/usage', icon: Clipboard },
|
||||
{ name: '消费记录', path: '/admin/transactions', icon: Clipboard },
|
||||
{ name: '充值记录', path: '/admin/recharge-records', icon: CreditCard },
|
||||
{ name: '购买记录', path: '/admin/purchase-records', icon: ShoppingCart },
|
||||
{ name: '发票管理', path: '/admin/invoices', icon: Wallet },
|
||||
{ name: '组件管理', path: '/admin/ui-components', icon: Cube }
|
||||
]
|
||||
@@ -137,6 +139,7 @@ export const getUserAccessibleMenuItems = (userType = 'user') => {
|
||||
export const requiresCertificationPaths = [
|
||||
'/finance/wallet',
|
||||
'/finance/recharge-records',
|
||||
'/finance/purchase-records',
|
||||
'/finance/transactions',
|
||||
'/apis/usage',
|
||||
'/apis/whitelist'
|
||||
@@ -166,6 +169,10 @@ export const getCurrentPageCertificationConfig = (path) => {
|
||||
title: '充值记录',
|
||||
description: '为了查看完整的充值记录,请先完成企业入驻认证。认证成功后我们将赠送您一定的调用额度!'
|
||||
},
|
||||
'/finance/purchase-records': {
|
||||
title: '购买记录',
|
||||
description: '为了查看完整的购买记录,请先完成企业入驻认证。认证成功后我们将赠送您一定的调用额度!'
|
||||
},
|
||||
'/finance/transactions': {
|
||||
title: '消费记录',
|
||||
description: '为了查看完整的消费记录,请先完成企业入驻认证。认证成功后我们将赠送您一定的调用额度!'
|
||||
|
||||
857
src/pages/admin/purchase-records/index.vue
Normal file
857
src/pages/admin/purchase-records/index.vue
Normal file
@@ -0,0 +1,857 @@
|
||||
<template>
|
||||
<ListPageLayout title="购买记录管理" subtitle="管理系统内所有用户的购买记录">
|
||||
<!-- 单用户模式显示 -->
|
||||
<template #stats v-if="singleUserMode">
|
||||
<div class="flex items-center gap-2 text-sm text-gray-600">
|
||||
<User class="w-4 h-4" />
|
||||
<span>当前用户:{{ currentUser?.company_name || currentUser?.phone }}</span>
|
||||
<span class="text-gray-400">(仅显示当前用户)</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 单用户模式操作按钮 -->
|
||||
<template #actions v-if="singleUserMode">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex items-center gap-2 text-sm text-gray-600">
|
||||
<User class="w-4 h-4" />
|
||||
<span>{{ currentUser?.enterprise_info?.company_name || currentUser?.phone }}</span>
|
||||
</div>
|
||||
<el-button size="small" @click="exitSingleUserMode">
|
||||
<Close class="w-4 h-4 mr-1" />
|
||||
取消
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" @click="goBackToUsers">
|
||||
<Back class="w-4 h-4 mr-1" />
|
||||
返回用户管理
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 筛选区域 -->
|
||||
<template #filters>
|
||||
<FilterSection>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
||||
<FilterItem label="企业名称" v-if="!singleUserMode">
|
||||
<el-input
|
||||
v-model="filters.company_name"
|
||||
placeholder="输入企业名称"
|
||||
clearable
|
||||
@input="handleFilterChange"
|
||||
class="w-full"
|
||||
/>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="支付类型">
|
||||
<el-select
|
||||
v-model="filters.payment_type"
|
||||
placeholder="选择支付类型"
|
||||
clearable
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
>
|
||||
<el-option label="支付宝" value="alipay" />
|
||||
<el-option label="微信" value="wechat" />
|
||||
<el-option label="免费" value="free" />
|
||||
</el-select>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="支付渠道">
|
||||
<el-select
|
||||
v-model="filters.pay_channel"
|
||||
placeholder="选择支付渠道"
|
||||
clearable
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
>
|
||||
<el-option label="支付宝" value="alipay" />
|
||||
<el-option label="微信" value="wechat" />
|
||||
</el-select>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="订单状态">
|
||||
<el-select
|
||||
v-model="filters.status"
|
||||
placeholder="选择订单状态"
|
||||
clearable
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
>
|
||||
<el-option label="已创建" value="created" />
|
||||
<el-option label="已支付" value="paid" />
|
||||
<el-option label="支付失败" value="failed" />
|
||||
<el-option label="已取消" value="cancelled" />
|
||||
<el-option label="已退款" value="refunded" />
|
||||
<el-option label="已关闭" value="closed" />
|
||||
</el-select>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="产品名称" v-if="!singleUserMode">
|
||||
<el-input
|
||||
v-model="filters.product_name"
|
||||
placeholder="输入产品名称"
|
||||
clearable
|
||||
@input="handleFilterChange"
|
||||
class="w-full"
|
||||
/>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="购买时间" class="col-span-1 md:col-span-2">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
@change="handleTimeRangeChange"
|
||||
class="w-full"
|
||||
:size="isMobile ? 'small' : 'default'"
|
||||
/>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="金额范围">
|
||||
<div class="flex gap-2">
|
||||
<el-input
|
||||
v-model="filters.min_amount"
|
||||
placeholder="最小金额"
|
||||
clearable
|
||||
@input="handleFilterChange"
|
||||
class="flex-1"
|
||||
/>
|
||||
<span class="text-gray-400 self-center">-</span>
|
||||
<el-input
|
||||
v-model="filters.max_amount"
|
||||
placeholder="最大金额"
|
||||
clearable
|
||||
@input="handleFilterChange"
|
||||
class="flex-1"
|
||||
/>
|
||||
</div>
|
||||
</FilterItem>
|
||||
</div>
|
||||
|
||||
<template #stats> 共找到 {{ total }} 条购买记录 </template>
|
||||
|
||||
<template #buttons>
|
||||
<el-button @click="resetFilters">重置筛选</el-button>
|
||||
<el-button type="primary" @click="loadPurchaseRecords">应用筛选</el-button>
|
||||
<el-button type="success" @click="showExportDialog">
|
||||
<Download class="w-4 h-4 mr-1" />
|
||||
导出数据
|
||||
</el-button>
|
||||
</template>
|
||||
</FilterSection>
|
||||
</template>
|
||||
|
||||
<!-- 表格区域 -->
|
||||
<template #table>
|
||||
<div v-if="loading" class="flex justify-center items-center py-12">
|
||||
<el-loading size="large" />
|
||||
</div>
|
||||
|
||||
<div v-else class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
||||
<el-table
|
||||
:data="purchaseRecords"
|
||||
style="width: 100%"
|
||||
:header-cell-style="{
|
||||
background: '#f8fafc',
|
||||
color: '#475569',
|
||||
fontWeight: '600',
|
||||
fontSize: '14px',
|
||||
}"
|
||||
:cell-style="{
|
||||
fontSize: '14px',
|
||||
color: '#1e293b',
|
||||
}"
|
||||
>
|
||||
<el-table-column prop="order_no" label="订单号" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="text-sm">
|
||||
<div class="text-gray-500">商户订单:</div>
|
||||
<div class="font-mono">{{ row.order_no }}</div>
|
||||
<div v-if="row.trade_no" class="text-gray-500 mt-1">交易号:</div>
|
||||
<div v-if="row.trade_no" class="font-mono">{{ row.trade_no }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="company_name"
|
||||
label="企业名称"
|
||||
min-width="150"
|
||||
v-if="!singleUserMode"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div>
|
||||
<div class="font-medium text-blue-600">{{ row.company_name || '未知企业' }}</div>
|
||||
<div class="text-xs text-gray-500">{{ row.user?.phone }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="product_name" label="产品信息" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div class="space-y-1">
|
||||
<div class="text-sm font-medium">{{ row.product_name }}</div>
|
||||
<div class="text-xs text-gray-500">{{ row.product_code }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="amount" label="订单金额" width="120">
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold text-green-600">¥{{ formatPrice(row.amount) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="payment_type" label="支付类型" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPaymentTypeTagType(row.payment_type)" size="small" effect="light">
|
||||
{{ getPaymentTypeText(row.payment_type) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="pay_channel" label="支付渠道" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPayChannelTagType(row.pay_channel)" size="small" effect="light">
|
||||
{{ getPayChannelText(row.pay_channel) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="status" label="订单状态" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getStatusTagType(row.status)" size="small" effect="light">
|
||||
{{ getStatusText(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="pay_time" label="支付时间" width="160">
|
||||
<template #default="{ row }">
|
||||
<div class="text-sm">
|
||||
<div v-if="row.pay_time" class="text-gray-900">{{ formatDate(row.pay_time) }}</div>
|
||||
<div v-if="row.pay_time" class="text-gray-500">{{ formatTime(row.pay_time) }}</div>
|
||||
<div v-else class="text-gray-400">-</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="flex items-center space-x-2">
|
||||
<el-button size="small" type="primary" @click="handleViewDetail(row)">
|
||||
查看详情
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 分页 -->
|
||||
<template #pagination>
|
||||
<el-pagination
|
||||
v-if="total > 0"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</template>
|
||||
<template #extra>
|
||||
<!-- 购买记录详情弹窗 -->
|
||||
<el-dialog
|
||||
v-model="detailDialogVisible"
|
||||
title="购买记录详情"
|
||||
width="800px"
|
||||
class="purchase-detail-dialog"
|
||||
>
|
||||
<div v-if="selectedPurchaseRecord" class="space-y-6">
|
||||
<!-- 基本信息 -->
|
||||
<div class="info-section">
|
||||
<h4 class="text-lg font-semibold text-gray-900 mb-4">基本信息</h4>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="info-item">
|
||||
<span class="info-label">订单号</span>
|
||||
<span class="info-value font-mono">{{ selectedPurchaseRecord?.order_no || '-' }}</span>
|
||||
</div>
|
||||
<div class="info-item" v-if="selectedPurchaseRecord?.trade_no">
|
||||
<span class="info-label">交易号</span>
|
||||
<span class="info-value font-mono">{{ selectedPurchaseRecord?.trade_no || '-' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">产品名称</span>
|
||||
<span class="info-value">{{ selectedPurchaseRecord?.product_name || '-' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">产品代码</span>
|
||||
<span class="info-value">{{ selectedPurchaseRecord?.product_code || '-' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">订单金额</span>
|
||||
<span class="info-value text-green-600 font-semibold"
|
||||
>¥{{ formatPrice(selectedPurchaseRecord?.amount) }}</span
|
||||
>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">支付类型</span>
|
||||
<span class="info-value">
|
||||
<el-tag
|
||||
:type="getPaymentTypeTagType(selectedPurchaseRecord?.payment_type)"
|
||||
size="small"
|
||||
>
|
||||
{{ getPaymentTypeText(selectedPurchaseRecord?.payment_type) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">支付渠道</span>
|
||||
<span class="info-value">
|
||||
<el-tag
|
||||
:type="getPayChannelTagType(selectedPurchaseRecord?.pay_channel)"
|
||||
size="small"
|
||||
>
|
||||
{{ getPayChannelText(selectedPurchaseRecord?.pay_channel) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">订单状态</span>
|
||||
<span class="info-value">
|
||||
<el-tag :type="getStatusTagType(selectedPurchaseRecord?.status)" size="small">
|
||||
{{ getStatusText(selectedPurchaseRecord?.status) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-item" v-if="!singleUserMode">
|
||||
<span class="info-label">企业名称</span>
|
||||
<span class="info-value">{{
|
||||
selectedPurchaseRecord?.company_name || '未知企业'
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 时间信息 -->
|
||||
<div class="info-section">
|
||||
<h4 class="text-lg font-semibold text-gray-900 mb-4">时间信息</h4>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="info-item">
|
||||
<span class="info-label">创建时间</span>
|
||||
<span class="info-value">{{
|
||||
formatDateTime(selectedPurchaseRecord?.created_at)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">支付时间</span>
|
||||
<span class="info-value">{{
|
||||
formatDateTime(selectedPurchaseRecord?.pay_time)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">更新时间</span>
|
||||
<span class="info-value">{{
|
||||
formatDateTime(selectedPurchaseRecord?.updated_at)
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="flex justify-center items-center py-8">
|
||||
<el-loading size="large" />
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
</ListPageLayout>
|
||||
|
||||
<!-- 导出弹窗 -->
|
||||
<ExportDialog
|
||||
v-model="exportDialogVisible"
|
||||
title="导出购买记录"
|
||||
:loading="exportLoading"
|
||||
:show-company-select="true"
|
||||
:show-product-select="true"
|
||||
:show-payment-type-select="true"
|
||||
:show-pay-channel-select="true"
|
||||
:show-status-select="true"
|
||||
:show-date-range="true"
|
||||
@confirm="handleExport"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { financeApi, userApi } from '@/api'
|
||||
import ExportDialog from '@/components/common/ExportDialog.vue'
|
||||
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 { Back, Close, Download, User } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
// 移动端检测
|
||||
const { isMobile } = useMobileTable()
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false)
|
||||
const purchaseRecords = ref([])
|
||||
const total = ref(0)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const detailDialogVisible = ref(false)
|
||||
const selectedPurchaseRecord = ref(null)
|
||||
const dateRange = ref([])
|
||||
|
||||
// 单用户模式
|
||||
const singleUserMode = ref(false)
|
||||
const currentUser = ref(null)
|
||||
|
||||
// 导出相关
|
||||
const exportDialogVisible = ref(false)
|
||||
const exportLoading = ref(false)
|
||||
|
||||
// 筛选条件
|
||||
const filters = reactive({
|
||||
company_name: '',
|
||||
product_name: '',
|
||||
payment_type: '',
|
||||
pay_channel: '',
|
||||
status: '',
|
||||
min_amount: '',
|
||||
max_amount: '',
|
||||
start_time: '',
|
||||
end_time: '',
|
||||
})
|
||||
|
||||
// 初始化
|
||||
onMounted(async () => {
|
||||
await checkSingleUserMode()
|
||||
await loadPurchaseRecords()
|
||||
})
|
||||
|
||||
// 检查单用户模式
|
||||
const checkSingleUserMode = async () => {
|
||||
const userId = route.query.user_id
|
||||
if (userId) {
|
||||
singleUserMode.value = true
|
||||
await loadUserInfo(userId)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载用户信息
|
||||
const loadUserInfo = async (userId) => {
|
||||
try {
|
||||
const response = await userApi.getUserDetail(userId)
|
||||
currentUser.value = response.data
|
||||
} catch (error) {
|
||||
console.error('加载用户信息失败:', error)
|
||||
ElMessage.error('加载用户信息失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 加载购买记录
|
||||
const loadPurchaseRecords = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
page: currentPage.value,
|
||||
page_size: pageSize.value,
|
||||
}
|
||||
|
||||
// 只传递非空的筛选条件
|
||||
if (filters.company_name) {
|
||||
params.company_name = filters.company_name
|
||||
}
|
||||
if (filters.product_name) {
|
||||
params.product_name = filters.product_name
|
||||
}
|
||||
if (filters.payment_type) {
|
||||
params.payment_type = filters.payment_type
|
||||
}
|
||||
if (filters.pay_channel) {
|
||||
params.pay_channel = filters.pay_channel
|
||||
}
|
||||
if (filters.status) {
|
||||
params.status = filters.status
|
||||
}
|
||||
if (filters.min_amount) {
|
||||
params.min_amount = filters.min_amount
|
||||
}
|
||||
if (filters.max_amount) {
|
||||
params.max_amount = filters.max_amount
|
||||
}
|
||||
if (filters.start_time) {
|
||||
params.start_time = filters.start_time
|
||||
}
|
||||
if (filters.end_time) {
|
||||
params.end_time = filters.end_time
|
||||
}
|
||||
|
||||
// 单用户模式添加用户ID筛选
|
||||
if (singleUserMode.value && currentUser.value?.id) {
|
||||
params.user_id = currentUser.value.id
|
||||
}
|
||||
|
||||
const response = await financeApi.getAdminPurchaseRecords(params)
|
||||
purchaseRecords.value = response.data?.items || []
|
||||
total.value = response.data?.total || 0
|
||||
} catch (error) {
|
||||
console.error('加载购买记录失败:', error)
|
||||
ElMessage.error('加载购买记录失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化价格
|
||||
const formatPrice = (price) => {
|
||||
if (!price) return '0.00'
|
||||
return Number(price).toFixed(2)
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (date) => {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
const formatTime = (date) => {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleTimeString('zh-CN', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})
|
||||
}
|
||||
|
||||
// 格式化日期时间
|
||||
const formatDateTime = (date) => {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
// 获取支付类型标签样式
|
||||
const getPaymentTypeTagType = (type) => {
|
||||
const typeMap = {
|
||||
alipay: 'primary',
|
||||
wechat: 'success',
|
||||
free: 'info'
|
||||
}
|
||||
return typeMap[type] || 'info'
|
||||
}
|
||||
|
||||
// 获取支付类型文本
|
||||
const getPaymentTypeText = (type) => {
|
||||
const typeMap = {
|
||||
alipay: '支付宝',
|
||||
wechat: '微信',
|
||||
free: '免费'
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
|
||||
// 获取支付渠道标签样式
|
||||
const getPayChannelTagType = (channel) => {
|
||||
const channelMap = {
|
||||
alipay: 'primary',
|
||||
wechat: 'success'
|
||||
}
|
||||
return channelMap[channel] || 'info'
|
||||
}
|
||||
|
||||
// 获取支付渠道文本
|
||||
const getPayChannelText = (channel) => {
|
||||
const channelMap = {
|
||||
alipay: '支付宝',
|
||||
wechat: '微信'
|
||||
}
|
||||
return channelMap[channel] || channel
|
||||
}
|
||||
|
||||
// 获取状态标签样式
|
||||
const getStatusTagType = (status) => {
|
||||
const statusMap = {
|
||||
created: 'info',
|
||||
paid: 'success',
|
||||
failed: 'danger',
|
||||
cancelled: 'warning',
|
||||
refunded: 'info',
|
||||
closed: 'info'
|
||||
}
|
||||
return statusMap[status] || 'info'
|
||||
}
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status) => {
|
||||
const statusMap = {
|
||||
created: '已创建',
|
||||
paid: '已支付',
|
||||
failed: '支付失败',
|
||||
cancelled: '已取消',
|
||||
refunded: '已退款',
|
||||
closed: '已关闭'
|
||||
}
|
||||
return statusMap[status] || status
|
||||
}
|
||||
|
||||
// 处理筛选变化
|
||||
const handleFilterChange = () => {
|
||||
currentPage.value = 1
|
||||
loadPurchaseRecords()
|
||||
}
|
||||
|
||||
// 处理时间范围变化
|
||||
const handleTimeRangeChange = (range) => {
|
||||
if (range && range.length === 2) {
|
||||
filters.start_time = range[0]
|
||||
filters.end_time = range[1]
|
||||
} else {
|
||||
filters.start_time = ''
|
||||
filters.end_time = ''
|
||||
}
|
||||
currentPage.value = 1
|
||||
loadPurchaseRecords()
|
||||
}
|
||||
|
||||
// 重置筛选
|
||||
const resetFilters = () => {
|
||||
Object.keys(filters).forEach((key) => {
|
||||
filters[key] = ''
|
||||
})
|
||||
dateRange.value = []
|
||||
currentPage.value = 1
|
||||
loadPurchaseRecords()
|
||||
}
|
||||
|
||||
// 处理分页大小变化
|
||||
const handleSizeChange = (size) => {
|
||||
pageSize.value = size
|
||||
currentPage.value = 1
|
||||
loadPurchaseRecords()
|
||||
}
|
||||
|
||||
// 处理当前页变化
|
||||
const handleCurrentChange = (page) => {
|
||||
currentPage.value = page
|
||||
loadPurchaseRecords()
|
||||
}
|
||||
|
||||
// 退出单用户模式
|
||||
const exitSingleUserMode = () => {
|
||||
singleUserMode.value = false
|
||||
currentUser.value = null
|
||||
router.replace({ name: 'AdminPurchaseRecords' })
|
||||
loadPurchaseRecords()
|
||||
}
|
||||
|
||||
// 返回用户管理
|
||||
const goBackToUsers = () => {
|
||||
const query = { user_id: currentUser.value?.id }
|
||||
|
||||
// 如果当前用户有企业名称,添加到查询参数
|
||||
if (currentUser.value?.enterprise_info?.company_name) {
|
||||
query.company_name = currentUser.value.enterprise_info.company_name
|
||||
}
|
||||
|
||||
// 如果当前用户有手机号,添加到查询参数
|
||||
if (currentUser.value?.phone) {
|
||||
query.phone = currentUser.value.phone
|
||||
}
|
||||
console.log('query', query)
|
||||
router.push({
|
||||
name: 'AdminUsers',
|
||||
query
|
||||
})
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleViewDetail = (purchaseRecord) => {
|
||||
selectedPurchaseRecord.value = purchaseRecord
|
||||
detailDialogVisible.value = true
|
||||
console.log('detailDialogVisible', detailDialogVisible.value)
|
||||
}
|
||||
|
||||
// 监听路由变化
|
||||
watch(
|
||||
() => route.query.user_id,
|
||||
async (newUserId) => {
|
||||
if (newUserId) {
|
||||
singleUserMode.value = true
|
||||
await loadUserInfo(newUserId)
|
||||
} else {
|
||||
singleUserMode.value = false
|
||||
currentUser.value = null
|
||||
}
|
||||
await loadPurchaseRecords()
|
||||
},
|
||||
)
|
||||
|
||||
// 导出相关方法
|
||||
const showExportDialog = () => {
|
||||
exportDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleExport = async (options) => {
|
||||
try {
|
||||
exportLoading.value = true
|
||||
|
||||
// 构建导出参数
|
||||
const params = {
|
||||
format: options.format
|
||||
}
|
||||
|
||||
// 添加企业筛选
|
||||
if (options.companyIds.length > 0) {
|
||||
params.user_ids = options.companyIds.join(',')
|
||||
}
|
||||
|
||||
// 添加产品筛选
|
||||
if (options.productIds.length > 0) {
|
||||
params.product_ids = options.productIds.join(',')
|
||||
}
|
||||
|
||||
// 添加支付类型筛选
|
||||
if (options.paymentType) {
|
||||
params.payment_type = options.paymentType
|
||||
}
|
||||
|
||||
// 添加支付渠道筛选
|
||||
if (options.payChannel) {
|
||||
params.pay_channel = options.payChannel
|
||||
}
|
||||
|
||||
// 添加状态筛选
|
||||
if (options.status) {
|
||||
params.status = options.status
|
||||
}
|
||||
|
||||
// 添加时间范围筛选
|
||||
if (options.dateRange && options.dateRange.length === 2) {
|
||||
params.start_time = options.dateRange[0]
|
||||
params.end_time = options.dateRange[1]
|
||||
}
|
||||
|
||||
// 调用导出API(需要在后端添加相应的API)
|
||||
const response = await financeApi.exportAdminPurchaseRecords(params)
|
||||
|
||||
// 创建下载链接
|
||||
const blob = new Blob([response], {
|
||||
type: options.format === 'excel'
|
||||
? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
: 'text/csv;charset=utf-8'
|
||||
})
|
||||
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `购买记录.${options.format === 'excel' ? 'xlsx' : 'csv'}`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
URL.revokeObjectURL(url)
|
||||
|
||||
ElMessage.success('导出成功')
|
||||
exportDialogVisible.value = false
|
||||
|
||||
} catch (error) {
|
||||
console.error('导出失败:', error)
|
||||
ElMessage.error('导出失败,请稍后重试')
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.info-section {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 0.5rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #374151;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 0.875rem;
|
||||
color: #111827;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.purchase-detail-dialog :deep(.el-dialog) {
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.purchase-detail-dialog :deep(.el-dialog__header) {
|
||||
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
||||
border-bottom: 1px solid rgba(226, 232, 240, 0.6);
|
||||
padding: 20px 24px;
|
||||
}
|
||||
|
||||
.purchase-detail-dialog :deep(.el-dialog__title) {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.purchase-detail-dialog :deep(.el-dialog__body) {
|
||||
padding: 24px;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* 表格样式优化 */
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background: #f8fafc !important;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
:deep(.el-table tr:hover > td) {
|
||||
background: #f8fafc !important;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.info-item {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
min-width: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,68 +1,256 @@
|
||||
<template>
|
||||
<div class="ui-components-page">
|
||||
<el-card class="filter-card">
|
||||
<el-form :model="filterForm" inline>
|
||||
<el-form-item label="关键词">
|
||||
<ListPageLayout
|
||||
title="UI组件管理"
|
||||
subtitle="管理系统中的UI组件和文件资源"
|
||||
>
|
||||
<!-- 筛选区域 -->
|
||||
<template #filters>
|
||||
<FilterSection>
|
||||
<div :class="['grid gap-4', isMobile ? 'grid-cols-1' : 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4']">
|
||||
<FilterItem label="关键词">
|
||||
<el-input
|
||||
v-model="filterForm.keyword"
|
||||
placeholder="请输入关键词搜索"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
@input="handleFilterChange"
|
||||
class="w-full"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="filterForm.is_active" placeholder="请选择状态" clearable>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="状态">
|
||||
<el-select
|
||||
v-model="filterForm.is_active"
|
||||
placeholder="请选择状态"
|
||||
clearable
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
>
|
||||
<el-option label="启用" :value="true" />
|
||||
<el-option label="禁用" :value="false" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
<el-button type="success" @click="handleCreate">新增UI组件</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</FilterItem>
|
||||
</div>
|
||||
|
||||
<el-card class="table-card">
|
||||
<template #stats>
|
||||
共找到 {{ pagination.total }} 个UI组件
|
||||
</template>
|
||||
|
||||
<template #buttons>
|
||||
<div :class="['flex gap-2', isMobile ? 'flex-wrap w-full' : '']">
|
||||
<el-button :size="isMobile ? 'small' : 'default'" @click="handleReset" :class="isMobile ? 'flex-1' : ''">
|
||||
重置筛选
|
||||
</el-button>
|
||||
<el-button :size="isMobile ? 'small' : 'default'" type="primary" @click="handleSearch" :class="isMobile ? 'flex-1' : ''">
|
||||
应用筛选
|
||||
</el-button>
|
||||
<el-button :size="isMobile ? 'small' : 'default'" type="success" @click="handleCreate" :class="isMobile ? 'w-full' : ''">
|
||||
<Plus class="w-4 h-4 mr-1" />
|
||||
<span :class="isMobile ? 'hidden sm:inline' : ''">新增UI组件</span>
|
||||
<span :class="isMobile ? 'sm:hidden' : 'hidden'">新增</span>
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</FilterSection>
|
||||
</template>
|
||||
|
||||
<!-- 表格区域 -->
|
||||
<template #table>
|
||||
<!-- 加载状态 -->
|
||||
<div v-if="loading" class="flex justify-center items-center py-12">
|
||||
<el-loading size="large" />
|
||||
</div>
|
||||
|
||||
<!-- 移动端卡片布局 -->
|
||||
<div v-else-if="isMobile && componentList.length > 0" class="component-cards">
|
||||
<div
|
||||
v-for="component in componentList"
|
||||
:key="component.id"
|
||||
class="component-card"
|
||||
>
|
||||
<div class="card-header">
|
||||
<div class="flex-1">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<span class="font-semibold text-base text-blue-600">{{ component.component_name || '未知组件' }}</span>
|
||||
<el-tag
|
||||
:type="component.is_active ? 'success' : 'danger'"
|
||||
size="small"
|
||||
effect="light"
|
||||
>
|
||||
{{ component.is_active ? '启用' : '禁用' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 font-mono">编码: {{ component.component_code }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-row">
|
||||
<span class="card-label">描述</span>
|
||||
<span class="card-value">{{ component.description || '-' }}</span>
|
||||
</div>
|
||||
<div class="card-row">
|
||||
<span class="card-label">版本</span>
|
||||
<span class="card-value">{{ component.version || '-' }}</span>
|
||||
</div>
|
||||
<div class="card-row">
|
||||
<span class="card-label">文件状态</span>
|
||||
<span class="card-value">
|
||||
<el-tag v-if="component.is_extracted" type="success" size="small">已解压</el-tag>
|
||||
<el-tag v-else-if="component.file_path" type="warning" size="small">已上传</el-tag>
|
||||
<el-tag v-else type="info" size="small">未上传</el-tag>
|
||||
</span>
|
||||
</div>
|
||||
<div class="card-row">
|
||||
<span class="card-label">文件大小</span>
|
||||
<span class="card-value">{{ component.file_size ? formatFileSize(component.file_size) : '-' }}</span>
|
||||
</div>
|
||||
<div class="card-row">
|
||||
<span class="card-label">排序</span>
|
||||
<span class="card-value">{{ component.sort_order || '-' }}</span>
|
||||
</div>
|
||||
<div class="card-row">
|
||||
<span class="card-label">创建时间</span>
|
||||
<span class="card-value text-sm">{{ formatDateTime(component.created_at) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="handleEdit(component)"
|
||||
class="flex-1"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!component.file_path"
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="handleUpload(component)"
|
||||
class="flex-1"
|
||||
>
|
||||
上传文件
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="component.file_path && !component.is_extracted && isZipFileFromPath(component.file_path)"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="handleUploadExtract(component)"
|
||||
class="flex-1"
|
||||
>
|
||||
上传并解压
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="component.is_extracted"
|
||||
size="small"
|
||||
type="success"
|
||||
@click="handleViewFolder(component)"
|
||||
class="flex-1"
|
||||
>
|
||||
查看文件夹
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="component.file_path"
|
||||
size="small"
|
||||
type="info"
|
||||
@click="handleDownload(component)"
|
||||
class="flex-1"
|
||||
>
|
||||
下载文件
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="component.is_extracted"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="handleDeleteFolder(component)"
|
||||
class="flex-1"
|
||||
>
|
||||
删除文件夹
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="handleDelete(component)"
|
||||
class="flex-1"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 桌面端表格布局 -->
|
||||
<div v-else-if="!isMobile" class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="table-container">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="componentList"
|
||||
stripe
|
||||
border
|
||||
style="width: 100%"
|
||||
:header-cell-style="{
|
||||
background: '#f8fafc',
|
||||
color: '#475569',
|
||||
fontWeight: '600',
|
||||
fontSize: '14px'
|
||||
}"
|
||||
:cell-style="{
|
||||
fontSize: '14px',
|
||||
color: '#1e293b'
|
||||
}"
|
||||
>
|
||||
<el-table-column prop="component_code" label="组件编码" width="150" />
|
||||
<el-table-column prop="component_name" label="组件名称" width="200" />
|
||||
<el-table-column prop="description" label="描述" show-overflow-tooltip />
|
||||
<el-table-column prop="version" label="版本" width="100" />
|
||||
<el-table-column label="文件状态" width="120">
|
||||
<el-table-column prop="component_code" label="组件编码" width="150">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.is_extracted" type="success">已解压</el-tag>
|
||||
<el-tag v-else-if="row.file_path" type="warning">已上传</el-tag>
|
||||
<el-tag v-else type="info">未上传</el-tag>
|
||||
<span class="font-mono text-sm text-gray-600">{{ row.component_code }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="component_name" label="组件名称" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div class="font-medium text-blue-600">{{ row.component_name || '未知组件' }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="description" label="描述" min-width="200" show-overflow-tooltip />
|
||||
|
||||
<el-table-column prop="version" label="版本" width="100" />
|
||||
|
||||
<el-table-column label="文件状态" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.is_extracted" type="success" size="small">已解压</el-tag>
|
||||
<el-tag v-else-if="row.file_path" type="warning" size="small">已上传</el-tag>
|
||||
<el-tag v-else type="info" size="small">未上传</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="文件大小" width="120">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.file_size">{{ formatFileSize(row.file_size) }}</span>
|
||||
<span v-else>-</span>
|
||||
<span v-else class="text-gray-400">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.is_active ? 'success' : 'danger'">
|
||||
<el-tag :type="row.is_active ? 'success' : 'danger'" size="small">
|
||||
{{ row.is_active ? '启用' : '禁用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="sort_order" label="排序" width="80" />
|
||||
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">
|
||||
{{ formatDateTime(row.created_at) }}
|
||||
<div class="text-sm">
|
||||
<div class="text-gray-900">{{ formatDate(row.created_at) }}</div>
|
||||
<div class="text-gray-500">{{ formatTime(row.created_at) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="320" fixed="right">
|
||||
|
||||
<el-table-column label="操作" width="340" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="flex items-center space-x-2">
|
||||
<el-button size="small" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button
|
||||
v-if="!row.file_path"
|
||||
@@ -88,39 +276,53 @@
|
||||
>
|
||||
查看文件夹
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.file_path"
|
||||
size="small"
|
||||
type="info"
|
||||
@click="handleDownload(row)"
|
||||
>
|
||||
<el-dropdown v-if="row.file_path || row.is_extracted">
|
||||
<el-button size="small" type="info">
|
||||
更多<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-if="row.file_path" @click="handleDownload(row)">
|
||||
下载文件
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.is_extracted"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="handleDeleteFolder(row)"
|
||||
>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="row.is_extracted" @click="handleDeleteFolder(row)">
|
||||
删除文件夹
|
||||
</el-button>
|
||||
<el-button size="small" type="danger" @click="handleDelete(row)">删除</el-button>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click="handleDelete(row)" divided>
|
||||
删除组件
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<el-button v-else size="small" type="danger" @click="handleDelete(row)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pagination-container">
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!loading && componentList.length === 0" class="text-center py-12">
|
||||
<el-empty description="暂无UI组件" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 分页 -->
|
||||
<template #pagination>
|
||||
<el-pagination
|
||||
v-if="pagination.total > 0"
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="pagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:layout="isMobile ? 'prev, pager, next' : 'total, sizes, prev, pager, next, jumper'"
|
||||
:small="isMobile"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
</ListPageLayout>
|
||||
|
||||
<!-- 创建/编辑对话框 -->
|
||||
<el-dialog
|
||||
@@ -187,7 +389,7 @@
|
||||
可以上传多个文件,每个文件不超过100MB。ZIP文件可以自动解压,其他文件类型仅保存。
|
||||
</div>
|
||||
<div class="el-upload__tip" v-else>
|
||||
可以上传整个文件夹,保持原有目录结构。ZIP文件可以自动解压,每个文件不超过100MB。
|
||||
。ZIP文件可以自动解压,每个文件不超过100MB。
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
@@ -272,15 +474,20 @@
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { uiComponentApi } from '@/api/ui-component'
|
||||
import { Document, Folder, UploadFilled } from '@element-plus/icons-vue'
|
||||
import FilterItem from '@/components/common/FilterItem.vue'
|
||||
import FilterSection from '@/components/common/FilterSection.vue'
|
||||
import ListPageLayout from '@/components/common/ListPageLayout.vue'
|
||||
import { ArrowDown, Document, Folder, Plus, UploadFilled } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
|
||||
// 移动端检测
|
||||
const { isMobile, isTablet } = useMobileTable()
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false)
|
||||
const componentList = ref([])
|
||||
@@ -366,6 +573,27 @@ const fetchComponentList = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (date) => {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
const formatTime = (date) => {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleTimeString('zh-CN', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
// 处理筛选变化
|
||||
const handleFilterChange = () => {
|
||||
pagination.page = 1
|
||||
fetchComponentList()
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
pagination.page = 1
|
||||
fetchComponentList()
|
||||
@@ -726,24 +954,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.ui-components-page {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.filter-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/* 对话框样式 */
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
@@ -762,4 +973,195 @@ onMounted(() => {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 移动端卡片布局 */
|
||||
.component-cards {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.component-card {
|
||||
background: white;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #f3f4f6;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.card-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.card-label {
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
font-weight: 500;
|
||||
min-width: 80px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-value {
|
||||
font-size: 14px;
|
||||
color: #1f2937;
|
||||
text-align: right;
|
||||
word-break: break-word;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid #f3f4f6;
|
||||
}
|
||||
|
||||
/* 表格容器 */
|
||||
.table-container {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
/* 表格样式优化 */
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background: #f8fafc !important;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
:deep(.el-table tr:hover > td) {
|
||||
background: #f8fafc !important;
|
||||
}
|
||||
|
||||
/* 对话框样式优化 */
|
||||
:deep(.el-dialog) {
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__header) {
|
||||
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
||||
border-bottom: 1px solid rgba(226, 232, 240, 0.6);
|
||||
padding: 20px 24px;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__title) {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 24px;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.card-row {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.card-value {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* 表格在移动端优化 */
|
||||
.table-container {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
font-size: 12px;
|
||||
min-width: 1000px;
|
||||
}
|
||||
|
||||
:deep(.el-table th),
|
||||
:deep(.el-table td) {
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
:deep(.el-table .cell) {
|
||||
padding: 0 4px;
|
||||
word-break: break-word;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* 分页组件在移动端优化 */
|
||||
:deep(.el-pagination) {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pagination__sizes) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pagination__total) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pagination__jump) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 对话框在移动端优化 */
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 16px;
|
||||
max-height: 80vh;
|
||||
}
|
||||
}
|
||||
|
||||
/* 超小屏幕进一步优化 */
|
||||
@media (max-width: 480px) {
|
||||
.component-card {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.card-label {
|
||||
font-size: 11px;
|
||||
min-width: 70px;
|
||||
}
|
||||
|
||||
.card-value {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -178,6 +178,10 @@
|
||||
<el-icon><wallet /></el-icon>
|
||||
充值记录
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{ action: 'purchase_records', user }">
|
||||
<el-icon><shopping-cart /></el-icon>
|
||||
购买记录
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
@@ -367,6 +371,10 @@
|
||||
<el-icon><wallet /></el-icon>
|
||||
充值记录
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{ action: 'purchase_records', user: row }">
|
||||
<el-icon><shopping-cart /></el-icon>
|
||||
购买记录
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
@@ -643,7 +651,7 @@ 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, Document, Money, Tickets, Wallet, Warning } from '@element-plus/icons-vue'
|
||||
import { ArrowDown, Document, Money, ShoppingCart, Tickets, Wallet, Warning } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
@@ -950,6 +958,12 @@ const handleMoreAction = (command) => {
|
||||
query: { user_id: user.id }
|
||||
})
|
||||
break
|
||||
case 'purchase_records':
|
||||
router.push({
|
||||
name: 'AdminPurchaseRecords',
|
||||
query: { user_id: user.id }
|
||||
})
|
||||
break
|
||||
default:
|
||||
ElMessage.warning('未知操作')
|
||||
}
|
||||
|
||||
555
src/pages/finance/purchase-records/index.vue
Normal file
555
src/pages/finance/purchase-records/index.vue
Normal file
@@ -0,0 +1,555 @@
|
||||
<template>
|
||||
<ListPageLayout
|
||||
title="购买记录"
|
||||
subtitle="查看您的所有购买记录"
|
||||
>
|
||||
<template #filters>
|
||||
<FilterSection>
|
||||
<FilterItem label="支付类型">
|
||||
<el-select
|
||||
v-model="filters.payment_type"
|
||||
placeholder="选择支付类型"
|
||||
clearable
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
>
|
||||
<el-option label="支付宝" value="alipay" />
|
||||
<el-option label="微信" value="wechat" />
|
||||
<el-option label="免费" value="free" />
|
||||
</el-select>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="支付渠道">
|
||||
<el-select
|
||||
v-model="filters.pay_channel"
|
||||
placeholder="选择支付渠道"
|
||||
clearable
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
>
|
||||
<el-option label="支付宝" value="alipay" />
|
||||
<el-option label="微信" value="wechat" />
|
||||
</el-select>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="订单状态">
|
||||
<el-select
|
||||
v-model="filters.status"
|
||||
placeholder="选择订单状态"
|
||||
clearable
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
>
|
||||
<el-option label="已创建" value="created" />
|
||||
<el-option label="已支付" value="paid" />
|
||||
<el-option label="支付失败" value="failed" />
|
||||
<el-option label="已取消" value="cancelled" />
|
||||
<el-option label="已退款" value="refunded" />
|
||||
<el-option label="已关闭" value="closed" />
|
||||
</el-select>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="开始时间" class="col-span-1">
|
||||
<el-date-picker
|
||||
v-model="filters.start_time"
|
||||
type="datetime"
|
||||
placeholder="选择开始时间"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
:size="isMobile ? 'small' : 'default'"
|
||||
/>
|
||||
</FilterItem>
|
||||
|
||||
<FilterItem label="结束时间" class="col-span-1">
|
||||
<el-date-picker
|
||||
v-model="filters.end_time"
|
||||
type="datetime"
|
||||
placeholder="选择结束时间"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
@change="handleFilterChange"
|
||||
class="w-full"
|
||||
:size="isMobile ? 'small' : 'default'"
|
||||
/>
|
||||
</FilterItem>
|
||||
|
||||
<template #stats>
|
||||
共找到 {{ total }} 条购买记录
|
||||
</template>
|
||||
|
||||
<template #buttons>
|
||||
<el-button @click="resetFilters">重置筛选</el-button>
|
||||
<el-button type="primary" @click="loadRecords">应用筛选</el-button>
|
||||
</template>
|
||||
</FilterSection>
|
||||
</template>
|
||||
|
||||
<template #table>
|
||||
<div v-if="loading" class="flex justify-center items-center py-12">
|
||||
<el-loading size="large" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="records.length === 0" class="text-center py-12">
|
||||
<el-empty description="暂无购买记录" />
|
||||
</div>
|
||||
|
||||
<div v-else class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="table-container">
|
||||
<el-table
|
||||
:data="records"
|
||||
style="width: 100%"
|
||||
:header-cell-style="{
|
||||
background: '#f8fafc',
|
||||
color: '#475569',
|
||||
fontWeight: '600',
|
||||
fontSize: '14px'
|
||||
}"
|
||||
:cell-style="{
|
||||
fontSize: '14px',
|
||||
color: '#1e293b'
|
||||
}"
|
||||
>
|
||||
<el-table-column prop="order_no" label="订单号">
|
||||
<template #default="{ row }">
|
||||
<div class="space-y-1">
|
||||
<div class="text-sm">
|
||||
<span class="text-gray-500">商户订单:</span>
|
||||
<span class="font-mono">{{ row.order_no }}</span>
|
||||
</div>
|
||||
<div v-if="row.trade_no" class="text-sm">
|
||||
<span class="text-gray-500">交易号:</span>
|
||||
<span class="font-mono">{{ row.trade_no }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="product_name" label="产品名称" width="200">
|
||||
<template #default="{ row }">
|
||||
<div class="space-y-1">
|
||||
<div class="text-sm font-medium">{{ row.product_name }}</div>
|
||||
<div class="text-xs text-gray-500">{{ row.product_code }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="amount" label="订单金额" width="120">
|
||||
<template #default="{ row }">
|
||||
<span class="font-medium text-green-600">
|
||||
¥{{ formatMoney(row.amount) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="payment_type" label="支付类型" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
:type="getPaymentTypeTagType(row.payment_type)"
|
||||
size="small"
|
||||
>
|
||||
{{ getPaymentTypeText(row.payment_type) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="pay_channel" label="支付渠道" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
:type="getPayChannelTagType(row.pay_channel)"
|
||||
size="small"
|
||||
>
|
||||
{{ getPayChannelText(row.pay_channel) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="status" label="订单状态" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
:type="getStatusTagType(row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ getStatusText(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="pay_time" label="支付时间" width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="text-sm">
|
||||
<div v-if="row.pay_time" class="text-gray-900">{{ formatDate(row.pay_time) }}</div>
|
||||
<div v-if="row.pay_time" class="text-gray-500">{{ formatTime(row.pay_time) }}</div>
|
||||
<div v-else class="text-gray-400">-</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="text-sm">
|
||||
<div class="text-gray-900">{{ formatDate(row.created_at) }}</div>
|
||||
<div class="text-gray-500">{{ formatTime(row.created_at) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #pagination>
|
||||
<div class="pagination-wrapper">
|
||||
<el-pagination
|
||||
v-if="total > 0"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ListPageLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { financeApi } 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 { ElMessage } from 'element-plus'
|
||||
|
||||
// 移动端检测
|
||||
const { isMobile } = useMobileTable()
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false)
|
||||
const records = ref([])
|
||||
const total = ref(0)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(20)
|
||||
|
||||
// 筛选条件
|
||||
const filters = reactive({
|
||||
payment_type: '',
|
||||
pay_channel: '',
|
||||
status: '',
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
})
|
||||
|
||||
// 搜索防抖定时器
|
||||
let searchTimer = null
|
||||
|
||||
// 加载购买记录
|
||||
const loadRecords = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 构建参数,过滤掉空值
|
||||
const params = {
|
||||
page: currentPage.value,
|
||||
page_size: pageSize.value
|
||||
}
|
||||
|
||||
// 只添加非空的筛选条件
|
||||
Object.keys(filters).forEach(key => {
|
||||
const value = filters[key]
|
||||
if (value !== '' && value !== null && value !== undefined) {
|
||||
params[key] = value
|
||||
}
|
||||
})
|
||||
|
||||
const response = await financeApi.getUserPurchaseRecords(params)
|
||||
records.value = response.data?.items || []
|
||||
total.value = response.data?.total || 0
|
||||
} catch (error) {
|
||||
console.error('加载购买记录失败:', error)
|
||||
ElMessage.error('加载购买记录失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化金额
|
||||
const formatMoney = (amount) => {
|
||||
if (!amount) return '0.00'
|
||||
const num = parseFloat(amount)
|
||||
if (isNaN(num)) return '0.00'
|
||||
return num.toFixed(2)
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (date) => {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
const formatTime = (date) => {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleTimeString('zh-CN', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
// 获取支付类型标签样式
|
||||
const getPaymentTypeTagType = (type) => {
|
||||
const typeMap = {
|
||||
alipay: 'primary',
|
||||
wechat: 'success',
|
||||
free: 'info'
|
||||
}
|
||||
return typeMap[type] || 'info'
|
||||
}
|
||||
|
||||
// 获取支付类型文本
|
||||
const getPaymentTypeText = (type) => {
|
||||
const typeMap = {
|
||||
alipay: '支付宝',
|
||||
wechat: '微信',
|
||||
free: '免费'
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
|
||||
// 获取支付渠道标签样式
|
||||
const getPayChannelTagType = (channel) => {
|
||||
const channelMap = {
|
||||
alipay: 'primary',
|
||||
wechat: 'success'
|
||||
}
|
||||
return channelMap[channel] || 'info'
|
||||
}
|
||||
|
||||
// 获取支付渠道文本
|
||||
const getPayChannelText = (channel) => {
|
||||
const channelMap = {
|
||||
alipay: '支付宝',
|
||||
wechat: '微信'
|
||||
}
|
||||
return channelMap[channel] || channel
|
||||
}
|
||||
|
||||
// 获取状态标签样式
|
||||
const getStatusTagType = (status) => {
|
||||
const statusMap = {
|
||||
created: 'info',
|
||||
paid: 'success',
|
||||
failed: 'danger',
|
||||
cancelled: 'warning',
|
||||
refunded: 'info',
|
||||
closed: 'info'
|
||||
}
|
||||
return statusMap[status] || 'info'
|
||||
}
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status) => {
|
||||
const statusMap = {
|
||||
created: '已创建',
|
||||
paid: '已支付',
|
||||
failed: '支付失败',
|
||||
cancelled: '已取消',
|
||||
refunded: '已退款',
|
||||
closed: '已关闭'
|
||||
}
|
||||
return statusMap[status] || status
|
||||
}
|
||||
|
||||
// 处理筛选变化
|
||||
const handleFilterChange = () => {
|
||||
currentPage.value = 1
|
||||
loadRecords()
|
||||
}
|
||||
|
||||
// 重置筛选
|
||||
const resetFilters = () => {
|
||||
Object.keys(filters).forEach(key => {
|
||||
filters[key] = ''
|
||||
})
|
||||
currentPage.value = 1
|
||||
loadRecords()
|
||||
}
|
||||
|
||||
// 处理分页大小变化
|
||||
const handleSizeChange = (size) => {
|
||||
pageSize.value = size
|
||||
currentPage.value = 1
|
||||
loadRecords()
|
||||
}
|
||||
|
||||
// 处理当前页变化
|
||||
const handleCurrentChange = (page) => {
|
||||
currentPage.value = page
|
||||
loadRecords()
|
||||
}
|
||||
|
||||
// 页面加载时获取数据
|
||||
onMounted(() => {
|
||||
loadRecords()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 表格样式优化 */
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background: #f8fafc !important;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
:deep(.el-table tr:hover > td) {
|
||||
background: #f8fafc !important;
|
||||
}
|
||||
|
||||
/* 表格容器 */
|
||||
.table-container {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
/* 分页器包装器 */
|
||||
.pagination-wrapper {
|
||||
padding: 16px 0;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.stat-item {
|
||||
padding: 12px 16px;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 表格在移动端优化 */
|
||||
.table-container {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
font-size: 12px;
|
||||
min-width: 1200px;
|
||||
}
|
||||
|
||||
:deep(.el-table th),
|
||||
:deep(.el-table td) {
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
:deep(.el-table .cell) {
|
||||
padding: 0 4px;
|
||||
word-break: break-word;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* 分页组件在移动端优化 */
|
||||
.pagination-wrapper {
|
||||
padding: 12px 0;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pagination) {
|
||||
flex-wrap: nowrap;
|
||||
min-width: fit-content;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pagination__sizes) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pagination__total) {
|
||||
font-size: 12px;
|
||||
margin-right: 8px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pagination__jump) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pager li) {
|
||||
min-width: 32px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0 2px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.btn-prev),
|
||||
.pagination-wrapper :deep(.btn-next) {
|
||||
min-width: 32px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 超小屏幕进一步优化 */
|
||||
@media (max-width: 480px) {
|
||||
.pagination-wrapper {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pagination__total) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pagination) {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.el-pager li) {
|
||||
min-width: 28px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.pagination-wrapper :deep(.btn-prev),
|
||||
.pagination-wrapper :deep(.btn-next) {
|
||||
min-width: 28px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
padding: 10px 12px;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -51,6 +51,28 @@
|
||||
>
|
||||
前往在线调试
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
v-if="product?.is_package && product?.sell_ui_component && showDownloadReportButton"
|
||||
:size="isMobile ? 'small' : 'default'"
|
||||
type="success"
|
||||
@click="handleDownloadReport"
|
||||
:loading="downloadingReport"
|
||||
>
|
||||
<el-icon><Download /></el-icon>
|
||||
{{ canDownloadReport ? '下载示例报告' : '购买示例报告' }}
|
||||
</el-button>
|
||||
|
||||
<!-- 手动检查支付状态按钮 -->
|
||||
<el-button
|
||||
v-if="currentReportOrderId && !canDownloadReport"
|
||||
:size="isMobile ? 'small' : 'default'"
|
||||
type="info"
|
||||
@click="checkPaymentStatusManually"
|
||||
:loading="checkingPaymentStatus"
|
||||
>
|
||||
检查支付状态
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -274,6 +296,82 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 支付对话框 -->
|
||||
<el-dialog
|
||||
v-model="reportPaymentDialogVisible"
|
||||
title="购买示例报告"
|
||||
width="500px"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div v-if="reportDownloadInfo">
|
||||
<el-alert
|
||||
title="购买说明"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
style="margin-bottom: 20px;"
|
||||
>
|
||||
<template #default>
|
||||
<p>您正在购买<strong>{{ reportDownloadInfo.product_name }}</strong>的示例报告</p>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<div class="component-list">
|
||||
<h4>包含的组件</h4>
|
||||
<div v-if="reportDownloadInfo.sub_products && reportDownloadInfo.sub_products.length > 0" class="component-tags">
|
||||
<el-tag
|
||||
v-for="item in reportDownloadInfo.sub_products"
|
||||
:key="item.product_id"
|
||||
:type="item.is_purchased ? 'success' : 'primary'"
|
||||
class="component-tag"
|
||||
>
|
||||
{{ item.product_code }}
|
||||
<span v-if="item.is_purchased" class="downloaded-indicator">✓</span>
|
||||
</el-tag>
|
||||
</div>
|
||||
<div v-else class="no-components">
|
||||
暂无组件信息
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="price-info" v-if="product.ui_component_price && !canDownloadReport">
|
||||
<h4>价格信息</h4>
|
||||
<div class="price-summary">
|
||||
<div class="price-row">
|
||||
<span>价格:</span>
|
||||
<span class="total-price">¥{{ formatPrice(product.ui_component_price) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="payment-methods">
|
||||
<h4>支付方式</h4>
|
||||
<div class="payment-buttons">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="createReportPaymentOrder('alipay')"
|
||||
>
|
||||
<el-icon><svg viewBox="0 0 1024 1024" width="18" height="18"><path d="M866.688 166.4c-14.336-14.336-33.792-22.528-54.272-22.528H200.704c-20.48 0-39.936 8.192-54.272 22.528S124.928 200.192 124.928 220.672v611.328c0 20.48 7.168 39.936 22.528 54.272s33.792 22.528 54.272 22.528h611.328c20.48 0 39.936-7.168 54.272-22.528s22.528-33.792 22.528-54.272V220.672c0-20.48-8.192-39.936-22.528-54.272zM512 310.272c85.504 0 155.648 70.144 155.648 155.648S597.504 621.568 512 621.568 356.352 551.424 356.352 465.92 426.496 310.272 512 310.272z m172.032 400.384c0 20.48-7.168 39.936-22.528 54.272s-33.792 22.528-54.272 22.528H416.768c-20.48 0-39.936-7.168-54.272-22.528s-22.528-33.792-22.528-54.272v-90.112c0-20.48 7.168-39.936 22.528-54.272s33.792-22.528 54.272-22.528h190.464c20.48 0 39.936 7.168 54.272 22.528s22.528 33.792 22.528 54.272v90.112z" fill="#1677FF"/></svg></el-icon>
|
||||
支付宝支付
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
size="large"
|
||||
@click="createReportPaymentOrder('wechat')"
|
||||
>
|
||||
<el-icon><svg viewBox="0 0 1024 1024" width="18" height="18"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm189.5 301.7c-8 14.4-21.7 26.8-41.1 37.4-19.4 10.6-41.9 15.9-67.6 15.9-20.7 0-39.5-3.6-56.3-10.9-16.8-7.3-31-17.6-42.6-31-11.6-13.4-20.6-29-26.9-46.8-6.3-17.8-9.5-36.9-9.5-57.3 0-22.4 3.9-43.2 11.8-62.3 7.9-19.1 19.1-35.7 33.6-49.8 14.5-14.1 31.5-25.2 51-33.3 19.5-8.1 40.5-12.1 63.1-12.1 22.6 0 43.6 4 63.1 12.1 19.5 8.1 36.5 19.2 51 33.3 14.5 14.1 25.7 30.7 33.6 49.8 7.9 19.1 11.8 39.9 11.8 62.3 0 20.4-3.1 39.5-9.5 57.3zm-189.5 20.2c19.1 0 35.9 5.5 50.3 16.4 14.4 10.9 21.6 25.5 21.6 43.6 0 18.2-7.2 32.7-21.6 43.6-14.4 10.9-31.2 16.4-50.3 16.4s-35.9-5.5-50.3-16.4c-14.4-10.9-21.6-25.5-21.6-43.6 0-18.2 7.2-32.7 21.6-43.6 14.4-10.9 31.2-16.4 50.3-16.4z" fill="#07C160"/></svg></el-icon>
|
||||
微信支付
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="reportPaymentDialogVisible = false">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -281,8 +379,9 @@
|
||||
import { productApi, subscriptionApi } from '@/api'
|
||||
import { useMobileTable } from '@/composables/useMobileTable'
|
||||
import { DocumentCopy, Download } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { marked } from 'marked'
|
||||
import { h } from 'vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -297,8 +396,16 @@ const userSubscriptions = ref([])
|
||||
const subscribing = ref(false)
|
||||
const cancelling = ref(false)
|
||||
const downloading = ref(false)
|
||||
const downloadingReport = ref(false)
|
||||
const activeTab = ref('content')
|
||||
const currentTimestamp = ref('')
|
||||
const showDownloadReportButton = ref(false)
|
||||
const canDownloadReport = ref(false)
|
||||
const reportDownloadInfo = ref(null)
|
||||
const reportPaymentDialogVisible = ref(false)
|
||||
const reportPaymentStatus = ref('pending')
|
||||
const currentReportOrderId = ref('')
|
||||
const checkingPaymentStatus = ref(false)
|
||||
|
||||
// DOM 引用
|
||||
const basicInfoRef = ref(null)
|
||||
@@ -324,15 +431,35 @@ onMounted(() => {
|
||||
loadUserSubscriptions()
|
||||
loadProductDetail().then(() => {
|
||||
addCollapsibleFeatures()
|
||||
// 检查是否可以下载示例报告
|
||||
if (product.value?.is_package) {
|
||||
checkReportDownloadAvailability()
|
||||
}
|
||||
})
|
||||
startTimestampUpdate()
|
||||
})
|
||||
|
||||
// 组件卸载时清理定时器
|
||||
onUnmounted(() => {
|
||||
// 清理时间戳更新定时器
|
||||
if (timestampTimer.value) {
|
||||
clearInterval(timestampTimer.value)
|
||||
}
|
||||
|
||||
// 清理支付状态检查定时器
|
||||
if (window.paymentCheckIntervals) {
|
||||
Object.keys(window.paymentCheckIntervals).forEach(orderId => {
|
||||
clearInterval(window.paymentCheckIntervals[orderId])
|
||||
})
|
||||
window.paymentCheckIntervals = {}
|
||||
}
|
||||
|
||||
// 关闭所有消息框
|
||||
ElMessageBox.close()
|
||||
|
||||
// 关闭所有加载提示
|
||||
const loadingInstance = ElLoading.service()
|
||||
loadingInstance.close()
|
||||
})
|
||||
|
||||
// 时间戳更新定时器
|
||||
@@ -654,6 +781,29 @@ const openProductDetail = (productId) => {
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
/*
|
||||
* 示例报告下载功能说明
|
||||
*
|
||||
* 功能概述:
|
||||
* - 只有组合包产品才能下载示例报告
|
||||
* - 根据用户是否已下载过子产品,计算价格(已下载的产品不需要再次付费)
|
||||
* - 支持微信和支付宝两种支付方式
|
||||
* - 支付成功后可以下载包含所有子产品UI组件和示例数据的ZIP文件
|
||||
*
|
||||
* 流程说明:
|
||||
* 1. 检查产品是否为组合包,以及是否可以下载示例报告
|
||||
* 2. 如果可以直接下载(免费或已付费),直接提供下载
|
||||
* 3. 如果需要付费,显示支付对话框,包含价格明细和支付方式选择
|
||||
* 4. 用户选择支付方式后,创建支付订单
|
||||
* 5. 定期检查支付状态,成功后自动下载示例报告
|
||||
*
|
||||
* 注意事项:
|
||||
* - 微信支付显示二维码,需要用户扫码支付
|
||||
* - 支付宝支付会跳转到支付宝页面
|
||||
* - 支付状态检查会在后台持续进行,直到成功或超时
|
||||
* - 下载的ZIP文件包含UI组件和示例数据
|
||||
*/
|
||||
|
||||
// 获取默认的请求方式内容
|
||||
const getDefaultBasicInfo = () => {
|
||||
return `## 请求头
|
||||
@@ -825,6 +975,532 @@ const downloadMarkdown = (type) => {
|
||||
|
||||
ElMessage.success('文档下载成功')
|
||||
}
|
||||
|
||||
// 检查报告下载可用性
|
||||
const checkReportDownloadAvailability = async () => {
|
||||
console.log('[checkReportDownloadAvailability] 开始检查下载可用性')
|
||||
console.log('[checkReportDownloadAvailability] 产品信息:', product.value)
|
||||
console.log('[checkReportDownloadAvailability] sell_ui_component:', product.value?.sell_ui_component)
|
||||
|
||||
if (!product.value?.id || !product.value?.is_package) {
|
||||
console.log('[checkReportDownloadAvailability] 产品不存在或不是组合包,隐藏下载按钮')
|
||||
showDownloadReportButton.value = false
|
||||
return
|
||||
}
|
||||
|
||||
if (!product.value?.sell_ui_component) {
|
||||
console.log('[checkReportDownloadAvailability] 产品不出售UI组件,隐藏下载按钮')
|
||||
showDownloadReportButton.value = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('[checkReportDownloadAvailability] 检查组件报告可用性,产品ID:', product.value.id)
|
||||
const response = await productApi.checkComponentReportAvailability(product.value.id)
|
||||
console.log('[checkReportDownloadAvailability] 检查可用性响应:', response)
|
||||
const { can_download } = response.data
|
||||
|
||||
showDownloadReportButton.value = true
|
||||
|
||||
console.log('[checkReportDownloadAvailability] 获取组件报告信息,产品ID:', product.value.id)
|
||||
// 获取下载信息和价格
|
||||
const infoResponse = await productApi.getComponentReportInfo(product.value.id)
|
||||
console.log('[checkReportDownloadAvailability] 组件报告信息响应:', infoResponse)
|
||||
|
||||
// 检查响应数据结构
|
||||
if (infoResponse.data && infoResponse.data.data) {
|
||||
// 如果响应是嵌套结构,提取实际数据
|
||||
reportDownloadInfo.value = infoResponse.data.data
|
||||
} else if (infoResponse.data) {
|
||||
// 直接使用响应数据
|
||||
reportDownloadInfo.value = infoResponse.data
|
||||
} else {
|
||||
console.error('[checkReportDownloadAvailability] 响应数据格式不正确:', infoResponse)
|
||||
showDownloadReportButton.value = false
|
||||
return
|
||||
}
|
||||
|
||||
canDownloadReport.value = reportDownloadInfo.value.can_download
|
||||
} catch (error) {
|
||||
console.error('[checkReportDownloadAvailability] 检查报告下载可用性失败:', error)
|
||||
console.error('[checkReportDownloadAvailability] 错误详情:', {
|
||||
message: error.message,
|
||||
response: error.response?.data,
|
||||
status: error.response?.status
|
||||
})
|
||||
showDownloadReportButton.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 处理下载报告按钮点击
|
||||
const handleDownloadReport = async () => {
|
||||
console.log('[handleDownloadReport] 开始处理下载报告按钮点击')
|
||||
console.log('[handleDownloadReport] 产品信息:', product.value)
|
||||
|
||||
if (!product.value?.id) {
|
||||
console.log('[handleDownloadReport] 产品信息不存在')
|
||||
ElMessage.warning('产品信息不存在')
|
||||
return
|
||||
}
|
||||
|
||||
// 如果可以直接下载
|
||||
if (canDownloadReport.value) {
|
||||
console.log('[handleDownloadReport] 可以直接下载,开始下载')
|
||||
downloadComponentReport()
|
||||
return
|
||||
}
|
||||
|
||||
console.log('[handleDownloadReport] 需要购买,检查下载信息是否存在')
|
||||
// 需要购买,显示支付对话框
|
||||
if (!reportDownloadInfo.value || !reportDownloadInfo.value.product_id) {
|
||||
console.log('[handleDownloadReport] 下载信息不存在或不完整,重新获取')
|
||||
try {
|
||||
const response = await productApi.getComponentReportInfo(product.value.id)
|
||||
console.log('[handleDownloadReport] 获取到的下载信息:', response)
|
||||
|
||||
// 检查响应数据结构
|
||||
if (response.data && response.data.data) {
|
||||
// 如果响应是嵌套结构,提取实际数据
|
||||
reportDownloadInfo.value = response.data.data
|
||||
} else if (response.data) {
|
||||
// 直接使用响应数据
|
||||
reportDownloadInfo.value = response.data
|
||||
} else {
|
||||
console.error('[handleDownloadReport] 响应数据格式不正确:', response)
|
||||
ElMessage.error('获取报告下载信息失败')
|
||||
return
|
||||
}
|
||||
|
||||
// 详细日志记录数据结构
|
||||
console.log('[handleDownloadReport] 下载信息详情:', {
|
||||
产品ID: reportDownloadInfo.value.product_id,
|
||||
产品名称: reportDownloadInfo.value.product_name,
|
||||
是否组合包: reportDownloadInfo.value.is_package,
|
||||
子产品数量: reportDownloadInfo.value.sub_products?.length || 0,
|
||||
子产品列表: reportDownloadInfo.value.sub_products,
|
||||
价格: product.value.ui_component_price,
|
||||
可下载: reportDownloadInfo.value.can_download
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('[handleDownloadReport] 获取报告下载信息失败:', error)
|
||||
console.error('[handleDownloadReport] 错误详情:', {
|
||||
message: error.message,
|
||||
response: error.response?.data,
|
||||
status: error.response?.status
|
||||
})
|
||||
ElMessage.error('获取报告下载信息失败')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
console.log('[handleDownloadReport] 下载信息已存在,使用缓存数据')
|
||||
// 详细日志记录数据结构
|
||||
console.log('[handleDownloadReport] 缓存的下载信息详情:', {
|
||||
产品ID: reportDownloadInfo.value.product_id,
|
||||
产品名称: reportDownloadInfo.value.product_name,
|
||||
是否组合包: reportDownloadInfo.value.is_package,
|
||||
子产品数量: reportDownloadInfo.value.sub_products?.length || 0,
|
||||
子产品列表: reportDownloadInfo.value.sub_products,
|
||||
价格: product.value.ui_component_price,
|
||||
可下载: reportDownloadInfo.value.can_download
|
||||
})
|
||||
}
|
||||
|
||||
console.log('[handleDownloadReport] 显示支付对话框')
|
||||
reportPaymentDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 下载组件报告
|
||||
const downloadComponentReport = async () => {
|
||||
if (!product.value?.id) {
|
||||
ElMessage.warning('产品信息不存在')
|
||||
return
|
||||
}
|
||||
|
||||
downloadingReport.value = true
|
||||
try {
|
||||
// 获取子产品代码列表
|
||||
let subProductCodes = []
|
||||
if (reportDownloadInfo.value && reportDownloadInfo.value.sub_products && reportDownloadInfo.value.sub_products.length > 0) {
|
||||
subProductCodes = reportDownloadInfo.value.sub_products.map(item => item.product_code)
|
||||
console.log('[downloadComponentReport] 提取子产品代码列表:', subProductCodes)
|
||||
} else {
|
||||
console.log('[downloadComponentReport] 未找到子产品信息,使用空列表')
|
||||
}
|
||||
|
||||
const response = await productApi.generateAndDownloadComponentReport({
|
||||
product_id: product.value.id,
|
||||
sub_product_codes: subProductCodes
|
||||
})
|
||||
|
||||
// 创建下载链接
|
||||
// 直接从response中获取数据,不再检查Blob类型
|
||||
const url = URL.createObjectURL(response.data)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `${product.value.name || '产品'}_示例报告.zip`
|
||||
|
||||
// 触发下载
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
|
||||
// 清理
|
||||
document.body.removeChild(link)
|
||||
URL.revokeObjectURL(url)
|
||||
|
||||
ElMessage.success('示例报告下载成功')
|
||||
} catch (error) {
|
||||
console.error('下载示例报告失败:', error)
|
||||
ElMessage.error('下载示例报告失败')
|
||||
} finally {
|
||||
downloadingReport.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 创建支付订单
|
||||
const createReportPaymentOrder = async (paymentType) => {
|
||||
console.log('[createReportPaymentOrder] 开始创建支付订单')
|
||||
console.log('[createReportPaymentOrder] 支付类型:', paymentType)
|
||||
console.log('[createReportPaymentOrder] 产品信息:', product.value)
|
||||
|
||||
if (!product.value?.id) {
|
||||
console.log('[createReportPaymentOrder] 产品信息不存在')
|
||||
ElMessage.warning('产品信息不存在')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 显示加载状态
|
||||
const loadingInstance = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在创建支付订单,请稍候...',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
})
|
||||
|
||||
console.log('[createReportPaymentOrder] 调用创建支付订单API')
|
||||
const response = await productApi.createComponentReportPaymentOrder(product.value.id, {
|
||||
payment_type: paymentType
|
||||
})
|
||||
console.log('[createReportPaymentOrder] 支付订单创建响应:', response)
|
||||
|
||||
// 关闭加载状态
|
||||
loadingInstance.close()
|
||||
|
||||
// 根据响应拦截器的处理方式,正确访问嵌套的 data 对象
|
||||
// 响应格式为 {code: 200, data: {...}}
|
||||
const responseData = response.data.data || response.data
|
||||
console.log('[createReportPaymentOrder] 解析响应数据:', responseData)
|
||||
|
||||
const { order_id, code_url, pay_url, payment_type } = responseData
|
||||
|
||||
currentReportOrderId.value = order_id
|
||||
reportPaymentStatus.value = 'pending'
|
||||
reportPaymentDialogVisible.value = false
|
||||
|
||||
// 根据支付类型处理
|
||||
if (payment_type === 'wechat' && code_url) {
|
||||
console.log('[createReportPaymentOrder] 微信支付,显示二维码')
|
||||
// 显示微信支付二维码
|
||||
showWechatPaymentQRCode(code_url, order_id)
|
||||
} else if (payment_type === 'alipay' && pay_url) {
|
||||
console.log('[createReportPaymentOrder] 支付宝支付,跳转到支付页面')
|
||||
// 跳转到支付宝支付页面
|
||||
window.open(pay_url, '_blank')
|
||||
// 显示支付状态检查提示
|
||||
ElMessage.info('已打开支付页面,请在支付完成后返回此页面')
|
||||
// 开始检查支付状态
|
||||
startPaymentStatusCheck(order_id)
|
||||
} else {
|
||||
console.error('[createReportPaymentOrder] 支付类型或支付链接不匹配', {
|
||||
payment_type,
|
||||
code_url: !!code_url,
|
||||
pay_url: !!pay_url
|
||||
})
|
||||
ElMessage.error('支付方式不支持或支付链接获取失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[createReportPaymentOrder] 创建支付订单失败:', error)
|
||||
console.error('[createReportPaymentOrder] 错误详情:', {
|
||||
message: error.message,
|
||||
response: error.response?.data,
|
||||
status: error.response?.status
|
||||
})
|
||||
|
||||
// 显示具体错误信息
|
||||
const errorMessage = error.response?.data?.message || error.message || '创建支付订单失败'
|
||||
ElMessage.error(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// 显示微信支付二维码
|
||||
const showWechatPaymentQRCode = (codeUrl, orderId) => {
|
||||
// 验证二维码URL是否有效
|
||||
if (!codeUrl || typeof codeUrl !== 'string') {
|
||||
ElMessage.error('微信支付二维码获取失败')
|
||||
return
|
||||
}
|
||||
|
||||
console.log('[showWechatPaymentQRCode] 准备显示二维码,URL:', codeUrl)
|
||||
|
||||
// 使用第三方二维码生成服务将微信支付URL转换为二维码图片
|
||||
const qrCodeImageUrl = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(codeUrl)}`
|
||||
|
||||
// 使用自定义对话框而不是ElMessageBox.alert,以确保HTML内容正确渲染
|
||||
const qrDialog = ElMessageBox({
|
||||
title: '微信扫码支付',
|
||||
message: h('div', { style: 'text-align: center; padding: 20px;' }, [
|
||||
h('h3', { style: 'margin-bottom: 20px;' }, '微信扫码支付'),
|
||||
h('div', { style: 'margin-bottom: 20px;' }, '请使用微信扫描下方二维码完成支付'),
|
||||
h('div', { style: 'display: flex; justify-content: center; margin-bottom: 20px;' }, [
|
||||
h('img', {
|
||||
src: qrCodeImageUrl,
|
||||
alt: '微信支付二维码',
|
||||
style: 'width: 200px; height: 200px; border: 1px solid #eee;',
|
||||
onError: (e) => {
|
||||
console.error('[showWechatPaymentQRCode] 二维码图片加载失败:', e)
|
||||
// 尝试使用备用方案:显示一个链接,让用户点击打开微信
|
||||
ElMessage({
|
||||
message: '二维码加载失败,请尝试直接打开微信支付',
|
||||
type: 'warning',
|
||||
duration: 5000,
|
||||
showClose: true
|
||||
})
|
||||
|
||||
// 更新对话框内容,显示支付链接
|
||||
instance.message = h('div', { style: 'text-align: center; padding: 20px;' }, [
|
||||
h('h3', { style: 'margin-bottom: 20px;' }, '微信扫码支付'),
|
||||
h('div', { style: 'margin-bottom: 20px;' }, '二维码生成失败,请点击下方链接打开微信支付'),
|
||||
h('div', { style: 'margin-bottom: 20px; padding: 10px; border: 1px dashed #ccc; border-radius: 4px;' }, [
|
||||
h('a', {
|
||||
href: codeUrl,
|
||||
onClick: (e) => {
|
||||
e.preventDefault()
|
||||
// 尝试打开微信支付链接
|
||||
window.open(codeUrl, '_self')
|
||||
},
|
||||
style: 'color: #409EFF; text-decoration: underline; cursor: pointer;'
|
||||
}, '点击打开微信支付')
|
||||
]),
|
||||
h('div', { style: 'font-size: 14px; color: #666;' }, [
|
||||
h('p', `支付金额:¥${formatPrice(product.value?.ui_component_price || 0)}`),
|
||||
h('p', '支付完成后,请点击"我已支付"按钮')
|
||||
])
|
||||
])
|
||||
}
|
||||
})
|
||||
]),
|
||||
h('div', { style: 'font-size: 14px; color: #666;' }, [
|
||||
h('p', `支付金额:¥${formatPrice(product.value?.ui_component_price || 0)}`),
|
||||
h('p', '支付完成后,系统将自动检测支付状态')
|
||||
])
|
||||
]),
|
||||
confirmButtonText: '我已支付',
|
||||
cancelButtonText: '支付遇到问题',
|
||||
type: 'info',
|
||||
showClose: false,
|
||||
closeOnClickModal: false,
|
||||
closeOnPressEscape: false,
|
||||
beforeClose: (action, instance, done) => {
|
||||
if (action === 'confirm') {
|
||||
// 用户点击了"我已支付"按钮,开始检查支付状态
|
||||
startPaymentStatusCheck(orderId)
|
||||
} else {
|
||||
// 用户点击了"支付遇到问题"按钮
|
||||
ElMessage.warning('如果支付遇到问题,请稍后重试或联系客服')
|
||||
}
|
||||
done()
|
||||
}
|
||||
}).catch(() => {
|
||||
// 对话框被关闭(通过取消按钮或其他方式)
|
||||
})
|
||||
|
||||
// 不立即开始检查支付状态,等待用户确认支付后再开始
|
||||
// 这样可以避免过早开始状态检查导致用户体验不佳
|
||||
}
|
||||
|
||||
// 开始检查支付状态
|
||||
const startPaymentStatusCheck = (orderId) => {
|
||||
if (!orderId) {
|
||||
ElMessage.error('订单ID不存在')
|
||||
return
|
||||
}
|
||||
|
||||
// 显示支付状态检查提示
|
||||
const loadingInstance = ElLoading.service({
|
||||
lock: false, // 不锁定屏幕,允许用户操作
|
||||
text: '正在检查支付状态,请完成支付后等待(检查超过1分钟将自动刷新页面)...',
|
||||
background: 'rgba(0, 0, 0, 0.5)'
|
||||
})
|
||||
|
||||
// 显示一个提示对话框,告知用户正在检查支付状态
|
||||
ElMessageBox.alert(
|
||||
'我们正在检测您的支付状态,支付完成后会自动为您下载示例报告。检查超过1分钟页面将自动刷新以获取最新状态。请勿关闭此页面。',
|
||||
'支付状态检测',
|
||||
{
|
||||
confirmButtonText: '我知道了',
|
||||
type: 'info',
|
||||
showClose: false,
|
||||
closeOnClickModal: false,
|
||||
closeOnPressEscape: false
|
||||
}
|
||||
).catch(() => {
|
||||
// 用户点击了确定按钮,继续检查
|
||||
})
|
||||
|
||||
let checkCount = 0
|
||||
const maxCheckCount = 60 // 最多检查3分钟(60次 * 3秒)
|
||||
|
||||
// 设置定时器检查支付状态
|
||||
const checkInterval = setInterval(async () => {
|
||||
checkCount++
|
||||
|
||||
// 更新提示文本
|
||||
loadingInstance.text = `正在检查支付状态... (${Math.ceil(checkCount/20)}分钟/${Math.ceil(maxCheckCount/20)}分钟)`
|
||||
|
||||
try {
|
||||
const response = await productApi.checkComponentReportPaymentStatus(orderId)
|
||||
// 正确处理响应数据格式
|
||||
const responseData = response.data.data || response.data
|
||||
const { payment_status, can_download } = responseData
|
||||
|
||||
console.log('[startPaymentStatusCheck] 支付状态检查结果:', {
|
||||
payment_status,
|
||||
can_download,
|
||||
check_count: checkCount
|
||||
})
|
||||
|
||||
if (payment_status === 'success' && can_download) {
|
||||
// 支付成功
|
||||
clearInterval(checkInterval)
|
||||
loadingInstance.close()
|
||||
|
||||
canDownloadReport.value = true
|
||||
ElMessage.success('支付成功,现在可以下载示例报告了')
|
||||
|
||||
// 关闭之前的提示框
|
||||
ElMessageBox.close()
|
||||
|
||||
// 自动下载
|
||||
downloadComponentReport()
|
||||
} else if (payment_status === 'failed') {
|
||||
// 支付失败
|
||||
clearInterval(checkInterval)
|
||||
loadingInstance.close()
|
||||
|
||||
// 关闭之前的提示框
|
||||
ElMessageBox.close()
|
||||
|
||||
ElMessage.error('支付失败,请重试')
|
||||
} else if (payment_status === 'cancelled') {
|
||||
// 支付取消
|
||||
clearInterval(checkInterval)
|
||||
loadingInstance.close()
|
||||
|
||||
// 关闭之前的提示框
|
||||
ElMessageBox.close()
|
||||
|
||||
ElMessage.info('支付已取消')
|
||||
} else if (checkCount >= 20) {
|
||||
// 检查超过1分钟(20次 * 3秒)
|
||||
clearInterval(checkInterval)
|
||||
loadingInstance.close()
|
||||
|
||||
// 关闭之前的提示框
|
||||
ElMessageBox.close()
|
||||
|
||||
ElMessage.warning('支付状态检查超过1分钟,页面将自动刷新以获取最新状态')
|
||||
|
||||
// 1秒后刷新页面
|
||||
setTimeout(() => {
|
||||
window.location.reload()
|
||||
}, 1000)
|
||||
} else if (checkCount >= maxCheckCount) {
|
||||
// 超时(3分钟)
|
||||
clearInterval(checkInterval)
|
||||
loadingInstance.close()
|
||||
|
||||
// 关闭之前的提示框
|
||||
ElMessageBox.close()
|
||||
|
||||
ElMessage.warning('支付状态检查超时,请刷新页面后检查')
|
||||
|
||||
// 显示手动检查选项
|
||||
ElMessageBox.confirm(
|
||||
'支付状态检查已超时,您可以选择继续等待或稍后手动检查支付状态。',
|
||||
'支付状态检查',
|
||||
{
|
||||
confirmButtonText: '继续等待',
|
||||
cancelButtonText: '稍后手动检查',
|
||||
type: 'warning'
|
||||
}
|
||||
).then(() => {
|
||||
// 继续等待,重置计数器
|
||||
checkCount = 0
|
||||
// 继续检查,不再设置超时
|
||||
}).catch(() => {
|
||||
// 用户选择稍后手动检查
|
||||
ElMessage.info('您可以在页面中点击"下载示例报告"按钮来手动检查支付状态')
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[startPaymentStatusCheck] 检查支付状态失败:', error)
|
||||
console.error('[startPaymentStatusCheck] 错误详情:', {
|
||||
message: error.message,
|
||||
response: error.response?.data,
|
||||
status: error.response?.status
|
||||
})
|
||||
|
||||
// 不显示错误消息,避免打扰用户,继续检查
|
||||
}
|
||||
}, 3000) // 每3秒检查一次,减少服务器压力
|
||||
|
||||
// 将定时器ID存储在组件实例中,以便在组件卸载时清理
|
||||
if (!window.paymentCheckIntervals) {
|
||||
window.paymentCheckIntervals = {}
|
||||
}
|
||||
window.paymentCheckIntervals[orderId] = checkInterval
|
||||
}
|
||||
|
||||
// 手动检查支付状态
|
||||
const checkPaymentStatusManually = async () => {
|
||||
if (!currentReportOrderId.value) {
|
||||
ElMessage.warning('没有正在处理的支付订单')
|
||||
return
|
||||
}
|
||||
|
||||
checkingPaymentStatus.value = true
|
||||
try {
|
||||
const response = await productApi.checkComponentReportPaymentStatus(currentReportOrderId.value)
|
||||
const { payment_status, can_download } = response.data
|
||||
|
||||
console.log('[checkPaymentStatusManually] 支付状态检查结果:', {
|
||||
payment_status,
|
||||
can_download
|
||||
})
|
||||
|
||||
if (payment_status === 'success' && can_download) {
|
||||
// 支付成功
|
||||
canDownloadReport.value = true
|
||||
ElMessage.success('支付成功,现在可以下载示例报告了')
|
||||
|
||||
// 自动下载
|
||||
downloadComponentReport()
|
||||
} else if (payment_status === 'failed') {
|
||||
// 支付失败
|
||||
ElMessage.error('支付失败,请重试')
|
||||
} else if (payment_status === 'pending') {
|
||||
// 支付中
|
||||
ElMessage.info('支付仍在处理中,请稍后再次检查')
|
||||
} else {
|
||||
// 其他状态
|
||||
ElMessage.warning(`支付状态: ${payment_status}`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[checkPaymentStatusManually] 检查支付状态失败:', error)
|
||||
ElMessage.error('检查支付状态失败,请稍后重试')
|
||||
} finally {
|
||||
checkingPaymentStatus.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -1658,4 +2334,158 @@ const downloadMarkdown = (type) => {
|
||||
border: 1px solid rgba(226, 232, 240, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
/* 支付对话框样式 */
|
||||
.component-list {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.component-list h4 {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.component-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.component-tag {
|
||||
position: relative;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.downloaded-indicator {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.no-components {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
color: #909399;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.price-info {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.price-info h4 {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.sub-products-list {
|
||||
margin-bottom: 16px;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.sub-product-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
.sub-product-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.product-code {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-weight: 500;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.price-summary {
|
||||
background: #f5f7fa;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.price-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.price-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-row.discount {
|
||||
color: #67c23a;
|
||||
}
|
||||
.price-row.total {
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px dashed #ebeef5;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.total-price {
|
||||
color: #f56c6c;
|
||||
font-size: 18px;
|
||||
}
|
||||
.payment-methods {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.payment-methods h4 {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.payment-buttons {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.payment-buttons .el-button {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
/* 微信支付二维码样式 */
|
||||
.el-message-box__message img {
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -136,6 +136,12 @@ const routes = [
|
||||
name: 'FinanceRechargeRecords',
|
||||
component: () => import('@/pages/finance/recharge-records/index.vue'),
|
||||
meta: { title: '充值记录' }
|
||||
},
|
||||
{
|
||||
path: 'purchase-records',
|
||||
name: 'FinancePurchaseRecords',
|
||||
component: () => import('@/pages/finance/purchase-records/index.vue'),
|
||||
meta: { title: '购买记录' }
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -292,6 +298,12 @@ const routes = [
|
||||
name: 'AdminUIComponents',
|
||||
component: () => import('@/pages/admin/ui-components/index.vue'),
|
||||
meta: { title: '组件管理' }
|
||||
},
|
||||
{
|
||||
path: 'purchase-records',
|
||||
name: 'AdminPurchaseRecords',
|
||||
component: () => import('@/pages/admin/purchase-records/index.vue'),
|
||||
meta: { title: '购买记录管理' }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -52,14 +52,16 @@ request.interceptors.request.use(
|
||||
// 响应拦截器
|
||||
request.interceptors.response.use(
|
||||
response => {
|
||||
const { data, status } = response
|
||||
const { data, status, config } = response
|
||||
|
||||
// 检查HTTP状态码
|
||||
if (status >= 200 && status < 300) {
|
||||
// 如果是blob响应(文件下载),直接返回data
|
||||
if (data instanceof Blob) {
|
||||
return data
|
||||
// 检查是否是文件下载API(通过URL判断)
|
||||
if (config.url && config.url.includes('/generate-and-download')) {
|
||||
// 直接返回原始响应,让前端处理文件下载
|
||||
return response
|
||||
}
|
||||
|
||||
// 严格按照后端响应格式处理
|
||||
if (data.success === true) {
|
||||
// 成功响应,返回data字段
|
||||
|
||||
Reference in New Issue
Block a user