From 9d99557f4b65f04a5e82ef01dfa414c00836e5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Mon, 12 Aug 2024 09:24:11 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.15.1.2407.01-=E6=B5=AE=E5=8A=A8?= =?UTF-8?q?=E8=96=AA=E9=85=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/variableSalary.js | 13 ++ .../components/salaryFileDialog/index.js | 31 +++- .../salaryFileImportDialog/index.js | 94 +++++++++++ .../components/salaryFileList/index.js | 159 +++++++++++------- .../hrmSalary/pages/variableSalary/index.js | 40 ++++- .../hrmSalary/pages/variableSalary/index.less | 4 + pc4mobx/hrmSalary/stores/baseTable.js | 20 +++ 7 files changed, 288 insertions(+), 73 deletions(-) create mode 100644 pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileImportDialog/index.js diff --git a/pc4mobx/hrmSalary/apis/variableSalary.js b/pc4mobx/hrmSalary/apis/variableSalary.js index 04bbeb02..c3e3f20a 100644 --- a/pc4mobx/hrmSalary/apis/variableSalary.js +++ b/pc4mobx/hrmSalary/apis/variableSalary.js @@ -29,3 +29,16 @@ export const createVariableSalary = params => { export const getVariableSalaryList = params => { return postFetch("/api/bs/hrmsalary/variableSalary/list", params); }; +//导入浮动薪酬档案 +export const importVariableSalary = params => { + return postFetch("/api/bs/hrmsalary/variableSalary/importData", params); +}; +//删除浮动薪酬档案 +export const deleteVariableSalary = params => { + return postFetch("/api/bs/hrmsalary/variableSalary/deleteSelectData", params); +}; +//获取浮动薪酬档案明细 +export const getVariableSalaryDetail = params => { + return postFetch("/api/bs/hrmsalary/variableSalary/getDetail", params); +}; + diff --git a/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileDialog/index.js b/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileDialog/index.js index 6297a558..f38f45a4 100644 --- a/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileDialog/index.js +++ b/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileDialog/index.js @@ -39,13 +39,16 @@ class Index extends Component { } initForm = (props) => { - const { baseTableStore: { VSSalaryFileForm } } = props; + const { baseTableStore: { VSSalaryFileForm }, detail } = props; API.getCreateForm().then(({ status, data }) => { this.setState({ conditions: [ ..._.map(salaryFileConditions, item => ({ ...item, - items: _.map(item.items, o => ({ ...o, label: getLabel(o.lanId, o.label) })) + items: _.map(item.items, o => ({ + ...o, viewAttr: !_.isEmpty(detail) ? 1 : 2, label: getLabel(o.lanId, o.label), + value: detail[getKey(o)] || "" + })) })), { items: _.map(data, o => ({ @@ -54,14 +57,25 @@ class Index extends Component { fieldcol: 14, label: o.name, labelcol: 6, - value: "", - viewAttr: 2 + value: detail[`${String(o.id)}_variableItem`] || "", + viewAttr: !_.isEmpty(detail) ? 1 : 2 })), title: "", col: 2, defaultshow: true } ] - }, () => VSSalaryFileForm.initFormFields(this.state.conditions)); + }, () => { + VSSalaryFileForm.initFormFields(this.state.conditions); + if (!_.isEmpty(detail)) { + VSSalaryFileForm.updateFields({ + employeeId: { + value: detail["employeeId"], + valueSpan: detail["username"], + valueObj: [{ id: detail["employeeId"], name: detail["username"] }] + } + }); + } + }); }); }; convertPayload = (payload) => { @@ -96,14 +110,17 @@ class Index extends Component { }); }; renderTitle = () => { - const { loading } = this.state, { title } = this.props; + const { loading } = this.state, { title, detail } = this.props; return
{title}
- + { + _.isEmpty(detail) && + + }
; }; diff --git a/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileImportDialog/index.js b/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileImportDialog/index.js new file mode 100644 index 00000000..5b8f023d --- /dev/null +++ b/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileImportDialog/index.js @@ -0,0 +1,94 @@ +/* + * 浮动薪酬 + * 薪资档案导入 + * @Author: 黎永顺 + * @Date: 2024/8/8 + * @Wechat: + * @Email: 971387674@qq.com + * @description: +*/ +import React, { Component } from "react"; +import { WeaCheckbox, WeaLocaleProvider } from "ecCom"; +import ImportDialog from "../../../../components/importDialog"; +import * as API from "../../../../apis/variableSalary"; +import { convertToUrlString } from "../../../../util/url"; + +const getLabel = WeaLocaleProvider.getLabel; + +class Index extends Component { + constructor(props) { + super(props); + this.state = { + importDialog: { + nextloading: false, link: "/api/bs/hrmsalary/variableSalary/downloadTemplate", + importResult: {}, imageId: "", hasData: false, + previewUrl: "/api/bs/hrmsalary/variableSalary/preview" + } + }; + } + + componentWillReceiveProps(nextProps, nextContext) { + const { importDialog } = this.state; + if (nextProps.visible !== this.props.visible && nextProps.visible) { + const { baseTableStore: { VSalryForm }, salaryMonth } = nextProps; + const payload = { + salaryMonth, ...VSalryForm.getFormParams(), hasData: importDialog.hasData + }; + this.setState({ importDialog: { ...importDialog, link: `${importDialog.link}?${convertToUrlString(payload)}` } }); + } else { + this.setState({ + importDialog: { + nextloading: false, link: "/api/bs/hrmsalary/variableSalary/downloadTemplate", hasData: false, + importResult: {}, imageId: "", previewUrl: "/api/bs/hrmsalary/variableSalary/preview" + } + }); + } + } + + handleImport = (payload) => { + const { salaryMonth } = this.props; + const { importDialog } = this.state; + this.setState({ importDialog: { ...importDialog, nextloading: true } }); + API.importVariableSalary({ ...payload, salaryMonth }).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; + return ( + this.setState({ + importDialog: { ...importDialog, importResult: {}, imageId: "", link: null } + })} + exportDataDom={ + { + const { baseTableStore: { VSalryForm }, salaryMonth } = this.props; + const payload = { salaryMonth, ...VSalryForm.getFormParams(), hasData: val === "1" }; + this.setState({ + importDialog: { + ...importDialog, hasData: val === "1", + link: `/api/bs/hrmsalary/variableSalary/downloadTemplate?${convertToUrlString(payload)}` + } + }); + }} + /> + } + nextCallback={imageId => this.setState({ importDialog: { ...importDialog, imageId } })} + nextUplaodCallback={imageId => this.handleImport({ imageId })} + /> + ); + } +} + +export default Index; diff --git a/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileList/index.js b/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileList/index.js index 6ec040bb..0756b644 100644 --- a/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileList/index.js +++ b/pc4mobx/hrmSalary/pages/variableSalary/components/salaryFileList/index.js @@ -8,10 +8,13 @@ * @description: */ import React, { Component } from "react"; -import { WeaLocaleProvider, WeaTable } from "ecCom"; -import { message, Modal } from "antd"; +import { WeaLocaleProvider } from "ecCom"; +import { WeaTableNew } from "comsMobx"; +import { message, Modal, Spin } from "antd"; import * as API from "../../../../apis/variableSalary"; +import { toJS } from "mobx"; +const WeaTableComx = WeaTableNew.WeaTable; const getLabel = WeaLocaleProvider.getLabel; class Index extends Component { @@ -23,64 +26,78 @@ class Index extends Component { } componentDidMount() { + window.addEventListener("message", this.handleReceive, false); + window.addEventListener("resize", this.handleResize, false); this.getVariableSalaryList(); } + componentWillUnmount() { + window.removeEventListener("message", this.handleReceive, false); + window.removeEventListener("resize", this.handleResize, false); + } + componentWillReceiveProps(nextProps, nextContext) { if (nextProps.isQuery !== this.props.isQuery) this.setState({ pageInfo: { ...this.state.pageInfo, current: 1 } }, () => this.getVariableSalaryList()); } + handleReceive = async ({ data }) => { + const { type, payload: { id, params } = {} } = data; + if (type === "init") { + this.getColumns(); + } else if (type === "turn") { + switch (id) { + case "PAGEINFO": + this.setState({ + pageInfo: { ...this.state.pageInfo, ...params } + }, () => this.getVariableSalaryList()); + break; + case "DEL": + this.handleDelete([params.id]); + break; + case "VIEW": + this.handleView(params.id); + break; + default: + break; + } + } + }; getVariableSalaryList = () => { - const { baseTableStore: { VSalryForm }, salaryMonth } = this.props; + const { baseTableStore: { VSalryForm, getVariableSalaryList }, salaryMonth } = this.props; const { pageInfo } = this.state; const { departmentIds } = VSalryForm.getFormParams(); - console.log(VSalryForm.getFormParams()); this.setState({ loading: true }); - API.getVariableSalaryList({ + getVariableSalaryList({ ...pageInfo, salaryMonth, ...VSalryForm.getFormParams(), departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [] - }) - .then(({ status, data }) => { - this.setState({ loading: false }); - if (status) { - const { list: dataSource, columns, pageNum: current, pageSize, total } = data; - this.setState({ - pageInfo: { ...pageInfo, current, pageSize, total }, dataSource, - columns: [ - ..._.filter(columns, o => o.dataIndex !== "id"), - { - title: getLabel(111, "操作"), dataIndex: "oprate", - render: (__, record) => ( - this.handleEdit(record.id)}>{getLabel(111, "编辑")} - { - record.canDelete && this.handleDelete([record.id])}>{getLabel(111, "删除")} - } - ) - } - ] - } - ); - } - }); - }; - handleEdit = (id) => { - API.getVariableSalaryItemDetail({ id }).then(({ status, data }) => { - if (status) this.props.onEditSalaryItem(data); + }).then(({ status, data }) => { + this.setState({ loading: false }); + if (status) { + const { pageInfo: result } = data; + const { list: dataSource, pageNum: current, pageSize, total } = result; + this.setState({ + pageInfo: { ...pageInfo, current, pageSize, total }, dataSource + } + ); + } }); }; - handleDelete = (itemIds) => { + handleView = (id) => { + API.getVariableSalaryDetail({ id }).then(({ status, data }) => { + if (status) this.props.onViewSalaryFile(data.data); + }); + }; + handleDelete = (ids) => { Modal.confirm({ title: getLabel(111, "信息确认"), content: getLabel(111, "确认删除吗?"), onOk: () => { - API.deleteVariableSalaryItem({ itemIds }).then(({ status, errormsg }) => { + API.deleteVariableSalary({ ids }).then(({ status, errormsg }) => { if (status) { message.success(getLabel(111, "删除成功")); - this.getVariableSalaryItemList(); + this.getVariableSalaryList(); } else { message.error(errormsg); } @@ -88,29 +105,57 @@ class Index extends Component { } }); }; + getColumns = () => { + const { baseTableStore: { SFTableStore }, showOperateBtn } = this.props; + const columns = _.map(_.filter(toJS(SFTableStore.columns), (item) => item.display === "true"), (it, idx) => ({ + dataIndex: it.dataIndex, title: it.title, align: "left", + width: 150, ellipsis: true + })); + if (!_.isEmpty(columns)) { + this.postMessageToChild({ + columns, showOperateBtn, dataSource: this.state.dataSource, scrollHeight: 100, + pageInfo: this.state.pageInfo, unitTableType: "variableSalary" + }); + } + return columns; + }; + postMessageToChild = (payload = {}) => { + const i18n = { + "操作": getLabel(30585, "操作"), "查看详情": getLabel(111, "查看详情"), + "共": getLabel(18609, "共"), "条": getLabel(18256, "条"), + "删除": getLabel(111, "删除") + }; + const childFrameObj = document.getElementById("unitTable"); + childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*"); + }; render() { - const { columns, dataSource, loading, pageInfo } = this.state; - const pagination = { - ...pageInfo, - showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`, - showQuickJumper: true, - showSizeChanger: true, - pageSizeOptions: ["10", "20", "50", "100"], - onShowSizeChange: (current, pageSize) => { - this.setState({ - pageInfo: { ...pageInfo, current, pageSize } - }, () => this.getVariableSalaryList()); - }, - onChange: current => { - this.setState({ - pageInfo: { ...pageInfo, current } - }, () => this.getVariableSalaryList()); - } - }; + const { loading, dataSource } = this.state; + const { baseTableStore: { SFTableStore } } = 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 ( - + +
+ +