salary-management-front/pc4mobx/hrmSalary/components/customForm/index.js

64 lines
2.9 KiB
JavaScript

import React from 'react'
import { Checkbox, Radio, Row, Col } from "antd"
import { WeaInput } from "ecCom"
import RequiredLabelTip from '../requiredLabelTip';
const CheckboxGroup = Checkbox.Group;
export default class CustomForm extends React.Component {
handleChange(params) {
let request = {...this.props.request, ...params}
this.props.onChange(request);
}
render() {
const { request, disable } = this.props;
return (
<div style={{padding: "20px"}}>
{
this.props.condition.map(item => {
let disabledValue = disable && disable.indexOf(item.domkey[0]) >= 0
return (
<Row style={{lineHeight: "40px"}}>
<Col span={6}>
{item.label} {
item.rules == "required" && <RequiredLabelTip />
} :
</Col>
<Col span={18}>
{
item.conditionType == "INPUT" &&
<WeaInput value={request[item.domkey[0]]} disabled={disabledValue} onChange={(value) => {
this.handleChange({[item.domkey[0]]: value})
}}/>
}
{
item.conditionType == "RADIO" && item.options &&
<Radio.Group value={request[item.domkey[0]]}
disabled={disabledValue}
onChange={(e) => this.handleChange({[item.domkey[0]]: e.target.value})}>
{
item.options.map(o => (
<Radio value={o.key}>{o.showname}</Radio>
))
}
</Radio.Group>
}
{
item.conditionType == "CHECKBOX" &&
item.options &&
<CheckboxGroup
disabled={disabledValue}
value={request[item.domkey[0]]} options={item.options.map(o => ({label: o.showname, value: o.key}))} onChange={(value) => this.handleChange({[item.domkey[0]]: value}) }/>
}
</Col>
</Row>
)
})
}
</div>
)
}
}