salary-management-front/pc4mobx/hrmSalary/pages/ledger/slideBaseForm.js

377 lines
13 KiB
JavaScript
Raw Normal View History

2022-06-02 14:48:55 +08:00
import React from "react";
2022-07-04 19:03:14 +08:00
import {Col, Row} from "antd";
import {WeaCheckbox, WeaInput, WeaSelect, WeaTextarea} from "ecCom";
2022-06-02 14:48:55 +08:00
import "./index.less";
import TipLabel from "../../components/TipLabel";
2022-07-04 19:03:14 +08:00
import {cycleTypeOption, daysOptions} from "./options";
import {inject, observer} from "mobx-react";
2022-06-02 14:48:55 +08:00
import RequiredLabelTip from "../../components/requiredLabelTip";
2022-07-04 19:03:14 +08:00
import {getAddMonthYearMonth, getCurrentMonth, getCurrentYearMonth, getSubtractMonthYearMonth} from "../../util/date";
import moment from "moment";
2022-03-15 17:50:54 +08:00
2022-06-02 14:48:55 +08:00
@inject("ledgerStore", "taxAgentStore")
2022-03-30 20:04:34 +08:00
@observer
2022-03-24 16:58:57 +08:00
export default class SlideBaseForm extends React.Component {
2022-06-02 14:48:55 +08:00
constructor(props) {
super(props);
this.state = {
name: "",
2022-06-17 16:53:27 +08:00
taxableItems: 1
2022-06-02 14:48:55 +08:00
};
}
2022-07-04 19:03:14 +08:00
2022-06-02 14:48:55 +08:00
componentWillMount() {
2022-07-04 19:03:14 +08:00
const {edit} = this.props;
const {ledgerStore: {initBaseInfoRequest}} = this.props;
2022-06-02 14:48:55 +08:00
if (edit) {
2022-07-04 19:03:14 +08:00
const {ledgerStore: {getLedgerBasicForm}} = this.props;
2022-06-02 14:48:55 +08:00
getLedgerBasicForm();
} else {
initBaseInfoRequest();
2022-03-15 17:50:54 +08:00
}
2022-06-02 14:48:55 +08:00
}
2022-03-15 17:50:54 +08:00
2022-06-02 14:48:55 +08:00
handleChange(params) {
2022-07-04 19:03:14 +08:00
const {ledgerStore: {baseInfoRequest, setBaseInfoRequest}} = this.props;
let request = {...baseInfoRequest};
2022-06-17 16:53:27 +08:00
Object.keys(params).map(key => {
2022-06-02 14:48:55 +08:00
request[key] = params[key];
});
setBaseInfoRequest(request);
}
2022-03-24 16:58:57 +08:00
2022-06-02 14:48:55 +08:00
// 获取开始日期
getStartDate(salaryCycleType, day) {
day = Number(day);
return this.getMonth(salaryCycleType) + "-" + (day < 10 ? "0" + day : day);
}
2022-04-27 19:27:23 +08:00
2022-06-02 14:48:55 +08:00
// 获取开始月份
getMonth(salaryCycleType) {
switch (salaryCycleType) {
case "1": // 上上月
return getSubtractMonthYearMonth(2);
case "2": // 上月
return getSubtractMonthYearMonth(1);
case "3": // 本月
return getCurrentYearMonth();
case "4": // 下月
return getAddMonthYearMonth(1);
2022-04-27 19:27:23 +08:00
}
2022-06-02 14:48:55 +08:00
}
2022-04-27 19:27:23 +08:00
2022-07-04 19:03:14 +08:00
initPeriodStr = (periodStrType, type, fromDay) => {
let str = "", tmpDate = null;
switch (type) {
case "1":
tmpDate = moment().subtract(2, "month");
const is_31H = moment(tmpDate, "YYYY-MM").daysInMonth() === 31;
if (fromDay == 1) {
tmpDate = moment().subtract(2, "month").endOf("month");
str = `至上上月最后一天`;
} else {
tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`))
.add(is_31H ? 30 : 29, "days");
str = `至上月${moment(tmpDate).date()}`;
}
break;
case "2":
tmpDate = moment().subtract(1, "month");
const is_31 = moment(tmpDate, "YYYY-MM").daysInMonth() === 31;
if (fromDay == 1) {
tmpDate = moment().subtract(1, "month").endOf("month");
str = `至上月最后一天`;
} else {
tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`))
.add(is_31 ? 30 : 29, "days");
str = `至本月${moment(tmpDate).date()}`;
}
break;
case "3":
tmpDate = moment().add(0, "month");
const is_31K = moment(tmpDate, "YYYY-MM").daysInMonth() === 31;
if (fromDay == 1) {
tmpDate = moment().endOf("month");
str = `至本月最后一天`;
} else {
tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`))
.add(is_31K ? 30 : 29, "days");
str = `至下月${moment(tmpDate).date()}`;
}
break;
case "4":
tmpDate = moment().add(1, "month");
const is_31L = moment(tmpDate, "YYYY-MM").daysInMonth() === 31;
if (fromDay == 1) {
tmpDate = moment().add(1, "month").endOf("month");
str = `至下月最后一天`;
} else {
tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`))
.add(is_31L ? 30 : 29, "days");
str = `至下下月${moment(tmpDate).date()}`;
}
break;
default:
break;
}
return {
[periodStrType]: str,
date: moment(tmpDate).format("YYYY-MM-DD")
};
};
2022-06-02 14:48:55 +08:00
render() {
2022-07-04 19:03:14 +08:00
const {request, ledgerStore, taxAgentStore, edit} = this.props;
const {baseInfoRequest} = ledgerStore;
const {taxAgentAdminOption} = taxAgentStore;
2022-06-02 14:48:55 +08:00
const {
2022-06-08 18:42:01 +08:00
canEdit = "true",
2022-06-02 14:48:55 +08:00
name,
taxAgentId,
taxableItems,
salaryCycleType,
salaryCycleFromDay,
taxCycleType,
attendCycleType,
attendCycleFromDay,
socialSecurityCycleType,
2022-06-17 16:53:27 +08:00
description
2022-06-02 14:48:55 +08:00
} = baseInfoRequest;
2022-07-04 19:03:14 +08:00
const salaryCycleStrObj = this.initPeriodStr("salaryCycleStr", salaryCycleType, salaryCycleFromDay);
const attendCycleStrObj = this.initPeriodStr("attendCycleStr", attendCycleType, attendCycleFromDay);
2022-06-02 14:48:55 +08:00
return (
<div className="slideBaseForm">
<Row>
<Col span={18}>
<div className="leftContentWrapper">
<Row className="formItem">
<Col span={6}>
账套名称
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaInput
disabled={canEdit !== "true"}
2022-07-04 19:03:14 +08:00
style={{width: "190px"}}
2022-06-02 14:48:55 +08:00
value={name}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({name: value});
2022-06-02 14:48:55 +08:00
}}
/>
</Col>
</Row>
<Row className="formItem">
<Col span={6}>
个税扣缴义务人
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaSelect
2022-06-17 16:53:27 +08:00
disabled={taxAgentId ? edit : false}
2022-06-02 14:48:55 +08:00
showSearch // 设置select可搜索
2022-07-04 19:03:14 +08:00
style={{width: 190}}
options={taxAgentAdminOption}
2022-06-02 14:48:55 +08:00
value={taxAgentId}
2022-06-17 16:53:27 +08:00
onChange={v => {
2022-07-04 19:03:14 +08:00
this.handleChange({taxAgentId: v});
2022-06-02 14:48:55 +08:00
}}
/>
</Col>
</Row>
<Row className="formItem">
<Col span={6}>
薪资类型
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaSelect
disabled={edit}
2022-06-02 14:48:55 +08:00
options={[
{
key: "1",
selected: true,
2022-06-17 16:53:27 +08:00
showname: "正常工资薪金所得"
},
{
key: "4",
selected: false,
showname: "劳务报酬所得"
},
2022-06-02 14:48:55 +08:00
]}
2022-07-04 19:03:14 +08:00
style={{width: "190px"}}
2022-06-02 14:48:55 +08:00
value={taxableItems}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({taxableItems: value});
2022-06-02 14:48:55 +08:00
}}
/>
</Col>
</Row>
<Row className="formItem">
<Col span={6}>
薪资周期
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaSelect
disabled={canEdit !== "true"}
options={cycleTypeOption}
2022-07-04 19:03:14 +08:00
style={{width: "90px"}}
2022-06-02 14:48:55 +08:00
value={salaryCycleType}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({salaryCycleType: value});
2022-06-02 14:48:55 +08:00
}}
/>
<WeaSelect
disabled={canEdit !== "true"}
options={daysOptions}
2022-07-04 19:03:14 +08:00
style={{width: "90px", marginLeft: "10px"}}
2022-06-02 14:48:55 +08:00
value={salaryCycleFromDay}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({salaryCycleFromDay: value});
2022-06-02 14:48:55 +08:00
}}
/>
2022-07-04 19:03:14 +08:00
<span style={{marginLeft: "10px"}}>{salaryCycleStrObj.salaryCycleStr}</span>
2022-06-02 14:48:55 +08:00
</Col>
</Row>
<Row className="formItem">
<Col span={6}>
税款所属期
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaSelect
disabled={canEdit !== "true"}
options={cycleTypeOption}
2022-07-04 19:03:14 +08:00
style={{width: "90px"}}
2022-06-02 14:48:55 +08:00
value={taxCycleType}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({taxCycleType: value});
2022-06-02 14:48:55 +08:00
}}
/>
</Col>
</Row>
<Row className="formItem">
<Col span={6}>
考勤周期
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaSelect
disabled={canEdit !== "true"}
options={cycleTypeOption}
2022-07-04 19:03:14 +08:00
style={{width: "90px"}}
2022-06-02 14:48:55 +08:00
value={attendCycleType}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({attendCycleType: value});
2022-06-02 14:48:55 +08:00
}}
/>
<WeaSelect
disabled={canEdit !== "true"}
options={daysOptions}
2022-07-04 19:03:14 +08:00
style={{width: "90px", marginLeft: "10px"}}
2022-06-02 14:48:55 +08:00
value={attendCycleFromDay}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({attendCycleFromDay: value});
2022-06-02 14:48:55 +08:00
}}
/>
2022-07-04 19:03:14 +08:00
<span style={{marginLeft: "10px"}}>{attendCycleStrObj.attendCycleStr}</span>
2022-06-02 14:48:55 +08:00
</Col>
</Row>
<Row className="formItem">
<Col span={6}>
福利台账月份
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaSelect
disabled={canEdit !== "true"}
options={cycleTypeOption}
2022-07-04 19:03:14 +08:00
style={{width: "90px"}}
2022-06-02 14:48:55 +08:00
value={socialSecurityCycleType}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({socialSecurityCycleType: value});
2022-06-02 14:48:55 +08:00
}}
/>
</Col>
</Row>
2022-03-24 16:58:57 +08:00
2022-06-02 14:48:55 +08:00
<Row className="formItem">
<Col span={6}>
核算人员范围
2022-07-04 19:03:14 +08:00
<RequiredLabelTip/>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={18}>
<WeaCheckbox
value={true}
viewAttr={1}
content="【起薪日期≤薪资周期止】且【最后发薪日期≥薪资周期起】"
2022-06-02 14:48:55 +08:00
/>
</Col>
</Row>
<Row className="formItem">
<Col span={6}>备注</Col>
<Col span={18}>
<WeaTextarea
disabled={canEdit !== "true"}
2022-07-04 19:03:14 +08:00
style={{width: "190px"}}
2022-06-02 14:48:55 +08:00
value={description}
2022-06-17 16:53:27 +08:00
onChange={value => {
2022-07-04 19:03:14 +08:00
this.handleChange({description: value});
2022-06-02 14:48:55 +08:00
}}
/>
</Col>
</Row>
2022-03-15 17:50:54 +08:00
</div>
2022-06-02 14:48:55 +08:00
</Col>
<Col span={6}>
<div className="rightContentWrapper">
<TipLabel title="月份周期说明">
<p className="greytip">
薪资所属月是
<span className="higelinered">{getCurrentYearMonth()}</span>
即核算员工
<span className="higelinered">{getCurrentMonth()}</span>
月的工资
</p>
<p className="greytip">根据您当前的选择相应的周期为</p>
<div className="tipLabel">薪资周期</div>
<p className="greytip">
<span className="higelinered">
{this.getStartDate(salaryCycleType, salaryCycleFromDay)}
</span>
<span className="higelinered">
2022-07-04 19:03:14 +08:00
{salaryCycleStrObj.date}
2022-06-02 14:48:55 +08:00
</span>
</p>
<div className="tipLabel">税款所属期</div>
<p className="greytip higelinered">
{this.getMonth(taxCycleType)}
</p>
<div className="tipLabel">考勤取值周期</div>
<p className="greytip">
<span className="higelinered">
{this.getStartDate(attendCycleType, attendCycleFromDay)}
</span>
<span className="higelinered">
2022-07-04 19:03:14 +08:00
{attendCycleStrObj.date}
2022-06-02 14:48:55 +08:00
</span>
</p>
<div className="tipLabel">福利台账月份</div>
<p className="greytip">
引用
<span className="higelinered">
{this.getMonth(socialSecurityCycleType)}
</span>
的福利台账数据
</p>
</TipLabel>
</div>
</Col>
</Row>
</div>
);
}
}