薪资项目管理页面重构
This commit is contained in:
parent
b2acfd61be
commit
f61c4bfbb0
|
|
@ -85,7 +85,7 @@ export const salaryItemFields = [
|
|||
key: 'taxAgentIds',
|
||||
label: '可见性范围',
|
||||
type: 'SELECT',
|
||||
viewAttr: 2,
|
||||
viewAttr: 3,
|
||||
tip: ''
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,23 +9,69 @@ import { WeaCheckbox, WeaFormItem, WeaInput, WeaSearchGroup, WeaSelect, WeaTexta
|
|||
import { salaryItemFields, valTakeOptions } from "./columns";
|
||||
|
||||
class SalaryItemForm extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
salaryItemFieldsList: salaryItemFields
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { salaryItemFieldsList } = this.state;
|
||||
const { request, isAdd } = this.props;
|
||||
const { systemType, sharedType, valueType } = request;
|
||||
console.log(this.state.salaryItemFieldsList, this.props);
|
||||
this.setState({
|
||||
salaryItemFieldsList: _.map(salaryItemFieldsList, item => {
|
||||
const { key } = item;
|
||||
switch (key) {
|
||||
case "sharedType":
|
||||
return { ...item, display: systemType.toString() === "0" || isAdd };
|
||||
case "taxAgentIds":
|
||||
return { ...item, display: sharedType === "1" };
|
||||
case "formulaContent":
|
||||
return { ...item, display: valueType === "2" || valueType === "3" };
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return { ...item };
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { userStatusList } = this.props;
|
||||
const { userStatusList, request } = this.props;
|
||||
const { salaryItemFieldsList } = this.state;
|
||||
return (
|
||||
<WeaSearchGroup showGroup needTigger={false}>
|
||||
{
|
||||
_.map(salaryItemFields, item => {
|
||||
const { key, label, type, viewAttr, tip, options } = item;
|
||||
return <WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 12 }}>
|
||||
_.map(salaryItemFieldsList, item => {
|
||||
const { key, label, type, viewAttr, tip, options, display = true } = item;
|
||||
const value = request[key] ? request[key].toString() : "";
|
||||
return <React.Fragment>
|
||||
{
|
||||
type === "INPUT" ? <WeaInput viewAttr={viewAttr}/> :
|
||||
type === "SWITCH" ? <WeaCheckbox helpfulTip={tip} display="switch" viewAttr={viewAttr}/> :
|
||||
type === "SELECT" ?
|
||||
<WeaSelect options={key !== "sharedType" ? options : userStatusList} viewAttr={viewAttr}/> :
|
||||
type === "RADIO" ? <WeaSelect options={valTakeOptions} detailtype={3} viewAttr={viewAttr}/> :
|
||||
type === "TEXTAREA" ? <WeaTextarea viewAttr={viewAttr} minRows={3}/> : null
|
||||
(type === "INPUT" && display) ?
|
||||
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 12 }}>
|
||||
<WeaInput viewAttr={viewAttr} value={value}/></WeaFormItem> :
|
||||
(type === "SWITCH" && display) ?
|
||||
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 12 }}>
|
||||
<WeaCheckbox value={value} helpfulTip={tip} display="switch" viewAttr={viewAttr}/>
|
||||
</WeaFormItem> :
|
||||
(type === "SELECT" && display) ?
|
||||
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 12 }}>
|
||||
<WeaSelect value={value} options={key !== "sharedType" ? options : userStatusList}
|
||||
viewAttr={viewAttr}/>
|
||||
</WeaFormItem> :
|
||||
(type === "RADIO" && display) ?
|
||||
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 12 }}>
|
||||
<WeaSelect value={value} options={valTakeOptions} detailtype={3} viewAttr={viewAttr}/>
|
||||
</WeaFormItem> :
|
||||
(type === "TEXTAREA" && display) ?
|
||||
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 12 }}><WeaTextarea
|
||||
value={value} viewAttr={viewAttr} minRows={3}/>
|
||||
</WeaFormItem> : null
|
||||
}
|
||||
</WeaFormItem>;
|
||||
</React.Fragment>;
|
||||
})
|
||||
}
|
||||
</WeaSearchGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue