review:代码生成的 demo01、demo02
parent
4f90f46a8f
commit
1f914e2ce2
|
@ -51,12 +51,14 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
valueFormat: 'x',
|
valueFormat: 'x',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// TODO 【富文本】@puhui999:@芋艿:后续要封装下;单独 pr
|
||||||
{
|
{
|
||||||
fieldName: 'description',
|
fieldName: 'description',
|
||||||
label: '简介',
|
label: '简介',
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
component: 'Editor',
|
component: 'Editor',
|
||||||
},
|
},
|
||||||
|
// TODO 【文件上传】@puhui999:@芋艿:后续要封装下;单独 pr
|
||||||
{
|
{
|
||||||
fieldName: 'avatar',
|
fieldName: 'avatar',
|
||||||
label: '头像',
|
label: '头像',
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { Demo01ContactApi } from '#/api/infra/demo/demo01';
|
import type { Demo01ContactApi } from '#/api/infra/demo/demo01';
|
||||||
|
|
||||||
import { DocAlert } from '#/components/doc-alert';
|
|
||||||
import Form from './modules/form.vue';
|
import Form from './modules/form.vue';
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { Download, Plus } from '@vben/icons';
|
import { Download, Plus } from '@vben/icons';
|
||||||
|
@ -63,14 +62,14 @@ async function onDelete(row: Demo01ContactApi.Demo01Contact) {
|
||||||
/** 表格操作按钮的回调函数 */
|
/** 表格操作按钮的回调函数 */
|
||||||
function onActionClick({ code, row }: OnActionClickParams<Demo01ContactApi.Demo01Contact>) {
|
function onActionClick({ code, row }: OnActionClickParams<Demo01ContactApi.Demo01Contact>) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'edit': {
|
case 'edit': {
|
||||||
onEdit(row);
|
onEdit(row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +105,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<DocAlert title="示例联系人" url="https://doc.iocoder.cn/infra/" />
|
|
||||||
|
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="onRefresh" />
|
||||||
<Grid table-title="示例联系人列表">
|
<Grid table-title="示例联系人列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
|
|
|
@ -20,10 +20,7 @@ const getTitle = computed(() => {
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: useFormSchema(),
|
schema: useFormSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false
|
||||||
commonConfig: {
|
|
||||||
labelWidth: 120,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
|
|
@ -83,6 +83,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
|
// TODO @puhui999:缺了你写的哪个时间选择哈
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -132,7 +133,7 @@ export function useGridColumns(
|
||||||
name: 'CellOperation',
|
name: 'CellOperation',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
code: 'add_child',
|
code: 'add_child', // TODO @puhui999:append 使用这个单词哈,和之前 vben 官方示例一致
|
||||||
text: '新增下级',
|
text: '新增下级',
|
||||||
show: hasAccessByCodes(['infra:demo02-category:create']),
|
show: hasAccessByCodes(['infra:demo02-category:create']),
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,8 +13,7 @@ import { useFormSchema } from '../data';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
const formData = ref<Demo02CategoryApi.Demo02Category>();
|
const formData = ref<Demo02CategoryApi.Demo02Category>();
|
||||||
// 新增下级时的父级ID
|
const parentId = ref<number>(); // 新增下级时的父级 ID
|
||||||
const parentId = ref<number>();
|
|
||||||
|
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
if (formData.value?.id) {
|
if (formData.value?.id) {
|
||||||
|
@ -26,10 +25,7 @@ const getTitle = computed(() => {
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: useFormSchema(),
|
schema: useFormSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false
|
||||||
commonConfig: {
|
|
||||||
labelWidth: 120,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
@ -65,6 +61,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理新增下级的情况
|
// 处理新增下级的情况
|
||||||
|
// TODO @puhui999:按照 dept 或者 menu 的 form 处理风格,可以更简洁一点;可能 parentId 也不用啦
|
||||||
if (!data.id && data.parentId) {
|
if (!data.id && data.parentId) {
|
||||||
parentId.value = data.parentId;
|
parentId.value = data.parentId;
|
||||||
formData.value = { parentId: parentId.value } as Demo02CategoryApi.Demo02Category;
|
formData.value = { parentId: parentId.value } as Demo02CategoryApi.Demo02Category;
|
||||||
|
|
Loading…
Reference in New Issue