This commit is contained in:
2025-12-23 16:17:03 +08:00
parent 3ddf6a2b70
commit 2bde0c38b9
3 changed files with 92 additions and 9 deletions

View File

@@ -139,6 +139,10 @@
<span class="card-label">成本价</span>
<span class="card-value text-gray-600">¥{{ formatPrice(subscription.product_admin?.cost_price) }}</span>
</div>
<div v-if="subscription.product?.is_package || subscription.product_admin?.is_package" class="card-row">
<span class="card-label">UI组件价格</span>
<span class="card-value text-purple-600 font-semibold">¥{{ formatPrice(subscription.ui_component_price) }}</span>
</div>
<div class="card-row">
<span class="card-label">订阅时间</span>
<span class="card-value text-sm">{{ formatDate(subscription.created_at) }} {{ formatTime(subscription.created_at) }}</span>
@@ -226,6 +230,13 @@
</template>
</el-table-column>
<el-table-column v-if="hasAnyPackageProducts" label="UI组件价格" width="130">
<template #default="{ row }">
<span v-if="row.product?.is_package || row.product_admin?.is_package" class="font-medium text-purple-600">¥{{ formatPrice(row.ui_component_price) }}</span>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column prop="created_at" label="订阅时间" width="160">
<template #default="{ row }">
<div class="text-sm">
@@ -309,6 +320,14 @@
</span>
</el-form-item>
<el-form-item v-if="selectedSubscription?.product?.is_package || selectedSubscription?.product_admin?.is_package" label="UI组件价格">
<div class="flex flex-col gap-1">
<span class="text-lg font-semibold text-purple-600">
¥{{ formatPrice(selectedSubscription?.ui_component_price) }}
</span>
</div>
</el-form-item>
<el-form-item label="当前价格">
<div class="flex flex-col gap-1">
<span class="text-lg font-semibold text-red-600">
@@ -364,6 +383,22 @@
</div>
</el-form-item>
<el-form-item v-if="(selectedSubscription?.product?.is_package || selectedSubscription?.product_admin?.is_package) && priceForm.adjustmentType === 'price'" label="UI组件价格" prop="ui_component_price">
<el-input-number
v-model="priceForm.ui_component_price"
:precision="2"
:min="0"
:step="0.01"
placeholder="请输入UI组件价格"
class="w-full"
/>
<div class="text-sm text-gray-500 mt-1">
<div class="text-purple-600">
组合包UI组件的购买报告价格
</div>
</div>
</el-form-item>
<el-form-item v-if="priceForm.adjustmentType === 'discount'" label="折扣比例" prop="discount">
<div class="flex items-center gap-2">
<el-input-number
@@ -585,6 +620,7 @@ const updatingPrice = ref(false)
const priceFormRef = ref(null)
const priceForm = reactive({
price: 0,
ui_component_price: 0,
discount: 10,
cost_multiple: 1.0,
adjustmentType: 'price' // 'price'、'discount' 或 'cost_multiple'
@@ -606,6 +642,10 @@ const priceRules = {
{ required: true, message: '请输入新价格', trigger: 'blur' },
{ type: 'number', min: 0, message: '价格不能小于0', trigger: 'blur' }
],
ui_component_price: [
{ required: false, message: '请输入UI组件价格', trigger: 'blur' },
{ type: 'number', min: 0, message: 'UI组件价格不能小于0', trigger: 'blur' }
],
discount: [
{ required: true, message: '请输入折扣比例', trigger: 'blur' },
{ type: 'number', min: 0.1, max: 10, message: '折扣比例必须在0.1-10之间', trigger: 'blur' }
@@ -671,6 +711,11 @@ const hasValidCostPrice = computed(() => {
return costPrice !== undefined && costPrice !== null && costPrice > 0
})
// 计算属性:检查是否有任何组合包产品
const hasAnyPackageProducts = computed(() => {
return subscriptions.value.some(sub => sub.product?.is_package || sub.product_admin?.is_package)
})
// 初始化
onMounted(async () => {
await checkSingleUserMode()
@@ -907,6 +952,14 @@ const handleCurrentChange = (page) => {
const handleEditPrice = (subscription) => {
selectedSubscription.value = subscription
priceForm.price = subscription.price
// 获取UI组件价格如果订阅中没有设置则从产品中获取
let uiComponentPrice = subscription.ui_component_price || 0
if (uiComponentPrice === 0 && (subscription.product?.is_package || subscription.product_admin?.is_package)) {
uiComponentPrice = subscription.product?.ui_component_price || subscription.product_admin?.ui_component_price || 0
}
priceForm.ui_component_price = uiComponentPrice
const productPrice = subscription.product?.price || subscription.product_admin?.price
priceForm.discount = calculateDiscount(productPrice, subscription.price)
if (subscription.product_admin?.cost_price) {
@@ -1014,9 +1067,20 @@ const handleUpdatePrice = async () => {
priceForm.price = finalPrice
}
await productAdminApi.updateSubscriptionPrice(selectedSubscription.value.id, {
// 构建请求数据
const requestData = {
price: finalPrice
})
}
// 如果是组合包包含UI组件价格
if (selectedSubscription.value.product?.is_package || selectedSubscription.value.product_admin?.is_package) {
// 只有在直接输入价格模式下才使用表单中的UI组件价格
if (priceForm.adjustmentType === 'price') {
requestData.ui_component_price = priceForm.ui_component_price
}
}
await productAdminApi.updateSubscriptionPrice(selectedSubscription.value.id, requestData)
ElMessage.success('价格调整成功')
priceDialogVisible.value = false

View File

@@ -317,6 +317,14 @@
</div>
</div>
</div>
<!-- 请求参数 -->
<div class="info-section">
<h4 class="text-lg font-semibold text-gray-900 mb-4">请求参数</h4>
<div class="info-item">
<span class="info-value">{{ selectedApiCall?.request_params || '-' }}</span>
</div>
</div>
</div>
<div v-else class="flex justify-center items-center py-8">
<el-loading size="large" />
@@ -464,6 +472,7 @@ const formatDateTime = (date) => {
return new Date(date).toLocaleString('zh-CN')
}
// 获取状态类型
const getStatusType = (status) => {
switch (status) {

View File

@@ -335,12 +335,12 @@
</div>
</div>
<div class="price-info" v-if="product.ui_component_price && !canDownloadReport">
<div class="price-info" v-if="currentUIComponentPrice && !canDownloadReport">
<h4>价格信息</h4>
<div class="price-summary">
<div class="price-row">
<span>价格</span>
<span class="total-price">¥{{ formatPrice(product.ui_component_price) }}</span>
<span class="total-price">¥{{ formatPrice(currentUIComponentPrice) }}</span>
</div>
</div>
</div>
@@ -426,6 +426,14 @@ const currentSubscription = computed(() => {
return userSubscriptions.value.find(sub => sub.product_id === product.value.id)
})
// 获取当前产品的UI组件价格优先使用订阅中的价格
const currentUIComponentPrice = computed(() => {
if (currentSubscription.value && currentSubscription.value.ui_component_price) {
return currentSubscription.value.ui_component_price
}
return product.value?.ui_component_price || 0
})
// 初始化
onMounted(() => {
loadUserSubscriptions()
@@ -1078,7 +1086,8 @@ const handleDownloadReport = async () => {
是否组合包: reportDownloadInfo.value.is_package,
子产品数量: reportDownloadInfo.value.sub_products?.length || 0,
子产品列表: reportDownloadInfo.value.sub_products,
价格: product.value.ui_component_price,
价格: currentUIComponentPrice.value,
价格来源: currentSubscription.value ? '用户订阅' : '产品默认',
可下载: reportDownloadInfo.value.can_download
})
} catch (error) {
@@ -1100,7 +1109,8 @@ const handleDownloadReport = async () => {
是否组合包: reportDownloadInfo.value.is_package,
子产品数量: reportDownloadInfo.value.sub_products?.length || 0,
子产品列表: reportDownloadInfo.value.sub_products,
价格: product.value.ui_component_price,
价格: currentUIComponentPrice.value,
价格来源: currentSubscription.value ? '用户订阅' : '产品默认',
可下载: reportDownloadInfo.value.can_download
})
}
@@ -1281,7 +1291,7 @@ const showWechatPaymentQRCode = (codeUrl, orderId) => {
}, '点击打开微信支付')
]),
h('div', { style: 'font-size: 14px; color: #666;' }, [
h('p', `支付金额:¥${formatPrice(product.value?.ui_component_price || 0)}`),
h('p', `支付金额:¥${formatPrice(currentUIComponentPrice)}`),
h('p', '支付完成后,请点击"我已支付"按钮')
])
])
@@ -1289,7 +1299,7 @@ const showWechatPaymentQRCode = (codeUrl, orderId) => {
})
]),
h('div', { style: 'font-size: 14px; color: #666;' }, [
h('p', `支付金额:¥${formatPrice(product.value?.ui_component_price || 0)}`),
h('p', `支付金额:¥${formatPrice(currentUIComponentPrice.value || 0)}`),
h('p', '支付完成后,系统将自动检测支付状态')
])
]),