diff --git a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js index cdbe05c9..261330e2 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js @@ -32,6 +32,7 @@ import { import { commonEnumList } from "../../../apis/ruleconfig"; import { getTaxAgentSelectList } from "../../../apis/taxAgent"; import { condition } from "./condition"; +import cs from "classnames"; import "../index.less"; const getKey = WeaTools.getKey; @@ -47,8 +48,7 @@ class StatisticalMicroSettingsSlide extends Component { dataSource: [], unitTypeList: [], salaryMonth: [], - salaryMonthDefault: "", - showMonthRange: true, + timeType: 10, statisticalItemPayload: { visible: false, id: "", dimension: "", statisticsItemId: "", isShare: false @@ -98,10 +98,10 @@ class StatisticalMicroSettingsSlide extends Component { const { form } = this.props; reportStatisticsGetSearchCondition({ id }).then(({ status, data }) => { if (status && !_.isEmpty(data)) { - const { salaryEndMonth, salaryStartMonth, ...formData } = data.data; + const { salaryEndMonth, salaryStartMonth, timeType, ...formData } = data.data; this.setState({ - salaryMonth: [salaryStartMonth || moment().startOf("year").format("YYYY-MM"), salaryEndMonth || moment().format("YYYY-MM")], - salaryMonthDefault: salaryStartMonth || moment().startOf("year").format("YYYY-MM") + timeType, + salaryMonth: [salaryStartMonth || moment().startOf("year").format("YYYY-MM"), salaryEndMonth || moment().format("YYYY-MM")] }); const fields = _.map(conditions[0].items, it => it.domkey[0]); fields.map(item => { @@ -121,17 +121,17 @@ class StatisticalMicroSettingsSlide extends Component { }); }; reportStatisticsSaveSearchCondition = () => { - const { salaryMonth, salaryMonthDefault, dataSource } = this.state; + const { salaryMonth, timeType, dataSource } = this.state; const { form, id, dimension, onClose } = this.props; const [salaryStartMonth, salaryEndMonth] = salaryMonth; const { department, employee, position, subCompany, taxAgent, ...extra } = form.getFormDatas(); const { value, valueSpan } = taxAgent; - if ((!salaryEndMonth || !salaryStartMonth) && !salaryMonthDefault) { + if (!salaryEndMonth || !salaryStartMonth) { this.refs.weaError.showError(); return; } const payload = { - dimension, id, + dimension, id, timeType, hiredate: extra["hiredate1__hiredate2"].value || [], department: _.map(department.valueObj, it => ({ id: it.id, name: it.name })), employee: _.map(employee.valueObj, it => ({ id: it.id, name: it.name })), @@ -139,14 +139,13 @@ class StatisticalMicroSettingsSlide extends Component { subCompany: _.map(subCompany.valueObj, it => ({ id: it.id, name: it.name })), taxAgent: value ? _.map(value.split(","), (it, idx) => ({ id: it, name: valueSpan.split(",")[idx] })) : [], items: dataSource, - salaryEndMonth: (salaryEndMonth || salaryMonthDefault) + "-01", - salaryStartMonth: (salaryStartMonth || salaryMonthDefault) + "-01" + salaryEndMonth: salaryEndMonth + "-01", + salaryStartMonth: salaryStartMonth + "-01" }; this.setState({ loading: true }); reportStatisticsSaveSearchCondition(payload).then(({ status, errormsg }) => { this.setState({ loading: false }); if (status) { - this.setState({ showMonthRange: true }); onClose(true); message.success(getLabel(111, "保存成功")); } else { @@ -236,8 +235,8 @@ class StatisticalMicroSettingsSlide extends Component { render() { const { - salaryMonth, salaryMonthDefault, showMonthRange, conditions, selectedRowKeys, loading, - statisticalItemPayload, dataSource, unitTypeList + salaryMonth, conditions, selectedRowKeys, loading, + statisticalItemPayload, dataSource, unitTypeList, timeType } = this.state; const { id, dimension, isShare } = this.props; const columns = [ @@ -278,9 +277,7 @@ class StatisticalMicroSettingsSlide extends Component { { - this.setState({ showMonthRange: true }, () => this.props.onClose()); - }} + onClose={() => this.props.onClose()} top={0} measureT="%" width={800} @@ -293,33 +290,10 @@ class StatisticalMicroSettingsSlide extends Component { -
-
- - this.setState({ - salaryMonth: [v, v], - salaryMonthDefault: v, - showMonthRange: !v - })}/> - -
-
- this.setState({ - showMonthRange: true, - salaryMonth: [] - })}>{getLabel(111, "指定日期范围")} - { - showMonthRange && - - this.setState({ salaryMonth: v })}/> - - } -
-
+ + this.setState({ salaryMonth: v, timeType })}/> +
{ @@ -373,6 +347,69 @@ const TitleDialog = (props) => { ; }; +const StatisticalScopePicker = (props) => { + const scopeBtns = [ + { key: 1, label: getLabel(111, "上月") }, + { key: 2, label: getLabel(111, "本月") }, + { key: 3, label: getLabel(111, "一季度") }, + { key: 4, label: getLabel(111, "二季度") }, + { key: 5, label: getLabel(111, "三季度") }, + { key: 6, label: getLabel(111, "四季度") }, + { key: 7, label: getLabel(111, "上半年") }, + { key: 8, label: getLabel(111, "下半年") }, + { key: 9, label: getLabel(111, "本年") } + ]; + const { timeType, dateRange, onChange, viewAttr, disabled = false } = props; + const [startDate, endDate] = dateRange || []; + return
+
+ { + _.map(scopeBtns.slice(0, 2), o => ( + )) + } +
+
+ { + _.map(scopeBtns.slice(2, 6), o => ( + )) + } +
+
+ { + _.map(scopeBtns.slice(6), o => ( + )) + } +
+
+ onChange([], 10)}>{getLabel(111, "指定月份")} +
+ { + return current && endDate && current.getTime() > new Date(endDate).getTime(); + }} + format="YYYY-MM" + onChange={(val) => onChange([val, endDate], timeType)} + viewAttr={viewAttr} + /> + + { + return current && startDate && current.getTime() < new Date(startDate).getTime(); + }} + format="YYYY-MM" + viewAttr={viewAttr} + onChange={(val) => onChange([startDate, val], timeType)} + /> +
+
+
; +}; export const MonthRangePicker = (props) => { const { dateRange, onChange, viewAttr, disabled = false } = props; const [startDate, endDate] = dateRange || []; @@ -398,3 +435,48 @@ export const MonthRangePicker = (props) => { /> ; }; +// 获取所属月份值 +const getSalaryMonthValue = (dateType) => { + let start = "", end = ""; + switch (dateType) { + case 1: + start = moment().add(-1, "month").startOf("month").format("YYYY-MM"); + end = moment().add(-1, "month").endOf("month").format("YYYY-MM"); + break; + case 2: + start = moment().startOf("month").format("YYYY-MM"); + end = moment().endOf("month").format("YYYY-MM"); + break; + case 3: + start = moment().year() + "-01"; + end = moment().year() + "-03"; + break; + case 4: + start = moment().year() + "-04"; + end = moment().year() + "-06"; + break; + case 5: + start = moment().year() + "-07"; + end = moment().year() + "-09"; + break; + case 6: + start = moment().year() + "-10"; + end = moment().year() + "-12"; + break; + case 7: + start = moment().startOf("year").format("YYYY-MM"); + end = moment().endOf("year").subtract(6, "month").format("YYYY-MM"); + break; + case 8: + start = moment().startOf("year").add(6, "month").format("YYYY-MM"); + end = moment().endOf("year").format("YYYY-MM"); + break; + case 9: + start = moment().startOf("year").format("YYYY-MM"); + end = moment().endOf("year").format("YYYY-MM"); + break; + default: + break; + } + return [start, end]; +}; diff --git a/pc4mobx/hrmSalary/pages/reportView/index.less b/pc4mobx/hrmSalary/pages/reportView/index.less index 721a4331..e1e94313 100644 --- a/pc4mobx/hrmSalary/pages/reportView/index.less +++ b/pc4mobx/hrmSalary/pages/reportView/index.less @@ -306,21 +306,32 @@ } .date-set-area { - width: 100%; - display: flex; - flex-direction: column; + .date-item { + margin-bottom: 5px; - .date-item:first-child { - margin-bottom: 10px; + button { + margin-right: 10px; + } } - .date-item:last-child { + .data-picker { display: flex; align-items: center; - a { + .title { + color: #5d9cec; + cursor: pointer; + font-size: 12px; margin-right: 10px; } + + .show-data-picker { + display: flex; + } + + .hide-data-picker { + display: none !important; + } } } }