fixadd
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user