feat:【antd】【mall】优化满减送的界面

This commit is contained in:
YunaiV
2025-11-29 11:17:37 +08:00
parent 56409edff4
commit 0ffebd6de4
2 changed files with 136 additions and 105 deletions

View File

@@ -102,46 +102,53 @@ onMounted(async () => {
</script> </script>
<template> <template>
<div class="w-full"> <div>
<Button type="link" class="pl-0" @click="handleSelect">添加优惠券</Button> <!-- 已选优惠券列表 -->
<div v-if="list.length > 0" class="mb-2 flex flex-col gap-2">
<div <div
v-for="(item, index) in list" v-for="(item, index) in list"
:key="item.id" :key="item.id"
class="coupon-list-item mb-2 flex justify-between rounded-lg border border-dashed border-gray-300 p-2" class="flex items-center justify-between rounded-md border border-gray-200 bg-white px-3 py-2 transition-all hover:border-blue-400 hover:shadow-sm"
> >
<div class="coupon-list-item-left flex flex-wrap items-center gap-2"> <div class="flex flex-wrap items-center gap-3">
<div>优惠券名称{{ item.name }}</div> <span class="font-medium text-gray-800">{{ item.name }}</span>
<div> <span class="flex items-center gap-1 text-sm text-gray-500">
范围
<DictTag <DictTag
:type="DICT_TYPE.PROMOTION_PRODUCT_SCOPE" :type="DICT_TYPE.PROMOTION_PRODUCT_SCOPE"
:value="item.productScope" :value="item.productScope"
/> />
</div> </span>
<div class="flex items-center"> <span class="flex items-center gap-1 text-sm text-gray-500">
优惠
<DictTag <DictTag
:type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE" :type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE"
:value="item.discountType" :value="item.discountType"
/> />
{{ discountFormat(item) }} {{ discountFormat(item) }}
</span>
</div> </div>
</div> <div class="flex shrink-0 items-center gap-2">
<div class="coupon-list-item-right flex items-center gap-2"> <span class="text-gray-500"></span>
<span></span>
<Input <Input
v-model:value="item.giveCount" v-model:value="item.giveCount"
class="!w-150px" class="!w-20"
placeholder="" placeholder=""
type="number" type="number"
size="small"
/> />
<span></span> <span class="text-gray-500"></span>
<Button type="link" danger @click="handleDelete(index)">删除</Button> <Button type="link" danger size="small" @click="handleDelete(index)">
删除
</Button>
</div>
</div> </div>
</div> </div>
<!-- 优惠券选择 --> <!-- 添加按钮 -->
<Button type="link" class="!pl-0" @click="handleSelect">
+ 添加优惠券
</Button>
<!-- 优惠券选择弹窗 -->
<CouponSelect <CouponSelect
ref="selectRef" ref="selectRef"
:take-type="CouponTemplateTakeTypeEnum.ADMIN.type" :take-type="CouponTemplateTakeTypeEnum.ADMIN.type"

View File

@@ -8,6 +8,7 @@ import { PromotionConditionTypeEnum } from '@vben/constants';
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
import { import {
Button, Button,
Card,
Col, Col,
Form, Form,
FormItem, FormItem,
@@ -61,24 +62,32 @@ function handleDelete(ruleIndex: number) {
<Row :gutter="[16, 16]"> <Row :gutter="[16, 16]">
<template v-if="formData.rules"> <template v-if="formData.rules">
<Col v-for="(rule, index) in formData.rules" :key="index" :span="24"> <Col v-for="(rule, index) in formData.rules" :key="index" :span="24">
<Card size="small" class="rounded-lg">
<!-- 规则标题 --> <!-- 规则标题 -->
<div class="mb-4 flex items-center"> <template #title>
<span class="text-base font-bold">活动层级 {{ index + 1 }}</span> <div class="flex items-center">
<span class="text-base font-medium">
活动层级 {{ index + 1 }}
</span>
</div>
</template>
<template v-if="index !== 0" #extra>
<Button <Button
v-if="index !== 0"
type="link" type="link"
danger danger
class="ml-2" size="small"
@click="handleDelete(index)" @click="handleDelete(index)"
> >
删除 删除
</Button> </Button>
</div> </template>
<Form :model="rule" layout="horizontal"> <Form :model="rule" layout="horizontal">
<!-- 优惠门槛 --> <!-- 优惠门槛 -->
<FormItem label="优惠门槛" :label-col="{ span: 4 }"> <FormItem label="优惠门槛:" :colon="false" class="mb-3">
<div class="flex items-center gap-2"> <div
class="flex items-center gap-2 rounded-md bg-gray-50 px-3 py-2"
>
<span></span> <span></span>
<InputNumber <InputNumber
v-if="isPriceCondition" v-if="isPriceCondition"
@@ -101,14 +110,15 @@ function handleDelete(ruleIndex: number) {
</div> </div>
</FormItem> </FormItem>
<!-- 优惠内容 --> <!-- 优惠内容 -->
<FormItem <FormItem label="优惠内容:" :colon="false" class="!mb-0">
label="优惠内容" <div class="flex flex-col gap-3">
:label-col="{ span: 4 }" <!-- 订单金额优惠 -->
:wrapper-col="{ span: 20 }" <div
class="flex items-center gap-2 rounded-md bg-gray-50 px-3 py-2"
> >
<div class="flex flex-col gap-2"> <span class="!w-21 shrink-0 text-sm text-gray-500">
<span>订单金额优惠</span> 订单金额优惠
<div class="flex items-center gap-2"> </span>
<span></span> <span></span>
<InputNumber <InputNumber
v-model:value="rule.discountPrice" v-model:value="rule.discountPrice"
@@ -120,17 +130,24 @@ function handleDelete(ruleIndex: number) {
/> />
<span></span> <span></span>
</div> </div>
<div class="flex items-center gap-2"> <!-- 包邮 -->
<span>包邮:</span> <div
class="flex items-center gap-2 rounded-md bg-gray-50 px-3 py-2"
>
<span class="w-20 shrink-0 text-sm text-gray-500">包邮</span>
<Switch <Switch
v-model:checked="rule.freeDelivery" v-model:checked="rule.freeDelivery"
checked-children="" checked-children=""
un-checked-children="" un-checked-children=""
/> />
</div> </div>
<div> <!-- 送积分 -->
<div>送积分:</div> <div
<div class="mt-2 flex items-center gap-2"> class="flex items-center gap-2 rounded-md bg-gray-50 px-3 py-2"
>
<span class="w-20 shrink-0 text-sm text-gray-500">
送积分
</span>
<span></span> <span></span>
<InputNumber <InputNumber
v-model:value="rule.point" v-model:value="rule.point"
@@ -140,17 +157,24 @@ function handleDelete(ruleIndex: number) {
/> />
<span>积分</span> <span>积分</span>
</div> </div>
</div> <!-- 送优惠券 -->
<div class="flex items-center gap-2"> <div
<span class="w-20">送优惠券:</span> class="flex flex-col items-start gap-2 rounded-md bg-gray-50 px-3 py-2"
>
<span class="w-20 shrink-0 text-sm text-gray-500">
送优惠券
</span>
<RewardRuleCouponSelect <RewardRuleCouponSelect
:model-value="rule" :model-value="rule"
@update:model-value="(val) => (formData.rules![index] = val)" @update:model-value="
(val) => (formData.rules![index] = val)
"
/> />
</div> </div>
</div> </div>
</FormItem> </FormItem>
</Form> </Form>
</Card>
</Col> </Col>
</template> </template>