2023-10-18 17:12:44 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* name:工资单发放-重构页面-工资单模板预览
|
|
|
|
|
* Description:
|
|
|
|
|
* Date: 2023/10/18
|
|
|
|
|
*/
|
|
|
|
|
import React, { Component } from "react";
|
2023-10-19 09:42:46 +08:00
|
|
|
import { WeaLocaleProvider } from "ecCom";
|
|
|
|
|
import { message } from "antd";
|
|
|
|
|
import moment from "moment";
|
2023-10-18 17:12:44 +08:00
|
|
|
import computer from "./computer.png";
|
|
|
|
|
import phone from "./phone_new.png";
|
|
|
|
|
import PcTemplate from "../../../components/pcTemplate";
|
2023-10-19 11:51:41 +08:00
|
|
|
import MobileTemplate from "../../../components/mobileTemplate";
|
2023-10-18 17:12:44 +08:00
|
|
|
import cs from "classnames";
|
|
|
|
|
import "./index.less";
|
|
|
|
|
|
2023-10-19 09:42:46 +08:00
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
|
|
2023-10-18 17:12:44 +08:00
|
|
|
class TmpPreview extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
2023-10-19 11:51:41 +08:00
|
|
|
active: "0", theme: "", tip: "", background: "", tipPosi: "", itemTypeList: [],
|
2023-10-18 17:12:44 +08:00
|
|
|
phsImgList: [
|
|
|
|
|
{ key: "0", src: computer },
|
|
|
|
|
{ key: "1", src: phone }
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 09:42:46 +08:00
|
|
|
componentDidMount() {
|
|
|
|
|
const dataStr = window.localStorage.getItem("weapp-salary-payroll-preview-data");
|
|
|
|
|
if (!dataStr) {
|
|
|
|
|
message.warning(getLabel(111, "参数异常!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const data = JSON.parse(dataStr);
|
|
|
|
|
let theme = data.theme || "";
|
2024-10-25 17:04:45 +08:00
|
|
|
theme = theme.replaceAll("${salaryMonth}", moment().format("YYYY年MM月"));
|
|
|
|
|
theme = theme.replaceAll("${salaryYear}", moment().format("YYYY年"));
|
2023-10-19 09:42:46 +08:00
|
|
|
this.setState({
|
|
|
|
|
theme, tip: data.textContent || "",
|
|
|
|
|
background: data.background || "",
|
|
|
|
|
tipPosi: data.textContentPosition || "",
|
|
|
|
|
itemTypeList: data.salaryItemSetting || []
|
|
|
|
|
});
|
|
|
|
|
if (theme.indexOf("${companyName}") !== -1) {
|
|
|
|
|
const themeAccount = window.localStorage.getItem("theme-account") || {};
|
2023-10-19 11:51:41 +08:00
|
|
|
if (themeAccount)
|
|
|
|
|
this.setState({ theme: theme.replaceAll("${companyName}", JSON.parse(themeAccount).subcompanyname) });
|
2023-10-19 09:42:46 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-18 17:12:44 +08:00
|
|
|
render() {
|
|
|
|
|
const { phsImgList, active } = this.state;
|
|
|
|
|
return (
|
|
|
|
|
<div className="salary-payroll-preview">
|
|
|
|
|
<div className="p-header">
|
|
|
|
|
<div className="ph-switch">
|
|
|
|
|
{
|
|
|
|
|
_.map(phsImgList, o => (
|
|
|
|
|
<div className={cs("phs-btn", { "active": active === o.key })}
|
|
|
|
|
onClick={() => this.setState({ active: o.key })}><img src={o.src} alt=""/>
|
|
|
|
|
</div>))
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="p-body">
|
|
|
|
|
<div className="pb-pc-container" style={{ display: active === "0" ? "block" : "none" }}>
|
2023-10-19 09:42:46 +08:00
|
|
|
<PcTemplate {...this.state}/>
|
2023-10-18 17:12:44 +08:00
|
|
|
</div>
|
2023-10-19 11:51:41 +08:00
|
|
|
<div className="pb-mobile-container" style={{ display: active === "1" ? "block" : "none" }}>
|
|
|
|
|
<MobileTemplate {...this.state}/>
|
|
|
|
|
</div>
|
2023-10-18 17:12:44 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default TmpPreview;
|