133 lines
4.4 KiB
JavaScript
133 lines
4.4 KiB
JavaScript
import {
|
|
WeaDialog,
|
|
WeaFormItem,
|
|
WeaNewScroll,
|
|
WeaSearchGroup,
|
|
WeaMoreButton,
|
|
} from 'ecCom'
|
|
|
|
import {
|
|
Spin,
|
|
Button,
|
|
} from 'antd'
|
|
|
|
import {
|
|
WeaSwitch
|
|
} from 'comsMobx'
|
|
|
|
import {
|
|
i18n
|
|
} from '../public/i18n';
|
|
|
|
export default class NewAndEditDialog extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
width: 700,
|
|
}
|
|
}
|
|
|
|
|
|
getForm() {
|
|
const {
|
|
condition,
|
|
form,
|
|
isFormInit,
|
|
} = this.props;
|
|
|
|
let arr = [];
|
|
isFormInit && condition.map(c => {
|
|
c.items.map((field, index) => {
|
|
arr.push(<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@jacv6v@${index}`}
|
|
label={`${field.label}`}
|
|
labelCol={{span: `${field.labelcol}`}}
|
|
error={form.getError(field)}
|
|
tipPosition="bottom"
|
|
wrapperCol={{span: `${field.fieldcol}`}}>
|
|
{<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@7vxyfr@${index}`} fieldConfig={field} form={form} formParams={form.getFormParams()} />}
|
|
</WeaFormItem>)
|
|
})
|
|
})
|
|
return <div className="wea-form-item-group">{arr}</div>
|
|
}
|
|
|
|
getSearchGroupForm() {
|
|
const {
|
|
condition,
|
|
form,
|
|
isFormInit,
|
|
domkey,
|
|
isEdit
|
|
} = this.props;
|
|
|
|
let arr = [];
|
|
isFormInit && condition.map((c, i) => {
|
|
let _arr = [];
|
|
c.items.map((field, index) => {
|
|
_arr.push({
|
|
com: (
|
|
<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@merei2@${index}`}
|
|
label={`${field.label}`}
|
|
labelCol={{span: `${field.labelcol}`}}
|
|
error={form.getError(field)}
|
|
tipPosition="bottom"
|
|
wrapperCol={{span: `${field.fieldcol}`}}
|
|
underline={isEdit?false:true}
|
|
>
|
|
<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@5r6c5a@${index}`} fieldConfig={field} form={form} formParams={form.getFormParams()} />
|
|
</WeaFormItem>
|
|
),
|
|
colSpan: 1
|
|
})
|
|
})
|
|
arr.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@qaih5l@${i}`} needTigger={true} title={c.title} showGroup={c.defaultshow} items={_arr} col={1} />)
|
|
})
|
|
|
|
return arr;
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
const {
|
|
title,
|
|
visible,
|
|
save,
|
|
onCancel,
|
|
loading,
|
|
isEdit,
|
|
height,
|
|
conditionLen,
|
|
} = this.props, {
|
|
width,
|
|
} = this.state;
|
|
|
|
const buttons = [
|
|
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@jd6baw`} type="primary" onClick={() => save()} disabled={loading}>{i18n.button.save()}</Button>),
|
|
(<WeaMoreButton ecId={`${this && this.props && this.props.ecId || ''}_WeaMoreButton@e4f4n1`} />)
|
|
];
|
|
|
|
return (
|
|
<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@1txk5f`}
|
|
title={title}
|
|
icon="icon-coms-hrm"
|
|
iconBgcolor="#217346"
|
|
visible={visible}
|
|
closable={true}
|
|
hasScroll={true}
|
|
onCancel={() => onCancel() }
|
|
buttons={isEdit?buttons:buttons.slice(1,2)}
|
|
style={{width: width, height: height}}
|
|
>
|
|
{
|
|
loading ? <div className='hrm-loading-center-small'>
|
|
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@4ygl4a`} spinning={loading}></Spin>
|
|
</div>
|
|
: <div className={conditionLen > 1 ? '' : 'hrm-dialog-form'}>
|
|
{conditionLen > 1 ? this.getSearchGroupForm() : this.getForm()}
|
|
</div>
|
|
}
|
|
</WeaDialog>
|
|
)
|
|
}
|
|
} |