From d1089d7a5029b8dea859ec35ff66531e7cc6079b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 16 Oct 2025 13:16:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=EF=BC=9A=E3=80=90mall=20=E5=95=86?= =?UTF-8?q?=E5=9F=8E=E3=80=91=E6=96=87=E7=AB=A0=E5=88=86=E7=B1=BB=EF=BC=88?= =?UTF-8?q?100%=20ele=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/promotion/article/category/data.ts | 58 ++++++++------- .../mall/promotion/article/category/index.vue | 12 +++- .../article/category/modules/form.vue | 4 +- .../src/views/mall/promotion/article/data.ts | 70 ++++++++++++++++--- .../views/mall/promotion/article/index.vue | 16 +++-- .../mall/promotion/article/modules/form.vue | 4 +- 6 files changed, 121 insertions(+), 43 deletions(-) diff --git a/apps/web-ele/src/views/mall/promotion/article/category/data.ts b/apps/web-ele/src/views/mall/promotion/article/category/data.ts index 576714d95..c61f030d1 100644 --- a/apps/web-ele/src/views/mall/promotion/article/category/data.ts +++ b/apps/web-ele/src/views/mall/promotion/article/category/data.ts @@ -1,9 +1,10 @@ import type { VbenFormSchema } from '#/adapter/form'; -import type { VxeGridPropTypes } from '#/adapter/vxe-table'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; -import { DICT_TYPE } from '@vben/constants'; +import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; +import { z } from '#/adapter/form'; import { getRangePickerDefaultProps } from '#/utils'; /** 新增/修改的表单 */ @@ -21,21 +22,28 @@ export function useFormSchema(): VbenFormSchema[] { fieldName: 'name', label: '分类名称', component: 'Input', + componentProps: { + placeholder: '请输入分类名称', + }, rules: 'required', }, { fieldName: 'picUrl', - label: '图标地址', + label: '分类图片', component: 'ImageUpload', + componentProps: { + placeholder: '请上传分类图片', + }, }, { fieldName: 'sort', - label: '排序', + label: '显示顺序', component: 'InputNumber', componentProps: { min: 0, + placeholder: '请输入显示顺序', controlsPosition: 'right', - placeholder: '请输入排序', + class: '!w-full', }, rules: 'required', }, @@ -48,7 +56,7 @@ export function useFormSchema(): VbenFormSchema[] { buttonStyle: 'solid', optionType: 'button', }, - rules: 'required', + rules: z.number().default(CommonStatusEnum.ENABLE), }, ]; } @@ -62,6 +70,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入分类名称', + allowClear: true, }, }, { @@ -70,6 +79,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Select', componentProps: { placeholder: '请选择状态', + allowClear: true, options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), }, }, @@ -79,58 +89,58 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'RangePicker', componentProps: { ...getRangePickerDefaultProps(), - clearable: true, + allowClear: true, }, }, ]; } /** 表格列配置 */ -export function useGridColumns(): VxeGridPropTypes.Columns { +export function useGridColumns(): VxeTableGridOptions['columns'] { return [ { - title: '编号', field: 'id', - width: 100, + title: '编号', + minWidth: 100, }, { - title: '分类名称', field: 'name', + title: '分类名称', minWidth: 240, + align: 'left', + fixed: 'left', }, { - title: '分类图片', field: 'picUrl', - width: 80, + title: '分类图片', + minWidth: 80, cellRender: { name: 'CellImage', }, }, { - title: '状态', field: 'status', - width: 150, + title: '状态', + minWidth: 150, cellRender: { - name: 'CellDictTag', - props: { - dictType: DICT_TYPE.COMMON_STATUS, - }, + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, }, }, { - title: '排序', field: 'sort', - width: 150, + title: '显示顺序', + minWidth: 150, }, { - title: '创建时间', field: 'createTime', - width: 180, + title: '创建时间', + minWidth: 180, formatter: 'formatDateTime', }, { title: '操作', - width: 180, + minWidth: 220, fixed: 'right', slots: { default: 'actions' }, }, diff --git a/apps/web-ele/src/views/mall/promotion/article/category/index.vue b/apps/web-ele/src/views/mall/promotion/article/category/index.vue index 654eab741..a53c59dfa 100644 --- a/apps/web-ele/src/views/mall/promotion/article/category/index.vue +++ b/apps/web-ele/src/views/mall/promotion/article/category/index.vue @@ -2,7 +2,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { MallArticleCategoryApi } from '#/api/mall/promotion/articleCategory'; -import { Page, useVbenModal } from '@vben/common-ui'; +import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { ElLoading, ElMessage } from 'element-plus'; @@ -42,7 +42,7 @@ async function handleDelete(row: MallArticleCategoryApi.ArticleCategory) { text: $t('ui.actionMessage.deleting', [row.name]), }); try { - await deleteArticleCategory(row.id as number); + await deleteArticleCategory(row.id!); ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name])); handleRefresh(); } finally { @@ -71,6 +71,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, @@ -82,6 +83,13 @@ const [Grid, gridApi] = useVbenVxeGrid({