From 2b6157788d44c5ef53d239b99ac9917fdb3b0883 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com>
Date: Fri, 17 Feb 2023 10:59:04 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=A1=A8=E6=A0=BC=E5=9B=BA?=
=?UTF-8?q?=E5=AE=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pages/dataAcquisition/cumDeduct/index.js | 879 +-----------------
.../dataAcquisition/cumDeduct/indexcopy.js | 855 +++++++++++++++++
2 files changed, 898 insertions(+), 836 deletions(-)
create mode 100644 pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/indexcopy.js
diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js
index ff7727d5..e7cd2ea3 100644
--- a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js
+++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js
@@ -1,855 +1,62 @@
-import React from "react";
-import { inject, observer } from "mobx-react";
-import { toJS } from "mobx";
-import { Button, Col, Dropdown, Menu, message, Modal, Popover, Row } from "antd";
-import { WeaDatePicker, WeaHelpfulTip, WeaSelect, WeaSlideModal, WeaTab, WeaTable, WeaTop, WeaNewScroll } from "ecCom";
-import moment from "moment";
-import { getSearchs, renderLoading } from "../../../util"; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中
-import ImportModal from "../../../components/importModal";
-import { dataCollectCondition, modalColumns } from "./columns";
-import { optionAddAll } from "../../../util/options";
-import SlideModalTitle from "../../../components/slideModalTitle";
-import EditSlideContent from "./components/editSlideContent";
-import AddItems from "../addItems";
-import * as API from "../../../apis/cumDeduct";
-import "./index.less";
+import React, { Component } from "react";
+import { getCumDeductList } from "../../../apis/cumDeduct";
+import { WeaTable } from "ecCom";
-@inject("cumDeductStore", "taxAgentStore")
-@observer
-export default class CumDeduct extends React.Component {
+
+class Index extends Component {
constructor(props) {
super(props);
this.state = {
- addVisible: false,
- editId: {},
- saveLoading: false,
- addAllLoading: false,
- value: "",
- selectedKey: [],
- slideSelectedKey: [], //详情表格的选中项
- visiable: false,
- monthValue: moment(new Date()).format("YYYY-MM"),
- taxAgentId: "All",
- datetime: "",
- inited: false,
- modalParam: {
- declareMonth: "",
- taxAgentId: ""
- }
+ columns: [], dataSource: []
};
}
- componentWillMount() {
- // 初始化渲染页面
- const {
- cumDeductStore: { doInit, addForm },
- taxAgentStore: { fetchTaxAgentOption, getTaxAgentSelectListAsAdmin }
- } = this.props;
- addForm.initFormFields(dataCollectCondition);
- doInit({ declareMonth: [this.state.monthValue], taxAgentId: "" });
- getTaxAgentSelectListAsAdmin();
- fetchTaxAgentOption().then((res) => {
+ componentDidMount() {
+ this.getCumDeductList();
+ }
+
+ getCumDeductList = () => {
+ getCumDeductList({ declareMonth: ["2023-02"], taxAgentId: "" }).then(res => {
this.setState({
- inited: true
- });
- });
- }
-
- getSearchsAdQuick() {
- const { monthValue, taxAgentId } = this.state;
- const {
- taxAgentStore: { taxAgentOption },
- cumDeductStore: { form, getTableDatas }
- } = this.props;
- return (
-
-
- 税款所属期:
- {
- this.setState({ monthValue: v });
- let params = {};
- if (taxAgentId == "All") {
- params.taxAgentId = "";
- } else {
- params.taxAgentId = taxAgentId;
- }
- if (v != null && v != "") {
- params.declareMonth = [v];
- }
- getTableDatas(params);
- }}
- />
-
-
-
-
-
-
-
- 个税扣缴义务人:
-
- {
- this.state.inited && {
- let params = {};
- if (v == "All") {
- params.taxAgentId = "";
- } else {
- params.taxAgentId = v;
- }
- if (monthValue != null && monthValue != "") {
- params.declareMonth = [monthValue];
- }
- getTableDatas(params);
- this.setState({ taxAgentId: v });
- }}
- />
+ columns: _.map(res.data.columns, item => {
+ if (item.dataIndex === "username") {
+ return {
+ ...item,
+ fixed: "left",
+ width: "20%"
+ };
}
-
-
- );
- }
-
- renderFormComponent() {
- const { modalParam } = this.state;
- const {
- taxAgentStore: { taxAgentAdminOption }
- } = this.props;
- return (
-
-
-
- 税款所属期
-
-
- this.setState({
- modalParam: { ...modalParam, declareMonth: value }
- })
- }
- />
-
-
-
- 个税扣缴义务人
-
- {
- this.setState({ modalParam: { ...modalParam, taxAgentId: v } });
- }}
- />
-
-
- );
- }
-
- onEdit = (record) => {
- const {
- cumDeductStore: {
- slideVisiable,
- setSlideVisiable,
- getCumDeductDetailList,
- setCurrentRecord
- }
- } = this.props;
- setSlideVisiable(true);
- setCurrentRecord(record);
- getCumDeductDetailList(record.id, { taxAgentId: record.taxAgentId });
- };
-
- // 增加编辑功能,重写columns绑定事件
- getColumns = (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 "username":
- return (
- {
- this.onEdit(record);
- }}>
- {text}
-
- );
- case "operate":
- return (
- {
- this.onEdit(record);
- }}>
- 查看明细
-
- );
- default:
- return ;
- }
- };
- return newColumn;
- });
- return newColumns;
- };
-
- handleCancel() {
- const { cumDeductStore } = this.props;
- const { modalVisiable, setModalVisiable, setStep } = cumDeductStore;
- setModalVisiable(false);
- setStep(0);
- }
-
- onOperatesClick = (record, index, operate, flag) => {
- switch (operate.index.toString()) {
- case "0": // 查看明细
- this.onEdit(record);
- break;
- }
- };
-
- showColumn = () => {
- const {
- cumDeductStore: { tableStore }
- } = this.props;
- tableStore.setColSetVisible(true);
- tableStore.tableColSet(true);
- };
-
- // 初始化导入参数
- handleInitModal() {
- const {
- cumDeductStore: { setSlideDataSource, setImportResult }
- } = this.props;
- setSlideDataSource([]);
- setImportResult({});
- }
-
- onSelectChange = (val) => {
- this.setState({
- selectedKey: val
- });
- };
-
- handleSearch = () => {
- const { cumDeductStore: { getTableDatas } } = this.props;
- const { monthValue, taxAgentId } = this.state;
- let params = {};
- if (monthValue != null && monthValue !== "") {
- params.declareMonth = [monthValue];
- }
- if (taxAgentId != null && taxAgentId !== "" && taxAgentId !== "All") {
- params.taxAgentId = taxAgentId;
- }
- getTableDatas({ ...params, current: 1 });
- };
-
- //新功能
- handleSaveDeduction = (payload) => {
- const { editId } = this.state;
- this.setState({ saveLoading: true });
- if (!_.isEmpty(editId)) {
- API.editAddUpDeduction({ ...payload, id: editId.id }).then(({ status, errormsg }) => {
- this.setState({ saveLoading: false });
- if (status) {
- message.success("编辑成功");
- this.setState({
- addVisible: false,
- editId: {}
- }, () => {
- const { cumDeductStore: { doSearch, addForm } } = this.props;
- const { monthValue, taxAgentId } = this.state;
- doSearch({
- declareMonth: [monthValue],
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- });
- addForm.resetForm();
- });
- } else {
- message.error(errormsg || "编辑失败");
- }
- });
- } else {
- API.createAddUpDeduction(payload).then(({ status, errormsg }) => {
- this.setState({ saveLoading: false });
- if (status) {
- message.success("新增成功");
- this.setState({
- addVisible: false,
- editId: {}
- }, () => {
- const { cumDeductStore: { doSearch, addForm } } = this.props;
- const { monthValue, taxAgentId } = this.state;
- doSearch({
- declareMonth: [monthValue],
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- });
- addForm.resetForm();
- });
- } else {
- message.error(errormsg || "新增失败");
- }
- });
- }
- };
- deleteSelectAddUpDeduction = () => {
- const { monthValue: declareMonth, taxAgentId, selectedKey } = this.state;
- const { cumDeductStore: { doSearch } } = this.props;
- if (selectedKey.length === 0) {
- message.warning("未选择条目");
- return;
- }
- const payload = {
- declareMonth,
- ids: selectedKey
- };
- Modal.confirm({
- title: "信息确认",
- content: "确定删除所选数据吗?若数据已参与核算,已参与核算的数据不会受影响,点击核算将会按当前列表最新数据重新核算。",
- onOk: () => {
- API.deleteSelectAddUpDeduction(payload).then(({ status, errormsg }) => {
- if (status) {
- message.success("删除成功");
- doSearch({
- declareMonth: [declareMonth],
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- });
- } else {
- message.error(errormsg || "删除失败");
+ if (item.dataIndex === "taxAgentName") {
+ return {
+ ...item,
+ fixed: "left",
+ width: "25%"
+ };
}
- });
- },
- onCancel: () => {
- }
- });
-
- };
- deleteAllAddUpDeduction = () => {
- const { monthValue: declareMonth, taxAgentId } = this.state;
- const { cumDeductStore: { doSearch } } = this.props;
- const payload = {
- declareMonth,
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- };
- Modal.confirm({
- title: "信息确认",
- content: `确定清空税款所属期为${declareMonth}的所有累计专项附加扣除数据吗?若数据已参与核算,已参与核算的数据不会受影响,点击核算将会按当前列表最新数据重新核算。`,
- onOk: () => {
- API.deleteAllAddUpDeduction(payload).then(({ status, errormsg }) => {
- if (status) {
- message.success("删除成功");
- doSearch({
- declareMonth: [declareMonth],
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- });
- } else {
- message.error(errormsg || "删除失败");
+ if (item.dataIndex === "operate") {
+ return {
+ ...item,
+ fixed: "right",
+ width: "100px"
+ };
}
- });
- }
- });
- };
- handleOperate = ({ key }, row) => {
- const { monthValue: declareMonth, taxAgentId } = this.state;
- const { cumDeductStore: { doSearch } } = this.props;
- if (key === "edit") {
- this.setState({
- addVisible: true
- }, () => {
- API.getAddUpDeduction({ id: row.id }).then(({ status, data }) => {
- if (status) {
- this.setState({ editId: data });
- }
- });
- });
- } else if (key === "delete") {
- const payload = {
- declareMonth,
- ids: [row.id]
- };
- Modal.confirm({
- title: "信息确认",
- content: `确定删除${row.departmentName}${row.username}(税款所属期:${declareMonth})的累计专项附加扣除数据吗?若数据已参与核算,已参与核算的数据不会受影响,点击核算将会按当前列表最新数据重新核算。`,
- onOk: () => {
- API.deleteSelectAddUpDeduction(payload).then(({ status, errormsg }) => {
- if (status) {
- message.success("删除成功");
- doSearch({
- declareMonth: [declareMonth],
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- });
- } else {
- message.error(errormsg || "删除失败");
- }
- });
- }
- });
- }
- };
- autoAddAll = () => {
- const { monthValue: declareMonth, taxAgentId } = this.state;
- const { cumDeductStore: { doSearch } } = this.props;
- this.setState({ addAllLoading: true });
- API.autoAddAll({ yearMonth: declareMonth }).then(({ status, data, errormsg }) => {
- this.setState({ addAllLoading: false });
- if (status) {
- message.success(data || "操作成功");
- doSearch({
- declareMonth: [declareMonth],
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- });
- } else {
- message.error(errormsg || "操作失败");
- }
- }).catch(() => this.setState({ addAllLoading: false }));
- };
- handleButtonClick = () => {
- if (!this.handleChangeDebounce) {
- this.handleChangeDebounce = _.debounce(this.handleChange, 500);
- }
- this.handleChangeDebounce();
- };
- handleChange = e => {
- const url = `${window.location
- .origin}/api/bs/hrmsalary/addUpDeduction/export?ids=&declareMonth=${this.state.monthValue}&taxAgentId=${this.state.taxAgentId == "All"
- ? ""
- : this.state.taxAgentId}`;
- window.open(url, "_self");
- };
- handleExportAllDetailClick = () => {
- if (!this.handleChangeDebounce) {
- const {
- cumDeductStore: { currentRecord }
- } = this.props;
- const url = `${window.location
- .origin}/api/bs/hrmsalary/addUpDeduction/exportDetail?accumulatedSpecialAdditionalDeductionId=${currentRecord.id}&ids=&taxAgentId=${currentRecord.taxAgentId}`;
- window.open(url, "_self");
- }
- this.handleChangeDebounce();
+ return {
+ ...item,
+ width: "25%"
+ };
+ }),
+ dataSource: res.data.list
+ });
+ });
};
render() {
- const {
- modalParam,
- slideSelectedKey,
- monthValue,
- taxAgentId,
- addVisible,
- editId,
- saveLoading,
- addAllLoading
- } = this.state;
- const { cumDeductStore, taxAgentStore } = this.props;
- const {
- loading,
- dataSource,
- columns,
- pageObj,
- addForm,
- form,
- condition,
- tableStore,
- showSearchAd,
- getTableDatas,
- doSearch,
- setShowSearchAd,
- previewImport,
- importFile
- } = cumDeductStore;
- const { taxAgentOption, showOperateBtn } = taxAgentStore;
- const {
- slideVisiable,
- setSlideVisiable,
- modalVisiable,
- setModalVisiable,
- slideTableStore,
- step,
- setStep,
- slideDataSource,
- importResult,
- setPageObj
- } = cumDeductStore;
- const selectedRowKeys = toJS(tableStore.selectedRowKeys) || [];
-
- const detailSelectedRowKeys = toJS(slideTableStore.selectedRowKeys) || [];
-
- const rightMenu = [
- // 右键菜单
- // {
- // key: "BTN_COLUMN",
- // icon: ,
- // content: "显示列定制",
- // onClick: this.showColumn,
- // },
- ];
- const adBtn = [
- // 高级搜索内部按钮
- ,
- ,
-
- ];
-
- const topTab = [];
-
- const renderSearchOperationItem = () => {
- return ;
- };
-
- const handleMenuClick = () => {
- if (this.state.selectedKey.length == 0) {
- message.warning("未选择条目");
- return;
- }
- const url = `${window.location
- .origin}/api/bs/hrmsalary/addUpDeduction/export?ids=${this.state.selectedKey.join(
- ","
- )}&declareMonth=${this.state.monthValue}&taxAgentId=${this.state.taxAgentId == "All"
- ? ""
- : this.state.taxAgentId}`;
- window.open(url, "_self");
- };
-
- const handleBtnImport = () => {
- const {
- cumDeductStore: { setModalVisiable, setStep }
- } = this.props;
- setStep(0);
- setModalVisiable(true);
- };
-
- const btns = [
- ,
-
- 导出选中
-
- }
- type="ghost">
- 导出全部
- ,
- ,
-
- 删除所选
-
- }
- type="ghost">
- 一键清空
- ,
-
- ];
-
- const handleExportSelectedDetailClick = () => {
- if (this.state.slideSelectedKey.length === 0) {
- message.warning("未选择条目");
- return;
- }
- const {
- cumDeductStore: { currentRecord }
- } = this.props;
- const url = `${window.location
- .origin}/api/bs/hrmsalary/addUpDeduction/exportDetail?accumulatedSpecialAdditionalDeductionId=${currentRecord.id}&ids=${this.state.slideSelectedKey.join(",")}&taxAgentId=${currentRecord.taxAgentId}`;
- window.open(url, "_self");
- };
-
- const renderBtns = () => {
- return [
-
- 导出选中
-
- }
- type="primary">
- 导出全部
-
- ];
- };
-
- const pagination = {
- total: pageObj.total,
- showTotal: (total) => `共 ${total} 条`,
- pageSizeOptions: ["10", "20", "50", "100"],
- showSizeChanger: true,
- onShowSizeChange(current, pageSize) {
- setPageObj({ ...pageObj, current, pageSize });
- getTableDatas({
- current,
- pageSize,
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId,
- declareMonth: monthValue && [monthValue]
- });
- },
- onChange(current) {
- setPageObj({ ...pageObj, current, pageSize: pageObj.pageSize });
- getTableDatas({
- current,
- pageSize: pageObj.pageSize,
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId,
- declareMonth: monthValue && [monthValue]
- });
- }
- };
- const rowSelection = {
- selectedRowKeys: this.state.selectedKey,
- onChange: this.onSelectChange
- };
- const newColumns = _.map([...columns], (item) => {
- if (item.dataIndex === "username") {
- return {
- ...item,
- width: 100,
- fixed: "left",
- render: (text, record) => (
-
- )
- };
- } else if (item.dataIndex === "taxAgentName") {
- return {
- ...item,
- width: 180,
- fixed: "left"
- };
- } else if (item.dataIndex === "operate") {
- return {
- ...item,
- width: 120,
- fixed: "right",
- render: (text, record) => (
-
- )
- };
- } else {
- return { ...item, width: 150 };
- }
- });
- if (_.isEmpty(newColumns)) {
- return renderLoading();
- }
+ const { columns, dataSource } = this.state;
return (
-
-
} // 左侧图标
- iconBgcolor="#F14A2D" // 左侧图标背景色
- showDropIcon={false} // 是否显示下拉按钮
- dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同)
- buttons={showOperateBtn ? btns : []}
- >
-
- setShowSearchAd(bool)} //高级搜索面板受控
- searchsAd={getSearchs(form, toJS(condition), 2)} // 高级搜索内部数据
- buttonsAd={adBtn} // 高级搜索内部按钮
- onSearch={() => this.handleSearch()} // 点搜索按钮时的回调
- searchsAdQuick={this.getSearchsAdQuick()}
- onSearchChange={(v) => form.updateFields({ username: v })} // 在搜索框中输入的文字改变时的回调: 这里需要同步高级搜索和外部搜索框的值
- searchsBaseValue={form.getFormParams().username} // 外部input搜索值受控: 这里和高级搜索的requestname同步
- />
-
-
-
-
-
-
-
- {modalVisiable && (
-
{
- this.handleInitModal();
- }}
- onValidate={() => {
- this.handleValidate();
- }}
- params={modalParam}
- columns={modalColumns}
- step={step}
- setStep={setStep}
- slideDataSource={slideDataSource}
- importResult={importResult}
- onFinish={() => {
- setModalVisiable(false);
- setStep(0);
- doSearch({
- declareMonth: this.state.monthValue ? [this.state.monthValue] : "",
- taxAgentId: taxAgentId === "All" ? "" : taxAgentId
- });
- }}
- previewImport={(params) => {
- previewImport(params);
- }}
- importFile={(params) => {
- importFile(params);
- }}
- templateLink={"/api/bs/hrmsalary/addUpDeduction/downloadTemplate"}
- renderFormComponent={() => this.renderFormComponent()}
- visiable={modalVisiable}
- onCancel={() => {
- this.handleCancel();
- }}
- />
- )}
-
- {(slideVisiable || addVisible) && (
- {
- const { baseInfo } = this.addItemRef.state;
- const bool = _.every(_.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId"]), v => !_.isEmpty(v));
- if (!bool && _.isEmpty(editId)) {
- Modal.warning({
- title: "信息确认",
- content: "必要信息不完整,红色*为必填项!"
- });
- return;
- }
- const payload = {
- ..._.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId", "taxAgentName"]),
- ...addForm.getFormParams()
- };
- this.handleSaveDeduction(payload);
- }}
- editable={!!addVisible}
- showOperateBtn={showOperateBtn}
- customOperate={(showOperateBtn && !addVisible) ? renderBtns() : []}
- />
- }
- content={
- addVisible ?
- this.addItemRef = dom}
- taxAgentOption={taxAgentOption}
- form={addForm}
- editId={editId}
- condition={dataCollectCondition}
- /> :
-
- this.setState({ slideSelectedKey: val })
- }
- />
- }
- onClose={() => {
- setSlideVisiable(false);
- this.setState({
- addVisible: false,
- editId: {}
- });
- }}
- showMask={true}
- closeMaskOnClick={() => {
- setSlideVisiable(false);
- this.setState({
- addVisible: false,
- editId: {}
- });
- }}
- />
- )}
-
+
);
}
}
+
+export default Index;
diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/indexcopy.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/indexcopy.js
new file mode 100644
index 00000000..ff7727d5
--- /dev/null
+++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/indexcopy.js
@@ -0,0 +1,855 @@
+import React from "react";
+import { inject, observer } from "mobx-react";
+import { toJS } from "mobx";
+import { Button, Col, Dropdown, Menu, message, Modal, Popover, Row } from "antd";
+import { WeaDatePicker, WeaHelpfulTip, WeaSelect, WeaSlideModal, WeaTab, WeaTable, WeaTop, WeaNewScroll } from "ecCom";
+import moment from "moment";
+import { getSearchs, renderLoading } from "../../../util"; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中
+import ImportModal from "../../../components/importModal";
+import { dataCollectCondition, modalColumns } from "./columns";
+import { optionAddAll } from "../../../util/options";
+import SlideModalTitle from "../../../components/slideModalTitle";
+import EditSlideContent from "./components/editSlideContent";
+import AddItems from "../addItems";
+import * as API from "../../../apis/cumDeduct";
+import "./index.less";
+
+@inject("cumDeductStore", "taxAgentStore")
+@observer
+export default class CumDeduct extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ addVisible: false,
+ editId: {},
+ saveLoading: false,
+ addAllLoading: false,
+ value: "",
+ selectedKey: [],
+ slideSelectedKey: [], //详情表格的选中项
+ visiable: false,
+ monthValue: moment(new Date()).format("YYYY-MM"),
+ taxAgentId: "All",
+ datetime: "",
+ inited: false,
+ modalParam: {
+ declareMonth: "",
+ taxAgentId: ""
+ }
+ };
+ }
+
+ componentWillMount() {
+ // 初始化渲染页面
+ const {
+ cumDeductStore: { doInit, addForm },
+ taxAgentStore: { fetchTaxAgentOption, getTaxAgentSelectListAsAdmin }
+ } = this.props;
+ addForm.initFormFields(dataCollectCondition);
+ doInit({ declareMonth: [this.state.monthValue], taxAgentId: "" });
+ getTaxAgentSelectListAsAdmin();
+ fetchTaxAgentOption().then((res) => {
+ this.setState({
+ inited: true
+ });
+ });
+ }
+
+ getSearchsAdQuick() {
+ const { monthValue, taxAgentId } = this.state;
+ const {
+ taxAgentStore: { taxAgentOption },
+ cumDeductStore: { form, getTableDatas }
+ } = this.props;
+ return (
+
+
+ 税款所属期:
+ {
+ this.setState({ monthValue: v });
+ let params = {};
+ if (taxAgentId == "All") {
+ params.taxAgentId = "";
+ } else {
+ params.taxAgentId = taxAgentId;
+ }
+ if (v != null && v != "") {
+ params.declareMonth = [v];
+ }
+ getTableDatas(params);
+ }}
+ />
+
+
+
+
+
+
+
+ 个税扣缴义务人:
+
+ {
+ this.state.inited && {
+ let params = {};
+ if (v == "All") {
+ params.taxAgentId = "";
+ } else {
+ params.taxAgentId = v;
+ }
+ if (monthValue != null && monthValue != "") {
+ params.declareMonth = [monthValue];
+ }
+ getTableDatas(params);
+ this.setState({ taxAgentId: v });
+ }}
+ />
+ }
+
+
+ );
+ }
+
+ renderFormComponent() {
+ const { modalParam } = this.state;
+ const {
+ taxAgentStore: { taxAgentAdminOption }
+ } = this.props;
+ return (
+
+
+
+ 税款所属期
+
+
+ this.setState({
+ modalParam: { ...modalParam, declareMonth: value }
+ })
+ }
+ />
+
+
+
+ 个税扣缴义务人
+
+ {
+ this.setState({ modalParam: { ...modalParam, taxAgentId: v } });
+ }}
+ />
+
+
+ );
+ }
+
+ onEdit = (record) => {
+ const {
+ cumDeductStore: {
+ slideVisiable,
+ setSlideVisiable,
+ getCumDeductDetailList,
+ setCurrentRecord
+ }
+ } = this.props;
+ setSlideVisiable(true);
+ setCurrentRecord(record);
+ getCumDeductDetailList(record.id, { taxAgentId: record.taxAgentId });
+ };
+
+ // 增加编辑功能,重写columns绑定事件
+ getColumns = (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 "username":
+ return (
+ {
+ this.onEdit(record);
+ }}>
+ {text}
+
+ );
+ case "operate":
+ return (
+ {
+ this.onEdit(record);
+ }}>
+ 查看明细
+
+ );
+ default:
+ return ;
+ }
+ };
+ return newColumn;
+ });
+ return newColumns;
+ };
+
+ handleCancel() {
+ const { cumDeductStore } = this.props;
+ const { modalVisiable, setModalVisiable, setStep } = cumDeductStore;
+ setModalVisiable(false);
+ setStep(0);
+ }
+
+ onOperatesClick = (record, index, operate, flag) => {
+ switch (operate.index.toString()) {
+ case "0": // 查看明细
+ this.onEdit(record);
+ break;
+ }
+ };
+
+ showColumn = () => {
+ const {
+ cumDeductStore: { tableStore }
+ } = this.props;
+ tableStore.setColSetVisible(true);
+ tableStore.tableColSet(true);
+ };
+
+ // 初始化导入参数
+ handleInitModal() {
+ const {
+ cumDeductStore: { setSlideDataSource, setImportResult }
+ } = this.props;
+ setSlideDataSource([]);
+ setImportResult({});
+ }
+
+ onSelectChange = (val) => {
+ this.setState({
+ selectedKey: val
+ });
+ };
+
+ handleSearch = () => {
+ const { cumDeductStore: { getTableDatas } } = this.props;
+ const { monthValue, taxAgentId } = this.state;
+ let params = {};
+ if (monthValue != null && monthValue !== "") {
+ params.declareMonth = [monthValue];
+ }
+ if (taxAgentId != null && taxAgentId !== "" && taxAgentId !== "All") {
+ params.taxAgentId = taxAgentId;
+ }
+ getTableDatas({ ...params, current: 1 });
+ };
+
+ //新功能
+ handleSaveDeduction = (payload) => {
+ const { editId } = this.state;
+ this.setState({ saveLoading: true });
+ if (!_.isEmpty(editId)) {
+ API.editAddUpDeduction({ ...payload, id: editId.id }).then(({ status, errormsg }) => {
+ this.setState({ saveLoading: false });
+ if (status) {
+ message.success("编辑成功");
+ this.setState({
+ addVisible: false,
+ editId: {}
+ }, () => {
+ const { cumDeductStore: { doSearch, addForm } } = this.props;
+ const { monthValue, taxAgentId } = this.state;
+ doSearch({
+ declareMonth: [monthValue],
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ });
+ addForm.resetForm();
+ });
+ } else {
+ message.error(errormsg || "编辑失败");
+ }
+ });
+ } else {
+ API.createAddUpDeduction(payload).then(({ status, errormsg }) => {
+ this.setState({ saveLoading: false });
+ if (status) {
+ message.success("新增成功");
+ this.setState({
+ addVisible: false,
+ editId: {}
+ }, () => {
+ const { cumDeductStore: { doSearch, addForm } } = this.props;
+ const { monthValue, taxAgentId } = this.state;
+ doSearch({
+ declareMonth: [monthValue],
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ });
+ addForm.resetForm();
+ });
+ } else {
+ message.error(errormsg || "新增失败");
+ }
+ });
+ }
+ };
+ deleteSelectAddUpDeduction = () => {
+ const { monthValue: declareMonth, taxAgentId, selectedKey } = this.state;
+ const { cumDeductStore: { doSearch } } = this.props;
+ if (selectedKey.length === 0) {
+ message.warning("未选择条目");
+ return;
+ }
+ const payload = {
+ declareMonth,
+ ids: selectedKey
+ };
+ Modal.confirm({
+ title: "信息确认",
+ content: "确定删除所选数据吗?若数据已参与核算,已参与核算的数据不会受影响,点击核算将会按当前列表最新数据重新核算。",
+ onOk: () => {
+ API.deleteSelectAddUpDeduction(payload).then(({ status, errormsg }) => {
+ if (status) {
+ message.success("删除成功");
+ doSearch({
+ declareMonth: [declareMonth],
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ });
+ } else {
+ message.error(errormsg || "删除失败");
+ }
+ });
+ },
+ onCancel: () => {
+ }
+ });
+
+ };
+ deleteAllAddUpDeduction = () => {
+ const { monthValue: declareMonth, taxAgentId } = this.state;
+ const { cumDeductStore: { doSearch } } = this.props;
+ const payload = {
+ declareMonth,
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ };
+ Modal.confirm({
+ title: "信息确认",
+ content: `确定清空税款所属期为${declareMonth}的所有累计专项附加扣除数据吗?若数据已参与核算,已参与核算的数据不会受影响,点击核算将会按当前列表最新数据重新核算。`,
+ onOk: () => {
+ API.deleteAllAddUpDeduction(payload).then(({ status, errormsg }) => {
+ if (status) {
+ message.success("删除成功");
+ doSearch({
+ declareMonth: [declareMonth],
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ });
+ } else {
+ message.error(errormsg || "删除失败");
+ }
+ });
+ }
+ });
+ };
+ handleOperate = ({ key }, row) => {
+ const { monthValue: declareMonth, taxAgentId } = this.state;
+ const { cumDeductStore: { doSearch } } = this.props;
+ if (key === "edit") {
+ this.setState({
+ addVisible: true
+ }, () => {
+ API.getAddUpDeduction({ id: row.id }).then(({ status, data }) => {
+ if (status) {
+ this.setState({ editId: data });
+ }
+ });
+ });
+ } else if (key === "delete") {
+ const payload = {
+ declareMonth,
+ ids: [row.id]
+ };
+ Modal.confirm({
+ title: "信息确认",
+ content: `确定删除${row.departmentName}${row.username}(税款所属期:${declareMonth})的累计专项附加扣除数据吗?若数据已参与核算,已参与核算的数据不会受影响,点击核算将会按当前列表最新数据重新核算。`,
+ onOk: () => {
+ API.deleteSelectAddUpDeduction(payload).then(({ status, errormsg }) => {
+ if (status) {
+ message.success("删除成功");
+ doSearch({
+ declareMonth: [declareMonth],
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ });
+ } else {
+ message.error(errormsg || "删除失败");
+ }
+ });
+ }
+ });
+ }
+ };
+ autoAddAll = () => {
+ const { monthValue: declareMonth, taxAgentId } = this.state;
+ const { cumDeductStore: { doSearch } } = this.props;
+ this.setState({ addAllLoading: true });
+ API.autoAddAll({ yearMonth: declareMonth }).then(({ status, data, errormsg }) => {
+ this.setState({ addAllLoading: false });
+ if (status) {
+ message.success(data || "操作成功");
+ doSearch({
+ declareMonth: [declareMonth],
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ });
+ } else {
+ message.error(errormsg || "操作失败");
+ }
+ }).catch(() => this.setState({ addAllLoading: false }));
+ };
+ handleButtonClick = () => {
+ if (!this.handleChangeDebounce) {
+ this.handleChangeDebounce = _.debounce(this.handleChange, 500);
+ }
+ this.handleChangeDebounce();
+ };
+
+ handleChange = e => {
+ const url = `${window.location
+ .origin}/api/bs/hrmsalary/addUpDeduction/export?ids=&declareMonth=${this.state.monthValue}&taxAgentId=${this.state.taxAgentId == "All"
+ ? ""
+ : this.state.taxAgentId}`;
+ window.open(url, "_self");
+ };
+ handleExportAllDetailClick = () => {
+ if (!this.handleChangeDebounce) {
+ const {
+ cumDeductStore: { currentRecord }
+ } = this.props;
+ const url = `${window.location
+ .origin}/api/bs/hrmsalary/addUpDeduction/exportDetail?accumulatedSpecialAdditionalDeductionId=${currentRecord.id}&ids=&taxAgentId=${currentRecord.taxAgentId}`;
+ window.open(url, "_self");
+ }
+ this.handleChangeDebounce();
+ };
+
+ render() {
+ const {
+ modalParam,
+ slideSelectedKey,
+ monthValue,
+ taxAgentId,
+ addVisible,
+ editId,
+ saveLoading,
+ addAllLoading
+ } = this.state;
+ const { cumDeductStore, taxAgentStore } = this.props;
+ const {
+ loading,
+ dataSource,
+ columns,
+ pageObj,
+ addForm,
+ form,
+ condition,
+ tableStore,
+ showSearchAd,
+ getTableDatas,
+ doSearch,
+ setShowSearchAd,
+ previewImport,
+ importFile
+ } = cumDeductStore;
+ const { taxAgentOption, showOperateBtn } = taxAgentStore;
+ const {
+ slideVisiable,
+ setSlideVisiable,
+ modalVisiable,
+ setModalVisiable,
+ slideTableStore,
+ step,
+ setStep,
+ slideDataSource,
+ importResult,
+ setPageObj
+ } = cumDeductStore;
+ const selectedRowKeys = toJS(tableStore.selectedRowKeys) || [];
+
+ const detailSelectedRowKeys = toJS(slideTableStore.selectedRowKeys) || [];
+
+ const rightMenu = [
+ // 右键菜单
+ // {
+ // key: "BTN_COLUMN",
+ // icon: ,
+ // content: "显示列定制",
+ // onClick: this.showColumn,
+ // },
+ ];
+ const adBtn = [
+ // 高级搜索内部按钮
+ ,
+ ,
+
+ ];
+
+ const topTab = [];
+
+ const renderSearchOperationItem = () => {
+ return ;
+ };
+
+ const handleMenuClick = () => {
+ if (this.state.selectedKey.length == 0) {
+ message.warning("未选择条目");
+ return;
+ }
+ const url = `${window.location
+ .origin}/api/bs/hrmsalary/addUpDeduction/export?ids=${this.state.selectedKey.join(
+ ","
+ )}&declareMonth=${this.state.monthValue}&taxAgentId=${this.state.taxAgentId == "All"
+ ? ""
+ : this.state.taxAgentId}`;
+ window.open(url, "_self");
+ };
+
+ const handleBtnImport = () => {
+ const {
+ cumDeductStore: { setModalVisiable, setStep }
+ } = this.props;
+ setStep(0);
+ setModalVisiable(true);
+ };
+
+ const btns = [
+ ,
+
+ 导出选中
+
+ }
+ type="ghost">
+ 导出全部
+ ,
+ ,
+
+ 删除所选
+
+ }
+ type="ghost">
+ 一键清空
+ ,
+
+ ];
+
+ const handleExportSelectedDetailClick = () => {
+ if (this.state.slideSelectedKey.length === 0) {
+ message.warning("未选择条目");
+ return;
+ }
+ const {
+ cumDeductStore: { currentRecord }
+ } = this.props;
+ const url = `${window.location
+ .origin}/api/bs/hrmsalary/addUpDeduction/exportDetail?accumulatedSpecialAdditionalDeductionId=${currentRecord.id}&ids=${this.state.slideSelectedKey.join(",")}&taxAgentId=${currentRecord.taxAgentId}`;
+ window.open(url, "_self");
+ };
+
+ const renderBtns = () => {
+ return [
+
+ 导出选中
+
+ }
+ type="primary">
+ 导出全部
+
+ ];
+ };
+
+ const pagination = {
+ total: pageObj.total,
+ showTotal: (total) => `共 ${total} 条`,
+ pageSizeOptions: ["10", "20", "50", "100"],
+ showSizeChanger: true,
+ onShowSizeChange(current, pageSize) {
+ setPageObj({ ...pageObj, current, pageSize });
+ getTableDatas({
+ current,
+ pageSize,
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId,
+ declareMonth: monthValue && [monthValue]
+ });
+ },
+ onChange(current) {
+ setPageObj({ ...pageObj, current, pageSize: pageObj.pageSize });
+ getTableDatas({
+ current,
+ pageSize: pageObj.pageSize,
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId,
+ declareMonth: monthValue && [monthValue]
+ });
+ }
+ };
+ const rowSelection = {
+ selectedRowKeys: this.state.selectedKey,
+ onChange: this.onSelectChange
+ };
+ const newColumns = _.map([...columns], (item) => {
+ if (item.dataIndex === "username") {
+ return {
+ ...item,
+ width: 100,
+ fixed: "left",
+ render: (text, record) => (
+
+ )
+ };
+ } else if (item.dataIndex === "taxAgentName") {
+ return {
+ ...item,
+ width: 180,
+ fixed: "left"
+ };
+ } else if (item.dataIndex === "operate") {
+ return {
+ ...item,
+ width: 120,
+ fixed: "right",
+ render: (text, record) => (
+
+ )
+ };
+ } else {
+ return { ...item, width: 150 };
+ }
+ });
+ if (_.isEmpty(newColumns)) {
+ return renderLoading();
+ }
+ return (
+
+
} // 左侧图标
+ iconBgcolor="#F14A2D" // 左侧图标背景色
+ showDropIcon={false} // 是否显示下拉按钮
+ dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同)
+ buttons={showOperateBtn ? btns : []}
+ >
+
+ setShowSearchAd(bool)} //高级搜索面板受控
+ searchsAd={getSearchs(form, toJS(condition), 2)} // 高级搜索内部数据
+ buttonsAd={adBtn} // 高级搜索内部按钮
+ onSearch={() => this.handleSearch()} // 点搜索按钮时的回调
+ searchsAdQuick={this.getSearchsAdQuick()}
+ onSearchChange={(v) => form.updateFields({ username: v })} // 在搜索框中输入的文字改变时的回调: 这里需要同步高级搜索和外部搜索框的值
+ searchsBaseValue={form.getFormParams().username} // 外部input搜索值受控: 这里和高级搜索的requestname同步
+ />
+
+
+
+
+
+
+
+ {modalVisiable && (
+
{
+ this.handleInitModal();
+ }}
+ onValidate={() => {
+ this.handleValidate();
+ }}
+ params={modalParam}
+ columns={modalColumns}
+ step={step}
+ setStep={setStep}
+ slideDataSource={slideDataSource}
+ importResult={importResult}
+ onFinish={() => {
+ setModalVisiable(false);
+ setStep(0);
+ doSearch({
+ declareMonth: this.state.monthValue ? [this.state.monthValue] : "",
+ taxAgentId: taxAgentId === "All" ? "" : taxAgentId
+ });
+ }}
+ previewImport={(params) => {
+ previewImport(params);
+ }}
+ importFile={(params) => {
+ importFile(params);
+ }}
+ templateLink={"/api/bs/hrmsalary/addUpDeduction/downloadTemplate"}
+ renderFormComponent={() => this.renderFormComponent()}
+ visiable={modalVisiable}
+ onCancel={() => {
+ this.handleCancel();
+ }}
+ />
+ )}
+
+ {(slideVisiable || addVisible) && (
+ {
+ const { baseInfo } = this.addItemRef.state;
+ const bool = _.every(_.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId"]), v => !_.isEmpty(v));
+ if (!bool && _.isEmpty(editId)) {
+ Modal.warning({
+ title: "信息确认",
+ content: "必要信息不完整,红色*为必填项!"
+ });
+ return;
+ }
+ const payload = {
+ ..._.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId", "taxAgentName"]),
+ ...addForm.getFormParams()
+ };
+ this.handleSaveDeduction(payload);
+ }}
+ editable={!!addVisible}
+ showOperateBtn={showOperateBtn}
+ customOperate={(showOperateBtn && !addVisible) ? renderBtns() : []}
+ />
+ }
+ content={
+ addVisible ?
+ this.addItemRef = dom}
+ taxAgentOption={taxAgentOption}
+ form={addForm}
+ editId={editId}
+ condition={dataCollectCondition}
+ /> :
+
+ this.setState({ slideSelectedKey: val })
+ }
+ />
+ }
+ onClose={() => {
+ setSlideVisiable(false);
+ this.setState({
+ addVisible: false,
+ editId: {}
+ });
+ }}
+ showMask={true}
+ closeMaskOnClick={() => {
+ setSlideVisiable(false);
+ this.setState({
+ addVisible: false,
+ editId: {}
+ });
+ }}
+ />
+ )}
+
+ );
+ }
+}