2022-06-27 10:35:39 +08:00
|
|
|
|
import React from "react";
|
2022-10-20 17:53:26 +08:00
|
|
|
|
import { WeaFormItem, WeaInput, WeaSearchGroup, WeaSelect } from "ecCom";
|
2022-06-27 10:35:39 +08:00
|
|
|
|
import { inject, observer } from "mobx-react";
|
2022-12-07 14:15:46 +08:00
|
|
|
|
import { getReplenishRuleSetOptions } from "../../../apis/payroll";
|
2022-10-20 17:53:26 +08:00
|
|
|
|
import { toJS } from "mobx";
|
2022-03-18 14:16:52 +08:00
|
|
|
|
|
2022-06-27 10:35:39 +08:00
|
|
|
|
@inject("payrollStore")
|
2022-04-13 16:56:31 +08:00
|
|
|
|
@observer
|
2022-03-18 14:16:52 +08:00
|
|
|
|
export default class BaseInformForm extends React.Component {
|
2022-06-27 10:35:39 +08:00
|
|
|
|
constructor(props) {
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
this.state = {
|
|
|
|
|
|
inited: false,
|
|
|
|
|
|
options: [],
|
2022-12-07 14:15:46 +08:00
|
|
|
|
replenishRuleOptions: [],
|
2022-06-27 10:35:39 +08:00
|
|
|
|
request: {}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2022-09-13 16:39:15 +08:00
|
|
|
|
|
2022-06-27 10:35:39 +08:00
|
|
|
|
componentWillMount() {
|
|
|
|
|
|
const { payrollStore } = this.props;
|
|
|
|
|
|
const { getPayrollBaseForm } = payrollStore;
|
2022-12-23 17:30:59 +08:00
|
|
|
|
const templateBaseData = window.localStorage.getItem("template-basedata") || "{}";
|
2022-06-27 10:35:39 +08:00
|
|
|
|
getPayrollBaseForm(this.props.id).then(data => {
|
|
|
|
|
|
this.setState(
|
|
|
|
|
|
{
|
2022-12-07 14:15:46 +08:00
|
|
|
|
replenishRuleOptions: _.map(data.replenishRuleSetOption, it => ({ key: it.id, showname: it.content })),
|
2022-09-13 16:39:15 +08:00
|
|
|
|
options: _.isEmpty(toJS(data.salarySobOptions)) ? [{ key: "", showname: "" }] : [{
|
|
|
|
|
|
key: "",
|
|
|
|
|
|
showname: ""
|
|
|
|
|
|
}, ...toJS(data.salarySobOptions)],
|
2022-12-07 14:15:46 +08:00
|
|
|
|
request: {
|
|
|
|
|
|
...data.templateBaseData,
|
|
|
|
|
|
reissueRule: data.templateBaseData.replenishRule ? "1" : "0",
|
|
|
|
|
|
...JSON.parse(templateBaseData)
|
|
|
|
|
|
}
|
|
|
|
|
|
}, () => {
|
|
|
|
|
|
this.props.onChange && this.props.onChange(this.state.request);
|
2022-06-27 10:35:39 +08:00
|
|
|
|
this.setState({
|
|
|
|
|
|
inited: true
|
|
|
|
|
|
});
|
2022-04-13 16:56:31 +08:00
|
|
|
|
}
|
2022-06-27 10:35:39 +08:00
|
|
|
|
);
|
|
|
|
|
|
});
|
2022-12-07 15:14:20 +08:00
|
|
|
|
JSON.parse(templateBaseData).salarySob && this.getReplenishRuleSetOptions({ salarySobId: JSON.parse(templateBaseData).salarySob });
|
2022-06-27 10:35:39 +08:00
|
|
|
|
}
|
2022-04-13 16:56:31 +08:00
|
|
|
|
|
2022-12-07 14:15:46 +08:00
|
|
|
|
hanldeChange = (params) => {
|
2022-06-27 10:35:39 +08:00
|
|
|
|
let request = { ...this.state.request, ...params };
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
request
|
2022-12-07 14:15:46 +08:00
|
|
|
|
}, () => {
|
|
|
|
|
|
if (this.state.request.reissueRule === "1" && this.state.request.salarySob) {
|
|
|
|
|
|
// TODO:获取规则设置枚举项
|
|
|
|
|
|
this.getReplenishRuleSetOptions();
|
|
|
|
|
|
}
|
2022-06-27 10:35:39 +08:00
|
|
|
|
});
|
|
|
|
|
|
this.props.onChange && this.props.onChange(request);
|
2022-12-07 14:15:46 +08:00
|
|
|
|
};
|
2022-12-07 15:14:20 +08:00
|
|
|
|
getReplenishRuleSetOptions = (params = {}) => {
|
2022-12-07 14:15:46 +08:00
|
|
|
|
const { request } = this.state;
|
2022-12-07 15:14:20 +08:00
|
|
|
|
getReplenishRuleSetOptions({ salarySobId: request.salarySob, ...params }).then(({ status, data }) => {
|
2022-12-07 14:15:46 +08:00
|
|
|
|
if (status && !_.isEmpty(data)) {
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
replenishRuleOptions: _.map(data, it => ({ key: it.id, showname: it.content }))
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2022-05-05 15:53:35 +08:00
|
|
|
|
|
2022-06-27 10:35:39 +08:00
|
|
|
|
render() {
|
2022-12-07 14:15:46 +08:00
|
|
|
|
const { request, options, replenishRuleOptions } = this.state;
|
|
|
|
|
|
const { salarySob, name, description, replenishName, replenishRule, reissueRule } = request;
|
|
|
|
|
|
|
2022-06-27 10:35:39 +08:00
|
|
|
|
return (
|
2022-12-07 14:15:46 +08:00
|
|
|
|
<WeaSearchGroup title="基础信息" items={[]} needTigger showGroup col={1}>
|
2022-10-20 17:53:26 +08:00
|
|
|
|
<WeaFormItem
|
|
|
|
|
|
label="薪资账套"
|
|
|
|
|
|
labelCol={{ span: 6 }}
|
|
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{
|
|
|
|
|
|
this.state.inited &&
|
|
|
|
|
|
<WeaSelect
|
|
|
|
|
|
viewAttr={3}
|
|
|
|
|
|
options={options}
|
|
|
|
|
|
value={salarySob ? salarySob : ""}
|
2022-12-02 14:27:39 +08:00
|
|
|
|
style={{ width: 200 }}
|
2022-10-20 17:53:26 +08:00
|
|
|
|
onChange={value => this.hanldeChange({ salarySob: value })}/>
|
|
|
|
|
|
}
|
|
|
|
|
|
</WeaFormItem>
|
|
|
|
|
|
<WeaFormItem
|
|
|
|
|
|
label="工资单模板名称"
|
|
|
|
|
|
labelCol={{ span: 6 }}
|
|
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<WeaInput
|
|
|
|
|
|
value={name}
|
|
|
|
|
|
viewAttr={3}
|
|
|
|
|
|
onChange={value => this.hanldeChange({ name: value })}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</WeaFormItem>
|
2022-12-06 15:04:57 +08:00
|
|
|
|
<WeaFormItem
|
|
|
|
|
|
label="补发工资单模板名称"
|
|
|
|
|
|
labelCol={{ span: 6 }}
|
|
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<WeaInput
|
2022-12-07 14:15:46 +08:00
|
|
|
|
value={replenishName}
|
2022-12-06 15:04:57 +08:00
|
|
|
|
viewAttr={3}
|
2022-12-07 14:15:46 +08:00
|
|
|
|
onChange={value => this.hanldeChange({ replenishName: value })}
|
2022-12-06 15:04:57 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</WeaFormItem>
|
|
|
|
|
|
<WeaFormItem
|
|
|
|
|
|
label="补发工资单名单生成规则"
|
|
|
|
|
|
labelCol={{ span: 6 }}
|
|
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<WeaSelect
|
2022-12-07 14:15:46 +08:00
|
|
|
|
options={[{ key: "0", showname: "全部" }, { key: "1", showname: "按规则" }]}
|
|
|
|
|
|
value={reissueRule}
|
2022-12-06 15:04:57 +08:00
|
|
|
|
detailtype={3}
|
|
|
|
|
|
viewAttr={3}
|
2022-12-07 14:15:46 +08:00
|
|
|
|
onChange={value => this.hanldeChange({ reissueRule: value })}
|
2022-12-06 15:04:57 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</WeaFormItem>
|
2022-12-07 14:15:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
reissueRule !== "0" &&
|
|
|
|
|
|
<WeaFormItem
|
|
|
|
|
|
label="规则设置"
|
|
|
|
|
|
labelCol={{ span: 6 }}
|
|
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<WeaSelect
|
|
|
|
|
|
options={replenishRuleOptions}
|
|
|
|
|
|
value={replenishRule}
|
|
|
|
|
|
viewAttr={3}
|
|
|
|
|
|
onChange={value => this.hanldeChange({ replenishRule: value })}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</WeaFormItem>
|
|
|
|
|
|
}
|
2022-10-20 17:53:26 +08:00
|
|
|
|
<WeaFormItem
|
|
|
|
|
|
label="备注"
|
|
|
|
|
|
labelCol={{ span: 6 }}
|
|
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<WeaInput
|
|
|
|
|
|
value={description}
|
|
|
|
|
|
onChange={value => this.hanldeChange({ description: value })}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</WeaFormItem>
|
|
|
|
|
|
</WeaSearchGroup>
|
2022-06-27 10:35:39 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|