salary-management-front/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js

478 lines
15 KiB
JavaScript
Raw Normal View History

2022-06-17 16:53:27 +08:00
import React from "react";
import { inject, observer } from "mobx-react";
import { toJS } from "mobx";
import { Button, Dropdown, Menu, message, Modal } from "antd";
import { WeaLocaleProvider, WeaNewScroll, WeaSelect, WeaSlideModal, WeaTop } from "ecCom";
import { renderNoright } from "../../../util";
2022-06-17 16:53:27 +08:00
import CustomTab from "../../../components/customTab";
import SlideModalTitle from "../../../components/slideModalTitle";
import TipLabel from "../../../components/TipLabel";
import DefaultSlideForm from "./defaultSlideForm";
import CustomNewModal from "./customNewModal";
2022-07-28 17:16:40 +08:00
import { paymentScopeEnum, welfareTypeEnum } from "./enum";
2022-06-17 16:53:27 +08:00
import CustomPaginationTable from "../../../components/customPaginationTable";
2022-07-28 17:16:40 +08:00
import TwoColContent from "../../../components/twoColContent";
import CopySchemaModal from "./copySchemaModal";
import CustomBenefitsTable from "./customBenefitsTable";
import "./index.less";
2022-02-25 09:24:56 +08:00
const { getLabel } = WeaLocaleProvider;
2022-08-25 17:54:18 +08:00
@inject("programmeStore", "taxAgentStore", "salaryFileStore")
2022-02-25 09:24:56 +08:00
@observer
export default class Programme extends React.Component {
constructor(props) {
super(props);
this.state = {
value: "",
searchValue: "",
2022-03-21 17:43:26 +08:00
slideVisiable: false,
2022-03-21 19:54:16 +08:00
currentOperate: "add",
copyModalValue: "",
copyId: "",
2022-04-01 15:02:18 +08:00
customNewVisible: false,
customEdit: false
2022-06-17 16:53:27 +08:00
};
2022-06-07 09:08:36 +08:00
2022-06-17 16:53:27 +08:00
this.pageInfo = { current: 1, pageSize: 10 };
2022-02-25 09:24:56 +08:00
}
2022-03-12 17:07:11 +08:00
componentWillMount() {
2023-02-13 16:38:15 +08:00
const { programmeStore, salaryFileStore, taxAgentStore } = this.props;
2022-06-17 16:53:27 +08:00
const { doInit } = programmeStore;
2022-03-12 17:07:11 +08:00
doInit();
2022-08-25 17:54:18 +08:00
const { commonEnumList } = salaryFileStore;
commonEnumList("user", { enumClass: "com.engine.salary.enums.sicategory.SharedTypeEnum" });
2023-02-13 16:38:15 +08:00
const { getTaxAgentSelectListAsAdmin } = taxAgentStore;
getTaxAgentSelectListAsAdmin();
2022-03-12 17:07:11 +08:00
}
2022-03-21 19:54:16 +08:00
// 增加编辑功能重写columns绑定事件
2022-06-17 16:53:27 +08:00
getColumns = columns => {
2023-02-15 14:18:20 +08:00
const { taxAgentStore: { showOperateBtn } } = this.props;
2022-06-17 16:53:27 +08:00
let newColumns = columns.filter(
item => item.dataIndex !== "id" && item.dataIndex !== "paymentArea"
);
2022-04-22 17:00:10 +08:00
newColumns = newColumns.map(column => {
2022-03-21 19:54:16 +08:00
let newColumn = column;
newColumn.render = (text, record) => {
2022-06-17 16:53:27 +08:00
//前端元素转义
let valueSpan =
record[newColumn.dataIndex + "span"] !== undefined
? record[newColumn.dataIndex + "span"]
: record[newColumn.dataIndex];
if (newColumn.dataIndex === "id") newColumn.display = false;
2022-06-17 16:53:27 +08:00
switch (newColumn.dataIndex) {
2022-03-21 19:54:16 +08:00
case "operate":
2022-06-17 16:53:27 +08:00
return (
<a href="javascript: void(0);" onClick={() => this.onEdit(record)}>编辑</a>
2022-06-17 16:53:27 +08:00
);
2022-03-21 19:54:16 +08:00
default:
2022-07-28 17:16:40 +08:00
return <div dangerouslySetInnerHTML={{ __html: valueSpan }}/>;
2022-03-21 19:54:16 +08:00
}
2022-06-17 16:53:27 +08:00
};
2022-03-21 19:54:16 +08:00
return newColumn;
});
2022-04-22 17:00:10 +08:00
newColumns.push({
title: "操作",
dataIndex: "operate",
width: 120,
2022-04-22 17:00:10 +08:00
render: (text, record) => {
2022-06-17 16:53:27 +08:00
return (
<React.Fragment>
<a href="javascript:void(0);" onClick={() => this.onEdit(record)}
style={{ marginRight: 10 }}>{showOperateBtn ? "编辑" : "查看"}</a>
{
showOperateBtn &&
<a href="javascript:void(0)" onClick={() => this.onCopy(record)}
style={{ marginRight: 10 }}>{getLabel(77, "复制")}</a>
}
{
showOperateBtn &&
<Dropdown
overlay={
<Menu>
<Menu.Item>
<a href="javascript:void(0)" onClick={() => this.onDelete(record)}>{getLabel(535052, "删除")}</a>
</Menu.Item>
</Menu>
}>
<a href="javascript:void(0)"><i className="icon-coms-more"/></a>
</Dropdown>
}
</React.Fragment>
2022-06-17 16:53:27 +08:00
);
}
});
2022-03-21 19:54:16 +08:00
return newColumns;
2022-06-17 16:53:27 +08:00
};
2022-03-21 19:54:16 +08:00
onEdit = (record) => {
2022-03-21 19:54:16 +08:00
let id = record.id;
2022-06-17 16:53:27 +08:00
const { programmeStore } = this.props;
const { getForm, selectedKey } = programmeStore;
2022-03-21 19:54:16 +08:00
getForm({
welfareTypeEnum: selectedKey,
id
2023-02-13 16:38:15 +08:00
}).then(() => {
this.setState({ slideVisiable: true, customEdit: true, currentOperate: "update" });
2022-06-17 16:53:27 +08:00
});
};
2022-03-21 19:54:16 +08:00
onCopy = (record) => {
2022-03-21 19:54:16 +08:00
this.setState({
copyId: record.id,
2022-07-28 17:16:40 +08:00
copyModalValue: record.schemeName,
2022-03-21 19:54:16 +08:00
copyModalVisible: true
2022-06-17 16:53:27 +08:00
});
};
2022-03-21 19:54:16 +08:00
2022-07-28 17:16:40 +08:00
onDelete = (record) => {
2022-08-25 17:54:18 +08:00
const { programmeStore: { deleteScheme, deleteLoading, selectedKey } } = this.props;
2022-07-28 17:16:40 +08:00
Modal.confirm({
title: "确认信息",
content: "确认删除本条数据吗?",
confirmLoading: deleteLoading,
onOk: () => {
2022-08-25 17:54:18 +08:00
deleteScheme({ ids: [record.id], welfareTypeEnum: selectedKey });
2022-07-28 17:16:40 +08:00
},
onCancel: () => {
}
});
};
onCustomEdit = (record) => {
2022-06-17 16:53:27 +08:00
const {
2022-06-21 17:35:19 +08:00
programmeStore: { getCustomForm, setCustomNewVisible, setCustomRequest },
taxAgentStore: { showOperateBtn }
2022-06-17 16:53:27 +08:00
} = this.props;
2022-07-28 17:16:40 +08:00
if (!showOperateBtn) {
2022-06-21 17:35:19 +08:00
message.warning("请设置编辑权限!");
return;
}
2022-06-17 16:53:27 +08:00
getCustomForm();
setCustomNewVisible(true);
2022-04-01 15:02:18 +08:00
this.setState({
customEdit: true
2022-06-17 16:53:27 +08:00
});
2022-04-01 15:02:18 +08:00
setCustomRequest({
insuranceName: record["insuranceName"],
2022-04-01 15:02:18 +08:00
id: record.id,
isUse: record.isUse,
2023-03-03 16:29:52 +08:00
paymentScope: record["paymentScope"].split(",").map(item => paymentScopeEnum[item]).join(","),
welfareType: welfareTypeEnum[record.welfareType]
2022-06-17 16:53:27 +08:00
});
};
2022-03-22 18:53:05 +08:00
2022-06-17 16:53:27 +08:00
// 页面跳转
handlePageChange(value) {
const { programmeStore: { form, getTableDatas, selectedKey } } = this.props;
this.pageInfo.current = value;
getTableDatas(selectedKey, this.pageInfo);
2022-05-18 17:10:12 +08:00
}
2022-03-12 17:07:11 +08:00
render() {
2022-06-21 11:33:00 +08:00
const { programmeStore, taxAgentStore: { showOperateBtn } } = this.props;
const { loading, hasRight, form, getTableDatas } = programmeStore;
2022-06-17 16:53:27 +08:00
const {
selectedKey,
setSelectedKey,
customSelectkey,
setCustomSelectkey,
requestParams,
setRequestParams,
formCondition,
setCustomNewVisible,
customNewVisible,
tableDataSource,
tableColumns,
tablePageInfo
} = programmeStore;
2023-02-13 10:41:40 +08:00
if (!hasRight && !loading) return renderNoright();
2022-02-25 09:24:56 +08:00
const topTab = [
2022-02-28 09:29:46 +08:00
{
title: "社保",
2022-03-12 17:07:11 +08:00
viewcondition: "SOCIAL_SECURITY"
2022-02-28 09:29:46 +08:00
},
{
title: "公积金",
2022-03-12 17:07:11 +08:00
viewcondition: "ACCUMULATION_FUND"
2022-02-28 09:29:46 +08:00
},
{
title: "企业年金及其他福利",
2022-03-12 17:07:11 +08:00
viewcondition: "OTHER"
2022-02-28 09:29:46 +08:00
},
{
title: "自定义福利",
2022-03-12 17:07:11 +08:00
viewcondition: "custom"
2022-02-28 09:29:46 +08:00
}
];
2022-02-25 09:24:56 +08:00
2022-06-17 16:53:27 +08:00
const options = [
2022-04-01 10:39:01 +08:00
{
showname: "全部",
key: ""
},
{
showname: "社保",
2022-06-17 16:53:27 +08:00
key: "SOCIAL_SECURITY"
},
{
showname: "公积金",
2022-06-17 16:53:27 +08:00
key: "ACCUMULATION_FUND"
},
{
showname: "企业年金及其他福利",
2022-03-21 19:54:16 +08:00
key: "OTHER"
}
2022-06-17 16:53:27 +08:00
];
2022-03-21 17:43:26 +08:00
const handleNewClick = () => {
2022-06-17 16:53:27 +08:00
const {
programmeStore: { initSlideParms, getForm, selectedKey }
} = this.props;
2022-03-28 10:53:19 +08:00
initSlideParms();
2022-06-17 16:53:27 +08:00
this.setState({ slideVisiable: true, currentOperate: "add" });
getForm({ welfareTypeEnum: selectedKey });
};
2022-03-21 17:43:26 +08:00
2022-03-22 16:53:39 +08:00
const handleCustomNewClick = () => {
2022-06-17 16:53:27 +08:00
const {
programmeStore: {
getCustomForm,
setCustomNewVisible,
setCustomRequest
}
} = this.props;
getCustomForm();
setCustomRequest({});
setCustomNewVisible(true);
this.setState({ customEdit: false });
};
2022-03-22 16:53:39 +08:00
2022-03-21 17:43:26 +08:00
const handleOnSave = () => {
2022-06-17 16:53:27 +08:00
const { programmeStore } = this.props;
const { currentOperate } = this.state;
const {
selectedKey,
defaultPersonDataSource,
defaultCompanyDataSource,
createScheme,
requestParams,
updateScheme
} = programmeStore;
2022-08-25 17:54:18 +08:00
let { schemeName, remarks, paymentArea, paymentType, sharedType, taxAgentIds } = requestParams;
2022-03-21 17:43:26 +08:00
let request = {
insuranceScheme: {
2022-05-18 17:10:12 +08:00
paymentType,
2022-03-21 17:43:26 +08:00
welfareType: selectedKey,
schemeName,
remarks,
2022-08-25 17:54:18 +08:00
paymentArea,
sharedType,
taxAgentIds
2022-03-21 17:43:26 +08:00
},
2022-06-17 16:53:27 +08:00
insuranceSchemeDetailList: [
...defaultPersonDataSource,
...defaultCompanyDataSource
]
};
if (currentOperate == "add") {
2022-08-25 17:54:18 +08:00
createScheme(request).then(res => {
if (res.status) this.setState({ slideVisiable: false });
});
2022-06-17 16:53:27 +08:00
} else if (currentOperate == "update") {
request.insuranceScheme.id = requestParams.id;
2022-08-25 17:54:18 +08:00
updateScheme(request).then(res => {
if (res.status) this.setState({ slideVisiable: false });
});
2022-03-21 17:43:26 +08:00
}
2022-06-17 16:53:27 +08:00
};
2022-02-25 09:24:56 +08:00
2022-03-12 17:07:11 +08:00
const renderCustomRightContent = () => {
let tipList = [
"1、可以为社保、公积金、企业年金及其他福利新增自定义的福利项残疾保险等",
"2、新增自定义福利默认启用社保福利方案中的自定义福利项均未开启缴纳当前页面的自定义福利项才可以停用停用后再新增方案时没有该福利项",
"3、自定义福利若要缴纳需要在方案里填写缴纳相关数据"
2022-06-17 16:53:27 +08:00
];
2022-07-28 17:16:40 +08:00
return <TipLabel tipList={tipList}/>;
2022-06-17 16:53:27 +08:00
};
2022-03-12 17:07:11 +08:00
2022-03-21 19:54:16 +08:00
const handleCopyModalSave = () => {
2022-06-17 16:53:27 +08:00
const { programmeStore: { copyScheme } } = this.props;
2022-03-21 19:54:16 +08:00
const { copyId, copyModalValue } = this.state;
if (_.isEmpty(this.refs.copyRef.state.value)) {
2022-09-09 10:29:12 +08:00
this.refs.copyRef.refs.weaError.showError();
} else {
copyScheme({ id: copyId, schemeName: copyModalValue }).then(() => {
this.setState({ copyModalVisible: false });
});
2022-09-09 10:29:12 +08:00
}
2022-06-17 16:53:27 +08:00
};
2022-03-21 19:54:16 +08:00
2022-03-28 10:53:19 +08:00
const handleSlideClose = () => {
2022-08-25 17:54:18 +08:00
this.setState({ slideVisiable: false, customEdit: false });
2022-06-17 16:53:27 +08:00
const { programmeStore: { initSlideParms } } = this.props;
initSlideParms();
};
2022-03-28 10:53:19 +08:00
2022-02-25 09:24:56 +08:00
return (
2023-02-13 10:41:40 +08:00
<div className="socialSecurityAndWelfareSchemeWrapper">
2022-12-01 14:28:30 +08:00
<WeaTop
title="社保福利方案" // 文字
icon={<i className="icon-coms-fa"/>} // 左侧图标
iconBgcolor="#F14A2D" // 左侧图标背景色
showDropIcon={false} // 是否显示下拉按钮
2023-02-13 10:41:40 +08:00
>
2022-12-01 14:28:30 +08:00
<CustomTab
topTab={topTab}
searchOperationItem={
<div>
{/* 操作按钮权限 */}
{showOperateBtn &&
<Button
type="primary"
style={{ marginRight: "10px" }}
onClick={() => {
if (selectedKey == "custom") {
handleCustomNewClick();
} else {
handleNewClick();
}
}}>
新建
</Button>}
2022-06-17 16:53:27 +08:00
2022-12-01 14:28:30 +08:00
{selectedKey == "custom" &&
<WeaSelect
options={options}
value={customSelectkey}
style={{ width: "150px" }}
onChange={v => {
setCustomSelectkey(v);
this.customBenefitsTableRef.getCustomCategoryList({ current: 1, welfareTypeEnum: v });
2022-12-01 14:28:30 +08:00
}}
/>}
</div>
}
onChange={v => {
setSelectedKey(v);
handleSlideClose();
if (v == "custom") {
// 自定义福利
} else {
getTableDatas(v);
2022-02-25 09:24:56 +08:00
}
2022-12-01 14:28:30 +08:00
}}
/>
2023-02-13 10:41:40 +08:00
<div className="tableWrapper">
<WeaNewScroll height="100%">
{selectedKey == "custom"
? <TwoColContent
leftContent={
<CustomBenefitsTable
ref={dom => this.customBenefitsTableRef = dom}
showOperateBtn={showOperateBtn}
welfareTypeEnum={customSelectkey}
onCustomEdit={this.onCustomEdit}
2023-02-13 10:41:40 +08:00
/>
}
rightContent={renderCustomRightContent()}
2022-12-01 14:28:30 +08:00
/>
2023-02-13 10:41:40 +08:00
: <CustomPaginationTable
loading={loading}
columns={this.getColumns(tableColumns)}
dataSource={tableDataSource}
total={toJS(tablePageInfo).total}
current={toJS(tablePageInfo).pageNum}
pageSize={this.pageInfo.pageSize}
onPageChange={value => {
this.handlePageChange(value);
}}
onShowSizeChange={(current, pageSize) => {
this.pageInfo = { current, pageSize };
const {
programmeStore: { form, getTableDatas, selectedKey }
} = this.props;
getTableDatas(selectedKey, this.pageInfo);
}}
/>}
</WeaNewScroll>
</div>
2022-12-01 14:28:30 +08:00
</WeaTop>
2022-08-25 17:54:18 +08:00
<WeaSlideModal
className="slideOuterWrapper"
2022-08-25 17:54:18 +08:00
visible={this.state.slideVisiable}
top={0}
2023-02-13 16:00:14 +08:00
measureT="%"
width={800}
measureX="px"
2022-08-25 17:54:18 +08:00
height={100}
2023-02-13 16:00:14 +08:00
measureY="%"
2022-08-25 17:54:18 +08:00
direction={"right"}
title={
<SlideModalTitle
2023-02-13 16:00:14 +08:00
subtitle={
this.state.customEdit ?
`修改${_.find(topTab, it => it.viewcondition === selectedKey).title}方案` :
`新增${_.find(topTab, it => it.viewcondition === selectedKey).title}方案`
}
2022-08-25 17:54:18 +08:00
editable={true}
showOperateBtn={showOperateBtn}
2023-02-13 16:00:14 +08:00
onSave={() => handleOnSave()}
2022-08-25 17:54:18 +08:00
/>
}
content={
this.state.slideVisiable ?
<DefaultSlideForm
customEditVisible={this.state.customEdit}
requestParams={requestParams}
onChange={requestParams => {
setRequestParams(requestParams);
}}
/> : null
2022-08-25 17:54:18 +08:00
}
onClose={() => {
handleSlideClose();
}}
/>
2022-06-17 16:53:27 +08:00
{this.state.copyModalVisible &&
<CopySchemaModal
ref="copyRef"
2022-07-28 17:16:40 +08:00
title={_.filter(topTab, it => it.viewcondition === selectedKey)[0].title}
2022-06-17 16:53:27 +08:00
visible={this.state.copyModalVisible}
value={this.state.copyModalValue}
onChange={value => this.setState({ copyModalValue: value })}
onCancel={() => {
this.setState({ copyModalVisible: false });
}}
footer={
2022-09-09 10:29:12 +08:00
[<Button
2022-06-17 16:53:27 +08:00
type="primary"
onClick={() => {
handleCopyModalSave();
}}>
保存
2022-09-09 10:29:12 +08:00
</Button>]
2022-03-21 19:54:16 +08:00
}
2022-06-17 16:53:27 +08:00
/>}
{customNewVisible &&
<CustomNewModal
visible={customNewVisible}
condition={formCondition}
form={form}
edit={this.state.customEdit}
onCancel={(isRefresh) => {
2022-06-17 16:53:27 +08:00
setCustomNewVisible(false);
isRefresh && this.customBenefitsTableRef.getCustomCategoryList();
2022-06-17 16:53:27 +08:00
}}
/>}
2022-02-25 09:24:56 +08:00
</div>
2022-06-17 16:53:27 +08:00
);
2022-02-25 09:24:56 +08:00
}
}