fix:套餐界面按钮隐藏
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
v-model:columns="columnChecks"
|
v-model:columns="columnChecks"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:show-delete="false"
|
:show-delete="false"
|
||||||
:not-show-add="true"
|
:show-add="false"
|
||||||
@refresh="getData"
|
@refresh="getData"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,14 +75,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</AFormItem>
|
</AFormItem>
|
||||||
|
|
||||||
<AFormItem label="价格" name="price">
|
<AFormItem label="价格" name="price" :rules="[{ required: true, message: '请输入价格' }]">
|
||||||
<AInputNumber
|
<AInputNumber
|
||||||
v-model:value="formState.price"
|
v-model:value="formState.price"
|
||||||
placeholder="请输入价格"
|
placeholder="请输入价格"
|
||||||
:min="0"
|
:min="0"
|
||||||
:precision="2"
|
:precision="2"
|
||||||
addon-after="元"
|
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
:formatter="value => `¥ ${value}`"
|
||||||
|
:parser="value => (value || '').replace(/[¥\s,]/g, '')"
|
||||||
/>
|
/>
|
||||||
</AFormItem>
|
</AFormItem>
|
||||||
|
|
||||||
@@ -242,12 +243,7 @@ const { columns, columnChecks, data, loading, getData, mobilePagination } = useT
|
|||||||
dataIndex: 'price',
|
dataIndex: 'price',
|
||||||
title: '价格',
|
title: '价格',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
customRender: ({ text }) => {
|
customRender: ({ text }) => `${Number(text).toFixed(2)}`
|
||||||
if (typeof text === 'number') {
|
|
||||||
return `¥${text.toFixed(2)}`;
|
|
||||||
}
|
|
||||||
return text || '-';
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'traffic',
|
key: 'traffic',
|
||||||
@@ -332,18 +328,30 @@ const { columns, columnChecks, data, loading, getData, mobilePagination } = useT
|
|||||||
const showModal = ref(false);
|
const showModal = ref(false);
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
|
|
||||||
interface PackageForm extends Omit<Api.Auth.PackageAdd, 'traffic' | 'duration'> {
|
interface PackageForm {
|
||||||
|
id?: string;
|
||||||
|
packageName: string;
|
||||||
|
periodNum: number;
|
||||||
|
periodType: number;
|
||||||
|
price: string;
|
||||||
|
trafficEnable: boolean;
|
||||||
traffic: number;
|
traffic: number;
|
||||||
trafficUnit: StorageUnit;
|
trafficUnit: StorageUnit;
|
||||||
|
rateLimitEnable: boolean;
|
||||||
|
rateLimitId?: number;
|
||||||
|
durationEnable: boolean;
|
||||||
duration: number;
|
duration: number;
|
||||||
durationUnit: TimeUnit;
|
durationUnit: TimeUnit;
|
||||||
|
clientNumEnable: boolean;
|
||||||
|
clientNum: number;
|
||||||
|
packageEnable: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formState = ref<PackageForm>({
|
const formState = ref<PackageForm>({
|
||||||
packageName: '',
|
packageName: '',
|
||||||
periodNum: 1,
|
periodNum: 1,
|
||||||
periodType: 2,
|
periodType: 2,
|
||||||
price: 0,
|
price: '0',
|
||||||
trafficEnable: false,
|
trafficEnable: false,
|
||||||
traffic: 0,
|
traffic: 0,
|
||||||
trafficUnit: 'GB',
|
trafficUnit: 'GB',
|
||||||
@@ -456,7 +464,7 @@ const handleCancel = () => {
|
|||||||
packageName: '',
|
packageName: '',
|
||||||
periodNum: 1,
|
periodNum: 1,
|
||||||
periodType: 2,
|
periodType: 2,
|
||||||
price: 0,
|
price: '0',
|
||||||
trafficEnable: false,
|
trafficEnable: false,
|
||||||
traffic: 0,
|
traffic: 0,
|
||||||
trafficUnit: 'GB',
|
trafficUnit: 'GB',
|
||||||
@@ -474,16 +482,30 @@ const handleCancel = () => {
|
|||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
try {
|
try {
|
||||||
await formRef.value?.validate();
|
await formRef.value?.validate();
|
||||||
const submitData = {
|
// 准备基础数据
|
||||||
...formState.value,
|
const baseData = {
|
||||||
traffic: formState.value.trafficEnable
|
packageName: formState.value.packageName,
|
||||||
? Math.round(convertStorage(formState.value.traffic, formState.value.trafficUnit, 'B'))
|
periodNum: formState.value.periodNum,
|
||||||
: 0,
|
periodType: formState.value.periodType,
|
||||||
duration: formState.value.durationEnable
|
price: formState.value.price,
|
||||||
? Math.round(convertTime(formState.value.duration, formState.value.durationUnit, '秒'))
|
trafficEnable: formState.value.trafficEnable,
|
||||||
: 0
|
rateLimitEnable: formState.value.rateLimitEnable,
|
||||||
|
rateLimitId: formState.value.rateLimitId,
|
||||||
|
durationEnable: formState.value.durationEnable,
|
||||||
|
clientNumEnable: formState.value.clientNumEnable,
|
||||||
|
clientNum: formState.value.clientNum,
|
||||||
|
packageEnable: formState.value.packageEnable
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 计算流量和时长
|
||||||
|
const traffic = formState.value.trafficEnable
|
||||||
|
? Math.round(convertStorage(formState.value.traffic, formState.value.trafficUnit, 'B'))
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
const duration = formState.value.durationEnable
|
||||||
|
? Math.round(convertTime(formState.value.duration, formState.value.durationUnit, '秒'))
|
||||||
|
: 0;
|
||||||
|
|
||||||
if (isEdit.value) {
|
if (isEdit.value) {
|
||||||
if (!editId.value) {
|
if (!editId.value) {
|
||||||
message.error('编辑ID不能为空');
|
message.error('编辑ID不能为空');
|
||||||
@@ -491,13 +513,19 @@ const handleOk = async () => {
|
|||||||
}
|
}
|
||||||
// 编辑模式
|
// 编辑模式
|
||||||
await updatePackage({
|
await updatePackage({
|
||||||
...submitData,
|
...baseData,
|
||||||
id: editId.value
|
id: editId.value,
|
||||||
|
traffic,
|
||||||
|
duration
|
||||||
});
|
});
|
||||||
message.success('修改成功');
|
message.success('修改成功');
|
||||||
} else {
|
} else {
|
||||||
// 新增模式
|
// 新增模式
|
||||||
await addPackage(submitData);
|
await addPackage({
|
||||||
|
...baseData,
|
||||||
|
traffic,
|
||||||
|
duration
|
||||||
|
});
|
||||||
message.success('添加成功');
|
message.success('添加成功');
|
||||||
}
|
}
|
||||||
handleCancel();
|
handleCancel();
|
||||||
|
|||||||
Reference in New Issue
Block a user