This commit is contained in:
@@ -61,177 +61,354 @@
|
||||
<ElDialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogType === 'add' ? '新增套餐' : '编辑套餐'"
|
||||
width="600px"
|
||||
width="60%"
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleDialogClosed"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="150px">
|
||||
<ElFormItem label="套餐编码" prop="package_code">
|
||||
<div style="display: flex; gap: 8px">
|
||||
<ElInput
|
||||
v-model="form.package_code"
|
||||
placeholder="请输入套餐编码或点击生成"
|
||||
:disabled="dialogType === 'edit'"
|
||||
clearable
|
||||
style="flex: 1"
|
||||
/>
|
||||
<ElButton v-if="dialogType === 'add'" @click="handleGeneratePackageCode">
|
||||
生成编码
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="套餐名称" prop="package_name">
|
||||
<ElInput v-model="form.package_name" placeholder="请输入套餐名称" clearable />
|
||||
</ElFormItem>
|
||||
<ElFormItem label="所属系列" prop="series_id">
|
||||
<ElSelect
|
||||
v-model="form.series_id"
|
||||
placeholder="请选择套餐系列"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="searchSeries"
|
||||
:loading="seriesLoading"
|
||||
clearable
|
||||
>
|
||||
<ElOption
|
||||
v-for="series in seriesOptions"
|
||||
:key="series.id"
|
||||
:label="series.series_name"
|
||||
:value="series.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="套餐类型" prop="package_type">
|
||||
<ElSelect
|
||||
v-model="form.package_type"
|
||||
placeholder="请选择套餐类型"
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in PACKAGE_TYPE_OPTIONS"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="套餐周期类型" prop="calendar_type">
|
||||
<ElSelect
|
||||
v-model="form.calendar_type"
|
||||
placeholder="请选择套餐周期类型"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
>
|
||||
<ElOption label="自然月" value="natural_month" />
|
||||
<ElOption label="按天" value="by_day" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="有效期(月)" prop="duration_months">
|
||||
<ElInputNumber
|
||||
v-model="form.duration_months"
|
||||
:min="1"
|
||||
:max="120"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入有效期(月)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
v-if="form.calendar_type === 'by_day'"
|
||||
label="套餐天数"
|
||||
prop="duration_days"
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="24">
|
||||
<ElFormItem label="套餐编码" prop="package_code">
|
||||
<div style="display: flex; gap: 8px">
|
||||
<ElInput
|
||||
v-model="form.package_code"
|
||||
placeholder="请输入套餐编码或点击生成"
|
||||
:disabled="dialogType === 'edit'"
|
||||
clearable
|
||||
/>
|
||||
<ElButton v-if="dialogType === 'add'" @click="handleGeneratePackageCode">
|
||||
生成编码
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="套餐名称" prop="package_name">
|
||||
<ElInput v-model="form.package_name" placeholder="请输入套餐名称" clearable />
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="所属系列" prop="series_id">
|
||||
<ElSelect
|
||||
v-model="form.series_id"
|
||||
placeholder="请选择套餐系列"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="searchSeries"
|
||||
:loading="seriesLoading"
|
||||
clearable
|
||||
>
|
||||
<ElOption
|
||||
v-for="series in seriesOptions"
|
||||
:key="series.id"
|
||||
:label="series.series_name"
|
||||
:value="series.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="套餐类型" prop="package_type">
|
||||
<ElSelect
|
||||
v-model="form.package_type"
|
||||
placeholder="请选择套餐类型"
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in PACKAGE_TYPE_OPTIONS"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="套餐周期类型" prop="calendar_type">
|
||||
<ElSelect
|
||||
v-model="form.calendar_type"
|
||||
placeholder="请选择套餐周期类型"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
>
|
||||
<ElOption label="自然月" value="natural_month" />
|
||||
<ElOption label="按天" value="by_day" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="有效期(月)" prop="duration_months">
|
||||
<ElInputNumber
|
||||
v-model="form.duration_months"
|
||||
:min="1"
|
||||
:max="120"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入有效期(月)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12" v-if="form.calendar_type === 'by_day'">
|
||||
<ElFormItem label="套餐天数" prop="duration_days">
|
||||
<ElInputNumber
|
||||
v-model="form.duration_days"
|
||||
:min="1"
|
||||
:max="3650"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入套餐天数"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12" v-if="form.calendar_type !== 'by_day'">
|
||||
<ElFormItem label="流量重置周期" prop="data_reset_cycle">
|
||||
<ElSelect
|
||||
v-model="form.data_reset_cycle"
|
||||
placeholder="请选择流量重置周期"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
>
|
||||
<ElOption label="每日" value="daily" />
|
||||
<ElOption label="每月" value="monthly" />
|
||||
<ElOption label="每年" value="yearly" />
|
||||
<ElOption label="不重置" value="none" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20" v-if="form.calendar_type === 'by_day'">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="流量重置周期" prop="data_reset_cycle">
|
||||
<ElSelect
|
||||
v-model="form.data_reset_cycle"
|
||||
placeholder="请选择流量重置周期"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
>
|
||||
<ElOption label="每日" value="daily" />
|
||||
<ElOption label="每月" value="monthly" />
|
||||
<ElOption label="每年" value="yearly" />
|
||||
<ElOption label="不重置" value="none" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="真流量额度(MB)" prop="real_data_mb">
|
||||
<ElInputNumber
|
||||
v-model="form.real_data_mb"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入真流量额度"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20" v-if="form.calendar_type !== 'by_day'">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="真流量额度(MB)" prop="real_data_mb">
|
||||
<ElInputNumber
|
||||
v-model="form.real_data_mb"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入真流量额度"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="启用虚流量">
|
||||
<ElSwitch
|
||||
v-model="form.enable_virtual_data"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20" v-if="form.calendar_type === 'by_day'">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="启用虚流量">
|
||||
<ElSwitch
|
||||
v-model="form.enable_virtual_data"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12" v-if="form.enable_virtual_data">
|
||||
<ElFormItem label="虚流量额度(MB)" prop="virtual_data_mb">
|
||||
<ElInputNumber
|
||||
v-model="form.virtual_data_mb"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入虚流量额度"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12" v-if="!form.enable_virtual_data">
|
||||
<ElFormItem label="启用实名激活">
|
||||
<ElSwitch
|
||||
v-model="form.enable_realname_activation"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20" v-if="form.calendar_type !== 'by_day' && form.enable_virtual_data">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="虚流量额度(MB)" prop="virtual_data_mb">
|
||||
<ElInputNumber
|
||||
v-model="form.virtual_data_mb"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入虚流量额度"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="启用实名激活">
|
||||
<ElSwitch
|
||||
v-model="form.enable_realname_activation"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20" v-if="form.calendar_type !== 'by_day' && !form.enable_virtual_data">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="启用实名激活">
|
||||
<ElSwitch
|
||||
v-model="form.enable_realname_activation"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="成本价(元)" prop="cost_price">
|
||||
<ElInputNumber
|
||||
v-model="form.cost_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入成本价"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20" v-if="form.calendar_type === 'by_day' && form.enable_virtual_data">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="启用实名激活">
|
||||
<ElSwitch
|
||||
v-model="form.enable_realname_activation"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="成本价(元)" prop="cost_price">
|
||||
<ElInputNumber
|
||||
v-model="form.cost_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入成本价"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow
|
||||
:gutter="20"
|
||||
v-if="
|
||||
(form.calendar_type !== 'by_day' && form.enable_virtual_data) ||
|
||||
(form.calendar_type === 'by_day' && !form.enable_virtual_data)
|
||||
"
|
||||
>
|
||||
<ElInputNumber
|
||||
v-model="form.duration_days"
|
||||
:min="1"
|
||||
:max="3650"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入套餐天数"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="流量重置周期" prop="data_reset_cycle">
|
||||
<ElSelect
|
||||
v-model="form.data_reset_cycle"
|
||||
placeholder="请选择流量重置周期"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
>
|
||||
<ElOption label="每日" value="daily" />
|
||||
<ElOption label="每月" value="monthly" />
|
||||
<ElOption label="每年" value="yearly" />
|
||||
<ElOption label="不重置" value="none" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="真流量额度(MB)" prop="real_data_mb">
|
||||
<ElInputNumber
|
||||
v-model="form.real_data_mb"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入真流量额度"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="启用虚流量">
|
||||
<ElSwitch
|
||||
v-model="form.enable_virtual_data"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
label="虚流量额度(MB)"
|
||||
prop="virtual_data_mb"
|
||||
v-if="form.enable_virtual_data"
|
||||
>
|
||||
<ElInputNumber
|
||||
v-model="form.virtual_data_mb"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入虚流量额度"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="启用实名激活">
|
||||
<ElSwitch
|
||||
v-model="form.enable_realname_activation"
|
||||
active-text="启用"
|
||||
inactive-text="不启用"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="成本价(元)" prop="cost_price">
|
||||
<ElInputNumber
|
||||
v-model="form.cost_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入成本价"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="建议售价(元)" prop="suggested_retail_price">
|
||||
<ElInputNumber
|
||||
v-model="form.suggested_retail_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入建议售价(可选)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="套餐描述" prop="description">
|
||||
<ElInput
|
||||
v-model="form.description"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入套餐描述(可选)"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="成本价(元)" prop="cost_price">
|
||||
<ElInputNumber
|
||||
v-model="form.cost_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入成本价"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="建议售价(元)" prop="suggested_retail_price">
|
||||
<ElInputNumber
|
||||
v-model="form.suggested_retail_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入建议售价(可选)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20" v-if="form.calendar_type === 'by_day' && form.enable_virtual_data">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="建议售价(元)" prop="suggested_retail_price">
|
||||
<ElInputNumber
|
||||
v-model="form.suggested_retail_price"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
placeholder="请输入建议售价(可选)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="24">
|
||||
<ElFormItem label="套餐描述" prop="description">
|
||||
<ElInput
|
||||
v-model="form.description"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入套餐描述(可选)"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@@ -258,7 +435,6 @@
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useTableContextMenu } from '@/composables/useTableContextMenu'
|
||||
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
|
||||
import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'
|
||||
import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'
|
||||
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
|
||||
@@ -398,6 +574,7 @@
|
||||
{ label: '套餐类型', prop: 'package_type' },
|
||||
{ label: '真流量', prop: 'real_data_mb' },
|
||||
{ label: '虚流量', prop: 'virtual_data_mb' },
|
||||
{ label: '虚流量比例', prop: 'virtual_ratio' },
|
||||
{ label: '有效期', prop: 'duration_months' },
|
||||
{ label: '成本价', prop: 'cost_price' },
|
||||
{ label: '建议售价', prop: 'suggested_retail_price' },
|
||||
@@ -519,6 +696,20 @@
|
||||
width: 100,
|
||||
formatter: (row: PackageResponse) => `${row.virtual_data_mb}MB`
|
||||
},
|
||||
{
|
||||
prop: 'virtual_ratio',
|
||||
label: '虚流量比例',
|
||||
width: 120,
|
||||
formatter: (row: PackageResponse) => {
|
||||
// 如果启用虚流量且虚流量大于0,计算比例
|
||||
if (row.enable_virtual_data && row.virtual_data_mb > 0) {
|
||||
const ratio = row.real_data_mb / row.virtual_data_mb
|
||||
return ratio.toFixed(2)
|
||||
}
|
||||
// 否则返回 1.0
|
||||
return '1.00'
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'duration_months',
|
||||
label: '有效期',
|
||||
|
||||
@@ -1809,10 +1809,14 @@
|
||||
}))
|
||||
}
|
||||
|
||||
// 可选:强制充值配置
|
||||
// 强制充值配置(无论开关状态都要传递)
|
||||
data.enable_force_recharge = form.enable_force_recharge
|
||||
if (form.enable_force_recharge) {
|
||||
data.enable_force_recharge = true
|
||||
// 启用时传递强充金额(分)
|
||||
data.force_recharge_amount = Math.round((form.force_recharge_amount || 0) * 100)
|
||||
} else {
|
||||
// 关闭时传递 0
|
||||
data.force_recharge_amount = 0
|
||||
}
|
||||
|
||||
// 可选:套餐配置(将元转换为分)
|
||||
|
||||
Reference in New Issue
Block a user