import React, { Component } from "react"; import { WeaCheckbox, WeaTab, WeaTable } from "ecCom"; import { Button } from "antd"; import { inject, observer } from "mobx-react"; import * as API from "../../../apis/offlineCompare"; import { getSearchs, renderLoading } from "../../../util"; import { getQueryString } from "../../../util/url"; import { calculateCompares } from "../../calculateDetail/compareDetail"; import CompareDetailImportModal from "../../calculateDetail/compareDetailImportModal"; import { conditions } from "./condition"; import "./index.less"; @inject("standingBookStore") @observer class StandingBookOfflineComparison extends Component { constructor(props) { super(props); this.state = { columns: [], dataSource: [], onlyDiffEmployee: "1", showSearchAd: false, loading: true, importVisible: false, pageInfo: { current: 1, pageSize: 10, total: 0 } }; } componentDidMount() { const { standingBookStore: { ocForm: form } } = this.props; this.comparisonwelfareList(); form.initFormFields(conditions); } comparisonwelfareList = () => { const billMonth = getQueryString("billMonth"); const paymentOrganization = getQueryString("paymentOrganization"); const { onlyDiffEmployee, pageInfo } = this.state; const { standingBookStore: { ocForm: form } } = this.props; const formParams = form.getFormParams(); const payload = { paymentStatus: 0, billMonth, paymentOrganization, onlyDiffEmployee: onlyDiffEmployee === "1" }; this.setState({ loading: true }); API.comparisonwelfareList({ ...payload, ...pageInfo, ...formParams }).then(({ status, data }) => { this.setState({ loading: false }); if (status) { const { columns, list: dataSource, total, pageNum: current, pageSize } = data; this.setState({ columns: _.map(columns, (it, idx) => ({ ...it, width: 150, fixed: idx < 2 ? "left" : false, render: (text, record) => { const { acctResultValue, excelResultValue } = record[it.dataIndex] || {}; if (Object.prototype.toString.call(text) === "[object Object]") { return
系统值:{acctResultValue}
线下值:{excelResultValue}
差值:{calculateCompares(acctResultValue, excelResultValue)}
; } return {text}; } })), dataSource, pageInfo: { ...pageInfo, current, total, pageSize } }); } }); }; handleExport = () => { const billMonth = getQueryString("billMonth"); const paymentOrganization = getQueryString("paymentOrganization"); const { onlyDiffEmployee } = this.state; let url = `/api/bs/hrmsalary/siaccount/comparisonresult/export?paymentStatus=0&billMonth=${billMonth}&paymentOrganization=${paymentOrganization}&onlyDiffEmployee=${onlyDiffEmployee === "1"}`; window.open(`${window.location.origin}${url}`); }; render() { const { onlyDiffEmployee, showSearchAd, pageInfo, dataSource, columns, loading, importVisible } = this.state; const { standingBookStore: { ocForm: form } } = this.props; if (_.isEmpty(columns)) { // 无权限处理 return renderLoading(); } const buttons = [ , ]; const adBtn = [ , , ]; return (
this.setState({ showSearchAd })} searchsAd={getSearchs(form, conditions, 2)} onSearch={() => { this.setState({ showSearchAd: false }, () => { this.comparisonwelfareList(); }); }} onSearchChange={v => form.updateFields({ userName: v })} searchsBaseValue={form.getFormParams().userName} searchsAdQuick={ this.setState({ onlyDiffEmployee }, () => { this.comparisonwelfareList(); }) } content="只显示有差异的人员"/> } /> `共 ${total} 条`, showSizeChanger: true, pageSizeOptions: ["10", "20", "50", "100"], onShowSizeChange: (current, pageSize) => { this.setState({ pageInfo: { ...pageInfo, current, pageSize } }, () => { this.comparisonwelfareList(); }); }, onChange: current => { this.setState({ pageInfo: { ...pageInfo, current } }, () => { this.comparisonwelfareList(); }); } }} /> { importVisible && this.comparisonwelfareList()} onCancel={() => this.setState({ importVisible: false })} /> }
); } } export default StandingBookOfflineComparison;