diff --git a/apps/web-antd/src/components/cropper/cropper-modal.vue b/apps/web-antd/src/components/cropper/cropper-modal.vue index 43e9766dc..d4edd11c9 100644 --- a/apps/web-antd/src/components/cropper/cropper-modal.vue +++ b/apps/web-antd/src/components/cropper/cropper-modal.vue @@ -43,15 +43,6 @@ const [Modal, modalApi] = useVbenModal({ if (isOpen) { // 打开时,进行 loading 加载。后续 CropperImage 组件加载完毕,会自动关闭 loading(通过 handleReady) modalLoading(true); - // TODO @puhui999:这里比 ele 多了,是符合预期的哇? - const img = new Image(); - img.src = src.value; - img.addEventListener('load', () => { - modalLoading(false); - }); - img.addEventListener('error', () => { - modalLoading(false); - }); } else { // 关闭时,清空右侧预览 previewSource.value = ''; diff --git a/apps/web-antd/src/components/form-create/components/use-images-upload.tsx b/apps/web-antd/src/components/form-create/components/use-images-upload.tsx index a9d0572b5..a57cbaa4b 100644 --- a/apps/web-antd/src/components/form-create/components/use-images-upload.tsx +++ b/apps/web-antd/src/components/form-create/components/use-images-upload.tsx @@ -15,9 +15,8 @@ export function useImagesUpload() { default: 5, }, }, - setup() { - // TODO: @puhui999:@dhb52 其实还是靠 props 默认参数起作用,没能从 formCreate 传递 - return (props: { maxNumber?: number; multiple?: boolean }) => ( + setup(props) { + return () => ( ); }, diff --git a/apps/web-antd/src/views/mall/promotion/article/data.ts b/apps/web-antd/src/views/mall/promotion/article/data.ts index 9f10b9377..5af659775 100644 --- a/apps/web-antd/src/views/mall/promotion/article/data.ts +++ b/apps/web-antd/src/views/mall/promotion/article/data.ts @@ -96,14 +96,10 @@ export function useFormSchema(): VbenFormSchema[] { defaultValue: true, }, { - // TODO: @puhui999:商品关联 fieldName: 'spuId', label: '商品关联', component: 'Input', formItemClass: 'col-span-2', - componentProps: { - placeholder: '请输入商品 SPU 编号', - }, }, { fieldName: 'sort', diff --git a/apps/web-antd/src/views/mall/promotion/article/modules/form.vue b/apps/web-antd/src/views/mall/promotion/article/modules/form.vue index b8a8487b8..0e73e0eca 100644 --- a/apps/web-antd/src/views/mall/promotion/article/modules/form.vue +++ b/apps/web-antd/src/views/mall/promotion/article/modules/form.vue @@ -14,6 +14,7 @@ import { updateArticle, } from '#/api/mall/promotion/article'; import { $t } from '#/locales'; +import { SpuShowcase } from '#/views/mall/product/spu/components'; import { useFormSchema } from '../data'; @@ -41,6 +42,10 @@ const [Form, formApi] = useVbenForm({ const [Modal, modalApi] = useVbenModal({ async onConfirm() { + // 同步商品选择到表单,确保验证时能获取到值 + if (formData.value?.spuId) { + await formApi.setFieldValue('spuId', formData.value.spuId); + } const { valid } = await formApi.validate(); if (!valid) { return; @@ -82,6 +87,11 @@ const [Modal, modalApi] = useVbenModal({ diff --git a/apps/web-antd/src/views/mall/promotion/coupon/template/modules/form.vue b/apps/web-antd/src/views/mall/promotion/coupon/template/modules/form.vue index b015eb7f4..23bc87900 100644 --- a/apps/web-antd/src/views/mall/promotion/coupon/template/modules/form.vue +++ b/apps/web-antd/src/views/mall/promotion/coupon/template/modules/form.vue @@ -49,6 +49,19 @@ const [Form, formApi] = useVbenForm({ const [Modal, modalApi] = useVbenModal({ async onConfirm() { + // 同步商品/分类选择到表单,确保验证时能获取到值 + if (formData.value.productSpuIds) { + await formApi.setFieldValue( + 'productSpuIds', + formData.value.productSpuIds, + ); + } + if (formData.value.productCategoryIds) { + await formApi.setFieldValue( + 'productCategoryIds', + formData.value.productCategoryIds, + ); + } const { valid } = await formApi.validate(); if (!valid) { return; diff --git a/apps/web-antd/src/views/mall/promotion/discountActivity/modules/form.vue b/apps/web-antd/src/views/mall/promotion/discountActivity/modules/form.vue index f1a9a5690..a0eff3e1d 100644 --- a/apps/web-antd/src/views/mall/promotion/discountActivity/modules/form.vue +++ b/apps/web-antd/src/views/mall/promotion/discountActivity/modules/form.vue @@ -10,7 +10,9 @@ import type { import { computed, nextTick, ref } from 'vue'; import { useVbenForm, useVbenModal } from '@vben/common-ui'; +import { PromotionDiscountTypeEnum } from '@vben/constants'; import { + cloneDeep, convertToInteger, erpCalculatePercentage, formatToFraction, @@ -39,13 +41,6 @@ defineOptions({ name: 'DiscountActivityForm' }); const emit = defineEmits(['success']); -/** 折扣类型枚举 */ -// TODO @puhui999:这里可以使用 biz-mall 里的枚举噢; -const PromotionDiscountTypeEnum = { - PRICE: { type: 1 }, // 满减 - PERCENT: { type: 2 }, // 折扣 -}; - // ================= 表单相关 ================= const formData = ref>({}); const getTitle = computed(() => { @@ -243,8 +238,7 @@ const [Modal, modalApi] = useVbenModal({ // 提交表单 try { // 获取折扣商品配置 - // TODO @puhui999:structuredClone 执行会报错; - const products = structuredClone( + const products = cloneDeep( spuAndSkuListRef.value?.getSkuConfigs('productConfig') || [], ) as MallDiscountActivityApi.DiscountProduct[]; // 转换金额为分 @@ -252,7 +246,7 @@ const [Modal, modalApi] = useVbenModal({ item.discountPercent = convertToInteger(item.discountPercent); item.discountPrice = convertToInteger(item.discountPrice); }); - const data = structuredClone( + const data = cloneDeep( await formApi.getValues(), ) as MallDiscountActivityApi.DiscountActivity; data.products = products; diff --git a/apps/web-antd/src/views/mall/promotion/rewardActivity/modules/form.vue b/apps/web-antd/src/views/mall/promotion/rewardActivity/modules/form.vue index 282d7ceea..4a35c0316 100644 --- a/apps/web-antd/src/views/mall/promotion/rewardActivity/modules/form.vue +++ b/apps/web-antd/src/views/mall/promotion/rewardActivity/modules/form.vue @@ -52,9 +52,21 @@ const [Form, formApi] = useVbenForm({ const [Modal, modalApi] = useVbenModal({ async onConfirm() { - // 在验证前同步 formData.rules 到表单中 - // TODO @puhui999:选择了分类、或者商品,还是报没选择; + // 在验证前同步 formData 中的值到表单中 await formApi.setFieldValue('rules', formData.value.rules || []); + // 同步商品/分类选择到表单,确保验证时能获取到值 + if (formData.value.productSpuIds) { + await formApi.setFieldValue( + 'productSpuIds', + formData.value.productSpuIds, + ); + } + if (formData.value.productCategoryIds) { + await formApi.setFieldValue( + 'productCategoryIds', + formData.value.productCategoryIds, + ); + } const { valid } = await formApi.validate(); if (!valid) { return; diff --git a/apps/web-ele/src/components/cropper/cropper-avatar.vue b/apps/web-ele/src/components/cropper/cropper-avatar.vue index 62bc20c42..0c537022b 100644 --- a/apps/web-ele/src/components/cropper/cropper-avatar.vue +++ b/apps/web-ele/src/components/cropper/cropper-avatar.vue @@ -6,6 +6,7 @@ import type { CropperAvatarProps } from './typing'; import { computed, ref, unref, watch, watchEffect } from 'vue'; import { useVbenModal } from '@vben/common-ui'; +import { IconifyIcon } from '@vben/icons'; import { $t } from '@vben/locales'; import { ElButton, ElMessage } from 'element-plus'; @@ -83,16 +84,16 @@ defineExpose({ class="duration-400 absolute inset-0 flex cursor-pointer items-center justify-center rounded-full bg-black bg-opacity-40 opacity-0 transition-opacity group-hover:opacity-100" :style="getImageWrapperStyle" > - - + />