amis-saas-8885 Merge remote-tracking branch 'origin/pre-release' into feat-optimize-6

Change-Id: I90e4427415bd7686abd21aa916f4737bb20b5a33
This commit is contained in:
igrowp 2023-01-05 17:19:34 +08:00
commit e9c68e9011
126 changed files with 3879 additions and 3276 deletions

View File

@ -1,6 +1,6 @@
{
"name": "amis-editor",
"version": "5.2.2-alpha.5",
"version": "5.2.3-beta.15",
"description": "amis 可视化编辑器",
"main": "lib/index.js",
"module": "esm/index.js",
@ -53,10 +53,6 @@
"@types/sortablejs": "^1.10.7",
"@types/tinycolor2": "^1.4.3",
"ajv": "^8.8.2",
"amis": "2.5.3-beta.0",
"amis-core": "2.5.3-beta.0",
"amis-formula": "2.5.3-beta.0",
"amis-ui": "2.5.3-beta.0",
"axios": "0.21.1",
"concurrently": "^6.2.0",
"css-loader": "^6.2.0",

View File

@ -80,7 +80,8 @@ function transpileDynamicImportForCJS(options) {
return {
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require([',
right: '], function(mod) {fullfill(tslib.__importStar(mod))})})})'
right:
'], function(mod) {fullfill(require("tslib").__importStar(mod))})})})'
};
// return {

View File

@ -390,6 +390,7 @@ export function remarkTpl(config: {
name: 'remark' | 'labelRemark';
label: string;
labelRemark?: string;
i18nEnabled?: boolean;
}) {
return {
type: 'ae-switch-more',
@ -437,13 +438,13 @@ export function remarkTpl(config: {
body: [
{
name: 'title',
type: 'input-text',
type: !config.i18nEnabled ? 'input-text' : 'input-text-i18n',
label: '提示标题',
placeholder: '请输入提示标题'
},
{
name: 'content',
type: 'textarea',
type: !config.i18nEnabled ? 'textarea' : 'textarea-i18n',
label: '内容'
}
]

View File

@ -1249,7 +1249,7 @@ extendLocale('en-US', {
'f2996845b6bf0a07fe26f74f35e42ebe': 'Units',
'e48d95a94e49b81b12a0113a5c253d8f': 'Value label',
'a465db53b8c98f42caa15ca5662f9c90': 'Direction',
'3aed2c11e95a9c0ea1d853d4aee72e8c': 'Automatic',
'3aed2c11e95a9c0ea1d853d4aee72e8c': 'Auto',
'1d1a0bd85740653320d80f0d6e0918e7': 'Inputtable',
'd22aa5f57ff8679ee7b7d473ef31417d': 'Resettable',
'15628d1d85aee23c229c528a70419414': 'Track',
@ -1652,7 +1652,7 @@ extendLocale('en-US', {
'da1b972efb29f850b50e219ad4d98ba5': 'Justified alignment',
'11b7fc50778c89572391ec4c6c4b55e1': 'Vertical alignment',
'2a6ad292447e6354ca39ee7f40d2fcc8': 'Top alignment',
'd68c21b6b65e7a2e361762b65b8a5032': 'Top alignment',
'd68c21b6b65e7a2e361762b65b8a5032': 'Bottom alignment',
'0d9eb53682343f1cbd562c9a944ef5bf': 'Insert a column on the left',
'814276d30e338eccbaee96c3e6bacb61': 'Insert a column on the right',
'2a3e7f5c382c56faf261a87573658325': 'Manual',
@ -3576,8 +3576,8 @@ extendLocale('en-US', {
'bb0e1fea25aafbe731886295fcef9a2e':
'Adsorption container: It can be set as a ceiling or ceiling display.',
'7d30297d4e1f310c73b27be88c748026': 'Adsorption position',
'2ea76e2ffc1b92911d6f7decfa993360': 'Ceiling',
'8cfc818a76662085cb64752d6d592fbe': 'Bottom suction',
'2ea76e2ffc1b92911d6f7decfa993360': 'Top',
'8cfc818a76662085cb64752d6d592fbe': 'Bottom',
'e2f6535e21570a0703c7c65f41b30eaa': 'Rolling adsorption',
'1c5ea0ffb2b15713cb22c41a02576924':
'When rolling adsorption is enabled, the adsorption mode will be automatically enabled when rolling to the upper and lower edges of the parent container.',
@ -3590,5 +3590,20 @@ extendLocale('en-US', {
'5a4e41af91746f8a3905aa9f66048955': 'Load Settings',
'6ade3082696deb00357f5c0359093cd4': 'Merge to upper loading',
'b6ac896eff6a6502e4ae7079b3e507a5': 'Not displaying loading',
'0e9ffe1f1cf3f7a620970ea75dba9f39': 'Use page global loading'
'0e9ffe1f1cf3f7a620970ea75dba9f39': 'Use page global loading',
'b1119174b1beedd2218e0b359ef14aec': 'Form submission',
'c6a65a86cd2bd74a6f72df0a7b81d3cb':
'After the event is configured, the default verification, submission to the api or target and other behaviors will not be triggered when the form is submitted. All behaviors need to be configured by yourself',
'c207ba29769aca6ffd45db9f80bcb29e': 'Zero as head',
'f02f876ee64cc016d97fa4dc498d4857': 'Height setting',
'091885db07e43ff7cbe60c3b664b0b50': 'Elastic',
'363165ccee78341a65f1d42174e8b08f': 'Adaptation',
'eb44269adb6ba70569cd62ea88cb2750': 'Elastic Settings',
'64561733c68085af3d09315c1d4d7ed6': 'Mouse Event Object',
'052f93928af33d4d7035e7c8e8a73f17':
'The alignment is set by the margin value, where margin: 0 auto is used to set the center alignment',
'a738a8594bd2b71002d09277b84d86dd': 'Left',
'fc0f19e9e47e352d36d36cf6eb653210': 'Right',
'c70638412c6cffd150117ae403dea939': 'Component static data',
'77fdd35933c099cdcb64b71f3fbe7a6c': 'Data List'
});

View File

@ -3175,5 +3175,20 @@ extendLocale('zh-CN', {
'5a4e41af91746f8a3905aa9f66048955': '加载设置',
'6ade3082696deb00357f5c0359093cd4': '合并到上层loading',
'b6ac896eff6a6502e4ae7079b3e507a5': '不展示loading',
'0e9ffe1f1cf3f7a620970ea75dba9f39': '使用页面全局loading'
'0e9ffe1f1cf3f7a620970ea75dba9f39': '使用页面全局loading',
'b1119174b1beedd2218e0b359ef14aec': '表单提交',
'c6a65a86cd2bd74a6f72df0a7b81d3cb':
'配置该事件后将不会触发表单提交时默认的校验、提交到api或者target等行为所有行为需要自己配置',
'c207ba29769aca6ffd45db9f80bcb29e': '以零为头部',
'f02f876ee64cc016d97fa4dc498d4857': '高度设置',
'091885db07e43ff7cbe60c3b664b0b50': '弹性',
'363165ccee78341a65f1d42174e8b08f': '适配',
'eb44269adb6ba70569cd62ea88cb2750': '弹性设置',
'64561733c68085af3d09315c1d4d7ed6': '鼠标事件对象',
'052f93928af33d4d7035e7c8e8a73f17':
'通过 margin 数值来设置对齐方式,其中 margin: 0 auto 用于设置居中对齐',
'a738a8594bd2b71002d09277b84d86dd': '靠左',
'fc0f19e9e47e352d36d36cf6eb653210': '靠右',
'c70638412c6cffd150117ae403dea939': '组件静态数据',
'77fdd35933c099cdcb64b71f3fbe7a6c': '数据列表'
});

View File

@ -47,6 +47,7 @@ export class AlertPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '类型',
name: 'level',

View File

@ -75,6 +75,7 @@ export class AnchorNavPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('combo-container', {
type: 'combo',
name: 'links',
@ -87,14 +88,7 @@ export class AnchorNavPlugin extends BasePlugin {
deleteBtn: {
icon: 'fa fa-trash'
},
items: [
{
type: 'input-text',
name: 'title',
required: true,
placeholder: '请输入锚点标题'
}
],
items: [getSchemaTpl('anchorTitle')],
scaffold: {
title: '锚点',
href: '',

View File

@ -31,6 +31,7 @@ export class AudioPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
isUnderField
? {
type: 'tpl',

View File

@ -56,6 +56,7 @@ export class AvatarPlugin extends BasePlugin {
className: 'p-none',
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
// 如果同时存在 src、text 和 icon会优先用 src、接着 text、最后 icon
{
type: 'button-group-select',
@ -140,14 +141,7 @@ export class AvatarPlugin extends BasePlugin {
},
// 文字
{
label: '文字',
name: 'text',
type: 'input-text',
pipeOut: (value: any) =>
value === '' ? undefined : value,
visibleOn: 'data.showtype === "text"'
},
getSchemaTpl('avatarText'),
{
type: 'input-group',
name: 'gap',

View File

@ -45,6 +45,7 @@ export class BreadcrumbPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '分隔符',
type: 'input-text',

View File

@ -46,17 +46,50 @@ export class ButtonPlugin extends BasePlugin {
eventName: 'click',
eventLabel: '点击',
description: '点击时触发',
defaultShow: true
defaultShow: true,
dataSchema: [
{
type: 'object',
properties: {
nativeEvent: {
type: 'object',
title: '鼠标事件对象'
}
}
}
]
},
{
eventName: 'mouseenter',
eventLabel: '鼠标移入',
description: '鼠标移入时触发'
description: '鼠标移入时触发',
dataSchema: [
{
type: 'object',
properties: {
nativeEvent: {
type: 'object',
title: '鼠标事件对象'
}
}
}
]
},
{
eventName: 'mouseleave',
eventLabel: '鼠标移出',
description: '鼠标移出时触发'
description: '鼠标移出时触发',
dataSchema: [
{
type: 'object',
properties: {
nativeEvent: {
type: 'object',
title: '鼠标事件对象'
}
}
}
]
}
// {
// eventName: 'doubleClick',
@ -85,12 +118,10 @@ export class ButtonPlugin extends BasePlugin {
{
title: '基本',
body: [
{
label: '名称',
type: 'input-text',
name: 'label'
},
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('label', {
label: '名称'
}),
{
label: '类型',
type: 'button-group-select',

View File

@ -53,6 +53,7 @@ export class ButtonGroupPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
type: 'button-group-select',
name: 'vertical',

View File

@ -185,285 +185,290 @@ export class CRUDPlugin extends BasePlugin {
}
};
scaffoldForm: ScaffoldForm = {
title: '增删改查快速开始-CRUD',
body: [
getSchemaTpl('apiControl', {
label: '接口地址',
sampleBuilder: (schema: any) =>
JSON.stringify(
{
status: 0,
msg: '',
data: [
{id: 1, name: 'Jack'},
{id: 2, name: 'Rose'}
]
},
null,
2
)
}),
{
type: 'button',
label: '格式校验并自动生成列配置',
className: 'm-t-xs m-b-xs',
onClick: async (e: Event, props: any) => {
const data = props.data;
const schemaFilter = getEnv((window as any).editorStore).schemaFilter;
let api: any = data.api;
// 主要是给爱速搭中替换 url
if (schemaFilter) {
api = schemaFilter({
api: data.api
}).api;
}
const result = await props.env.fetcher(api, data);
get scaffoldForm(): ScaffoldForm {
const {i18nEnabled} = getEnv((window as any).editorStore);
return {
title: '增删改查快速开始-CRUD',
body: [
getSchemaTpl('apiControl', {
label: '接口地址',
sampleBuilder: (schema: any) =>
JSON.stringify(
{
status: 0,
msg: '',
data: [
{id: 1, name: 'Jack'},
{id: 2, name: 'Rose'}
]
},
null,
2
)
}),
{
type: 'button',
label: '格式校验并自动生成列配置',
className: 'm-t-xs m-b-xs',
onClick: async (e: Event, props: any) => {
const data = props.data;
const schemaFilter = getEnv(
(window as any).editorStore
).schemaFilter;
let api: any = data.api;
// 主要是给爱速搭中替换 url
if (schemaFilter) {
api = schemaFilter({
api: data.api
}).api;
}
const result = await props.env.fetcher(api, data);
let autoFillKeyValues: Array<any> = [];
const items = result.data?.rows || result.data?.items;
if (items?.length) {
Object.keys(items[0]).forEach((key: any) => {
const value = items[0][key];
autoFillKeyValues.push({
label: key,
type: 'text',
name: key
let autoFillKeyValues: Array<any> = [];
const items = result.data?.rows || result.data?.items;
if (items?.length) {
Object.keys(items[0]).forEach((key: any) => {
const value = items[0][key];
autoFillKeyValues.push({
label: key,
type: 'text',
name: key
});
});
});
props.formStore.setValues({
columns: autoFillKeyValues
});
// 查询条件的字段列表
props.formStore.setValues({
filterSettingSource: autoFillKeyValues.map(column => {
return column.name;
})
});
} else {
toast.warning(
'API返回格式不正确请点击接口地址右侧示例的问号查看示例'
);
props.formStore.setValues({
columns: autoFillKeyValues
});
// 查询条件的字段列表
props.formStore.setValues({
filterSettingSource: autoFillKeyValues.map(column => {
return column.name;
})
});
} else {
toast.warning(
'API返回格式不正确请点击接口地址右侧示例的问号查看示例'
);
}
}
},
{
name: 'features',
label: '启用功能',
type: 'checkboxes',
joinValues: false,
extractValue: true,
itemClassName: 'max-w-lg',
options: [
{label: '新增', value: 'create'},
{label: '查询', value: 'filter'},
{label: '批量删除', value: 'bulkDelete'},
{label: '批量修改', value: 'bulkUpdate'},
{label: '操作栏-编辑', value: 'update'},
{label: '操作栏-查看详情', value: 'view'},
{label: '操作栏-删除', value: 'delete'}
]
},
{
type: 'group',
body: [
{
columnRatio: 10,
type: 'checkboxes',
label: '启用的查询字段',
name: 'filterEnabledList',
joinValues: false,
source: '${filterSettingSource}'
},
{
columnRatio: 2,
type: 'input-number',
label: '每列显示几个字段',
value: 3,
name: 'filterColumnCount'
}
],
visibleOn: 'data.features && data.features.includes("filter")'
},
{
name: 'columns',
type: 'input-table',
label: false,
addable: true,
removable: true,
needConfirm: false,
columns: [
{
type: i18nEnabled ? 'input-text-i18n' : 'input-text',
name: 'label',
label: '标题'
},
{
type: 'input-text',
name: 'name',
label: '绑定字段名'
},
{
type: 'select',
name: 'type',
label: '类型',
value: 'text',
options: [
{
value: 'text',
label: '纯文本'
},
{
value: 'tpl',
label: '模板'
},
{
value: 'image',
label: '图片'
},
{
value: 'date',
label: '日期'
},
{
value: 'progress',
label: '进度'
},
{
value: 'status',
label: '状态'
},
{
value: 'mapping',
label: '映射'
},
{
value: 'operation',
label: '操作栏'
}
]
}
]
}
},
{
name: 'features',
label: '启用功能',
type: 'checkboxes',
joinValues: false,
extractValue: true,
itemClassName: 'max-w-lg',
options: [
{label: '新增', value: 'create'},
{label: '查询', value: 'filter'},
{label: '批量删除', value: 'bulkDelete'},
{label: '批量修改', value: 'bulkUpdate'},
{label: '操作栏-编辑', value: 'update'},
{label: '操作栏-查看详情', value: 'view'},
{label: '操作栏-删除', value: 'delete'}
]
},
{
type: 'group',
body: [
{
columnRatio: 10,
type: 'checkboxes',
label: '启用的查询字段',
name: 'filterEnabledList',
joinValues: false,
source: '${filterSettingSource}'
},
{
columnRatio: 2,
type: 'input-number',
label: '每列显示几个字段',
value: 3,
name: 'filterColumnCount'
}
],
visibleOn: 'data.features && data.features.includes("filter")'
},
{
name: 'columns',
type: 'input-table',
label: false,
addable: true,
removable: true,
needConfirm: false,
columns: [
{
type: 'input-text',
name: 'label',
label: '标题'
},
{
type: 'input-text',
name: 'name',
label: '绑定字段名'
},
{
type: 'select',
name: 'type',
label: '类型',
value: 'text',
options: [
{
value: 'text',
label: '纯文本'
},
{
value: 'tpl',
label: '模板'
},
{
value: 'image',
label: '图片'
},
{
value: 'date',
label: '日期'
},
{
value: 'progress',
label: '进度'
},
{
value: 'status',
label: '状态'
},
{
value: 'mapping',
label: '映射'
},
{
value: 'operation',
label: '操作栏'
}
]
}
]
}
],
pipeOut: (value: any) => {
let valueSchema = cloneDeep(value);
// 查看/删除 操作,可选择是否使用接口返回值预填充
const features: Array<any> = valueSchema.features;
const oper: {
type: 'operation';
label?: string;
buttons: Array<ActionSchema>;
} = {
type: 'operation',
label: '操作',
buttons: []
};
const itemBtns: Array<string> = ['update', 'view', 'delete'];
const hasFeatures = get(features, 'length');
],
pipeOut: (value: any) => {
let valueSchema = cloneDeep(value);
// 查看/删除 操作,可选择是否使用接口返回值预填充
const features: Array<any> = valueSchema.features;
const oper: {
type: 'operation';
label?: string;
buttons: Array<ActionSchema>;
} = {
type: 'operation',
label: '操作',
buttons: []
};
const itemBtns: Array<string> = ['update', 'view', 'delete'];
const hasFeatures = get(features, 'length');
valueSchema.bulkActions = [];
/** 统一api格式 */
valueSchema.api =
typeof valueSchema.api === 'string'
? normalizeApi(valueSchema.api)
: valueSchema.api;
hasFeatures &&
features.forEach((item: string) => {
if (itemBtns.includes(item)) {
let schema;
valueSchema.bulkActions = [];
/** 统一api格式 */
valueSchema.api =
typeof valueSchema.api === 'string'
? normalizeApi(valueSchema.api)
: valueSchema.api;
hasFeatures &&
features.forEach((item: string) => {
if (itemBtns.includes(item)) {
let schema;
if (item === 'update') {
schema = cloneDeep(this.btnSchemas.update);
schema.dialog.body.body = value.columns
.filter(
({type}: any) => type !== 'progress' && type !== 'operation'
)
.map(({type, ...rest}: any) => ({
...rest,
type: viewTypeToEditType(type)
}));
} else if (item === 'view') {
schema = cloneDeep(this.btnSchemas.view);
schema.dialog.body.body = value.columns.map(
({type, ...rest}: any) => ({
...rest,
type: 'static'
})
);
} else if (item === 'delete') {
schema = cloneDeep(this.btnSchemas.delete);
schema.api = valueSchema.api?.method?.match(/^(post|delete)$/i)
? valueSchema.api
: {...valueSchema.api, method: 'post'};
}
// 添加操作按钮
this.addItem(oper.buttons, schema);
} else {
// 批量操作
if (item === 'bulkUpdate') {
this.addItem(
valueSchema.bulkActions,
cloneDeep(this.btnSchemas.bulkUpdate)
);
}
if (item === 'bulkDelete') {
this.addItem(
valueSchema.bulkActions,
cloneDeep(this.btnSchemas.bulkDelete)
);
}
// 创建
if (item === 'create') {
const createSchemaBase = this.btnSchemas.create;
createSchemaBase.dialog.body = {
type: 'form',
api: valueSchema.api?.method?.match(/^(post|put)$/i)
if (item === 'update') {
schema = cloneDeep(this.btnSchemas.update);
schema.dialog.body.body = value.columns
.filter(
({type}: any) => type !== 'progress' && type !== 'operation'
)
.map(({type, ...rest}: any) => ({
...rest,
type: viewTypeToEditType(type)
}));
} else if (item === 'view') {
schema = cloneDeep(this.btnSchemas.view);
schema.dialog.body.body = value.columns.map(
({type, ...rest}: any) => ({
...rest,
type: 'static'
})
);
} else if (item === 'delete') {
schema = cloneDeep(this.btnSchemas.delete);
schema.api = valueSchema.api?.method?.match(/^(post|delete)$/i)
? valueSchema.api
: {...valueSchema.api, method: 'post'},
body: valueSchema.columns.map((column: ColumnItem) => {
const type = column.type;
return {
type: viewTypeToEditType(type),
name: column.name,
label: column.label
};
})
};
valueSchema.headerToolbar = [createSchemaBase, 'bulkActions'];
}
let keysFilter = Object.keys(valueSchema.filter || {});
if (item === 'filter' && !keysFilter.length) {
if (valueSchema.filterEnabledList) {
valueSchema.filter = {
title: '查询条件'
};
valueSchema.filter.columnCount = value.filterColumnCount;
valueSchema.filter.mode = 'horizontal';
valueSchema.filter.body = valueSchema.filterEnabledList.map(
(item: any) => {
return {
type: 'input-text',
label: item.label,
name: item.value
};
}
: {...valueSchema.api, method: 'post'};
}
// 添加操作按钮
this.addItem(oper.buttons, schema);
} else {
// 批量操作
if (item === 'bulkUpdate') {
this.addItem(
valueSchema.bulkActions,
cloneDeep(this.btnSchemas.bulkUpdate)
);
}
if (item === 'bulkDelete') {
this.addItem(
valueSchema.bulkActions,
cloneDeep(this.btnSchemas.bulkDelete)
);
}
// 创建
if (item === 'create') {
const createSchemaBase = this.btnSchemas.create;
createSchemaBase.dialog.body = {
type: 'form',
api: valueSchema.api?.method?.match(/^(post|put)$/i)
? valueSchema.api
: {...valueSchema.api, method: 'post'},
body: valueSchema.columns.map((column: ColumnItem) => {
const type = column.type;
return {
type: viewTypeToEditType(type),
name: column.name,
label: column.label
};
})
};
valueSchema.headerToolbar = [createSchemaBase, 'bulkActions'];
}
let keysFilter = Object.keys(valueSchema.filter || {});
if (item === 'filter' && !keysFilter.length) {
if (valueSchema.filterEnabledList) {
valueSchema.filter = {
title: '查询条件'
};
valueSchema.filter.columnCount = value.filterColumnCount;
valueSchema.filter.mode = 'horizontal';
valueSchema.filter.body = valueSchema.filterEnabledList.map(
(item: any) => {
return {
type: 'input-text',
label: item.label,
name: item.value
};
}
);
}
}
}
}
});
const hasOperate = valueSchema.columns.find(
(item: any) => item.type === 'operation'
);
hasFeatures && !hasOperate && valueSchema.columns.push(oper);
return valueSchema;
},
canRebuild: true
};
});
const hasOperate = valueSchema.columns.find(
(item: any) => item.type === 'operation'
);
hasFeatures && !hasOperate && valueSchema.columns.push(oper);
return valueSchema;
},
canRebuild: true
};
}
addItem(source: any, target: any) {
const canAdd = source.find((item: any) => item.label === target.label);
@ -524,6 +529,7 @@ export class CRUDPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('switch', {
name: 'filter',
label: '启用查询条件',
@ -579,11 +585,7 @@ export class CRUDPlugin extends BasePlugin {
placement: 'left'
},
items: [
{
type: 'tpl',
tpl: '<span class="label label-success">${label}</span>',
columnClassName: 'p-t-xs'
},
getSchemaTpl('tpl:btnLabel'),
{
columnClassName: 'p-t-xs col-edit',
@ -633,11 +635,7 @@ export class CRUDPlugin extends BasePlugin {
type: 'button'
},
items: [
{
type: 'tpl',
tpl: '<span class="label label-success">${label}</span>',
columnClassName: 'p-t-xs'
},
getSchemaTpl('tpl:btnLabel'),
{
type: 'checkbox',
@ -913,41 +911,12 @@ export class CRUDPlugin extends BasePlugin {
description:
'覆盖默认消息提示,但如果 api 返回 msg 则会优先使用这个 msg',
items: [
{
label: '获取成功提示',
type: 'input-text',
name: 'fetchSuccess'
},
{
label: '获取失败提示',
type: 'input-text',
name: 'fetchFailed'
},
{
label: '保存顺序成功提示',
type: 'input-text',
name: 'saveOrderSuccess'
},
{
label: '保存顺序失败提示',
type: 'input-text',
name: 'saveOrderFailed'
},
{
label: '快速保存成功提示',
type: 'input-text',
name: 'quickSaveSuccess'
},
{
label: '快速保存失败提示',
type: 'input-text',
name: 'quickSaveFailed'
}
getSchemaTpl('fetchSuccess'),
getSchemaTpl('fetchFailed'),
getSchemaTpl('saveOrderSuccess'),
getSchemaTpl('saveOrderFailed'),
getSchemaTpl('quickSaveSuccess'),
getSchemaTpl('quickSaveFailed')
]
}
]
@ -1722,12 +1691,12 @@ export class CRUDPlugin extends BasePlugin {
}
renderRenderer(props: any) {
const $$editor = props.$$editor;
const {$$editor, style, ...rest} = props;
const renderer = $$editor.renderer;
return (
<div className="ae-CRUDEditor">
<div className="ae-CRUDEditor" style={style}>
{this.renderEditableComponents(props)}
<renderer.component {...props} />
<renderer.component $$editor={$$editor} {...rest} />
</div>
);
}
@ -1755,7 +1724,11 @@ export class CRUDPlugin extends BasePlugin {
}
}
async buildDataSchemas(node: EditorNodeType, region?: EditorNodeType) {
async buildDataSchemas(
node: EditorNodeType,
region?: EditorNodeType,
trigger?: EditorNodeType
) {
const child: EditorNodeType = node.children.find(
item => !!~['table', 'table2', 'cards', 'list'].indexOf(item.type)
);
@ -1763,7 +1736,8 @@ export class CRUDPlugin extends BasePlugin {
if (!child?.info?.plugin?.buildDataSchemas) {
return;
}
return child.info.plugin.buildDataSchemas(child);
return child.info.plugin.buildDataSchemas(child, undefined, trigger);
}
}

View File

@ -77,6 +77,7 @@ export class CardPlugin extends BasePlugin {
{
title: '常规',
body: flatten([
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
children: (
<Button
@ -119,30 +120,15 @@ export class CardPlugin extends BasePlugin {
{
type: 'divider'
},
{
name: 'header.title',
type: 'input-text',
label: '标题',
description: '支持模板语法如: <code>\\${xxx}</code>'
},
{
name: 'header.subTitle',
type: 'input-text',
label: '副标题',
description: '支持模板语法如: <code>\\${xxx}</code>'
},
getSchemaTpl('cardTitle'),
getSchemaTpl('cardSubTitle'),
{
name: 'header.avatar',
type: 'input-text',
label: '图片地址',
description: '支持模板语法如: <code>\\${xxx}</code>'
},
{
name: 'header.desc',
type: 'textarea',
label: '描述',
description: '支持模板语法如: <code>\\${xxx}</code>'
},
getSchemaTpl('cardDesc'),
{
name: 'header.highlight',
type: 'input-text',

View File

@ -50,6 +50,7 @@ export class Card2Plugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
type: 'button-group-select',
label: tipedLabel('选择区域', '点击触发选中或取消选中的区域'),

View File

@ -73,11 +73,18 @@ export class CardsPlugin extends BasePlugin {
panelTitle = '卡片集';
panelBodyCreator = (context: BaseEventContext) => {
const isCRUDBody = context.schema.type === 'crud';
const curPosition = context?.schema?.style?.position;
const isAbsolute = curPosition === 'fixed' || curPosition === 'absolute';
return [
getSchemaTpl('tabs', [
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {
visibleOn: isAbsolute ? isAbsolute : undefined,
value: 'left-top'
}),
{
children: (
<div className="m-b">
@ -92,15 +99,10 @@ export class CardsPlugin extends BasePlugin {
</div>
)
},
{
type: 'divider'
},
{
name: 'title',
type: 'input-text',
label: '标题'
},
getSchemaTpl('title'),
{
name: 'href',
type: 'input-text',
@ -117,13 +119,7 @@ export class CardsPlugin extends BasePlugin {
description: '绑定当前环境变量',
test: !isCRUDBody
},
{
name: 'placeholder',
value: '暂无数据',
type: 'input-text',
label: '无数据提示'
}
getSchemaTpl('cardsPlaceholder')
]
},
{

View File

@ -43,6 +43,7 @@ export class CarouselPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
isUnderField
? {
type: 'tpl',
@ -101,23 +102,13 @@ export class CarouselPlugin extends BasePlugin {
getSchemaTpl('imageUrl', {
name: 'content'
}),
{
type: 'input-text',
label: '图片标题',
name: 'title',
visibleOn: 'this.type == "image"'
},
getSchemaTpl('imageTitle'),
getSchemaTpl('className', {
label: '图片标题类名',
name: 'titleClassName',
visibleOn: 'this.type == "image"'
}),
{
type: 'textarea',
label: '图片描述',
name: 'description',
visibleOn: 'this.type == "image"'
},
getSchemaTpl('imageDesc'),
getSchemaTpl('className', {
label: '图片描述类名',
name: 'descriptionClassName',

View File

@ -180,6 +180,7 @@ export class ChartPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('api', {
label: '接口拉取',
description:

View File

@ -28,11 +28,12 @@ export class CodeViewPlugin extends BasePlugin {
};
panelTitle = '代码高亮';
panelBody = [
getSchemaTpl('tabs', [
panelBodyCreator = (context: BaseEventContext) => {
return getSchemaTpl('tabs', [
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
type: 'input-text',
label: '名称',
@ -55,7 +56,7 @@ export class CodeViewPlugin extends BasePlugin {
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
}
])
];
};
}
registerEditorPlugin(CodeViewPlugin);

View File

@ -42,29 +42,9 @@ export class CollapsePlugin extends BasePlugin {
{
title: '基本',
body: [
{
name: 'header',
label: '标题',
type: 'input-text',
pipeIn: defaultValue(
context?.schema?.title || context?.schema?.header || ''
),
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
// 转换一下旧版本的title字段
form.setValueByName('header', value);
form.setValueByName('title', undefined);
}
},
{
name: 'collapseHeader',
label: tipedLabel('展开标题', '折叠器处于展开状态时的标题'),
type: 'input-text'
},
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('collapseHeader'),
getSchemaTpl('collapseOpenHeader'),
{
name: 'headerPosition',
label: '标题位置',

View File

@ -67,6 +67,7 @@ export class CollapseGroupPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
name: 'expandIconPosition',
label: '图标位置',

View File

@ -84,7 +84,7 @@ export class ContainerPlugin extends BasePlugin {
label: '垂直对齐方式',
options: [
{
label: '起点对齐',
label: '顶部对齐',
value: 'flex-start'
},
{
@ -92,7 +92,7 @@ export class ContainerPlugin extends BasePlugin {
value: 'center'
},
{
label: '终点对齐',
label: '底部对齐',
value: 'flex-end'
},
{
@ -138,7 +138,7 @@ export class ContainerPlugin extends BasePlugin {
label: '垂直对齐方式',
options: [
{
label: '起点对齐',
label: '顶部对齐',
value: 'flex-start'
},
{
@ -146,7 +146,7 @@ export class ContainerPlugin extends BasePlugin {
value: 'center'
},
{
label: '终点对齐',
label: '底部对齐',
value: 'flex-end'
},
{
@ -176,15 +176,22 @@ export class ContainerPlugin extends BasePlugin {
{
name: 'wrapperComponent',
label: '容器标签',
type: 'input-text',
type: 'select',
searchable: true,
options: [
'div',
'p',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'article',
'aside',
'code',
'div',
'footer',
'header',
'p',
'section'
],
pipeIn: defaultValue('div'),
@ -203,36 +210,9 @@ export class ContainerPlugin extends BasePlugin {
{
title: '布局',
body: [
isFlexItem
? getSchemaTpl('layout:flex', {
isFlexColumnItem,
onText: isFlexColumnItem ? '弹性高度' : '弹性宽度',
offText: isFlexColumnItem ? '固定高度' : '固定宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-grow', {
visibleOn:
'data.style && data.style.flex !== "0 0 auto" && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '弹性高度' : '弹性宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "1 1 auto"'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '固定高度' : '固定宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "0 0 auto"'
})
: null,
getSchemaTpl('layout:position'),
getSchemaTpl('layout:position', {
visibleOn: '!data.stickyStatus'
}),
getSchemaTpl('layout:originPosition'),
getSchemaTpl('layout:inset', {
mode: 'vertical'
@ -240,6 +220,41 @@ export class ContainerPlugin extends BasePlugin {
// 自由容器不需要 display 相关配置项
...(!isFreeContainer ? displayTpl : []),
isFlexItem
? getSchemaTpl('layout:flex', {
isFlexColumnItem,
label: isFlexColumnItem ? '高度设置' : '宽度设置',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-grow', {
visibleOn:
'data.style && data.style.flex === "1 1 auto" && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '弹性高度' : '弹性宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "1 1 auto"'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '固定高度' : '固定宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "0 0 150px"'
})
: null,
getSchemaTpl('layout:overflow-x', {
visibleOn: `${
isFlexItem && !isFlexColumnItem
} && data.style.flex === '0 0 150px'`
}),
getSchemaTpl('layout:isFixedHeight', {
visibleOn: `${!isFlexItem || !isFlexColumnItem}`
@ -258,7 +273,7 @@ export class ContainerPlugin extends BasePlugin {
!isFlexItem || !isFlexColumnItem
} && (data.isFixedHeight || data.style && data.style.maxHeight) || (${
isFlexItem && isFlexColumnItem
} && data.style.flex === '0 0 auto')`
} && data.style.flex === '0 0 150px')`
}),
getSchemaTpl('layout:isFixedWidth', {
@ -273,13 +288,13 @@ export class ContainerPlugin extends BasePlugin {
getSchemaTpl('layout:min-width', {
visibleOn: `${!isFlexItem || isFlexColumnItem}`
}),
getSchemaTpl('layout:overflow-x', {
visibleOn: `${
!isFlexItem || isFlexColumnItem
} && (data.isFixedWidth || data.style && data.style.maxWidth) || (${
isFlexItem && !isFlexColumnItem
} && data.style.flex === '0 0 auto')`
} && (data.isFixedWidth || data.style && data.style.maxWidth)`
}),
!isFlexItem ? getSchemaTpl('layout:margin-center') : null,
getSchemaTpl('layout:z-index'),
getSchemaTpl('layout:sticky'),

View File

@ -41,6 +41,7 @@ export class CustomPlugin extends BasePlugin {
panelTitle = '自定义代码';
panelBody = [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('fieldSet', {
title: 'HTML 内容',
body: [

View File

@ -53,6 +53,7 @@ export class CustomPlugin extends BasePlugin {
panelTitle = '自定义代码';
panelBody = [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('fieldSet', {
title: 'HTML 内容',
body: [

View File

@ -115,6 +115,7 @@ export class DialogPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '标题',
type: 'input-text',

View File

@ -22,10 +22,17 @@ export class DividerPlugin extends BasePlugin {
};
panelTitle = '分隔线';
panelJustify = true;
panelBody = getSchemaTpl('tabs', [
{
title: '外观',
body: [getSchemaTpl('className')]
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('layout:width:v2', {
visibleOn: 'data.style && data.style.position && (data.style.position === "fixed" || data.style.position === "absolute")',
}),
getSchemaTpl('className')
]
},
{
title: '显隐',

View File

@ -116,6 +116,7 @@ export class DrawerPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '标题',
type: 'input-text',

View File

@ -59,6 +59,7 @@ export class DropDownButtonPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
children: (
<div className="mb-3">
@ -74,11 +75,9 @@ export class DropDownButtonPlugin extends BasePlugin {
</div>
)
},
{
getSchemaTpl('label', {
label: '按钮文案',
type: 'input-text',
name: 'label'
},
}),
{
type: 'button-group-select',
name: 'trigger',

View File

@ -40,6 +40,7 @@ export class EachPlugin extends BasePlugin {
panelTitle = '循环';
panelBodyCreator = (context: BaseEventContext) => {
return [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
type: 'input-text',
name: 'name',
@ -63,14 +64,12 @@ export class EachPlugin extends BasePlugin {
)
},
{
name: 'placeholder',
type: 'input-text',
getSchemaTpl('placeholder', {
label: '占位符',
pipeIn: defaultValue('暂无内容'),
description:
'当没有关联变量,或者目标变量不是数组或者对象时显示此占位信息'
},
}),
getSchemaTpl('className')
];

View File

@ -110,6 +110,7 @@ export class ButtonGroupControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -124,16 +125,7 @@ export class ButtonGroupControlPlugin extends BasePlugin {
},
{
title: '按钮管理',
body: [
getSchemaTpl('optionControlV2'),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
)
]
body: [getSchemaTpl('optionControlV2')]
},
getSchemaTpl('status', {
isFormItem: true

View File

@ -70,6 +70,7 @@ export class ButtonToolbarControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('label'),
getSchemaTpl('labelRemark'),
getSchemaTpl('remark'),

View File

@ -100,6 +100,7 @@ export class ChainedSelectControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -101,6 +101,7 @@ export class CheckboxControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -121,6 +121,7 @@ export class CheckboxesControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -195,14 +196,7 @@ export class CheckboxesControlPlugin extends BasePlugin {
form: {
body: [getSchemaTpl('deleteApi')]
}
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
)
})
]
},
getSchemaTpl('status', {isFormItem: true}),

View File

@ -129,6 +129,7 @@ export class CodeEditorControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -14,7 +14,10 @@ import {
import {setVariable} from 'amis-core';
import {ValidatorTag} from '../../validator';
import {getArgsWrapper, getEventControlConfig} from '../../renderer/event-control/helper';
import {
getArgsWrapper,
getEventControlConfig
} from '../../renderer/event-control/helper';
export class ComboControlPlugin extends BasePlugin {
// 关联渲染器名字
@ -182,7 +185,7 @@ export class ComboControlPlugin extends BasePlugin {
type: 'input-text',
required: true,
placeholder: '变量名',
source: '${__setValueDs}',
source: '${__setValueDs}'
},
{
name: 'val',
@ -209,7 +212,6 @@ export class ComboControlPlugin extends BasePlugin {
panelJustify = true;
panelBodyCreator = (context: BaseEventContext) => {
return getSchemaTpl('tabs', [
{
title: '属性',
@ -236,11 +238,10 @@ export class ComboControlPlugin extends BasePlugin {
pipeOut: (value: any) => {
try {
return JSON.parse(value);
}
catch (err) {
} catch (err) {
return value;
}
}
}
}),
// 多选模式和条数绑定了,所以设定了多选,条数开启
getSchemaTpl('multiple', {
@ -249,13 +250,13 @@ export class ComboControlPlugin extends BasePlugin {
label: '最多条数',
name: 'maxLength',
type: 'input-number',
visibleOn: 'data.multiple',
visibleOn: 'data.multiple'
},
{
label: '最少条数',
name: 'minLength',
type: 'input-number',
visibleOn: 'data.multiple',
visibleOn: 'data.multiple'
}
]
}),
@ -275,14 +276,11 @@ export class ComboControlPlugin extends BasePlugin {
{
type: 'input-text',
name: 'draggableTip',
label: tipedLabel(
'提示文字',
'拖拽排序的提示文字'
)
label: tipedLabel('提示文字', '拖拽排序的提示文字')
}
]
},
// 可新增
getSchemaTpl('switch', {
name: 'addable',
@ -292,7 +290,12 @@ export class ComboControlPlugin extends BasePlugin {
),
visibleOn: 'data.multiple',
pipeIn: defaultValue(false),
onChange: (value: any, oldValue: any, model: any, form: any) => {
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
if (value) {
form.setValueByName('addBtn', {
label: '新增',
@ -310,7 +313,12 @@ export class ComboControlPlugin extends BasePlugin {
label: '可删除',
pipeIn: defaultValue(false),
visibleOn: 'data.multiple',
onChange: (value: any, oldValue: any, model: any, form: any) => {
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
if (value) {
form.setValueByName('removableMode', 'icon');
form.setValueByName('deleteIcon', undefined);
@ -338,11 +346,15 @@ export class ComboControlPlugin extends BasePlugin {
value: 'button'
}
],
onChange: (value: any, oldValue: any, model: any, form: any) => {
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
if (value === 'icon') {
form.setValueByName('deleteBtn', undefined);
}
else if (value === 'button'){
} else if (value === 'button') {
form.setValueByName('deleteBtn', {
label: '删除',
level: 'default'
@ -383,7 +395,7 @@ export class ComboControlPlugin extends BasePlugin {
}
]
},
getSchemaTpl('labelRemark'),
getSchemaTpl('remark'),
@ -438,11 +450,10 @@ export class ComboControlPlugin extends BasePlugin {
return (value ?? []).map(item => ({field: item}));
},
pipeOut(value?: Array<{field: string}>) {
return (value ?? [])
.map(item => {
const keys = Object.keys(item);
return keys.length > 0 ? item.field : '';
});
return (value ?? []).map(item => {
const keys = Object.keys(item);
return keys.length > 0 ? item.field : '';
});
}
}),
@ -453,11 +464,11 @@ export class ComboControlPlugin extends BasePlugin {
'如果数据比较多,比较卡顿时,可开启此配置项'
),
pipeIn: defaultValue(false),
visibleOn: 'data.multiple && !data.tabsMode',
visibleOn: 'data.multiple && !data.tabsMode'
})
]
}]
),
}
])
])
]
},
@ -480,11 +491,16 @@ export class ComboControlPlugin extends BasePlugin {
{label: '选项卡', value: true}
],
pipeIn: defaultValue(false),
onChange: (value: any, oldValue: any, model: any, form: any) => {
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
if (value) {
form.setValueByName('lazyLoad', undefined);
}
},
}
},
{
type: 'container',
@ -527,7 +543,12 @@ export class ComboControlPlugin extends BasePlugin {
name: 'multiLine',
label: '多行展示',
pipeIn: defaultValue(false),
onChange: (value: boolean, oldValue: any, model: any, form: any) => {
onChange: (
value: boolean,
oldValue: any,
model: any,
form: any
) => {
if (!value) {
form.setValueByName('subFormMode', undefined);
form.setValueByName('noBorder', undefined);
@ -548,11 +569,11 @@ export class ComboControlPlugin extends BasePlugin {
getSchemaTpl('subFormItemMode', {
visibleOn: 'data.multiLine',
type: 'select',
label: '子表单',
label: '子表单'
})
]
}),
getSchemaTpl('style:classNames'),
getSchemaTpl('style:classNames')
])
},
{

View File

@ -14,6 +14,7 @@ import {isObject, isString} from 'lodash';
import defaultConfig, {
OperationMap
} from 'amis-ui/lib/components/condition-builder/config';
import {getEnv} from 'mobx-state-tree';
export class ConditionBilderPlugin extends BasePlugin {
// 关联渲染器名字
@ -96,185 +97,188 @@ export class ConditionBilderPlugin extends BasePlugin {
]
};
scaffoldForm: ScaffoldForm = {
title: '快速开始-条件组合',
body: [
{
type: 'combo',
name: 'fields',
multiple: true,
draggable: true,
multiLine: true,
items: [
{
type: 'group',
body: [
{
type: 'select',
name: 'type',
placeholder: '条件类型',
options: [
{
label: '文本',
value: 'text'
},
{
label: '数字',
value: 'number'
},
{
label: '布尔',
value: 'boolean'
},
{
label: '日期',
value: 'date'
},
{
label: '日期时间',
value: 'datetime'
},
{
label: '时间',
value: 'time'
},
{
label: '选项',
value: 'select'
}
]
},
{
type: 'input-text',
name: 'name',
placeholder: '字段名'
},
{
type: 'input-text',
placeholder: '字段名称',
name: 'label'
}
]
},
{
type: 'group',
visibleOn: 'data.type === "number"',
body: [
{
type: 'input-number',
name: 'minimum',
placeholder: '最小值'
},
{
type: 'input-number',
name: 'maximum',
placeholder: '最大值'
},
{
type: 'input-number',
name: 'step',
min: 0,
placeholder: '步长'
}
]
},
{
type: 'group',
visibleOn: '!!~["date", "datetime", "time"].indexOf(data.type)',
body: [
{
type: 'input-text',
name: 'format',
placeholder: '值格式'
},
{
type: 'input-text',
name: 'inputFormat',
placeholder: '日期显示格式'
},
{
type: 'input-text',
name: 'timeFormat',
placeholder: '时间显示格式',
visibleOn: 'data.type === "datetime"'
}
]
},
{
type: 'group',
visibleOn: 'data.type === "select"',
body: [
{
type: 'input-text',
name: 'source',
placeholder: '字段选项远程拉取,支持接口或数据映射'
}
]
},
{
type: 'group',
body: [
{
type: 'input-text',
placeholder: '占位符',
name: 'placeholder'
},
{
name: 'operators',
placeholder: '操作符',
asFormItem: true,
children: ({data, render, onChange}: any) =>
render(
'operations',
get scaffoldForm(): ScaffoldForm {
const {i18nEnabled} = getEnv((window as any).editorStore);
return {
title: '快速开始-条件组合',
body: [
{
type: 'combo',
name: 'fields',
multiple: true,
draggable: true,
multiLine: true,
items: [
{
type: 'group',
body: [
{
type: 'select',
name: 'type',
placeholder: '条件类型',
options: [
{
type: 'select',
name: 'operators',
multiple: true,
value:
data.value ||
defaultConfig.types[data.type]?.operators ||
[],
joinValues: false,
extractValue: true,
options: defaultConfig.types[data.type]?.operators.map(
item => {
if (isObject(item) && item.label && item.value) {
return (
{
label: item.label,
value: item.value
} || []
);
} else if (isString(item)) {
return (
{
label: OperationMap[item],
value: item
} || []
);
} else {
return [];
}
}
)
label: '文本',
value: 'text'
},
{
onChange: (value: any) => onChange(value)
label: '数字',
value: 'number'
},
{
label: '布尔',
value: 'boolean'
},
{
label: '日期',
value: 'date'
},
{
label: '日期时间',
value: 'datetime'
},
{
label: '时间',
value: 'time'
},
{
label: '选项',
value: 'select'
}
)
}
]
}
]
}
],
canRebuild: true
};
]
},
{
type: 'input-text',
name: 'name',
placeholder: '字段名'
},
{
type: i18nEnabled ? 'input-text-i18n' : 'input-text',
placeholder: '字段名称',
name: 'label'
}
]
},
{
type: 'group',
visibleOn: 'data.type === "number"',
body: [
{
type: 'input-number',
name: 'minimum',
placeholder: '最小值'
},
{
type: 'input-number',
name: 'maximum',
placeholder: '最大值'
},
{
type: 'input-number',
name: 'step',
min: 0,
placeholder: '步长'
}
]
},
{
type: 'group',
visibleOn: '!!~["date", "datetime", "time"].indexOf(data.type)',
body: [
{
type: 'input-text',
name: 'format',
placeholder: '值格式'
},
{
type: 'input-text',
name: 'inputFormat',
placeholder: '日期显示格式'
},
{
type: 'input-text',
name: 'timeFormat',
placeholder: '时间显示格式',
visibleOn: 'data.type === "datetime"'
}
]
},
{
type: 'group',
visibleOn: 'data.type === "select"',
body: [
{
type: 'input-text',
name: 'source',
placeholder: '字段选项远程拉取,支持接口或数据映射'
}
]
},
{
type: 'group',
body: [
{
type: i18nEnabled ? 'input-text-i18n' : 'input-text',
placeholder: '占位符',
name: 'placeholder'
},
{
name: 'operators',
placeholder: '操作符',
asFormItem: true,
children: ({data, render, onChange}: any) =>
render(
'operations',
{
type: 'select',
name: 'operators',
multiple: true,
value:
data.value ||
defaultConfig.types[data.type]?.operators ||
[],
joinValues: false,
extractValue: true,
options: defaultConfig.types[data.type]?.operators.map(
item => {
if (isObject(item) && item.label && item.value) {
return (
{
label: item.label,
value: item.value
} || []
);
} else if (isString(item)) {
return (
{
label: OperationMap[item],
value: item
} || []
);
} else {
return [];
}
}
)
},
{
onChange: (value: any) => onChange(value)
}
)
}
]
}
]
}
],
canRebuild: true
};
}
previewSchema: any = {
type: 'form',
@ -285,7 +289,10 @@ export class ConditionBilderPlugin extends BasePlugin {
panelTitle = '条件组件';
panelBodyCreator = (context: BaseEventContext) => {
return [getSchemaTpl('source')];
return [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('source')
];
};
buildSubRenderers(

View File

@ -135,6 +135,7 @@ export class DiffEditorControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -58,12 +58,9 @@ export class FieldSetControlPlugin extends BasePlugin {
panelTitle = '字段集';
panelBodyCreator = (context: BaseEventContext) => {
return [
{
label: '标题',
name: 'title',
type: 'input-text'
// required: true
},
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('title'),
getSchemaTpl('switch', {
name: 'collapsable',

View File

@ -13,109 +13,116 @@ import {EditorNodeType} from 'amis-editor-core';
import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core';
import {setVariable} from 'amis-core';
import {getEventControlConfig} from '../../renderer/event-control/helper';
import {getEnv} from 'mobx-state-tree';
// 用于脚手架的常用表单控件
const formItemOptions = [
{
name: 'type',
label: '控件类型',
type: 'select',
required: true,
options: [
{
label: '单行文本框',
value: 'input-text'
},
{
label: '多行文本',
value: 'textarea'
},
{
label: '分组',
value: 'group'
},
{
label: '数字输入',
value: 'input-number'
},
{
label: '单选框',
value: 'radios'
},
{
label: '勾选框',
value: 'checkbox'
},
{
label: '复选框',
value: 'checkboxes'
},
{
label: '下拉框',
value: 'select'
},
{
label: '开关',
value: 'switch'
},
{
label: '日期',
value: 'input-date'
},
{
label: '表格',
value: 'input-table'
},
{
label: '文件上传',
value: 'input-file'
},
{
label: '图片上传',
value: 'input-image'
},
{
label: '富文本编辑器',
value: 'input-rich-text'
}
]
},
{
name: 'label',
label: '显示名称',
type: 'input-text',
hiddenOn: 'data.type === "group"'
},
{
name: 'name',
label: '提交字段名',
required: true,
type: 'input-text',
hiddenOn: 'data.type === "group"'
}
];
const getFormItemOptions = ({i18nEnabled}: {i18nEnabled?: boolean}) => {
return [
{
name: 'type',
label: '控件类型',
type: 'select',
required: true,
options: [
{
label: '单行文本框',
value: 'input-text'
},
{
label: '多行文本',
value: 'textarea'
},
{
label: '分组',
value: 'group'
},
{
label: '数字输入',
value: 'input-number'
},
{
label: '单选框',
value: 'radios'
},
{
label: '勾选框',
value: 'checkbox'
},
{
label: '复选框',
value: 'checkboxes'
},
{
label: '下拉框',
value: 'select'
},
{
label: '开关',
value: 'switch'
},
{
label: '日期',
value: 'input-date'
},
{
label: '表格',
value: 'input-table'
},
{
label: '文件上传',
value: 'input-file'
},
{
label: '图片上传',
value: 'input-image'
},
{
label: '富文本编辑器',
value: 'input-rich-text'
}
]
},
{
name: 'label',
label: '显示名称',
type: i18nEnabled ? 'input-text-i18n' : 'input-text',
hiddenOn: 'data.type === "group"'
},
{
name: 'name',
label: '提交字段名',
required: true,
type: 'input-text',
hiddenOn: 'data.type === "group"'
}
];
};
// 自动为form中子元素单选框、复选框补上默认options
const autoAddOptions = (values: any) => {
if (values && (values.type === 'form' || values.type === 'group') && values.body?.length > 0) {
if (
values &&
(values.type === 'form' || values.type === 'group') &&
values.body?.length > 0
) {
values.body.forEach((formItem: any) => {
if (formItem.type === 'radios' || formItem.type === 'checkboxes') {
formItem.options = [
{
label: "选项A",
value: "A"
label: '选项A',
value: 'A'
},
{
label: "选项B",
value: "B"
label: '选项B',
value: 'B'
}
];
} else if (formItem.type === 'form' || formItem.type === 'group') {
autoAddOptions(formItem);
autoAddOptions(formItem);
}
});
}
}
};
export class FormPlugin extends BasePlugin {
// 关联渲染器名字
@ -157,59 +164,62 @@ export class FormPlugin extends BasePlugin {
]
};
scaffoldForm: ScaffoldForm = {
title: '快速创建表单',
body: [
getSchemaTpl('apiControl', {
label: '提交地址'
}),
{
name: 'mode',
label: '文字与输入框展示模式',
type: 'button-group-select',
pipeIn: defaultValue('normal', false),
options: [
{
label: '上下',
value: 'normal'
},
{
label: '左右摆放',
value: 'horizontal'
},
{
label: '内联',
value: 'inline'
}
]
},
{
label: '表单控件',
type: 'combo',
name: 'body',
multiple: true,
draggable: true,
multiLine: false,
items: [
...formItemOptions,
{
visibleOn: 'data.type === "group"',
type: 'combo',
name: 'body',
label: '分组内的控件',
multiple: true,
draggable: true,
multiLine: true,
items: [...formItemOptions]
}
]
get scaffoldForm(): ScaffoldForm {
const {i18nEnabled} = getEnv((window as any).editorStore);
return {
title: '快速创建表单',
body: [
getSchemaTpl('apiControl', {
label: '提交地址'
}),
{
name: 'mode',
label: '文字与输入框展示模式',
type: 'button-group-select',
pipeIn: defaultValue('normal', false),
options: [
{
label: '上下',
value: 'normal'
},
{
label: '左右摆放',
value: 'horizontal'
},
{
label: '内联',
value: 'inline'
}
]
},
{
label: '表单控件',
type: 'combo',
name: 'body',
multiple: true,
draggable: true,
multiLine: false,
items: [
...getFormItemOptions({i18nEnabled}),
{
visibleOn: 'data.type === "group"',
type: 'combo',
name: 'body',
label: '分组内的控件',
multiple: true,
draggable: true,
multiLine: true,
items: [...getFormItemOptions({i18nEnabled})]
}
]
}
],
pipeOut: (values: any) => {
autoAddOptions(values);
return values;
}
],
pipeOut: (values: any) => {
autoAddOptions(values);
return values;
}
};
};
}
// scaffoldForm: ScaffoldForm = {
// title: '配置表单信息',
@ -335,22 +345,23 @@ export class FormPlugin extends BasePlugin {
}
]
},
// {
// eventName: 'submit',
// eventLabel: '表单提交',
// strongDesc: '配置该事件后将不会触发表单提交时默认的校验、提交到api或者target等行为所有行为需要自己配置',
// dataSchema: [
// {
// type: 'object',
// properties: {
// 'event.data': {
// type: 'object',
// title: '当前表单数据'
// }
// }
// }
// ]
// },
{
eventName: 'submit',
eventLabel: '表单提交',
strongDesc:
'配置该事件后将不会触发表单提交时默认的校验、提交到api或者target等行为所有行为需要自己配置',
dataSchema: [
{
type: 'object',
properties: {
'event.data': {
type: 'object',
title: '当前表单数据'
}
}
}
]
},
{
eventName: 'submitSucc',
eventLabel: '提交成功',
@ -429,20 +440,15 @@ export class FormPlugin extends BasePlugin {
{
title: '常规',
body: [
{
name: 'title',
type: 'input-text',
label: '标题',
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('title', {
visibleOn: `this.wrapWithPanel !== false`
},
{
name: 'submitText',
type: 'input-text',
label: '提交按钮名称',
}),
getSchemaTpl('submitText', {
pipeIn: defaultValue('提交'),
visibleOn: `this.wrapWithPanel !== false && !this.actions && (!Array.isArray(this.body) || !this.body.some(function(item) {return !!~['submit','button','reset','button-group'].indexOf(item.type);}))`,
description: '当没有自定义按钮时有效。'
},
}),
getSchemaTpl('switch', {
name: 'autoFocus',
@ -773,31 +779,11 @@ export class FormPlugin extends BasePlugin {
description:
'可以不设置,接口返回的 msg 字段,优先级更高',
items: [
{
label: '获取成功提示',
name: 'fetchSuccess',
type: 'input-text'
},
{
label: '获取失败提示',
name: 'fetchFailed',
type: 'input-text'
},
{
label: '保存成功提示',
name: 'saveSuccess',
type: 'input-text'
},
{
label: '保存失败提示',
name: 'saveFailed',
type: 'input-text'
},
{
label: '验证失败提示',
name: 'validateFailed',
type: 'input-text'
}
getSchemaTpl('fetchSuccess'),
getSchemaTpl('fetchFailed'),
getSchemaTpl('saveSuccess'),
getSchemaTpl('saveFailed'),
getSchemaTpl('validateFailed')
]
}
]

View File

@ -27,6 +27,7 @@ export class FormulaControlPlugin extends BasePlugin {
panelTitle = '公式';
panelBody = [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '字段名',
name: 'name',

View File

@ -71,6 +71,7 @@ export class GroupControlPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('label'),
getSchemaTpl('description', {

View File

@ -1,6 +1,6 @@
import React from 'react';
import {registerEditorPlugin} from 'amis-editor-core';
import {BasePlugin} from 'amis-editor-core';
import {BasePlugin, getSchemaTpl} from 'amis-editor-core';
export class HiddenControlPlugin extends BasePlugin {
// 关联渲染器名字
@ -26,6 +26,7 @@ export class HiddenControlPlugin extends BasePlugin {
panelTitle = '隐藏域';
panelBody = [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
type: 'input-text',
name: 'value',
@ -34,7 +35,6 @@ export class HiddenControlPlugin extends BasePlugin {
];
renderRenderer(props: any) {
console.log('props:', props);
return this.renderPlaceholder('功能组件(隐藏字段)', props.key, props.style);
}
}

View File

@ -55,8 +55,8 @@ export class ArrayControlPlugin extends BasePlugin {
panelTitle = '数组框';
panelBodyCreator = (context: BaseEventContext) => {
return [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('switchDefaultValue'),
{
type: 'textarea',
name: 'value',
@ -64,7 +64,6 @@ export class ArrayControlPlugin extends BasePlugin {
visibleOn: 'typeof this.value !== "undefined"',
pipeOut: valuePipeOut
},
{
children: (
<Button

View File

@ -99,6 +99,7 @@ export class CityControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -176,6 +176,7 @@ export class ColorControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -262,6 +262,7 @@ export class DateControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -202,6 +202,7 @@ export class DateRangeControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -358,18 +359,8 @@ export class DateRangeControlPlugin extends BasePlugin {
}),
getSchemaTpl('remark'),
getSchemaTpl('labelRemark'),
{
type: 'input-text',
name: 'startPlaceholder',
label: '前占位提示',
pipeIn: defaultValue('开始时间')
},
{
type: 'input-text',
name: 'endPlaceholder',
label: '后占位提示',
pipeIn: defaultValue('结束时间')
},
getSchemaTpl('startPlaceholder'),
getSchemaTpl('endPlaceholder'),
getSchemaTpl('autoFillApi')
]
},

View File

@ -89,6 +89,7 @@ export class ExcelControlPlugin extends BasePlugin {
{
common: {
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '解析模式',
name: 'parseMode',

View File

@ -134,16 +134,12 @@ export class FileControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
getSchemaTpl('label'),
{
type: 'input-text',
name: 'btnLabel',
label: '按钮名称',
value: '文件上传'
},
getSchemaTpl('btnLabel'),
getSchemaTpl('multiple', {
replace: true,
body: [

View File

@ -53,13 +53,15 @@ export class InputGroupControlPlugin extends BasePlugin {
panelTitle = 'Input 组合';
regions = [{
key: 'body',
label: '内容区',
preferTag: '内容区',
renderMethod: 'render',
matchRegion: (elem: JSX.Element) => !!elem,
}];
regions = [
{
key: 'body',
label: '内容区',
preferTag: '内容区',
renderMethod: 'render',
matchRegion: (elem: JSX.Element) => !!elem
}
];
notRenderFormZone = true;
@ -94,7 +96,7 @@ export class InputGroupControlPlugin extends BasePlugin {
label: '内联模式',
name: 'inline',
pipeIn: defaultValue(false)
}),
})
]
}),
getSchemaTpl('style:classNames')

View File

@ -142,6 +142,7 @@ export class ImageControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -106,6 +106,7 @@ export class KVControlPlugin extends BasePlugin {
panelTitle = 'KV 键值对';
panelBody = [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
type: 'input-text',
name: 'valueType',

View File

@ -134,6 +134,7 @@ export class NumberControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -195,46 +196,9 @@ export class NumberControlPlugin extends BasePlugin {
min: 1,
max: 100
},
{
type: 'input-text',
name: 'prefix',
label: tipedLabel('前缀', '输入内容前展示,不包含在数据值中')
},
{
type: 'input-text',
name: 'suffix',
label: tipedLabel('后缀', '输入内容后展示,不包含在数据值中')
},
getSchemaTpl('combo-container', {
type: 'combo',
label: '单位选项',
mode: 'normal',
name: 'unitOptions',
flat: true,
items: [
{
placeholder: '单位选项',
type: 'input-text',
name: 'text'
}
],
draggable: false,
multiple: true,
pipeIn: (value: any) => {
if (!isObject(value)) {
return Array.isArray(value) ? value : [];
}
const res = value.map((item: any) => item.value);
return res;
},
pipeOut: (value: any[]) => {
if (!value.length) {
return undefined;
}
return value;
}
}),
getSchemaTpl('prefix'),
getSchemaTpl('suffix'),
getSchemaTpl('unitOptions'),
getSchemaTpl('labelRemark'),
getSchemaTpl('remark'),
getSchemaTpl('placeholder'),

View File

@ -118,15 +118,14 @@ export class RangeControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
{
getSchemaTpl('label', {
label: 'Label',
name: 'label',
type: 'input-text'
},
}),
{
label: '方式',
@ -217,12 +216,7 @@ export class RangeControlPlugin extends BasePlugin {
}
},
{
type: 'input-text',
name: 'unit',
label: '单位',
value: ''
},
getSchemaTpl('unit'),
// tooltipVisible 为true时会一直显示为undefined时才会鼠标移入显示
getSchemaTpl('switch', {

View File

@ -94,15 +94,14 @@ export class RateControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
{
getSchemaTpl('label', {
label: 'Label',
name: 'label',
type: 'input-text'
},
}),
getSchemaTpl('valueFormula', {
rendererSchema: {
@ -143,31 +142,7 @@ export class RateControlPlugin extends BasePlugin {
getSchemaTpl('labelRemark'),
getSchemaTpl('remark'),
getSchemaTpl('combo-container', {
type: 'combo',
label: '描述',
mode: 'normal',
name: 'texts',
items: [
{
placeholder: 'Key',
type: 'input-number',
unique: true,
name: 'key',
columnClassName: 'w-xs flex-none',
min: 0,
step: 1,
max: 10,
precision: 0
},
{
placeholder: '描述内容',
type: 'input-text',
name: 'value'
}
],
getSchemaTpl('texts', {
draggable: false,
multiple: true,
pipeIn: (value: any) => {
@ -212,7 +187,6 @@ export class RateControlPlugin extends BasePlugin {
res[key] = item?.value || '';
}
});
return res;
}
}),

View File

@ -34,6 +34,7 @@ export class RepeatControlPlugin extends BasePlugin {
panelTitle = '周期';
panelBody = [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('switchDefaultValue'),
{
type: 'input-text',

View File

@ -40,6 +40,7 @@ export class RichTextControlPlugin extends BasePlugin {
// 有设置这个就默认使用 froala
const hasRichTextToken = this.manager.env?.richTextToken ? true : false;
return [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('switchDefaultValue'),
{
type: 'textarea',

View File

@ -1,15 +1,17 @@
import {Button} from 'amis';
import {SchemaCollection} from 'amis/lib/Schema';
import React from 'react';
import {registerEditorPlugin} from 'amis-editor-core';
import {
BaseEventContext,
BasePlugin,
BasicToolbarItem,
ContextMenuEventContext,
ContextMenuItem
ContextMenuItem,
getSchemaTpl,
registerEditorPlugin,
diff,
JSONPipeOut
} from 'amis-editor-core';
import {diff, JSONPipeOut} from 'amis-editor-core';
export class SubFormControlPlugin extends BasePlugin {
// 关联渲染器名字
@ -54,6 +56,7 @@ export class SubFormControlPlugin extends BasePlugin {
panelTitle = '子表单项';
panelBodyCreator = (context: BaseEventContext) => {
return [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
children: ({value, onChange}: any) => {
return (
@ -76,12 +79,10 @@ export class SubFormControlPlugin extends BasePlugin {
label: '名称字段名',
description: '当值中存在这个字段,则按钮名称将使用此字段的值来展示。'
},
{
name: 'btnLabel',
getSchemaTpl('btnLabel', {
label: '按钮标签名',
value: '设置',
type: 'input-text'
},
value: '设置'
}),
{
name: 'minLength',
visibleOn: 'data.multiple',

View File

@ -17,6 +17,7 @@ import {
import {setVariable} from 'amis-core';
import {repeatArray} from 'amis-editor-core';
import {mockValue} from 'amis-editor-core';
import {getEnv} from 'mobx-state-tree';
export class TableControlPlugin extends BasePlugin {
// 关联渲染器名字
@ -77,80 +78,83 @@ export class TableControlPlugin extends BasePlugin {
}
};
scaffoldForm: ScaffoldForm = {
title: '快速构建表格',
body: [
{
name: 'columns',
type: 'combo',
multiple: true,
label: false,
addButtonText: '新增一列',
draggable: true,
items: [
{
type: 'input-text',
name: 'label',
placeholder: '标题'
},
{
type: 'input-text',
name: 'name',
placeholder: '绑定字段名'
},
{
type: 'select',
name: 'type',
placeholder: '类型',
value: 'text',
options: [
{
value: 'text',
label: '纯文本'
},
{
value: 'tpl',
label: '模板'
},
{
value: 'image',
label: '图片'
},
{
value: 'date',
label: '日期'
},
// {
// value: 'datetime',
// label: '日期时间'
// },
// {
// value: 'time',
// label: '时间'
// },
{
value: 'progress',
label: '进度'
},
{
value: 'status',
label: '状态'
},
{
value: 'mapping',
label: '映射'
},
{
value: 'operation',
label: '操作栏'
}
]
}
]
}
],
canRebuild: true
};
get scaffoldForm(): ScaffoldForm {
const {i18nEnabled} = getEnv((window as any).editorStore);
return {
title: '快速构建表格',
body: [
{
name: 'columns',
type: 'combo',
multiple: true,
label: false,
addButtonText: '新增一列',
draggable: true,
items: [
{
type: i18nEnabled ? 'input-text-i18n' : 'input-text',
name: 'label',
placeholder: '标题'
},
{
type: 'input-text',
name: 'name',
placeholder: '绑定字段名'
},
{
type: 'select',
name: 'type',
placeholder: '类型',
value: 'text',
options: [
{
value: 'text',
label: '纯文本'
},
{
value: 'tpl',
label: '模板'
},
{
value: 'image',
label: '图片'
},
{
value: 'date',
label: '日期'
},
// {
// value: 'datetime',
// label: '日期时间'
// },
// {
// value: 'time',
// label: '时间'
// },
{
value: 'progress',
label: '进度'
},
{
value: 'status',
label: '状态'
},
{
value: 'mapping',
label: '映射'
},
{
value: 'operation',
label: '操作栏'
}
]
}
]
}
],
canRebuild: true
};
}
panelTitle = '表格编辑';
panelBodyCreator = (context: BaseEventContext) => {
@ -174,6 +178,7 @@ export class TableControlPlugin extends BasePlugin {
// </div>
// )
// },
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -136,17 +136,13 @@ export class TagControlPlugin extends BasePlugin {
common: {
replace: true,
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
getSchemaTpl('label'),
getSchemaTpl('clearable'),
{
type: 'input-text',
name: 'optionsTip',
label: '选项提示',
value: '最近您使用的标签'
},
getSchemaTpl('optionsTip'),
getSchemaTpl('valueFormula', {
rendererSchema: context?.schema,
mode: 'vertical' // 改成上下展示模式

View File

@ -162,6 +162,7 @@ export class TextControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -280,6 +280,7 @@ export class TreeControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -91,6 +91,7 @@ export class ItemPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
ignoreName
? null
: getSchemaTpl('formItemName', {

View File

@ -104,6 +104,7 @@ export class ListControlPlugin extends BasePlugin {
common: {
replace: true,
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -122,14 +123,7 @@ export class ListControlPlugin extends BasePlugin {
body: [
getSchemaTpl('optionControlV2', {
description: '设置选项后,输入时会下拉这些选项供用户参考。'
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source'
},
{context}
)
})
]
},
status: {}

View File

@ -37,6 +37,7 @@ export class LocationControlPlugin extends BasePlugin {
panelBodyCreator = (context: BaseEventContext) => {
return [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('clearable'),
{
type: 'input-text',

View File

@ -115,6 +115,7 @@ export class MatrixControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -166,19 +167,9 @@ export class MatrixControlPlugin extends BasePlugin {
scaffold: {
label: '列说明'
},
items: [
{
type: 'input-text',
name: 'label',
placeholder: '列说明'
}
]
items: [getSchemaTpl('matrixColumnLabel')]
}),
{
name: 'rowLabel',
label: '行标题文字',
type: 'input-text'
},
getSchemaTpl('matrixRowTitle'),
getSchemaTpl('combo-container', {
label: '行配置',
name: 'rows',
@ -189,13 +180,7 @@ export class MatrixControlPlugin extends BasePlugin {
label: '行说明'
},
addButtonText: '添加一行',
items: [
{
type: 'input-text',
name: 'label',
placeholder: '行说明'
}
]
items: [getSchemaTpl('matrixRowLabel')]
})
],
getSchemaTpl('apiControl', {

View File

@ -208,6 +208,7 @@ export class NestedSelectControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -105,6 +105,7 @@ export class PickerControlPlugin extends BasePlugin {
{
title: '属性',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('switch', {
name: 'embed',
label: '开启内嵌模式'

View File

@ -115,6 +115,7 @@ export class RadiosControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -140,14 +141,7 @@ export class RadiosControlPlugin extends BasePlugin {
name: 'selectFirst',
horizontal: {justify: true, left: 5},
visibleOn: '!this.options'
}),
getSchemaTpl(
'loadingConfig',
{
visibleOn: 'this.source || !this.options'
},
{context}
)
})
]
},
getSchemaTpl('status', {isFormItem: true}),

View File

@ -215,6 +215,7 @@ export class SelectControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -82,16 +82,13 @@ export class SwitchControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
getSchemaTpl('label'),
{
name: 'option',
type: 'input-text',
label: '说明'
},
getSchemaTpl('option'),
{
type: 'ae-switch-more',

View File

@ -225,12 +225,11 @@ export class TabsTransferPlugin extends BasePlugin {
{
type: 'group',
body: [
{
type: 'input-text',
name: 'label',
getSchemaTpl('label', {
label: false,
placeholder: '名称',
required: true
},
}),
{
type: 'input-text',
@ -262,6 +261,7 @@ export class TabsTransferPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -118,6 +118,7 @@ export class TextareaControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),
@ -126,12 +127,7 @@ export class TextareaControlPlugin extends BasePlugin {
// rendererSchema: context?.schema,
// mode: 'vertical' // 改成上下展示模式
// }),
{
type: 'ae-textareaFormulaControl',
label: '默认值',
name: 'value',
mode: 'normal'
},
getSchemaTpl('textareaDefaultValue'),
getSchemaTpl('switch', {
name: 'trimContents',
pipeIn: defaultValue(true),

View File

@ -170,6 +170,7 @@ export class TransferPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -262,6 +262,7 @@ export class TreeSelectControlPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('formItemName', {
required: true
}),

View File

@ -1,5 +1,5 @@
import React from 'react';
import {registerEditorPlugin} from 'amis-editor-core';
import {registerEditorPlugin, getSchemaTpl} from 'amis-editor-core';
import {
BasePlugin,
BasicSubRenderInfo,
@ -35,7 +35,10 @@ export class UUIDControlPlugin extends BasePlugin {
};
panelTitle = 'UUID';
panelBody = [{type: 'static', value: '自动按 UUID v4 格式生成,无需配置'}];
panelBody = [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{type: 'static', value: '自动按 UUID v4 格式生成,无需配置'}
];
renderRenderer(props: any) {
return this.renderPlaceholder('UUID展现将隐藏', props.key, props.style);

View File

@ -232,6 +232,7 @@ export class GridPlugin extends BasePlugin {
{
title: '布局',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '列数',
name: 'columns',
@ -389,6 +390,7 @@ export class GridPlugin extends BasePlugin {
className: 'p-none',
body: [
getSchemaTpl('collapseGroup', [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
title: '插入',
body: [

View File

@ -67,6 +67,7 @@ export class HBoxPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('fieldSet', {
title: '插入',
collapsable: false,

View File

@ -40,6 +40,7 @@ export class IFramePlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
type: 'ae-textareaFormulaControl',
name: 'src',

View File

@ -92,7 +92,9 @@ export class ImagePlugin extends BasePlugin {
mode: 'normal',
name: 'enlargeAble',
label: tipedLabel(
'图片放大功能', '放大功能和打开外部链接功能是冲突的,若要点击时打开外部链接请先关闭此功能'),
'图片放大功能',
'放大功能和打开外部链接功能是冲突的,若要点击时打开外部链接请先关闭此功能'
),
value: false,
hiddenOnDefault: false,
formType: 'extend',
@ -111,7 +113,7 @@ export class ImagePlugin extends BasePlugin {
type: 'input-text',
label: '打开外部链接',
name: 'href',
hiddenOn: "this.enlargeAble",
hiddenOn: 'this.enlargeAble',
clearValueOnHidden: true
},
getSchemaTpl('imageUrl', {

View File

@ -46,85 +46,88 @@ export class ImagesPlugin extends BasePlugin {
body: getSchemaTpl('collapseGroup', [
{
title: '基本',
body: (isUnderField ? [] : [
{
type: 'formula',
name: '__mode',
autoSet: false,
formula:
'!this.name && !this.source && Array.isArray(this.options) ? 2 : 1'
},
{
label: '数据源',
name: '__mode',
type: 'button-group-select',
size: 'sm',
options: [
body: (isUnderField
? []
: [
{
label: '关联字段',
value: 1
type: 'formula',
name: '__mode',
autoSet: false,
formula:
'!this.name && !this.source && Array.isArray(this.options) ? 2 : 1'
},
{
label: '静态设置',
value: 2
}
],
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
if (value !== oldValue && value == 1) {
form.deleteValueByName('options');
}
}
},
{
name: 'source',
type: 'input-text',
label: '关联数据',
description:
'比如:\\${listVar},用来关联作用域中的已有数据。',
visibleOn: 'this.__mode == 1'
},
{
type: 'combo',
name: 'options',
visibleOn: 'this.__mode == 2',
minLength: 1,
label: '图片集数据',
multiple: true,
multiLine: true,
addable: true,
removable: true,
value: [{}],
items: [
getSchemaTpl('imageUrl', {
name: 'image',
label: '缩略图'
}),
getSchemaTpl('imageUrl', {
name: 'src',
label: '原图'
}),
label: '数据源',
name: '__mode',
type: 'button-group-select',
size: 'sm',
options: [
{
label: '关联字段',
value: 1
},
{
label: '静态设置',
value: 2
}
],
onChange: (
value: any,
oldValue: any,
model: any,
form: any
) => {
if (value !== oldValue && value == 1) {
form.deleteValueByName('options');
}
}
},
{
name: 'source',
type: 'input-text',
label: '图片标题',
name: 'title'
label: '关联数据',
description:
'比如:\\${listVar},用来关联作用域中的已有数据。',
visibleOn: 'this.__mode == 1'
},
{
type: 'textarea',
label: '图片描述',
name: 'caption'
}
type: 'combo',
name: 'options',
visibleOn: 'this.__mode == 2',
minLength: 1,
label: '图片集数据',
multiple: true,
multiLine: true,
addable: true,
removable: true,
value: [{}],
items: [
getSchemaTpl('imageUrl', {
name: 'image',
label: '缩略图'
}),
getSchemaTpl('imageUrl', {
name: 'src',
label: '原图'
}),
{
type: 'input-text',
label: '图片标题',
name: 'title'
},
{
type: 'textarea',
label: '图片描述',
name: 'caption'
}
]
},
getSchemaTpl('switch', {
name: 'enlargeAble',
label: '图片放大功能'
})
]
},
getSchemaTpl('switch', {
name: 'enlargeAble',
label: '图片放大功能'
})
]).concat([
).concat([
getSchemaTpl('imageUrl', {
name: 'defaultImage',
label: tipedLabel('占位图', '无数据时显示的图片')

View File

@ -81,7 +81,9 @@ export class FlexPluginBase extends BasePlugin {
const isSorptionContainer = curRendererSchema?.isSorptionContainer || false;
const positionTpl = [
getSchemaTpl('layout:position'),
getSchemaTpl('layout:position', {
visibleOn: '!data.stickyStatus'
}),
getSchemaTpl('layout:originPosition'),
getSchemaTpl('layout:inset', {
mode: 'vertical'
@ -99,35 +101,6 @@ export class FlexPluginBase extends BasePlugin {
title: '布局',
body: [
isSorptionContainer ? getSchemaTpl('layout:sorption') : null,
isFlexItem
? getSchemaTpl('layout:flex', {
isFlexColumnItem,
onText: isFlexColumnItem ? '弹性高度' : '弹性宽度',
offText: isFlexColumnItem ? '固定高度' : '固定宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-grow', {
visibleOn:
'data.style && data.style.flex !== "0 0 auto" && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '弹性高度' : '弹性宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "1 1 auto"'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '固定高度' : '固定宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "0 0 auto"'
})
: null,
// 吸附容器不显示定位相关配置项
...(isSorptionContainer ? [] : positionTpl),
@ -170,7 +143,7 @@ export class FlexPluginBase extends BasePlugin {
label: '垂直对齐方式',
options: [
{
label: '起点对齐',
label: '顶部对齐',
value: 'flex-start'
},
{
@ -178,7 +151,7 @@ export class FlexPluginBase extends BasePlugin {
value: 'center'
},
{
label: '终点对齐',
label: '底部对齐',
value: 'flex-end'
},
{
@ -226,7 +199,7 @@ export class FlexPluginBase extends BasePlugin {
label: '垂直对齐方式',
options: [
{
label: '起点对齐',
label: '顶部对齐',
value: 'flex-start'
},
{
@ -234,7 +207,7 @@ export class FlexPluginBase extends BasePlugin {
value: 'center'
},
{
label: '终点对齐',
label: '底部对齐',
value: 'flex-end'
},
{
@ -251,6 +224,41 @@ export class FlexPluginBase extends BasePlugin {
}),
getSchemaTpl('layout:flex-wrap'),
isFlexItem
? getSchemaTpl('layout:flex', {
isFlexColumnItem,
label: isFlexColumnItem ? '高度设置' : '宽度设置',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-grow', {
visibleOn:
'data.style && data.style.flex === "1 1 auto" && (data.style.position === "static" || data.style.position === "relative")'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '弹性高度' : '弹性宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "1 1 auto"'
})
: null,
isFlexItem
? getSchemaTpl('layout:flex-basis', {
label: isFlexColumnItem ? '固定高度' : '固定宽度',
visibleOn:
'data.style && (data.style.position === "static" || data.style.position === "relative") && data.style.flex === "0 0 150px"'
})
: null,
getSchemaTpl('layout:overflow-x', {
visibleOn: `${
isFlexItem && !isFlexColumnItem
} && data.style.flex === '0 0 150px'`
}),
getSchemaTpl('layout:isFixedHeight', {
visibleOn: `${!isFlexItem || !isFlexColumnItem}`
}),
@ -263,12 +271,13 @@ export class FlexPluginBase extends BasePlugin {
getSchemaTpl('layout:min-height', {
visibleOn: `${!isFlexItem || !isFlexColumnItem}`
}),
getSchemaTpl('layout:overflow-y', {
visibleOn: `${
!isFlexItem || !isFlexColumnItem
} && (data.isFixedHeight || data.style && data.style.maxHeight) || (${
isFlexItem && isFlexColumnItem
} && data.style.flex === '0 0 auto')`
} && data.style.flex === '0 0 150px')`
}),
getSchemaTpl('layout:isFixedWidth', {
@ -283,13 +292,13 @@ export class FlexPluginBase extends BasePlugin {
getSchemaTpl('layout:min-width', {
visibleOn: `${!isFlexItem || isFlexColumnItem}`
}),
getSchemaTpl('layout:overflow-x', {
visibleOn: `${
!isFlexItem || isFlexColumnItem
} && (data.isFixedWidth || data.style && data.style.maxWidth) || (${
isFlexItem && !isFlexColumnItem
} && data.style.flex === '0 0 auto')`
} && (data.isFixedWidth || data.style && data.style.maxWidth)`
}),
!isFlexItem ? getSchemaTpl('layout:margin-center') : null,
getSchemaTpl('layout:z-index'),
!isSorptionContainer && getSchemaTpl('layout:sticky'),

View File

@ -11,13 +11,12 @@ export default class Layout_free_container extends ContainerPlugin {
tags = ['布局'];
scaffold: any = {
type: 'container',
title: '自由容器',
isFreeContainer: true,
size: 'xs',
body: [],
wrapperBody: false,
style: {
position: 'static',
position: 'relative',
minHeight: '200px'
},
};

View File

@ -9,7 +9,6 @@ export default class Layout_fixed_top extends FlexPluginBase {
order = 502;
scaffold: any = {
type: 'flex',
title: '吸附容器',
isSorptionContainer: true,
sorptionPosition: 'top',
className: 'p-1',
@ -17,6 +16,7 @@ export default class Layout_fixed_top extends FlexPluginBase {
defaultFlexColumnSchema(),
defaultFlexColumnSchema(),
defaultFlexColumnSchema(),
defaultFlexColumnSchema(),
],
style: {
position: 'fixed',

View File

@ -34,6 +34,7 @@ export class LinkPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
name: 'href',
type: 'input-text',
@ -42,11 +43,7 @@ export class LinkPlugin extends BasePlugin {
'支持取变量,如果已绑定字段名,可以不用设置'
)
},
{
name: 'body',
type: 'input-text',
label: tipedLabel('内容', '不填写时,自动使用目标地址值')
},
getSchemaTpl('inputBody'),
getSchemaTpl('switch', {
name: 'blank',
label: '在新窗口打开'

View File

@ -145,7 +145,7 @@ export class ListPlugin extends BasePlugin {
}
]
}
},
}
]
},
getSchemaTpl('status')

View File

@ -73,6 +73,7 @@ export class ListItemPlugin extends BasePlugin {
// {
// type: 'divider'
// },
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
name: 'title',
type: 'input-text',

View File

@ -44,12 +44,18 @@ export class LogPlugin extends BasePlugin {
required: true,
name: 'source',
renderLabel: true,
label: tipedLabel('数据源', `返回日志信息的服务,后端需要通过流的方式返回结果。
<a target="_blank" href="https://baidu.github.io/amis/zh-CN/components/log#%E5%90%8E%E7%AB%AF%E5%AE%9E%E7%8E%B0%E5%8F%82%E8%80%83"></a>`)
label: tipedLabel(
'数据源',
`返回日志信息的服务,后端需要通过流的方式返回结果。
<a target="_blank" href="https://baidu.github.io/amis/zh-CN/components/log#%E5%90%8E%E7%AB%AF%E5%AE%9E%E7%8E%B0%E5%8F%82%E8%80%83"></a>`
)
}),
{
type: 'input-text',
label: tipedLabel('文本编码', '返回内容的字符编码,例如 UTF-8、ISO-8859-2、KOI8-R、GBK等等。默认UTF-8'),
label: tipedLabel(
'文本编码',
'返回内容的字符编码,例如 UTF-8、ISO-8859-2、KOI8-R、GBK等等。默认UTF-8'
),
name: 'encoding'
},
getSchemaTpl('placeholder', {
@ -58,7 +64,10 @@ export class LogPlugin extends BasePlugin {
}),
{
type: 'switch',
label: tipedLabel('跟随底部', '自动滚动到底部,方便查看最新日志内容'),
label: tipedLabel(
'跟随底部',
'自动滚动到底部,方便查看最新日志内容'
),
name: 'autoScroll',
value: true,
inputClassName: 'is-inline'
@ -98,19 +107,25 @@ export class LogPlugin extends BasePlugin {
body: [
{
type: 'input-number',
label: tipedLabel('每行高度', `设置每行高度,这时就会默认启用虚拟渲染,避免渲染卡顿。
label: tipedLabel(
'每行高度',
`设置每行高度,这时就会默认启用虚拟渲染,避免渲染卡顿。
<ul><li></li>
<li></li></ul>
`),
`
),
name: 'rowHeight',
min: 1
},
{
type: 'input-number',
label: tipedLabel('显示行数', `限制最大显示行数,避免渲染卡顿,默认不限制。
label: tipedLabel(
'显示行数',
`限制最大显示行数,避免渲染卡顿,默认不限制。
<ul><li></li>
<li></li></ul>
`),
`
),
name: 'maxLength',
min: 1
}

View File

@ -91,7 +91,9 @@ export class MappingPlugin extends BasePlugin {
if (value === true) {
return {
type: 'tag',
label: `\${${this.getDisplayField(data)} | default: "-"}`
label: `\${${this.getDisplayField(
data
)} | default: "-"}`
};
}
return value ? value : undefined;
@ -130,13 +132,11 @@ export class MappingPlugin extends BasePlugin {
getDisplayField(data: any) {
if (
data.source
|| (
data.map
&& Array.isArray(data.map)
&& data.map[0]
&& Object.keys(data.map[0]).length > 1
)
data.source ||
(data.map &&
Array.isArray(data.map) &&
data.map[0] &&
Object.keys(data.map[0]).length > 1)
) {
return data.labelField ?? 'label';
}

View File

@ -30,7 +30,10 @@ export class MarkdownPlugin extends BasePlugin {
getSchemaTpl('tabs', [
{
title: '常规',
body: [getSchemaTpl('markdownBody')]
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('markdownBody')
]
},
{
title: '外观',

View File

@ -52,12 +52,10 @@ export class NavPlugin extends BasePlugin {
to: ''
},
items: [
{
type: 'input-text',
name: 'label',
getSchemaTpl('label', {
label: '名称',
required: true
},
}),
{
type: 'input-text',
@ -145,6 +143,7 @@ export class NavPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
$ref: 'links',
name: 'links'

View File

@ -34,22 +34,15 @@ export class TableCellPlugin extends BasePlugin {
</Button>
)
},*/
{
name: 'label',
label: '列名称',
type: 'input-text'
},
getSchemaTpl('label', {
label: '列名称'
}),
getSchemaTpl('formItemName', {
label: '绑定字段名'
}),
{
name: 'remark',
label: '提示',
type: 'input-text',
description: '显示一个提示图标,鼠标放上去会提示该内容。'
},
getSchemaTpl('remark'),
{
name: 'placeholder',

View File

@ -157,16 +157,8 @@ export class PagePlugin extends BasePlugin {
}
]
},
{
label: '页面标题',
name: 'title',
type: 'input-text'
},
{
label: '副标题',
name: 'subTitle',
type: 'textarea'
},
getSchemaTpl('pageTitle'),
getSchemaTpl('pageSubTitle'),
getSchemaTpl('remark', {
label: '标题提示',
hiddenOn:
@ -222,7 +214,7 @@ export class PagePlugin extends BasePlugin {
type: 'input-kv',
mode: 'normal',
name: 'data',
label: '初始化静态数据'
label: '组件静态数据'
}),
getSchemaTpl('apiControl', {
name: 'initApi',
@ -378,6 +370,16 @@ export class PagePlugin extends BasePlugin {
};
rendererBeforeDispatchEvent(node: EditorNodeType, e: any, data: any) {
if (e === 'init') {
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
const jsonschema: any = {
$id: 'pageInitData',
...jsonToJsonSchema(data)
};
scope?.removeSchema(jsonschema.$id);
scope?.addSchema(jsonschema);
}
if (e === 'inited') {
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
const jsonschema: any = {

View File

@ -66,6 +66,7 @@ export class PaginationPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
name: 'mode',
label: '模式',

View File

@ -98,12 +98,8 @@ export class PanelPlugin extends BasePlugin {
className: 'p-none',
title: '基本',
body: [
{
label: '标题',
name: 'title',
type: 'input-text'
},
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
getSchemaTpl('title'),
isForm
? null
: {

View File

@ -1,6 +1,11 @@
import {registerEditorPlugin} from 'amis-editor-core';
import {
registerEditorPlugin,
RendererPluginAction,
RendererPluginEvent
} from 'amis-editor-core';
import {BaseEventContext, BasePlugin} from 'amis-editor-core';
import {defaultValue, getSchemaTpl} from 'amis-editor-core';
import {getEventControlConfig} from '../renderer/event-control/helper';
export class PlainPlugin extends BasePlugin {
// 关联渲染器名字
@ -44,7 +49,8 @@ export class PlainPlugin extends BasePlugin {
label: '内容',
type: 'textarea',
mode: 'col',
pipeIn: (value: any, data: any) => value || (data && data.text),
pipeIn: (value: any, data: any) =>
value || (data && data.text),
name: 'tpl',
description:
'如果当前字段有值,请不要设置,否则覆盖。支持使用 <code>\\${xxx}</code> 来获取变量,或者用 lodash.template 语法来写模板逻辑。<a target="_blank" href="/amis/zh-CN/docs/concepts/template">详情</a>'
@ -58,27 +64,27 @@ export class PlainPlugin extends BasePlugin {
isTableCell ? null : getSchemaTpl('status')
])
},
isTableCell ? null : {
title: '外观',
body: getSchemaTpl('collapseGroup', [
{
title: '基本',
body: [
getSchemaTpl('switch', {
name: 'inline',
label: '内联模式',
value: true
})
]
},
{
title: 'CSS类名',
body: [
getSchemaTpl('className')
]
isTableCell
? null
: {
title: '外观',
body: getSchemaTpl('collapseGroup', [
{
title: '基本',
body: [
getSchemaTpl('switch', {
name: 'inline',
label: '内联模式',
value: true
})
]
},
{
title: 'CSS类名',
body: [getSchemaTpl('className')]
}
])
}
])
}
])
];
};

View File

@ -42,6 +42,7 @@ export class ProgressPlugin extends BasePlugin {
{
title: '基本',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '类型',
name: 'mode',

View File

@ -60,6 +60,7 @@ export class PropertyPlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
label: '标题',
type: 'input-text',

View File

@ -29,6 +29,7 @@ export class QRCodePlugin extends BasePlugin {
{
title: '常规',
body: [
getSchemaTpl('layout:originPosition', {value: 'left-top'}),
{
name: 'value',
type: 'input-text',

Some files were not shown because too many files have changed in this diff Show More