193 lines
5.8 KiB
JavaScript
193 lines
5.8 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 规则配置
|
|
* Description:
|
|
* Date: 2022-09-19 18:15:32
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaFormItem, WeaSearchGroup, WeaSelect, WeaTop } from "ecCom";
|
|
import { Button, message, Modal } from "antd";
|
|
import * as API from "../../apis/ruleconfig";
|
|
import "./index.less";
|
|
|
|
class Index extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
items: [],
|
|
importItems: [],
|
|
saveParams: {
|
|
orderRule: "",
|
|
ascOrDesc: "",
|
|
rule: ""
|
|
}
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
let sysSetting = this.getSysSetting();
|
|
}
|
|
|
|
getSysSetting = async () => {
|
|
const [orderRuleEnum, ascOrDescEnum, matchEmployeeModeEnum, sysOrderRule, sysConfCodeRule] = await Promise.all([this.orderRuleEnum(), this.ascOrDescEnum(), this.matchEmployeeModeEnum(), this.sysOrderRule(), this.sysConfCodeRule()]);
|
|
if (orderRuleEnum.status && ascOrDescEnum.status && matchEmployeeModeEnum.status) {
|
|
const orderOptions = _.map(orderRuleEnum.data, it => ({ key: it.value, showname: it.defaultLabel }));
|
|
const ascOptions = _.map(ascOrDescEnum.data, it => ({ key: it.value, showname: it.defaultLabel }));
|
|
const employeeOptions = _.map(matchEmployeeModeEnum.data, it => ({ key: it.value, showname: it.defaultLabel }));
|
|
this.setState({
|
|
items: [
|
|
{
|
|
com: Select({
|
|
label: "排序字段",
|
|
onChange: this.handleChane,
|
|
value: sysOrderRule.data.orderRule,
|
|
options: orderOptions
|
|
})
|
|
},
|
|
{
|
|
com: Select({
|
|
label: "正序/倒序",
|
|
onChange: this.handleChane,
|
|
value: sysOrderRule.data.ascOrDesc,
|
|
options: ascOptions
|
|
})
|
|
}
|
|
],
|
|
importItems: [
|
|
{
|
|
com: Select({
|
|
label: "人员字段",
|
|
onChange: this.handleChane,
|
|
value: sysConfCodeRule.data,
|
|
options: employeeOptions
|
|
})
|
|
}
|
|
],
|
|
saveParams: {
|
|
...this.state.saveParams,
|
|
orderRule: sysOrderRule.data.orderRule,
|
|
ascOrDesc: sysOrderRule.data.ascOrDesc,
|
|
rule: sysConfCodeRule.data
|
|
}
|
|
});
|
|
}
|
|
};
|
|
sysOrderRule = () => {
|
|
return API.sysOrderRule();
|
|
};
|
|
sysConfCodeRule = () => {
|
|
return API.sysConfCodeRule({code:"matchEmployeeMode"});
|
|
};
|
|
orderRuleEnum = () => {
|
|
const payload = {
|
|
enumClass: "com.engine.salary.sys.enums.OrderRuleEnum"
|
|
};
|
|
return API.commonEnumList(payload);
|
|
};
|
|
ascOrDescEnum = () => {
|
|
const payload = {
|
|
enumClass: "com.engine.salary.sys.enums.AscOrDescEnum"
|
|
};
|
|
return API.commonEnumList(payload);
|
|
};
|
|
matchEmployeeModeEnum = () => {
|
|
const payload = {
|
|
enumClass: "com.engine.salary.sys.enums.MatchEmployeeModeEnum"
|
|
};
|
|
return API.commonEnumList(payload);
|
|
};
|
|
handleSave = (type) => {
|
|
const { saveParams } = this.state;
|
|
if (type === "ORDER") {
|
|
if (_.isEmpty(saveParams.orderRule) || _.isEmpty(saveParams.ascOrDesc)) {
|
|
Modal.warning({
|
|
title: "信息确认",
|
|
content: "必要信息不完整,红色*为必填项!"
|
|
});
|
|
return;
|
|
}
|
|
API.updateOrderRule(_.pick(saveParams, ["orderRule", "ascOrDesc"])).then(({ status, errormsg }) => {
|
|
if (status) {
|
|
message.success("保存成功!");
|
|
let sysSetting = this.getSysSetting();
|
|
} else {
|
|
message.error(errormsg || "保存失败!");
|
|
}
|
|
});
|
|
} else if (type === "EMPLOYEE") {
|
|
if (_.isEmpty(saveParams.rule)) {
|
|
Modal.warning({
|
|
title: "信息确认",
|
|
content: "必要信息不完整,红色*为必填项!"
|
|
});
|
|
return;
|
|
}
|
|
API.saveMatchEmployeeModeRule(_.pick(saveParams, ["rule"])).then(({ status, errormsg }) => {
|
|
if (status) {
|
|
message.success("保存成功!");
|
|
let sysSetting = this.getSysSetting();
|
|
} else {
|
|
message.error(errormsg || "保存失败!");
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
handleChane = (data) => {
|
|
const { type, selected } = data;
|
|
if (type === "排序字段") {
|
|
this.setState({
|
|
saveParams: { ...this.state.saveParams, orderRule: selected }
|
|
});
|
|
} else if (type === "正序/倒序") {
|
|
this.setState({
|
|
saveParams: { ...this.state.saveParams, ascOrDesc: selected }
|
|
});
|
|
} else if (type === "人员字段") {
|
|
this.setState({
|
|
saveParams: { ...this.state.saveParams, rule: selected }
|
|
});
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const { items, importItems } = this.state;
|
|
return (
|
|
<div className="ruleWrapper">
|
|
<WeaTop
|
|
title={<span>规则配置</span>}
|
|
icon={<i className="icon-coms-Flow-setting"/>}
|
|
iconBgcolor="#F14A2D"
|
|
buttons={[]}
|
|
/>
|
|
<WeaSearchGroup
|
|
title={
|
|
<div className="titleWrapper">
|
|
<span>排序规则</span>
|
|
<Button type="primary" onClick={() => this.handleSave("ORDER")}>保存</Button>
|
|
</div>
|
|
} showGroup center items={items}/>
|
|
<WeaSearchGroup
|
|
title={
|
|
<div className="titleWrapper">
|
|
<span>人员校验规则</span>
|
|
<Button type="primary" onClick={() => this.handleSave("EMPLOYEE")}>保存</Button>
|
|
</div>
|
|
} showGroup center items={importItems}/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Index;
|
|
|
|
const Select = payload => {
|
|
const { label, onChange, value, options = [] } = payload;
|
|
return (
|
|
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
<WeaSelect options={[{ key: "", showname: "" }, ...options]} viewAttr={3} value={value}
|
|
onChange={(selected) => onChange({ type: label, selected })}/>
|
|
</WeaFormItem>
|
|
);
|
|
};
|