diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/index.less b/pc4mobx/hrmSalary/pages/ledgerPage/components/index.less index 96d0463d..5ed5c65c 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/index.less +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/index.less @@ -91,39 +91,14 @@ //调薪计薪规则弹框 .adjustRuleModalWrapper { - .titleTipWrapper { - display: flex; - align-items: center; + .calcRules .cust { + line-height: 30px; - .title { - margin-right: 4px; - } - } - - .adjustRuleDetailWrapper { - display: flex; - flex-direction: column; - - .adjustSalaryFlex { + .child { display: flex; align-items: center; - margin-bottom: 10px; } } - - .wea-select, .ant-select-selection, .ant-select { - width: 100%; - } - - .wea-select { - display: inline-block; - position: relative; - } - - .ant-select-selection { - height: 30px; - border-radius: 0; - } } // 回算薪资项目 @@ -249,7 +224,7 @@ padding: 0; background: transparent; border: none; - font-size: 20px!important; + font-size: 20px !important; line-height: 20px; } diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAdjustRuleAddModal.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAdjustRuleAddModal.js index 771fdb12..2456af87 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAdjustRuleAddModal.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAdjustRuleAddModal.js @@ -9,9 +9,10 @@ import { inject, observer } from "mobx-react"; import { WeaDialog, WeaFormItem, WeaHelpfulTip, WeaLocaleProvider, WeaSelect, WeaTools } from "ecCom"; import FormInfo from "../../../components/FormInfo"; import { WeaSwitch } from "comsMobx"; -import { Button, Modal } from "antd"; +import { Button } from "antd"; import { listSalarySobItem } from "../../../apis/ledger"; import { monthDays, ruleConditions } from "../config"; +import "./index.less"; const { getLabel } = WeaLocaleProvider; const getKey = WeaTools.getKey; @@ -21,19 +22,12 @@ const getKey = WeaTools.getKey; class LedgerAdjustRuleAddModal extends Component { constructor(props) { super(props); - this.state = { - beforeAdjustmentType: 2, - afterAdjustmentType: 1, - salaryItemId: "", - salaryItemName: "", - dayOfMonth: "1", - salaryItemOptions: [], - conditions: [] - }; + this.state = { conditions: [] }; } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) this.listSalarySobItem(nextProps.salarySobId); + if (nextProps.visible !== this.props.visible && !nextProps.visible) this.props.ledgerStore.initRuleForm(); } listSalarySobItem = (salarySobId) => { @@ -46,17 +40,26 @@ class LedgerAdjustRuleAddModal extends Component { this.setState({ conditions: _.map(ruleConditions, item => ({ ...item, items: _.map(item.items, o => { + o = { ...o, label: getLabel(o.lanId, o.label) }; if (getKey(o) === "salaryItemId") { return { - ...o, label: getLabel(o.lanId, o.label), - options: _.map(data, it => ({ key: it.salaryItemId.toString(), showname: it.salaryItemName })) + ...o, options: _.map(data, it => ({ key: it.salaryItemId.toString(), showname: it.salaryItemName })) }; } else if (getKey(o) === "dayOfMonth") { - return { ...o, label: getLabel(o.lanId, o.label), options: monthDays }; + return { ...o, options: monthDays }; + } else if (getKey(o) === "beforeAdjustmentType" || getKey(o) === "afterAdjustmentType") { + return { + ...o, + options: _.map(o.options, k => ({ + ...k, + showname: !k.helpfultip ? getLabel(k.lanId, k.showname) : + {getLabel(k.lanId, k.showname)} + + + })) + }; } - return { - ...o, label: getLabel(o.lanId, o.label), helpfulTip: getLabel(o.helpfulTipLanId, o.helpfulTip) - }; + return o; }) })) }, () => this.props.ledgerStore.ruleForm.initFormFields(this.state.conditions)); @@ -64,156 +67,77 @@ class LedgerAdjustRuleAddModal extends Component { }); }; handleSave = () => { - const { salaryRuleItemsList, onSave } = this.props; - const { salaryItemOptions, ...extraItems } = this.state; - if (_.isEmpty(extraItems.salaryItemId)) { - Modal.warning({ - title: "信息确认", - content: "必要信息不完整,红色*为必填项!" - }); - return; - } - const items = { ...extraItems, salaryItemName: this.state.salaryItemName }; - const { salaryItemName, salaryItemId, ...extraFileds } = items; - const salaryItemNameFiled = salaryItemName.split(","), salaryItemIdFiled = salaryItemId.split(","); - const fields = _.map(salaryItemNameFiled, (item, index) => { - return { - ...extraFileds, - salaryItemName: item, - salaryItemId: salaryItemIdFiled[index] - }; - }); - this.handleReset(); - onSave([...salaryRuleItemsList, ...fields]); - }; - handleReset = () => { - this.setState({ - beforeAdjustmentType: 2, - afterAdjustmentType: 1, - salaryItemId: "", - salaryItemName: "", - dayOfMonth: "1", - salaryItemOptions: [] - }, () => { - const { onCancel } = this.props; - onCancel(); + const { salaryRuleItemsList, onSave, ledgerStore: { ruleForm } } = this.props; + ruleForm.validateForm().then(f => { + if (f.isValid) { + const { salaryItemId } = ruleForm.getFormParams(), { fieldMap } = ruleForm; + const fields = _.map(salaryItemId.split(","), o => ({ + ...ruleForm.getFormParams(), + salaryItemId: o, + salaryItemName: _.find(fieldMap["salaryItemId"]["options"], k => k.key === o).showname + })); + this.props.onCancel(onSave([...salaryRuleItemsList, ...fields])); + } else { + f.showErrors(); + } }); }; render() { - const { - salaryItemId, - salaryItemOptions, - dayOfMonth, - beforeAdjustmentType, - afterAdjustmentType, - conditions - } = this.state; - const { title, visible, ledgerStore: { ruleForm } } = this.props; + const { title, visible, ledgerStore: { ruleForm } } = this.props, { conditions } = this.state; const buttons = []; const itemRender = { salaryItemId: (field, textAreaProps, form, formParams) => { return (); }, - dayOfMonth: () => null + dayOfMonth: () => null, + beforeAdjustmentType: () => null, + afterAdjustmentType: () => null }; const childrenComponents = { salaryItemId: () => { + const { dayOfMonth, beforeAdjustmentType, afterAdjustmentType } = ruleForm.getFormParams(); const coms = [], { fieldMap } = ruleForm; coms.push( - + + {getLabel(111, "计薪规则")} + + } labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
{fieldMap["dayOfMonth"].label}
- + ruleForm.updateFields({ dayOfMonth: { value: v } })}/>
{getLabel(111, "(含)之前")}
+
+
{fieldMap["beforeAdjustmentType"].label}
+ ruleForm.updateFields({ beforeAdjustmentType: { value: v } })}/> +
+
+
{getLabel(111, "否则:调薪生效日期在10号之后")}
+
+
+
{fieldMap["afterAdjustmentType"].label}
+ ruleForm.updateFields({ afterAdjustmentType: { value: v } })}/> +
); - return [ - { - com:
{coms}
, - col: 1 - } - ]; + return [{ com:
{coms}
, col: 1 }]; } }; return ( - + - {/**/} - {/* */} - {/* this.setState({ salaryItemId, salaryItemName })}*/} - {/* />*/} - {/* */} - {/* } labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} colon={false}>*/} - {/*
*/} - {/*
*/} - {/* 如果:调薪生效日期在*/} - {/* this.setState({ dayOfMonth })}*/} - {/* />*/} - {/* (含)之前*/} - {/*
*/} - {/*
*/} - {/* 计薪规则为:*/} - {/* this.setState({ beforeAdjustmentType: e.target.value })}*/} - {/* value={beforeAdjustmentType}>*/} - {/* 取调整后薪资*/} - {/* 分段计薪*/} - {/* 取平均*/} - {/* */} - {/* */} - {/*
*/} - {/*
否则:调薪生效日期在{dayOfMonth}号之后
*/} - {/*
*/} - {/* 计薪规则为:*/} - {/* this.setState({ afterAdjustmentType: e.target.value })}*/} - {/* value={afterAdjustmentType}>*/} - {/* 取调整前薪资*/} - {/* 分段计薪*/} - {/* 取平均*/} - {/* */} - {/* */} - {/*
*/} - {/*
*/} - {/*
*/} - {/*
*/}
); } @@ -221,14 +145,3 @@ class LedgerAdjustRuleAddModal extends Component { export default LedgerAdjustRuleAddModal; -const AdjustTitle = () => { - return
- 计薪规则 - - : -
; -}; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/config.js b/pc4mobx/hrmSalary/pages/ledgerPage/config.js index e6726805..a1085635 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/config.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/config.js @@ -881,7 +881,51 @@ export const ruleConditions = [//调薪计薪规则项表单 label: "如果:调薪生效日期在", lanId: 111, labelcol: 0, - value: "", + value: "1", + viewAttr: 2 + }, + { + conditionType: "SELECT", + domkey: ["beforeAdjustmentType"], + fieldcol: 6, + label: "计薪规则为:", + lanId: 111, + labelcol: 0, + value: "2", + options: [ + { key: "2", showname: "取调整后薪资", lanId: 111 }, + { + key: "4", showname: "分段计薪", lanId: 111, helpfultiplanId: 111, + helpfultip: "调整前薪资/当月自然日天数*调整前自然日天数+调整后薪资/当月自然日天数*调整后自然日天数" + }, + { + key: "3", showname: "取平均", lanId: 111, + helpfultip: "(调整前薪资+调整后薪资)/2", helpfultiplanId: 111 + } + ], + detailtype: 3, + viewAttr: 2 + }, + { + conditionType: "SELECT", + domkey: ["afterAdjustmentType"], + fieldcol: 6, + label: "计薪规则为:", + lanId: 111, + labelcol: 0, + value: "1", + options: [ + { key: "1", showname: "取调整前薪资", lanId: 111 }, + { + key: "4", showname: "分段计薪", lanId: 111, helpfultiplanId: 111, + helpfultip: "调整前薪资/当月自然日天数*调整前自然日天数+调整后薪资/当月自然日天数*调整后自然日天数" + }, + { + key: "3", showname: "取平均", lanId: 111, + helpfultip: "(调整前薪资+调整后薪资)/2", helpfultiplanId: 111 + } + ], + detailtype: 3, viewAttr: 2 } ],