add examples

This commit is contained in:
chenos 2020-12-27 21:53:44 +08:00
parent 04e9393dea
commit cf47b9f282
5 changed files with 162 additions and 2 deletions

View File

@ -0,0 +1,90 @@
import { TableOptions } from '@nocobase/database';
export default {
title: '作者',
showInDataMenu: true,
name: 'authors',
// createdBy: true,
// updatedBy: true,
fields: [
{
interface: 'string',
title: '姓名',
name: 'name',
component: {
showInTable: true,
showInDetail: true,
showInForm: true,
},
},
{
interface: 'radio',
title: '性别',
dataSource: [
{value: 'male', label: '男性'},
{value: 'female', label: '女性'},
],
component: {
showInTable: true,
showInDetail: true,
showInForm: true,
},
},
{
interface: 'number',
title: '年龄',
component: {
showInTable: true,
showInDetail: true,
showInForm: true,
},
},
{
interface: 'linkTo',
title: '书籍',
target: 'books',
labelField: 'name',
component: {
showInTable: true,
showInDetail: true,
showInForm: true,
},
},
{
interface: 'createdBy',
title: '创建人',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
},
{
interface: 'updatedBy',
title: '更新人',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
},
{
interface: 'createdAt',
title: '创建日期',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
},
{
interface: 'updatedAt',
title: '更新日期',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
}
],
};

View File

@ -0,0 +1,68 @@
import { TableOptions } from '@nocobase/database';
export default {
title: '书籍',
showInDataMenu: true,
name: 'books',
// createdBy: true,
// updatedBy: true,
fields: [
{
interface: 'string',
title: '书籍名称',
name: 'name',
component: {
showInTable: true,
showInDetail: true,
showInForm: true,
},
},
{
interface: 'linkTo',
title: '作者',
target: 'authors',
labelField: 'name',
component: {
showInTable: true,
showInDetail: true,
showInForm: true,
},
},
{
interface: 'createdBy',
title: '创建人',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
},
{
interface: 'updatedBy',
title: '更新人',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
},
{
interface: 'createdAt',
title: '创建日期',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
},
{
interface: 'updatedAt',
title: '更新日期',
component: {
showInTable: true,
showInDetail: true,
// showInForm: true,
},
}
],
};

View File

@ -196,5 +196,7 @@ api.registerPlugin('plugin-file-manager', [path.resolve(__dirname, '../../../plu
default: true
});
await database.getModel('collections').import(require('./collections/example').default);
await database.getModel('collections').import(require('./collections/authors').default);
await database.getModel('collections').import(require('./collections/books').default);
await database.close();
})();

View File

@ -178,7 +178,7 @@ export default {
interface: 'boolean',
type: 'boolean',
name: 'default',
title: '默认标签页',
title: '作为默认标签页',
defaultValue: false,
component: {
type: 'checkbox',

View File

@ -141,7 +141,7 @@ export default {
interface: 'boolean',
type: 'boolean',
name: 'default',
title: '默认视图',
title: '作为默认试图',
defaultValue: false,
component: {
type: 'checkbox',