trunk/pc4mobx/organization/components/department/NewPopconfirm.js

120 lines
3.7 KiB
JavaScript
Raw Normal View History

2022-06-02 16:51:21 +08:00
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 NewPopconfirm extends React.Component {
constructor(props) {
super(props);
this.state = {
2022-06-07 09:34:25 +08:00
value: '0'
2022-06-02 16:51:21 +08:00
}
}
2022-06-07 09:34:25 +08:00
renderComponent(field, index,form) {
return <WeaFormItem style={{ margin: "10px" }} 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()}
onChange={this.onChange} />}
</WeaFormItem>
}
2022-06-02 16:51:21 +08:00
getForm() {
const {
condition,
form,
isFormInit,
2022-06-07 09:34:25 +08:00
isMerge
} = this.props, {
value
} = this.state;
2022-06-02 16:51:21 +08:00
let arr = [];
isFormInit && condition.map(c => {
c.items.map((field, index) => {
2022-06-07 09:34:25 +08:00
if(!isMerge){
if (field.domkey[0] !== 'company' && field.domkey[0] !== 'department') {
arr.push(
this.renderComponent(field,index,form)
)
}
value === '0' && field.domkey[0] === 'company' && arr.push(
this.renderComponent(field,index,form)
)
value === '1' && field.domkey[0] === 'department' && arr.push(
this.renderComponent(field,index,form)
)
}else{
arr.push(
this.renderComponent(field,index,form))
}
2022-06-02 16:51:21 +08:00
})
})
return <div className="wea-form-item-group">{arr}</div>
}
2022-06-06 16:48:19 +08:00
onChange = data => {
2022-06-07 09:34:25 +08:00
data.moveType && this.setState({
value:data.moveType.value
})
2022-06-06 16:48:19 +08:00
};
2022-06-02 16:51:21 +08:00
render() {
const {
title,
visible,
save,
onCancel,
loading,
height,
2022-06-06 16:48:19 +08:00
width
2022-06-07 09:34:25 +08:00
} = this.props
2022-06-02 16:51:21 +08:00
const buttons = [
2022-10-25 17:50:10 +08:00
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@jd6baw`} type="primary" onClick={() => {save();this.setState({value:"0"})}} disabled={loading}>{i18n.button.ok()}</Button>),
2022-09-02 16:17:54 +08:00
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@jd6baw`} type="primary" onClick={() => {this.setState({value:"0"});onCancel()}} disabled={loading}>{i18n.button.cancel()}</Button>)
2022-06-02 16:51:21 +08:00
];
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}
2022-09-02 16:17:54 +08:00
onCancel={() => {this.setState({value:"0"});onCancel()}}
2022-06-02 16:51:21 +08:00
buttons={buttons}
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>
2022-06-06 16:48:19 +08:00
: this.getForm()
2022-06-02 16:51:21 +08:00
}
</WeaDialog>
)
}
}