mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-15 17:31:18 +08:00
amis-saas-7476 table2字段调整
Change-Id: I20cd6c63447a08785ae5de1d3477033a0a98871d
This commit is contained in:
parent
e6e06534a3
commit
25d808d9b2
@ -121,8 +121,8 @@ import './plugin/Steps';
|
|||||||
import './plugin/Sparkline';
|
import './plugin/Sparkline';
|
||||||
import './plugin/Submit';
|
import './plugin/Submit';
|
||||||
import './plugin/Table';
|
import './plugin/Table';
|
||||||
import './plugin/Table-v2';
|
import './plugin/Table2';
|
||||||
import './plugin/TableCell-v2';
|
import './plugin/TableCell2';
|
||||||
import './plugin/Tabs';
|
import './plugin/Tabs';
|
||||||
import './plugin/Tasks';
|
import './plugin/Tasks';
|
||||||
import './plugin/Time';
|
import './plugin/Time';
|
||||||
|
@ -527,7 +527,7 @@ export class CRUDPlugin extends BasePlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 可能会出错,但是cards table-v2 list 配置面板结构统一,因此
|
// 可能会出错,但是cards table2 list 配置面板结构统一,因此
|
||||||
(context.data as any).tabs.forEach((tab: any) => {
|
(context.data as any).tabs.forEach((tab: any) => {
|
||||||
if (tab.title === '属性') {
|
if (tab.title === '属性') {
|
||||||
tab.body[0].body.forEach((collapse: any) => {
|
tab.body[0].body.forEach((collapse: any) => {
|
||||||
@ -707,7 +707,7 @@ export class CRUDPlugin extends BasePlugin {
|
|||||||
);
|
);
|
||||||
if (appendCols?.length) {
|
if (appendCols?.length) {
|
||||||
appendCols.forEach((col: any) => {
|
appendCols.forEach((col: any) => {
|
||||||
if (existColsName.includes(col.key)) {
|
if (existColsName.includes(col.name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,7 +760,6 @@ export class CRUDPlugin extends BasePlugin {
|
|||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1383,14 +1382,14 @@ export class CRUDPlugin extends BasePlugin {
|
|||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: 'A',
|
title: 'A',
|
||||||
key: 'a'
|
name: 'a'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'B',
|
title: 'B',
|
||||||
key: 'b'
|
name: 'b'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'operation',
|
name: 'operation',
|
||||||
title: '操作',
|
title: '操作',
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
@ -1534,7 +1533,7 @@ export class TableCRUDPlugin extends CRUDPlugin {
|
|||||||
mode: 'table2',
|
mode: 'table2',
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
key: 'id',
|
name: 'id',
|
||||||
title: 'ID',
|
title: 'ID',
|
||||||
type: 'container',
|
type: 'container',
|
||||||
body: [
|
body: [
|
||||||
@ -1544,7 +1543,7 @@ export class TableCRUDPlugin extends CRUDPlugin {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'engine',
|
name: 'engine',
|
||||||
title: '示例',
|
title: '示例',
|
||||||
type: 'container',
|
type: 'container',
|
||||||
body: [
|
body: [
|
||||||
|
@ -25,19 +25,19 @@ import {getEventControlConfig} from '../renderer/event-control/helper';
|
|||||||
import {SchemaObject} from 'amis/lib/Schema';
|
import {SchemaObject} from 'amis/lib/Schema';
|
||||||
import {getArgsWrapper} from '../renderer/event-control/helper';
|
import {getArgsWrapper} from '../renderer/event-control/helper';
|
||||||
|
|
||||||
export class TableV2Plugin extends BasePlugin {
|
export class Table2Plugin extends BasePlugin {
|
||||||
// 关联渲染器名字
|
// 关联渲染器名字
|
||||||
rendererName = 'table2';
|
rendererName = 'table2';
|
||||||
$schema = '/schemas/TableSchema.json';
|
$schema = '/schemas/TableSchema.json';
|
||||||
|
|
||||||
// 组件名称
|
// 组件名称
|
||||||
name = '表格V2';
|
name = '表格2';
|
||||||
isBaseComponent = true;
|
isBaseComponent = true;
|
||||||
panelJustify = true;
|
panelJustify = true;
|
||||||
disabledRendererPlugin = true;
|
disabledRendererPlugin = true;
|
||||||
description =
|
description =
|
||||||
'用来展示表格数据,可以配置列信息,然后关联数据便能完成展示。支持嵌套、超级表头、列固定、表头固顶、合并单元格等等。当前组件需要配置数据源,不自带数据拉取,请优先使用 「CRUD」 组件。';
|
'用来展示表格数据,可以配置列信息,然后关联数据便能完成展示。支持嵌套、超级表头、列固定、表头固顶、合并单元格等等。当前组件需要配置数据源,不自带数据拉取,请优先使用 「CRUD」 组件。';
|
||||||
docLink = '/amis/zh-CN/components/table-v2';
|
docLink = '/amis/zh-CN/components/table2';
|
||||||
icon = 'fa fa-table';
|
icon = 'fa fa-table';
|
||||||
|
|
||||||
scaffold: SchemaObject = {
|
scaffold: SchemaObject = {
|
||||||
@ -74,11 +74,11 @@ export class TableV2Plugin extends BasePlugin {
|
|||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: 'A',
|
title: 'A',
|
||||||
key: 'a'
|
name: 'a'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'B',
|
title: 'B',
|
||||||
key: 'b'
|
name: 'b'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@ -101,7 +101,7 @@ export class TableV2Plugin extends BasePlugin {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'input-text',
|
type: 'input-text',
|
||||||
name: 'key',
|
name: 'name',
|
||||||
placeholder: '绑定字段名'
|
placeholder: '绑定字段名'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -326,18 +326,19 @@ export class TableV2Plugin extends BasePlugin {
|
|||||||
const columns: EditorNodeType = node.children.find(
|
const columns: EditorNodeType = node.children.find(
|
||||||
item => item.isRegion && item.region === 'columns'
|
item => item.isRegion && item.region === 'columns'
|
||||||
);
|
);
|
||||||
|
if (columns) {
|
||||||
for (let current of columns.children) {
|
for (let current of columns.children) {
|
||||||
const schema = current.schema;
|
const schema = current.schema;
|
||||||
if (schema && schema.key) {
|
if (schema && schema.key) {
|
||||||
itemsSchema.properties[schema.key] = current.info?.plugin
|
itemsSchema.properties[schema.key] = current.info?.plugin
|
||||||
?.buildDataSchemas
|
?.buildDataSchemas
|
||||||
? await current.info.plugin.buildDataSchemas(current, region)
|
? await current.info.plugin.buildDataSchemas(current, region)
|
||||||
: {
|
: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
title: schema.label || schema.title,
|
title: schema.label || schema.title,
|
||||||
description: schema.description
|
description: schema.description
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,8 +823,8 @@ export class TableV2Plugin extends BasePlugin {
|
|||||||
|
|
||||||
if (Array.isArray(props.columns)) {
|
if (Array.isArray(props.columns)) {
|
||||||
props.columns.forEach((column: any) => {
|
props.columns.forEach((column: any) => {
|
||||||
if (column.key) {
|
if (column.name) {
|
||||||
setVariable(mockedData, column.key, mockValue(column));
|
setVariable(mockedData, column.name, mockValue(column));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -905,4 +906,4 @@ export class TableV2Plugin extends BasePlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEditorPlugin(TableV2Plugin);
|
registerEditorPlugin(Table2Plugin);
|
@ -1,6 +1,6 @@
|
|||||||
import {Button, Icon} from 'amis';
|
import {Button, Icon} from 'amis';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {FormItemProps, getVariable} from 'amis-core';
|
import {getVariable} from 'amis-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BasePlugin,
|
BasePlugin,
|
||||||
@ -20,7 +20,7 @@ import {TabsSchema} from 'amis/lib/renderers/Tabs';
|
|||||||
import {SchemaObject} from 'amis/lib/Schema';
|
import {SchemaObject} from 'amis/lib/Schema';
|
||||||
import {remarkTpl} from '../component/BaseControl';
|
import {remarkTpl} from '../component/BaseControl';
|
||||||
|
|
||||||
export class TableCellV2Plugin extends BasePlugin {
|
export class TableCell2Plugin extends BasePlugin {
|
||||||
panelTitle = '列配置';
|
panelTitle = '列配置';
|
||||||
panelIcon = 'fa fa-columns';
|
panelIcon = 'fa fa-columns';
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ export class TableCellV2Plugin extends BasePlugin {
|
|||||||
? false
|
? false
|
||||||
: {
|
: {
|
||||||
sameName: context.info.renderer.isFormItem ? 'name' : undefined,
|
sameName: context.info.renderer.isFormItem ? 'name' : undefined,
|
||||||
name: 'key',
|
name: 'name',
|
||||||
type: 'ae-DataBindingControl',
|
type: 'ae-DataBindingControl',
|
||||||
label: '列字段',
|
label: '列字段',
|
||||||
onBindingChange(
|
onBindingChange(
|
||||||
@ -557,7 +557,6 @@ export class TableCellV2Plugin extends BasePlugin {
|
|||||||
const parent = dom.parentElement?.parentElement;
|
const parent = dom.parentElement?.parentElement;
|
||||||
const groupId = parent?.getAttribute('data-group-id');
|
const groupId = parent?.getAttribute('data-group-id');
|
||||||
const wrapper = dom.closest('table')!.parentElement?.parentElement;
|
const wrapper = dom.closest('table')!.parentElement?.parentElement;
|
||||||
|
|
||||||
return [].slice.call(
|
return [].slice.call(
|
||||||
wrapper?.querySelectorAll(
|
wrapper?.querySelectorAll(
|
||||||
`th[data-group-id="${groupId}"],
|
`th[data-group-id="${groupId}"],
|
||||||
@ -585,4 +584,4 @@ export class TableCellV2Plugin extends BasePlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEditorPlugin(TableCellV2Plugin);
|
registerEditorPlugin(TableCell2Plugin);
|
Loading…
Reference in New Issue
Block a user