Compare commits

..

2 Commits

Author SHA1 Message Date
何美荣
aa6e19172b 还原 2025-09-29 10:14:46 +08:00
何美荣
5991d81cef 不知道哪来的 2025-09-29 10:14:12 +08:00

View File

@ -88,16 +88,9 @@ const contentStyle = {
}; };
class GroupHome extends React.Component { class GroupHome extends React.Component {
_isMounted = false; // 标记组件是否已挂载
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
noticeData: [], // 公告列表数据
currentNoticePage: 1, // 当前公告页码
noticePageSize: 4, // 每页公告数量与图片一致默认显示4条
totalNoticeCount: 0, // 公告总数量
activeNoticeTab: "all", // 活跃公告标签(全部/集团发布/公司发布,参考图片)
isNaN: false, isNaN: false,
scoreVisible: false, scoreVisible: false,
scoreTotalVisible: false, scoreTotalVisible: false,
@ -107,9 +100,6 @@ class GroupHome extends React.Component {
standardScoreNaN: [], standardScoreNaN: [],
visible: false, visible: false,
safetySloganOne: "", safetySloganOne: "",
animationDuration: 20,
sliderColor: '#de4e58',
sliderSize: '24px',
safetySloganTwo: "", safetySloganTwo: "",
noticeTitle: "", noticeTitle: "",
tmpData: {}, tmpData: {},
@ -117,8 +107,8 @@ class GroupHome extends React.Component {
pagination: {}, pagination: {},
retData: [], retData: [],
chartData: [], chartData: [],
displayStr: '', displayStr: null,
displayNum: 16, displayNum: 24,
columnData: [], columnData: [],
columnFields: [], columnFields: [],
delayData: [], delayData: [],
@ -217,22 +207,22 @@ class GroupHome extends React.Component {
} }
componentDidMount() { componentDidMount() {
this._isMounted = true; // 组件挂载时设为true if (localStorage.getItem("webOrgId") !== '00300000-0000-0000-0000-000000000000') {
const currentPath = this.props.location.pathname; history.replace('/home')
console.log(currentPath, '999')
if (localStorage.getItem("webOrgId") !== '00300000-0000-0000-0000-000000000000' && currentPath !== '/home') {
this.props.history.replace('/home')
return
// props.history.push({ pathname: "/grouphome" }); // props.history.push({ pathname: "/grouphome" });
} }
if (window.navigator.userAgent.indexOf("Windows") < 1) { if (window.navigator.userAgent.indexOf("Windows") < 1) {
window.location.replace(config.guideH5Host); window.location.replace(config.guideH5Host);
openNotificationMobile("bottomRight"); openNotificationMobile("bottomRight");
return; // 阻止后续代码执行 this.state.displayStr = "none";
this.state.displayNum = 24;
//alert('手机'); //alert('手机');
} else {
this.state.displayStr = "";
this.state.displayNum = 16;
//alert('PC');
} }
this.setState({ this.state.columns = [
columns: [
{ {
width: "450px", width: "450px",
title: "任务名称", title: "任务名称",
@ -271,8 +261,18 @@ class GroupHome extends React.Component {
key: "NOTICE_TYPE", key: "NOTICE_TYPE",
render: (text, record) => this.ShowState(record), render: (text, record) => this.ShowState(record),
}, },
], ];
scoreNoneColumns: [{ this.getTeam();
//定时器功能,暂时不开启
this.timerID = setInterval(
() => this.getBaseInfoData(1, this.state.tableKey, 5),
120000
);
this.showModalSign();
this.getBaseInfoData(1, 1, 5);
this.setMessageData();
this.state.scoreNoneColumns = [
{
width: "80px", width: "80px",
title: "生产单元", title: "生产单元",
dataIndex: "Nav_ProductionUnit.NAME", dataIndex: "Nav_ProductionUnit.NAME",
@ -340,8 +340,9 @@ class GroupHome extends React.Component {
})} })}
</span> </span>
), ),
}], },
scoreColumns: [ ];
this.state.scoreColumns = [
{ {
width: "80px", width: "80px",
title: "生产单元", title: "生产单元",
@ -445,8 +446,8 @@ class GroupHome extends React.Component {
</span> </span>
), ),
}, },
], ];
scoreTotalColumns: [ this.state.scoreTotalColumns = [
{ {
title: "生产单元", title: "生产单元",
dataIndex: "Nav_ProductionUnit.NAME", dataIndex: "Nav_ProductionUnit.NAME",
@ -477,142 +478,11 @@ class GroupHome extends React.Component {
</span> </span>
), ),
}, },
] ];
})
this.getTeam();
this.getHomeTitle()
//定时器功能,暂时不开启
this.timerID = setInterval(
() => {
if (this._isMounted) {
this.getBaseInfoData(1, this.state.tableKey, 5)
} }
},
120000
);
this.showModalSign();
this.getBaseInfoData(1, 1, 5);
this.setMessageData();
this.getNoticeData()
}
componentWillUnmount() { componentWillUnmount() {
this._isMounted = false; // 组件卸载时设为false this.timerID && clearTimeout(this.timerID);
if (this.timerID) {
clearInterval(this.timerID);
this.timerID = null;
} }
}
getNoticeData = () => {
const { currentNoticePage, noticePageSize, activeNoticeTab, mineType } = this.state;
const orgId = storage("lacal").getItem("webOrgId")?.val;
// 构建请求参数(按标签筛选:全部/集团/公司)
let json = initFilter(orgId, mineType);
extendRule(json, "pageNum", 1, currentNoticePage);
extendRule(json, "pageSize", 1, noticePageSize);
if (activeNoticeTab === "group") {
extendRule(json, "sourceType", 1, 1); // 1=集团发布
} else if (activeNoticeTab === "company") {
extendRule(json, "sourceType", 1, 2); // 2=公司发布
}
this.setState({
noticeData: [
{
id: "1",
title: "为表彰先进树立榜样激励广大员工积极进取集团决定开展2023年度优秀员工评选工作...",
source: "集团发布",
date: "08-30",
readStatus: "未读", // 可选:未读/已读
isImportant: true // 是否重要提醒
},
{
id: "2",
title: "根据国家法定节假日安排结合公司实际情况现将2023年国庆节放假安排通知如下...",
source: "公司发布",
date: "08-28",
readStatus: "已读",
isImportant: false
},
{
id: "3",
title: "根据国家法定节假日安排结合公司实际情况现将2023年国庆节放假安排通知如下...",
source: "公司发布",
date: "08-28",
readStatus: "已读",
isImportant: false
},
{
id: "4",
title: "根据国家法定节假日安排结合公司实际情况现将2023年国庆节放假安排通知如下...",
source: "公司发布",
date: "08-28",
readStatus: "已读",
isImportant: false
},
{
id: "5",
title: "根据国家法定节假日安排结合公司实际情况现将2023年国庆节放假安排通知如下...",
source: "公司发布",
date: "08-28",
readStatus: "已读",
isImportant: false
},
{
id: "6",
title: "根据国家法定节假日安排结合公司实际情况现将2023年国庆节放假安排通知如下...",
source: "公司发布",
date: "08-28",
readStatus: "已读",
isImportant: false
}
// 更多公告...
],
totalNoticeCount: 10 // 公告总数
})
// this.props.dispatch({
// type: "app/getDataByPost",
// url: "PF/Notice/GetNoticeList", // 假设的公告列表接口,需替换为实际接口
// payload: json,
// onlyData: false,
// onComplete: (data) => {
// if (data && data.IsSuccessful) {
// this.setState({
// noticeData: data.Data.list, // 公告列表
// totalNoticeCount: data.Data.total, // 公告总数
// });
// }
// },
// });
};
// 公告页码切换
changeNoticePage = (page) => {
const { totalNoticeCount, noticePageSize } = this.state;
// 边界判断页码不能小于1不能大于总页数
if (page < 1 || page > Math.ceil(totalNoticeCount / noticePageSize)) return;
this.setState({ currentNoticePage: page }, () => {
this.getNoticeData(); // 切换页码后重新请求数据
});
};
// 公告标签切换(全部/集团发布/公司发布)
switchNoticeTab = (tabType) => {
this.setState({
activeNoticeTab: tabType,
currentNoticePage: 1, // 切换标签时重置为第1页
}, () => {
this.getNoticeData(); // 切换标签后重新请求数据
});
};
// 查看更多公告(跳转至公告详情页或展开全部)
viewMoreNotice = () => {
// 逻辑1跳转至独立公告页面推荐
this.props.history.push({ pathname: "/noticeList", state: { tab: this.state.activeNoticeTab } });
// 逻辑2在当前页展开全部公告备选
// this.setState({ noticePageSize: this.state.totalNoticeCount });
};
showModalSign = () => { showModalSign = () => {
var userId = storage("lacal").getItem("userid")?.val; //登录后有存储登录信息 var userId = storage("lacal").getItem("userid")?.val; //登录后有存储登录信息
@ -625,38 +495,53 @@ class GroupHome extends React.Component {
url: "FM/User/UserSign", //验证是否有签名照 url: "FM/User/UserSign", //验证是否有签名照
onComplete: (ret) => { onComplete: (ret) => {
//返回查询结果ret //返回查询结果ret
if (this._isMounted && ret) { if (ret) {
//判断是否有记录 //判断是否有记录
openNotification("topRight"); openNotification("topRight");
} }
}, },
}); });
}; };
getHomeTitle = () => {
var orgId = storage("lacal").getItem("webOrgId")?.val; //登录后有存储登录信息
let json = initFilter(orgId);
this.props.dispatch({
type: "app/getDataByPost",
payload: json,
url: "PF/HomeTitle/OrderPaged",
onComplete: (ret) => {
if (this._isMounted && ret) {
this.setState({
safetySloganOne: ret[0].TITLE,
// safetySloganOne: "1.安全方针:以人为本、关注健康、依法治企、安全发展。 2.安全理念一切风险皆可控一切事故皆可防3.安全方针以人为本、关注健康、依法治企、安全发展。4.安全方针以人为本、关注健康、依法治企、安全发展。5.安全方针:以人为本、关注健康、依法治企、安全发展。 6.安全理念一切风险皆可控一切事故皆可防7.安全方针以人为本、关注健康、依法治企、安全发展。8.安全方针:以人为本、关注健康、依法治企、安全发展。",
animationDuration: ret[0].SECOND,
sliderColor: ret[0].COCOR,
sliderSize: ret[0].FONTSIZE
});
}
},
});
}
getTeam = () => { getTeam = () => {
var userId = storage("lacal").getItem("userid")?.val; //登录后有存储登录信息 var userId = storage("lacal").getItem("userid")?.val; //登录后有存储登录信息
var orgId = storage("lacal").getItem("webOrgId")?.val; //登录后有存储登录信息 var orgId = storage("lacal").getItem("webOrgId")?.val; //登录后有存储登录信息
// 龙岩稀土
if (orgId == "8f1cf418-8bf3-ea3f-7a6d-fc5d61247008") {
this.setState({
safetySloganOne: "安全方针:以人为本、关注健康、依法治企、安全发展。",
});
}
// 都昌金鼎
else if (orgId == "8b3c41aa-51b1-7ce9-1879-248a038c1b5c") {
this.setState({
safetySloganOne: "安全方针:安全第一,预防为主,科学管理,持续改进。",
mineType: localStorage.getItem("currentMineType")
});
}
//洛阳豫璐
else if (orgId == "d9871ba8-0eec-9e4a-bb87-7d5a540d8913") {
this.setState({
safetySloganOne: "安全方针:科技、安全、环保、效益。",
});
}
//博柏
else if (orgId == "3efd5276-632b-e379-9ff3-7a7546591fca") {
this.setState({
safetySloganOne: "安全方针:安全第一、综合治理、控制风险、科学发展",
mineType: localStorage.getItem("currentMineType")
});
}
//行洛坑
else {
this.setState({
safetySloganOne: "安全方针:安全第一、综合治理、控制风险、科学发展",
mineType: localStorage.getItem("currentMineType")
});
}
this.setState({
safetySloganTwo: "安全理念:一切风险皆可控,一切事故皆可防!",
});
let json = initFilter(orgId); let json = initFilter(orgId);
extendRule(json, "ID", 1, userId); extendRule(json, "ID", 1, userId);
extendInclude(json, "Nav_Department"); extendInclude(json, "Nav_Department");
@ -665,7 +550,7 @@ class GroupHome extends React.Component {
payload: json, payload: json,
url: "FM/User/Get", url: "FM/User/Get",
onComplete: (ret) => { onComplete: (ret) => {
if (this._isMounted && ret && ret.Nav_Department) { if (ret && ret.Nav_Department) {
this.setState({ this.setState({
departmentName: ret.Nav_Department.NAME, departmentName: ret.Nav_Department.NAME,
deparmentType: ret.Nav_Department.DEPARTMENT_TYPE, deparmentType: ret.Nav_Department.DEPARTMENT_TYPE,
@ -849,7 +734,7 @@ class GroupHome extends React.Component {
payload: json, payload: json,
onlyData: false, onlyData: false,
onComplete: (re) => { onComplete: (re) => {
if (this._isMounted && re && re.IsSuccessful && re.Data.newData) { if (re && re.IsSuccessful && re.Data.newData) {
this.state.tableData[0].total = re.Data.todoCount; this.state.tableData[0].total = re.Data.todoCount;
this.state.tableData[1].total = re.Data.timeOverCount; this.state.tableData[1].total = re.Data.timeOverCount;
this.state.tableData[2].total = re.Data.doneCount; this.state.tableData[2].total = re.Data.doneCount;
@ -1566,9 +1451,6 @@ class GroupHome extends React.Component {
className: styles.slideHeight, className: styles.slideHeight,
fade: true, fade: true,
}; };
// 在render方法中添加动态样式计算
const { safetySloganOne, animationDuration, sliderColor, sliderSize } = this.state;
const rowSelection = { const rowSelection = {
onChange: (selectedRowKeys, selectedRows) => { onChange: (selectedRowKeys, selectedRows) => {
this.state.taskSelects = selectedRows; this.state.taskSelects = selectedRows;
@ -1727,16 +1609,11 @@ class GroupHome extends React.Component {
<div className="slide-icon-style"> <div className="slide-icon-style">
<Icon type="sound" style={{ fontSize: "28px" }}></Icon> <Icon type="sound" style={{ fontSize: "28px" }}></Icon>
</div> </div>
<div <div className="slide-style">
className="slide-style"
style={{
'--animation-duration': `${animationDuration}s`, // 动态设置动画时长
'--slider-color': `${sliderColor}`, // 动态设置颜色
'--slider-size': `${sliderSize}px`, // 动态设置颜色
}}
>
<p className="slide-text-style"> <p className="slide-text-style">
{safetySloganOne || '暂无公告'} {this.state.safetySloganOne}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{this.state.safetySloganTwo}
</p> </p>
</div> </div>
</div> </div>
@ -2079,82 +1956,47 @@ class GroupHome extends React.Component {
backgroundColor: "white", backgroundColor: "white",
}} }}
> >
<div className="statistical-title-style">
<div className="badge-style">
<Icon
type="bar-chart"
style={{ color: "#5f6ac2", marginRight: "4px" }}
></Icon>
班组活动完成率
</div>
{this.state.departmentCompletionData.length > 0 ? (
<span
style={{
fontSize: "14px",
float: "right",
marginRight: "16px",
marginTop: "4px",
}}
>
<div
onClick={() => this.showDetailModal("BI001_HOMEDETAIL")}
>
<IconFont
type="icon-24gl-expand2"
style={{
fontSize: "18px",
color: "#333333",
cursor: "pointer",
}}
></IconFont>
</div>
</span>
) : null}
</div>
<br />
<div style={{ width: "100%", height: "100%" }}> <div style={{ width: "100%", height: "100%" }}>
{this.state.departmentCompletionData.length > 0 ? (
<div className="notice-board-container"> <ClassCompletion
{/* 公告栏标题栏:标题 + 标签 + 查看更多 */} departmentCompletionData={
<div className="notice-board-header"> this.state.departmentCompletionData
<div className="notice-board-title"> }
公告栏 />
{/* 重要提醒标签(参考图片,有重要提醒时显示) */} ) : null}
{this.state.noticeData.some(item => item.isImportant) && (
<span className="notice-important-tag">包含{this.state.noticeData.filter(item => item.isImportant).length}个重要提醒</span>
)}
</div>
<div style={{whiteSpace: "nowrap"}}>
<Button
type={this.state.activeNoticeTab === "all" ? "primary" : "default"}
size="small"
onClick={() => this.switchNoticeTab("all")}
style={{ marginRight: 8 }}
>
全部
</Button>
<Button
type={this.state.activeNoticeTab === "group" ? "primary" : "default"}
size="small"
onClick={() => this.switchNoticeTab("group")}
style={{ marginRight: 8 }}
>
集团
</Button>
<Button
type={this.state.activeNoticeTab === "company" ? "primary" : "default"}
size="small"
onClick={() => this.switchNoticeTab("company")}
>
公司
</Button>
</div>
</div>
{/* 公告标签切换(全部/集团发布/公司发布,参考图片) */}
{/* 公告列表 */}
<ul className="notice-list">
{this.state.noticeData.length > 0 ? (
this.state.noticeData.map(notice => (
<li
key={notice.id}
className={`notice-item ${notice.readStatus === "未读" ? "unread" : ""}`}
onClick={() => this.viewNoticeDetail(notice.id)} // 点击查看公告详情
>
<div className="notice-item-content">
<span className="notice-item-title">{notice.title}</span>
<span className="notice-item-date">{notice.date}</span>
</div>
<div className="notice-item-source">
{notice.source === 1 ? "集团发布" : "公司发布"}
</div>
</li>
))
) : (
<li style={{ textAlign: "center", padding: "20px 0", color: "#999" }}>
暂无公告数据
</li>
)}
</ul>
<div className="notice-pagination">
<Button onClick={this.viewMoreNotice} block>查看更多公告</Button>
{/* <a className="notice-view-more" onClick={this.viewMoreNotice}> */}
{/* 查看更多公告 */}
{/* </a> */}
</div>
</div>
</div> </div>
{/* <Toggle getNum={this.getChildCount}></Toggle> */} {/* <Toggle getNum={this.getChildCount}></Toggle> */}
</div> </div>