mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 15:09:20 +08:00
fix(ecom-dmb): 修复推广管理和刷单管理表单模态框问题
This commit is contained in:
+38
-35
@@ -47,16 +47,23 @@ interface Emits {
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
// 创建 vben modal
|
||||
// 与父组件 v-model:open 同步:遮罩/右上角关闭时也要 emit false,否则父级一直为 true 无法二次打开
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
destroyOnClose: false,
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleOk();
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
emit('update:open', false);
|
||||
resetFormData();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
@@ -110,41 +117,40 @@ const shopListLoading = ref(false);
|
||||
const feeTypeList = ref<PromotionFeeTypeVO.Info[]>([]);
|
||||
const feeTypeListLoading = ref(false);
|
||||
|
||||
// 监听props变化
|
||||
// 监听 props.open:先准备好表单再 open,关闭时同步 modalApi
|
||||
watch(
|
||||
() => props.open,
|
||||
async (newVal) => {
|
||||
if (newVal) {
|
||||
// 等渲染周期完成后再 open,避免 Slot 依赖追踪失效
|
||||
await nextTick();
|
||||
modalApi.open();
|
||||
isEdit.value = !!props.promotionFeeData;
|
||||
if (props.promotionFeeData) {
|
||||
// 编辑模式,填充表单数据
|
||||
formData.value = {
|
||||
shopId: props.promotionFeeData.shopId,
|
||||
feeTypeId: props.promotionFeeData.feeTypeId,
|
||||
feeName: props.promotionFeeData.feeName,
|
||||
platform: props.promotionFeeData.platform,
|
||||
campaignName: props.promotionFeeData.campaignName || '',
|
||||
feeAmount: props.promotionFeeData.feeAmount,
|
||||
baseAmount: props.promotionFeeData.baseAmount,
|
||||
feeRate: props.promotionFeeData.feeRate,
|
||||
clickCount: props.promotionFeeData.clickCount,
|
||||
impressionCount: props.promotionFeeData.impressionCount,
|
||||
conversionCount: props.promotionFeeData.conversionCount,
|
||||
feeDate: props.promotionFeeData.feeDate
|
||||
? dayjs(props.promotionFeeData.feeDate)
|
||||
: undefined,
|
||||
remark: props.promotionFeeData.remark || '',
|
||||
};
|
||||
} else {
|
||||
// 新增模式,重置表单数据
|
||||
resetFormData();
|
||||
}
|
||||
} else {
|
||||
if (!newVal) {
|
||||
modalApi.close();
|
||||
return;
|
||||
}
|
||||
isEdit.value = !!props.promotionFeeData;
|
||||
if (props.promotionFeeData) {
|
||||
formData.value = {
|
||||
shopId: props.promotionFeeData.shopId,
|
||||
feeTypeId: props.promotionFeeData.feeTypeId,
|
||||
feeName: props.promotionFeeData.feeName,
|
||||
platform: props.promotionFeeData.platform,
|
||||
campaignName: props.promotionFeeData.campaignName || '',
|
||||
feeAmount: props.promotionFeeData.feeAmount,
|
||||
baseAmount: props.promotionFeeData.baseAmount,
|
||||
feeRate: props.promotionFeeData.feeRate,
|
||||
clickCount: props.promotionFeeData.clickCount,
|
||||
impressionCount: props.promotionFeeData.impressionCount,
|
||||
conversionCount: props.promotionFeeData.conversionCount,
|
||||
feeDate: props.promotionFeeData.feeDate
|
||||
? dayjs(props.promotionFeeData.feeDate)
|
||||
: undefined,
|
||||
remark: props.promotionFeeData.remark || '',
|
||||
};
|
||||
} else {
|
||||
resetFormData();
|
||||
}
|
||||
await nextTick();
|
||||
modalApi.open();
|
||||
await nextTick();
|
||||
formRef.value?.clearValidate?.();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -218,19 +224,16 @@ const handleOk = async () => {
|
||||
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
} catch (error) {
|
||||
console.error('操作失败:', error);
|
||||
message.error(isEdit.value ? '更新失败' : '创建失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
// 取消:关闭与重置由 onOpenChange 统一处理
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
resetFormData();
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
|
||||
Reference in New Issue
Block a user