mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vben.git
synced 2025-12-30 10:32:25 +00:00
feat:【ele】【mall】coupon 代码对齐 antd
This commit is contained in:
@@ -60,7 +60,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
rules: 'required',
|
rules: 'required',
|
||||||
defaultValue: PromotionProductScopeEnum.ALL.scope,
|
defaultValue: PromotionProductScopeEnum.ALL.scope,
|
||||||
},
|
},
|
||||||
// TODO @puhui999: 商品选择器优化
|
|
||||||
{
|
{
|
||||||
fieldName: 'productSpuIds',
|
fieldName: 'productSpuIds',
|
||||||
label: '商品',
|
label: '商品',
|
||||||
@@ -84,7 +83,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
},
|
},
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
// TODO @puhui999: 商品分类选择器优化
|
|
||||||
{
|
{
|
||||||
fieldName: 'productCategoryIds',
|
fieldName: 'productCategoryIds',
|
||||||
label: '商品分类',
|
label: '商品分类',
|
||||||
|
|||||||
@@ -16,11 +16,18 @@ import {
|
|||||||
updateCouponTemplate,
|
updateCouponTemplate,
|
||||||
} from '#/api/mall/promotion/coupon/couponTemplate';
|
} from '#/api/mall/promotion/coupon/couponTemplate';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
import { ProductCategorySelect } from '#/views/mall/product/category/components';
|
||||||
|
import { SpuShowcase } from '#/views/mall/product/spu/components';
|
||||||
|
|
||||||
import { useFormSchema } from '../data';
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
const formData = ref<MallCouponTemplateApi.CouponTemplate>();
|
const formData = ref<
|
||||||
|
Partial<MallCouponTemplateApi.CouponTemplate> & {
|
||||||
|
productCategoryIds?: number | number[];
|
||||||
|
productSpuIds?: number[];
|
||||||
|
}
|
||||||
|
>({});
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
return formData.value?.id
|
return formData.value?.id
|
||||||
? $t('ui.actionTitle.edit', ['优惠券模板'])
|
? $t('ui.actionTitle.edit', ['优惠券模板'])
|
||||||
@@ -64,7 +71,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
},
|
},
|
||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
formData.value = undefined;
|
formData.value = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载数据
|
// 加载数据
|
||||||
@@ -75,7 +82,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
formData.value = await getCouponTemplate(data.id);
|
formData.value = await getCouponTemplate(data.id);
|
||||||
const processedData = await processLoadData(formData.value);
|
const processedData = await processLoadData(formData.value as any);
|
||||||
// 设置到表单
|
// 设置到表单
|
||||||
await formApi.setValues(processedData);
|
await formApi.setValues(processedData);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -144,7 +151,15 @@ async function processLoadData(
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="getTitle" class="w-2/5">
|
<Modal :title="getTitle" class="w-2/5">
|
||||||
<Form class="mx-4" />
|
<Form class="mx-4">
|
||||||
<!-- TODO @puhui999:这里需要同步下 -->
|
<!-- 自定义插槽:商品选择 -->
|
||||||
|
<template #productSpuIds>
|
||||||
|
<SpuShowcase v-model="formData.productSpuIds" />
|
||||||
|
</template>
|
||||||
|
<!-- 自定义插槽:分类选择 -->
|
||||||
|
<template #productCategoryIds>
|
||||||
|
<ProductCategorySelect v-model="formData.productCategoryIds" />
|
||||||
|
</template>
|
||||||
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user