428 lines
14 KiB
JavaScript
428 lines
14 KiB
JavaScript
import React, { Component } from "react";
|
|
import { inject, observer } from "mobx-react";
|
|
import { Button, Dropdown, Menu, message, Modal, Popover } from "antd";
|
|
import { WeaPopoverHrm, WeaSlideModal, WeaTab, WeaTable, WeaTop } from "ecCom";
|
|
import InlineForm from "./components/inlineForm";
|
|
import { getSearchs, renderLoading } from "../../../util";
|
|
import * as API from "../../../apis/special";
|
|
import SlideModalTitle from "../../../components/slideModalTitle";
|
|
import AddItems from "../addItems";
|
|
import SpecialAddContent from "./components/specialAddContent";
|
|
import { condition } from "./components/condition";
|
|
import "./index.less";
|
|
|
|
@inject("specialAddStore", "taxAgentStore")
|
|
@observer
|
|
class SpecialAddDeduction extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
loading: {
|
|
query: false
|
|
},
|
|
advanceParams: { //高级搜索参数
|
|
visible: false,
|
|
condition: []
|
|
},
|
|
drawerParams: { //抽屜弹框参数
|
|
visible: false, title: "新建",
|
|
loading: false, isView: true,
|
|
editId: {}
|
|
},
|
|
dataSource: [],
|
|
columns: [],
|
|
selectedRowKeys: [],
|
|
pageInfo: {
|
|
current: 1, pageSize: 10, total: 0
|
|
}
|
|
};
|
|
this.inlineForm = null;
|
|
this.addItemRef = null;
|
|
}
|
|
|
|
componentDidMount() {
|
|
const { taxAgentStore: { getTaxAgentSelectListAsAdmin }, specialAddStore: { addForm } } = this.props;
|
|
addForm.initFormFields(condition);
|
|
getTaxAgentSelectListAsAdmin();
|
|
this.getSearchCondition();
|
|
this.specialAddDeductionList();
|
|
}
|
|
|
|
getSearchCondition = () => {
|
|
const { specialAddStore: { advanceForm } } = this.props;
|
|
const { advanceParams } = this.state;
|
|
API.getSearchCondition().then(({ status, data }) => {
|
|
if (status) {
|
|
const { condition } = data;
|
|
this.setState({
|
|
advanceParams: {
|
|
...advanceParams,
|
|
condition: condition
|
|
}
|
|
}, () => advanceForm.initFormFields(this.state.advanceParams.condition));
|
|
}
|
|
});
|
|
};
|
|
specialAddDeductionList = (params = {}) => {
|
|
const { loading, pageInfo } = this.state;
|
|
const { specialAddStore: { advanceForm } } = this.props;
|
|
const queryParams = advanceForm.getFormParams();
|
|
const extraParams = this.inlineForm ? this.inlineForm.getFieldsValue() : {};
|
|
const payload = {
|
|
...pageInfo,
|
|
...queryParams,
|
|
...extraParams,
|
|
...params
|
|
};
|
|
console.log(queryParams, payload);
|
|
console.log(this.inlineForm);
|
|
this.setState({ loading: { ...loading, query: true } });
|
|
API.specialAddDeductionList(payload).then(({ status, data }) => {
|
|
this.setState({ loading: { ...loading, query: false } });
|
|
if (status) {
|
|
const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
|
|
this.setState({
|
|
pageInfo: { ...pageInfo, current, pageSize, total },
|
|
dataSource,
|
|
columns: _.map(columns, item => {
|
|
const { dataIndex } = item;
|
|
if (dataIndex === "username") {
|
|
return {
|
|
...item,
|
|
render: (text, record) => {
|
|
return <a
|
|
href={`javaScript:openhrm(${record.employeeId});`}
|
|
onClick={e => window.pointerXY(e)}
|
|
title={text}
|
|
>
|
|
{text}
|
|
</a>;
|
|
}
|
|
};
|
|
} else if (dataIndex === "operate") {
|
|
return {
|
|
...item,
|
|
render: (text, record) => (
|
|
<div className="linkWapper">
|
|
<a href="javaScript:void(0);" onClick={() => {
|
|
}}>
|
|
查看明细
|
|
</a>
|
|
{
|
|
this.props.taxAgentStore.showOperateBtn &&
|
|
<Popover
|
|
overlayClassName="moreIconWrapper"
|
|
placement="bottomRight"
|
|
content={<Menu onClick={(e) => this.handleOperate(e, record)}>
|
|
<Menu.Item key="edit">编辑</Menu.Item>
|
|
<Menu.Item key="delete">删除</Menu.Item>
|
|
</Menu>} title="">
|
|
<i className="icon-coms-more"/>
|
|
</Popover>
|
|
}
|
|
</div>
|
|
)
|
|
};
|
|
} else {
|
|
return { ...item };
|
|
}
|
|
})
|
|
});
|
|
}
|
|
});
|
|
};
|
|
handleSaveSpecialList = (payload) => {
|
|
const { drawerParams } = this.state;
|
|
this.setState({ drawerParams: { ...drawerParams, loading: true } });
|
|
if (!_.isEmpty(drawerParams.editId)) {
|
|
API.specialAddDeductionEditData({ ...payload, id: drawerParams.editId.id }).then(({ status, errormsg }) => {
|
|
this.setState({ drawerParams: { ...drawerParams, loading: false } });
|
|
if (status) {
|
|
message.success("编辑成功");
|
|
this.setState({
|
|
drawerParams: {
|
|
...drawerParams,
|
|
visible: false,
|
|
editId: {}
|
|
}
|
|
}, () => {
|
|
const { specialAddStore: { addForm } } = this.props;
|
|
this.specialAddDeductionList();
|
|
addForm.resetForm();
|
|
});
|
|
} else {
|
|
message.error(errormsg || "编辑失败");
|
|
}
|
|
});
|
|
} else {
|
|
API.specialAddDeductionCreateData(payload).then(({ status, errormsg }) => {
|
|
this.setState({ drawerParams: { ...drawerParams, loading: false } });
|
|
if (status) {
|
|
message.success("新增成功");
|
|
this.setState({
|
|
drawerParams: {
|
|
...drawerParams,
|
|
visible: false,
|
|
editId: {}
|
|
}
|
|
}, () => {
|
|
const { specialAddStore: { addForm } } = this.props;
|
|
this.specialAddDeductionList();
|
|
addForm.resetForm();
|
|
});
|
|
} else {
|
|
message.error(errormsg || "新增失败");
|
|
}
|
|
});
|
|
}
|
|
};
|
|
handleOperate = ({ key }, row) => {
|
|
const { drawerParams } = this.state;
|
|
if (key === "edit") {
|
|
this.setState({
|
|
drawerParams: {
|
|
...drawerParams,
|
|
visible: true,
|
|
isView: false,
|
|
title: "编辑"
|
|
}
|
|
}, () => {
|
|
const { drawerParams: params } = this.state;
|
|
API.specialAddDeductionGetDetailList({ specialAddDeductionId: row.id }).then(({ status, data }) => {
|
|
if (status) {
|
|
this.setState({
|
|
drawerParams: {
|
|
...params,
|
|
editId: data
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
} else if (key === "delete") {
|
|
const payload = {
|
|
ids: [row.id]
|
|
};
|
|
Modal.confirm({
|
|
title: "信息确认",
|
|
content: `确定删除${row.departmentName}${row.username}的专项附加扣除数据吗?若数据已参与核算,已参与核算的数据不会受影响,点击核算将会按当前列表最新数据重新核算。`,
|
|
onOk: () => {
|
|
API.specialAddDeductionDeleteSelectData(payload).then(({ status, errormsg }) => {
|
|
if (status) {
|
|
message.success("删除成功");
|
|
this.specialAddDeductionList();
|
|
} else {
|
|
message.error(errormsg || "删除失败");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|
|
getSearchsAdQuick = (isAd) => {
|
|
const { advanceParams } = this.state;
|
|
const { taxAgentStore: { taxAgentAdminOption }, specialAddStore: { advanceForm } } = this.props;
|
|
return isAd ? getSearchs(advanceForm, advanceParams.condition, 2)
|
|
: <InlineForm
|
|
ref={dom => this.inlineForm = dom}
|
|
taxAgentOption={taxAgentAdminOption}
|
|
onChange={this.specialAddDeductionList}
|
|
/>;
|
|
};
|
|
|
|
render() {
|
|
const { advanceParams, dataSource, columns, loading, selectedRowKeys, pageInfo, drawerParams } = this.state;
|
|
const { taxAgentStore, specialAddStore: { advanceForm, addForm } } = this.props;
|
|
const { showOperateBtn, taxAgentAdminOption } = taxAgentStore;
|
|
const rowSelection = {
|
|
selectedRowKeys,
|
|
onChange: (selectedRowKeys) => this.setState({ selectedRowKeys })
|
|
};
|
|
const customBtns = [
|
|
<Dropdown.Button
|
|
onClick={() => {
|
|
}}
|
|
overlay={
|
|
<Menu onClick={() => {
|
|
}}>
|
|
<Menu.Item key="select">导出选中</Menu.Item>
|
|
</Menu>
|
|
}
|
|
type="primary"
|
|
>
|
|
导出全部
|
|
</Dropdown.Button>
|
|
];
|
|
const btns = [
|
|
<Button type="primary">导入</Button>,
|
|
<Dropdown.Button
|
|
onClick={() => {
|
|
}}
|
|
overlay={
|
|
<Menu onClick={() => {
|
|
}}>
|
|
<Menu.Item key="select">导出选中</Menu.Item>
|
|
</Menu>
|
|
}
|
|
type="ghost"
|
|
>
|
|
导出全部
|
|
</Dropdown.Button>,
|
|
<Button type="primary" onClick={() => this.setState({
|
|
drawerParams: {
|
|
...drawerParams,
|
|
visible: true,
|
|
isView: false,
|
|
editId: {}
|
|
}
|
|
})}>新建</Button>,
|
|
<Dropdown.Button
|
|
onClick={() => {
|
|
}}
|
|
overlay={
|
|
<Menu onClick={() => {
|
|
}}>
|
|
<Menu.Item key="select">删除所选</Menu.Item>
|
|
</Menu>
|
|
}
|
|
type="ghost"
|
|
>
|
|
一键清空
|
|
</Dropdown.Button>
|
|
];
|
|
const pagination = {
|
|
...pageInfo,
|
|
showTotal: (total) => `共 ${total} 条`,
|
|
pageSizeOptions: ["10", "20", "50", "100"],
|
|
showSizeChanger: true,
|
|
showQuickJumper: true,
|
|
onShowSizeChange: (current, pageSize) => {
|
|
this.setState({
|
|
pageInfo: { ...pageInfo, current, pageSize }
|
|
}, () => {
|
|
this.specialAddDeductionList({
|
|
current,
|
|
pageSize
|
|
});
|
|
});
|
|
},
|
|
onChange: (current) => {
|
|
this.setState({
|
|
pageInfo: { ...pageInfo, current }
|
|
}, () => {
|
|
this.specialAddDeductionList({
|
|
current
|
|
});
|
|
});
|
|
}
|
|
};
|
|
//加载数据
|
|
if (_.isEmpty(columns)) {
|
|
// 无权限处理
|
|
return renderLoading();
|
|
}
|
|
return (
|
|
<div className="specialAddWrapper">
|
|
<WeaTop
|
|
title="专项附加扣除"
|
|
icon={<i className="icon-coms-fa"/>}
|
|
iconBgcolor="#F14A2D"
|
|
buttons={showOperateBtn ? btns : []}
|
|
>
|
|
<div className="specialAddContent">
|
|
<WeaTab
|
|
searchType={["base", "advanced"]}
|
|
searchsBasePlaceHolder="请输入姓名"
|
|
showSearchAd={advanceParams.visible}
|
|
searchsBaseValue={advanceForm.getFormParams().username}
|
|
onSearchChange={(v) => advanceForm.updateFields({ username: v })}
|
|
onAdReset={() => advanceForm.reset()}
|
|
onAdSearch={() => this.specialAddDeductionList()}
|
|
onSearch={() => this.specialAddDeductionList()}
|
|
searchsAdQuick={this.getSearchsAdQuick()}
|
|
searchsAd={this.getSearchsAdQuick(true)}
|
|
setShowSearchAd={bool => this.setState({ advanceParams: { ...advanceParams, visible: bool } })}
|
|
/>
|
|
<WeaTable
|
|
rowKey="id"
|
|
rowSelection={rowSelection}
|
|
columns={columns}
|
|
dataSource={dataSource}
|
|
pagination={pagination}
|
|
loading={loading.query}
|
|
/>
|
|
<WeaSlideModal
|
|
className="specialAddSlideWrapper"
|
|
{...drawerParams}
|
|
top={0}
|
|
width={60}
|
|
height={100}
|
|
direction="right"
|
|
measure="%"
|
|
title={
|
|
<SlideModalTitle
|
|
subtitle={drawerParams.title}
|
|
loading={drawerParams.loading}
|
|
onSave={() => {
|
|
const { baseInfo } = this.addItemRef.state;
|
|
const bool = _.every(_.pick(baseInfo, ["taxAgentId", "employeeId"]), v => !_.isEmpty(v));
|
|
if (!bool && _.isEmpty(drawerParams.editId)) {
|
|
Modal.warning({
|
|
title: "信息确认",
|
|
content: "必要信息不完整,红色*为必填项!"
|
|
});
|
|
return;
|
|
}
|
|
const payload = {
|
|
..._.pick(baseInfo, ["taxAgentId", "employeeId", "taxAgentName"]),
|
|
...addForm.getFormParams()
|
|
};
|
|
this.handleSaveSpecialList(payload);
|
|
}}
|
|
editable={!drawerParams.isView}
|
|
showOperateBtn={showOperateBtn}
|
|
customOperate={(showOperateBtn && !drawerParams.isView) ? customBtns : []}
|
|
/>
|
|
}
|
|
content={
|
|
!drawerParams.isView ?
|
|
<AddItems
|
|
ref={(dom) => this.addItemRef = dom}
|
|
taxAgentOption={taxAgentAdminOption}
|
|
form={addForm}
|
|
isSpecial
|
|
editId={drawerParams.editId}
|
|
condition={condition}
|
|
/> :
|
|
<SpecialAddContent/>
|
|
}
|
|
onClose={() => this.setState({
|
|
drawerParams: {
|
|
...drawerParams,
|
|
visible: false,
|
|
isView: true,
|
|
editId: {}
|
|
}
|
|
})}
|
|
showMask={true}
|
|
closeMaskOnClick={() => this.setState({
|
|
drawerParams: {
|
|
...drawerParams,
|
|
visible: false,
|
|
isView: true,
|
|
editId: {}
|
|
}
|
|
})}
|
|
/>
|
|
{/*人员卡片*/}
|
|
<WeaPopoverHrm/>
|
|
</div>
|
|
</WeaTop>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default SpecialAddDeduction;
|
|
|