From b678ec91e6ed6da28004b141953717d3d0df184b Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Wed, 6 Apr 2022 14:26:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hrmSalary/components/EditTable/index.js | 3 + .../hrmSalary/components/customForm/index.js | 7 +- .../components/requiredLabelTip/index.js | 17 +++++ .../components/requiredLabelTip/index.less | 3 + .../hrmSalary/pages/ledger/addUserModal.js | 17 ++++- pc4mobx/hrmSalary/pages/ledger/index.js | 14 +++- .../hrmSalary/pages/ledger/slideBaseForm.js | 15 ++-- .../pages/ledger/step3/AddCategoryModal.js | 3 +- .../pages/ledger/step4/RuleEditModal.js | 37 +++++++++- .../pages/ledger/step5/ValidRuleEditModal.js | 26 ++++++- .../pages/salaryFile/editAgentModal.js | 56 +++++++++----- .../pages/salaryItem/customSalaryItemSlide.js | 38 ++++++---- pc4mobx/hrmSalary/pages/salaryItem/options.js | 20 ++--- .../programme/defaultSlideForm.js | 5 +- pc4mobx/hrmSalary/pages/taxAgent/editModal.js | 5 +- .../pages/taxRate/editSlideContent.js | 4 +- pc4mobx/hrmSalary/stores/ledger.js | 74 +++++++++++++++++++ pc4mobx/hrmSalary/stores/programme.js | 36 +++++++++ pc4mobx/hrmSalary/stores/salaryFile.js | 18 +++++ pc4mobx/hrmSalary/stores/salaryItem.js | 37 +++++++++- pc4mobx/hrmSalary/stores/taxRate.js | 9 +++ pc4mobx/hrmSalary/style/index.less | 1 + pc4mobx/hrmSalary/util/validate.js | 12 +++ 23 files changed, 386 insertions(+), 71 deletions(-) create mode 100644 pc4mobx/hrmSalary/components/requiredLabelTip/index.js create mode 100644 pc4mobx/hrmSalary/components/requiredLabelTip/index.less create mode 100644 pc4mobx/hrmSalary/util/validate.js diff --git a/pc4mobx/hrmSalary/components/EditTable/index.js b/pc4mobx/hrmSalary/components/EditTable/index.js index 06611a74..8cc7f433 100644 --- a/pc4mobx/hrmSalary/components/EditTable/index.js +++ b/pc4mobx/hrmSalary/components/EditTable/index.js @@ -20,6 +20,7 @@ export class EditableCell extends React.Component {
{ editable ? : value @@ -40,6 +41,7 @@ export default class EditableTable extends React.Component { if (item.editable) { item.render = (text, record) => ( ( - {item.label} : + {item.label} { + item.rules == "required" && + } : { diff --git a/pc4mobx/hrmSalary/components/requiredLabelTip/index.js b/pc4mobx/hrmSalary/components/requiredLabelTip/index.js new file mode 100644 index 00000000..e50e0e4a --- /dev/null +++ b/pc4mobx/hrmSalary/components/requiredLabelTip/index.js @@ -0,0 +1,17 @@ +import React from 'react' +import "./index.less" + +export default class RequiredLabelTip extends React.Component { + render() { + return ( + * + ) + } +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/components/requiredLabelTip/index.less b/pc4mobx/hrmSalary/components/requiredLabelTip/index.less new file mode 100644 index 00000000..e75b7b58 --- /dev/null +++ b/pc4mobx/hrmSalary/components/requiredLabelTip/index.less @@ -0,0 +1,3 @@ +.requireLabel:after { + +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/pages/ledger/addUserModal.js b/pc4mobx/hrmSalary/pages/ledger/addUserModal.js index 13887db8..5d9f9614 100644 --- a/pc4mobx/hrmSalary/pages/ledger/addUserModal.js +++ b/pc4mobx/hrmSalary/pages/ledger/addUserModal.js @@ -2,6 +2,7 @@ import React from 'react' import { Modal, Button, Row, Col, Radio } from 'antd' import { WeaSelect, WeaBrowser } from "ecCom" import { inject, observer } from 'mobx-react'; +import RequiredLabelTip from '../../components/requiredLabelTip'; const objectOptions = [ { @@ -38,6 +39,7 @@ export default class AddUserModal extends React.Component { this.setState({radioValue: e.target.value}) } + // 保存 handleSave() { const { ledgerStore: {saveLedgerPersonRange, salarySobId, includeType} } = this.props; saveLedgerPersonRange({ @@ -48,6 +50,15 @@ export default class AddUserModal extends React.Component { }) } + // 重置 + handleReset() { + this.setState({ + selectedKey: "EMPLOYEE", + radioValue: "ALL", + ids: "" + }) + } + render() { return ( {this.props.onCancel()}} width={600} @@ -55,13 +66,13 @@ export default class AddUserModal extends React.Component { footer={
- +
} >
- 对象类型 + 对象类型
{ @@ -103,7 +114,7 @@ export default class AddUserModal extends React.Component { - 选择员工状态 + 选择员工状态 this.onRadioChange(e)} value={this.state.radioValue}> 全部 diff --git a/pc4mobx/hrmSalary/pages/ledger/index.js b/pc4mobx/hrmSalary/pages/ledger/index.js index 2339ccad..ad837a58 100644 --- a/pc4mobx/hrmSalary/pages/ledger/index.js +++ b/pc4mobx/hrmSalary/pages/ledger/index.js @@ -325,7 +325,19 @@ export default class Ledger extends React.Component { content={
{ - currentStep == 0 && + currentStep == 0 && + } + { + currentStep == 1 && + } + { + currentStep == 2 && + } + { + currentStep == 3 && + } + { + currentStep == 4 && }
diff --git a/pc4mobx/hrmSalary/pages/ledger/slideBaseForm.js b/pc4mobx/hrmSalary/pages/ledger/slideBaseForm.js index 982f3fa5..c75a1321 100644 --- a/pc4mobx/hrmSalary/pages/ledger/slideBaseForm.js +++ b/pc4mobx/hrmSalary/pages/ledger/slideBaseForm.js @@ -5,6 +5,7 @@ import "./index.less" import TipLabel from '../../components/TipLabel' import { daysOptions, cycleTypeOption } from './options' import { inject, observer } from 'mobx-react'; +import RequiredLabelTip from "../../components/requiredLabelTip" @inject('ledgerStore') @observer @@ -48,13 +49,13 @@ export default class SlideBaseForm extends React.Component {
- 账套名称 + 账套名称 {this.handleChange({name: value})}}/> - 薪资类型 + 薪资类型 - 薪资周期 + 薪资周期 {this.handleChange({salaryCycleType: value})}}/> {this.handleChange({salaryCycleFromDay: value})}}/> @@ -72,13 +73,13 @@ export default class SlideBaseForm extends React.Component { - 税款所属期 + 税款所属期 {this.handleChange({taxCycleType: value})}}/> - 考勤周期 + 考勤周期 {this.handleChange({attendCycleType: value})}}/> {this.handleChange({attendCycleFromDay: value})}}/> @@ -86,14 +87,14 @@ export default class SlideBaseForm extends React.Component { - 福利台账月份 + 福利台账月份 {this.handleChange({socialSecurityCycleType: value})}}/> - 核算人员范围 + 核算人员范围 diff --git a/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js b/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js index 222fa583..f2ae0917 100644 --- a/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js +++ b/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js @@ -1,6 +1,7 @@ import React from 'react' import { Row, Col, Modal, Button } from 'antd' import { WeaInput } from 'ecCom' +import RequiredLabelTip from '../../../components/requiredLabelTip' export default class AddCategoryModal extends React.Component { @@ -17,7 +18,7 @@ export default class AddCategoryModal extends React.Component { >
- 分类名称 + 分类名称 {this.setState({name: value})}}/> diff --git a/pc4mobx/hrmSalary/pages/ledger/step4/RuleEditModal.js b/pc4mobx/hrmSalary/pages/ledger/step4/RuleEditModal.js index 05e717fe..1ae038ba 100644 --- a/pc4mobx/hrmSalary/pages/ledger/step4/RuleEditModal.js +++ b/pc4mobx/hrmSalary/pages/ledger/step4/RuleEditModal.js @@ -1,8 +1,10 @@ import React from 'react' -import { Row, Col, Radio, Button, Modal } from 'antd' +import { Row, Col, Radio, Button, Modal, message } from 'antd' import { WeaSelect, WeaHelpfulTip} from 'ecCom' import { inject, observer } from 'mobx-react'; import {daysOptions} from "../options" +import RequiredLabelTip from '../../../components/requiredLabelTip'; +import { notNull } from '../../../util/validate'; @inject('ledgerStore') @@ -35,8 +37,36 @@ export default class RuleEditModal extends React.Component { afterAdjustmentTypeChange(e) { this.setState({afterAdjustmentType: e.target.value}) } + + validateForm() { + const {itemValue, effectiveDate, beforeAdjustmentType, afterAdjustmentType} = this.state; + if(!notNull(itemValue)) { + message.warning("薪资项目不能为空") + return false; + } + + if(!notNull(effectiveDate)) { + message.warning("计薪规则不能为空") + return false; + } + + if(!notNull(beforeAdjustmentType)) { + message.warning("计薪规则不能为空") + return false; + } + + if(!notNull(afterAdjustmentType)) { + message.warning("计薪规则不能为空") + return false; + } + + return true; + } handleSave() { + if(!this.validateForm()) { + return; + } const { ledgerStore } = this.props; const { ruleOptionList } = ledgerStore; let salaryItemName = "" @@ -45,6 +75,7 @@ export default class RuleEditModal extends React.Component { salaryItemName = item.showname } }) + this.props.onSave({ salaryItemId:this.state.itemValue, dayOfMonth:this.state.effectiveDate, @@ -66,7 +97,7 @@ export default class RuleEditModal extends React.Component { >
- 薪资项目 + 薪资项目 { initedSelect && @@ -75,7 +106,7 @@ export default class RuleEditModal extends React.Component { - 计薪规则 + 计薪规则
- 规则名称 + 规则名称 {this.setState({name: value})}}/> - 校验规则 + 校验规则 {this.setState({formulaId: value})}}/> diff --git a/pc4mobx/hrmSalary/pages/salaryFile/editAgentModal.js b/pc4mobx/hrmSalary/pages/salaryFile/editAgentModal.js index c3148047..d92f29ab 100644 --- a/pc4mobx/hrmSalary/pages/salaryFile/editAgentModal.js +++ b/pc4mobx/hrmSalary/pages/salaryFile/editAgentModal.js @@ -1,11 +1,10 @@ import React from 'react' import { Modal, Row, Col, Button } from "antd" import { WeaDatePicker, WeaSelect } from "ecCom" -import { adjustResion } from './adjustReason' import { inject, observer } from 'mobx-react'; import moment from 'moment' -@inject('taxAgentStore', "salaryFileStore") +@inject("salaryFileStore") @observer export default class EditAgentModal extends React.Component { constructor(props) { @@ -22,25 +21,41 @@ export default class EditAgentModal extends React.Component { } } - componentWillMount() { - const { taxAgentStore: {fetchTaxAgentOption}} = this.props; - fetchTaxAgentOption().then(() => { - this.setState({initSelected: true}) + getAdjustReasonList() { + const { salaryFileStore:{salaryArchiveTaxAgentForm}} = this.props; + let adjustReasonList = salaryArchiveTaxAgentForm.adjustReasonList.map(item => { + item = {...item} + item.showname = item.content; + item.key = item.id + ""; + item.selected = false + return item; }) + return adjustReasonList } - - getResionOptions() { - return Object.keys(adjustResion).map(key => { - let item = {} - item.showname = adjustResion[key] - item.key = key + + getTaxAgentList() { + const { salaryFileStore:{salaryArchiveTaxAgentForm}} = this.props; + return salaryArchiveTaxAgentForm.taxAgentList.map(item => { + item = {...item} + item.showname = item.name; + item.key = item.id + ""; item.selected = false return item }) } + componentWillMount() { + const { salaryFileStore: {salaryArchiveTaxAgentForm, getTaxAgentForm}} = this.props; + getTaxAgentForm(this.props.currentId).then(() => { + + this.setState({initSelected: true}) + }) + } + + handleSave() { const { salaryFileStore: {saveTaxAgent}} = this.props; + saveTaxAgent(this.state.request) } @@ -53,8 +68,8 @@ export default class EditAgentModal extends React.Component { } render() { - const { taxAgentStore } = this.props; - const { taxAgentOption } = taxAgentStore + const { salaryFileStore } = this.props; + const { salaryArchiveTaxAgentForm } = salaryFileStore const { request } = this.state; const { salaryArchiveId, @@ -62,6 +77,7 @@ export default class EditAgentModal extends React.Component { adjustReason, taxAgentId } = request; + return ( 调整原因 - { - this.handleChange({adjustReason: value}) - }}/> + { + this.state.initSelected && + { + this.handleChange({adjustReason: value}) + }}/> + } 调整前 + {salaryArchiveTaxAgentForm.adjustBefore} 调整后 { - this.state.initSelected && { + this.state.initSelected && { this.handleChange({taxAgentId: value}) }} /> } diff --git a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js index 828d1cfd..62107ee4 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js @@ -3,11 +3,14 @@ import { Row, Col, Switch, Radio } from 'antd' import { WeaHelpfulTip, WeaSelect, WeaTextarea, WeaInput } from 'ecCom' import "./index.less" import { roundingModeOptions, patternOptions, dataTypeOptions } from "./options" - +import RequiredLabelTip from '../../components/requiredLabelTip' export default class CustomSalaryItemSlide extends React.Component { constructor(props) { super(props) + this.state = { + showForm: false + } } handleChange(params) { let request = {...this.props.request, ...params} @@ -24,7 +27,7 @@ export default class CustomSalaryItemSlide extends React.Component {
- 名称 + 名称 {this.handleChange({name: value})}}/> @@ -59,7 +62,7 @@ export default class CustomSalaryItemSlide extends React.Component { - 字段类型 + 字段类型 {this.handleChange({dataType: value})}} style={{width: "200px"}}/> @@ -69,7 +72,7 @@ export default class CustomSalaryItemSlide extends React.Component { - 舍入规则 + 舍入规则 {this.handleChange({roundingMode: value})}}/> @@ -78,7 +81,7 @@ export default class CustomSalaryItemSlide extends React.Component { - 保留小数位 + 保留小数位 {this.handleChange({pattern: value})}} value={pattern} style={{width: "200px"}}/> @@ -88,21 +91,30 @@ export default class CustomSalaryItemSlide extends React.Component { - 取值方式 + 取值方式 - {this.handleChange({valueType: e.target.value})}}> + { + this.setState({ + showForm: e.target.value == 2 ? true: false + }) + this.handleChange({valueType: e.target.value}) + }}> 输入 公式 - - 公式 - - - - + { + this.state.showForm && + + 公式 + + + + + } + 备注 diff --git a/pc4mobx/hrmSalary/pages/salaryItem/options.js b/pc4mobx/hrmSalary/pages/salaryItem/options.js index 3d9a3bb0..c8825781 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/options.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/options.js @@ -1,21 +1,21 @@ export const roundingModeOptions = [ { - key: 1, + key: "1", selected: false, showname: "原始数据" }, { - key: 2, + key: "2", selected: false, showname: "四舍五入" }, { - key: 3, + key: "3", selected: false, showname: "向上舍入" }, { - key: 4, + key: "4", selected: false, showname: "向下舍入" } @@ -23,32 +23,32 @@ export const roundingModeOptions = [ export const patternOptions = [ { - key: 0, + key: "0", showname: "0", selected: false }, { - key: 1, + key: "1", showname: "1", selected: false }, { - key: 2, + key: "2", showname: "2", selected: false }, { - key: 3, + key: "3", showname: "3", selected: false }, { - key: 4, + key: "4", showname: "4", selected: false }, { - key: 5, + key: "5", showname: "5", selected: false }, diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js index ba57dfed..382fb904 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js @@ -5,6 +5,7 @@ import { insertUpdateColumns } from './columns' import { inject, observer } from 'mobx-react'; import SmallTab from '../../../components/smallTab' import "./index.less" +import RequiredLabelTip from '../../../components/requiredLabelTip'; @inject('programmeStore') @observer @@ -170,7 +171,7 @@ export default class DefaultSlideForm extends React.Component {
- 缴纳类型 + 缴纳类型 - 方案名称 + 方案名称 { diff --git a/pc4mobx/hrmSalary/pages/taxAgent/editModal.js b/pc4mobx/hrmSalary/pages/taxAgent/editModal.js index 0592aab8..52d382c4 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/editModal.js +++ b/pc4mobx/hrmSalary/pages/taxAgent/editModal.js @@ -2,6 +2,7 @@ import React from 'react' import { Button, Modal, Row, Col, message } from 'antd'; import { WeaTextarea, WeaInput } from "ecCom"; import { logColumns, dataSource } from "../../common/columns" +import RequiredLabelTip from "../../components/requiredLabelTip" export default class EditModal extends React.Component { constructor(props) { @@ -28,7 +29,7 @@ export default class EditModal extends React.Component { } submitAdd() { - if(this.validate) { + if(this.validate()) { this.props.onSubmitAdd({name: this.state.name, description: this.state.remark}) } } @@ -48,7 +49,7 @@ export default class EditModal extends React.Component { > -
名称:
+
名称:
-
名称:
+
名称:
{this.addItem()}} onDataSourceChange={setDataSource} editable={this.state.editable} diff --git a/pc4mobx/hrmSalary/stores/ledger.js b/pc4mobx/hrmSalary/stores/ledger.js index 63f34eee..04b3198d 100644 --- a/pc4mobx/hrmSalary/stores/ledger.js +++ b/pc4mobx/hrmSalary/stores/ledger.js @@ -4,6 +4,7 @@ import { WeaForm, WeaTableNew } from 'comsMobx'; import * as API from '../apis/ledger'; // 引入API接口文件 import { tempateColumns } from '../pages/payroll/columns'; +import { notNull } from '../util/validate'; const { TableStore } = WeaTableNew; @@ -103,6 +104,10 @@ export class LedgerStore { @action addItemGroup = name => { + if(!name || name == "" || name.trim() == "") { + message.warning("分类名称不能为空") + return + } let itemGroups = [...this.itemGroups] let flag = false; itemGroups.map(item => { @@ -253,9 +258,57 @@ export class LedgerStore { }) } + validateBaseFrom(params) { + if(!notNull(params.name)) { + message.warning("名称不能为空"); + return false + } + + if(!notNull(params.taxableItems)) { + message.warning("薪资类型不能为空"); + return false + } + + if(!notNull(params.salaryCycleType)) { + message.warning("薪资周期不能为空"); + return false + } + + if(!notNull(params.salaryCycleFromDay)) { + message.warning("薪资周期不能为空"); + return false + } + + if(!notNull(params.taxCycleType)) { + message.warning("税款所属期不能为空"); + return false + } + + if(!notNull(params.attendCycleType)) { + message.warning("考勤周期不能为空"); + return false + } + + if(!notNull(params.attendCycleFromDay)) { + message.warning("考勤周期不能为空"); + return false + } + + if(!notNull(params.socialSecurityCycleType)) { + message.warning("福利台账月份不能为空"); + return false + } + + return true + } + + //保存薪资帐套基本信息 @action saveLedgerBasic = (params) => { + if(!this.validateBaseFrom(params)) { + return + } return new Promise((resolve, reject) => { API.saveLedgerBasic(params).then(res => { if(res.status) { @@ -285,9 +338,30 @@ export class LedgerStore { }) } + validateLedgerPersonRange(params) { + if(!notNull(params.includeType)) { + message.warning("对象类型不能为空") + return false + } + + if(!notNull(params.targetParams)) { + message.warning("对象类型不能为空") + return false + } + + if(!notNull(params.employeeStatus)) { + message.warning("选择员工状态不能为空") + return false + } + return true + } + //保存薪资帐套人员范围 @action saveLedgerPersonRange = (params) => { + if(!this.validateLedgerPersonRange(params)) { + return + } API.saveLedgerPersonRange(params).then(res => { if(res.status) { if(this.includeType == 1) { diff --git a/pc4mobx/hrmSalary/stores/programme.js b/pc4mobx/hrmSalary/stores/programme.js index 40592019..35ddd247 100644 --- a/pc4mobx/hrmSalary/stores/programme.js +++ b/pc4mobx/hrmSalary/stores/programme.js @@ -4,6 +4,7 @@ import { WeaForm, WeaTableNew } from 'comsMobx'; import * as API from '../apis/welfareScheme'; // 引入API接口文件 import * as CumAPI from '../apis/cumDeduct' +import { notNull } from '../util/validate'; const { TableStore } = WeaTableNew; @@ -141,7 +142,23 @@ export class ProgrammeStore { }) } + valideForm(params) { + if(!notNull(params.insuranceScheme.paymentArea)) { + message.warning("缴纳类型不能为空") + return false + } + + if(!notNull(params.insuranceScheme.schemeName)) { + message.warning("方案名称不能为空") + return false + } + return true; + } + @action createScheme = (params) => { + if(!this.valideForm(params)) { + return + } API.createScheme(params).then(res => { if(res.status) { message.success("新建成功"); @@ -153,6 +170,9 @@ export class ProgrammeStore { } @action updateScheme = (params) => { + if(!this.valideForm()) { + return + } API.updateScheme(params).then(res => { if(res.status) { message.success("更新成功"); @@ -189,8 +209,24 @@ export class ProgrammeStore { }) } + validateCustomRequest() { + let flag = true; + this.formCondition.forEach(item => { + if(item.rules == "required") { + if(!notNull(this.customRequest[item.domkey[0]])) { + message.warning(item.label + "不能为空") + flag = false + } + } + }) + return flag; + } + // 新增自定义福利 @action createSICategory = (params) => { + if(!this.validateCustomRequest()) { + return + } return new Promise((resolve, reject) => { API.createSICategory(params).then(res => { if(res.status) { diff --git a/pc4mobx/hrmSalary/stores/salaryFile.js b/pc4mobx/hrmSalary/stores/salaryFile.js index 904b4fd8..306bc011 100644 --- a/pc4mobx/hrmSalary/stores/salaryFile.js +++ b/pc4mobx/hrmSalary/stores/salaryFile.js @@ -19,6 +19,7 @@ export class salaryFileStore { @observable previewDataSource = []; @observable dataSource = []; @observable detailForm= {} + @observable salaryArchiveTaxAgentForm = {} // 初始化操作 @@ -154,4 +155,21 @@ export class salaryFileStore { }) } + // 调整-义务扣缴人-调整表单 + @action + getTaxAgentForm = (salaryArchiveId) => { + return new Promise((resolve, reject) => { + API.getTaxAgentForm({salaryArchiveId}).then(res => { + if(res.status) { + this.salaryArchiveTaxAgentForm = res.data.salaryArchiveTaxAgentForm + resolve() + } else { + message.error(res.errormsg || "获取失败") + reject() + } + }) + }) + + } + } \ No newline at end of file diff --git a/pc4mobx/hrmSalary/stores/salaryItem.js b/pc4mobx/hrmSalary/stores/salaryItem.js index 7c4711fe..3e09bc92 100644 --- a/pc4mobx/hrmSalary/stores/salaryItem.js +++ b/pc4mobx/hrmSalary/stores/salaryItem.js @@ -3,6 +3,7 @@ import { message } from 'antd'; import { WeaForm, WeaTableNew } from 'comsMobx'; import * as API from '../apis/item'; // 引入API接口文件 +import {notNull} from '../util/validate' const { TableStore } = WeaTableNew; @@ -135,7 +136,7 @@ export class SalaryItemStore { getItemForm = (id) => { API.getItemForm(id).then(res => { if(res.status) { - this.request = res.data + this.request = res.data.map(item => item.toString()) } else { message.error(res.errormsg || '获取失败') } @@ -188,9 +189,40 @@ export class SalaryItemStore { }) } + validateForm(params) { + if(!notNull(params.name)) { + message.warning("名称不能为空") + return false; + } + + if(!notNull(params.dataType)) { + message.warning("字段类型不能为空") + return false; + } + + if(!notNull(params.roundingMode)) { + message.warning("舍入规则不能为空") + return false; + } + + if(!notNull(params.pattern)) { + message.warning("保留小数位不能为空") + return false; + } + + if(!notNull(params.valueType)) { + message.warning("取值方式不能为空") + return false; + } + return true + } + //薪资项目-新增薪资项目 @action saveItem = (params, continueFlag) => { + if(!this.validateForm(params)) { + return + } API.saveItem(params).then(res => { if(res.status) { if(!continueFlag) { @@ -204,7 +236,4 @@ export class SalaryItemStore { } }) } - - - } \ No newline at end of file diff --git a/pc4mobx/hrmSalary/stores/taxRate.js b/pc4mobx/hrmSalary/stores/taxRate.js index 76b9ddcd..fc3c4cd7 100644 --- a/pc4mobx/hrmSalary/stores/taxRate.js +++ b/pc4mobx/hrmSalary/stores/taxRate.js @@ -89,6 +89,10 @@ export class taxRateStore { }, taxRateRecords: this.dataSource } + if(!params.name || params.name == "" ) { + message.warning("名称不能为空") + return + } API.saveTaxRate(params).then(res => { if(res.status) { message.success("保存成功"); @@ -131,6 +135,11 @@ export class taxRateStore { }, taxRateRecords: this.dataSource } + + if(!params.name || params.name == "") { + message.warning("名称不能为空") + return + } API.updateTaxRate(params).then(res => { if(res.status) { message.success("保存成功"); diff --git a/pc4mobx/hrmSalary/style/index.less b/pc4mobx/hrmSalary/style/index.less index 7e0ea59f..92ab7c56 100644 --- a/pc4mobx/hrmSalary/style/index.less +++ b/pc4mobx/hrmSalary/style/index.less @@ -28,3 +28,4 @@ white-space: nowrap; overflow: hidden; } + diff --git a/pc4mobx/hrmSalary/util/validate.js b/pc4mobx/hrmSalary/util/validate.js new file mode 100644 index 00000000..5c0391fc --- /dev/null +++ b/pc4mobx/hrmSalary/util/validate.js @@ -0,0 +1,12 @@ +export const notNull = (name) => { + if(typeof(name) == "string") { + name = name.trim() + } + if(name !== undefined) { + name = name.toString() + } + if(!name || name == "") { + return false + } + return true +} \ No newline at end of file