目前看来 Repeat 组件有点多余

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

View File

@ -775,9 +775,43 @@ export default {
type: 'divider'
},
{
type: 'repeat',
name: 'repeat',
label: '时间频率'
label: '时间频率',
type: 'group',
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'

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
/**
* @file filter
* @author fex
*
*
*/
/* 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">
<Select
classPrefix={ns}
className={input ? 'pull-right' : null}
className={input ? 'pull-right' : ''}
options={optionsArray}
placeholder={placeholder}
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)) {
return parseInt(RegExp.$1, 10);
}
return value || 0;
return strictMode ? 0 : value || 0;
}
export function getLevelFromClassName(