自定义福利编辑
This commit is contained in:
parent
7c07f6c591
commit
3ee405ec39
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,12 @@ export default class CustomForm extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { request } = this.props;
|
||||
const { request, disable } = this.props;
|
||||
return (
|
||||
<div style={{padding: "20px"}}>
|
||||
{
|
||||
this.props.condition.map(item => {
|
||||
let disabledValue = disable && disable.indexOf(item.domkey[0]) >= 0
|
||||
return (
|
||||
<Row style={{lineHeight: "40px"}}>
|
||||
<Col span={6}>
|
||||
|
|
@ -25,12 +26,14 @@ export default class CustomForm extends React.Component {
|
|||
<Col span={18}>
|
||||
{
|
||||
item.conditionType == "INPUT" &&
|
||||
<WeaInput value={request[item.domkey[0]]} onChange={(value) => {this.handleChange({[item.domkey[0]]: value})}}/>
|
||||
<WeaInput value={request[item.domkey[0]]} disabled={disabledValue} onChange={(value) => {this.handleChange({[item.domkey[0]]: value})}}/>
|
||||
}
|
||||
|
||||
{
|
||||
item.conditionType == "RADIO" && item.options &&
|
||||
<Radio.Group onChange={(e) => this.handleChange({[item.domkey[0]]: e.target.value})}>
|
||||
<Radio.Group value={request[item.domkey[0]]}
|
||||
disabled={disabledValue}
|
||||
onChange={(e) => this.handleChange({[item.domkey[0]]: e.target.value})}>
|
||||
{
|
||||
item.options.map(o => (
|
||||
<Radio value={o.key}>{o.showname}</Radio>
|
||||
|
|
@ -42,7 +45,9 @@ export default class CustomForm extends React.Component {
|
|||
{
|
||||
item.conditionType == "CHECKBOX" &&
|
||||
item.options &&
|
||||
<CheckboxGroup options={item.options.map(o => ({label: o.showname, value: o.key}))} onChange={(value) => this.handleChange({[item.domkey[0]]: value}) }/>
|
||||
<CheckboxGroup
|
||||
disabled={disabledValue}
|
||||
value={request[item.domkey[0]]} options={item.options.map(o => ({label: o.showname, value: o.key}))} onChange={(value) => this.handleChange({[item.domkey[0]]: value}) }/>
|
||||
}
|
||||
</Col>
|
||||
</Row>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Modal visible={this.props.visible} onCancel={() => {this.props.onCancel()}} title="新建自定义福利" onOk={() => {this.handleOK()}}>
|
||||
{/* {getCustomSearchs(this.props.form, toJS(this.props.condition), 1)} */}
|
||||
<CustomForm condition={this.props.condition} request={customRequest} onChange={(value) => {setCustomRequest(value)}}/>
|
||||
<CustomForm condition={this.props.condition} disable={this.props.edit ? ['paymentScope', 'welfareType'] : null} request={customRequest} onChange={(value) => {setCustomRequest(value)}}/>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
export const paymentScopeEnum = {
|
||||
1: "SCOPE_COMPANY",
|
||||
2: "SCOPE_PERSON"
|
||||
}
|
||||
|
||||
export const welfareTypeEnum = {
|
||||
1: "SOCIAL_SECURITY",
|
||||
2: "ACCUMULATION_FUND",
|
||||
3: "OTHER"
|
||||
}
|
||||
|
|
@ -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)}}
|
||||
/>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 || "编辑失败")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue