diff --git a/apps/web-ele/src/views/mall/promotion/point/activity/data.ts b/apps/web-ele/src/views/mall/promotion/point/activity/data.ts index dcb750cbb..51db7b0ed 100644 --- a/apps/web-ele/src/views/mall/promotion/point/activity/data.ts +++ b/apps/web-ele/src/views/mall/promotion/point/activity/data.ts @@ -3,50 +3,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; - -/** 表单配置 */ -export function useFormSchema(): VbenFormSchema[] { - return [ - { - fieldName: 'id', - component: 'Input', - dependencies: { - triggerFields: [''], - show: () => false, - }, - }, - { - fieldName: 'spuId', - label: '积分商城活动商品', - component: 'Input', - componentProps: { - placeholder: '请选择商品', - }, - rules: 'required', - }, - { - fieldName: 'sort', - label: '排序', - component: 'InputNumber', - componentProps: { - placeholder: '请输入排序', - min: 0, - controlsPosition: 'right', - class: '!w-full', - }, - rules: 'required', - }, - { - fieldName: 'remark', - label: '备注', - component: 'Textarea', - componentProps: { - placeholder: '请输入备注', - rows: 4, - }, - }, - ]; -} +import { fenToYuan } from '@vben/utils'; /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { @@ -56,15 +13,15 @@ export function useGridFormSchema(): VbenFormSchema[] { label: '活动状态', component: 'Select', componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), placeholder: '请选择活动状态', clearable: true, - options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), }, }, ]; } -/** 列表的字段 */ +/** 列表的表格列 */ export function useGridColumns(): VxeTableGridOptions['columns'] { return [ { @@ -78,6 +35,9 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { minWidth: 80, cellRender: { name: 'CellImage', + props: { + height: 40, + }, }, }, { @@ -89,18 +49,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'marketPrice', title: '原价', minWidth: 100, - formatter: 'formatFenToYuanAmount', - }, - { - field: 'point', - title: '兑换积分', - minWidth: 100, - }, - { - field: 'price', - title: '兑换金额', - minWidth: 100, - formatter: 'formatFenToYuanAmount', + formatter: ({ row }) => `¥${fenToYuan(row.marketPrice)}`, }, { field: 'status', @@ -125,7 +74,9 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'redeemedQuantity', title: '已兑换数量', minWidth: 100, - slots: { default: 'redeemedQuantity' }, + formatter: ({ row }) => { + return (row.totalStock || 0) - (row.stock || 0); + }, }, { field: 'createTime', @@ -141,3 +92,48 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, ]; } + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'sort', + label: '排序', + component: 'InputNumber', + componentProps: { + min: 0, + placeholder: '请输入排序', + controlsPosition: 'right', + class: '!w-full', + }, + defaultValue: 0, + rules: 'required', + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + rows: 4, + }, + formItemClass: 'col-span-2', + }, + // TODO @puhui999:商品图太大了。 + { + fieldName: 'spuId', + label: '活动商品', + component: 'Input', + rules: 'required', + formItemClass: 'col-span-2', + }, + ]; +} diff --git a/apps/web-ele/src/views/mall/promotion/point/activity/index.vue b/apps/web-ele/src/views/mall/promotion/point/activity/index.vue index 4fcebfad2..dc8b10534 100644 --- a/apps/web-ele/src/views/mall/promotion/point/activity/index.vue +++ b/apps/web-ele/src/views/mall/promotion/point/activity/index.vue @@ -1,10 +1,7 @@