salary-management-front/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js

235 lines
6.9 KiB
JavaScript
Raw Normal View History

2022-10-24 18:42:15 +08:00
/*
* Author: 黎永顺
* name: 新增数据采集项
* Description:
*/
import React, { Component } from "react";
import { WeaBrowser, WeaFormItem, WeaInput, WeaSearchGroup } from "ecCom";
import { getSearchs } from "../../util";
import { Select } from "../ruleConfig";
import { PickDate } from "../appConfig";
import "./index.less";
class AddItems extends Component {
constructor(props) {
super(props);
this.state = {
baseInfo: {
2022-10-31 13:55:49 +08:00
declareMonth: "",
taxAgentId: "",
taxAgentName: "",
employeeId: "",
2022-10-31 17:35:21 +08:00
employeeName: "",
2022-11-01 14:06:06 +08:00
personArea: "ORGANIZATION",
2022-10-24 18:42:15 +08:00
username: "",
idcard: ""
}
};
}
2023-02-21 18:05:54 +08:00
2023-02-20 14:28:08 +08:00
componentDidMount() {
this.setState({
baseInfo: {
...this.state.baseInfo,
2023-02-21 18:05:54 +08:00
declareMonth: this.props.editId.declareMonth || this.props.editId.taxYearMonth,
2023-02-20 14:28:08 +08:00
taxAgentId: this.props.editId.taxAgentId,
taxAgentName: this.props.editId.taxAgentName,
employeeId: this.props.editId.employeeId,
employeeName: this.props.editId.username
}
});
const fields = _.map(this.props.condition[0].items, it => {
return it.domkey[0];
});
fields.map(item => {
this.props.form.updateFields({
[item]: this.props.editId[item] || ""
});
});
}
2023-02-21 18:05:54 +08:00
2022-10-31 17:35:21 +08:00
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.editId !== this.props.editId) {
this.setState({
baseInfo: {
...this.state.baseInfo,
2023-02-21 18:05:54 +08:00
declareMonth: nextProps.editId.declareMonth || nextProps.editId.taxYearMonth,
2022-10-31 17:35:21 +08:00
taxAgentId: nextProps.editId.taxAgentId,
taxAgentName: nextProps.editId.taxAgentName,
employeeId: nextProps.editId.employeeId,
2022-11-23 15:12:19 +08:00
employeeName: nextProps.editId.username
2022-10-31 17:35:21 +08:00
}
});
2022-11-23 15:12:19 +08:00
const fields = _.map(nextProps.condition[0].items, it => {
return it.domkey[0];
});
2022-10-31 17:35:21 +08:00
fields.map(item => {
nextProps.form.updateFields({
2022-11-23 15:12:19 +08:00
[item]: nextProps.editId[item] || ""
});
});
2022-10-31 17:35:21 +08:00
}
2022-10-31 13:55:49 +08:00
}
2022-10-24 18:42:15 +08:00
render() {
2022-11-04 11:33:58 +08:00
const { taxAgentOption = [], form, condition = [], isCum, isSpecial, editId } = this.props;
2022-10-24 18:42:15 +08:00
const { baseInfo } = this.state;
2022-11-04 11:33:58 +08:00
let items = [
2022-10-24 18:42:15 +08:00
{
com: PickDate({
label: "税款所属期",
2022-10-31 17:35:21 +08:00
viewAttr: _.isEmpty(editId) ? 3 : 1,
2022-10-24 18:42:15 +08:00
labelCol: { span: 6 },
wrapperCol: { span: 18 },
format: "YYYY-MM",
2022-10-31 13:55:49 +08:00
value: baseInfo.declareMonth,
2022-10-24 18:42:15 +08:00
onChange: (data) => {
2022-10-31 13:55:49 +08:00
this.setState({ baseInfo: { ...baseInfo, declareMonth: data.date } });
2022-10-24 18:42:15 +08:00
}
})
},
{
com: Select({
label: "个税扣缴义务人",
2022-10-31 17:35:21 +08:00
viewAttr: _.isEmpty(editId) ? 3 : 1,
2022-10-24 18:42:15 +08:00
options: taxAgentOption,
2022-10-31 13:55:49 +08:00
value: baseInfo.taxAgentId,
2022-10-24 18:42:15 +08:00
onChange: (data) => {
2022-10-31 13:55:49 +08:00
this.setState({ baseInfo: { ...baseInfo, taxAgentId: data.selected, taxAgentName: data.showName } });
2022-10-24 18:42:15 +08:00
}
})
},
{
com: Browser({
label: "人员",
2022-10-31 17:35:21 +08:00
viewAttr: _.isEmpty(editId) ? 3 : 1,
value: baseInfo.employeeId,
valueSpan: baseInfo.employeeName,
2022-11-23 15:12:19 +08:00
onChange: ({ ids, names }) => {
2022-10-31 17:35:21 +08:00
this.setState({ baseInfo: { ...baseInfo, employeeId: ids, employeeName: names } });
2022-10-24 18:42:15 +08:00
}
})
}
];
const cumSituationitems = [
{
com: PickDate({
label: "税款所属期",
2022-11-01 14:06:06 +08:00
viewAttr: _.isEmpty(editId) ? 3 : 1,
2022-10-24 18:42:15 +08:00
labelCol: { span: 6 },
wrapperCol: { span: 18 },
format: "YYYY-MM",
2022-10-31 13:55:49 +08:00
value: baseInfo.declareMonth,
2022-10-24 18:42:15 +08:00
onChange: (data) => {
2022-10-31 13:55:49 +08:00
this.setState({ baseInfo: { ...baseInfo, declareMonth: data.date } });
2022-10-24 18:42:15 +08:00
}
})
},
{
com: Select({
label: "个税扣缴义务人",
2022-11-01 14:06:06 +08:00
viewAttr: _.isEmpty(editId) ? 3 : 1,
2022-10-24 18:42:15 +08:00
options: taxAgentOption,
2022-10-31 13:55:49 +08:00
value: baseInfo.taxAgentId,
2022-10-24 18:42:15 +08:00
onChange: (data) => {
2022-10-31 13:55:49 +08:00
this.setState({ baseInfo: { ...baseInfo, taxAgentId: data.selected, taxAgentName: data.showName } });
2022-10-24 18:42:15 +08:00
}
})
},
{
com: Select({
label: "人员范围",
2022-11-01 14:06:06 +08:00
viewAttr: _.isEmpty(editId) ? 3 : 1,
2022-10-24 18:42:15 +08:00
options: [
2022-10-31 17:35:21 +08:00
{ key: "ORGANIZATION", showname: "内部人员" }
2022-10-31 13:55:49 +08:00
// { key: "EXT_EMPLOYEE", showname: "非系统人员" }
],
2022-10-24 18:42:15 +08:00
value: baseInfo.personArea,
onChange: (data) => {
this.setState({ baseInfo: { ...baseInfo, personArea: data.selected } });
}
})
}
];
const insider = [{
com: Browser({
label: "人员",
2022-11-01 14:06:06 +08:00
viewAttr: _.isEmpty(editId) ? 3 : 1,
value: baseInfo.employeeId,
valueSpan: baseInfo.employeeName,
2022-11-23 15:12:19 +08:00
onChange: ({ ids, names }) => {
2022-10-31 17:35:21 +08:00
this.setState({ baseInfo: { ...baseInfo, employeeId: ids, employeeName: names } });
2022-10-24 18:42:15 +08:00
}
})
}];
const noSysPerson = [
{
com: InputCus({
label: "姓名",
viewAttr: 2,
onChange: (username) => {
this.setState({ baseInfo: { ...baseInfo, username } });
}
})
},
{
com: InputCus({
label: "身份证号码",
viewAttr: 3,
onChange: (idcard) => {
this.setState({ baseInfo: { ...baseInfo, idcard } });
}
})
}
];
2022-11-04 11:33:58 +08:00
isSpecial && items.shift();
2022-10-24 18:42:15 +08:00
return (
<div className="addItemsWrapper">
<WeaSearchGroup
2023-02-20 13:21:04 +08:00
className="baseForm"
2022-10-24 18:42:15 +08:00
title="基础信息"
2022-10-31 17:35:21 +08:00
items={!isCum ? items : baseInfo.personArea === "ORGANIZATION" ? [...cumSituationitems, ...insider] : baseInfo.personArea === "EXT_EMPLOYEE" ? [...cumSituationitems, ...noSysPerson] : cumSituationitems}
2023-02-20 13:21:04 +08:00
needTigger showGroup col={1}/>
2022-10-24 18:42:15 +08:00
{
getSearchs(form, condition, 2)
}
<Tips><span>若此员工数据已存在在同期列表中则当前数据保存后会覆盖列表数据</span></Tips>
</div>
);
}
}
export default AddItems;
export const Browser = payload => {
2022-11-23 15:12:19 +08:00
const { label, onChange, viewAttr = 3, value, valueSpan, type = 1, isSingle = true } = payload;
2022-10-24 18:42:15 +08:00
return (
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
<WeaBrowser
viewAttr={viewAttr}
2022-11-23 15:12:19 +08:00
type={type}
isSingle={isSingle}
2022-10-31 17:35:21 +08:00
value={value}
valueSpan={valueSpan}
2022-11-23 15:12:19 +08:00
onChange={(ids, names) => onChange({ ids, names })}/>
2022-10-24 18:42:15 +08:00
</WeaFormItem>
);
};
export const InputCus = payload => {
const { label, onChange, value, viewAttr = 3 } = payload;
return (
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
<WeaInput value={value} onChange={onChange} viewAttr={viewAttr}/>
</WeaFormItem>
);
};
export const Tips = payload => {
const { children } = payload;
return (
<div className="tipWrapper">
<div className="title">小提示</div>
<div className="content">{children}</div>
</div>
);
};