diff --git a/pc4mobx/hrmSalary/apis/ledger.js b/pc4mobx/hrmSalary/apis/ledger.js index 487181bc..d4f64824 100644 --- a/pc4mobx/hrmSalary/apis/ledger.js +++ b/pc4mobx/hrmSalary/apis/ledger.js @@ -155,3 +155,15 @@ export const salarysobRangeImportData = params => { export const getSalaryItemForm = params => { return postFetch("/api/bs/hrmsalary/salarysob/item/getSalaryItemForm", params); }; +//薪资核算规则配置-获取薪资审批规则表单 +export const getSalaryApprovalForm = params => { + return postFetch("/api/bs/hrmsalary/salarysob/salaryApproval/getForm", params); +}; +//薪资核算规则配置-保存薪资审批规则表单 +export const salaryApprovalSaveForm = params => { + return postFetch("/api/bs/hrmsalary/salarysob/salaryApproval/saveForm", params); +}; +//薪资核算规则配置-获取能够添加的项目 +export const getListSalaryItem = params => { + return postFetch("/api/bs/hrmsalary/salarysob/salaryApproval/listSalaryItem", params); +}; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountApprRule.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountApprRule.js new file mode 100644 index 00000000..59990157 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountApprRule.js @@ -0,0 +1,160 @@ +/* + * Author: 黎永顺 + * name: 薪资核算规则配置 + * Description: + * Date: 2024/4/24 + */ +import React, { Component } from "react"; +import { WeaSwitch } from "comsMobx"; +import { inject, observer } from "mobx-react"; +import { WeaFormItem, WeaLocaleProvider, WeaSearchGroup, WeaTools } from "ecCom"; +import LedgerAccountSalaryItemsSet from "./ledgerAccountSalaryItemsSet"; +import * as API from "../../../apis/ledger"; +import { acctApprRulesConditions } from "../config"; + +const getLabel = WeaLocaleProvider.getLabel; +const getKey = WeaTools.getKey; + +@inject("ledgerStore") +@observer +class LedgerAccountApprRule extends Component { + constructor(props) { + super(props); + this.state = { + conditions: [], approvalId: "", approvalItemGroup: [] + }; + } + + componentDidMount() { + this.init(); + } + + init = () => { + const { saveSalarySobId, editId } = this.props; + API.getSalaryApprovalForm({ salarySobId: saveSalarySobId || editId }).then(({ status, data }) => { + if (status) { + this.setState({ + approvalId: data.id, + approvalItemGroup: _.map(data.approvalItemGroup, item => ({ + ...item, id: String(item.sorted), + approvalItems: _.map(item.approvalItems, o => ({ ...o, id: `${String(item.sorted)}-${String(o.sorted)}` })) + })), + conditions: _.map(acctApprRulesConditions, item => ({ + ...item, items: _.map(item.items, o => ({ + ...o, value: getKey(o) === "isOpenApproval" ? (data[getKey(o)] ? "1" : "0") : data[getKey(o)], + viewAttr: getKey(o) === "approvalWorkflowUrl" ? (data["isOpenApproval"] ? 3 : 2) : o.viewAttr, + hide: getKey(o) !== "isOpenApproval" ? !data["isOpenApproval"] : false, + label: getLabel(o.lanId, o.label) + })) + })) + }, () => { + const { ledgerStore: { AARForm } } = this.props; + AARForm.initFormFields(this.state.conditions); + }); + } + }); + }; + + componentWillUnmount() { + const { ledgerStore: { initAARForm } } = this.props; + initAARForm(); + } + + renderForm = (form, conditions) => { + const { saveSalarySobId, editId } = this.props; + const { approvalItemGroup } = this.state; + const { isFormInit } = form; + const formParams = form.getFormParams(); + let group = []; + isFormInit && conditions && conditions.map(c => { + let items = []; + c.items.map(fields => { + if (getKey(fields) !== "approvalItemGroup") { + items.push({ + com: ( + + + ), + hide: fields.hide + }); + } else { + items.push({ + com: ( + + this.setState({ + approvalItemGroup: _.map(approvalItemGroup, o => ({ + ...o, + approvalItems: (groupId === o.id && !_.isEmpty(items)) ? [...o.approvalItems, ..._.map(items, (k, ki) => ({ + salaryItemId: k.id, salaryItemName: k.name, + id: `${String(o.sorted)}-${String(o.approvalItems.length + ki)}` + }))] : o.approvalItems + })) + }, () => form.updateFields({ approvalItemGroup: { value: this.state.approvalItemGroup } }))} + onEdit={(groupName, groupId) => this.setState({ + approvalItemGroup: _.map(approvalItemGroup, o => ({ + ...o, groupName: groupId === o.id ? groupName : o.groupName + })) + }, () => form.updateFields({ approvalItemGroup: { value: this.state.approvalItemGroup } }))} + onDelete={(group, item) => this.setState({ + approvalItemGroup: _.isEmpty(item) ? _.filter(approvalItemGroup, o => o.id !== group.id) : + _.map(approvalItemGroup, o => ({ + ...o, + approvalItems: _.filter(o.approvalItems, oo => oo.id !== item.id) + })) + }, () => form.updateFields({ approvalItemGroup: { value: this.state.approvalItemGroup } }))} + onChange={datas => this.setState({ + approvalItemGroup: datas + }, () => form.updateFields({ approvalItemGroup: { value: datas } }))}/> + ), + hide: fields.hide + }); + } + }); + group.push(); + }); + return group; + }; + convertFormItemViewAttr = (viewAttr) => { + const { ledgerStore: { AARForm } } = this.props; + const { isOpenApproval } = AARForm.getFormParams(); + this.setState({ + conditions: _.map(this.state.conditions, item => ({ + ...item, items: _.map(item.items, o => { + if (getKey(o) === "approvalWorkflowUrl") { + return { ...o, viewAttr, hide: isOpenApproval === "0" }; + } else if (getKey(o) === "approvalItemGroup") { + return { ...o, viewAttr, hide: isOpenApproval === "0" }; + } + return { ...o }; + }) + })) + }); + }; + handleFormItemChange = (value) => { + const { ledgerStore: { AARForm } } = this.props; + const { isOpenApproval } = AARForm.getFormParams(); + if (_.keys(value)[0] === "isOpenApproval") { + this.convertFormItemViewAttr(isOpenApproval === "1" ? 3 : 2); + } + }; + + render() { + const { conditions } = this.state; + const { ledgerStore: { AARForm } } = this.props; + return ( +
+ {this.renderForm(AARForm, conditions)} +
+ ); + } +} + +export default LedgerAccountApprRule; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountApprRuleClassifyNameEditDialog.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountApprRuleClassifyNameEditDialog.js new file mode 100644 index 00000000..482f3ea5 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountApprRuleClassifyNameEditDialog.js @@ -0,0 +1,71 @@ +/* + * Author: 黎永顺 + * name:审批规则分类编辑 + * Description: + * Date: 2024/4/25 + */ +import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; +import { WeaDialog, WeaLocaleProvider, WeaTools } from "ecCom"; +import { Button } from "antd"; +import { getSearchs } from "../../../util"; +import { classifyConditions } from "../config"; + +const getKey = WeaTools.getKey; +const getLabel = WeaLocaleProvider.getLabel; + +@inject("ledgerStore") +@observer +class LedgerAccountApprRuleClassifyNameEditDialog extends Component { + constructor(props) { + super(props); + this.state = { conditions: [] }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) this.init(nextProps); + if (nextProps.visible !== this.props.visible && !nextProps.visible) this.props.ledgerStore.initAARClassifyForm(); + } + + init = (props) => { + const { ledgerStore: { AARClassifyForm }, groupName } = props; + this.setState({ + conditions: _.map(classifyConditions, item => ({ + ...item, + items: _.map(item.items, o => ({ ...o, label: getLabel(o.lanId, o.label) })) + })) + }, () => { + AARClassifyForm.initFormFields(this.state.conditions); + AARClassifyForm.updateFields({ groupName }); + }); + }; + save = () => { + const { ledgerStore: { AARClassifyForm }, groupId } = this.props; + AARClassifyForm.validateForm().then(f => { + if (f.isValid) { + this.props.onCancel(); + this.props.onEdit(AARClassifyForm.getFormParams().groupName, groupId); + } else { + f.showErrors(); + } + }); + }; + + render() { + const { conditions } = this.state; + const { ledgerStore: { AARClassifyForm } } = this.props; + return ( + {getLabel(537558, "保存")} + ]} + > +
{getSearchs(AARClassifyForm, conditions, 1, false)}
+
+ ); + } +} + +export default LedgerAccountApprRuleClassifyNameEditDialog; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountSalaryItemsSet.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountSalaryItemsSet.js new file mode 100644 index 00000000..7152c7ba --- /dev/null +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAccountSalaryItemsSet.js @@ -0,0 +1,134 @@ +/* + * Author: 黎永顺 + * name: 薪资核算规则配置-审批薪资项目 + * Description: + * Date: 2024/4/24 + */ +import React, { Component } from "react"; +import { WeaLocaleProvider, WeaSortable, WeaTransfer } from "ecCom"; +import LedgerAccountApprRuleClassifyNameEditDialog from "./ledgerAccountApprRuleClassifyNameEditDialog"; +import * as API from "../../../apis/ledger"; +import { Icon, Modal } from "antd"; +import cs from "classnames"; +import SalaryItemModal from "../../payroll/stepForm/salaryItemModal"; + +const getLabel = WeaLocaleProvider.getLabel; + +class LedgerAccountSalaryItemsSet extends Component { + constructor(props) { + super(props); + this.state = { + editDialog: { visible: false, groupName: "", groupId: "" }, + salaryItemDialog: { visible: false, title: getLabel(111, "薪资项目项"), options: [], groupId: "" } + }; + } + + handleDeleteClick = (group, item = {}) => { + Modal.confirm({ + title: getLabel(131329, "信息确认"), + content: getLabel(543231, "确认删除本条数据吗?"), + onOk: () => this.props.onDelete(group, item) + }); + }; + handleAddSalaryItems = (group) => { + const { salaryItemDialog } = this.state; + const { salarySobId } = this.props; + const payload = { + salarySobId, excludeIds: _.map(group.approvalItems, o => o.salaryItemId) + }; + API.getListSalaryItem(payload).then(({ status, data }) => { + if (status) this.setState({ + salaryItemDialog: { + ...salaryItemDialog, visible: true, options: data, groupId: group.id + } + }); + }); + }; + handleConfirm = () => { + const { salaryItemDialog } = this.state; + this.setState({ + salaryItemDialog: { ...salaryItemDialog, visible: false } + }, () => this.props.onAdd(salaryItemDialog.groupId, _.filter(this.state.salaryItemDialog.options, g => g.checkedSalaryItem))); + }; + + render() { + const { editDialog, salaryItemDialog } = this.state; + const { datas } = this.props; + return ( +
+ this.props.onChange(list)} + renderNodeItem={(item) => { + return
+
+ + {item.groupName} + + this.setState({ + editDialog: { visible: true, groupName: item.groupName, groupId: item.id } + })}/> + this.handleDeleteClick(item)}/> + + + this.handleAddSalaryItems(item)}/> +
+
+ { + !_.isEmpty(item.approvalItems) ? + this.props.onChange( + _.map(datas, child => { + if (child.id === item.id) { + return { ...child, approvalItems: items }; + } + return { ...child }; + }) + )} + renderNodeItem={(filed) => { + return
+
+
{filed.salaryItemName}
+ this.handleDeleteClick(item, filed)}/> +
+
; + }} + className="wea-sortable-salary-item" + /> : +
暂无数据
+ } +
+
; + }} + className="wea-sortable-salary-item" + /> + this.setState({ + editDialog: { ...editDialog, visible: false } + })}/> + this.setState({ + salaryItemDialog: { ...salaryItemDialog, visible: false } + })} onConfirm={this.handleConfirm}> +
+ g.checkedSalaryItem), o => o.id)} + onChange={v => { + this.setState({ + salaryItemDialog: { + ...salaryItemDialog, + options: _.map(salaryItemDialog.options, o => ({ ...o, checkedSalaryItem: _.includes(v, o.id) })) + } + }); + }} + /> +
+
+
+ ); + } +} + +export default LedgerAccountSalaryItemsSet; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js index 5692c526..07c4cd0d 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js @@ -6,7 +6,7 @@ */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; -import { WeaSlideModal, WeaSteps } from "ecCom"; +import { WeaLocaleProvider, WeaSlideModal, WeaSteps } from "ecCom"; import { Button, message, Modal } from "antd"; import SlideModalTitle from "../../../components/slideModalTitle"; import LedgerBaseSetting from "./ledgerBaseSetting"; @@ -14,17 +14,12 @@ import LedgerAssociatedPersonnel from "./ledgerAssociatedPersonnel"; import LedgerSalaryAdjustmentRules from "./ledgerSalaryAdjustmentRules"; import LedgerBackCalculatedSalaryItem from "./ledgerBackCalculatedSalaryItem"; import LedgerSalaryItem from "./ledgerSalaryItem"; -import { saveAdjustmentRule, saveLedgerBasic, saveLedgerItem } from "../../../apis/ledger"; +import LedgerAccountApprRule from "./ledgerAccountApprRule"; +import { salaryApprovalSaveForm, saveAdjustmentRule, saveLedgerBasic, saveLedgerItem } from "../../../apis/ledger"; import "./index.less"; const Step = WeaSteps.Step; -const tabs = [ - { key: 0, title: "基础设置" }, - { key: 1, title: "关联人员" }, - { key: 2, title: "薪资项目" }, - { key: 3, title: "回算薪资项目" }, - { key: 4, title: "调薪计薪规则" } -]; +const getLabel = WeaLocaleProvider.getLabel; @inject("taxAgentStore", "ledgerStore") @observer @@ -95,7 +90,6 @@ class LedgerSlide extends Component { this.setState({ loading: false }); if (status) { message.success("保存成功"); - this.handleClose(); } else { message.success(errormsg || "保存失败"); } @@ -166,6 +160,40 @@ class LedgerSlide extends Component { handleSaveSalaryItemParams = (empFields, itemGroups) => { this.setState({ empFields, itemGroups }); }; + handleDefaultSave = () => { + const { saveSalarySobId } = this.state; + const { state: { approvalId } } = this.approRef.wrappedInstance; + const { ledgerStore: { AARForm } } = this.props; + const { approvalItemGroup, isOpenApproval, ...extra } = AARForm.getFormParams(); + const group = _.map(approvalItemGroup, (item, index) => ({ + groupName: item.groupName, sorted: index, + approvalItems: _.map(item.approvalItems, (o, oi) => ({ + salaryItemId: o.salaryItemId, sorted: oi, + salaryItemName: o.salaryItemName + })) + })); + if (isOpenApproval === "1" && _.isEmpty(extra.approvalWorkflowUrl)) { + AARForm.showError("approvalWorkflowUrl", getLabel(111, "\"审批流程地址\"未填写")); + return; + } else if (isOpenApproval === "1" && _.isEmpty(group)) { + AARForm.showError("approvalItemGroup", getLabel(111, "\"审批薪资项目\"未填写")); + return; + } + const payload = { + ...extra, isOpenApproval: isOpenApproval === "1", id: approvalId, + salarySobId: this.props.editId || saveSalarySobId, + approvalItemGroup: group + }; + this.setState({ loading: true }); + salaryApprovalSaveForm(payload).then(({ status, errormsg }) => { + this.setState({ loading: false }); + if (status) { + message.success(getLabel(111, "保存成功!")); + } else { + message.error(errormsg); + } + }); + }; renderChildren = () => { const { current, saveSalarySobId } = this.state; let CurrentDom = null; @@ -189,7 +217,8 @@ class LedgerSlide extends Component { onSaveParams={(adjustRules) => this.setState({ adjustRules })}/>; break; default: - CurrentDom = null; + CurrentDom = + this.approRef = dom} saveSalarySobId={saveSalarySobId}/>; break; } return CurrentDom; @@ -245,13 +274,28 @@ class LedgerSlide extends Component { case 4: CurrentDom = !editId ? [ + , , - + ] : [ - + ]; break; default: + CurrentDom = !editId ? + [ + , + + ] : [ + + ]; break; } } @@ -261,6 +305,14 @@ class LedgerSlide extends Component { render() { const { title, visible, editId, taxAgentStore: { showOperateBtn } } = this.props; const { current } = this.state; + const tabs = [ + { key: 0, title: getLabel(82751, "基础设置") }, + { key: 1, title: getLabel(543467, "关联人员") }, + { key: 2, title: getLabel(542362, "薪资项目") }, + { key: 3, title: getLabel(543468, "回算薪资项目") }, + { key: 4, title: getLabel(543469, "调薪计薪规则") }, + { key: 10, title: getLabel(111, "核算审批规则") } + ]; return ( this.AARForm = new WeaForm();//重置核算审批规则form + @action initAARClassifyForm = (v) => this.AARClassifyForm = new WeaForm();//重置审批规则分类编辑form /*******************************************************/ @@ -148,14 +152,14 @@ export class LedgerStore { setItemGroups = itemGroups => { itemGroups = itemGroups ? [...itemGroups] : []; itemGroups && - itemGroups.map(item => { - if (item.items) { - item.items && - item.items.map(i => { - i.key = i.id; - }); - } - }); + itemGroups.map(item => { + if (item.items) { + item.items && + item.items.map(i => { + i.key = i.id; + }); + } + }); this.itemGroups = itemGroups; }; @@ -388,9 +392,9 @@ export class LedgerStore { if (!this.validateBaseFrom(params)) { reject("保存失败"); } - this.saveLoading= true; + this.saveLoading = true; API.saveLedgerBasic(params).then(res => { - this.saveLoading= false; + this.saveLoading = false; if (res.status) { this.salarySobId = res.data; resolve(); @@ -463,9 +467,9 @@ export class LedgerStore { //薪资帐套人员范围(包含)列表 getLedgerPersonRangeInclude = params => { - this.loading= true; + this.loading = true; API.getLedgerPersonRangeInclude(params).then(res => { - this.loading= false; + this.loading = false; if (res.status) { this.setUserTableStore(res.data); } else { @@ -476,9 +480,9 @@ export class LedgerStore { //薪资帐套人员范围(排除)列表 getLedgerPersonRangeExclude = params => { - this.loading= true; + this.loading = true; API.getLedgerPersonRangeExclude(params).then(res => { - this.loading= false; + this.loading = false; if (res.status) { this.setUserTableStore(res.data); } else { @@ -508,12 +512,12 @@ export class LedgerStore { listSalaryItem = (searchValue = "", current = 1) => { let excludeIds = []; this.itemGroups && - this.itemGroups.map(item => { - item.items && - item.items.map(i => { - excludeIds.push(i.salaryItemId); - }); + this.itemGroups.map(item => { + item.items && + item.items.map(i => { + excludeIds.push(i.salaryItemId); }); + }); this.loading = true; API.listSalaryItem({ name: searchValue, excludeIds, current }).then(res => { if (res.status) { @@ -562,7 +566,7 @@ export class LedgerStore { salaryItemId: i.salaryItemId, sortedIndex: index + 1, formulaId: i.formulaId, - itemHide: i.itemHide || "0", + itemHide: i.itemHide || "0" })); return result; } @@ -571,14 +575,14 @@ export class LedgerStore { let params = { salarySobId: this.salarySobId, - empFields: _.map(this.userSelectedList, (it, idx) => ({...it, sortedIndex:idx })), + empFields: _.map(this.userSelectedList, (it, idx) => ({ ...it, sortedIndex: idx })), itemGroups: itemGroups.filter(item => item.id != "default"), items: itemGroups.filter(item => item.id == "default")[0].items }; return new Promise((resolve, reject) => { - this.saveLoading= true; + this.saveLoading = true; API.saveLedgerItem(params).then(res => { - this.saveLoading= false; + this.saveLoading = false; if (res.status) { resolve(); message.success("保存成功"); @@ -626,9 +630,9 @@ export class LedgerStore { ruleParams: this.sobItemRuleDataSource }; return new Promise((resolve, reject) => { - this.saveLoading= true; + this.saveLoading = true; API.saveAdjustmentRule(params).then(res => { - this.saveLoading= false; + this.saveLoading = false; if (res.status) { resolve(); message.success("保存成功");