diff --git a/pc4mobx/hrmSalary/pages/payrollFiles/components/advanceInputBtn/index.js b/pc4mobx/hrmSalary/pages/payrollFiles/components/advanceInputBtn/index.js index b3260f1b..3163fd29 100644 --- a/pc4mobx/hrmSalary/pages/payrollFiles/components/advanceInputBtn/index.js +++ b/pc4mobx/hrmSalary/pages/payrollFiles/components/advanceInputBtn/index.js @@ -12,11 +12,11 @@ import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; -@inject("salaryFileStore") +@inject("payrollFilesStore") @observer class Index extends Component { render() { - const { salaryFileStore: { salaryFileQueryForm } } = this.props; + const { payrollFilesStore: { salaryFileQueryForm } } = this.props; return (
({ key: String(o.value), showname: o.defaultLabel })) }; - } else if (getKey(child) === "statuses") { + } else if (getKey(child) === "taxAgentId") { return { ...child, options: _.map(taxAgentList, o => ({ key: o.id, showname: o.content })) @@ -52,14 +52,14 @@ class salaryFileAdvanceSearchPannel extends Component { }; }) }, () => { - const { salaryFileStore: { salaryFileQueryForm } } = this.props; + const { payrollFilesStore: { salaryFileQueryForm } } = this.props; salaryFileQueryForm.initFormFields(this.state.searchConditions); }); } render() { const { searchConditions } = this.state; - const { salaryFileStore: { salaryFileQueryForm } } = this.props; + const { payrollFilesStore: { salaryFileQueryForm } } = this.props; return (
diff --git a/pc4mobx/hrmSalary/pages/payrollFiles/components/salaryFileImportDialog/index.js b/pc4mobx/hrmSalary/pages/payrollFiles/components/salaryFileImportDialog/index.js new file mode 100644 index 00000000..c9a7d295 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/payrollFiles/components/salaryFileImportDialog/index.js @@ -0,0 +1,117 @@ +/* + * Author: 黎永顺 + * name: 薪资档案页面重构-导入弹窗 + * Description: + * Date: 2024/1/9 + */ +import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; +import { WeaCheckbox, WeaLocaleProvider } from "ecCom"; +import ImportDialog from "../../../.././components/importDialog"; +import { convertToUrlString, getURLParameters } from "../../../../util/url"; +import { importSalaryArchive } from "../../../../apis/payrollFiles"; + +const getLabel = WeaLocaleProvider.getLabel; + +@inject("payrollFilesStore") +@observer +class Index extends Component { + constructor(props) { + super(props); + this.state = { + importDialog: { + nextloading: false, link: "", importResult: {}, imageId: "", + previewUrl: "/api/bs/hrmsalary/salaryArchive/preview", + extraPreview: {} + } + }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) { + const { payrollFilesStore: { salaryFileQueryForm }, importType, isExtEmp } = nextProps; + let payload = {}, extraPreview = {}; + if (importType !== "init" && importType !== "salaryItemAdjust") { + extraPreview = { + importType: "", listType: importType + }; + payload = { + importType: "", listType: importType, + ...salaryFileQueryForm.getFormParams() + }; + } else { + extraPreview = { + importType: importType, listType: "FIXED" + }; + payload = { + importType: importType, listType: "FIXED", + ...salaryFileQueryForm.getFormParams() + }; + } + if (isExtEmp) payload = { ...payload, extSalaryArchiveList: true }; + this.setState({ + importDialog: { + ...this.state.importDialog, extraPreview, + link: `/api/bs/hrmsalary/salaryArchive/downloadTemplate?${convertToUrlString(payload)}` + } + }); + } else { + this.setState({ + importDialog: { + nextloading: false, link: "", importResult: {}, imageId: "", + previewUrl: "/api/bs/hrmsalary/salaryArchive/preview", + extraPreview: {} + } + }); + } + } + + handleImport = (payload) => { + const { importDialog } = this.state, { isExtEmp } = this.props; + const { extraPreview } = importDialog; + this.setState({ importDialog: { ...importDialog, nextloading: true } }); + importSalaryArchive({ ...payload, ...extraPreview, isExtEmp }).then(({ data, status }) => { + this.setState({ importDialog: { ...importDialog, nextloading: false } }); + if (status) { + this.setState({ + importDialog: { ...importDialog, ...payload, importResult: data } + }); + } + }).catch(() => this.setState({ importDialog: { ...importDialog, nextloading: false } })); + }; + + render() { + const { importDialog } = this.state; + const { link } = importDialog; + return ( + this.setState({ + importDialog: { + ...importDialog, importResult: {}, imageId: "", link: "" + } + })} + exportDataDom={ + { + let payload = { ...getURLParameters(link), hasData: val === "1" }; + this.setState({ + importDialog: { + ...importDialog, + link: `/api/bs/hrmsalary/salaryArchive/downloadTemplate?${convertToUrlString(payload)}` + } + }); + }} + /> + } + nextCallback={imageId => this.setState({ importDialog: { ...importDialog, imageId } })} + nextUplaodCallback={imageId => this.handleImport({ imageId })} + /> + ); + } +} + +export default Index; diff --git a/pc4mobx/hrmSalary/pages/payrollFiles/components/salaryFileList/index.js b/pc4mobx/hrmSalary/pages/payrollFiles/components/salaryFileList/index.js new file mode 100644 index 00000000..1c3f7c89 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/payrollFiles/components/salaryFileList/index.js @@ -0,0 +1,203 @@ +/* + * Author: 黎永顺 + * name: 薪资档案页面重构-列表 + * Description: + * Date: 2024/1/8 + */ +import React, { Component } from "react"; +import { inject, observer } from "mobx-react"; +import { WeaLoadingGlobal, WeaLocaleProvider } from "ecCom"; +import { WeaTableNew } from "comsMobx"; +import { toJS } from "mobx"; +import { message, Spin } from "antd"; +import * as API from "../../../../apis/payrollFiles"; + +const WeaTableComx = WeaTableNew.WeaTable; +const getLabel = WeaLocaleProvider.getLabel; +const URLLIST = { + pending: "/api/bs/hrmsalary/salaryArchive/pendingList", + fixed: "/api/bs/hrmsalary/salaryArchive/fixedList", + suspend: "/api/bs/hrmsalary/salaryArchive/suspendList", + stop: "/api/bs/hrmsalary/salaryArchive/stopList", + ext: "/api/bs/hrmsalary/salaryArchive/extList" +}; +const APILIST = { + addToSalarypayment: API.gotoFixed, //设为发薪员工 + delPenditngToDo: API.deletePendingTodo, //待定薪删除待办 + delSalaryFiles: API.deleteSalaryArchive, //删除薪资档案 + salarySuspension: API.gotoStop, //停薪 + delSuspendToDo: API.deleteSuspendTodo, //待停薪删除待办 + cancelSalarySuspension: API.cancelStop //取消停薪 +}; + +@inject("payrollFilesStore", "taxAgentStore") +@observer +class Index extends Component { + constructor(props) { + super(props); + this.state = { + dataSource: [], columns: [], loading: false, selectedRowKeys: [], + pageInfo: { current: 1, pageSize: 10, total: 0 } + }; + } + + componentDidMount() { + this.getSalaryFileList(this.props); + window.addEventListener("message", this.handleReceive, false); + window.addEventListener("resize", this.handleResize, false); + } + + handleResize = () => { + this.forceUpdate(); + }; + + componentWillReceiveProps(nextProps, nextContext) { + if ((nextProps.selectedKey !== this.props.selectedKey) || (nextProps.isQuery !== this.props.isQuery)) { + this.setState({ + pageInfo: { ...this.state.pageInfo, current: 1, pageSize: 10, total: 0 } + }, () => this.getSalaryFileList(nextProps)); + } + if ((nextProps.selectedKey !== this.props.selectedKey)) { + this.setState({ + dataSource: [], columns: [], loading: false, selectedRowKeys: [], + welfareEditSlide: { ...this.state.welfareEditSlide, visible: false } + }); + } + } + + componentWillUnmount() { + window.removeEventListener("message", this.handleReceive, false); + window.removeEventListener("resize", this.handleResize, false); + } + + handleReceive = async ({ data }) => { + const { type, payload: { id, params } = {} } = data; + if (type === "init") { + this.getColumns(); + } else if (type === "turn") { + console.log(data); + switch (id) { + case "PAGEINFO": + this.setState({ + pageInfo: { ...this.state.pageInfo, ...params } + }, () => this.getSalaryFileList(this.props)); + break; + case "ROWSELECTION": + const { selectedRowKeys } = params; + this.setState({ selectedRowKeys }); + break; + case "ADD-TO-SALARYPAYMENT": + case "DEL-PENDITNG-TO-DO": + case "DEL-SALARY-FILES": + case "SALARY-SUSPENSION": + case "DEL-SUSPEND-TO-DO": + case "CANCEL-SALARY-SUSPENSION": + const { interfaceParams } = params; + this.handleSalaryOpts(_.camelCase(id), interfaceParams); + break; + default: + break; + } + } + }; + handleSalaryOpts = (type, payload) => { + WeaLoadingGlobal.start(); + APILIST[type](payload).then(({ status, data = {}, errormsg }) => { + WeaLoadingGlobal.destroy(); + if (status) { + const { msg, type } = data; + if (type === "fail" || type === "info") { + message.error(msg); + } else if (type === "success") { + message.success(msg); + this.getSalaryFileList(this.props); + this.setState({ selectedRowKeys: [] }); + } else { + message.success(getLabel(30700, "操作成功!")); + this.getSalaryFileList(this.props); + this.setState({ selectedRowKeys: [] }); + } + } else { + message.error(errormsg); + } + }); + }; + postMessageToChild = (payload = {}) => { + const i18n = { + "操作": getLabel(30585, "操作"), "调薪": getLabel(542686, "调薪"), + "增员": getLabel(543180, "增员"), "删除档案": getLabel(23238, "删除档案"), + "删除待办": getLabel(543181, "删除待办"), "查看": getLabel(33564, "查看"), + "取消停薪": getLabel(543309, "取消停薪"), "共": getLabel(18609, "共"), + "条": getLabel(18256, "条"), "设为发薪人员": getLabel(543308, "设为发薪人员"), + "停薪": getLabel(542692, "停薪"), "编辑": getLabel(501169, "编辑") + }; + const childFrameObj = document.getElementById("atdTable"); + childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*"); + }; + getSalaryFileList = (props) => { + const { pageInfo } = this.state; + const { + payrollFilesStore: { salaryFileQueryForm, queryList }, selectedKey, onChangeTopTabCount + } = props; + this.setState({ loading: true }); + queryList(pageInfo, salaryFileQueryForm.getFormParams(), URLLIST[selectedKey]).then(({ status, data }) => { + this.setState({ loading: false }); + if (status) { + const { pageInfo: result } = data; + const { list: dataSource, total, pageNum: current, pageSize } = result; + this.setState({ + pageInfo: { ...pageInfo, current, pageSize, total }, dataSource + }, () => { + onChangeTopTabCount(selectedKey, total); + }); + } + }).catch(() => this.setState({ loading: false })); + }; + getColumns = () => { + const { payrollFilesStore: { tableStore }, taxAgentStore: { showOperateBtn } } = this.props; + const columns = _.map(_.filter(toJS(tableStore.columns), (item) => item.display === "true"), (it, idx) => ({ + dataIndex: it.dataIndex, title: it.title, align: "left", + width: (it.dataIndex === "taxAgentName" || it.dataIndex === "operate") ? 185 : 150, + fixed: it.dataIndex === "username" ? "left" : it.dataIndex === "operate" ? "right" : "", + ellipsis: true + })); + if (!_.isEmpty(columns)) { + this.postMessageToChild({ + columns, showOperateBtn, selectedKey: this.props.selectedKey, + showDelSalaryFileBtn: this.props.showDelSalaryFileBtn, + dataSource: this.state.dataSource, selectedRowKeys: this.state.selectedRowKeys, + showSum: false, pageInfo: this.state.pageInfo + }); + } + }; + + render() { + const { loading, dataSource } = this.state; + const { payrollFilesStore: { tableStore } } = this.props; + const dom = document.querySelector(".wea-new-top-req-content"); + let height = 280; + if (dom && dataSource.length > 0) { + height = (parseFloat(dom.style.height) > 620 && dataSource.length === 10) ? dataSource.length * 39 + 113 : dataSource.length < 10 ? dataSource.length * 39 + 113 : parseFloat(dom.style.height) - 16; + } + return ( +
+ +