目前看来 Repeat 组件有点多余

This commit is contained in:
2betop 2020-05-11 20:20:10 +08:00
parent 5cb489fac8
commit a6a64f4ec2
6 changed files with 47 additions and 10 deletions

View File

@ -775,9 +775,43 @@ export default {
type: 'divider' type: 'divider'
}, },
{ {
type: 'repeat', label: '时间频率',
name: 'repeat', type: 'group',
label: '时间频率' controls: [
{
name: 'repeatCount',
type: 'range',
label: false,
visibleOn: 'data.repeatUnit != "none"'
},
{
type: 'select',
name: 'repeatUnit',
label: false,
value: 'none',
mode: 'inline',
columnClassName: 'v-middle no-grow',
options: [
{
label: '不重复',
value: 'none'
},
{
label: '年',
value: 'year'
},
{
label: '月',
value: 'month'
},
{
label: '日',
value: 'day'
}
]
}
]
}, },
{ {
type: 'divider' type: 'divider'

View File

@ -1304,9 +1304,8 @@
} }
.v-middle { .v-middle {
// display: inline-flex;
// align-items: center;
vertical-align: middle !important; vertical-align: middle !important;
align-self: center;
} }
.scrollable { .scrollable {

View File

@ -36,6 +36,7 @@ export interface Option {
export interface Options extends Array<Option> {} export interface Options extends Array<Option> {}
export interface OptionProps { export interface OptionProps {
className?: string;
multi?: boolean; multi?: boolean;
multiple?: boolean; multiple?: boolean;
valueField?: string; valueField?: string;

View File

@ -138,14 +138,15 @@ export class ControlGroupRenderer extends React.Component<InputGroupProps> {
const columnWidth = const columnWidth =
control.columnRatio || control.columnRatio ||
getWidthRate(control && control.columnClassName); getWidthRate(control && control.columnClassName, true);
return ( return (
<div <div
key={index} key={index}
className={cx( className={cx(
`${ns}Form-groupColumn`, `${ns}Form-groupColumn`,
columnWidth ? `${ns}Form-groupColumn--${columnWidth}` : '' columnWidth ? `${ns}Form-groupColumn--${columnWidth}` : '',
control && control.columnClassName
)} )}
> >
{this.renderControl(control, index, { {this.renderControl(control, index, {

View File

@ -1,6 +1,8 @@
/** /**
* @file filter * @file filter
* @author fex * @author fex
*
*
*/ */
/* eslint fecs-indent: [0, "space", 2, 2] */ /* eslint fecs-indent: [0, "space", 2, 2] */
@ -189,7 +191,7 @@ export default class RepeatControl extends React.Component<RepeatProps, any> {
<div className="col v-middle repeat-btn"> <div className="col v-middle repeat-btn">
<Select <Select
classPrefix={ns} classPrefix={ns}
className={input ? 'pull-right' : null} className={input ? 'pull-right' : ''}
options={optionsArray} options={optionsArray}
placeholder={placeholder} placeholder={placeholder}
onChange={this.handleOptionChange} onChange={this.handleOptionChange}

View File

@ -1006,12 +1006,12 @@ export function camel(str?: string) {
: ''; : '';
} }
export function getWidthRate(value: any): number { export function getWidthRate(value: any, strictMode = false): number {
if (typeof value === 'string' && /\bcol\-\w+\-(\d+)\b/.test(value)) { if (typeof value === 'string' && /\bcol\-\w+\-(\d+)\b/.test(value)) {
return parseInt(RegExp.$1, 10); return parseInt(RegExp.$1, 10);
} }
return value || 0; return strictMode ? 0 : value || 0;
} }
export function getLevelFromClassName( export function getLevelFromClassName(