diff --git a/pc4mobx/hrmSalary/apis/ruleconfig.js b/pc4mobx/hrmSalary/apis/ruleconfig.js index b0639647..7ff084ce 100644 --- a/pc4mobx/hrmSalary/apis/ruleconfig.js +++ b/pc4mobx/hrmSalary/apis/ruleconfig.js @@ -1,53 +1,57 @@ -import { WeaTools } from 'ecCom'; -import { postFetch } from '../util/request'; +import { WeaTools } from "ecCom"; +import { postFetch } from "../util/request"; //通用字典表 {enumClass:""} export const commonEnumList = (params) => { - return WeaTools.callApi('/api/bs/hrmsalary/common/enum/list', 'GET', params); -} + return WeaTools.callApi("/api/bs/hrmsalary/common/enum/list", "GET", params); +}; export const sysOrderRule = params => { - return WeaTools.callApi('/api/bs/hrmsalary/sys/orderRule', 'GET', params); -} + return WeaTools.callApi("/api/bs/hrmsalary/sys/orderRule", "GET", params); +}; //保存排序规则 export const updateOrderRule = (params) => { - return postFetch('/api/bs/hrmsalary/sys/updateOrderRule', params); -} + return postFetch("/api/bs/hrmsalary/sys/updateOrderRule", params); +}; //导入规则详情信息 export const sysConfCodeRule = params => { - return WeaTools.callApi('/api/bs/hrmsalary/sys/conf/code', 'GET', params); -} + return WeaTools.callApi("/api/bs/hrmsalary/sys/conf/code", "GET", params); +}; //保存导入规则 export const saveMatchEmployeeModeRule = (params) => { - return postFetch('/api/bs/hrmsalary/sys/saveMatchEmployeeModeRule', params); -} + return postFetch("/api/bs/hrmsalary/sys/saveMatchEmployeeModeRule", params); +}; //应用配置查询 export const queryAppsetting = (params) => { - return WeaTools.callApi('/api/bs/hrmsalary/sys/app/setting', 'GET', params); -} + return WeaTools.callApi("/api/bs/hrmsalary/sys/app/setting", "GET", params); +}; //加密配置保存 export const saveEncryptSetting = (params) => { - return postFetch('/api/bs/hrmsalary/sys/app/setting/saveEncryptSetting', params); -} + return postFetch("/api/bs/hrmsalary/sys/app/setting/saveEncryptSetting", params); +}; //加密配置保存 export const appSettingSave = (params) => { - return postFetch('/api/bs/hrmsalary/sys/app/setting/save', params); -} + return postFetch("/api/bs/hrmsalary/sys/app/setting/save", params); +}; //获取加密进度条 export const getEncryptProgress = params => { - return WeaTools.callApi('/api/bs/hrmsalary/sys/app/getEncryptProgress', 'GET', params); -} + return WeaTools.callApi("/api/bs/hrmsalary/sys/app/getEncryptProgress", "GET", params); +}; //保存报税规则 export const operateTaxDeclarationFunction = (params) => { - return postFetch('/api/bs/hrmsalary/sys/operateTaxDeclarationFunction', params); -} + return postFetch("/api/bs/hrmsalary/sys/operateTaxDeclarationFunction", params); +}; +//保存匹配规则 +export const saveSalaryAcctEmployeeRule = (params) => { + return postFetch("/api/bs/hrmsalary/sys/saveSalaryAcctEmployeeRule", params); +}; //保存薪酬统计报表 export const reportStatisticsReportSave = (params) => { - return postFetch('/api/bs/hrmsalary/report/statistics/report/save', params); -} + return postFetch("/api/bs/hrmsalary/report/statistics/report/save", params); +}; //薪酬统计维度下拉列表 export const reportGetForm = params => { - return WeaTools.callApi('/api/bs/hrmsalary/report/statistics/report/getForm', 'GET', params); -} + return WeaTools.callApi("/api/bs/hrmsalary/report/statistics/report/getForm", "GET", params); +}; diff --git a/pc4mobx/hrmSalary/pages/ruleConfig/index.js b/pc4mobx/hrmSalary/pages/ruleConfig/index.js index 16c8b786..675273ea 100644 --- a/pc4mobx/hrmSalary/pages/ruleConfig/index.js +++ b/pc4mobx/hrmSalary/pages/ruleConfig/index.js @@ -5,8 +5,7 @@ * Date: 2022-09-19 18:15:32 */ import React, { Component } from "react"; -import { WeaFormItem, WeaLocaleProvider, WeaNewScroll, WeaSearchGroup, WeaSelect, WeaTop } from "ecCom"; -import { CheckBox } from "../appConfig"; +import { WeaCheckbox, WeaFormItem, WeaLocaleProvider, WeaNewScroll, WeaSearchGroup, WeaSelect, WeaTop } from "ecCom"; import { message, Modal } from "antd"; import * as API from "../../apis/ruleconfig"; import "./index.less"; @@ -14,100 +13,59 @@ import ProgressModal from "../../components/progressModal"; const { getLabel } = WeaLocaleProvider; -class Index extends Component { +export default class Index extends Component { constructor(props) { super(props); this.state = { items: [], - importItems: [], - enctryItems: [], - declareItems: [], - loading: { - order: false, - employee: false, - encry: false, - declare: false - }, + matchRuleOptions: [], orderOptions: [], ascOptions: [], employeeOptions: [], saveParams: { orderRule: "", ascOrDesc: "", rule: "", enctry: "", - operateTaxDeclaration: "" + operateTaxDeclaration: "", + matchRule: "" }, + showEncryptOperationButton: "", progressVisible: false, progress: 50 }; } - componentDidMount() { - let sysSetting = this.getSysSetting(); + async componentDidMount() { + const { saveParams } = this.state; + const [ + matchRuleEnum, orderRuleEnum, ascOrDescEnum, matchEmployeeModeEnum, + orderRules, codeRule, appSettings + ] = await Promise.all([ + this.matchRuleEnum(), this.orderRuleEnum(), this.ascOrDescEnum(), this.matchEmployeeModeEnum(), + this.sysOrderRule(), this.sysConfCodeRule(), this.queryAppsetting() + ]); + const matchRuleOptions = _.map(matchRuleEnum.data, it => ({ key: it.value, showname: it.defaultLabel })); + 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 })); + const { data: { ascOrDesc, orderRule } } = orderRules; + const { data: rule } = codeRule; + const { + data: { + showEncryptOperationButton, + isOpenEncrypt: enctry, + isOpenTaxDeclaration: operateTaxDeclaration, + salaryAcctEmployeeRule: matchRule + } + } = appSettings; + this.setState({ + matchRuleOptions, orderOptions, ascOptions, employeeOptions, + showEncryptOperationButton, + saveParams: { + ...saveParams, + ascOrDesc, orderRule, rule, enctry, operateTaxDeclaration, matchRule + } + }); } - 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 || orderOptions[0].value, - options: orderOptions - }) - }, - { - com: Select({ - label: "正序/倒序", - onChange: this.handleChane, - value: sysOrderRule.data.ascOrDesc || ascOptions[0].value, - options: ascOptions - }) - } - ], - importItems: [ - { - com: Select({ - label: "人员字段", - onChange: this.handleChane, - value: sysConfCodeRule.data || employeeOptions[0].value, - options: employeeOptions - }) - } - ], - enctryItems: queryAppsetting.data.showEncryptOperationButton === "true" ? [ - { - 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 || orderOptions[0].value, - ascOrDesc: sysOrderRule.data.ascOrDesc || ascOptions[0].value, - rule: sysConfCodeRule.data || employeeOptions[0].value, - enctry: queryAppsetting.data.isOpenEncrypt, - operateTaxDeclaration: queryAppsetting.data.isOpenTaxDeclaration - } - }); - } - }; sysOrderRule = () => { return API.sysOrderRule(); }; @@ -117,6 +75,12 @@ class Index extends Component { queryAppsetting = () => { return API.queryAppsetting(); }; + matchRuleEnum = () => { + const payload = { + enumClass: "com.engine.salary.sys.enums.SalaryAcctEmployeeRuleEnum" + }; + return API.commonEnumList(payload); + }; orderRuleEnum = () => { const payload = { enumClass: "com.engine.salary.sys.enums.OrderRuleEnum" @@ -135,345 +99,207 @@ class Index extends Component { }; 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 || "保存失败!"); - // } - // }); - } + updateOrderRule = () => { + API.updateOrderRule(_.pick(this.state.saveParams, ["orderRule", "ascOrDesc"])) + .then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(22619, "保存成功!")); + } else { + message.error(errormsg || getLabel(22620, "保存失败!")); + } + }); + }; + saveMatchEmployeeModeRule = () => { + API.saveMatchEmployeeModeRule(_.pick(this.state.saveParams, ["rule"])).then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(22619, "保存成功!")); + } else { + message.error(errormsg || getLabel(22620, "保存失败!")); + } + }); + }; + saveSalaryAcctEmployeeRule = () => { + API.saveSalaryAcctEmployeeRule({ rule: this.state.saveParams.matchRule }) + .then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(22619, "保存成功!")); + } else { + message.error(errormsg || getLabel(22620, "保存失败!")); + } + }); + }; + operateTaxDeclarationFunction = () => { + API.operateTaxDeclarationFunction(_.pick(this.state.saveParams, ["operateTaxDeclaration"])) + .then(({ status, errormsg }) => { + if (status) { + message.success(getLabel(22619, "保存成功!")); + } else { + message.error(errormsg || getLabel(22620, "保存失败!")); + } + }); + }; + saveEncryptSetting = () => { + API.saveEncryptSetting({ isOpenEncrypt: this.state.saveParams.enctry }) + .then(({ data, status, errormsg }) => { + if (status) { + const { isSuccess, progressId, msg } = data; + if (!isSuccess) { + message.error(errormsg || msg || getLabel(22620, "保存失败!")); + 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(getLabel(22619, "保存成功!")); + } 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 || getLabel(22620, "保存失败!")); + } + }); + }, 1000); + }); + } + }); }; - handleChane = (data) => { - const { type, selected } = data; - if (type === "排序字段") { - this.setState({ - saveParams: { ...this.state.saveParams, orderRule: selected } - }, () => { - Modal.confirm({ - title: getLabel(131329, "信息确认"), - content: getLabel(111, "确认要保存吗?"), - onOk: () => { - API.updateOrderRule(_.pick(this.state.saveParams, ["orderRule", "ascOrDesc"])) - .then(({ status, errormsg }) => { - if (status) { - message.success(getLabel(22619, "保存成功!")); - let sysSetting = this.getSysSetting(); - } else { - message.error(errormsg || getLabel(22620, "保存失败!")); - } - }); - }, - onCancel: () => { + handleChange = (key, val) => { + const { saveParams } = this.state; + Modal.confirm({ + title: getLabel(131329, "信息确认"), + content: getLabel(111, "确认要保存吗?"), + onOk: () => { + this.setState({ + saveParams: { + ...saveParams, + [key]: val + } + }, () => { + switch (key) { + case "orderRule": + case "ascOrDesc": + this.updateOrderRule(); + break; + case "rule": + this.saveMatchEmployeeModeRule(); + break; + case "matchRule": + this.saveSalaryAcctEmployeeRule(); + break; + case "operateTaxDeclaration": + this.operateTaxDeclarationFunction(); + break; + case "enctry": + this.saveEncryptSetting(); + break; + default: + break; } }); - }); - } else if (type === "正序/倒序") { - this.setState({ - saveParams: { ...this.state.saveParams, ascOrDesc: selected } - }, () => { - Modal.confirm({ - title: getLabel(131329, "信息确认"), - content: getLabel(111, "确认要保存吗?"), - onOk: () => { - API.updateOrderRule(_.pick(this.state.saveParams, ["orderRule", "ascOrDesc"])) - .then(({ status, errormsg }) => { - if (status) { - message.success(getLabel(22619, "保存成功!")); - let sysSetting = this.getSysSetting(); - } else { - message.error(errormsg || getLabel(22620, "保存失败!")); - } - }); - }, - onCancel: () => { + }, + onCancel: () => { + this.setState({ + saveParams: { + ...saveParams, + [key]: saveParams[key] } }); - }); - } else if (type === "人员字段") { - this.setState({ - saveParams: { ...this.state.saveParams, rule: selected } - }, () => { - Modal.confirm({ - title: getLabel(131329, "信息确认"), - content: getLabel(111, "确认要保存吗?"), - onOk: () => { - API.saveMatchEmployeeModeRule(_.pick(this.state.saveParams, ["rule"])).then(({ status, errormsg }) => { - this.setState({ loading: { ...this.state.loading, employee: false } }); - if (status) { - message.success(getLabel(22619, "保存成功!")); - let sysSetting = this.getSysSetting(); - } else { - message.error(errormsg || getLabel(22620, "保存失败!")); - } - }); - }, - onCancel: () => { - } - }); - }); - } else if (type === "加密设置") { - this.setState({ - saveParams: { ...this.state.saveParams, enctry: selected } - }, () => { - Modal.confirm({ - title: getLabel(131329, "信息确认"), - content: getLabel(543354, "开启/关闭加密前请做好数据库备份!!!逆向解密会花费几分钟时间,请耐心等待!!!"), - onOk: () => { - API.saveEncryptSetting({ isOpenEncrypt: this.state.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 || getLabel(22620, "保存失败!")); - 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(getLabel(22619, "保存成功!")); - } 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 || getLabel(22620, "保存失败!")); - } - }); - }, 1000); - }); - } - }); - }, - onCancel: () => { - } - }); - }); - } else if (type === "个税申报") { - this.setState({ - saveParams: { ...this.state.saveParams, operateTaxDeclaration: selected } - }, () => { - Modal.confirm({ - title: getLabel(131329, "信息确认"), - content: getLabel(111, "确认要保存吗?"), - onOk: () => { - API.operateTaxDeclarationFunction(_.pick(this.state.saveParams, ["operateTaxDeclaration"])) - .then(({ status, errormsg }) => { - if (status) { - message.success(getLabel(22619, "保存成功!")); - let sysSetting = this.getSysSetting(); - } else { - message.error(errormsg || getLabel(22620, "保存失败!")); - } - }); - }, - onCancel: () => { - } - }); - }); - } + } + }); }; render() { - const { items, importItems, enctryItems, declareItems, loading } = this.state; + const { saveParams, matchRuleOptions, orderOptions, ascOptions, employeeOptions } = this.state; + const { orderRule, ascOrDesc, rule, enctry, operateTaxDeclaration, matchRule } = saveParams; return (
规则配置} + title={{getLabel(543355, "规则配置")}} icon={} iconBgcolor="#F14A2D" buttons={[]} /> - - 排序规则 - - {/**/} -
- } showGroup center items={items}/> - - 人员校验规则 - - {/**/} - - } showGroup center items={importItems}/> - { - !_.isEmpty(enctryItems) && - - 加密规则 - - {/**/} - - } showGroup center items={enctryItems}/> - } - - 报税规则 - - {/**/} - - } showGroup center items={declareItems}/> + + + this.handleChange("orderRule", val)} + /> + + + this.handleChange("ascOrDesc", val)} + /> + + + + + this.handleChange("rule", val)} + /> + + + {/*{*/} + {/* !_.isEmpty(enctryItems) &&*/} + + + this.handleChange("enctry", val)}/> + + + {/*}*/} + + + this.handleChange("operateTaxDeclaration", val)}/> + + + + + this.handleChange("matchRule", val)} + /> + + { this.state.progressVisible && { this.setState({ progressVisible: false, progress: 0 }); @@ -487,8 +313,6 @@ class Index extends Component { } } -export default Index; - export const Select = payload => { const { label,