From 9bffbb1fcc54eeb75dfb0b80d17b189cb5df8722 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 12 May 2025 00:35:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20ele=20=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-ele/src/views/system/notice/data.ts | 163 ++++++++++++++++++ .../web-ele/src/views/system/notice/index.vue | 140 +++++++++++++++ .../src/views/system/notice/modules/form.vue | 84 +++++++++ 3 files changed, 387 insertions(+) create mode 100644 apps/web-ele/src/views/system/notice/data.ts create mode 100644 apps/web-ele/src/views/system/notice/index.vue create mode 100644 apps/web-ele/src/views/system/notice/modules/form.vue diff --git a/apps/web-ele/src/views/system/notice/data.ts b/apps/web-ele/src/views/system/notice/data.ts new file mode 100644 index 00000000..a181a534 --- /dev/null +++ b/apps/web-ele/src/views/system/notice/data.ts @@ -0,0 +1,163 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { SystemNoticeApi } from '#/api/system/notice'; + +import { useAccess } from '@vben/access'; + +import { z } from '#/adapter/form'; +import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils'; + +const { hasAccessByCodes } = useAccess(); + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'title', + label: '公告标题', + component: 'Input', + rules: 'required', + }, + { + fieldName: 'type', + label: '公告类型', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.SYSTEM_NOTICE_TYPE, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: 'required', + }, + { + fieldName: 'content', + label: '公告内容', + component: 'RichTextarea', + rules: 'required', + }, + { + fieldName: 'status', + label: '公告状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'title', + label: '公告标题', + component: 'Input', + componentProps: { + placeholder: '请输入公告标题', + allowClear: true, + }, + }, + { + fieldName: 'status', + label: '公告状态', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + placeholder: '请选择公告状态', + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '公告编号', + minWidth: 100, + }, + { + field: 'title', + title: '公告标题', + minWidth: 200, + }, + { + field: 'type', + title: '公告类型', + minWidth: 100, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.SYSTEM_NOTICE_TYPE }, + }, + }, + { + field: 'status', + title: '公告状态', + minWidth: 100, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'operation', + title: '操作', + minWidth: 180, + align: 'center', + fixed: 'right', + cellRender: { + attrs: { + nameField: 'title', + nameTitle: '公告', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'edit', + show: hasAccessByCodes(['system:notice:update']), + }, + { + code: 'push', + text: '推送', + show: hasAccessByCodes(['system:notice:update']), + }, + { + code: 'delete', + show: hasAccessByCodes(['system:notice:delete']), + }, + ], + }, + }, + ]; +} diff --git a/apps/web-ele/src/views/system/notice/index.vue b/apps/web-ele/src/views/system/notice/index.vue new file mode 100644 index 00000000..697f5fdc --- /dev/null +++ b/apps/web-ele/src/views/system/notice/index.vue @@ -0,0 +1,140 @@ + + + diff --git a/apps/web-ele/src/views/system/notice/modules/form.vue b/apps/web-ele/src/views/system/notice/modules/form.vue new file mode 100644 index 00000000..21757557 --- /dev/null +++ b/apps/web-ele/src/views/system/notice/modules/form.vue @@ -0,0 +1,84 @@ + + +