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

469 lines
15 KiB
JavaScript
Raw Normal View History

2022-02-25 09:24:56 +08:00
import React from 'react';
import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx';
2022-04-22 17:00:10 +08:00
import { Button, Table, DatePicker, Row, Col, Switch, Modal, Dropdown, Menu } from 'antd';
2022-02-25 09:24:56 +08:00
2022-04-22 17:00:10 +08:00
import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaInputSearch, WeaSlideModal, WeaSelect, WeaTable } from 'ecCom';
2022-03-22 16:53:39 +08:00
2022-03-12 17:07:11 +08:00
import { WeaTableNew } from "comsMobx"
2022-04-25 17:18:58 +08:00
import CustomTable from '../../../components/customTable'
2022-02-28 09:29:46 +08:00
import "./index.less";
2022-04-22 17:00:10 +08:00
const WeaMobxTable = WeaTableNew.WeaTable;
2022-02-28 09:29:46 +08:00
2022-02-25 09:24:56 +08:00
import { renderNoright, getSearchs } from '../../../util'; // 渲染form数据的方法因为多个页面都会使用所以抽的公共方法在util中
import CustomTab from '../../../components/customTab';
import ContentWrapper from '../../../components/contentWrapper';
2022-02-28 09:29:46 +08:00
import SlideModalTitle from '../../../components/slideModalTitle';
2022-03-12 17:07:11 +08:00
import TipLabel from '../../../components/TipLabel'
2022-03-21 17:43:26 +08:00
import DefaultSlideForm from './defaultSlideForm'
2022-03-22 16:53:39 +08:00
import CustomNewModal from './customNewModal'
2022-04-01 15:02:18 +08:00
import { welfareTypeEnum, paymentScopeEnum } from './enum';
2022-06-07 09:08:36 +08:00
import CustomPaginationTable from '../../../components/customPaginationTable'
2022-02-28 09:29:46 +08:00
2022-02-25 09:24:56 +08:00
2022-02-28 09:29:46 +08:00
import {
socialSecurityColumns,
accumulationFundColumns,
otherBenefitsColumns,
CustomBenefitsColumns, dataSource
} from './columns';
2022-02-25 09:24:56 +08:00
const { MonthPicker } = DatePicker;
2022-03-12 17:07:11 +08:00
import TwoColContent from '../../../components/twoColContent';
2022-03-21 19:54:16 +08:00
import CopySchemaModal from './copySchemaModal';
2022-03-12 17:07:11 +08:00
@inject('programmeStore')
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-02-25 09:24:56 +08:00
}
2022-06-07 09:08:36 +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() {
const { programmeStore } = this.props;
const {doInit} = programmeStore;
doInit();
}
2022-03-21 19:54:16 +08:00
// 增加编辑功能重写columns绑定事件
getColumns = (columns) => {
2022-04-22 17:00:10 +08:00
let newColumns = columns.filter(item => item.dataIndex !== "id" && item.dataIndex !== "paymentArea")
2022-05-19 15:13:31 +08:00
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, index) => { //前端元素转义
let valueSpan = record[newColumn.dataIndex + "span"] !== undefined ? record[newColumn.dataIndex + "span"] : record[newColumn.dataIndex];
2022-04-22 17:00:10 +08:00
if(newColumn.dataIndex == "id") {
newColumn.display = false
}
2022-03-21 19:54:16 +08:00
switch(newColumn.dataIndex) {
case "operate":
return <a onClick={() => {this.onEdit(record)}}>编辑</a>
default:
return <div dangerouslySetInnerHTML={{ __html: valueSpan }} />
}
}
return newColumn;
});
2022-04-22 17:00:10 +08:00
newColumns.push({
title: "操作",
dataIndex: "operate",
render: (text, record) => {
return <a onClick={() => {this.onEdit(record)}}>编辑</a>
}
})
newColumns.push(
{
title : '',
key: "moreOperate",
dataIndex: "moreOperate",
render: (text, record) => {
return (
<Dropdown overlay={<Menu>
<Menu.Item>
<a onClick={() => {
this.onCopy(record);
}}>复制</a>
</Menu.Item>
</Menu>}>
<i className="icon-coms-more"></i>
</Dropdown>
);
}
})
2022-03-21 19:54:16 +08:00
return newColumns;
}
2022-04-01 09:28:05 +08:00
handleCategoryStatusChange(record, value) {
const {programmeStore: { updateCustomCategoryStatus }} = this.props;
Modal.confirm({
title: '信息确认',
content: `确认要${value ? '启用' : '停用'}`,
onOk:() => {
updateCustomCategoryStatus(record.id, value)
},
onCancel: () => {
},
});
}
2022-03-22 18:53:05 +08:00
getCustomColumns = (columns) => {
let newColumns = '';
newColumns = columns.map(column => {
let newColumn = column;
newColumn.render = (text, record, index) => { //前端元素转义
let valueSpan = record[newColumn.dataIndex + "span"] !== undefined ? record[newColumn.dataIndex + "span"] : record[newColumn.dataIndex];
switch(newColumn.dataIndex) {
case "operate":
return <a onClick={() => {this.onCustomEdit(record)}}>编辑</a>
2022-04-01 09:28:05 +08:00
case "is_use":
return <Switch checked={text == 1} onChange={(value) => {this.handleCategoryStatusChange(record, value)}}/>
2022-03-22 18:53:05 +08:00
default:
return <div dangerouslySetInnerHTML={{ __html: valueSpan }} />
}
}
return newColumn;
});
return newColumns;
}
2022-03-21 19:54:16 +08:00
onEdit(record) {
let id = record.id;
const { programmeStore } = this.props
const { getForm, selectedKey } = programmeStore
getForm({
welfareTypeEnum: selectedKey,
id
})
this.setState({slideVisiable: true, currentOperate: "update"})
}
onCopy(record) {
this.setState({
copyId: record.id,
copyModalVisible: true
})
}
2022-03-22 18:53:05 +08:00
onCustomOperatesClick(record, index, operate, flag) {
switch(operate.text.toString()){
case '编辑': // 编辑
this.onCustomEdit(record);
break;
}
}
onCustomEdit(record) {
2022-03-28 10:53:19 +08:00
const { programmeStore: {getCustomForm, setCustomNewVisible, setCustomRequest}} = this.props;
2022-04-01 15:02:18 +08:00
getCustomForm()
2022-03-28 10:53:19 +08:00
setCustomNewVisible(true)
2022-04-01 15:02:18 +08:00
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]
})
2022-03-22 18:53:05 +08:00
}
2022-05-18 17:10:12 +08:00
// 页面跳转
handlePageChange(value) {
const { programmeStore: {form, getTableDatas, selectedKey} } = this.props;
2022-06-07 09:08:36 +08:00
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() {
const { programmeStore } = this.props;
const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = programmeStore;
2022-03-22 16:53:39 +08:00
const { selectedKey, setSelectedKey, getCustomCategoryList, customTableStore,
2022-04-01 13:54:24 +08:00
customSelectkey, setCustomSelectkey, requestParams, setRequestParams, formCondition,
2022-04-24 14:50:44 +08:00
setCustomNewVisible, customNewVisible, tableDataSource, tableColumns, tablePageInfo } = programmeStore;
2022-02-25 09:24:56 +08:00
if (!hasRight && !loading) { // 无权限处理
return renderNoright();
}
const rightMenu = [// 右键菜单
{
key: 'BTN_COLUMN',
icon: <i className='icon-coms-Custom' />,
content: '显示列定制',
onClick: this.showColumn
},
];
const collectParams = { // 收藏功能配置
favname: '社保福利方案',
favouritetype: 1,
objid: 0,
link: 'wui/index.html#/ns_demo03/index',
importantlevel: 1,
};
const adBtn = [ // 高级搜索内部按钮
<Button type="primary" onClick={doSearch}>搜索</Button>,
<Button type="ghost" onClick={() => form.resetForm()}>重置</Button>,
<Button type="ghost" onClick={() => setShowSearchAd(false)}>取消</Button>,
];
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
const options = [
2022-04-01 10:39:01 +08:00
{
showname: "全部",
key: ""
},
{
showname: "社保",
key: "SOCIAL_SECURITY"
},
{
showname: "公积金",
key: "ACCUMULATION_FUND"
},
{
showname: "企业年金及其他福利",
2022-03-21 19:54:16 +08:00
key: "OTHER"
}
]
2022-03-21 17:43:26 +08:00
const handleNewClick = () => {
2022-05-18 17:10:12 +08:00
const { programmeStore: {initSlideParms, getForm, selectedKey}} = this.props;
2022-03-28 10:53:19 +08:00
initSlideParms();
2022-03-21 19:54:16 +08:00
this.setState({ slideVisiable: true, currentOperate: "add" })
2022-05-18 17:10:12 +08:00
getForm({welfareTypeEnum: selectedKey})
2022-03-21 17:43:26 +08:00
}
2022-03-22 16:53:39 +08:00
const handleCustomNewClick = () => {
2022-04-01 10:39:01 +08:00
const { programmeStore : { getCustomForm, getCumCustomForm, setCustomNewVisible, setCustomRequest }} = this.props;
2022-03-22 16:53:39 +08:00
getCustomForm()
2022-04-01 10:39:01 +08:00
setCustomRequest({})
2022-03-28 10:53:19 +08:00
setCustomNewVisible(true)
2022-04-01 15:02:18 +08:00
this.setState({customEdit: false})
2022-03-22 16:53:39 +08:00
}
2022-05-30 17:30:53 +08:00
// const renderSearchOperationItem = () => {
// const { programmeStore: {setCustomSelectkey, getCustomCategoryList}} = this.props;
// return
// }
2022-02-28 09:29:46 +08:00
2022-03-21 17:43:26 +08:00
const handleOnSave = () => {
const { programmeStore } = this.props
2022-03-21 19:54:16 +08:00
const { currentOperate } = this.state
const { selectedKey, defaultPersonDataSource, defaultCompanyDataSource, createScheme, requestParams, updateScheme } = programmeStore
2022-05-18 17:10:12 +08:00
let { schemeName, remarks, paymentArea, paymentType } = 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,
paymentArea
},
insuranceSchemeDetailList: [...defaultPersonDataSource, ...defaultCompanyDataSource]
}
2022-03-21 19:54:16 +08:00
if(currentOperate == "add") {
createScheme(request)
} else if(currentOperate == "update"){
request.insuranceScheme.id = requestParams.id
updateScheme(request)
}
this.setState({slideVisiable: false})
2022-02-25 09:24:56 +08:00
}
2022-03-12 17:07:11 +08:00
const renderCustomRightContent = () => {
let tipList = [
"1、可以为社保、公积金、企业年金及其他福利新增自定义的福利项残疾保险等",
"2、新增自定义福利默认启用社保福利方案中的自定义福利项均未开启缴纳当前页面的自定义福利项才可以停用停用后再新增方案时没有该福利项",
"3、自定义福利若要缴纳需要在方案里填写缴纳相关数据"
]
return (<TipLabel tipList={tipList} />)
}
2022-03-21 19:54:16 +08:00
const handleCopyModalSave = () => {
const { programmeStore: {copyScheme}} = this.props;
const { copyId, copyModalValue } = this.state;
copyScheme({id:copyId, schemeName: copyModalValue})
this.setState({copyModalVisible : false})
}
2022-03-28 10:53:19 +08:00
const handleSlideClose = () => {
this.setState({ slideVisiable: false })
const { programmeStore: {initSlideParms} } = this.props;
initSlideParms()
}
2022-02-25 09:24:56 +08:00
return (
<div className="mySalaryBenefitsWrapper">
<WeaRightMenu
datas={rightMenu} // 右键菜单
collectParams={collectParams} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能
>
<WeaTop
title="社保福利方案" // 文字
icon={<i className='icon-coms-meeting' />} // 左侧图标
iconBgcolor='#F14A2D' // 左侧图标背景色
showDropIcon={true} // 是否显示下拉按钮
dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同)
dropMenuProps={{ collectParams }} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能
>
<CustomTab topTab={topTab}
searchOperationItem={
2022-05-30 17:30:53 +08:00
<div>
<Button type="primary" style={{ marginRight: '10px' }} onClick={() => {
if(selectedKey == "custom") {
handleCustomNewClick()
} else {
handleNewClick()
}
}}>新建</Button>
{
selectedKey == "custom" && <WeaSelect
options={options}
value={customSelectkey}
style={{width: "150px"}}
onChange={(v) => {
setCustomSelectkey(v)
getCustomCategoryList(v)
console.log("v:", v)
}}
/>
}
</div>
2022-02-25 09:24:56 +08:00
}
2022-02-28 09:29:46 +08:00
onChange={(v) => {
2022-03-22 16:53:39 +08:00
setSelectedKey(v)
2022-03-12 17:07:11 +08:00
if(v == "custom") { // 自定义福利
getCustomCategoryList()
} else {
getTableDatas(v)
}
2022-02-28 09:29:46 +08:00
}}
2022-02-25 09:24:56 +08:00
/>
{
2022-03-12 17:07:11 +08:00
selectedKey == "custom" ?
<TwoColContent
leftContent={
2022-04-22 17:00:10 +08:00
<WeaMobxTable // table内部做了loading加载处理页面就不需要再加了
2022-03-12 17:07:11 +08:00
comsWeaTableStore={tableStore} // table store
hasOrder={true} // 是否启用排序
needScroll={true} // 是否启用table内部列表滚动将自适应到父级高度
2022-03-22 18:53:05 +08:00
getColumns={this.getCustomColumns}
onOperatesClick={this.onCustomOperatesClick.bind(this)}
2022-03-12 17:07:11 +08:00
/>
}
rightContent={
renderCustomRightContent()
}
/> :
2022-06-07 09:08:36 +08:00
<CustomPaginationTable
2022-04-25 17:18:58 +08:00
loading={loading}
2022-04-22 17:00:10 +08:00
columns={this.getColumns(tableColumns)}
dataSource={tableDataSource}
2022-06-07 09:08:36 +08:00
total={tablePageInfo.total}
current={tablePageInfo.pageNum}
onPageChange={(value) => {
this.handlePageChange(value)
}}
onShowSizeChange={(current,pageSize) => {
this.pageInfo = {current, pageSize}
const { programmeStore: {form, getTableDatas, selectedKey} } = this.props;
getTableDatas(selectedKey, this.pageInfo)
2022-04-24 14:50:44 +08:00
}}
2022-03-12 17:07:11 +08:00
/>
2022-04-22 17:00:10 +08:00
2022-02-25 09:24:56 +08:00
}
</WeaTop>
</WeaRightMenu>
2022-03-28 10:53:19 +08:00
{
this.state.slideVisiable && <WeaSlideModal visible={this.state.slideVisiable}
2022-02-28 09:29:46 +08:00
top={0}
2022-03-01 09:42:00 +08:00
width={40}
2022-02-28 09:29:46 +08:00
height={100}
direction={'right'}
measure={'%'}
title={
<SlideModalTitle
2022-05-30 09:38:45 +08:00
subtitle={this.state.customEdit ? "修改社保方案": "新增社保方案"}
2022-02-28 09:29:46 +08:00
subTabs={[{title: "基础设置"}]}
2022-03-21 17:43:26 +08:00
onSave={() => {
handleOnSave();
}}
2022-02-28 09:29:46 +08:00
/>
}
2022-03-21 19:54:16 +08:00
content={(<DefaultSlideForm requestParams={requestParams} onChange={(requestParams) => {
2022-05-18 17:10:12 +08:00
console.log("requestParams:", requestParams);
2022-03-21 19:54:16 +08:00
setRequestParams(requestParams)
2022-03-21 17:43:26 +08:00
}}/>)}
2022-03-28 10:53:19 +08:00
onClose={() => {handleSlideClose()}}
2022-02-28 09:29:46 +08:00
showMask={true}
2022-03-28 10:53:19 +08:00
closeMaskOnClick={() => {handleSlideClose()}}
2022-02-28 09:29:46 +08:00
onAnimationEnd={() => console.log('onAnimationEnd')} />
2022-03-28 10:53:19 +08:00
}
2022-03-21 19:54:16 +08:00
{
this.state.copyModalVisible && <CopySchemaModal
visible={this.state.copyModalVisible}
value={this.state.copyModalValue}
onChange={(value) => this.setState({copyModalValue: value})}
onCancel={() => {this.setState({copyModalVisible: false})}}
footer={<Button type="primary" onClick={() => {handleCopyModalSave()}}>保存</Button>
}
/>
}
2022-03-22 16:53:39 +08:00
{
2022-03-28 10:53:19 +08:00
customNewVisible && <CustomNewModal
visible={customNewVisible}
2022-03-22 16:53:39 +08:00
condition={formCondition}
form={form}
2022-04-01 15:02:18 +08:00
edit={this.state.customEdit}
2022-03-28 10:53:19 +08:00
onCancel={() => {setCustomNewVisible(false)}}
2022-03-22 16:53:39 +08:00
/>
}
2022-02-25 09:24:56 +08:00
</div>
)
}
}