diff --git a/pc4mobx/hrmSalary/pages/mySalaryMobile/components/mobileDatePicker/index.js b/pc4mobx/hrmSalary/pages/mySalaryMobile/components/mobileDatePicker/index.js
index a17b065e..dde59609 100644
--- a/pc4mobx/hrmSalary/pages/mySalaryMobile/components/mobileDatePicker/index.js
+++ b/pc4mobx/hrmSalary/pages/mySalaryMobile/components/mobileDatePicker/index.js
@@ -16,60 +16,49 @@ class Index extends Component {
constructor(props) {
super(props);
this.state = {
- yearList: {}, monthList: {}
+ visible: false,
+ salaryYearMonth: { year: "", month: "" }
};
}
componentWillReceiveProps(nextProps, nextContext) {
- if (nextProps.visible !== this.props.visible && nextProps.visible) {
- this.setState({
- yearList: {
- list: YearFn(Number(moment().subtract(100, "year").format("YYYY")), Number(moment().add(100, "year").format("YYYY"))),
- defaultValue: nextProps[nextProps.type].defaultValueYear,
- displayValue(name) {
- return name;
- }
- },
- monthList: {
- list: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
- defaultValue: nextProps.type === "salaryStart" ? "0" : nextProps[nextProps.type].defaultValueMonth,
- displayValue(name) {
- return name;
- }
- }
- }, () => {
- console.log(this.state);
- });
- }
+ const { value } = nextProps;
+ const [year, month] = value.split("-");
+ this.setState({
+ salaryYearMonth: { year, month }
+ });
}
handleChangeYear = (year) => {
- this.setState({
- yearList: {
- ...this.state.yearList,
- defaultValue: year
- }
- }, () => this.props.onChange(this.props.type, "defaultValueYear", year));
+ this.setState({ salaryYearMonth: { ...this.state.salaryYearMonth, year } });
};
handleChangeMonth = (month) => {
- this.setState({
- monthList: {
- ...this.state.monthList,
- defaultValue: ""
- }
- }, () => this.props.onChange(this.props.type, "defaultValueMonth", month));
+
+ this.setState({ salaryYearMonth: { ...this.state.salaryYearMonth, month: parseInt(month).toString() } });
+ };
+ handleCancel = () => {
+ this.setState({ visible: false });
+ };
+ handleConfirm = () => {
+ const { year, month } = this.state.salaryYearMonth;
+ this.setState({ visible: false }, () => {
+ this.props.onChange(moment(new Date(`${year}- ${month}`)).format("YYYY-MM"));
+ });
};
render() {
- const { yearList, monthList } = this.state;
+ const { value } = this.props;
+ const { visible } = this.state;
+ const [year, month] = value.split("-");
return (
-
+ this.setState({ visible: true })}>{value}
+
{
this.setState({ loading: false });
if (status) {
- const { datas: dataSource, pageInfo } = data;
- const { pageNum: current, pageSize, total } = pageInfo;
+ const { datas: dataSource, pageInfo: pageResult } = data;
+ const { pageNum: current, pageSize, total } = pageResult;
this.setState({
dataSource, pageInfo: { ...pageInfo, current, pageSize, total }
});
@@ -75,43 +61,17 @@ class Index extends Component {
const div = document.getElementById("mySalaryMobile");
if ((div.scrollHeight - div.scrollTop) === div.clientHeight) handler();
};
- handleChange = (type, key, val) => {
+ handleChange = (type, val) => {
+ const { salaryYearMonth } = this.state;
+ const [salaryStartYearMonth, salaryEndYearMonth] = salaryYearMonth;
this.setState({
- [type]: {
- ...this.state[type],
- [type]: {
- ...this.state[type][type],
- [key]: val
- }
- }
- });
- };
- handleCancel = () => {
- this.setState({
- salaryStart: {
- visible: false, type: "",
- salaryStart: {
- defaultValueYear: moment().year().toString(),
- defaultValueMonth: (moment().startOf("year").month() + 1).toString()
- }
- },
- salaryEnd: {
- visible: false,
- salaryEnd: {
- defaultValueYear: moment().year().toString(),
- defaultValueMonth: (moment().month() + 1).toString()
- }
- }
- });
- };
- handleConfirm = () => {
- this.handleCancel();
+ salaryYearMonth: type === "salaryStartYearMonth" ? [val, salaryEndYearMonth] : [salaryStartYearMonth, val]
+ }, () => this.getMySalaryBillList());
};
render() {
- const { salaryStart, salaryEnd, salaryYearMonth, dataSource } = this.state;
+ const { salaryYearMonth, dataSource } = this.state;
const [salaryStartYearMonth, salaryEndYearMonth] = salaryYearMonth;
- const mobilePorps = { ...salaryStart, ...salaryEnd, visible: salaryEnd.visible || salaryStart.visible };
return (
@@ -121,21 +81,12 @@ class Index extends Component {
/>
- this.setState({
- salaryStart: { ...salaryStart, visible: true, type: "salaryStart" }
- })}>{salaryStartYearMonth}
+ this.handleChange("salaryStartYearMonth", v)}/>
{getLabel(15322, "至")}
- this.setState({
- salaryEnd: { ...salaryEnd, visible: true, type: "salaryEnd" }
- })}>{salaryEndYearMonth}
+ this.handleChange("salaryEndYearMonth", v)}/>
-
);
}
diff --git a/pc4mobx/hrmSalary/pages/mySalaryMobile/index.less b/pc4mobx/hrmSalary/pages/mySalaryMobile/index.less
index 259f5e9e..16ae3726 100644
--- a/pc4mobx/hrmSalary/pages/mySalaryMobile/index.less
+++ b/pc4mobx/hrmSalary/pages/mySalaryMobile/index.less
@@ -26,10 +26,6 @@
position: fixed;
top: 47px;
- .date {
- color: #333;
- }
-
.to {
margin: 0 10px;
color: #999;
@@ -37,6 +33,10 @@
}
.ui-picker-address {
+ .date {
+ color: #333;
+ }
+
.ui-popup-title {
font-size: 12px !important;
}