From 50ef308a8a49674ad57f968f1b4c345db76dd9b3 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sat, 7 Jun 2025 13:01:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90ele=E3=80=91=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=BB=E5=AD=90=E8=A1=A8=20normal=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/infra/demo/demo03/normal/data.ts | 208 ++++++++++++++++++ .../views/infra/demo/demo03/normal/index.vue | 185 ++++++++++++++++ .../normal/modules/demo03-course-form.vue | 116 ++++++++++ .../normal/modules/demo03-grade-form.vue | 51 +++++ .../infra/demo/demo03/normal/modules/form.vue | 119 ++++++++++ 5 files changed, 679 insertions(+) create mode 100644 apps/web-ele/src/views/infra/demo/demo03/normal/data.ts create mode 100644 apps/web-ele/src/views/infra/demo/demo03/normal/index.vue create mode 100644 apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-course-form.vue create mode 100644 apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-grade-form.vue create mode 100644 apps/web-ele/src/views/infra/demo/demo03/normal/modules/form.vue diff --git a/apps/web-ele/src/views/infra/demo/demo03/normal/data.ts b/apps/web-ele/src/views/infra/demo/demo03/normal/data.ts new file mode 100644 index 000000000..3872175e0 --- /dev/null +++ b/apps/web-ele/src/views/infra/demo/demo03/normal/data.ts @@ -0,0 +1,208 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { Demo03StudentApi } from '#/api/infra/demo/demo03/normal'; + +import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '名字', + rules: 'required', + component: 'Input', + componentProps: { + placeholder: '请输入名字', + }, + }, + { + fieldName: 'sex', + label: '性别', + rules: 'required', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + }, + { + fieldName: 'birthday', + label: '出生日期', + rules: 'required', + component: 'DatePicker', + componentProps: { + showTime: true, + format: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x', + }, + }, + { + fieldName: 'description', + label: '简介', + rules: 'required', + component: 'RichTextarea', + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '名字', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入名字', + }, + }, + { + fieldName: 'sex', + label: '性别', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number'), + placeholder: '请选择性别', + }, + }, + { + fieldName: 'description', + label: '简介', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入简介', + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 40 }, + { + field: 'id', + title: '编号', + minWidth: 120, + }, + { + field: 'name', + title: '名字', + minWidth: 120, + }, + { + field: 'sex', + title: '性别', + minWidth: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.SYSTEM_USER_SEX }, + }, + }, + { + field: 'birthday', + title: '出生日期', + minWidth: 120, + formatter: 'formatDateTime', + }, + { + field: 'description', + title: '简介', + minWidth: 120, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 120, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 200, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} + +// ==================== 子表(学生课程) ==================== + +/** 新增/修改列表的字段 */ +export function useDemo03CourseGridEditColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'name', + title: '名字', + minWidth: 120, + slots: { default: 'name' }, + }, + { + field: 'score', + title: '分数', + minWidth: 120, + slots: { default: 'score' }, + }, + { + title: '操作', + width: 200, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} + +// ==================== 子表(学生班级) ==================== + +/** 新增/修改的表单 */ +export function useDemo03GradeFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '名字', + rules: 'required', + component: 'Input', + componentProps: { + placeholder: '请输入名字', + }, + }, + { + fieldName: 'teacher', + label: '班主任', + rules: 'required', + component: 'Input', + componentProps: { + placeholder: '请输入班主任', + }, + }, + ]; +} diff --git a/apps/web-ele/src/views/infra/demo/demo03/normal/index.vue b/apps/web-ele/src/views/infra/demo/demo03/normal/index.vue new file mode 100644 index 000000000..1b2ff4045 --- /dev/null +++ b/apps/web-ele/src/views/infra/demo/demo03/normal/index.vue @@ -0,0 +1,185 @@ + + + diff --git a/apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-course-form.vue b/apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-course-form.vue new file mode 100644 index 000000000..c60eb281c --- /dev/null +++ b/apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-course-form.vue @@ -0,0 +1,116 @@ + + + diff --git a/apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-grade-form.vue b/apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-grade-form.vue new file mode 100644 index 000000000..5d5f396bf --- /dev/null +++ b/apps/web-ele/src/views/infra/demo/demo03/normal/modules/demo03-grade-form.vue @@ -0,0 +1,51 @@ + + + diff --git a/apps/web-ele/src/views/infra/demo/demo03/normal/modules/form.vue b/apps/web-ele/src/views/infra/demo/demo03/normal/modules/form.vue new file mode 100644 index 000000000..fe255a158 --- /dev/null +++ b/apps/web-ele/src/views/infra/demo/demo03/normal/modules/form.vue @@ -0,0 +1,119 @@ + + +