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
-
+ {
+ _.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 (
-
+
+
+
+
+
+
+
+
);
}
}
diff --git a/pc4mobx/hrmSalary/pages/variableSalary/index.js b/pc4mobx/hrmSalary/pages/variableSalary/index.js
index 5035381c..ff883269 100644
--- a/pc4mobx/hrmSalary/pages/variableSalary/index.js
+++ b/pc4mobx/hrmSalary/pages/variableSalary/index.js
@@ -16,6 +16,8 @@ import SalaryItemDialog from "./components/salaryItemDialog";
import SalaryFileDialog from "./components/salaryFileDialog";
import SalaryItemList from "./components/salaryItemList";
import SalaryFileList from "./components/salaryFileList";
+import SalaryFileImportDialog from "./components/salaryFileImportDialog";
+import { convertToUrlString } from "../../util/url";
import moment from "moment";
import { Button } from "antd";
import cs from "classnames";
@@ -32,35 +34,49 @@ class Index extends Component {
selectedKey: "salaryFile", isQuery: false, showSearchAd: false,
salaryMonth: moment(new Date()).format("YYYY-MM"),
SIDialog: { visible: false, title: "", id: "" }, //薪资项目薪资编辑弹框
- SFDialog: { visible: false, title: "", id: "" } //薪资档案编辑弹框
+ SFDialog: { visible: false, title: "", detail: {} }, //薪资档案编辑弹框
+ SFImpDialog: { visible: false, title: getLabel(24023, "数据导入") }//薪资档案导入
};
}
handleAdvanceSearch = () => this.setState({ isQuery: !this.state.isQuery });
openAdvanceSearch = () => this.setState({ showSearchAd: !this.state.showSearchAd });
- handleOperate = (type) => {
+ handleOperate = (type, detail = {}) => {
switch (type) {
case "create":
this.setState({
- SFDialog: { visible: true, id: "", title: getLabel(111, "新增薪资档案") }
+ SFDialog: {
+ visible: true, detail,
+ title: _.isEmpty(detail) ? getLabel(111, "新增薪资档案") : getLabel(111, "查看薪资档案")
+ }
});
break;
+ case "import":
+ this.setState({ SFImpDialog: { ...this.state.SFImpDialog, visible: true } });
+ break;
+ case "export":
+ const { baseTableStore: { VSalryForm } } = this.props;
+ const { salaryMonth } = this.state;
+ const payload = { salaryMonth, ...VSalryForm.getFormParams() };
+ window.open(`/api/bs/hrmsalary/variableSalary/export?${convertToUrlString(payload)}`, "_blank");
+ break;
default:
break;
}
};
render() {
- const { selectedKey, SIDialog, SFDialog, showSearchAd, isQuery, salaryMonth } = this.state;
+ const { selectedKey, SIDialog, SFDialog, SFImpDialog, showSearchAd, isQuery, salaryMonth } = this.state;
const { taxAgentStore: { showOperateBtn }, baseTableStore: { VSSalaryItemForm } } = this.props;
const tabs = [
{
title: getLabel(111, "薪资档案"), key: "salaryFile",
buttons: showOperateBtn ? [
- ,
+ // ,
,
,
- this.setState({ salaryMonth: val })}/>,
+ this.setState({ salaryMonth: val }, () => this.handleAdvanceSearch())}/>,
this.openAdvanceSearch()}
onAdvanceSearch={this.handleAdvanceSearch}/>
] : [
@@ -68,7 +84,8 @@ class Index extends Component {
this.openAdvanceSearch()}
onAdvanceSearch={this.handleAdvanceSearch}/>
],
- children:
+ children: this.handleOperate("create", data)}/>
},
{
title: getLabel(111, "薪资项目"), key: "salaryItem",
@@ -90,11 +107,11 @@ class Index extends Component {
title={getLabel(111, "浮动薪酬")} icon={} selectedKey={selectedKey}
iconBgcolor="#F14A2D" tabDatas={tabs} className="variable_salary_wrapper"
buttons={_.find(tabs, o => selectedKey === o.key).buttons} buttonSpace={10}
- onChange={selectedKey => this.setState({ selectedKey })}
+ onChange={selectedKey => this.setState({ selectedKey, SFDialog: { ...SFDialog, visible: false } })}
showDropIcon={false}
>
- this.setState({ showSearchAd: false })} onAdSearch={this.onAdSearch}/>
+ this.setState({ showSearchAd: false })} onAdSearch={this.handleAdvanceSearch}/>
{_.find(tabs, o => selectedKey === o.key).children}
{/*薪资项目*/}
@@ -105,6 +122,11 @@ class Index extends Component {
this.setState({
SFDialog: { ...SFDialog, visible: false }
}, () => callback && callback())}/>
+ {/* 薪资档案导入*/}
+ {
+ this.setState({ SFImpDialog: { ...SFImpDialog, visible: false } },
+ () => callback && this.handleAdvanceSearch());
+ }}/>
);
}
diff --git a/pc4mobx/hrmSalary/pages/variableSalary/index.less b/pc4mobx/hrmSalary/pages/variableSalary/index.less
index 26e8d09d..b76440d6 100644
--- a/pc4mobx/hrmSalary/pages/variableSalary/index.less
+++ b/pc4mobx/hrmSalary/pages/variableSalary/index.less
@@ -10,6 +10,10 @@
background: #FFF;
}
+ .ant-spin-nested-loading, .ant-spin-container {
+ height: 100% !important;
+ }
+
}
.searchAdvanced-condition-hide {
diff --git a/pc4mobx/hrmSalary/stores/baseTable.js b/pc4mobx/hrmSalary/stores/baseTable.js
index 8598d0cb..19333392 100644
--- a/pc4mobx/hrmSalary/stores/baseTable.js
+++ b/pc4mobx/hrmSalary/stores/baseTable.js
@@ -3,6 +3,7 @@ import { message } from "antd";
import { WeaForm, WeaTableNew } from "comsMobx";
import * as API from "../apis"; // 引入API接口文件
+import { getVariableSalaryList } from "../apis/variableSalary"; //浮动薪酬-薪资档案列表查询
const { TableStore } = WeaTableNew;
@@ -20,6 +21,25 @@ export class BaseTableStore {
@action initVSSalaryItemForm = () => this.VSSalaryItemForm = new WeaForm();
@observable VSSalaryFileForm = new WeaForm(); // 新增编辑薪资档案form
@action initVSSalaryFileForm = () => this.VSSalaryFileForm = new WeaForm();
+ @observable SFTableStore = new TableStore(); // 浮动薪酬-薪资档案table
+
+ @action("浮动薪酬-薪资档案列表查询")
+ getVariableSalaryList = (payload) => {
+ return new Promise((resolve, reject) => {
+ getVariableSalaryList(payload).then(res => {
+ const { data, status } = res;
+ if (status) {
+ const { dataKey } = data;
+ const { datas } = dataKey;
+ this.SFTableStore.getDatas(datas);
+ }
+ resolve(res);
+ }).catch(() => {
+ reject();
+ });
+ });
+ };
+
// 初始化操作
@action