fix: mall

This commit is contained in:
xingyu4j
2025-10-22 18:17:21 +08:00
parent 1f64551a3e
commit 1db4c4170b
4 changed files with 51 additions and 53 deletions

View File

@@ -221,14 +221,9 @@ function selectSku(skus: MallSpuApi.Sku[]) {
selectedSkuIds.value = [];
return;
}
if (props.radio) {
// 单选模式
selectedSkuIds.value = [skus[0]?.id!];
} else {
// 多选模式
selectedSkuIds.value = skus.map((sku) => sku.id!);
}
props.radio
? (selectedSkuIds.value = [skus[0]?.id!])
: (selectedSkuIds.value = skus.map((sku) => sku.id!));
}
// 展开行,加载 SKU 列表
@@ -308,6 +303,10 @@ const [Modal, modalApi] = useVbenModal({
await gridApi.query();
},
});
defineExpose({
open: modalApi.open,
close: modalApi.close,
});
</script>
<template>

View File

@@ -5,7 +5,6 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
// 2. 导入 VBEN 常量和工具
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { $t } from '@vben/locales';
// 3. 导入 Zod 用于高级验证
import { z } from '#/adapter/form';
@@ -59,7 +58,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
field: 'marketPrice',
title: '原价',
minWidth: 100,
formatter: 'formatAmount',
formatter: 'formatAmount2',
},
{
field: 'status',
@@ -98,13 +97,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
},
{
field: 'createTime',
title: $t('common.createTime'),
title: '创建时间',
minWidth: 180,
align: 'center',
formatter: 'formatDateTime',
},
{
title: $t('common.action'),
title: '操作',
width: 150,
fixed: 'right',
slots: { default: 'actions' },

View File

@@ -1,8 +1,6 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { computed } from 'vue';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { message } from 'ant-design-vue';
@@ -55,43 +53,6 @@ function handleRefresh() {
gridApi.query();
}
// 计算操作按钮
const getActions = computed(() => (row: any) => {
const actions: any[] = [
{
label: $t('common.edit'),
icon: ACTION_ICON.EDIT,
onClick: handleEdit.bind(null, row),
},
];
// 如果状态是启用(0),显示关闭按钮
if (row.status === 0) {
actions.push({
label: '关闭',
icon: ACTION_ICON.CLOSE,
danger: true,
popConfirm: {
title: '确认关闭该积分商城活动吗?',
confirm: handleClose.bind(null, row),
},
});
} else {
// 否则显示删除按钮
actions.push({
label: $t('common.delete'),
icon: ACTION_ICON.DELETE,
danger: true,
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.spuName]),
confirm: handleDelete.bind(null, row),
},
});
}
return actions;
});
// 3. 使用 useVbenVxeGrid 初始化列表
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
@@ -99,6 +60,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
@@ -121,6 +84,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
description="积分商城活动,用于管理积分兑换商品的配置"
doc-link="https://doc.iocoder.cn/mall/promotion-point/"
title="积分商城活动"
auto-content-height
>
<!-- 弹窗组件的注册 -->
<FormModal @success="handleRefresh" />
@@ -133,7 +97,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
:actions="[
{
label: $t('ui.actionTitle.create', ['积分活动']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['promotion:point-activity:create'],
onClick: handleCreate,
},
]"
@@ -141,7 +107,41 @@ const [Grid, gridApi] = useVbenVxeGrid({
</template>
<!-- 操作列按钮 -->
<template #actions="{ row }">
<TableAction :actions="getActions(row)" />
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['promotion:point-activity:update'],
onClick: handleEdit.bind(null, row),
},
{
label: '关闭',
type: 'link',
danger: true,
icon: ACTION_ICON.CLOSE,
ifShow: row.status === 0,
auth: ['promotion:point-activity:close'],
popConfirm: {
title: '确认关闭该积分商城活动吗?',
confirm: handleClose.bind(null, row),
},
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
ifShow: row.status !== 0,
auth: ['promotion:point-activity:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.spuName]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>

View File

@@ -108,7 +108,7 @@ const gridColumns = computed<VxeGridProps['columns']>(() => {
field: 'marketPrice',
title: '原价',
minWidth: 100,
formatter: 'formatAmount',
formatter: 'formatAmount2',
},
{
field: 'status',