This commit is contained in:
xingyu4j
2025-11-12 09:58:23 +08:00
47 changed files with 1016 additions and 799 deletions

View File

@@ -59,7 +59,7 @@ onMounted(async () => {
}" }"
:multiple="multiple" :multiple="multiple"
:tree-checkable="multiple" :tree-checkable="multiple"
class="w-1/1" class="w-full"
placeholder="请选择商品分类" placeholder="请选择商品分类"
allow-clear allow-clear
tree-default-expand-all tree-default-expand-all

View File

@@ -0,0 +1,2 @@
export { default as CombinationShowcase } from './showcase.vue';

View File

@@ -0,0 +1,146 @@
<!-- 拼团活动橱窗组件用于展示和选择拼团活动 -->
<script lang="ts" setup>
import type { MallCombinationActivityApi } from '#/api/mall/promotion/combination/combinationActivity';
import { computed, ref, watch } from 'vue';
import { CloseCircleFilled, PlusOutlined } from '@vben/icons';
import { Image, Tooltip } from 'ant-design-vue';
import { getCombinationActivityListByIds } from '#/api/mall/promotion/combination/combinationActivity';
import CombinationTableSelect from './table-select.vue';
interface CombinationShowcaseProps {
modelValue?: number | number[];
limit?: number;
disabled?: boolean;
}
const props = withDefaults(defineProps<CombinationShowcaseProps>(), {
modelValue: undefined,
limit: Number.MAX_VALUE,
disabled: false,
});
const emit = defineEmits(['update:modelValue', 'change']);
const activityList = ref<MallCombinationActivityApi.CombinationActivity[]>([]); // 已选择的活动列表
const combinationTableSelectRef =
ref<InstanceType<typeof CombinationTableSelect>>(); // 活动选择表格组件引用
const isMultiple = computed(() => props.limit !== 1); // 是否为多选模式
/** 计算是否可以添加 */
const canAdd = computed(() => {
if (props.disabled) {
return false;
}
if (!props.limit) {
return true;
}
return activityList.value.length < props.limit;
});
/** 监听 modelValue 变化,加载活动详情 */
watch(
() => props.modelValue,
async (newValue) => {
// eslint-disable-next-line unicorn/no-nested-ternary
const ids = Array.isArray(newValue) ? newValue : newValue ? [newValue] : [];
if (ids.length === 0) {
activityList.value = [];
return;
}
// 只有活动发生变化时才重新查询
if (
activityList.value.length === 0 ||
activityList.value.some((activity) => !ids.includes(activity.id!))
) {
activityList.value = await getCombinationActivityListByIds(ids);
}
},
{ immediate: true },
);
/** 打开活动选择对话框 */
function handleOpenActivitySelect() {
combinationTableSelectRef.value?.open(activityList.value);
}
/** 选择活动后触发 */
function handleActivitySelected(
activities:
| MallCombinationActivityApi.CombinationActivity
| MallCombinationActivityApi.CombinationActivity[],
) {
activityList.value = Array.isArray(activities) ? activities : [activities];
emitActivityChange();
}
/** 删除活动 */
function handleRemoveActivity(index: number) {
activityList.value.splice(index, 1);
emitActivityChange();
}
/** 触发变更事件 */
function emitActivityChange() {
if (props.limit === 1) {
const activity =
activityList.value.length > 0 ? activityList.value[0] : null;
emit('update:modelValue', activity?.id || 0);
emit('change', activity);
} else {
emit(
'update:modelValue',
activityList.value.map((activity) => activity.id!),
);
emit('change', activityList.value);
}
}
</script>
<template>
<div class="flex flex-wrap items-center gap-2">
<!-- 已选活动列表 -->
<div
v-for="(activity, index) in activityList"
:key="activity.id"
class="group relative h-[60px] w-[60px] overflow-hidden rounded-lg"
>
<Tooltip :title="activity.name">
<div class="relative h-full w-full">
<Image
:src="activity.picUrl"
class="h-full w-full rounded-lg object-cover"
/>
<!-- 删除按钮 -->
<CloseCircleFilled
v-if="!disabled"
class="absolute -right-2 -top-2 cursor-pointer text-xl text-red-500 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100"
@click="handleRemoveActivity(index)"
/>
</div>
</Tooltip>
</div>
<!-- 添加活动按钮 -->
<Tooltip v-if="canAdd" title="选择活动">
<div
class="hover:border-primary hover:bg-primary/5 flex h-[60px] w-[60px] cursor-pointer items-center justify-center rounded-lg border-2 border-dashed transition-colors"
@click="handleOpenActivitySelect"
>
<PlusOutlined class="text-xl text-gray-400" />
</div>
</Tooltip>
</div>
<!-- 活动选择对话框 -->
<CombinationTableSelect
ref="combinationTableSelectRef"
:multiple="isMultiple"
@change="handleActivitySelected"
/>
</template>

View File

@@ -0,0 +1,285 @@
<!-- 拼团活动选择弹窗组件 -->
<script lang="ts" setup>
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { MallCategoryApi } from '#/api/mall/product/category';
import type { MallCombinationActivityApi } from '#/api/mall/promotion/combination/combinationActivity';
import { computed, onMounted, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { fenToYuan, formatDate, handleTree } from '@vben/utils';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getCategoryList } from '#/api/mall/product/category';
import { getCombinationActivityPage } from '#/api/mall/promotion/combination/combinationActivity';
interface CombinationTableSelectProps {
multiple?: boolean; // 是否多选true - checkboxfalse - radio
}
const props = withDefaults(defineProps<CombinationTableSelectProps>(), {
multiple: false,
});
const emit = defineEmits<{
change: [
activity:
| MallCombinationActivityApi.CombinationActivity
| MallCombinationActivityApi.CombinationActivity[],
];
}>();
const categoryList = ref<MallCategoryApi.Category[]>([]); // 分类列表
const categoryTreeList = ref<any[]>([]); // 分类树
/** 单选:处理选中变化 */
function handleRadioChange() {
const selectedRow =
gridApi.grid.getRadioRecord() as MallCombinationActivityApi.CombinationActivity;
if (selectedRow) {
emit('change', selectedRow);
modalApi.close();
}
}
/**
* 格式化拼团价格
* @param products
*/
const formatCombinationPrice = (
products: MallCombinationActivityApi.CombinationProduct[],
) => {
if (!products || products.length === 0) return '-';
const combinationPrice = Math.min(
...products.map((item) => item.combinationPrice || 0),
);
return `${fenToYuan(combinationPrice)}`;
};
/** 搜索表单 Schema */
const formSchema = computed<VbenFormSchema[]>(() => [
{
fieldName: 'name',
label: '活动名称',
component: 'Input',
componentProps: {
placeholder: '请输入活动名称',
clearable: true,
},
},
{
fieldName: 'status',
label: '活动状态',
component: 'Select',
componentProps: {
placeholder: '请选择活动状态',
clearable: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
},
},
]);
/** 表格列配置 */
const gridColumns = computed<VxeGridProps['columns']>(() => {
const columns: VxeGridProps['columns'] = [];
if (props.multiple) {
columns.push({ type: 'checkbox', width: 55 });
} else {
columns.push({ type: 'radio', width: 55 });
}
columns.push(
{
field: 'id',
title: '活动编号',
minWidth: 80,
},
{
field: 'name',
title: '活动名称',
minWidth: 140,
},
{
field: 'activityTime',
title: '活动时间',
minWidth: 210,
formatter: ({ row }) => {
return `${formatDate(row.startTime, 'YYYY-MM-DD')} ~ ${formatDate(row.endTime, 'YYYY-MM-DD')}`;
},
},
{
field: 'picUrl',
title: '商品图片',
width: 100,
cellRender: {
name: 'CellImage',
},
},
{
field: 'spuName',
title: '商品标题',
minWidth: 300,
},
{
field: 'marketPrice',
title: '原价',
minWidth: 100,
formatter: ({ cellValue }) => {
return cellValue ? `${fenToYuan(cellValue)}` : '-';
},
},
{
field: 'products',
title: '拼团价',
minWidth: 100,
formatter: ({ cellValue }) => {
return formatCombinationPrice(cellValue);
},
},
{
field: 'groupCount',
title: '开团组数',
minWidth: 100,
},
{
field: 'groupSuccessCount',
title: '成团组数',
minWidth: 100,
},
{
field: 'recordCount',
title: '购买次数',
minWidth: 100,
},
{
field: 'status',
title: '活动状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
},
},
{
field: 'createTime',
title: '创建时间',
width: 180,
formatter: 'formatDateTime',
},
);
return columns;
});
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: formSchema.value,
layout: 'horizontal',
collapsed: false,
},
gridOptions: {
columns: gridColumns.value,
height: 500,
border: true,
checkboxConfig: {
reserve: true,
},
radioConfig: {
reserve: true,
},
rowConfig: {
keyField: 'id',
isHover: true,
},
proxyConfig: {
ajax: {
async query({ page }: any, formValues: any) {
return await getCombinationActivityPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
},
gridEvents: {
radioChange: handleRadioChange,
},
});
const [Modal, modalApi] = useVbenModal({
destroyOnClose: true,
showConfirmButton: props.multiple, // 特殊radio 单选情况下,走 handleRadioChange 处理。
onConfirm: () => {
const selectedRows =
gridApi.grid.getCheckboxRecords() as MallCombinationActivityApi.CombinationActivity[];
emit('change', selectedRows);
modalApi.close();
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
gridApi.grid.clearCheckboxRow();
gridApi.grid.clearRadioRow();
return;
}
// 1. 先查询数据
await gridApi.query();
// 2. 设置已选中行
const data = modalApi.getData<
| MallCombinationActivityApi.CombinationActivity
| MallCombinationActivityApi.CombinationActivity[]
>();
if (props.multiple && Array.isArray(data) && data.length > 0) {
setTimeout(() => {
const tableData = gridApi.grid.getTableData().fullData;
data.forEach((activity) => {
const row = tableData.find(
(item: MallCombinationActivityApi.CombinationActivity) =>
item.id === activity.id,
);
if (row) {
gridApi.grid.setCheckboxRow(row, true);
}
});
}, 300);
} else if (!props.multiple && data && !Array.isArray(data)) {
setTimeout(() => {
const tableData = gridApi.grid.getTableData().fullData;
const row = tableData.find(
(item: MallCombinationActivityApi.CombinationActivity) =>
item.id === data.id,
);
if (row) {
gridApi.grid.setRadioRow(row);
}
}, 300);
}
},
});
/** 对外暴露的方法 */
defineExpose({
open: (
data?:
| MallCombinationActivityApi.CombinationActivity
| MallCombinationActivityApi.CombinationActivity[],
) => {
modalApi.setData(data).open();
},
});
/** 初始化分类数据 */
onMounted(async () => {
categoryList.value = await getCategoryList({});
categoryTreeList.value = handleTree(categoryList.value, 'id', 'parentId');
});
</script>
<template>
<Modal title="选择活动" class="w-[950px]">
<Grid />
</Modal>
</template>

View File

@@ -22,10 +22,13 @@ const handleIndexChange = (index: number) => {
<template> <template>
<!-- 无图片 --> <!-- 无图片 -->
<div <div
class="bg-card flex h-64 items-center justify-center" class="flex items-center justify-center bg-gray-300"
:style="{
height: property.items.length === 0 ? '250px' : `${property.height}px`,
}"
v-if="property.items.length === 0" v-if="property.items.length === 0"
> >
<IconifyIcon icon="tdesign:image" class="size-6 text-gray-800" /> <IconifyIcon icon="tdesign:image" class="text-[120px] text-gray-800" />
</div> </div>
<div v-else class="relative"> <div v-else class="relative">
<Carousel <Carousel
@@ -33,7 +36,7 @@ const handleIndexChange = (index: number) => {
:autoplay-speed="property.interval * 1000" :autoplay-speed="property.interval * 1000"
:dots="property.indicator !== 'number'" :dots="property.indicator !== 'number'"
@change="handleIndexChange" @change="handleIndexChange"
class="h-44" :style="{ height: `${property.height}px` }"
> >
<div v-for="(item, index) in property.items" :key="index"> <div v-for="(item, index) in property.items" :key="index">
<Image <Image
@@ -45,7 +48,7 @@ const handleIndexChange = (index: number) => {
</Carousel> </Carousel>
<div <div
v-if="property.indicator === 'number'" v-if="property.indicator === 'number'"
class="absolute bottom-2.5 right-2.5 rounded-xl bg-black px-2 py-1 text-xs text-white opacity-40" class="absolute bottom-[10px] right-[10px] rounded-xl bg-black px-[8px] py-[2px] text-[10px] text-white opacity-40"
> >
{{ currentIndex }} / {{ property.items.length }} {{ currentIndex }} / {{ property.items.length }}
</div> </div>

View File

@@ -7,6 +7,7 @@ import { useVModel } from '@vueuse/core';
import { import {
Form, Form,
FormItem, FormItem,
InputNumber,
Radio, Radio,
RadioButton, RadioButton,
RadioGroup, RadioGroup,
@@ -37,7 +38,7 @@ const formData = useVModel(props, 'modelValue', emit);
<p class="text-base font-bold">样式设置</p> <p class="text-base font-bold">样式设置</p>
<div class="flex flex-col gap-2 rounded-md p-4 shadow-lg"> <div class="flex flex-col gap-2 rounded-md p-4 shadow-lg">
<FormItem label="样式" prop="type"> <FormItem label="样式" prop="type">
<RadioGroup v-model="formData.type"> <RadioGroup v-model:value="formData.type">
<Tooltip class="item" content="默认" placement="bottom"> <Tooltip class="item" content="默认" placement="bottom">
<RadioButton value="default"> <RadioButton value="default">
<IconifyIcon icon="system-uicons:carousel" class="size-6" /> <IconifyIcon icon="system-uicons:carousel" class="size-6" />
@@ -50,18 +51,26 @@ const formData = useVModel(props, 'modelValue', emit);
</Tooltip> </Tooltip>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem label="高度" prop="height">
<InputNumber
v-model:value="formData.height"
class="mr-[10px] !w-1/2"
controls-position="right"
/>
px
</FormItem>
<FormItem label="指示器" prop="indicator"> <FormItem label="指示器" prop="indicator">
<RadioGroup v-model="formData.indicator"> <RadioGroup v-model:value="formData.indicator">
<Radio value="dot">小圆点</Radio> <Radio value="dot">小圆点</Radio>
<Radio value="number">数字</Radio> <Radio value="number">数字</Radio>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem label="是否轮播" prop="autoplay"> <FormItem label="是否轮播" prop="autoplay">
<Switch v-model="formData.autoplay" /> <Switch v-model:checked="formData.autoplay" />
</FormItem> </FormItem>
<FormItem label="播放间隔" prop="interval" v-if="formData.autoplay"> <FormItem label="播放间隔" prop="interval" v-if="formData.autoplay">
<Slider <Slider
v-model="formData.interval" v-model:value="formData.interval"
:max="10" :max="10"
:min="0.5" :min="0.5"
:step="0.5" :step="0.5"
@@ -77,7 +86,7 @@ const formData = useVModel(props, 'modelValue', emit);
<Draggable v-model="formData.items" :empty-item="{ type: 'img' }"> <Draggable v-model="formData.items" :empty-item="{ type: 'img' }">
<template #default="{ element }"> <template #default="{ element }">
<FormItem label="类型" prop="type" class="mb-2" label-width="40px"> <FormItem label="类型" prop="type" class="mb-2" label-width="40px">
<RadioGroup v-model="element.type"> <RadioGroup v-model:value="element.type">
<Radio value="img">图片</Radio> <Radio value="img">图片</Radio>
<Radio value="video">视频</Radio> <Radio value="video">视频</Radio>
</RadioGroup> </RadioGroup>

View File

@@ -1,4 +1,87 @@
// 导出所有优惠券相关组件 import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
export { CouponDiscount } from './coupon-discount';
export { CouponDiscountDesc } from './coupon-discount-desc'; import { defineComponent } from 'vue';
export { CouponValidTerm } from './coupon-validTerm';
import {
CouponTemplateValidityTypeEnum,
PromotionDiscountTypeEnum,
} from '@vben/constants';
import { floatToFixed2, formatDate } from '@vben/utils';
/** 有效期 */
export const CouponValidTerm = defineComponent({
name: 'CouponValidTerm',
props: {
coupon: {
type: Object as () => MallCouponTemplateApi.CouponTemplate,
required: true,
},
},
setup(props) {
const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
const text =
coupon.validityType === CouponTemplateValidityTypeEnum.DATE.type
? `有效期:${formatDate(coupon.validStartTime, 'YYYY-MM-DD')}${formatDate(
coupon.validEndTime,
'YYYY-MM-DD',
)}`
: `领取后第 ${coupon.fixedStartTerm} - ${coupon.fixedEndTerm} 天内可用`;
return () => <div>{text}</div>;
},
});
/** 优惠值 */
export const CouponDiscount = defineComponent({
name: 'CouponDiscount',
props: {
coupon: {
type: Object as () => MallCouponTemplateApi.CouponTemplate,
required: true,
},
},
setup(props) {
const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
// 折扣
let value = `${(coupon.discountPercent ?? 0) / 10}`;
let suffix = ' 折';
// 满减
if (coupon.discountType === PromotionDiscountTypeEnum.PRICE.type) {
value = floatToFixed2(coupon.discountPrice);
suffix = ' 元';
}
return () => (
<div>
<span class={'text-20px font-bold'}>{value}</span>
<span>{suffix}</span>
</div>
);
},
});
/** 优惠描述 */
export const CouponDiscountDesc = defineComponent({
name: 'CouponDiscountDesc',
props: {
coupon: {
type: Object as () => MallCouponTemplateApi.CouponTemplate,
required: true,
},
},
setup(props) {
const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
// 使用条件
const useCondition =
coupon.usePrice > 0 ? `${floatToFixed2(coupon.usePrice)}元,` : '';
// 优惠描述
const discountDesc =
coupon.discountType === PromotionDiscountTypeEnum.PRICE.type
? `${floatToFixed2(coupon.discountPrice)}`
: `${(coupon.discountPercent ?? 0) / 10}`;
return () => (
<div>
<span>{useCondition}</span>
<span>{discountDesc}</span>
</div>
);
},
});

View File

@@ -1,34 +0,0 @@
import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
import { defineComponent } from 'vue';
import { PromotionDiscountTypeEnum } from '@vben/constants';
import { floatToFixed2 } from '@vben/utils';
// 优惠描述
export const CouponDiscountDesc = defineComponent({
name: 'CouponDiscountDesc',
props: {
coupon: {
type: Object as () => MallCouponTemplateApi.CouponTemplate,
required: true,
},
},
setup(props) {
const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
// 使用条件
const useCondition =
coupon.usePrice > 0 ? `${floatToFixed2(coupon.usePrice)}元,` : '';
// 优惠描述
const discountDesc =
coupon.discountType === PromotionDiscountTypeEnum.PRICE.type
? `${floatToFixed2(coupon.discountPrice)}`
: `${(coupon.discountPercent ?? 0) / 10}`;
return () => (
<div>
<span>{useCondition}</span>
<span>{discountDesc}</span>
</div>
);
},
});

View File

@@ -1,34 +0,0 @@
import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
import { defineComponent } from 'vue';
import { PromotionDiscountTypeEnum } from '@vben/constants';
import { floatToFixed2 } from '@vben/utils';
// 优惠值
export const CouponDiscount = defineComponent({
name: 'CouponDiscount',
props: {
coupon: {
type: Object as () => MallCouponTemplateApi.CouponTemplate,
required: true,
},
},
setup(props) {
const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
// 折扣
let value = `${(coupon.discountPercent ?? 0) / 10}`;
let suffix = ' 折';
// 满减
if (coupon.discountType === PromotionDiscountTypeEnum.PRICE.type) {
value = floatToFixed2(coupon.discountPrice);
suffix = ' 元';
}
return () => (
<div>
<span class={'text-20px font-bold'}>{value}</span>
<span>{suffix}</span>
</div>
);
},
});

View File

@@ -1,28 +0,0 @@
import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
import { defineComponent } from 'vue';
import { CouponTemplateValidityTypeEnum } from '@vben/constants';
import { formatDate } from '@vben/utils';
// 有效期
export const CouponValidTerm = defineComponent({
name: 'CouponValidTerm',
props: {
coupon: {
type: Object as () => MallCouponTemplateApi.CouponTemplate,
required: true,
},
},
setup(props) {
const coupon = props.coupon as MallCouponTemplateApi.CouponTemplate;
const text =
coupon.validityType === CouponTemplateValidityTypeEnum.DATE.type
? `有效期:${formatDate(coupon.validStartTime, 'YYYY-MM-DD')}${formatDate(
coupon.validEndTime,
'YYYY-MM-DD',
)}`
: `领取后第 ${coupon.fixedStartTerm} - ${coupon.fixedEndTerm} 天内可用`;
return () => <div>{text}</div>;
},
});

View File

@@ -13,12 +13,19 @@ import {
CouponValidTerm, CouponValidTerm,
} from './component'; } from './component';
/** 商品卡片 */ /** 优惠劵卡片 */
defineOptions({ name: 'CouponCard' }); defineOptions({ name: 'CouponCard' });
// 定义属性
/** 定义属性 */
const props = defineProps<{ property: CouponCardProperty }>(); const props = defineProps<{ property: CouponCardProperty }>();
// 商品列表
const couponList = ref<MallCouponTemplateApi.CouponTemplate[]>([]); const couponList = ref<MallCouponTemplateApi.CouponTemplate[]>([]); // 优惠劵列表
const phoneWidth = ref(375); // 手机宽度
const containerRef = ref(); // 容器引用
const scrollbarWidth = ref('100%'); // 滚动条宽度
const couponWidth = ref(375); // 优惠券宽度
/** 监听优惠券 ID 变化,加载优惠券列表 */
watch( watch(
() => props.property.couponIds, () => props.property.couponIds,
async () => { async () => {
@@ -32,15 +39,7 @@ watch(
}, },
); );
// 手机宽度 /** 计算布局参数 */
const phoneWidth = ref(384);
// 容器
const containerRef = ref();
// 滚动条宽度
const scrollbarWidth = ref('100%');
// 优惠券的宽度
const couponWidth = ref(384);
// 计算布局参数
watch( watch(
() => [props.property, phoneWidth, couponList.value.length], () => [props.property, phoneWidth, couponList.value.length],
() => { () => {
@@ -56,9 +55,10 @@ watch(
}, },
{ immediate: true, deep: true }, { immediate: true, deep: true },
); );
/** 初始化 */
onMounted(() => { onMounted(() => {
// 提取手机宽度 phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 375;
phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 384;
}); });
</script> </script>
<template> <template>
@@ -82,17 +82,14 @@ onMounted(() => {
v-for="(coupon, index) in couponList" v-for="(coupon, index) in couponList"
:key="index" :key="index"
> >
<!-- 布局11--> <!-- 布局 11 -->
<div <div
v-if="property.columns === 1" v-if="property.columns === 1"
class="ml-4 flex flex-row justify-between p-2" class="ml-4 flex flex-row justify-between p-2"
> >
<div class="flex flex-col justify-evenly gap-1"> <div class="flex flex-col justify-evenly gap-1">
<!-- 优惠值 -->
<CouponDiscount :coupon="coupon" /> <CouponDiscount :coupon="coupon" />
<!-- 优惠描述 -->
<CouponDiscountDesc :coupon="coupon" /> <CouponDiscountDesc :coupon="coupon" />
<!-- 有效期 -->
<CouponValidTerm :coupon="coupon" /> <CouponValidTerm :coupon="coupon" />
</div> </div>
<div class="flex flex-col justify-evenly"> <div class="flex flex-col justify-evenly">
@@ -107,17 +104,14 @@ onMounted(() => {
</div> </div>
</div> </div>
</div> </div>
<!-- 布局22--> <!-- 布局 22 -->
<div <div
v-else-if="property.columns === 2" v-else-if="property.columns === 2"
class="ml-4 flex flex-row justify-between p-2" class="ml-4 flex flex-row justify-between p-2"
> >
<div class="flex flex-col justify-evenly gap-1"> <div class="flex flex-col justify-evenly gap-1">
<!-- 优惠值 -->
<CouponDiscount :coupon="coupon" /> <CouponDiscount :coupon="coupon" />
<!-- 优惠描述 -->
<CouponDiscountDesc :coupon="coupon" /> <CouponDiscountDesc :coupon="coupon" />
<!-- 领取说明 -->
<div v-if="coupon.totalCount >= 0"> <div v-if="coupon.totalCount >= 0">
仅剩{{ coupon.totalCount - coupon.takeCount }} 仅剩{{ coupon.totalCount - coupon.takeCount }}
</div> </div>
@@ -135,11 +129,9 @@ onMounted(() => {
</div> </div>
</div> </div>
</div> </div>
<!-- 布局33--> <!-- 布局 33 -->
<div v-else class="flex flex-col items-center justify-around gap-1 p-1"> <div v-else class="flex flex-col items-center justify-around gap-1 p-1">
<!-- 优惠值 -->
<CouponDiscount :coupon="coupon" /> <CouponDiscount :coupon="coupon" />
<!-- 优惠描述 -->
<CouponDiscountDesc :coupon="coupon" /> <CouponDiscountDesc :coupon="coupon" />
<div <div
class="rounded-full px-2 py-0.5" class="rounded-full px-2 py-0.5"

View File

@@ -5,23 +5,20 @@ import { ref } from 'vue';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
import { Button, Image, message } from 'ant-design-vue'; import { Button, Image } from 'ant-design-vue';
/** 悬浮按钮 */ /** 悬浮按钮 */
defineOptions({ name: 'FloatingActionButton' }); defineOptions({ name: 'FloatingActionButton' });
// 定义属性
/** 定义属性 */
defineProps<{ property: FloatingActionButtonProperty }>(); defineProps<{ property: FloatingActionButtonProperty }>();
// 是否展开 const expanded = ref(false); // 是否展开
const expanded = ref(false);
// 处理展开/折叠
const handleToggleFab = () => {
expanded.value = !expanded.value;
};
const handleActive = (index: number) => { /** 处理展开/折叠 */
message.success(`点击了${index}`); function handleToggleFab() {
}; expanded.value = !expanded.value;
}
</script> </script>
<template> <template>
<div <div
@@ -38,9 +35,8 @@ const handleActive = (index: number) => {
v-for="(item, index) in property.list" v-for="(item, index) in property.list"
:key="index" :key="index"
class="flex flex-col items-center" class="flex flex-col items-center"
@click="handleActive(index)"
> >
<Image :src="item.imgUrl" fit="contain" class="h-7 w-7"> <Image :src="item.imgUrl" fit="contain" class="!h-7 !w-7">
<template #error> <template #error>
<div class="flex h-full w-full items-center justify-center"> <div class="flex h-full w-full items-center justify-center">
<IconifyIcon <IconifyIcon
@@ -64,33 +60,15 @@ const handleActive = (index: number) => {
<Button type="primary" size="large" circle @click="handleToggleFab"> <Button type="primary" size="large" circle @click="handleToggleFab">
<IconifyIcon <IconifyIcon
icon="lucide:plus" icon="lucide:plus"
class="fab-icon" class="transition-transform duration-300"
:class="[{ active: expanded }]" :class="expanded ? 'rotate-[135deg]' : 'rotate-0'"
/> />
</Button> </Button>
</div> </div>
<!-- 模态背景展开时显示点击后折叠 --> <!-- 模态背景展开时显示点击后折叠 -->
<div v-if="expanded" class="modal-bg" @click="handleToggleFab"></div> <div
v-if="expanded"
class="absolute left-[calc(50%-384px/2)] top-0 z-[11] h-full w-[384px] bg-black/40"
@click="handleToggleFab"
></div>
</template> </template>
<style scoped lang="scss">
/* 模态背景 */
.modal-bg {
position: absolute;
top: 0;
left: calc(50% - 384px / 2);
z-index: 11;
width: 384px;
height: 100%;
background-color: rgb(0 0 0 / 40%);
}
.fab-icon {
transform: rotate(0deg);
transition: transform 0.3s;
&.active {
transform: rotate(135deg);
}
}
</style>

View File

@@ -2,10 +2,9 @@ import type { StyleValue } from 'vue';
import type { HotZoneItemProperty } from '../../config'; import type { HotZoneItemProperty } from '../../config';
// 热区的最小宽高 export const HOT_ZONE_MIN_SIZE = 100; // 热区的最小宽高
export const HOT_ZONE_MIN_SIZE = 100;
// 控制的类型 /** 控制的类型 */
export enum CONTROL_TYPE_ENUM { export enum CONTROL_TYPE_ENUM {
LEFT, LEFT,
TOP, TOP,
@@ -13,14 +12,14 @@ export enum CONTROL_TYPE_ENUM {
HEIGHT, HEIGHT,
} }
// 定义热区的控制点 /** 定义热区的控制点 */
export interface ControlDot { export interface ControlDot {
position: string; position: string;
types: CONTROL_TYPE_ENUM[]; types: CONTROL_TYPE_ENUM[];
style: StyleValue; style: StyleValue;
} }
// 热区的8个控制点 /** 热区的 8 个控制点 */
export const CONTROL_DOT_LIST = [ export const CONTROL_DOT_LIST = [
{ {
position: '左上角', position: '左上角',
@@ -98,10 +97,10 @@ export const CONTROL_DOT_LIST = [
] as ControlDot[]; ] as ControlDot[];
// region 热区的缩放 // region 热区的缩放
// 热区的缩放比例 export const HOT_ZONE_SCALE_RATE = 2; // 热区的缩放比例
export const HOT_ZONE_SCALE_RATE = 2;
// 缩小:缩回适合手机屏幕的大小 /** 缩小:缩回适合手机屏幕的大小 */
export const zoomOut = (list?: HotZoneItemProperty[]) => { export function zoomOut(list?: HotZoneItemProperty[]) {
return ( return (
list?.map((hotZone) => ({ list?.map((hotZone) => ({
...hotZone, ...hotZone,
@@ -111,9 +110,10 @@ export const zoomOut = (list?: HotZoneItemProperty[]) => {
height: (hotZone.height /= HOT_ZONE_SCALE_RATE), height: (hotZone.height /= HOT_ZONE_SCALE_RATE),
})) || [] })) || []
); );
}; }
// 放大:作用是为了方便在电脑屏幕上编辑
export const zoomIn = (list?: HotZoneItemProperty[]) => { /** 放大:作用是为了方便在电脑屏幕上编辑 */
export function zoomIn(list?: HotZoneItemProperty[]) {
return ( return (
list?.map((hotZone) => ({ list?.map((hotZone) => ({
...hotZone, ...hotZone,
@@ -123,7 +123,8 @@ export const zoomIn = (list?: HotZoneItemProperty[]) => {
height: (hotZone.height *= HOT_ZONE_SCALE_RATE), height: (hotZone.height *= HOT_ZONE_SCALE_RATE),
})) || [] })) || []
); );
}; }
// endregion // endregion
/** /**

View File

@@ -11,7 +11,7 @@ import { IconifyIcon } from '@vben/icons';
import { Button, Image } from 'ant-design-vue'; import { Button, Image } from 'ant-design-vue';
import AppLinkSelectDialog from '#/views/mall/promotion/components/app-link-input/app-link-select-dialog.vue'; import { AppLinkSelectDialog } from '#/views/mall/promotion/components';
import { import {
CONTROL_DOT_LIST, CONTROL_DOT_LIST,
@@ -213,8 +213,9 @@ const handleAppLinkChange = (appLink: AppLink) => {
</span> </span>
<IconifyIcon <IconifyIcon
icon="lucide:x" icon="lucide:x"
class="absolute inset-0 right-0 top-0 hidden size-6 cursor-pointer items-center rounded-bl-[80%] p-[2px_2px_6px_6px] text-right text-white group-hover:block" class="absolute right-0 top-0 hidden cursor-pointer rounded-bl-[80%] p-[2px_2px_6px_6px] text-right text-white group-hover:block"
:style="{ backgroundColor: 'hsl(var(--primary))' }" :style="{ backgroundColor: 'hsl(var(--primary))' }"
:size="14"
@click="handleRemove(item)" @click="handleRemove(item)"
/> />
@@ -230,9 +231,7 @@ const handleAppLinkChange = (appLink: AppLink) => {
</div> </div>
<template #prepend-footer> <template #prepend-footer>
<Button @click="handleAdd" type="primary" ghost> <Button @click="handleAdd" type="primary" ghost>
<template #icon> <IconifyIcon icon="lucide:plus" class="mr-5px" />
<IconifyIcon icon="lucide:plus" />
</template>
添加热区 添加热区
</Button> </Button>
</template> </template>

View File

@@ -2,8 +2,10 @@
import type { HotZoneProperty } from './config'; import type { HotZoneProperty } from './config';
import { Image } from 'ant-design-vue'; import { Image } from 'ant-design-vue';
/** 热区 */ /** 热区 */
defineOptions({ name: 'HotZone' }); defineOptions({ name: 'HotZone' });
const props = defineProps<{ property: HotZoneProperty }>(); const props = defineProps<{ property: HotZoneProperty }>();
</script> </script>
@@ -12,21 +14,23 @@ const props = defineProps<{ property: HotZoneProperty }>();
<Image <Image
:src="props.property.imgUrl" :src="props.property.imgUrl"
class="pointer-events-none h-full w-full select-none" class="pointer-events-none h-full w-full select-none"
:preview="false"
/> />
<div <div
v-for="(item, index) in props.property.list" v-for="(item, index) in props.property.list"
:key="index" :key="index"
class="bg-primary-700 absolute z-10 flex cursor-move items-center justify-center border text-sm opacity-80" class="absolute z-10 flex cursor-move items-center justify-center border text-sm opacity-80"
:style="{ :style="{
width: `${item.width}px`, width: `${item.width}px`,
height: `${item.height}px`, height: `${item.height}px`,
top: `${item.top}px`, top: `${item.top}px`,
left: `${item.left}px`, left: `${item.left}px`,
color: 'hsl(var(--primary))',
background: 'color-mix(in srgb, hsl(var(--primary)) 30%, transparent)',
borderColor: 'hsl(var(--primary))',
}" }"
> >
<p class="text-primary"> {{ item.name }}
{{ item.name }}
</p>
</div> </div>
</div> </div>
</template> </template>

View File

@@ -15,42 +15,40 @@ import HotZoneEditDialog from './components/hot-zone-edit-dialog/index.vue';
defineOptions({ name: 'HotZoneProperty' }); defineOptions({ name: 'HotZoneProperty' });
const props = defineProps<{ modelValue: HotZoneProperty }>(); const props = defineProps<{ modelValue: HotZoneProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
// 热区编辑对话框 const editDialogRef = ref(); // 热区编辑对话框
const editDialogRef = ref();
// 打开热区编辑对话框 /** 打开热区编辑对话框 */
const handleOpenEditDialog = () => { function handleOpenEditDialog() {
editDialogRef.value.open(); editDialogRef.value.open();
}; }
</script> </script>
<template> <template>
<ComponentContainerProperty v-model="formData.style"> <ComponentContainerProperty v-model="formData.style">
<!-- 表单 --> <!-- 表单 -->
<Form <Form label-width="80px" :model="formData" class="mt-2">
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
:model="formData"
class="mt-2"
>
<FormItem label="上传图片" prop="imgUrl"> <FormItem label="上传图片" prop="imgUrl">
<UploadImg <UploadImg
v-model="formData.imgUrl" v-model="formData.imgUrl"
height="50px" height="50px"
width="auto" width="auto"
class="min-w-20" class="min-w-[80px]"
:show-description="false" :show-description="false"
/> />
<p class="text-xs text-gray-500">推荐宽度 750</p>
</FormItem> </FormItem>
<p class="text-center text-sm text-gray-500">推荐宽度 750</p>
</Form> </Form>
<Button type="primary" class="mt-4 w-full" @click="handleOpenEditDialog"> <Button type="primary" plain class="w-full" @click="handleOpenEditDialog">
设置热区 设置热区
</Button> </Button>
</ComponentContainerProperty> </ComponentContainerProperty>
<!-- 热区编辑对话框 --> <!-- 热区编辑对话框 -->
<HotZoneEditDialog <HotZoneEditDialog
ref="editDialogRef" ref="editDialogRef"
@@ -58,26 +56,3 @@ const handleOpenEditDialog = () => {
:img-url="formData.imgUrl" :img-url="formData.imgUrl"
/> />
</template> </template>
<style scoped lang="scss">
.hot-zone {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: hsl(var(--text-color));
cursor: move;
background: color-mix(in srgb, hsl(var(--primary)) 30%, transparent);
border: 1px solid hsl(var(--primary));
/* 控制点 */
.ctrl-dot {
position: absolute;
width: 4px;
height: 4px;
background-color: #fff;
border-radius: 50%;
}
}
</style>

View File

@@ -9,9 +9,11 @@ import { Image } from 'ant-design-vue';
/** 广告魔方 */ /** 广告魔方 */
defineOptions({ name: 'MagicCube' }); defineOptions({ name: 'MagicCube' });
const props = defineProps<{ property: MagicCubeProperty }>(); const props = defineProps<{ property: MagicCubeProperty }>();
// 一个方块的大小
const CUBE_SIZE = 93.75; const CUBE_SIZE = 93.75; // 一个方块的大小
/** /**
* 计算方块的行数 * 计算方块的行数
* 行数用于计算魔方的总体高度,存在以下情况: * 行数用于计算魔方的总体高度,存在以下情况:

View File

@@ -57,6 +57,7 @@ const handleHotAreaSelected = (_: any, index: number) => {
</FormItem> </FormItem>
</template> </template>
</template> </template>
<!-- TODO @芋艿距离不一致需要看看怎么统一 -->
<FormItem label="上圆角" name="borderRadiusTop"> <FormItem label="上圆角" name="borderRadiusTop">
<Slider v-model:value="formData.borderRadiusTop" :max="100" :min="0" /> <Slider v-model:value="formData.borderRadiusTop" :max="100" :min="0" />
</FormItem> </FormItem>

View File

@@ -5,6 +5,7 @@ import { Image } from 'ant-design-vue';
/** 宫格导航 */ /** 宫格导航 */
defineOptions({ name: 'MenuGrid' }); defineOptions({ name: 'MenuGrid' });
defineProps<{ property: MenuGridProperty }>(); defineProps<{ property: MenuGridProperty }>();
</script> </script>

View File

@@ -9,6 +9,7 @@ import {
AppLinkInput, AppLinkInput,
ColorInput, ColorInput,
Draggable, Draggable,
InputWithColor,
} from '#/views/mall/promotion/components'; } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
@@ -18,7 +19,9 @@ import { EMPTY_MENU_GRID_ITEM_PROPERTY } from './config';
defineOptions({ name: 'MenuGridProperty' }); defineOptions({ name: 'MenuGridProperty' });
const props = defineProps<{ modelValue: MenuGridProperty }>(); const props = defineProps<{ modelValue: MenuGridProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>
@@ -27,12 +30,11 @@ const formData = useVModel(props, 'modelValue', emit);
<!-- 表单 --> <!-- 表单 -->
<Form label-width="80px" :model="formData" class="mt-2"> <Form label-width="80px" :model="formData" class="mt-2">
<FormItem label="每行数量" prop="column"> <FormItem label="每行数量" prop="column">
<RadioGroup v-model="formData.column"> <RadioGroup v-model:value="formData.column">
<Radio :value="3">3</Radio> <Radio :value="3">3</Radio>
<Radio :value="4">4</Radio> <Radio :value="4">4</Radio>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<p class="text-base font-bold">菜单设置</p> <p class="text-base font-bold">菜单设置</p>
<div class="flex flex-col gap-2 rounded-md p-4 shadow-lg"> <div class="flex flex-col gap-2 rounded-md p-4 shadow-lg">
<Draggable <Draggable
@@ -47,17 +49,17 @@ const formData = useVModel(props, 'modelValue', emit);
width="80px" width="80px"
:show-description="false" :show-description="false"
> >
<template #tip> 建议尺寸44 * 44 </template> <template #tip> 建议尺寸44 * 44</template>
</UploadImg> </UploadImg>
</FormItem> </FormItem>
<FormItem label="标题" prop="title"> <FormItem label="标题" prop="title">
<ColorInput <InputWithColor
v-model="element.title" v-model="element.title"
v-model:color="element.titleColor" v-model:color="element.titleColor"
/> />
</FormItem> </FormItem>
<FormItem label="副标题" prop="subtitle"> <FormItem label="副标题" prop="subtitle">
<ColorInput <InputWithColor
v-model="element.subtitle" v-model="element.subtitle"
v-model:color="element.subtitleColor" v-model:color="element.subtitleColor"
/> />
@@ -70,7 +72,7 @@ const formData = useVModel(props, 'modelValue', emit);
</FormItem> </FormItem>
<template v-if="element.badge.show"> <template v-if="element.badge.show">
<FormItem label="角标内容" prop="badge.text"> <FormItem label="角标内容" prop="badge.text">
<ColorInput <InputWithColor
v-model="element.badge.text" v-model="element.badge.text"
v-model:color="element.badge.textColor" v-model:color="element.badge.textColor"
/> />

View File

@@ -7,6 +7,7 @@ import { Image } from 'ant-design-vue';
/** 列表导航 */ /** 列表导航 */
defineOptions({ name: 'MenuList' }); defineOptions({ name: 'MenuList' });
defineProps<{ property: MenuListProperty }>(); defineProps<{ property: MenuListProperty }>();
</script> </script>

View File

@@ -7,6 +7,7 @@ import { Image } from 'ant-design-vue';
/** 菜单导航 */ /** 菜单导航 */
defineOptions({ name: 'MenuSwiper' }); defineOptions({ name: 'MenuSwiper' });
const props = defineProps<{ property: MenuSwiperProperty }>(); const props = defineProps<{ property: MenuSwiperProperty }>();
const TITLE_HEIGHT = 20; // 标题的高度 const TITLE_HEIGHT = 20; // 标题的高度
@@ -71,9 +72,7 @@ watch(
class="relative flex flex-col items-center justify-center" class="relative flex flex-col items-center justify-center"
:style="{ width: columnWidth, height: `${rowHeight}px` }" :style="{ width: columnWidth, height: `${rowHeight}px` }"
> >
<!-- 图标 + 角标 -->
<div class="relative" :class="`h-${ICON_SIZE}px w-${ICON_SIZE}px`"> <div class="relative" :class="`h-${ICON_SIZE}px w-${ICON_SIZE}px`">
<!-- 右上角角标 -->
<span <span
v-if="item.badge?.show" v-if="item.badge?.show"
class="absolute -right-2.5 -top-2.5 z-10 h-5 rounded-[10px] px-1.5 text-center text-xs leading-5" class="absolute -right-2.5 -top-2.5 z-10 h-5 rounded-[10px] px-1.5 text-center text-xs leading-5"
@@ -91,7 +90,6 @@ watch(
:preview="false" :preview="false"
/> />
</div> </div>
<!-- 标题 -->
<span <span
v-if="property.layout === 'iconText'" v-if="property.layout === 'iconText'"
class="text-xs" class="text-xs"

View File

@@ -1,18 +1,18 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { NavigationBarCellProperty } from '../config'; import type { NavigationBarCellProperty } from '../config';
import type { Rect } from '#/views/mall/promotion/components/magic-cube-editor/util';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
import { import {
FormItem, FormItem,
Image,
Input, Input,
Radio, Radio,
RadioButton,
RadioGroup, RadioGroup,
Slider, Slider,
Switch,
Tooltip,
} from 'ant-design-vue'; } from 'ant-design-vue';
import appNavBarMp from '#/assets/imgs/diy/app-nav-bar-mp.png'; import appNavBarMp from '#/assets/imgs/diy/app-nav-bar-mp.png';
@@ -23,7 +23,7 @@ import {
MagicCubeEditor, MagicCubeEditor,
} from '#/views/mall/promotion/components'; } from '#/views/mall/promotion/components';
// 导航栏属性面板 /** 导航栏单元格属性面板 */
defineOptions({ name: 'NavigationBarCellProperty' }); defineOptions({ name: 'NavigationBarCellProperty' });
const props = defineProps({ const props = defineProps({
@@ -36,54 +36,64 @@ const props = defineProps({
default: () => [], default: () => [],
}, },
}); });
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const cellList = useVModel(props, 'modelValue', emit); const cellList = useVModel(props, 'modelValue', emit);
// 单元格数量小程序6个右侧胶囊按钮占了2个其它平台8个 /**
* 计算单元格数量
* 1. 小程序6 个(因为右侧有胶囊按钮占据 2 个格子的空间)
* 2. 其它平台8 个(全部空间可用)
*/
const cellCount = computed(() => (props.isMp ? 6 : 8)); const cellCount = computed(() => (props.isMp ? 6 : 8));
// 转换为Rect格式的数据 const selectedHotAreaIndex = ref(0); // 选中的热区
const rectList = computed<Rect[]>(() => {
return cellList.value.map((cell) => ({
left: cell.left,
top: cell.top,
width: cell.width,
height: cell.height,
right: cell.left + cell.width,
bottom: cell.top + cell.height,
}));
});
// 选中的热区 /** 处理热区被选中事件 */
const selectedHotAreaIndex = ref(0); function handleHotAreaSelected(
const handleHotAreaSelected = (
cellValue: NavigationBarCellProperty, cellValue: NavigationBarCellProperty,
index: number, index: number,
) => { ) {
selectedHotAreaIndex.value = index; selectedHotAreaIndex.value = index;
// 默认设置为选中文字,并设置属性
if (!cellValue.type) { if (!cellValue.type) {
cellValue.type = 'text'; cellValue.type = 'text';
cellValue.textColor = '#111111'; cellValue.textColor = '#111111';
} }
}; // 如果点击的是搜索框,则初始化搜索框的属性
if (cellValue.type === 'search') {
cellValue.placeholderPosition = 'left';
cellValue.backgroundColor = '#EEEEEE';
cellValue.textColor = '#969799';
}
}
</script> </script>
<template> <template>
<div class="h-40px flex items-center justify-center"> <div class="h-40px flex items-center justify-center">
<MagicCubeEditor <MagicCubeEditor
v-model="rectList" v-model="cellList as any"
:cols="cellCount" :cols="cellCount"
:cube-size="38" :cube-size="38"
:rows="1" :rows="1"
class="m-b-16px" class="m-b-16px"
@hot-area-selected="handleHotAreaSelected" @hot-area-selected="handleHotAreaSelected"
/> />
<Image v-if="isMp" alt="" class="w-19 h-8" :src="appNavBarMp" /> <img
v-if="isMp"
alt=""
style="width: 76px; height: 30px"
:src="appNavBarMp"
/>
</div> </div>
<template v-for="(cell, cellIndex) in cellList" :key="cellIndex"> <template v-for="(cell, cellIndex) in cellList" :key="cellIndex">
<template v-if="selectedHotAreaIndex === Number(cellIndex)"> <template v-if="selectedHotAreaIndex === Number(cellIndex)">
<FormItem label="类型"> <FormItem :prop="`cell[${cellIndex}].type`" label="类型">
<RadioGroup v-model:value="cell.type"> <RadioGroup
v-model:value="cell.type"
@change="handleHotAreaSelected(cell, cellIndex)"
>
<Radio value="text">文字</Radio> <Radio value="text">文字</Radio>
<Radio value="image">图片</Radio> <Radio value="image">图片</Radio>
<Radio value="search">搜索框</Radio> <Radio value="search">搜索框</Radio>
@@ -91,38 +101,69 @@ const handleHotAreaSelected = (
</FormItem> </FormItem>
<!-- 1. 文字 --> <!-- 1. 文字 -->
<template v-if="cell.type === 'text'"> <template v-if="cell.type === 'text'">
<FormItem label="内容"> <FormItem :prop="`cell[${cellIndex}].text`" label="内容">
<Input v-model:value="cell!.text" :maxlength="10" show-count /> <Input v-model:value="cell!.text" :maxlength="10" show-count />
</FormItem> </FormItem>
<FormItem label="颜色"> <FormItem :prop="`cell[${cellIndex}].text`" label="颜色">
<ColorInput v-model="cell!.textColor" /> <ColorInput v-model="cell!.textColor" />
</FormItem> </FormItem>
<FormItem label="链接"> <FormItem :prop="`cell[${cellIndex}].url`" label="链接">
<AppLinkInput v-model="cell.url" /> <AppLinkInput v-model="cell.url" />
</FormItem> </FormItem>
</template> </template>
<!-- 2. 图片 --> <!-- 2. 图片 -->
<template v-else-if="cell.type === 'image'"> <template v-else-if="cell.type === 'image'">
<FormItem label="图片"> <FormItem :prop="`cell[${cellIndex}].imgUrl`" label="图片">
<UploadImg <UploadImg
v-model="cell.imgUrl" v-model="cell.imgUrl"
:limit="1" :limit="1"
height="56px"
width="56px"
:show-description="false" :show-description="false"
class="size-14"
/> />
<span class="text-xs text-gray-500">建议尺寸 56*56</span> <span class="text-xs text-gray-500">建议尺寸 56*56</span>
</FormItem> </FormItem>
<FormItem label="链接"> <FormItem :prop="`cell[${cellIndex}].url`" label="链接">
<AppLinkInput v-model="cell.url" /> <AppLinkInput v-model="cell.url" />
</FormItem> </FormItem>
</template> </template>
<!-- 3. 搜索框 --> <!-- 3. 搜索框 -->
<template v-else> <template v-else>
<FormItem label="提示文字"> <FormItem label="框体颜色" prop="backgroundColor">
<ColorInput v-model="cell.backgroundColor" />
</FormItem>
<FormItem class="lef" label="文本颜色" prop="textColor">
<ColorInput v-model="cell.textColor" />
</FormItem>
<FormItem :prop="`cell[${cellIndex}].placeholder`" label="提示文字">
<Input v-model:value="cell.placeholder" :maxlength="10" show-count /> <Input v-model:value="cell.placeholder" :maxlength="10" show-count />
</FormItem> </FormItem>
<FormItem label="圆角"> <FormItem label="文本位置" prop="placeholderPosition">
<Slider v-model:value="cell.borderRadius" :max="100" :min="0" /> <RadioGroup v-model:value="cell!.placeholderPosition">
<Tooltip content="居左" placement="top">
<RadioButton value="left">
<IconifyIcon icon="ant-design:align-left-outlined" />
</RadioButton>
</Tooltip>
<Tooltip content="居中" placement="top">
<RadioButton value="center">
<IconifyIcon icon="ant-design:align-center-outlined" />
</RadioButton>
</Tooltip>
</RadioGroup>
</FormItem>
<FormItem label="扫一扫" prop="showScan">
<Switch v-model:checked="cell!.showScan" />
</FormItem>
<FormItem :prop="`cell[${cellIndex}].borderRadius`" label="圆角">
<Slider
v-model:value="cell.borderRadius"
:max="100"
:min="0"
:show-input-controls="false"
input-size="small"
show-input
/>
</FormItem> </FormItem>
</template> </template>
</template> </template>

View File

@@ -18,7 +18,7 @@ defineOptions({ name: 'NavigationBar' });
const props = defineProps<{ property: NavigationBarProperty }>(); const props = defineProps<{ property: NavigationBarProperty }>();
// 背景 /** 计算背景样式 */
const bgStyle = computed(() => { const bgStyle = computed(() => {
const background = const background =
props.property.bgType === 'img' && props.property.bgImg props.property.bgType === 'img' && props.property.bgImg
@@ -26,27 +26,31 @@ const bgStyle = computed(() => {
: props.property.bgColor; : props.property.bgColor;
return { background }; return { background };
}); });
// 单元格列表
/** 获取当前预览的单元格列表 */
const cellList = computed(() => const cellList = computed(() =>
props.property._local?.previewMp props.property._local?.previewMp
? props.property.mpCells ? props.property.mpCells
: props.property.otherCells, : props.property.otherCells,
); );
// 单元格宽度
/** 计算单元格宽度 */
const cellWidth = computed(() => { const cellWidth = computed(() => {
return props.property._local?.previewMp return props.property._local?.previewMp
? (384 - 80 - 86) / 6 ? (375 - 80 - 86) / 6
: (384 - 90) / 8; : (375 - 90) / 8;
}); });
// 获得单元格样式
const getCellStyle = (cell: NavigationBarCellProperty) => { /** 获取单元格样式 */
function getCellStyle(cell: NavigationBarCellProperty) {
return { return {
width: `${cell.width * cellWidth.value + (cell.width - 1) * 10}px`, width: `${cell.width * cellWidth.value + (cell.width - 1) * 10}px`,
left: `${cell.left * cellWidth.value + (cell.left + 1) * 10}px`, left: `${cell.left * cellWidth.value + (cell.left + 1) * 10}px`,
position: 'absolute', position: 'absolute',
} as StyleValue; } as StyleValue;
}; }
// 获得搜索框属性
/** 获取搜索框属性配置 */
const getSearchProp = computed(() => (cell: NavigationBarCellProperty) => { const getSearchProp = computed(() => (cell: NavigationBarCellProperty) => {
return { return {
height: 30, height: 30,
@@ -57,7 +61,10 @@ const getSearchProp = computed(() => (cell: NavigationBarCellProperty) => {
}); });
</script> </script>
<template> <template>
<div class="navigation-bar" :style="bgStyle"> <div
class="flex h-[50px] items-center justify-between bg-white px-[6px]"
:style="bgStyle"
>
<div class="flex h-full w-full items-center"> <div class="flex h-full w-full items-center">
<div <div
v-for="(cell, cellIndex) in cellList" v-for="(cell, cellIndex) in cellList"
@@ -78,35 +85,7 @@ const getSearchProp = computed(() => (cell: NavigationBarCellProperty) => {
v-if="property._local?.previewMp" v-if="property._local?.previewMp"
:src="appNavbarMp" :src="appNavbarMp"
alt="" alt=""
class="w-22 h-8" style="width: 86px; height: 30px"
/> />
</div> </div>
</template> </template>
<style lang="scss" scoped>
.navigation-bar {
display: flex;
align-items: center;
justify-content: space-between;
height: 50px;
padding: 0 6px;
background: #fff;
/* 左边 */
.left {
margin-left: 8px;
}
.center {
flex: 1;
font-size: 14px;
line-height: 35px;
color: #333;
text-align: center;
}
/* 右边 */
.right {
margin-right: 8px;
}
}
</style>

View File

@@ -17,16 +17,16 @@ import { ColorInput } from '#/views/mall/promotion/components';
import NavigationBarCellProperty from './components/cell-property.vue'; import NavigationBarCellProperty from './components/cell-property.vue';
// 导航栏属性面板 /** 导航栏属性面板 */
defineOptions({ name: 'NavigationBarProperty' }); defineOptions({ name: 'NavigationBarProperty' });
const props = defineProps<{ modelValue: NavigationBarProperty }>(); const props = defineProps<{ modelValue: NavigationBarProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
// 表单校验
const rules: Record<string, any> = { const rules: Record<string, any> = {
name: [{ required: true, message: '请输入页面名称', trigger: 'blur' }], name: [{ required: true, message: '请输入页面名称', trigger: 'blur' }],
}; }; // 表单校验
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
if (!formData.value._local) { if (!formData.value._local) {

View File

@@ -1,23 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NoticeBarProperty } from './config'; import type { NoticeBarProperty } from './config';
import { ref } from 'vue';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
import { Divider, Image } from 'ant-design-vue'; import { Carousel, Divider, Image } from 'ant-design-vue';
/** 公告栏 */ /** 公告栏 */
defineOptions({ name: 'NoticeBar' }); defineOptions({ name: 'NoticeBar' });
const props = defineProps<{ property: NoticeBarProperty }>(); defineProps<{ property: NoticeBarProperty }>();
// 自动轮播
const activeIndex = ref(0);
setInterval(() => {
const contents = props.property.contents || [];
activeIndex.value = (activeIndex.value + 1) % (contents.length || 1);
}, 3000);
</script> </script>
<template> <template>
@@ -30,11 +21,17 @@ setInterval(() => {
> >
<Image :src="property.iconUrl" class="h-[18px]" :preview="false" /> <Image :src="property.iconUrl" class="h-[18px]" :preview="false" />
<Divider type="vertical" /> <Divider type="vertical" />
<div class="h-6 flex-1 truncate pr-2 leading-6"> <Carousel
{{ property.contents?.[activeIndex]?.text }} :autoplay="true"
</div> :dots="false"
vertical
class="flex-1 pr-2"
style="height: 24px"
>
<div v-for="(item, index) in property.contents" :key="index">
<div class="h-6 truncate leading-6">{{ item.text }}</div>
</div>
</Carousel>
<IconifyIcon icon="lucide:arrow-right" /> <IconifyIcon icon="lucide:arrow-right" />
</div> </div>
</template> </template>
<style scoped lang="scss"></style>

View File

@@ -7,25 +7,18 @@ import { Form, FormItem, Textarea } from 'ant-design-vue';
import UploadImg from '#/components/upload/image-upload.vue'; import UploadImg from '#/components/upload/image-upload.vue';
import { ColorInput } from '#/views/mall/promotion/components'; import { ColorInput } from '#/views/mall/promotion/components';
// 导航栏属性面板 /** 导航栏属性面板 */
defineOptions({ name: 'PageConfigProperty' }); defineOptions({ name: 'PageConfigProperty' });
const props = defineProps<{ modelValue: PageConfigProperty }>(); const props = defineProps<{ modelValue: PageConfigProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
// 表单校验
const rules = {};
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>
<template> <template>
<Form <Form :model="formData" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
:model="formData"
:rules="rules"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<FormItem label="页面描述" name="description"> <FormItem label="页面描述" name="description">
<Textarea <Textarea
v-model:value="formData!.description" v-model:value="formData!.description"
@@ -47,5 +40,3 @@ const formData = useVModel(props, 'modelValue', emit);
</FormItem> </FormItem>
</Form> </Form>
</template> </template>
<style scoped lang="scss"></style>

View File

@@ -9,18 +9,19 @@ import { Image } from 'ant-design-vue';
/** 弹窗广告 */ /** 弹窗广告 */
defineOptions({ name: 'Popover' }); defineOptions({ name: 'Popover' });
// 定义属性
defineProps<{ property: PopoverProperty }>();
// 处理选中 const props = defineProps<{ property: PopoverProperty }>();
const activeIndex = ref(0);
const handleActive = (index: number) => { const activeIndex = ref(0); // 选中 index
/** 处理选中 */
function handleActive(index: number) {
activeIndex.value = index; activeIndex.value = index;
}; }
</script> </script>
<template> <template>
<div <div
v-for="(item, index) in property.list" v-for="(item, index) in props.property.list"
:key="index" :key="index"
class="absolute bottom-1/2 right-1/2 h-[454px] w-[292px] rounded border border-gray-300 bg-white p-0.5" class="absolute bottom-1/2 right-1/2 h-[454px] w-[292px] rounded border border-gray-300 bg-white p-0.5"
:style="{ :style="{
@@ -40,5 +41,3 @@ const handleActive = (index: number) => {
<div class="absolute right-1 top-1 text-xs">{{ index + 1 }}</div> <div class="absolute right-1 top-1 text-xs">{{ index + 1 }}</div>
</div> </div>
</template> </template>
<style scoped lang="scss"></style>

View File

@@ -9,10 +9,10 @@ import { getArticle } from '#/api/mall/promotion/article';
/** 营销文章 */ /** 营销文章 */
defineOptions({ name: 'PromotionArticle' }); defineOptions({ name: 'PromotionArticle' });
// 定义属性
const props = defineProps<{ property: PromotionArticleProperty }>(); const props = defineProps<{ property: PromotionArticleProperty }>(); // 定义属性
// 商品列表
const article = ref<MallArticleApi.Article>(); const article = ref<MallArticleApi.Article>(); // 商品列表
watch( watch(
() => props.property.id, () => props.property.id,

View File

@@ -12,18 +12,18 @@ import { getArticlePage } from '#/api/mall/promotion/article';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// 营销文章属性面板 /** 营销文章属性面板 */
defineOptions({ name: 'PromotionArticleProperty' }); defineOptions({ name: 'PromotionArticleProperty' });
const props = defineProps<{ modelValue: PromotionArticleProperty }>(); const props = defineProps<{ modelValue: PromotionArticleProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
// 文章列表
const articles = ref<MallArticleApi.Article[]>([]);
// 加载中 const articles = ref<MallArticleApi.Article[]>([]); // 文章列表
const loading = ref(false); const loading = ref(false); // 加载中
// 查询文章列表
/** 查询文章列表 */
const queryArticleList = async (title?: string) => { const queryArticleList = async (title?: string) => {
loading.value = true; loading.value = true;
const { list } = await getArticlePage({ const { list } = await getArticlePage({
@@ -35,7 +35,7 @@ const queryArticleList = async (title?: string) => {
loading.value = false; loading.value = false;
}; };
// 初始化 /** 初始化 */
onMounted(() => { onMounted(() => {
queryArticleList(); queryArticleList();
}); });

View File

@@ -15,10 +15,10 @@ import { getCombinationActivityListByIds } from '#/api/mall/promotion/combinatio
/** 拼团卡片 */ /** 拼团卡片 */
defineOptions({ name: 'PromotionCombination' }); defineOptions({ name: 'PromotionCombination' });
// 定义属性
const props = defineProps<{ property: PromotionCombinationProperty }>(); const props = defineProps<{ property: PromotionCombinationProperty }>();
// 商品列表
const spuList = ref<MallSpuApi.Spu[]>([]); const spuList = ref<MallSpuApi.Spu[]>([]); // 商品列表
const spuIdList = ref<number[]>([]); const spuIdList = ref<number[]>([]);
const combinationActivityList = ref< const combinationActivityList = ref<
MallCombinationActivityApi.CombinationActivity[] MallCombinationActivityApi.CombinationActivity[]
@@ -30,7 +30,7 @@ watch(
try { try {
// 新添加的拼团组件是没有活动ID的 // 新添加的拼团组件是没有活动ID的
const activityIds = props.property.activityIds; const activityIds = props.property.activityIds;
// 检查活动ID的有效性 // 检查活动 ID 的有效性
if (Array.isArray(activityIds) && activityIds.length > 0) { if (Array.isArray(activityIds) && activityIds.length > 0) {
// 获取拼团活动详情列表 // 获取拼团活动详情列表
combinationActivityList.value = combinationActivityList.value =
@@ -68,32 +68,25 @@ watch(
}, },
); );
/** /** 计算商品的间距 */
* 计算商品的间距 function calculateSpace(index: number) {
* @param index 商品索引 const columns = props.property.layoutType === 'twoCol' ? 2 : 1; // 商品的列数
*/ const marginLeft = index % columns === 0 ? '0' : `${props.property.space}px`; // 第一列没有左边距
const calculateSpace = (index: number) => { const marginTop = index < columns ? '0' : `${props.property.space}px`; // 第一行没有上边距
// 商品的列数
const columns = props.property.layoutType === 'twoCol' ? 2 : 1;
// 第一列没有左边距
const marginLeft = index % columns === 0 ? '0' : `${props.property.space}px`;
// 第一行没有上边距
const marginTop = index < columns ? '0' : `${props.property.space}px`;
return { marginLeft, marginTop }; return { marginLeft, marginTop };
}; }
// 容器 const containerRef = ref(); // 容器
const containerRef = ref();
// 计算商品的宽度 /** 计算商品的宽度 */
const calculateWidth = () => { function calculateWidth() {
let width = '100%'; let width = '100%';
// 双列时每列的宽度为:(总宽度 - 间距)/ 2
if (props.property.layoutType === 'twoCol') { if (props.property.layoutType === 'twoCol') {
// 双列时每列的宽度为:(总宽度 - 间距)/ 2
width = `${(containerRef.value.offsetWidth - props.property.space) / 2}px`; width = `${(containerRef.value.offsetWidth - props.property.space) / 2}px`;
} }
return { width }; return { width };
}; }
</script> </script>
<template> <template>
<div <div

View File

@@ -1,11 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PromotionCombinationProperty } from './config'; import type { PromotionCombinationProperty } from './config';
import type { MallCombinationActivityApi } from '#/api/mall/promotion/combination/combinationActivity';
import { onMounted, ref } from 'vue';
import { CommonStatusEnum } from '@vben/constants';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
@@ -22,27 +17,20 @@ import {
Tooltip, Tooltip,
} from 'ant-design-vue'; } from 'ant-design-vue';
import { getCombinationActivityPage } from '#/api/mall/promotion/combination/combinationActivity';
import UploadImg from '#/components/upload/image-upload.vue'; import UploadImg from '#/components/upload/image-upload.vue';
// import CombinationShowcase from '#/views/mall/promotion/combination/components/combination-showcase.vue'; import { CombinationShowcase } from '#/views/mall/promotion/combination/components';
import { ColorInput } from '#/views/mall/promotion/components'; import { ColorInput } from '#/views/mall/promotion/components';
// 拼团属性面板 import ComponentContainerProperty from '../../component-container-property.vue';
/** 拼团属性面板 */
defineOptions({ name: 'PromotionCombinationProperty' }); defineOptions({ name: 'PromotionCombinationProperty' });
const props = defineProps<{ modelValue: PromotionCombinationProperty }>(); const props = defineProps<{ modelValue: PromotionCombinationProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
// 活动列表
const activityList = ref<MallCombinationActivityApi.CombinationActivity[]>([]);
onMounted(async () => {
const { list } = await getCombinationActivityPage({
pageNo: 1,
pageSize: 10,
status: CommonStatusEnum.ENABLE,
});
activityList.value = list;
});
</script> </script>
<template> <template>
@@ -184,5 +172,3 @@ onMounted(async () => {
</Form> </Form>
</ComponentContainerProperty> </ComponentContainerProperty>
</template> </template>
<style scoped lang="scss"></style>

View File

@@ -14,10 +14,10 @@ import { getPointActivityListByIds } from '#/api/mall/promotion/point';
/** 积分商城卡片 */ /** 积分商城卡片 */
defineOptions({ name: 'PromotionPoint' }); defineOptions({ name: 'PromotionPoint' });
// 定义属性
const props = defineProps<{ property: PromotionPointProperty }>(); const props = defineProps<{ property: PromotionPointProperty }>();
// 商品列表
const spuList = ref<MallPointActivityApi.SpuExtensionWithPoint[]>([]); const spuList = ref<MallPointActivityApi.SpuExtensionWithPoint[]>([]); // 商品列表
const spuIdList = ref<number[]>([]); const spuIdList = ref<number[]>([]);
const pointActivityList = ref<MallPointActivityApi.PointActivity[]>([]); const pointActivityList = ref<MallPointActivityApi.PointActivity[]>([]);
@@ -27,7 +27,7 @@ watch(
try { try {
// 新添加的积分商城组件是没有活动ID的 // 新添加的积分商城组件是没有活动ID的
const activityIds = props.property.activityIds; const activityIds = props.property.activityIds;
// 检查活动ID的有效性 // 检查活动 ID 的有效性
if (Array.isArray(activityIds) && activityIds.length > 0) { if (Array.isArray(activityIds) && activityIds.length > 0) {
// 获取积分商城活动详情列表 // 获取积分商城活动详情列表
pointActivityList.value = await getPointActivityListByIds(activityIds); pointActivityList.value = await getPointActivityListByIds(activityIds);
@@ -65,32 +65,25 @@ watch(
}, },
); );
/** /** 计算商品的间距 */
* 计算商品的间距 function calculateSpace(index: number) {
* @param index 商品索引 const columns = props.property.layoutType === 'twoCol' ? 2 : 1; // 商品的列数
*/ const marginLeft = index % columns === 0 ? '0' : `${props.property.space}px`; // 第一列没有左边距
const calculateSpace = (index: number) => { const marginTop = index < columns ? '0' : `${props.property.space}px`; // 第一行没有上边距
// 商品的列数
const columns = props.property.layoutType === 'twoCol' ? 2 : 1;
// 第一列没有左边距
const marginLeft = index % columns === 0 ? '0' : `${props.property.space}px`;
// 第一行没有上边距
const marginTop = index < columns ? '0' : `${props.property.space}px`;
return { marginLeft, marginTop }; return { marginLeft, marginTop };
}; }
// 容器 const containerRef = ref(); // 容器
const containerRef = ref();
// 计算商品的宽度 /** 计算商品的宽度 */
const calculateWidth = () => { function calculateWidth() {
let width = '100%'; let width = '100%';
// 双列时每列的宽度为:(总宽度 - 间距)/ 2
if (props.property.layoutType === 'twoCol') { if (props.property.layoutType === 'twoCol') {
// 双列时每列的宽度为:(总宽度 - 间距)/ 2
width = `${(containerRef.value.offsetWidth - props.property.space) / 2}px`; width = `${(containerRef.value.offsetWidth - props.property.space) / 2}px`;
} }
return { width }; return { width };
}; }
</script> </script>
<template> <template>
<div <div

View File

@@ -315,17 +315,17 @@ onMounted(() => {
> >
<Tooltip title="重置"> <Tooltip title="重置">
<Button @click="handleReset"> <Button @click="handleReset">
<IconifyIcon class="size-6" icon="lucide:refresh-cw" /> <IconifyIcon class="size-5" icon="lucide:refresh-cw" />
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip v-if="previewUrl" title="预览"> <Tooltip v-if="previewUrl" title="预览">
<Button @click="handlePreview"> <Button @click="handlePreview">
<IconifyIcon class="size-6" icon="lucide:eye" /> <IconifyIcon class="size-5" icon="lucide:eye" />
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip title="保存"> <Tooltip title="保存">
<Button @click="handleSave"> <Button @click="handleSave">
<IconifyIcon class="size-6" icon="lucide:check" /> <IconifyIcon class="size-5" icon="lucide:check" />
</Button> </Button>
</Tooltip> </Tooltip>
</Button.Group> </Button.Group>

View File

@@ -1,4 +1,5 @@
export { default as AppLinkInput } from './app-link-input/index.vue'; export { default as AppLinkInput } from './app-link-input/index.vue';
export { default as AppLinkSelectDialog } from './app-link-input/select-dialog.vue';
export { default as ColorInput } from './color-input/index.vue'; export { default as ColorInput } from './color-input/index.vue';
export { default as DiyEditor } from './diy-editor/index.vue'; export { default as DiyEditor } from './diy-editor/index.vue';
export { type DiyComponentLibrary, PAGE_LIBS } from './diy-editor/util'; export { type DiyComponentLibrary, PAGE_LIBS } from './diy-editor/util';

View File

@@ -26,35 +26,28 @@ defineOptions({ name: 'DiyTemplateDecorate' });
const route = useRoute(); const route = useRoute();
const { refreshTab } = useTabs(); const { refreshTab } = useTabs();
/** 特殊:存储 reset 重置时,当前 selectedTemplateItem 值,从而进行恢复 */ const DIY_PAGE_INDEX_KEY = 'diy_page_index'; // 特殊:存储 reset 重置时,当前 selectedTemplateItem 值,从而进行恢复
const DIY_PAGE_INDEX_KEY = 'diy_page_index';
const selectedTemplateItem = ref(0); const selectedTemplateItem = ref(0);
/** 左上角工具栏操作按钮 */
const templateItems = ref([ const templateItems = ref([
{ name: '基础设置', icon: 'lucide:settings' }, { name: '基础设置', icon: 'lucide:settings' },
{ name: '首页', icon: 'lucide:home' }, { name: '首页', icon: 'lucide:home' },
{ name: '我的', icon: 'lucide:user' }, { name: '我的', icon: 'lucide:user' },
]); ]); // 左上角工具栏操作按钮
const formData = ref<MallDiyTemplateApi.DiyTemplateProperty>(); const formData = ref<MallDiyTemplateApi.DiyTemplateProperty>();
/** 当前编辑的属性 */
const currentFormData = ref< const currentFormData = ref<
MallDiyPageApi.DiyPage | MallDiyTemplateApi.DiyTemplateProperty MallDiyPageApi.DiyPage | MallDiyTemplateApi.DiyTemplateProperty
>({ >({
property: '', property: '',
} as MallDiyPageApi.DiyPage); } as MallDiyPageApi.DiyPage); // 当前编辑的属性
/** templateItem 对应的缓存 */
const currentFormDataMap = ref< const currentFormDataMap = ref<
Map<string, MallDiyPageApi.DiyPage | MallDiyTemplateApi.DiyTemplateProperty> Map<string, MallDiyPageApi.DiyPage | MallDiyTemplateApi.DiyTemplateProperty>
>(new Map()); >(new Map()); // templateItem 对应的缓存
/** 商城 H5 预览地址 */ const previewUrl = ref(''); // 商城 H5 预览地址
const previewUrl = ref('');
/** 模板组件库 */ const templateLibs = [] as DiyComponentLibrary[]; // 模板组件库
const templateLibs = [] as DiyComponentLibrary[];
/** 当前组件库 */
const libs = ref<DiyComponentLibrary[]>(templateLibs); // 当前组件库 const libs = ref<DiyComponentLibrary[]>(templateLibs); // 当前组件库
/** 获取详情 */ /** 获取详情 */
@@ -76,6 +69,7 @@ async function getPageDetail(id: any) {
} }
/** 模板选项切换 */ /** 模板选项切换 */
// TODO @xingyu貌似切换不对“个人中心”切换不过去
function handleTemplateItemChange(event: any) { function handleTemplateItemChange(event: any) {
// 从事件对象中获取值 // 从事件对象中获取值
const val = event.target?.value ?? event; const val = event.target?.value ?? event;
@@ -227,7 +221,7 @@ onMounted(async () => {
> >
<IconifyIcon <IconifyIcon
:icon="item.icon" :icon="item.icon"
class="mt-2 flex size-6 items-center" class="mt-2 flex size-5 items-center"
/> />
</Radio.Button> </Radio.Button>
</template> </template>

View File

@@ -1,7 +1,5 @@
<!-- eslint-disable unicorn/no-nested-ternary --> <!-- 积分商城活动橱窗组件用于展示和选择积分商城活动 -->
<!-- 积分活动橱窗组件 - 用于装修时展示和选择积分活动 -->
<script lang="ts" setup> <script lang="ts" setup>
// TODO @puhui999看看是不是整体优化下代码风格参考别的模块
import type { MallPointActivityApi } from '#/api/mall/promotion/point'; import type { MallPointActivityApi } from '#/api/mall/promotion/point';
import { computed, ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
@@ -15,128 +13,113 @@ import { getPointActivityListByIds } from '#/api/mall/promotion/point';
import PointTableSelect from './point-table-select.vue'; import PointTableSelect from './point-table-select.vue';
interface PointShowcaseProps { interface PointShowcaseProps {
modelValue: number | number[]; modelValue?: number | number[];
limit?: number; limit?: number;
disabled?: boolean; disabled?: boolean;
} }
const props = withDefaults(defineProps<PointShowcaseProps>(), { const props = withDefaults(defineProps<PointShowcaseProps>(), {
modelValue: undefined,
limit: Number.MAX_VALUE, limit: Number.MAX_VALUE,
disabled: false, disabled: false,
}); });
const emit = defineEmits<{ const emit = defineEmits(['update:modelValue', 'change']);
change: [value: any];
'update:modelValue': [value: number | number[]];
}>();
// 积分活动列表 const pointActivityList = ref<MallPointActivityApi.PointActivity[]>([]); // 已选择的活动列表
const pointActivityList = ref<MallPointActivityApi.PointActivity[]>([]); const pointTableSelectRef = ref<InstanceType<typeof PointTableSelect>>(); // 活动选择表格组件引用
const isMultiple = computed(() => props.limit !== 1); // 是否为多选模式
// 计算是否可以添加 /** 计算是否可以添加 */
const canAdd = computed(() => { const canAdd = computed(() => {
if (props.disabled) return false; if (props.disabled) {
if (!props.limit) return true; return false;
}
if (!props.limit) {
return true;
}
return pointActivityList.value.length < props.limit; return pointActivityList.value.length < props.limit;
}); });
// 积分活动选择器引用 /** 监听 modelValue 变化,加载活动详情 */
const pointActivityTableSelectRef = ref();
/**
* 打开积分活动选择器
*/
function openPointActivityTableSelect() {
pointActivityTableSelectRef.value.open(pointActivityList.value);
}
/**
* 选择活动后触发
*/
function handleActivitySelected(
activityList:
| MallPointActivityApi.PointActivity
| MallPointActivityApi.PointActivity[],
) {
pointActivityList.value = Array.isArray(activityList)
? activityList
: [activityList];
emitActivityChange();
}
/**
* 删除活动
*/
function handleRemoveActivity(index: number) {
pointActivityList.value.splice(index, 1);
emitActivityChange();
}
/**
* 发送变更事件
*/
function emitActivityChange() {
if (props.limit === 1) {
const pointActivity =
pointActivityList.value.length > 0 ? pointActivityList.value[0] : null;
emit('update:modelValue', pointActivity?.id || 0);
emit('change', pointActivity);
} else {
emit(
'update:modelValue',
pointActivityList.value.map((pointActivity) => pointActivity.id),
);
emit('change', pointActivityList.value);
}
}
// 监听 modelValue 变化
watch( watch(
() => props.modelValue, () => props.modelValue,
async () => { async (newValue) => {
const ids = Array.isArray(props.modelValue) // eslint-disable-next-line unicorn/no-nested-ternary
? props.modelValue const ids = Array.isArray(newValue) ? newValue : newValue ? [newValue] : [];
: props.modelValue
? [props.modelValue]
: [];
// 不需要返显
if (ids.length === 0) { if (ids.length === 0) {
pointActivityList.value = []; pointActivityList.value = [];
return; return;
} }
// 只有活动发生变化时才重新查询
// 只有活动发生变化之后,才会查询活动
if ( if (
pointActivityList.value.length === 0 || pointActivityList.value.length === 0 ||
pointActivityList.value.some( pointActivityList.value.some((activity) => !ids.includes(activity.id!))
(pointActivity) => !ids.includes(pointActivity.id!),
)
) { ) {
pointActivityList.value = await getPointActivityListByIds(ids); pointActivityList.value = await getPointActivityListByIds(ids);
} }
}, },
{ immediate: true }, { immediate: true },
); );
/** 打开活动选择对话框 */
function handleOpenActivitySelect() {
pointTableSelectRef.value?.open(pointActivityList.value);
}
/** 选择活动后触发 */
function handleActivitySelected(
activities:
| MallPointActivityApi.PointActivity
| MallPointActivityApi.PointActivity[],
) {
pointActivityList.value = Array.isArray(activities)
? activities
: [activities];
emitActivityChange();
}
/** 删除活动 */
function handleRemoveActivity(index: number) {
pointActivityList.value.splice(index, 1);
emitActivityChange();
}
/** 触发变更事件 */
function emitActivityChange() {
if (props.limit === 1) {
const activity =
pointActivityList.value.length > 0 ? pointActivityList.value[0] : null;
emit('update:modelValue', activity?.id || 0);
emit('change', activity);
} else {
emit(
'update:modelValue',
pointActivityList.value.map((activity) => activity.id!),
);
emit('change', pointActivityList.value);
}
}
</script> </script>
<template> <template>
<div class="flex flex-wrap items-center gap-2"> <div class="flex flex-wrap items-center gap-2">
<!-- 活动图片列表 --> <!-- 已选活动列表 -->
<div <div
v-for="(pointActivity, index) in pointActivityList" v-for="(activity, index) in pointActivityList"
:key="pointActivity.id" :key="activity.id"
class="relative flex h-[60px] w-[60px] cursor-pointer items-center justify-center rounded-lg border border-dashed border-gray-300" class="relative h-[60px] w-[60px] overflow-hidden rounded-lg border border-dashed border-gray-300"
> >
<Tooltip :title="pointActivity.spuName"> <Tooltip :title="activity.spuName">
<div class="relative h-full w-full"> <div class="relative h-full w-full">
<Image <Image
:preview="true" :preview="true"
:src="pointActivity.picUrl" :src="activity.picUrl"
class="h-full w-full rounded-lg object-cover" class="h-full w-full rounded-lg object-cover"
/> />
<!-- 删除按钮 -->
<IconifyIcon <IconifyIcon
v-show="!disabled" v-if="!disabled"
icon="lucide:x" icon="lucide:x"
class="absolute -right-2 -top-2 z-10 h-5 w-5 cursor-pointer text-red-500 hover:text-red-600" class="absolute -right-2 -top-2 z-10 h-5 w-5 cursor-pointer text-red-500 hover:text-red-600"
@click="handleRemoveActivity(index)" @click="handleRemoveActivity(index)"
@@ -145,21 +128,21 @@ watch(
</Tooltip> </Tooltip>
</div> </div>
<!-- 添加按钮 --> <!-- 添加活动按钮 -->
<Tooltip v-if="canAdd" title="选择活动"> <Tooltip v-if="canAdd" title="选择活动">
<div <div
class="flex h-14 w-14 cursor-pointer items-center justify-center rounded-lg border border-dashed border-gray-300 hover:border-blue-400" class="flex h-[60px] w-[60px] cursor-pointer items-center justify-center rounded-lg border border-dashed border-gray-300 hover:border-blue-400"
@click="openPointActivityTableSelect" @click="handleOpenActivitySelect"
> >
<IconifyIcon icon="lucide:plus" class="text-lg text-gray-400" /> <IconifyIcon icon="lucide:plus" class="text-xl text-gray-400" />
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
<!-- 积分活动选择对话框 --> <!-- 活动选择对话框 -->
<PointTableSelect <PointTableSelect
ref="pointActivityTableSelectRef" ref="pointTableSelectRef"
:multiple="limit !== 1" :multiple="isMultiple"
@change="handleActivitySelected" @change="handleActivitySelected"
/> />
</template> </template>

View File

@@ -1,23 +1,21 @@
<!-- 积分活动表格选择器 --> <!-- 积分商城活动选择弹窗组件 -->
<script lang="ts" setup> <script lang="ts" setup>
// TODO @puhui999看看是不是整体优化下代码风格参考别的模块
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import type { MallPointActivityApi } from '#/api/mall/promotion/point'; import type { MallPointActivityApi } from '#/api/mall/promotion/point';
import { computed, ref } from 'vue'; import { computed } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants'; import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks'; import { getDictOptions } from '@vben/hooks';
import { dateFormatter, fenToYuanFormat } from '@vben/utils';
import { Checkbox, Radio } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getPointActivityPage } from '#/api/mall/promotion/point'; import { getPointActivityPage } from '#/api/mall/promotion/point';
interface PointTableSelectProps { interface PointTableSelectProps {
multiple?: boolean; multiple?: boolean; // 是否单选true - checkboxfalse - radio
} }
const props = withDefaults(defineProps<PointTableSelectProps>(), { const props = withDefaults(defineProps<PointTableSelectProps>(), {
@@ -26,90 +24,75 @@ const props = withDefaults(defineProps<PointTableSelectProps>(), {
const emit = defineEmits<{ const emit = defineEmits<{
change: [ change: [
value: activity:
| MallPointActivityApi.PointActivity | MallPointActivityApi.PointActivity
| MallPointActivityApi.PointActivity[], | MallPointActivityApi.PointActivity[],
]; ];
}>(); }>();
// 单选:选中的活动 ID /** 单选:处理选中变化 */
const selectedActivityId = ref<number>(); function handleRadioChange() {
// 多选:选中状态映射 const selectedRow =
const checkedStatus = ref<Record<number, boolean>>({}); gridApi.grid.getRadioRecord() as MallPointActivityApi.PointActivity;
// 多选:选中的活动列表 if (selectedRow) {
const checkedActivities = ref<MallPointActivityApi.PointActivity[]>([]); emit('change', selectedRow);
modalApi.close();
}
}
// 全选状态 /** 计算已兑换数量 */
const isCheckAll = ref(false); const getRedeemedQuantity = (row: MallPointActivityApi.PointActivity) =>
const isIndeterminate = ref(false); (row.totalStock || 0) - (row.stock || 0);
// 搜索表单配置 /** 搜索表单 Schema */
const formSchema = computed<VbenFormSchema[]>(() => { const formSchema = computed<VbenFormSchema[]>(() => [
return [ {
{ fieldName: 'status',
fieldName: 'status', label: '活动状态',
label: '活动状态', component: 'Select',
component: 'Select', componentProps: {
componentProps: { options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), placeholder: '请选择活动状态',
placeholder: '请选择活动状态', clearable: true,
allowClear: true,
},
}, },
]; },
}); ]);
// 列配置 /** 表格列配置 */
const gridColumns = computed<VxeGridProps['columns']>(() => { const gridColumns = computed<VxeGridProps['columns']>(() => {
const columns: VxeGridProps['columns'] = []; const columns: VxeGridProps['columns'] = [];
// 多选模式
if (props.multiple) { if (props.multiple) {
columns.push({ columns.push({ type: 'checkbox', width: 55 });
field: 'checkbox',
title: '',
width: 55,
align: 'center',
slots: { default: 'checkbox-column', header: 'checkbox-header' },
});
} else { } else {
// 单选模式 columns.push({ type: 'radio', width: 55 });
columns.push({
field: 'radio',
title: '#',
width: 55,
align: 'center',
slots: { default: 'radio-column' },
});
} }
columns.push( columns.push(
{ {
field: 'id', field: 'id',
title: '活动编号', title: '活动编号',
minWidth: 80, minWidth: 100,
align: 'center',
}, },
{ {
field: 'picUrl', field: 'picUrl',
title: '商品图片', title: '商品图片',
minWidth: 80, width: 100,
align: 'center',
cellRender: { cellRender: {
name: 'CellImage', name: 'CellImage',
props: {
height: 40,
},
}, },
}, },
{ {
field: 'spuName', field: 'spuName',
title: '商品标题', title: '商品标题',
minWidth: 300, minWidth: 200,
}, },
{ {
field: 'marketPrice', field: 'marketPrice',
title: '原价', title: '原价',
minWidth: 100, minWidth: 100,
formatter: 'formatAmount2', align: 'center',
formatter: ({ cellValue }) => fenToYuanFormat(cellValue),
}, },
{ {
field: 'status', field: 'status',
@@ -118,9 +101,7 @@ const gridColumns = computed<VxeGridProps['columns']>(() => {
align: 'center', align: 'center',
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { props: { type: DICT_TYPE.COMMON_STATUS },
type: DICT_TYPE.COMMON_STATUS,
},
}, },
}, },
{ {
@@ -140,216 +121,119 @@ const gridColumns = computed<VxeGridProps['columns']>(() => {
title: '已兑换数量', title: '已兑换数量',
minWidth: 100, minWidth: 100,
align: 'center', align: 'center',
formatter: ({ row }) => (row.totalStock || 0) - (row.stock || 0), formatter: ({ row }) => getRedeemedQuantity(row),
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180, width: 180,
align: 'center', align: 'center',
formatter: 'formatDateTime', formatter: ({ cellValue }) => dateFormatter(cellValue),
}, },
); );
return columns; return columns;
}); });
// 初始化表格
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions: { formOptions: {
schema: formSchema.value, schema: formSchema.value,
layout: 'horizontal',
collapsed: false,
}, },
gridOptions: { gridOptions: {
columns: gridColumns.value, columns: gridColumns.value,
height: 500, height: 500,
border: true, border: true,
showOverflow: true, checkboxConfig: {
reserve: true,
},
radioConfig: {
reserve: true,
},
rowConfig: {
keyField: 'id',
isHover: true,
},
proxyConfig: { proxyConfig: {
ajax: { ajax: {
async query({ page }: any, formValues: any) { async query({ page }: any, formValues: any) {
try { return await getPointActivityPage({
const params: any = { pageNo: page.currentPage,
pageNo: page.currentPage, pageSize: page.pageSize,
pageSize: page.pageSize, ...formValues,
}; });
if (formValues.status !== undefined) {
params.status = formValues.status;
}
const data = await getPointActivityPage(params);
const list = data.list || [];
// 初始化 checkbox 绑定
list.forEach(
(activityVO) =>
(checkedStatus.value[activityVO.id] =
checkedStatus.value[activityVO.id] || false),
);
// 计算全选框状态
calculateIsCheckAll(list);
return {
items: list,
total: data.total || 0,
};
} catch (error) {
console.error('加载积分活动数据失败:', error);
return { items: [], total: 0 };
}
}, },
}, },
}, },
}, },
gridEvents: {
radioChange: handleRadioChange,
},
}); });
/**
* 单选:处理选中
*/
function handleSingleSelected(row: MallPointActivityApi.PointActivity) {
selectedActivityId.value = row.id;
emit('change', row);
modalApi.close();
}
/**
* 多选:全选/全不选
*/
function handleCheckAll(e: any) {
const checked = e.target.checked;
isCheckAll.value = checked;
isIndeterminate.value = false;
const list = gridApi.grid.getData();
list.forEach((pointActivity) =>
handleCheckOne(checked, pointActivity, false),
);
}
/**
* 多选:选中一行
*/
function handleCheckOne(
checked: boolean,
pointActivity: MallPointActivityApi.PointActivity,
isCalcCheckAll: boolean,
) {
if (checked) {
checkedActivities.value.push(pointActivity);
checkedStatus.value[pointActivity.id] = true;
} else {
const index = findCheckedIndex(pointActivity);
if (index > -1) {
checkedActivities.value.splice(index, 1);
checkedStatus.value[pointActivity.id] = false;
isCheckAll.value = false;
}
}
// 计算全选框状态
if (isCalcCheckAll) {
const list = gridApi.grid.getData();
calculateIsCheckAll(list);
}
}
/**
* 查找活动在已选中列表中的索引
*/
function findCheckedIndex(activityVO: MallPointActivityApi.PointActivity) {
return checkedActivities.value.findIndex((item) => item.id === activityVO.id);
}
/**
* 计算全选框状态
*/
function calculateIsCheckAll(list: MallPointActivityApi.PointActivity[]) {
isCheckAll.value = list.every(
(activityVO) => checkedStatus.value[activityVO.id],
);
isIndeterminate.value =
!isCheckAll.value &&
list.some((activityVO) => checkedStatus.value[activityVO.id]);
}
/**
* 多选:确认选择
*/
function handleConfirm() {
emit('change', [...checkedActivities.value]);
modalApi.close();
}
/**
* 打开对话框
*/
function open(pointList?: MallPointActivityApi.PointActivity[]) {
// 重置
checkedActivities.value = [];
checkedStatus.value = {};
isCheckAll.value = false;
isIndeterminate.value = false;
// 处理已选中
if (pointList && pointList.length > 0) {
checkedActivities.value = [...pointList];
checkedStatus.value = Object.fromEntries(
pointList.map((activityVO) => [activityVO.id, true]),
);
}
modalApi.open();
}
// 暴露 open 方法
defineExpose({ open });
// 初始化弹窗
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({
onConfirm: props.multiple ? handleConfirm : undefined, destroyOnClose: true,
showConfirmButton: props.multiple, // 特殊radio 单选情况下,走 handleRadioChange 处理。
onConfirm: () => {
const selectedRows =
gridApi.grid.getCheckboxRecords() as MallPointActivityApi.PointActivity[];
emit('change', selectedRows);
modalApi.close();
},
async onOpenChange(isOpen: boolean) { async onOpenChange(isOpen: boolean) {
if (!isOpen) { if (!isOpen) {
// 关闭时清理状态 await gridApi.grid.clearCheckboxRow();
if (!props.multiple) { await gridApi.grid.clearRadioRow();
selectedActivityId.value = undefined;
}
return; return;
} }
// 打开时触发查询 // 1. 先查询数据
await gridApi.query(); await gridApi.query();
// 2. 设置已选中行
const data = modalApi.getData<
MallPointActivityApi.PointActivity | MallPointActivityApi.PointActivity[]
>();
if (props.multiple && Array.isArray(data) && data.length > 0) {
setTimeout(() => {
const tableData = gridApi.grid.getTableData().fullData;
data.forEach((activity) => {
const row = tableData.find(
(item: MallPointActivityApi.PointActivity) =>
item.id === activity.id,
);
if (row) {
gridApi.grid.setCheckboxRow(row, true);
}
});
}, 300);
} else if (!props.multiple && data && !Array.isArray(data)) {
setTimeout(() => {
const tableData = gridApi.grid.getTableData().fullData;
const row = tableData.find(
(item: MallPointActivityApi.PointActivity) => item.id === data.id,
);
if (row) {
gridApi.grid.setRadioRow(row);
}
}, 300);
}
},
});
/** 对外暴露的方法 */
defineExpose({
open: (
data?:
| MallPointActivityApi.PointActivity
| MallPointActivityApi.PointActivity[],
) => {
modalApi.setData(data).open();
}, },
}); });
</script> </script>
<template> <template>
<Modal class="w-[70%]" title="选择活动"> <Modal title="选择活动" class="w-[950px]">
<Grid> <Grid />
<!-- 多选表头 checkbox -->
<template v-if="props.multiple" #checkbox-header>
<Checkbox
v-model:checked="isCheckAll"
:indeterminate="isIndeterminate"
@change="handleCheckAll"
/>
</template>
<!-- 多选 checkbox -->
<template v-if="props.multiple" #checkbox-column="{ row }">
<Checkbox
v-model:checked="checkedStatus[row.id]"
@change="(e: any) => handleCheckOne(e.target.checked, row, true)"
/>
</template>
<!-- 单选 radio -->
<template v-if="!props.multiple" #radio-column="{ row }">
<Radio
:checked="selectedActivityId === row.id"
:value="row.id"
class="cursor-pointer"
@click="handleSingleSelected(row)"
/>
</template>
</Grid>
</Modal> </Modal>
</template> </template>

View File

@@ -7,7 +7,7 @@ import { onMounted, ref, watch } from 'vue';
import { ElScrollbar } from 'element-plus'; import { ElScrollbar } from 'element-plus';
import * as CouponTemplateApi from '#/api/mall/promotion/coupon/couponTemplate'; import { getCouponTemplateList } from '#/api/mall/promotion/coupon/couponTemplate';
import { import {
CouponDiscount, CouponDiscount,
@@ -32,9 +32,7 @@ watch(
() => props.property.couponIds, () => props.property.couponIds,
async () => { async () => {
if (props.property.couponIds?.length > 0) { if (props.property.couponIds?.length > 0) {
couponList.value = await CouponTemplateApi.getCouponTemplateList( couponList.value = await getCouponTemplateList(props.property.couponIds);
props.property.couponIds,
);
} }
}, },
{ {

View File

@@ -39,7 +39,7 @@ function handleToggleFab() {
<ElImage :src="item.imgUrl" fit="contain" class="h-7 w-7"> <ElImage :src="item.imgUrl" fit="contain" class="h-7 w-7">
<template #error> <template #error>
<div class="flex h-full w-full items-center justify-center"> <div class="flex h-full w-full items-center justify-center">
<IconifyIcon icon="ep:picture" :color="item.textColor" /> <IconifyIcon icon="lucide:image" :color="item.textColor" />
</div> </div>
</template> </template>
</ElImage> </ElImage>
@@ -55,7 +55,7 @@ function handleToggleFab() {
<!-- todo: @owen 使用APP主题色 --> <!-- todo: @owen 使用APP主题色 -->
<ElButton type="primary" size="large" circle @click="handleToggleFab"> <ElButton type="primary" size="large" circle @click="handleToggleFab">
<IconifyIcon <IconifyIcon
icon="ep:plus" icon="lucide:plus"
class="transition-transform duration-300" class="transition-transform duration-300"
:class="expanded ? 'rotate-[135deg]' : 'rotate-0'" :class="expanded ? 'rotate-[135deg]' : 'rotate-0'"
/> />

View File

@@ -23,9 +23,9 @@ const formData = useVModel(props, 'modelValue', emit);
const editDialogRef = ref(); // 热区编辑对话框 const editDialogRef = ref(); // 热区编辑对话框
/** 打开热区编辑对话框 */ /** 打开热区编辑对话框 */
const handleOpenEditDialog = () => { function handleOpenEditDialog() {
editDialogRef.value.open(); editDialogRef.value.open();
}; }
</script> </script>
<template> <template>

View File

@@ -19,7 +19,7 @@ export interface NoticeContentProperty {
export const component = { export const component = {
id: 'NoticeBar', id: 'NoticeBar',
name: '公告栏', name: '公告栏',
icon: 'ep:bell', icon: 'lucide:bell',
property: { property: {
iconUrl: 'http://mall.yudao.iocoder.cn/static/images/xinjian.png', iconUrl: 'http://mall.yudao.iocoder.cn/static/images/xinjian.png',
contents: [ contents: [

View File

@@ -19,7 +19,6 @@ function handleActive(index: number) {
activeIndex.value = index; activeIndex.value = index;
} }
</script> </script>
<template> <template>
<div <div
v-for="(item, index) in props.property.list" v-for="(item, index) in props.property.list"
@@ -35,7 +34,7 @@ function handleActive(index: number) {
<ElImage :src="item.imgUrl" fit="contain" class="h-full w-full"> <ElImage :src="item.imgUrl" fit="contain" class="h-full w-full">
<template #error> <template #error>
<div class="flex h-full w-full items-center justify-center"> <div class="flex h-full w-full items-center justify-center">
<IconifyIcon icon="ep:picture" /> <IconifyIcon icon="lucide:image" />
</div> </div>
</template> </template>
</ElImage> </ElImage>

View File

@@ -5,7 +5,7 @@ import type { MallArticleApi } from '#/api/mall/promotion/article';
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
import * as ArticleApi from '#/api/mall/promotion/article/index'; import { getArticle } from '#/api/mall/promotion/article';
/** 营销文章 */ /** 营销文章 */
defineOptions({ name: 'PromotionArticle' }); defineOptions({ name: 'PromotionArticle' });
@@ -18,7 +18,7 @@ watch(
() => props.property.id, () => props.property.id,
async () => { async () => {
if (props.property.id) { if (props.property.id) {
article.value = await ArticleApi.getArticle(props.property.id); article.value = await getArticle(props.property.id);
} }
}, },
{ {

View File

@@ -10,8 +10,8 @@ import { fenToYuan } from '@vben/utils';
import { ElImage } from 'element-plus'; import { ElImage } from 'element-plus';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getSpuDetailList } from '#/api/mall/product/spu';
import * as CombinationActivityApi from '#/api/mall/promotion/combination/combinationActivity'; import { getCombinationActivityListByIds } from '#/api/mall/promotion/combination/combinationActivity';
/** 拼团卡片 */ /** 拼团卡片 */
defineOptions({ name: 'PromotionCombination' }); defineOptions({ name: 'PromotionCombination' });
@@ -34,9 +34,7 @@ watch(
if (Array.isArray(activityIds) && activityIds.length > 0) { if (Array.isArray(activityIds) && activityIds.length > 0) {
// 获取拼团活动详情列表 // 获取拼团活动详情列表
combinationActivityList.value = combinationActivityList.value =
await CombinationActivityApi.getCombinationActivityListByIds( await getCombinationActivityListByIds(activityIds);
activityIds,
);
// 获取拼团活动的 SPU 详情列表 // 获取拼团活动的 SPU 详情列表
spuList.value = []; spuList.value = [];
@@ -44,7 +42,7 @@ watch(
.map((activity) => activity.spuId) .map((activity) => activity.spuId)
.filter((spuId): spuId is number => typeof spuId === 'number'); .filter((spuId): spuId is number => typeof spuId === 'number');
if (spuIdList.value.length > 0) { if (spuIdList.value.length > 0) {
spuList.value = await ProductSpuApi.getSpuDetailList(spuIdList.value); spuList.value = await getSpuDetailList(spuIdList.value);
} }
// 更新 SPU 的最低价格 // 更新 SPU 的最低价格
@@ -78,7 +76,7 @@ function calculateSpace(index: number) {
return { marginLeft, marginTop }; return { marginLeft, marginTop };
} }
const containerRef = ref(); const containerRef = ref(); // 容器
/** 计算商品的宽度 */ /** 计算商品的宽度 */
function calculateWidth() { function calculateWidth() {

View File

@@ -74,7 +74,7 @@ function calculateSpace(index: number) {
return { marginLeft, marginTop }; return { marginLeft, marginTop };
} }
const containerRef = ref(); const containerRef = ref(); // 容器
/** 计算商品的宽度 */ /** 计算商品的宽度 */
function calculateWidth() { function calculateWidth() {

View File

@@ -54,11 +54,6 @@ const formData = useVModel(props, 'modelValue', emit);
<IconifyIcon icon="fluent:text-column-two-24-filled" /> <IconifyIcon icon="fluent:text-column-two-24-filled" />
</ElRadioButton> </ElRadioButton>
</ElTooltip> </ElTooltip>
<!--<ElTooltip class="item" content="三列" placement="bottom">
<ElRadioButton value="threeCol">
<IconifyIcon icon="fluent:text-column-three-24-filled" />
</ElRadioButton>
</ElTooltip>-->
</ElRadioGroup> </ElRadioGroup>
</ElFormItem> </ElFormItem>
<ElFormItem label="商品名称" prop="fields.name.show"> <ElFormItem label="商品名称" prop="fields.name.show">