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": {
"@nocobase/database": "^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": {
"@nocobase/actions": "^0.3.0-alpha.0"

View File

@ -54,11 +54,39 @@ export default {
name: 'interface',
title: '字段类型',
dataSource: options,
createOnly: true,
component: {
type: 'select',
showInTable: true,
showInDetail: 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',
},
},
{
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',
multiple: false,
@ -137,7 +229,7 @@ export default {
},
},
{
interface: 'string',
interface: 'textarea',
type: 'virtual',
name: 'component.tooltip',
title: '提示信息',
@ -209,17 +301,6 @@ export default {
type: 'drawerSelect',
},
},
{
interface: 'boolean',
type: 'virtual',
name: 'showTime',
title: '显示时间',
defaultValue: false,
component: {
type: 'boolean',
showInForm: true,
},
},
{
interface: 'boolean',
type: 'boolean',

View File

@ -51,6 +51,7 @@ export default {
title: '视图类型',
dataSource: [
{ label: '表格', value: 'table' },
{ label: '表单', value: 'form' },
{ label: '看板', value: 'kanban', disabled: true },
{ label: '日历', value: 'calendar', disabled: true },
{ label: '地图', value: 'map', disabled: true },
@ -63,10 +64,15 @@ export default {
},
},
{
interface: 'string',
interface: 'select',
type: 'string',
name: 'template',
title: '模板',
dataSource: [
{ label: '表单', value: 'DrawerForm' },
{ label: '常规表格', value: 'Table' },
{ label: '简易表格', value: 'SimpleTable' },
],
component: {
type: 'string',
showInTable: true,
@ -74,6 +80,36 @@ export default {
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',
type: 'boolean',

View File

@ -37,6 +37,9 @@ const transforms = {
if (mode === 'update' && field.get('createOnly')) {
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');
if (defaultValue) {
prop.default = defaultValue;