/* * Author: 黎永顺 * name:薪资档案 * Description: * Date: 2022-10-10 17:53:44 */ import React, { Component } from "react"; import { toJS } from "mobx"; import { inject, observer } from "mobx-react"; import { tabCondition } from "./config"; import * as API from "../../apis/payrollFiles"; import { WeaBrowser, WeaFormItem, WeaHelpfulTip, WeaInput, WeaLocaleProvider, WeaPopoverHrm, WeaSearchGroup, WeaSelect, WeaSlideModal, WeaTab, WeaTop } from "ecCom"; import { WeaTableNew } from "comsMobx"; import { Button, Dropdown, Menu, message, Modal, Spin } from "antd"; import ImportMenu from "./components/importMenu"; import ExportMenu from "./components/exportMenu"; import AllWithoutPay from "./components/allWithoutPay"; import BatchSuspendsPay from "./components/batchSuspendsPay"; import SlideModalTitle from "../../components/slideModalTitle"; import SalaryFileViewSlide from "../salaryFile/saralyFileViewSlide"; import { sysinfo } from "../../apis/ruleconfig"; import SalaryArchiveEditAdjLogRecord from "../salaryFile/salaryArchiveEditAdjLogRecord"; import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; const WeaTableComx = WeaTableNew.WeaTable; @inject("payrollFilesStore", "taxAgentStore", "salaryFileStore") @observer class Index extends Component { constructor(props) { super(props); this.state = { selectedKey: "pending", showSearchAd: false, dataSource: [], archiveStatusList: [], userStatusList: [], importType: [], selectedRowKeys: [], tabCount: { SUSPEND: 0, STOP: 0, FIXED: 0, PENDING: 0 }, loading: { query: false, add: false, update: false }, pageInfo: { current: 1, pageSize: 10, total: 0 }, searchItemsValue: { username: "", workcode: "", departmentIds: "", positionIds: "", statuses: "", // archiveStatus: "EFFICIENT", taxAgentId: "", subcompanyIds: "" }, salaryAdjustmentInfo: {}, adjLogRecordDialog: { visible: false, title: "", id: "", salaryArchiveId: "" }, noPayDate: "", slideParams: { visible: false, id: "" }, paysetParams: { payStartDate: "", payEndDate: "" }, salaryArchiveDelete: "", //待定薪、停薪员工 是否允许删除薪资档案 0: 否, 1: 是, extEmpsWitch: "1" //非系统人员开关, 1: 开启, 0:关闭 }; } Input = (value, key) => { const { username, workcode } = this.state.searchItemsValue; return ( this.setState({ searchItemsValue: { ...this.state.searchItemsValue, [key]: val } })}/> ); }; Browser = (value, key) => { const { positionIds, departmentIds, subcompanyIds } = this.state.searchItemsValue; return ( { this.setState({ searchItemsValue: { ...this.state.searchItemsValue, [key]: val } }); }}/> ); }; Select = (value, key) => { const { taxAgentStore } = this.props; const { statuses, archiveStatus, taxAgentId } = this.state.searchItemsValue; const { archiveStatusList, userStatusList } = this.state; const { taxAgentOption } = taxAgentStore; return ( this.setState({ searchItemsValue: { ...this.state.searchItemsValue, [key]: val } })}/> ); }; componentDidMount() { const { taxAgentStore } = this.props; const { fetchTaxAgentOption } = taxAgentStore; fetchTaxAgentOption(); this.queryTabTotal(); this.queryList("/api/bs/hrmsalary/salaryArchive/pendingList"); this.getSysinfo(); const init = this.init(); window.addEventListener("message", this.handleReceive, false); } componentWillUnmount() { window.removeEventListener("message", this.handleReceive, false); } /* * Author: 黎永顺 * Description: 非系统人员开关查询 * Params: * Date: 2023/7/14 */ getSysinfo = () => { sysinfo().then(({ status, data }) => { if (status) this.setState({ extEmpsWitch: data.extEmpsWitch }); }); }; handleReceive = ({ data }) => { const { payrollFilesStore: { tableStore }, taxAgentStore: { showOperateBtn } } = this.props; const columns = _.map(_.filter(toJS(tableStore.columns), (item) => item.display === "true"), (it, idx) => ({ dataIndex: it.dataIndex, width: (it.dataIndex === "username" || it.dataIndex === "operate") ? 150 : it.dataIndex === "taxAgentName" ? 176 : 150, title: it.title, align: "left", fixed: (idx === 0 || idx === 1 || idx === 2) ? "left" : it.dataIndex === "operate" ? "right" : "", ellipsis: true })); const { type, payload: { id, params } = {} } = data; const { dataSource, pageInfo, selectedKey, selectedRowKeys } = this.state; if (type === "init") { this.postMessageToChild({ columns, dataSource, showOperateBtn, selectedKey, showSum: false, pageInfo, selectedRowKeys }); } else if (type === "turn") { if (id === "PAGEINFO") { const { pageNum: current, size: pageSize } = params; this.setState({ pageInfo: { ...pageInfo, current, pageSize } }, () => this.query()); } else if (id === "EDIT") { const { record } = params; this.handleEdit(record); } else if (id === "MOREOPT") { const { id, event: e } = params; this.handleMenuClick(e, id); } else if (id === "CANCELSTOP") { const { id } = params; this.cancelStop(id); } else if (id === "ROWSELECTION") { const { selectedRowKeys } = params; this.setState({ selectedRowKeys }); } } }; postMessageToChild = (payload) => { const childFrameObj = document.getElementById("atdTable"); const { dataSource, columns, showSum, pageInfo, showOperateBtn, selectedKey, selectedRowKeys } = payload; const { salaryArchiveDelete } = this.state; childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ dataSource, columns, showSum, pageInfo, showOperateBtn, selectedKey, selectedRowKeys, salaryArchiveDelete }), "*"); }; init = async () => { const { data: archiveStatusList } = await this.commonEnumList({ enumClass: "com.engine.salary.enums.salaryarchive.ArchiveStatusEnum" }); const { data: userStatusList } = await this.commonEnumList({ enumClass: "com.engine.salary.enums.UserStatusEnum" }); const { data: salaryArchiveDelete } = await this.salaryArchiveDelete(); this.setState({ archiveStatusList: [{ key: "", showname: "" }, ..._.map(archiveStatusList, it => ({ key: String(it.value), showname: it.defaultLabel }))], userStatusList: [..._.map(userStatusList, it => ({ key: String(it.value), showname: it.defaultLabel }))], salaryArchiveDelete }, () => this.getImportTypes()); }; salaryAdjustmentInfo = () => { API.salaryAdjustmentInfo().then(({ status, data }) => { if (status) { this.setState({ salaryAdjustmentInfo: data }); } }); }; queryTabTotal = () => { API.queryTabTotal().then(({ data = {}, status }) => { if (status) { this.setState({ tabCount: { ...this.state.tabCount, ...data } }); } }); }; queryList = (url) => { const { loading, pageInfo, searchItemsValue, selectedKey } = this.state; const { payrollFilesStore: { tableStore, queryList }, taxAgentStore: { showOperateBtn } } = this.props; const payload = { ...pageInfo }; this.setState({ loading: { ...loading, query: true } }); queryList(payload, searchItemsValue, url).then(({ data, status }) => { this.setState({ loading: { ...loading, query: false } }); if (status && selectedKey === _.lowerCase(data.listType)) { const { pageInfo: paganition } = data; const { list: dataSource, total, pageNum: current, pageSize } = paganition; this.setState({ dataSource, pageInfo: { ...pageInfo, total, current, pageSize }, tabCount: { ...this.state.tabCount, [tabCountKey[selectedKey]]: total } }); } }); }; //一键全部设为定薪员工 allGotoFixed = () => { const { pageInfo } = this.state; if (pageInfo.total === 0) { message.warning("您没有需要处理的待定薪人员!"); return; } Modal.warning({ title: "信息确认", content: `确定要将所有待定薪人员(共${pageInfo.total}条数据)设为发薪人员吗?`, onOk: () => { API.allGotoFixed({}).then(({ status, data, errormsg }) => { if (status) { const { msg } = data; message.info(msg || "操作成功!"); this.queryTabTotal(); this.query(); } else { message.error(errormsg || "操作失败!"); } }); } }); }; commonEnumList = (params) => { return API.commonEnumList(params); }; salaryArchiveDelete = () => { return API.salaryArchiveDelete(); }; getImportTypes = () => { API.getImportTypes().then(({ data, status }) => { if (status) { this.setState({ importType: data }); } }); }; //取消停薪 cancelStop = (id) => { API.cancelStop([id]).then(({ status, errormsg }) => { if (status) { message.success("操作成功!"); this.queryTabTotal(); this.query(); } else { message.error(errormsg || "操作失败!"); } }); }; //待定薪删除待办 deletePendingTodo = (params) => { API.deletePendingTodo(params).then(({ status, errormsg }) => { if (status) { message.success("操作成功!"); this.setState({ selectedRowKeys: [] }, () => { this.queryTabTotal(); this.query(); }); } else { message.error(errormsg || "操作失败!"); } }); }; //待停薪删除待办 deleteSuspendTodo = (params) => { API.deleteSuspendTodo(params).then(({ status, errormsg }) => { if (status) { message.success("操作成功!"); this.setState({ selectedRowKeys: [] }, () => { this.query(); this.queryTabTotal(); }); } else { message.error(errormsg || "操作失败!"); } }); }; handleClick = ({ key }) => { const { selectedRowKeys } = this.state; if (selectedRowKeys.length === 0) { message.warning("请选择表格数据"); return; } if (key === "batchDelete") { this.deletePendingTodo(selectedRowKeys); } else { API.gotoFixed(selectedRowKeys).then(({ status, data, errormsg }) => { if (status) { if (data.type === "success") { message.success("操作成功!"); this.setState({ selectedRowKeys: [] }, () => { this.queryTabTotal(); this.query(); }); } else { message.info(data.msg); } } else { message.error(errormsg || "操作失败!"); } }); } }; getRightOptionBtns = () => { const { selectedKey, importType, selectedRowKeys, searchItemsValue, pageInfo } = this.state; const { taxAgentStore: { showOperateBtn } } = this.props; if (selectedKey === "pending" && showOperateBtn) { return [ , }> , , 批量设为发薪员工 批量删除待办 } > ]; } else if (selectedKey === "fixed" && showOperateBtn) { return [ } placement="topLeft" />, { this.query(); this.setState({ selectedRowKeys: [] }); }}/> }> , }> ]; } else if (selectedKey === "suspend" && showOperateBtn) { return [ { this.queryTabTotal(); this.query(); this.setState({ selectedRowKeys: [] }); }} /> }> , , , }> ]; } else if (selectedKey === "stop" && showOperateBtn) { return [ { this.queryTabTotal(); this.query(); this.setState({ selectedRowKeys: [] }); }} /> }> , }> ]; } else if (selectedKey === "ext" && showOperateBtn) { return [ } placement="topLeft" />, { this.query(); this.setState({ selectedRowKeys: [] }); }}/> }> ]; } return []; }; getColumns = () => { const { payrollFilesStore: { tableStore }, taxAgentStore: { showOperateBtn } } = this.props; const columns = _.map(_.filter(toJS(tableStore.columns), (item) => item.display === "true"), (it, idx) => ({ dataIndex: it.dataIndex, width: (it.dataIndex === "username" || it.dataIndex === "operate") ? 150 : it.dataIndex === "taxAgentName" ? 176 : 150, title: it.title, align: "left", fixed: (idx === 0 || idx === 1 || idx === 2) ? "left" : it.dataIndex === "operate" ? "right" : "", ellipsis: true })); this.postMessageToChild({ columns, showOperateBtn, selectedKey: this.state.selectedKey, dataSource: this.state.dataSource, selectedRowKeys: this.state.selectedRowKeys, showSum: false, pageInfo: this.state.pageInfo }); }; handleEdit = (record) => { const { selectedKey } = this.state; this.setState({ slideParams: { ...this.state.slideParams, visible: true, id: record.id } }, () => selectedKey === "fixed" && this.salaryAdjustmentInfo()); }; //列表操作 handleMenuClick = (e, id) => { const { key } = e; if (key === "payroll") { //设为定薪员工 API.gotoFixed([id]).then(({ status, errormsg }) => { if (status) { message.success("操作成功!"); this.query(); } else { message.error(errormsg || "操作失败!"); } }); } else if (key === "stopSalary") { //停薪 API.gotoStop([id]).then(({ status, errormsg }) => { if (status) { message.success("操作成功!"); this.query(); } else { message.error(errormsg || "操作失败!"); } }); } else if (key === "deletePendingTodo") { this.deletePendingTodo([id]); } else if (key === "deleteSuspendTodo") { this.deleteSuspendTodo([id]); } else if (key === "view") { this.handleEdit(id); } else if (key === "deleteAchives") { Modal.confirm({ title: getLabel(131329, "信息确认"), content: getLabel(388758, "确认要删除吗?"), onOk: () => { API.deleteSalaryArchive([id]).then(({ status, errormsg }) => { if (status) { message.success(getLabel(30700, "操作成功")); this.query(); } else { message.error(errormsg || getLabel(30651, "操作失败")); } }); } }); } }; // 查看 Slide 头部操作按钮 renderEditSlideOperate = () => { const { taxAgentStore: { showOperateBtn } } = this.props; const { slideParams: { id }, salaryAdjustmentInfo, selectedKey } = this.state; const { isShow, url } = salaryAdjustmentInfo; let arrList = []; if (showOperateBtn && isShow === "true" && selectedKey === "fixed") { arrList.push(); } if (showOperateBtn && (selectedKey === "fixed" || selectedKey === "ext")) { arrList.push(); } selectedKey !== "stop" && arrList.push(); return arrList; }; //切换tab handleChangeTab = (selectedKey) => { const { slideParams, pageInfo } = this.state; this.setState({ selectedRowKeys: [], slideParams: { ...slideParams, visible: false, id: "" }, selectedKey, pageInfo: { ...pageInfo, current: 1, pageSize: 10 } }, () => { if (!this.handleChangeDebounce) { this.handleChangeDebounce = _.debounce(() => { this.query(); }, 500); } this.handleChangeDebounce(); }); }; //编辑保存 handleSave = () => { const { paysetParams, selectedKey } = this.state; const { salaryFileStore: { adjustSalaryItems, detailForm } } = this.props; if ((selectedKey === "pending" && _.isEmpty(paysetParams.payStartDate)) || (selectedKey === "suspend" && _.isEmpty(paysetParams.payEndDate))) { Modal.warning({ title: "信息确认", content: "必要信息不完整,红色*为必填项!" }); return; } const payload = { ...paysetParams, salaryArchiveId: detailForm.id, salaryArchiveItems: _.map(toJS(adjustSalaryItems), it => ({ salaryItemId: it.id, adjustValue: String(it.value || "") })), status: selectedKey === "ext" ? "FIXED" : _.upperCase(selectedKey) }; API.savePaySet(payload).then(({ status, errormsg }) => { if (status) { message.success("操作成功!"); this.query(); } else { message.error(errormsg || "保存失败!"); } }); }; //发薪设置 handleSetpay = (params) => { const { type, date } = params; const { paysetParams } = this.state; if (type === "起始发薪日期") { this.setState({ paysetParams: { ...paysetParams, payStartDate: date } }); } else if (type === "最后发薪日期") { this.setState({ paysetParams: { ...paysetParams, payEndDate: date } }); } }; query = () => { const { selectedKey } = this.state; switch (selectedKey) { case "pending": this.queryList("/api/bs/hrmsalary/salaryArchive/pendingList"); break; case "fixed": this.queryList("/api/bs/hrmsalary/salaryArchive/fixedList"); break; case "suspend": this.queryList("/api/bs/hrmsalary/salaryArchive/suspendList"); break; case "stop": this.queryList("/api/bs/hrmsalary/salaryArchive/stopList"); break; default: this.queryList("/api/bs/hrmsalary/salaryArchive/extList"); break; } }; render() { const { tabCount, selectedKey, loading, pageInfo, showSearchAd, slideParams, adjLogRecordDialog, paysetParams, extEmpsWitch } = this.state; const { payrollFilesStore: { tableStore } } = this.props; const renderSearch = () => { const searchItems = [ { com: this.Input("姓名", "username") }, { com: this.Browser("分部", "subcompanyIds") }, { com: this.Browser("部门", "departmentIds") }, { com: this.Browser("岗位", "positionIds") }, { com: this.Select("人员状态", "statuses") }, // { com: this.Select("档案状态", "archiveStatus") }, { com: this.Select("个税扣缴义务人", "taxAgentId") }, { com: this.Input("工号", "workcode") } ]; return ; }; const adBtn = [ // 高级搜索内部按钮 , , ]; const rightMenu = [ { key: "BTN_COLUMN", icon: , content: "显示列定制", onClick: () => { tableStore.setColSetVisible(true); tableStore.tableColSet(true); } } ]; return (
} iconBgcolor="#F14A2D" showDropIcon={true} dropMenuDatas={rightMenu} > this.setState({ showSearchAd: bool })} //高级搜索面板受控 searchsAd={renderSearch()} // 高级搜索内部数据g1etSearchs(form, toJS(condition), 2) buttonsAd={adBtn} // 高级搜索内部按钮 onSearch={() => { this.setState({ pageInfo: { ...pageInfo, current: 1, pageSize: 10 } }, () => { this.query(); }); }} // 点搜索按钮时的回调this.handleSearch() searchsBasePlaceHolder={"请输入姓名"} onSearchChange={(v) => this.setState({ searchItemsValue: { ...this.state.searchItemsValue, username: v } })} // 在搜索框中输入的文字改变时的回调: 这里需要同步高级搜索和外部搜索框的值form.updateFields({ username: v }) searchsBaseValue={this.state.searchItemsValue.username} />