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