Skip to content

Commit

Permalink
Merge pull request edp963#40 from edp963/dev-0.3
Browse files Browse the repository at this point in the history
merge from edp963/davinci dev-0.3
  • Loading branch information
xxxllluuu authored Oct 28, 2020
2 parents 59a458f + 2105e6a commit f53db01
Show file tree
Hide file tree
Showing 121 changed files with 6,239 additions and 1,656 deletions.
4 changes: 2 additions & 2 deletions webapp/app/components/ConditionValuesControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import moment, { Moment } from 'moment'
import OperatorTypes from 'utils/operatorTypes'

import { Row, Col, Input, InputNumber, DatePicker, Button, Tag, Switch } from 'antd'

import { DEFAULT_DATETIME_FORMAT } from 'app/globalConstants'
import Styles from './ConditionValuesControl.less'

export type ConditionValueTypes = string | number | boolean
Expand Down Expand Up @@ -170,7 +170,7 @@ export class ConditionValuesControl extends React.PureComponent<IConditionValues
<DatePicker
style={this.controlStyle}
size={size}
format="YYYY-MM-DD HH:mm:ss"
format={DEFAULT_DATETIME_FORMAT}
showTime={{ defaultValue: moment('00:00:00', 'HH:mm:ss') }}
value={dateValue}
onChange={this.localValuesChange(idx)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Form, Row, Col, Select, Radio, Empty } from 'antd'
import { WrappedFormUtils } from 'antd/lib/form/Form'
import { RadioChangeEvent } from 'antd/lib/radio'
import { IViewModelProps } from 'app/containers/View/types'
import { ControlFieldTypes } from '../../constants'
import { ControlFieldTypes, ControlTypes, IS_RANGE_TYPE } from '../../constants'
import { IFlatRelatedView } from './types'
import { filterSelectOption } from 'app/utils/util'
import styles from '../../Control.less'
Expand All @@ -36,13 +36,15 @@ const RadioGroup = Radio.Group
interface IGlobalControlRelatedViewFormProps {
form: WrappedFormUtils
relatedViews: IFlatRelatedView[]
controlType: ControlTypes
optionWithVariable: boolean
onFieldTypeChange: (id: number) => (e: RadioChangeEvent) => void
}

const GlobalControlRelatedViewForm: FC<IGlobalControlRelatedViewFormProps> = ({
form,
relatedViews,
controlType,
optionWithVariable,
onFieldTypeChange
}) => {
Expand Down Expand Up @@ -92,85 +94,85 @@ const GlobalControlRelatedViewForm: FC<IGlobalControlRelatedViewFormProps> = ({
</div>
<div className={viewsClass}>
{relatedViews.length ? (
relatedViews.map(
({ id, name, fieldType, fields, models, variables }) => {
const isMultiple = Array.isArray(fields)
const fieldValues =
form.getFieldValue(`relatedViews[${id}].fields`) || []
return (
<div key={id} className={styles.relatedView}>
<div className={styles.name}>
<h4>{name}</h4>
{getFieldDecorator(
`relatedViews[${id}].fieldType`,
{}
)(
<RadioGroup
size="small"
className={styles.fieldType}
disabled={optionWithVariable}
onChange={onFieldTypeChange(id)}
>
<RadioButton value={ControlFieldTypes.Column}>
字段
</RadioButton>
<RadioButton value={ControlFieldTypes.Variable}>
变量
</RadioButton>
</RadioGroup>
)}
</div>
<Row gutter={8}>
<Col span={24}>
<FormItem>
{getFieldDecorator(`relatedViews[${id}].fields`, {
rules: [
{
required: true,
message: `关联${
fieldType === ControlFieldTypes.Column
? '字段'
: '变量'
}不能为空`
},
{ validator: columnValidator }
]
})(
<Select
showSearch
placeholder="请选择"
filterOption={filterSelectOption}
{...(isMultiple && { mode: 'multiple' })}
disabled={optionWithVariable}
>
{fieldType === ControlFieldTypes.Column
? models.map((m: IViewModelProps) => (
<Option key={m.name} value={m.name}>
{m.name}
</Option>
))
: variables.map((v) => (
<Option
key={v.name}
value={v.name}
disabled={
isMultiple &&
fieldValues.length === 2 &&
!fieldValues.includes(v.name)
}
>
{v.name}
</Option>
))}
</Select>
)}
</FormItem>
</Col>
</Row>
relatedViews.map(({ id, name, fieldType, models, variables }) => {
const isMultiple =
IS_RANGE_TYPE[controlType] &&
fieldType === ControlFieldTypes.Variable
const fieldValues =
form.getFieldValue(`relatedViews[${id}].fields`) || []
return (
<div key={id} className={styles.relatedView}>
<div className={styles.name}>
<h4>{name}</h4>
{getFieldDecorator(
`relatedViews[${id}].fieldType`,
{}
)(
<RadioGroup
size="small"
className={styles.fieldType}
disabled={optionWithVariable}
onChange={onFieldTypeChange(id)}
>
<RadioButton value={ControlFieldTypes.Column}>
字段
</RadioButton>
<RadioButton value={ControlFieldTypes.Variable}>
变量
</RadioButton>
</RadioGroup>
)}
</div>
)
}
)
<Row gutter={8}>
<Col span={24}>
<FormItem>
{getFieldDecorator(`relatedViews[${id}].fields`, {
rules: [
{
required: true,
message: `关联${
fieldType === ControlFieldTypes.Column
? '字段'
: '变量'
}不能为空`
},
{ validator: columnValidator }
]
})(
<Select
showSearch
placeholder="请选择"
filterOption={filterSelectOption}
{...(isMultiple && { mode: 'multiple' })}
disabled={optionWithVariable}
>
{fieldType === ControlFieldTypes.Column
? models.map((m: IViewModelProps) => (
<Option key={m.name} value={m.name}>
{m.name}
</Option>
))
: variables.map((v) => (
<Option
key={v.name}
value={v.name}
disabled={
isMultiple &&
fieldValues.length === 2 &&
!fieldValues.includes(v.name)
}
>
{v.name}
</Option>
))}
</Select>
)}
</FormItem>
</Col>
</Row>
</div>
)
})
) : (
<Empty key="empty" image={Empty.PRESENTED_IMAGE_SIMPLE} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Form, Row, Col, Radio, Select, Divider } from 'antd'
import { WrappedFormUtils } from 'antd/lib/form/Form'
import { RadioChangeEvent } from 'antd/lib/radio'
import { IFlatRelatedView } from './types'
import { ControlFieldTypes } from '../../constants'
import { ControlFieldTypes, ControlTypes, IS_RANGE_TYPE } from '../../constants'
import { filterSelectOption } from 'app/utils/util'
import { IViewModelProps } from 'app/containers/View/types'
const FormItem = Form.Item
Expand All @@ -34,19 +34,22 @@ const RadioButton = Radio.Button
interface ILocalControlRelatedInfoFormProps {
form: WrappedFormUtils
relatedView: IFlatRelatedView
controlType: ControlTypes
optionWithVariable: boolean
onFieldTypeChange: (id: number) => (e: RadioChangeEvent) => void
}

const LocalControlRelatedInfoForm: FC<ILocalControlRelatedInfoFormProps> = ({
form,
relatedView,
controlType,
optionWithVariable,
onFieldTypeChange
}) => {
const { getFieldDecorator } = form
const { id, fields, fieldType, models, variables } = relatedView
const isMultiple = Array.isArray(fields)
const { id, fieldType, models, variables } = relatedView
const isMultiple =
IS_RANGE_TYPE[controlType] && fieldType === ControlFieldTypes.Variable
const fieldValues = form.getFieldValue(`relatedViews[${id}].fields`) || []
const colSpan = { xxl: 12, xl: 18 }
const itemCols = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
ControlOptionTypes,
ControlTypes
} from '../../constants'
import { IControl, IControlOption, IControlRelatedField } from '../../types'
import { IControl, IControlOption } from '../../types'
import { IViewBase, IFormedViews } from 'app/containers/View/types'
import { OperatorTypesLocale } from 'app/utils/operatorTypes'
import { getOperatorOptions } from '../../util'
Expand Down Expand Up @@ -152,9 +152,7 @@ const ValueForm: FC<IValueFormProps> = ({
title: '关联变量',
key: 'variables',
dataIndex: 'variables',
render: (variables) =>
variables &&
Object.values(variables).map((v: IControlRelatedField) => v.name)
render: (variables) => variables && Object.values(variables)
})
}

Expand Down
15 changes: 11 additions & 4 deletions webapp/app/components/Control/Config/ControlForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import { IControl, IControlOption } from '../../types'
import { IViewBase, IFormedViews } from 'app/containers/View/types'
import { IFlatRelatedItem, IFlatRelatedView } from './types'
import { parseDefaultValue } from '../../util'
import { ControlPanelTypes } from '../../constants'
import {
ControlFieldTypes,
ControlPanelTypes,
IS_RANGE_TYPE
} from '../../constants'
import styles from '../../Control.less'

interface IControlFormProps extends FormComponentProps {
Expand Down Expand Up @@ -104,9 +108,10 @@ class ControlForm extends PureComponent<IControlFormProps> {
...values,
[`relatedViews[${id}].fieldType`]: fieldType,
[`relatedViews[${id}].fields`]: fields
? Array.isArray(fields)
? fields.map((f) => f.name)
: fields.name
? IS_RANGE_TYPE[controlBase.type] &&
fieldType === ControlFieldTypes.Variable
? fields
: fields[0]
: void 0
}),
{}
Expand Down Expand Up @@ -195,6 +200,7 @@ class ControlForm extends PureComponent<IControlFormProps> {
<GlobalControlRelatedViewForm
form={form}
relatedViews={relatedViewList}
controlType={controlBase.type}
optionWithVariable={controlBase.optionWithVariable}
onFieldTypeChange={onFieldTypeChange}
/>
Expand All @@ -206,6 +212,7 @@ class ControlForm extends PureComponent<IControlFormProps> {
<LocalControlRelatedInfoForm
form={form}
relatedView={relatedViewList[0]}
controlType={controlBase.type}
optionWithVariable={controlBase.optionWithVariable}
onFieldTypeChange={onFieldTypeChange}
/>
Expand Down
7 changes: 1 addition & 6 deletions webapp/app/components/Control/Config/OptionSettingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ class OptionSettingForm extends PureComponent<IOptionSettingFormProps> {
} else {
form.setFieldsValue({
...values,
...(optionWithVariable &&
values.variables &&
Object.entries(values.variables).reduce((obj, [viewId, field]) => {
obj[viewId] = field.name
return obj
}, {}))
...(optionWithVariable && values.variables)
})
}
}
Expand Down
Loading

0 comments on commit f53db01

Please sign in to comment.