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