1release/2.9.42311.01
This commit is contained in:
parent
a075c4a479
commit
8252cebd98
|
|
@ -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 {
|
|||
<WeaSlideModal
|
||||
className="microSlideWrapper"
|
||||
{...this.props}
|
||||
onClose={() => {
|
||||
this.setState({ showMonthRange: true }, () => this.props.onClose());
|
||||
}}
|
||||
onClose={() => this.props.onClose()}
|
||||
top={0}
|
||||
measureT="%"
|
||||
width={800}
|
||||
|
|
@ -293,33 +290,10 @@ class StatisticalMicroSettingsSlide extends Component {
|
|||
<React.Fragment>
|
||||
<WeaSearchGroup title={getLabel(111, "统计时间范围")} col={2} showGroup needTigger>
|
||||
<WeaFormItem label={getLabel(111, "薪资所属月")} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }}>
|
||||
<div className="date-set-area">
|
||||
<div className="date-item">
|
||||
<WeaError tipPosition="bottom" ref="weaError" error={getLabel(111, "此项必填")}>
|
||||
<WeaDatePicker format="YYYY-MM" viewAttr={3} value={salaryMonth[0] || salaryMonthDefault}
|
||||
disabled={isShare}
|
||||
onChange={v => this.setState({
|
||||
salaryMonth: [v, v],
|
||||
salaryMonthDefault: v,
|
||||
showMonthRange: !v
|
||||
})}/>
|
||||
</WeaError>
|
||||
</div>
|
||||
<div className="date-item">
|
||||
<a href="javascript:void(0);"
|
||||
onClick={() => this.setState({
|
||||
showMonthRange: true,
|
||||
salaryMonth: []
|
||||
})}>{getLabel(111, "指定日期范围")}</a>
|
||||
{
|
||||
showMonthRange &&
|
||||
<WeaError tipPosition="bottom" ref="weaError" error={getLabel(111, "此项必填")}>
|
||||
<MonthRangePicker viewAttr={3} dateRange={salaryMonth} disabled={isShare}
|
||||
onChange={v => this.setState({ salaryMonth: v })}/>
|
||||
</WeaError>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<WeaError tipPosition="bottom" ref="weaError" error={getLabel(111, "此项必填")}>
|
||||
<StatisticalScopePicker viewAttr={3} dateRange={salaryMonth} disabled={isShare} timeType={timeType}
|
||||
onChange={(v, timeType) => this.setState({ salaryMonth: v, timeType })}/>
|
||||
</WeaError>
|
||||
</WeaFormItem>
|
||||
</WeaSearchGroup>
|
||||
{
|
||||
|
|
@ -373,6 +347,69 @@ const TitleDialog = (props) => {
|
|||
</div>
|
||||
</div>;
|
||||
};
|
||||
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 <div className="date-set-area">
|
||||
<div className="date-item">
|
||||
{
|
||||
_.map(scopeBtns.slice(0, 2), o => (
|
||||
<Button type={timeType === o.key ? "primary" : "ghost"} disabled={disabled}
|
||||
onClick={() => onChange(getSalaryMonthValue(o.key), o.key)}>{o.label}</Button>))
|
||||
}
|
||||
</div>
|
||||
<div className="date-item">
|
||||
{
|
||||
_.map(scopeBtns.slice(2, 6), o => (
|
||||
<Button type={timeType === o.key ? "primary" : "ghost"} disabled={disabled}
|
||||
onClick={() => onChange(getSalaryMonthValue(o.key), o.key)}>{o.label}</Button>))
|
||||
}
|
||||
</div>
|
||||
<div className="date-item">
|
||||
{
|
||||
_.map(scopeBtns.slice(6), o => (
|
||||
<Button type={timeType === o.key ? "primary" : "ghost"} disabled={disabled}
|
||||
onClick={() => onChange(getSalaryMonthValue(o.key), o.key)}>{o.label}</Button>))
|
||||
}
|
||||
</div>
|
||||
<div className="data-picker">
|
||||
<span className="title" onClick={(val) => onChange([], 10)}>{getLabel(111, "指定月份")}</span>
|
||||
<div
|
||||
className={cs("rangePickerBox", { "hide-data-picker": timeType !== 10, "show-data-picker": timeType === 10 })}>
|
||||
<WeaDatePicker
|
||||
value={startDate} disabled={disabled}
|
||||
disabledDate={(current) => {
|
||||
return current && endDate && current.getTime() > new Date(endDate).getTime();
|
||||
}}
|
||||
format="YYYY-MM"
|
||||
onChange={(val) => onChange([val, endDate], timeType)}
|
||||
viewAttr={viewAttr}
|
||||
/>
|
||||
<span className="to" style={{ margin: "0 10px" }}>至</span>
|
||||
<WeaDatePicker
|
||||
value={endDate} disabled={disabled}
|
||||
disabledDate={(current) => {
|
||||
return current && startDate && current.getTime() < new Date(startDate).getTime();
|
||||
}}
|
||||
format="YYYY-MM"
|
||||
viewAttr={viewAttr}
|
||||
onChange={(val) => onChange([startDate, val], timeType)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
};
|
||||
export const MonthRangePicker = (props) => {
|
||||
const { dateRange, onChange, viewAttr, disabled = false } = props;
|
||||
const [startDate, endDate] = dateRange || [];
|
||||
|
|
@ -398,3 +435,48 @@ export const MonthRangePicker = (props) => {
|
|||
/>
|
||||
</div>;
|
||||
};
|
||||
// 获取所属月份值
|
||||
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];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue