From 5597a7cc1361fd76218c939df391b96ac95a047a Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Thu, 4 Jul 2019 19:13:46 +0800 Subject: [PATCH] =?UTF-8?q?Picker=20=E4=BC=98=E5=8C=96,=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=80=BC=E5=B1=95=E7=A4=BA=E7=94=A8=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scss/components/_crud.scss | 4 ++-- src/renderers/CRUD.tsx | 3 ++- src/renderers/Form/Picker.tsx | 15 +++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/scss/components/_crud.scss b/scss/components/_crud.scss index ff6d0286..48742b89 100644 --- a/scss/components/_crud.scss +++ b/scss/components/_crud.scss @@ -17,7 +17,7 @@ &-value { cursor: pointer; - vertical-align: top; + vertical-align: middle; user-select: none; line-height: $Form-input-lineHeight * $Form-input-fontSize - px2rem(2px); display: inline-block; @@ -59,7 +59,7 @@ user-select: none; margin-left: $gap-xs; margin-top: $gap-xs; - vertical-align: top; + vertical-align: middle; } &-toolbar-item { diff --git a/src/renderers/CRUD.tsx b/src/renderers/CRUD.tsx index b6c752c8..d2f283ae 100644 --- a/src/renderers/CRUD.tsx +++ b/src/renderers/CRUD.tsx @@ -25,6 +25,7 @@ import {evalExpression, filter} from '../utils/tpl'; import {isValidApi, buildApi} from '../utils/api'; import omit = require('lodash/omit'); import find = require('lodash/find'); +import Html from '../components/Html'; interface CRUDProps extends RendererProps { api?: Api; @@ -1264,7 +1265,7 @@ export default class CRUD extends React.Component { {labelTpl - ? filter(labelTpl, item) + ? () : getVariable(item, labelField || 'label') || getVariable(item, primaryField || 'id')} diff --git a/src/renderers/Form/Picker.tsx b/src/renderers/Form/Picker.tsx index 0789c69d..725e04f3 100644 --- a/src/renderers/Form/Picker.tsx +++ b/src/renderers/Form/Picker.tsx @@ -12,8 +12,10 @@ import { Action } from '../../types'; import find = require('lodash/find'); -import {anyChanged, autobind} from '../../utils/helper'; +import {anyChanged, autobind, getVariable} from '../../utils/helper'; import findIndex = require('lodash/findIndex'); +import Html from '../../components/Html'; +import { filter } from '../../utils/tpl'; export interface PickerProps extends OptionsControlProps { modalMode: 'dialog' | 'drawer'; @@ -172,6 +174,7 @@ export default class PickerControl extends React.PureComponent classPrefix: ns, selectedOptions, labelField, + labelTpl, disabled } = this.props; return ( @@ -181,7 +184,11 @@ export default class PickerControl extends React.PureComponent 'is-disabled': disabled })}> × - {item[labelField || 'label']} + + {labelTpl + ? () + : getVariable(item, labelField || 'label') || getVariable(item, 'id')} + ))} @@ -235,13 +242,13 @@ export default class PickerControl extends React.PureComponent className={`${ns}Picker-pickBtn`} tooltip="点击选择" tooltipContainer={env && env.getModalContainer ? env.getModalContainer() : undefined} - level="link" + level="info" size="sm" disabled={disabled} onClick={this.open} iconOnly > - + 选定 {render('modal', {