365 lines
12 KiB
JavaScript
365 lines
12 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 规则配置
|
|
* Description:
|
|
* Date: 2022-09-19 18:15:32
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaFormItem, WeaNewScroll, WeaSearchGroup, WeaSelect, WeaTop } from "ecCom";
|
|
import { CheckBox } from "../appConfig";
|
|
import { Button, message, Modal } from "antd";
|
|
import * as API from "../../apis/ruleconfig";
|
|
import "./index.less";
|
|
import ProgressModal from "../../components/progressModal";
|
|
|
|
class Index extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
items: [],
|
|
importItems: [],
|
|
enctryItems: [],
|
|
declareItems: [],
|
|
loading: {
|
|
order: false,
|
|
employee: false,
|
|
encry: false,
|
|
declare: false
|
|
},
|
|
saveParams: {
|
|
orderRule: "",
|
|
ascOrDesc: "",
|
|
rule: "",
|
|
enctry: "",
|
|
operateTaxDeclaration: ""
|
|
},
|
|
progressVisible: false,
|
|
progress: 50
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
let sysSetting = this.getSysSetting();
|
|
}
|
|
|
|
getSysSetting = async () => {
|
|
const [orderRuleEnum, ascOrDescEnum, matchEmployeeModeEnum, sysOrderRule, sysConfCodeRule, queryAppsetting] = await Promise.all([this.orderRuleEnum(), this.ascOrDescEnum(), this.matchEmployeeModeEnum(), this.sysOrderRule(), this.sysConfCodeRule(), this.queryAppsetting()]);
|
|
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
|
|
})
|
|
}
|
|
],
|
|
enctryItems: [
|
|
{
|
|
com: CheckBox({
|
|
label: "加密设置",
|
|
value: queryAppsetting.data.isOpenEncrypt,
|
|
onChange: (data) => this.handleChane({ type: "加密设置", selected: data })
|
|
})
|
|
}
|
|
],
|
|
declareItems: [
|
|
{
|
|
com: CheckBox({
|
|
label: "个税申报",
|
|
value: queryAppsetting.data.isOpenTaxDeclaration,
|
|
onChange: (data) => this.handleChane({ type: "个税申报", selected: data })
|
|
})
|
|
}
|
|
],
|
|
saveParams: {
|
|
...this.state.saveParams,
|
|
orderRule: sysOrderRule.data.orderRule,
|
|
ascOrDesc: sysOrderRule.data.ascOrDesc,
|
|
rule: sysConfCodeRule.data,
|
|
enctry: queryAppsetting.data.isOpenEncrypt,
|
|
operateTaxDeclaration: queryAppsetting.data.isOpenTaxDeclaration
|
|
}
|
|
});
|
|
}
|
|
};
|
|
sysOrderRule = () => {
|
|
return API.sysOrderRule();
|
|
};
|
|
sysConfCodeRule = () => {
|
|
return API.sysConfCodeRule({ code: "matchEmployeeMode" });
|
|
};
|
|
queryAppsetting = () => {
|
|
return API.queryAppsetting();
|
|
};
|
|
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;
|
|
}
|
|
this.setState({ loading: { ...this.state.loading, order: true } });
|
|
API.updateOrderRule(_.pick(saveParams, ["orderRule", "ascOrDesc"])).then(({ status, errormsg }) => {
|
|
this.setState({ loading: { ...this.state.loading, order: false } });
|
|
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;
|
|
}
|
|
this.setState({ loading: { ...this.state.loading, employee: true } });
|
|
API.saveMatchEmployeeModeRule(_.pick(saveParams, ["rule"])).then(({ status, errormsg }) => {
|
|
this.setState({ loading: { ...this.state.loading, employee: false } });
|
|
if (status) {
|
|
message.success("保存成功!");
|
|
let sysSetting = this.getSysSetting();
|
|
} else {
|
|
message.error(errormsg || "保存失败!");
|
|
}
|
|
});
|
|
} else if (type === "ENCRYTION") {
|
|
Modal.confirm({
|
|
title: "信息确认",
|
|
content: "开启/关闭加密前请做好数据库备份!!!逆向解密会花费几分钟时间,请耐心等待!!!",
|
|
onOk: () => {
|
|
this.setState({ loading: { ...this.state.loading, encry: true } });
|
|
API.saveEncryptSetting({ isOpenEncrypt: saveParams.enctry }).then(({ data, status, errormsg }) => {
|
|
this.setState({ loading: { ...this.state.loading, encry: false } });
|
|
if (status) {
|
|
const { isSuccess, progressId, msg } = data;
|
|
if (!isSuccess) {
|
|
message.error(errormsg || msg || "保存失败!");
|
|
return;
|
|
}
|
|
this.setState({
|
|
progressVisible: true,
|
|
progress: 0
|
|
}, () => {
|
|
let number = 1;
|
|
this.timer && clearInterval(this.timer);
|
|
this.timer = setInterval(() => {
|
|
API.getEncryptProgress({ progressId }).then(({ status, data, errormsg }) => {
|
|
const { progress_statue } = data;
|
|
if (progress_statue === "success" && this.timer) {
|
|
clearInterval(this.timer);
|
|
this.timer = null;
|
|
number = 1;
|
|
this.setState({
|
|
progress: 100
|
|
}, () => {
|
|
this.setState({
|
|
progressVisible: false
|
|
});
|
|
});
|
|
message.success("保存成功");
|
|
} else if (progress_statue === "in_progress" && this.timer) {
|
|
if (this.state.progress >= 90) {
|
|
this.setState({
|
|
progress: this.state.progress + (0.001 * this.state.progress)
|
|
});
|
|
} else {
|
|
this.setState({
|
|
progress: 10 * number
|
|
}, () => number++);
|
|
}
|
|
} else if (!status || (progress_statue === "fail" && this.timer)) {
|
|
clearInterval(this.timer);
|
|
this.timer = null;
|
|
number = 1;
|
|
this.setState({
|
|
progress: 100
|
|
}, () => {
|
|
this.setState({
|
|
progressVisible: false
|
|
});
|
|
});
|
|
message.error(errormsg || "保存失败!");
|
|
}
|
|
});
|
|
}, 1000);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
onCancel: () => {
|
|
}
|
|
});
|
|
} else if (type === "DECLARATION") {
|
|
this.setState({ loading: { ...this.state.loading, declare: true } });
|
|
API.operateTaxDeclarationFunction(_.pick(saveParams, ["operateTaxDeclaration"])).then(({ status, errormsg }) => {
|
|
this.setState({ loading: { ...this.state.loading, declare: false } });
|
|
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 }
|
|
});
|
|
} else if (type === "加密设置") {
|
|
this.setState({
|
|
saveParams: { ...this.state.saveParams, enctry: selected }
|
|
});
|
|
} else if (type === "个税申报") {
|
|
this.setState({
|
|
saveParams: { ...this.state.saveParams, operateTaxDeclaration: selected }
|
|
});
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const { items, importItems, enctryItems, declareItems, loading } = this.state;
|
|
return (
|
|
<div className="ruleWrapper">
|
|
<WeaTop
|
|
title={<span>规则配置</span>}
|
|
icon={<i className="icon-coms-Flow-setting"/>}
|
|
iconBgcolor="#F14A2D"
|
|
buttons={[]}
|
|
/>
|
|
<WeaNewScroll height={`calc(100% - 46px)`}>
|
|
<WeaSearchGroup
|
|
title={
|
|
<div className="titleWrapper">
|
|
<span>排序规则</span>
|
|
<Button type="primary" onClick={() => this.handleSave("ORDER")} loading={loading.order}>保存</Button>
|
|
</div>
|
|
} showGroup center items={items}/>
|
|
<WeaSearchGroup
|
|
title={
|
|
<div className="titleWrapper">
|
|
<span>人员校验规则</span>
|
|
<Button type="primary" onClick={() => this.handleSave("EMPLOYEE")}
|
|
loading={loading.employee}>保存</Button>
|
|
</div>
|
|
} showGroup center items={importItems}/>
|
|
<WeaSearchGroup
|
|
title={
|
|
<div className="titleWrapper">
|
|
<span>加密规则</span>
|
|
<Button type="primary" onClick={() => this.handleSave("ENCRYTION")}
|
|
loading={loading.encry}>保存</Button>
|
|
</div>
|
|
} showGroup center items={enctryItems}/>
|
|
<WeaSearchGroup
|
|
title={
|
|
<div className="titleWrapper">
|
|
<span>报税规则</span>
|
|
<Button type="primary" onClick={() => this.handleSave("DECLARATION")}
|
|
loading={loading.declare}>保存</Button>
|
|
</div>
|
|
} showGroup center items={declareItems}/>
|
|
{
|
|
this.state.progressVisible &&
|
|
<ProgressModal
|
|
title="加密/解密中..."
|
|
visible={this.state.progressVisible}
|
|
onCancel={() => {
|
|
this.setState({ progressVisible: false, progress: 0 });
|
|
}}
|
|
progress={this.state.progress}
|
|
/>
|
|
}
|
|
</WeaNewScroll>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Index;
|
|
|
|
export const Select = payload => {
|
|
const {
|
|
label,
|
|
onChange,
|
|
value,
|
|
options = [],
|
|
viewAttr = 3,
|
|
detailtype = 1,
|
|
multiple = false,
|
|
showSearch = false
|
|
} = payload;
|
|
return (
|
|
<WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
<WeaSelect options={multiple ? options : [{ key: "", showname: "" }, ...options]} viewAttr={viewAttr}
|
|
detailtype={detailtype}
|
|
value={value}
|
|
multiple={multiple}
|
|
showSearch={showSearch}
|
|
optionFilterProp="children"
|
|
style={multiple ? { width: 600 } : {}}
|
|
onChange={(selected, showName) => onChange({ type: label, selected, showName })}/>
|
|
</WeaFormItem>
|
|
);
|
|
};
|