From 732ea0c41eca8ce755898835872481a1c0c603f9 Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Sun, 10 Nov 2019 11:38:33 +0800 Subject: [PATCH] =?UTF-8?q?Tree=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scss/components/form/_tree.scss | 8 ++++---- src/components/Tree.tsx | 4 +++- src/renderers/Form/Options.tsx | 36 +++++++++++++++++++++++++++++++-- src/utils/api.ts | 6 +++--- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/scss/components/form/_tree.scss b/scss/components/form/_tree.scss index 8949898e0..3e5def7b2 100644 --- a/scss/components/form/_tree.scss +++ b/scss/components/form/_tree.scss @@ -32,8 +32,6 @@ position: relative; >div { - color: inherit; - &:hover { text-decoration: none; @@ -230,11 +228,13 @@ - &-item &-item>&-itemLabel { + &-item &-item>&-itemLabel, + &-item>&-placeholder { padding-left: $Tree-indent; } - &-item &-item &-item>&-itemLabel { + &-item &-item &-item>&-itemLabel, + &-item &-item>&-placeholder { padding-left: $Tree-indent * 2; } diff --git a/src/components/Tree.tsx b/src/components/Tree.tsx index 7982fabf0..f90f61c0d 100644 --- a/src/components/Tree.tsx +++ b/src/components/Tree.tsx @@ -646,6 +646,8 @@ export class TreeSelector extends React.Component< ) : null} {childrenItems} + ) : !childrenItems && item.placeholder ? ( +
{item.placeholder}
) : null} ); @@ -674,7 +676,7 @@ export class TreeSelector extends React.Component< let addBtn = null; - if (creatable && hideRoot) { + if (creatable && rootCreatable !== false && hideRoot) { addBtn = ( = []; -export function normalizeApi(api: Api): ApiObject { +export function normalizeApi(api: Api, defaultMethod?: string): ApiObject { if (typeof api === 'string') { let method = rSchema.test(api) ? RegExp.$1 : ''; method && (api = api.replace(method + ':', '')); api = { - method: method as any, + method: (method || defaultMethod) as any, url: api }; } else { @@ -46,7 +46,7 @@ export function buildApi( [propName: string]: any; } = {} ): ApiObject { - api = normalizeApi(api); + api = normalizeApi(api, options.method); const {autoAppend, ignoreData, ...rest} = options; api.config = {