salary-management-front/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/components/editSlideContent.js

200 lines
5.7 KiB
JavaScript
Raw Normal View History

2022-06-02 14:48:55 +08:00
import React from "react";
2022-11-02 09:28:27 +08:00
import { Col, DatePicker, Row } from "antd";
2022-06-02 14:48:55 +08:00
import { inject, observer } from "mobx-react";
2022-11-02 09:28:27 +08:00
import { WeaTable } from "ecCom";
2022-06-02 14:48:55 +08:00
import "./editSlideContent.less";
import moment from "moment";
2022-03-10 13:51:13 +08:00
const { MonthPicker } = DatePicker;
2022-03-10 09:40:31 +08:00
let emptyItem = {
2022-06-02 14:48:55 +08:00
incomeLowerLimit: "0.00",
incomeUpperLimit: "0.00",
dutyFreeValue: "0.00",
dutyFreeRate: "0.00",
taxableIncomeLl: "0.00",
taxableIncomeUl: "0.00",
taxRate: "0.00",
2022-11-02 09:28:27 +08:00
taxDeduction: "0.00"
2022-06-02 14:48:55 +08:00
};
2022-03-10 09:40:31 +08:00
2022-06-02 14:48:55 +08:00
@inject("cumDeductStore", "taxAgentStore")
2022-03-10 09:40:31 +08:00
@observer
export default class EditSlideContent extends React.Component {
2022-06-02 14:48:55 +08:00
constructor(props) {
super(props);
this.state = {
taxAgentId: "",
startDate: "",
endDate: "",
editable:
2022-11-02 09:28:27 +08:00
this.props.editable === undefined ? "true" : this.props.editable
2022-06-02 14:48:55 +08:00
};
}
2022-03-10 09:40:31 +08:00
2022-06-02 14:48:55 +08:00
componentWillMount() {
// 初始化渲染页面
const {
2022-11-02 09:28:27 +08:00
taxAgentStore: { fetchTaxAgentOption }
2022-06-02 14:48:55 +08:00
} = this.props;
fetchTaxAgentOption();
}
2022-03-10 13:51:13 +08:00
2022-06-02 14:48:55 +08:00
addItem() {
const {
2022-11-02 09:28:27 +08:00
taxRateStore: { setDataSource }
2022-06-02 14:48:55 +08:00
} = this.props;
let dataSource = [...this.props.taxRateStore.dataSource];
let indexNum = 1;
if (dataSource.length > 0) {
indexNum = dataSource[dataSource.length - 1].indexNum + 1;
2022-03-10 09:40:31 +08:00
}
2022-06-02 14:48:55 +08:00
let item = { ...emptyItem };
item.indexNum = indexNum;
dataSource.push(item);
setDataSource(dataSource);
}
2022-03-10 09:40:31 +08:00
2022-06-02 14:48:55 +08:00
fetchCumDeductDetailList(param) {
const { cumDeductStore } = this.props;
const { getCumDeductDetailList, currentRecord } = cumDeductStore;
getCumDeductDetailList(currentRecord.id, param);
}
2022-03-10 13:51:13 +08:00
2022-06-02 14:48:55 +08:00
// 日期格式变化加载数据
handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) {
let declareMonth = [];
if (startDate != "" && startDate != undefined) {
declareMonth.push(startDate);
2022-03-11 10:04:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (endDate != "" && endDate != undefined) {
declareMonth.push(endDate);
2022-05-13 15:25:21 +08:00
}
2022-06-02 14:48:55 +08:00
let item = {
2022-11-02 09:28:27 +08:00
taxAgentId: taxAgentId
2022-06-02 14:48:55 +08:00
};
if (declareMonth.length != 0) {
item.declareMonth = declareMonth;
}
this.fetchCumDeductDetailList(item);
}
2022-05-13 15:25:21 +08:00
2022-06-02 14:48:55 +08:00
onSelectChange = (val) => {
const { onChangeSlideSelectKey } = this.props;
onChangeSlideSelectKey && onChangeSlideSelectKey(val);
};
2022-03-10 13:51:13 +08:00
2022-06-02 14:48:55 +08:00
render() {
const { cumDeductStore } = this.props;
const {
currentRecord,
slideColumns,
slidePageObj,
slideTableDataSource,
setSlidePageObj,
2022-11-21 17:50:06 +08:00
slideLoading,
getCumDeductDetailList
2022-06-02 14:48:55 +08:00
} = cumDeductStore;
const { startDate, endDate, taxAgentId } = this.state;
2022-11-21 17:50:06 +08:00
const declareMonth = [startDate, endDate];
2022-06-02 14:48:55 +08:00
const pagination = {
2022-11-21 17:50:06 +08:00
current: slidePageObj.current,
pageSize: slidePageObj.pageSize,
2022-06-02 14:48:55 +08:00
total: slidePageObj.total,
showTotal: (total) => `${total}`,
showSizeChanger: true,
onShowSizeChange(current, pageSize) {
setSlidePageObj({ ...slidePageObj, current, pageSize });
2022-11-21 17:50:06 +08:00
getCumDeductDetailList(currentRecord.id, {
...slidePageObj,
2022-11-25 13:32:14 +08:00
taxAgentId: currentRecord.taxAgentId,
2022-11-21 17:50:06 +08:00
current,
pageSize,
declareMonth: _.filter(declareMonth, item => item)
});
2022-06-02 14:48:55 +08:00
},
onChange(current) {
setSlidePageObj({
...slidePageObj,
current,
2022-11-02 09:28:27 +08:00
pageSize: slidePageObj.pageSize
2022-06-02 14:48:55 +08:00
});
2022-11-21 17:50:06 +08:00
getCumDeductDetailList(currentRecord.id, {
...slidePageObj, current,
2022-11-25 13:32:14 +08:00
taxAgentId: currentRecord.taxAgentId,
2022-11-21 17:50:06 +08:00
declareMonth: _.filter(declareMonth, item => item)
});
2022-06-02 14:48:55 +08:00
}
2022-11-02 09:28:27 +08:00
};
const newColumns = _.map([...slideColumns], (item) => ({ ...item }));
2022-06-02 14:48:55 +08:00
const rowSelection = {
selectedRowKeys: this.props.slideSelectedKey,
2022-11-02 09:28:27 +08:00
onChange: this.onSelectChange
2022-06-02 14:48:55 +08:00
};
return (
<div className="cumDeductSlide">
<Row className="topLabelBar">
<Col span={4}>
<span className="username">{currentRecord.username}</span>
</Col>
<Col span={12}>
2022-10-31 17:35:21 +08:00
<span className="formLabel">税款所属期</span>
2022-06-02 14:48:55 +08:00
<div className="weaRangePickerWrapper">
<div className="monthPickerWrapper">
<MonthPicker
width={100}
value={startDate}
onChange={(v) => {
let startDate = "";
if (v != "" && v != undefined) {
startDate = moment(v).format("YYYY-MM");
}
this.setState({ startDate });
this.handleFetchCumDeductDetailList(
startDate,
endDate,
2022-11-25 13:32:14 +08:00
currentRecord.taxAgentId
2022-06-02 14:48:55 +08:00
);
}}
/>
</div>
<span className="betweenLable"></span>
<div className="monthPickerWrapper">
<MonthPicker
width={100}
value={endDate}
onChange={(v) => {
let endDate = "";
if (v != "" && v != undefined) {
endDate = moment(v).format("YYYY-MM");
}
this.setState({ endDate });
this.handleFetchCumDeductDetailList(
startDate,
endDate,
taxAgentId
);
}}
/>
</div>
</div>
</Col>
</Row>
<div>
<WeaTable
rowKey="id"
rowSelection={rowSelection}
columns={newColumns}
dataSource={slideTableDataSource}
pagination={pagination}
loading={slideLoading}
scroll={{ x: 900 }}
/>
</div>
</div>
);
}
}