From 3ee405ec393eeb21867e55c1a46ff5508be93645 Mon Sep 17 00:00:00 2001
From: MustangDeng <670124965@qq.com>
Date: Fri, 1 Apr 2022 15:02:18 +0800
Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=A6=8F=E5=88=A9?=
=?UTF-8?q?=E7=BC=96=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pc4mobx/hrmSalary/apis/welfareScheme.js | 11 +++++-
.../hrmSalary/components/customForm/index.js | 13 +++++--
.../programme/customNewModal.js | 15 +++++--
.../socialSecurityBenefits/programme/enum.js | 10 +++++
.../socialSecurityBenefits/programme/index.js | 18 ++++++++-
pc4mobx/hrmSalary/stores/programme.js | 39 +++++++++++++++----
6 files changed, 86 insertions(+), 20 deletions(-)
create mode 100644 pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/enum.js
diff --git a/pc4mobx/hrmSalary/apis/welfareScheme.js b/pc4mobx/hrmSalary/apis/welfareScheme.js
index 3d5aa4e0..d7adb154 100644
--- a/pc4mobx/hrmSalary/apis/welfareScheme.js
+++ b/pc4mobx/hrmSalary/apis/welfareScheme.js
@@ -46,12 +46,19 @@ export const createSICategory = params => {
mode: 'cors',
headers: {
'Content-Type': 'application/json'
- },
+ },
body: JSON.stringify(params)
}).then(res => res.json())
};
export const updateCustomCategory = params => {
- return WeaTools.callApi('/api/bs/hrmsalary/sicategory/updateCustomCategory', 'post', params);
+ return fetch('/api/bs/hrmsalary/sicategory/updateCustomCategory', {
+ method: 'POST',
+ mode: 'cors',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(params)
+ }).then(res => res.json())
};
export const deleteCustomCategory = params => {
return WeaTools.callApi('/api/bs/hrmsalary/sicategory/deleteCustomCategory', 'post', params);
diff --git a/pc4mobx/hrmSalary/components/customForm/index.js b/pc4mobx/hrmSalary/components/customForm/index.js
index ddc675bd..41d753ff 100644
--- a/pc4mobx/hrmSalary/components/customForm/index.js
+++ b/pc4mobx/hrmSalary/components/customForm/index.js
@@ -12,11 +12,12 @@ export default class CustomForm extends React.Component {
}
render() {
- const { request } = this.props;
+ const { request, disable } = this.props;
return (
{
this.props.condition.map(item => {
+ let disabledValue = disable && disable.indexOf(item.domkey[0]) >= 0
return (
@@ -25,12 +26,14 @@ export default class CustomForm extends React.Component {
{
item.conditionType == "INPUT" &&
- {this.handleChange({[item.domkey[0]]: value})}}/>
+ {this.handleChange({[item.domkey[0]]: value})}}/>
}
{
item.conditionType == "RADIO" && item.options &&
- this.handleChange({[item.domkey[0]]: e.target.value})}>
+ this.handleChange({[item.domkey[0]]: e.target.value})}>
{
item.options.map(o => (
{o.showname}
@@ -42,7 +45,9 @@ export default class CustomForm extends React.Component {
{
item.conditionType == "CHECKBOX" &&
item.options &&
- ({label: o.showname, value: o.key}))} onChange={(value) => this.handleChange({[item.domkey[0]]: value}) }/>
+ ({label: o.showname, value: o.key}))} onChange={(value) => this.handleChange({[item.domkey[0]]: value}) }/>
}
diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js
index 6f57a4b2..1e4d920d 100644
--- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js
+++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/customNewModal.js
@@ -13,9 +13,16 @@ export default class CustomNewModal extends React.Component {
}
handleOK() {
- const { programmeStore: {createSICategory, setCustomRequest, customRequest}} = this.props;
- createSICategory(customRequest)
- this.props.onCancel()
+ const { programmeStore: {createSICategory, setCustomRequest, customRequest, updateCustomCategory}} = this.props;
+ if(!this.props.edit) { // 新增
+ createSICategory(customRequest).then(() => {
+ this.props.onCancel()
+ })
+ } else {
+ updateCustomCategory(customRequest).then(() => {
+ this.props.onCancel()
+ })
+ }
}
render() {
@@ -23,7 +30,7 @@ export default class CustomNewModal extends React.Component {
return (
{this.props.onCancel()}} title="新建自定义福利" onOk={() => {this.handleOK()}}>
{/* {getCustomSearchs(this.props.form, toJS(this.props.condition), 1)} */}
- {setCustomRequest(value)}}/>
+ {setCustomRequest(value)}}/>
)
}
diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/enum.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/enum.js
new file mode 100644
index 00000000..cd653e53
--- /dev/null
+++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/enum.js
@@ -0,0 +1,10 @@
+export const paymentScopeEnum = {
+ 1: "SCOPE_COMPANY",
+ 2: "SCOPE_PERSON"
+}
+
+export const welfareTypeEnum = {
+ 1: "SOCIAL_SECURITY",
+ 2: "ACCUMULATION_FUND",
+ 3: "OTHER"
+}
\ No newline at end of file
diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js
index a90287ef..a7097026 100644
--- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js
+++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js
@@ -18,6 +18,7 @@ import SlideModalTitle from '../../../components/slideModalTitle';
import TipLabel from '../../../components/TipLabel'
import DefaultSlideForm from './defaultSlideForm'
import CustomNewModal from './customNewModal'
+import { welfareTypeEnum, paymentScopeEnum } from './enum';
import {
@@ -44,7 +45,8 @@ export default class Programme extends React.Component {
currentOperate: "add",
copyModalValue: "",
copyId: "",
- customNewVisible: false
+ customNewVisible: false,
+ customEdit: false
}
}
@@ -146,8 +148,18 @@ export default class Programme extends React.Component {
onCustomEdit(record) {
const { programmeStore: {getCustomForm, setCustomNewVisible, setCustomRequest}} = this.props;
+ getCustomForm()
setCustomNewVisible(true)
- setCustomRequest(record)
+ this.setState({
+ customEdit: true
+ })
+ setCustomRequest({
+ insuranceName: record['insurance_name'],
+ id: record.id,
+ isUse: record.is_use,
+ paymentScope: record.payment_scope.split(",").map(item => paymentScopeEnum[item]),
+ welfareType: welfareTypeEnum[record.welfare_type]
+ })
}
render() {
@@ -230,6 +242,7 @@ export default class Programme extends React.Component {
getCustomForm()
setCustomRequest({})
setCustomNewVisible(true)
+ this.setState({customEdit: false})
}
@@ -399,6 +412,7 @@ export default class Programme extends React.Component {
visible={customNewVisible}
condition={formCondition}
form={form}
+ edit={this.state.customEdit}
onCancel={() => {setCustomNewVisible(false)}}
/>
}
diff --git a/pc4mobx/hrmSalary/stores/programme.js b/pc4mobx/hrmSalary/stores/programme.js
index 072d8bfd..40592019 100644
--- a/pc4mobx/hrmSalary/stores/programme.js
+++ b/pc4mobx/hrmSalary/stores/programme.js
@@ -191,20 +191,24 @@ export class ProgrammeStore {
// 新增自定义福利
@action createSICategory = (params) => {
- API.createSICategory(params).then(res => {
- if(res.status) {
- message.success("新增成功")
- this.getCustomCategoryList()
- } else {
- message.error(res.errormsg || "新增失败")
- }
+ return new Promise((resolve, reject) => {
+ API.createSICategory(params).then(res => {
+ if(res.status) {
+ message.success("新增成功")
+ resolve()
+ this.getCustomCategoryList()
+ } else {
+ reject()
+ message.error(res.errormsg || "新增失败")
+ }
+ })
})
+
}
// 自定义福利启用、停用
@action
updateCustomCategoryStatus = (id, isUse) => {
-
let params = {
id,
isUse: isUse ? 1 : 0
@@ -219,4 +223,23 @@ export class ProgrammeStore {
})
}
+ // 自定义福利编辑
+ @action
+ updateCustomCategory = (params) => {
+ return new Promise((resolve, reject) => {
+ API.updateCustomCategory(params).then(res => {
+ if(res.status) {
+ message.success("编辑成功")
+ resolve()
+ this.getCustomCategoryList()
+ } else {
+ reject()
+ message.error(res.errormsg || "编辑失败")
+ }
+ })
+ })
+
+ }
+
+
}
\ No newline at end of file