import React from "react"; import { Button, Col, Icon, message, Modal, Row } from "antd"; import { WeaBrowser, WeaFormItem, WeaHelpfulTip, WeaInput, WeaLocaleProvider, WeaSearchGroup, WeaSelect, WeaTab } from "ecCom"; import { inject, observer } from "mobx-react"; import { getQueryString } from "../../util/url"; import "./index.less"; const { getLabel } = WeaLocaleProvider; @inject("calculateStore", "salaryFileStore") @observer export default class UserSure extends React.Component { constructor(props) { super(props); this.state = { showSearchAd: false, searchItemsValue: { employeeName: "", workcode: "", departmentIds: "", positionIds: "", statuses: "" }, selectedKey: "0", selectedRowKeys: [], // table 选中项 userListSearchValue: "" }; this.id = ""; this.current = 1; this.pageInfo = { current: 1, pageSize: 10 }; } componentWillMount() { let id = getQueryString("id"); this.id = id; const { calculateStore } = this.props; const { salaryacctGetForm, getSalarySobCycle } = calculateStore; salaryacctGetForm(id); this.current = 1; getSalarySobCycle(id); } Input = (value, key) => { const { employeeName, workcode } = this.state.searchItemsValue; return ( this.setState({ searchItemsValue: { ...this.state.searchItemsValue, [key]: val } })}/> ); }; Browser = (value, key) => { const { positionIds, departmentIds } = this.state.searchItemsValue; return ( { this.setState({ searchItemsValue: { ...this.state.searchItemsValue, [key]: val } }); }}/> ); }; Select = (value, key) => { const { statuses } = this.state.searchItemsValue; return ( this.setState({ searchItemsValue: { ...this.state.searchItemsValue, [key]: val } })}/> ); }; componentDidMount() { window.addEventListener("message", this.handleClick, false); } componentWillUnmount() { window.removeEventListener("message", this.handleClick, false); } handleClick = ({ data }) => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); const { type, data: { id, data: record, extraId = "" } = {} } = data; let payload = {}; if (type === "PC") { if (id === "SA") { payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); //window.postMessage } else if (id === "DELETE") { this.handleDeleteItem(record); } else if (id === "COSTCENTER") { window.open(record.url, "_blank"); } else if (id === "BATCHDELETE") { this.onSelectChange(record); } else if (id === "PAGEINFO") { const { pageNum: current, size: pageSize } = record; this.pageInfo = { current, pageSize }; if (extraId === "SA") { const payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue, current, pageSize } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); } else if (extraId === "MA") { const payload = { type: "PC", listType: "MA", url: this.state.selectedKey === "1" ? "/api/bs/hrmsalary/salaryacct/reducedemployee/list" : "/api/bs/hrmsalary/salaryacct/addedemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue, current, pageSize } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); } } } }; // 添加人员回调 handleUserBrowserChange(ids) { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); if (ids && ids.length > 0) { let idList = ids.split(","); const { calculateStore: { saveAcctemployee, checkTaxAgent } } = this.props; saveAcctemployee(this.id, idList).then(() => { message.success("添加成功"); const payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue, ...this.pageInfo } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); checkTaxAgent(this.id); }); } } // 导出 handleExport() { let url = ""; if (this.state.selectedKey == 0) { url = `${window.location.origin}/api/bs/hrmsalary/salaryacct/acctemployee/export?salaryAcctRecordId=${this.id}`; } else if (this.state.selectedKey == 1) { url = `${window.location.origin}/api/bs/hrmsalary/salaryacct/reducedemployee/export?salaryAcctRecordId=${this.id}`; } else { url = `${window.location.origin}/api/bs/hrmsalary/salaryacct/addedemployee/export?salaryAcctRecordId=${this.id}`; } window.open(url, "_self"); } // 批量删除 handleBatchDelete() { const { selectedRowKeys } = this.state; const { calculateStore: { deleteAcctemployee } } = this.props; if (selectedRowKeys.length == 0) { message.warning("未选择条目"); return; } Modal.confirm({ title: "信息确认", content: "确认删除", onOk: () => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); deleteAcctemployee(this.id, selectedRowKeys).then(() => { message.success("删除成功"); const payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue, ...this.pageInfo, current: 1 } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); }); }, onCancel: () => { } }); } // 删除人员 handleDeleteItem = record => { const { calculateStore: { deleteAcctemployee } } = this.props; Modal.confirm({ title: "信息确认", content: "确认删除", onOk: () => { deleteAcctemployee(this.id, [record.id]).then(() => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); const payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue, ...this.pageInfo } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); }); }, onCancel: () => { } }); }; // 刷新薪资核算人员的个税扣缴义务人 handleRefresh = () => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); const { calculateStore: { refreshTaxAgent } } = this.props; refreshTaxAgent(salaryAcctRecordId).then(() => { const payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue, ...this.pageInfo } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); }); }; onSelectChange = selectedRowKeys => { this.setState({ selectedRowKeys, userListSearchValue: "" }); }; // 搜索 handleUserListSearch = (value) => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); this.pageInfo.current = 1; if (this.state.selectedKey == 0) { const payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...value } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); } else { const payload = { type: "PC", listType: "MA", url: "/api/bs/hrmsalary/salaryacct/reducedemployee/list", queryParams: { salaryAcctRecordId, ...value } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); } }; render() { const { showSearchAd, selectedKey } = this.state; const { calculateStore } = this.props; const { calculateBaseForm, baseSalarySobCycle } = calculateStore; const adBtn = [ // 高级搜索内部按钮 , , ]; const renderSearch = () => { const searchItems = [ { com: this.Input("姓名", "employeeName") }, { com: this.Input("工号", "workcode") }, { com: this.Browser("部门", "departmentIds") }, { com: this.Browser("岗位", "positionIds") }, { com: this.Select("状态", "statuses") } ]; return ; }; return (
基本信息
薪资所属月: : ""} placement="topLeft" /> {calculateBaseForm.formDTO && calculateBaseForm.formDTO.salaryMonth} 核算账套: {calculateBaseForm.formDTO && calculateBaseForm.formDTO.salarySobName} 备注: {calculateBaseForm.formDTO && calculateBaseForm.formDTO.description}
{ this.setState({ selectedKey: "0" }, () => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); const payload = { type: "PC", listType: "SA", url: "/api/bs/hrmsalary/salaryacct/acctemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); //window.postMessage }); }}> 核算人员范围 | { this.setState({ selectedKey: "1" }, () => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); const payload = { type: "PC", listType: "MA", url: "/api/bs/hrmsalary/salaryacct/reducedemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); }); }}> 环比上月减少人员 | { this.setState({ selectedKey: "2" }, () => { const childFrameObj = document.getElementById("atdTable"); const salaryAcctRecordId = getQueryString("id"); const payload = { type: "PC", listType: "MA", url: "/api/bs/hrmsalary/salaryacct/addedemployee/list", queryParams: { salaryAcctRecordId, ...this.state.searchItemsValue } }; childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*"); }); }}> 环比上月增加人员
this.setState({ showSearchAd: bool })} //高级搜索面板受控 searchsAd={renderSearch()} // 高级搜索内部数据getSearchs(form, toJS(condition), 2) buttonsAd={adBtn} // 高级搜索内部按钮 onSearch={() => this.handleUserListSearch(this.state.searchItemsValue)} // 点搜索按钮时的回调 buttons={selectedKey == 0 ? [ { this.handleBatchDelete(); }} title="批量删除" />, this.handleUserBrowserChange(ids)}> , { this.handleExport(); }} style={{ fontSize: 20, position: "relative", top: 2 }} title="导出" /> // { // this.handleRefresh(); // }} // style={{ fontSize: 20, position: "relative", top: 2 }} // title="刷新" // /> ] : [ { this.handleExport(); }} style={{ fontSize: 20, position: "relative", top: 2 }} title="导出" /> ]} searchsBasePlaceHolder={"请输入姓名"} onSearchChange={(v) => this.setState({ searchItemsValue: { ...this.state.searchItemsValue, employeeName: v } }) } // 在搜索框中输入的文字改变时的回调: 这里需要同步高级搜索和外部搜索框的值form.updateFields({ username: v }) searchsBaseValue={this.state.searchItemsValue.employeeName} // 外部input搜索值受控: 这里和高级搜索的requestname同步form.getFormParams().username />