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