feat: improve fields & views tables options

This commit is contained in:
chenos 2020-12-09 20:46:57 +08:00
parent 13385b8ab3
commit 9b73e2a7d3
4 changed files with 135 additions and 14 deletions

View File

@ -6,7 +6,8 @@
"dependencies": { "dependencies": {
"@nocobase/database": "^0.3.0-alpha.0", "@nocobase/database": "^0.3.0-alpha.0",
"@nocobase/resourcer": "^0.3.0-alpha.0", "@nocobase/resourcer": "^0.3.0-alpha.0",
"@nocobase/server": "^0.3.0-alpha.0" "@nocobase/server": "^0.3.0-alpha.0",
"deepmerge": "^4.2.2"
}, },
"devDependencies": { "devDependencies": {
"@nocobase/actions": "^0.3.0-alpha.0" "@nocobase/actions": "^0.3.0-alpha.0"

View File

@ -54,11 +54,39 @@ export default {
name: 'interface', name: 'interface',
title: '字段类型', title: '字段类型',
dataSource: options, dataSource: options,
createOnly: true,
component: { component: {
type: 'select', type: 'select',
showInTable: true, showInTable: true,
showInDetail: true, showInDetail: true,
showInForm: true, showInForm: true,
"x-linkages": [
{
"type": "value:visible",
"target": "precision",
"condition": "{{ ['number', 'percent'].indexOf($self.value) !== -1 }}"
},
{
"type": "value:visible",
"target": "dataSource",
"condition": "{{ ['select', 'multipleSelect', 'radio', 'checkboxes'].indexOf($self.value) !== -1 }}"
},
{
"type": "value:visible",
"target": "dateFormat",
"condition": "{{ ['datetime', 'createdAt', 'updatedAt'].indexOf($self.value) !== -1 }}"
},
{
"type": "value:visible",
"target": "showTime",
"condition": "{{ ['datetime', 'createdAt', 'updatedAt'].indexOf($self.value) !== -1 }}"
},
{
"type": "value:visible",
"target": "timeFormat",
"condition": "{{ ['time', 'datetime', 'createdAt', 'updatedAt'].indexOf($self.value) !== -1 }}"
},
],
}, },
}, },
{ {
@ -110,6 +138,70 @@ export default {
type: 'number', type: 'number',
}, },
}, },
{
interface: 'select',
type: 'virtual',
name: 'precision',
title: '精度',
defaultValue: 0,
dataSource: [
{value: 0, label: '1'},
{value: 1, label: '1.0'},
{value: 2, label: '1.00'},
{value: 3, label: '1.000'},
{value: 4, label: '1.0000'},
],
component: {
type: 'number',
showInForm: true,
},
},
{
interface: 'select',
type: 'virtual',
name: 'dateFormat',
title: '日期格式',
defaultValue: 'YYYY-MM-DD',
dataSource: [
{value: 'YYYY-MM-DD', label: 'YYYY-MM-DD'},
],
component: {
type: 'string',
showInForm: true,
},
},
{
interface: 'boolean',
type: 'virtual',
name: 'showTime',
title: '显示时间',
defaultValue: false,
component: {
type: 'boolean',
showInForm: true,
"x-linkages": [
{
"type": "value:visible",
"target": "timeFormat",
"condition": "{{ ($form.values && $form.values.interface === 'time') || $self.value === true }}"
},
],
},
},
{
interface: 'select',
type: 'virtual',
name: 'timeFormat',
title: '时间格式',
defaultValue: 'HH:mm:ss',
dataSource: [
{ value: 'HH:mm:ss', label: 'HH:mm:ss' },
],
component: {
type: 'string',
showInForm: true,
},
},
{ {
interface: 'linkTo', interface: 'linkTo',
multiple: false, multiple: false,
@ -137,7 +229,7 @@ export default {
}, },
}, },
{ {
interface: 'string', interface: 'textarea',
type: 'virtual', type: 'virtual',
name: 'component.tooltip', name: 'component.tooltip',
title: '提示信息', title: '提示信息',
@ -209,17 +301,6 @@ export default {
type: 'drawerSelect', type: 'drawerSelect',
}, },
}, },
{
interface: 'boolean',
type: 'virtual',
name: 'showTime',
title: '显示时间',
defaultValue: false,
component: {
type: 'boolean',
showInForm: true,
},
},
{ {
interface: 'boolean', interface: 'boolean',
type: 'boolean', type: 'boolean',

View File

@ -51,6 +51,7 @@ export default {
title: '视图类型', title: '视图类型',
dataSource: [ dataSource: [
{ label: '表格', value: 'table' }, { label: '表格', value: 'table' },
{ label: '表单', value: 'form' },
{ label: '看板', value: 'kanban', disabled: true }, { label: '看板', value: 'kanban', disabled: true },
{ label: '日历', value: 'calendar', disabled: true }, { label: '日历', value: 'calendar', disabled: true },
{ label: '地图', value: 'map', disabled: true }, { label: '地图', value: 'map', disabled: true },
@ -63,10 +64,15 @@ export default {
}, },
}, },
{ {
interface: 'string', interface: 'select',
type: 'string', type: 'string',
name: 'template', name: 'template',
title: '模板', title: '模板',
dataSource: [
{ label: '表单', value: 'DrawerForm' },
{ label: '常规表格', value: 'Table' },
{ label: '简易表格', value: 'SimpleTable' },
],
component: { component: {
type: 'string', type: 'string',
showInTable: true, showInTable: true,
@ -74,6 +80,36 @@ export default {
showInForm: true, showInForm: true,
}, },
}, },
{
interface: 'radio',
type: 'virtual',
name: 'defaultPerPage',
title: '每页显示几行数据',
defaultValue: 50,
dataSource: [
{label: '20', value: 20},
{label: '50', value: 50},
{label: '100', value: 100},
],
component: {
type: 'radio',
showInForm: true,
showInDetail: true,
},
},
{
interface: 'boolean',
type: 'virtual',
name: 'draggable',
title: '支持拖拽数据排序',
showInForm: true,
showInDetail: true,
component: {
type: 'checkbox',
showInForm: true,
showInDetail: true,
},
},
{ {
interface: 'boolean', interface: 'boolean',
type: 'boolean', type: 'boolean',

View File

@ -37,6 +37,9 @@ const transforms = {
if (mode === 'update' && field.get('createOnly')) { if (mode === 'update' && field.get('createOnly')) {
set(prop, 'x-component-props.disabled', true); set(prop, 'x-component-props.disabled', true);
} }
if (typeof field.get('showTime') === 'boolean') {
set(prop, 'x-component-props.showTime', field.get('showTime'));
}
const defaultValue = get(field.options, 'defaultValue'); const defaultValue = get(field.options, 'defaultValue');
if (defaultValue) { if (defaultValue) {
prop.default = defaultValue; prop.default = defaultValue;