From 85fb8d745270c0dfb8e3801c27fc2dc4240b0459 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 12 Apr 2022 22:48:24 +0800 Subject: [PATCH] fix: randomly generate role name --- .../src/acl/Configuration/schemas/roles.ts | 19 ++++++++++++++++++- packages/client/src/locale/zh_CN.ts | 2 +- .../src/schema-initializer/items/index.tsx | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/client/src/acl/Configuration/schemas/roles.ts b/packages/client/src/acl/Configuration/schemas/roles.ts index 089945fe0..17b3ed1d2 100644 --- a/packages/client/src/acl/Configuration/schemas/roles.ts +++ b/packages/client/src/acl/Configuration/schemas/roles.ts @@ -1,4 +1,7 @@ import { ISchema } from '@formily/react'; +import { uid } from '@formily/shared'; +import { useRequest } from '../../../api-client'; +import { useActionContext } from '../../../schema-component'; import { roleCollectionsSchema } from './roleCollections'; const collection = { @@ -25,7 +28,6 @@ const collection = { title: '角色标识', type: 'string', 'x-component': 'Input', - description: '使用英文', } as ISchema, }, { @@ -92,6 +94,20 @@ export const roleSchema: ISchema = { type: 'void', 'x-component': 'Action.Drawer', 'x-decorator': 'Form', + 'x-decorator-props': { + useValues(options) { + const ctx = useActionContext(); + return useRequest( + () => + Promise.resolve({ + data: { + name: `r_${uid()}`, + }, + }), + { ...options, refreshDeps: [ctx.visible] }, + ); + }, + }, title: '添加角色', properties: { title: { @@ -101,6 +117,7 @@ export const roleSchema: ISchema = { name: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', + description: '{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}', }, default: { 'x-component': 'CollectionField', diff --git a/packages/client/src/locale/zh_CN.ts b/packages/client/src/locale/zh_CN.ts index ef5d571ec..31ba62229 100644 --- a/packages/client/src/locale/zh_CN.ts +++ b/packages/client/src/locale/zh_CN.ts @@ -100,7 +100,7 @@ export default { "Create collection": "创建数据表", "Collection display name": "数据表名称", "Collection name": "数据表标识", - "Randomly generated and can be modified. Support letters, numbers and underscores, must start with a letter.": "随机生成,可修改。支持英文、数字和下划线,必须以英文字母开头。", + "Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.": "随机生成,可修改。支持英文、数字和下划线,必须以英文字母开头。", "Storage type": "存储类型", "Edit": "编辑", "Edit collection": "编辑数据表", diff --git a/packages/client/src/schema-initializer/items/index.tsx b/packages/client/src/schema-initializer/items/index.tsx index 435106b3a..710b7dab3 100644 --- a/packages/client/src/schema-initializer/items/index.tsx +++ b/packages/client/src/schema-initializer/items/index.tsx @@ -105,7 +105,7 @@ export const FormBlockInitializer = (props) => { } - componentType={'Form'} + componentType={'CreateForm'} createBlockSchema={createFormBlockSchema} /> );