diff --git a/packages/amis-editor/src/plugin/Date.tsx b/packages/amis-editor/src/plugin/Date.tsx index e3db45e39..ccbc82143 100644 --- a/packages/amis-editor/src/plugin/Date.tsx +++ b/packages/amis-editor/src/plugin/Date.tsx @@ -26,47 +26,45 @@ export class DatePlugin extends BasePlugin { }; panelTitle = '日期展示'; + panelJustify = true; panelBodyCreator = (context: BaseEventContext) => { return [ getSchemaTpl('tabs', [ { - title: '常规', - body: [ + title: '属性', + body: getSchemaTpl('collapseGroup', [ { - type: 'input-date', - name: 'value', - label: '日期数值' + title: '基本', + body: [ + { + type: 'input-date', + name: 'value', + label: '日期数值' + }, + { + type: 'input-text', + name: 'format', + label: '显示日期格式', + description: '请参考 moment 中的格式用法。', + pipeIn: defaultValue('YYYY-MM-DD') + }, + { + type: 'input-text', + name: 'valueFormat', + label: '数据日期格式', + description: '请参考 moment 中的格式用法。', + pipeIn: defaultValue('X') + }, + getSchemaTpl('placeholder', { + pipeIn: defaultValue('-'), + label: '占位符' + }) + ] }, - { - type: 'input-text', - name: 'format', - label: '显示日期格式', - description: '请参考 moment 中的格式用法。', - pipeIn: defaultValue('YYYY-MM-DD') - }, - { - type: 'input-text', - name: 'valueFormat', - label: '数据日期格式', - description: '请参考 moment 中的格式用法。', - pipeIn: defaultValue('X') - }, - { - name: 'placeholder', - type: 'input-text', - pipeIn: defaultValue('-'), - label: '占位符' - } - ] + getSchemaTpl('status') + ]) }, - { - title: '外观', - body: [getSchemaTpl('className')] - }, - { - title: '显隐', - body: [getSchemaTpl('ref'), getSchemaTpl('visible')] - } + getSchemaTpl('onlyClassNameTab') ]) ]; }; diff --git a/packages/amis-editor/src/plugin/Datetime.tsx b/packages/amis-editor/src/plugin/Datetime.tsx index db435e4b3..bdb5fda44 100644 --- a/packages/amis-editor/src/plugin/Datetime.tsx +++ b/packages/amis-editor/src/plugin/Datetime.tsx @@ -21,47 +21,45 @@ export class DatetimePlugin extends DatePlugin { format: 'YYYY-MM-DD HH:mm:ss', value: Math.round(Date.now() / 1000) }; + panelJustify = true; panelBodyCreator = (context: BaseEventContext) => { return [ getSchemaTpl('tabs', [ { - title: '常规', - body: [ + title: '属性', + body: getSchemaTpl('collapseGroup', [ { - type: 'input-datetime', - name: 'value', - label: '日期时间数值' + title: '基本', + body: [ + { + type: 'input-datetime', + name: 'value', + label: '日期时间数值' + }, + { + type: 'input-text', + name: 'format', + label: '显示日期时间格式', + description: '请参考 moment 中的格式用法。', + pipeIn: defaultValue('YYYY-MM-DD HH:mm:ss') + }, + { + type: 'input-text', + name: 'valueFormat', + label: '数据日期格式', + description: '请参考 moment 中的格式用法。', + pipeIn: defaultValue('X') + }, + getSchemaTpl('placeholder', { + pipeIn: defaultValue('-'), + label: '占位符' + }) + ] }, - { - type: 'input-text', - name: 'format', - label: '显示日期时间格式', - description: '请参考 moment 中的格式用法。', - pipeIn: defaultValue('YYYY-MM-DD HH:mm:ss') - }, - { - type: 'input-text', - name: 'valueFormat', - label: '数据日期格式', - description: '请参考 moment 中的格式用法。', - pipeIn: defaultValue('X') - }, - { - name: 'placeholder', - type: 'input-text', - pipeIn: defaultValue('-'), - label: '占位符' - } - ] + getSchemaTpl('status') + ]) }, - { - title: '外观', - body: [getSchemaTpl('className')] - }, - { - title: '显隐', - body: [getSchemaTpl('ref'), getSchemaTpl('visible')] - } + getSchemaTpl('onlyClassNameTab') ]) ]; }; diff --git a/packages/amis-editor/src/plugin/Form/Static.tsx b/packages/amis-editor/src/plugin/Form/Static.tsx index 1131d1015..d6cbb59eb 100644 --- a/packages/amis-editor/src/plugin/Form/Static.tsx +++ b/packages/amis-editor/src/plugin/Form/Static.tsx @@ -1,11 +1,249 @@ import React from 'react'; import {Button} from 'amis'; -import {defaultValue, getSchemaTpl} from 'amis-editor-core'; +import {defaultValue, getSchemaTpl, setSchemaTpl, tipedLabel} from 'amis-editor-core'; import {registerEditorPlugin} from 'amis-editor-core'; import {BaseEventContext, BasePlugin} from 'amis-editor-core'; import {EditorNodeType} from 'amis-editor-core'; import {mockValue} from 'amis-editor-core'; +// 快速编辑 +setSchemaTpl('quickEdit', { + type: 'ae-switch-more', + mode: 'normal', + name: 'quickEdit', + label: '可快速编辑', + value: false, + hiddenOnDefault: true, + formType: 'extend', + pipeIn: (value: any) => !!value, + form: { + body: [ + { + label: '编辑模式', + name: 'quickEdit.mode', + type: 'button-group-select', + inputClassName: 'items-center', + visibleOn: 'data.quickEdit', + pipeIn: defaultValue('popOver'), + options: [ + { + label: '下拉', + value: 'popOver' + }, + { + label: '内嵌', + value: 'inline' + } + ] + }, + getSchemaTpl('switch', { + name: 'quickEdit.saveImmediately', + label: tipedLabel('立即保存', '开启后修改即提交,而不是标记修改批量提交。'), + visibleOn: 'data.quickEdit', + pipeIn: (value: any) => !!value + }), + getSchemaTpl('apiControl', { + name: 'quickEdit.saveImmediately.api', + label: '保存接口', + mode: 'row', + description: + '单独给立即保存配置接口,如果不配置,则默认使用quickSaveItemApi。', + visibleOn: 'this.quickEdit && this.quickEdit.saveImmediately' + }), + { + name: 'quickEdit', + asFormItem: true, + visibleOn: 'data.quickEdit', + mode: 'row', + children: ({value, onChange, data}: any) => { + if (value === true) { + value = {}; + } + + const originMode = value.mode; + + value = { + type: 'input-text', + name: data.name, + ...value + }; + delete value.mode; + + // todo 多个快速编辑表单模式看来只能代码模式编辑了。 + + return ( + + ); + } + } + ] + } +}); + +// 查看更多 +setSchemaTpl('morePopOver', { + type: 'ae-switch-more', + mode: 'normal', + name: 'popOver', + label: '查看更多展示', + value: false, + hiddenOnDefault: true, + formType: 'extend', + pipeIn: (value: any) => !!value, + form: { + body: [ + { + label: '弹出模式', + name: 'popOver.mode', + type: 'button-group-select', + visibleOn: 'data.popOver', + pipeIn: defaultValue('popOver'), + options: [ + { + label: '浮层', + value: 'popOver' + }, + + { + label: '弹框', + value: 'dialog' + }, + + { + label: '抽屉', + value: 'drawer' + } + ] + }, + { + name: 'popOver.position', + label: '浮层位置', + type: 'select', + visibleOn: 'data.popOver && (data.popOver.mode === "popOver" || !data.popOver.mode)', + pipeIn: defaultValue('center'), + options: [ + { + label: '目标左上角', + value: 'left-top' + }, + { + label: '目标右上角', + value: 'right-top' + }, + { + label: '目标中部', + value: 'center' + }, + { + label: '目标左下角', + value: 'left-bottom' + }, + { + label: '目标右下角', + value: 'right-bottom' + }, + { + label: '页面左上角', + value: 'fixed-left-top' + }, + { + label: '页面右上角', + value: 'fixed-right-top' + }, + { + label: '页面左下角', + value: 'fixed-left-bottom' + }, + { + label: '页面右下角', + value: 'fixed-right-bottom' + } + ] + }, + { + visibleOn: 'data.popOver', + name: 'popOver', + mode: 'row', + asFormItem: true, + children: ({value, onChange}: any) => { + value = { + type: 'panel', + title: '查看详情', + body: '内容详情', + ...value + }; + + return ( + + ); + } + } + ] + } +}); + +// 可复制 +setSchemaTpl('copyable', { + type: 'ae-switch-more', + mode: 'normal', + name: 'copyable', + label: '可复制', + value: false, + hiddenOnDefault: true, + formType: 'extend', + pipeIn: (value: any) => !!value, + form: { + body: [ + { + label: '复制内容模板', + name: 'copyable.content', + type: 'textarea', + mode: 'row', + maxRow: 2, + visibleOn: 'data.copyable', + description: '默认为当前字段值,可定制。' + } + ] + } +}); + export class StaticControlPlugin extends BasePlugin { // 关联渲染器名字 rendererName = 'static'; @@ -38,10 +276,9 @@ export class StaticControlPlugin extends BasePlugin { ] }; multifactor = true; - notRenderFormZone = true; - panelTitle = '静态展示'; + panelJustify = true; panelBodyCreator = (context: BaseEventContext) => { const renderer: any = context.info.renderer; @@ -52,6 +289,13 @@ export class StaticControlPlugin extends BasePlugin { { title: '基本', body: [ + { + type: 'alert', + inline: false, + level: 'warning', + className: 'text-sm', + body: '
当前组件已停止维护,建议您使用静态展示新特性实现表单项及整个表单的静态展示。
' + }, getSchemaTpl('formItemName', { required: false }), @@ -64,241 +308,15 @@ export class StaticControlPlugin extends BasePlugin { // ...context?.schema, // type: 'textarea', // 改用多行文本编辑 // value: context?.schema.tpl // 避免默认值丢失 - // }, - mode: 'vertical' // 改成上下展示模式 + // } }), - getSchemaTpl('switch', { - name: 'quickEdit', - label: '可快速编辑', - pipeIn: (value: any) => !!value - }), - { - label: '快速编辑模式', - name: 'quickEdit.mode', - type: 'button-group-select', - size: 'sm', - mode: 'row', - className: 'ae-buttonGroupSelect--justify', - visibleOn: 'data.quickEdit', - pipeIn: defaultValue('popOver'), - options: [ - { - label: '下拉', - value: 'popOver' - }, - { - label: '内嵌', - value: 'inline' - } - ] - }, - getSchemaTpl('switch', { - name: 'quickEdit.saveImmediately', - label: '立即保存', - visibleOn: 'data.quickEdit', - labelRemark: { - className: 'm-l-xs', - trigger: 'click', - rootClose: true, - placement: 'left', - content: '开启后修改即提交,而不是标记修改批量提交。' - }, - pipeIn: (value: any) => !!value - }), - getSchemaTpl('apiControl', { - name: 'quickEdit.saveImmediately.api', - label: '立即保存接口', - description: - '是否单独给立即保存配置接口,如果不配置,则默认使用quickSaveItemApi。', - visibleOn: 'this.quickEdit && this.quickEdit.saveImmediately' - }), - { - name: 'quickEdit', - asFormItem: true, - visibleOn: 'data.quickEdit', - children: ({value, onChange, data}: any) => { - if (value === true) { - value = {}; - } - - const originMode = value.mode; - - value = { - type: 'input-text', - name: data.name, - ...value - }; - delete value.mode; - - // todo 多个快速编辑表单模式看来只能代码模式编辑了。 - - return ( - - ); - } - }, - getSchemaTpl('switch', { - name: 'popOver', - label: '查看更多展示', - pipeIn: (value: any) => !!value - }), - { - label: '弹出模式', - name: 'popOver.mode', - type: 'button-group-select', - size: 'sm', - mode: 'row', - className: 'ae-buttonGroupSelect--justify', - visibleOn: 'data.popOver', - pipeIn: defaultValue('popOver'), - options: [ - { - label: '浮层', - value: 'popOver' - }, - - { - label: '弹框', - value: 'dialog' - }, - - { - label: '抽屉', - value: 'drawer' - } - ] - }, - { - name: 'popOver.position', - label: '浮层位置', - type: 'select', - mode: 'row', - visibleOn: 'data.popOver && data.popOver.mode === "popOver"', - pipeIn: defaultValue('center'), - options: [ - { - label: '目标中部', - value: 'center' - }, - - { - label: '目标左上角', - value: 'left-top' - }, - - { - label: '目标右上角', - value: 'right-top' - }, - - { - label: '目标左下角', - value: 'left-bottom' - }, - - { - label: '目标右下角', - value: 'right-bottom' - }, - - { - label: '页面左上角', - value: 'fixed-left-top' - }, - - { - label: '页面右上角', - value: 'fixed-right-top' - }, - - { - label: '页面左下角', - value: 'fixed-left-bottom' - }, - - { - label: '页面右下角', - value: 'fixed-right-bottom' - } - ] - }, - { - visibleOn: 'data.popOver', - name: 'popOver', - asFormItem: true, - children: ({value, onChange}: any) => { - value = { - type: 'panel', - title: '查看详情', - body: '内容详情', - ...value - }; - - return ( - - ); - } - }, - getSchemaTpl('borderMode'), - getSchemaTpl('switch', { - name: 'copyable', - label: '可复制', - pipeIn: (value: any) => !!value - }), - - { - label: '复制内容模板', - name: 'copyable.content', - type: 'textarea', - mode: 'row', - maxRow: 2, - visibleOn: 'data.copyable', - description: '默认为当前字段值,可定制。' - }, + getSchemaTpl('quickEdit'), + getSchemaTpl('morePopOver'), + getSchemaTpl('copyable'), getSchemaTpl('labelRemark'), getSchemaTpl('remark'), getSchemaTpl('placeholder'), - getSchemaTpl('description'), - getSchemaTpl('autoFillApi') + getSchemaTpl('description') /*{ children: (