view.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. /*
  2. * @Author: dayan_hjm
  3. * @Date: 2023-10-25 10:32:44
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2024-10-14 17:16:34
  6. */
  7. /*
  8. * @Author: dayan_hjm
  9. * @Date: 2022-10-27 11:40:02
  10. * @Last Modified by: dayan_hjm
  11. * @Last Modified time: 2023-10-25 10:32:07
  12. */
  13. import React, { useState, useEffect, Component } from "react";
  14. import styles from "./style.less";
  15. import { useHistory, useLocation, withRouter } from "react-router-dom";
  16. import { observer, observable } from "mobx-react";
  17. import { message, Space, Form, Popconfirm, Modal, Tooltip, Icon, Button } from "antd";
  18. import mod from './mod';
  19. import { toJS } from "mobx";
  20. import BottomLineForSend from "./component/bottomLineForSend.jsx";
  21. import MoodSendView from "./component/moodSendView.jsx";
  22. import OneSendView from "./component/oneSendView.jsx";
  23. import LeftMenoyView from "./component/leftMenoyView.jsx";
  24. import RightBottomView from "./component/rightBottomView.jsx";
  25. import OneQualified from "./component/oneQualified.jsx";
  26. import MapView from "./component/mapView.jsx";
  27. import $store from "@store/";
  28. import {
  29. timeService,
  30. numberService,
  31. checkToken,
  32. updateTimeService
  33. } from "./api";
  34. import { getThousandNum, deleteCacheAndChangeUrl, timestampToTime, setWaterMark } from "@utils/util";
  35. import {
  36. fullscreen,
  37. } from "@ant-design/icons";
  38. import 'animate.css';
  39. @withRouter
  40. class Home extends Component {
  41. // 构造函数,组件的实例创建时,最先执行
  42. constructor(props, context) {
  43. super(props, context);
  44. this.store = mod;
  45. this.state = {
  46. updateTime: '',
  47. changGif: false,
  48. changNun: false,
  49. plannedCompletionData: [
  50. ],
  51. plannedCompletionNum: 1,
  52. manHourData: [
  53. ],
  54. manHourNum: 1,
  55. };
  56. this.timer = null //定时器,用于检测同步状态
  57. }
  58. componentWillMount() {
  59. if (window.location.host.indexOf("localhost") == -1) {
  60. this.getToken()
  61. }
  62. }
  63. async getToken() {
  64. if (!sessionStorage.getItem("tqcVToken")) {
  65. this.props.history.replace("/home/index");
  66. } else {
  67. await checkToken(sessionStorage.getItem("tqcVToken")).then(({ data, resultCode }) => {
  68. if (data?.userId) {
  69. sessionStorage.setItem("tqcUserName", data?.userId);
  70. $store.app.setMarkSrc(
  71. setWaterMark({
  72. toDataURL: true,
  73. waterMarkText: [data?.userId || sessionStorage.getItem("tqcUserName"), timestampToTime()],
  74. })
  75. );
  76. } else {
  77. window.location = window.location.origin + '/transfer.html#/login';
  78. // this.props.history.replace("/home/index");
  79. }
  80. });
  81. }
  82. }
  83. componentDidMount() {
  84. this.fontMsgChange();
  85. this.getUrl();
  86. this.getUrl2()
  87. this.getUrl3();
  88. setTimeout(() => {
  89. this.videoStart();
  90. }, 200)
  91. setTimeout(() => {
  92. //替换gif
  93. this.setState({ changGif: true });
  94. }, 2000);
  95. setTimeout(() => {
  96. this.setState({ changNun: true });
  97. }, 4500)
  98. }
  99. videoStart() {
  100. /* Chrome 浏览器的视频自动播放策略
  101. 1.始终允许静音模式下自动播放
  102. 2.在以下的情况中,带声音播放会被允许:
  103. ①用户已经与当前的域进行了交互(也就是click,tap事件)。
  104. ②在桌面设备上,用户的媒体参与度指数阈值已经超过,这意味着用户之前播放过有声视频。
  105. ③用户已经将网站添加到移动设备上的主屏幕或允在桌面上安装了PWA。
  106. 3.顶部帧可以将自动播放权限委派给其iframe,来允许自动播放声音
  107. 媒体参与度(Media Engagement)是指用户与媒体内容进行互动的程度,可以通过多个指标来衡量。这些指标主要包括观看时间、观看率、转化率、交互行为等。
  108. 可以通过:chrome://media-engagement/ 查看
  109. */
  110. const video = document.querySelector('.video2');
  111. console.log(video.play());
  112. const model = document.querySelector('.model')
  113. const btn = document.querySelector('button')
  114. // 第一种方法 引导用户去与页面交互实现播放
  115. async function play() {
  116. try {
  117. await video.play();
  118. //使用await的原因是因为video.play()方法返回的是一个Promise,所以在这里我们可以对他进行一些处理
  119. model.style.display = 'none';
  120. btn.removeEventListener('click', play);
  121. // 如果他自动播放了就隐藏按钮,消除点击事件
  122. } catch (err) {
  123. model.style.display = 'block';
  124. btn.addEventListener('click', play);
  125. // 如果Promise返回的是error就引导用户点击按钮,在调用play方法
  126. }
  127. }
  128. play();
  129. //第二种方法比较主流,类似的有网页版抖音以及B站
  130. function play() {
  131. video.muted = true;//设置视频为静音
  132. video.play();//调用播放方法
  133. const ctx = new AudioContext();
  134. const canAutoPlay = ctx.state === 'running'; //通过这个可以判断出视频能不能够自动播放 如何可以它的值就是“running” 否则为"suspended"
  135. // 如果是不能播放我们就执行下面的逻辑,其实就是类似于第一种方法,让用户与其交互
  136. ctx.close();
  137. if (canAutoPlay) {
  138. video.muted = false;
  139. model.style.display = 'none';
  140. btn.removeEventListener('click', play);
  141. }
  142. else {
  143. model.style.display = 'block';
  144. btn.addEventListener('click', play);
  145. }
  146. }
  147. play()
  148. }
  149. async getUrl() {
  150. await timeService().then(({ data = [], resultCode }) => {
  151. if (+resultCode === 0) {
  152. let plannedCompletionData = [], manHourData = [];
  153. data.map((x, i) => {
  154. if (x.indexValue || x.indexValue == 0) {
  155. if (x.indexName == '产量计划完成率') {
  156. plannedCompletionData.push({
  157. name: x.factoryName,
  158. value: Number((x.indexValue * 100).toFixed(2)),
  159. })
  160. } else {
  161. manHourData.push({
  162. name: x.factoryName,
  163. // value: Number((x.indexValue * 100).toFixed(2)),
  164. value: Number(x.indexValue),
  165. })
  166. }
  167. }
  168. });
  169. this.setState({ plannedCompletionData, manHourData, plannedCompletionNum: 1, manHourNum: 1 });
  170. }
  171. });
  172. }
  173. async getUrl2() {
  174. await numberService().then(({ data = [], resultCode }) => {
  175. if (+resultCode === 0) {
  176. let totalValue = 0, yearDecline = 0, yearSend = 0, productInventory = 0;
  177. data.map((x, i) => {
  178. if (x.indexName == '产值') {
  179. totalValue = x.indexValue
  180. } else if (x.indexName == '年度产量') {
  181. yearDecline = x.indexValue
  182. } else if (x.indexName == '产品库存') {
  183. yearSend = x.indexValue
  184. } else if (x.indexName == '年度发货量') {
  185. productInventory = x.indexValue
  186. }
  187. });
  188. this.store.saveState({ totalValue, yearDecline, yearSend, productInventory });
  189. setTimeout(() => {
  190. $(".shu1").numScroll();
  191. }, 2500)
  192. }
  193. });
  194. }
  195. async getUrl3() {
  196. await updateTimeService().then(({ data = [], resultCode }) => {
  197. if (+resultCode === 0) {
  198. this.setState({ updateTime: data?.[0]?.etlTime || '' })
  199. }
  200. });
  201. }
  202. componentWillUnmount() {
  203. clearInterval(this.timer);
  204. this.timer = null;
  205. }
  206. fontMsgChange(type) {
  207. this.timer = setInterval(() => {
  208. const { plannedCompletionData, plannedCompletionNum, manHourData, manHourNum } = this.state;
  209. //产量计划完成率
  210. var p1 = document.getElementById('plannedCompletionBox');
  211. const datas_ = plannedCompletionData[plannedCompletionNum - 1];
  212. var res = "";
  213. if (datas_) {
  214. if (type) {
  215. res = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number">' + getThousandNum(datas_?.value.toFixed(2)) + '</span><span class="topMsg_number_2" style={{fontSize: "0.75em",color: "#fff"}}>%</span><p class="topMsg_number_p">' + datas_?.name + '</p></div>';
  216. } else {
  217. res = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number shu1">' + datas_?.value.toFixed(2) + '</span><span class="topMsg_number_2" style={{fontSize: "0.75em",color: "#fff"}}>%</span><p class="topMsg_number_p">' + datas_?.name + '</p></div>';
  218. }
  219. }
  220. p1.innerHTML = res;
  221. //百万工时损工率
  222. var p2 = document.getElementById('manHourBox');
  223. const datas_2 = manHourData[manHourNum - 1];
  224. var res2 = "";
  225. if (datas_2) {
  226. if (type) {
  227. res2 = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number">' + getThousandNum(datas_2?.value.toFixed(2)) + '</span><p class="topMsg_number_p">' + datas_2?.name + '</p></div>';//<span class="topMsg_number_2">%</span>
  228. } else {
  229. res2 = '<div class="topMsg_box animate__animated animate__zoomIn"><span class="topMsg_number shu1">' + datas_2?.value.toFixed(2) + '</span><p class="topMsg_number_p">' + datas_2?.name + '</p></div>';
  230. }
  231. }
  232. p2.innerHTML = res2;
  233. const num_ = plannedCompletionNum + 1 > plannedCompletionData.length ? 1 : plannedCompletionNum + 1;
  234. const num_2 = manHourNum + 1 > manHourData.length ? 1 : manHourNum + 1;
  235. this.setState({ plannedCompletionNum: num_, manHourNum: num_2 })
  236. }, 4000)
  237. }
  238. render() {
  239. const stores = this.store.state;
  240. let { totalValue, yearDecline, yearSend, productInventory } = this.store.state;
  241. let { changGif, updateTime, changNun } = this.state;
  242. return (
  243. <div className={[styles.tlk_box + ' home_box ']}>
  244. {/* 水印 */}
  245. {
  246. window.urlConfig && window.urlConfig.SHOW_WATERMARK && <div className={"shuiYin"} style={{ backgroundImage: `url(${$store.app.markSrc})`, backgroundRepeat: 'repeat' }}></div>
  247. }
  248. {/* 右键切换大屏 */}
  249. <Tooltip placement="bottom" title={"产供销价值链"}>
  250. <img src={require("@assets/imgs/iconJpg/rightJ.png").default} alt="" className={"rightJ_png"} onClick={() => {
  251. deleteCacheAndChangeUrl("/home/gvc", (url) => {
  252. this.props.history.replace(url);
  253. })
  254. }} />
  255. </Tooltip>
  256. <Tooltip placement="bottom" title={"产供销价值链"}>
  257. <img src={require("@assets/imgs/iconJpg/rightJL.png").default} alt="" className={"rightJ_png rightJ_png_L"} onClick={() => {
  258. deleteCacheAndChangeUrl("/home/gvc", (url) => {
  259. this.props.history.replace(url);
  260. })
  261. }} />
  262. </Tooltip>
  263. {/* 视频播放器 */}
  264. <MapView></MapView>
  265. <div className={"video_box"}>
  266. <video src={require("@assets/imgs/dataVImg/homeVideo2.mp4").default} autoplay="autoplay" loop="loop" class="video2 center_box2 animate__animated animate__fadeIn animate__delay-1s"></video>
  267. </div>
  268. <div className={[styles.home + " home cbHome"]}>
  269. <div className="leftContent">
  270. <div class="bottomContent2 animate__animated animate__fadeInDown animate__slower animate__delay-2s">
  271. <div className="bottomContent bigDivPd">
  272. <Tooltip placement="bottom" title={' ● 近六个月的产量和发货量的对比数据(含外加工),当月的数据计算至更新日期。'}>
  273. <p className="topMsg_title">产品月度产量 / Monthly Net Production</p>
  274. </Tooltip>
  275. <div className="topMsg_content">
  276. <OneSendView></OneSendView>
  277. </div>
  278. </div>
  279. </div>
  280. <div class="bottomContent2 animate__animated animate__fadeInDown animate__slower animate__delay-2s">
  281. <div className="bottomContent bigDivPd">
  282. <Tooltip placement="bottom" title={' ● 近六个月的产量和发货量的对比数据(含外加工),当月的数据计算至更新日期。'}>
  283. <p className="topMsg_title">产品发货量 / Lithium Shipment</p>
  284. </Tooltip>
  285. <div className="topMsg_content">
  286. <MoodSendView></MoodSendView>
  287. </div>
  288. </div>
  289. </div>
  290. <div class="center_box2 animate__animated animate__fadeInDown animate__slower animate__delay-1s">
  291. <div className="center_box">
  292. <Tooltip placement="bottom" title={<p className="titpeP">
  293. <p>● 截止更新日期的主产品库存金额,计算:</p>
  294. <img src={require("@assets/imgs/dataVimg/gongshi2.png").default} alt="" style={{ width: "1.3em", margin: " -0.3em 0.5em 0 0em" }} />
  295. 物料1库存数*物料1移动平均价+物料2*物料2移动平均价+…
  296. </p>}>
  297. <p className="topMsg_title" style={{ position: "relative", zIndex: 999999 }}>产品库存 / Lithium Inventory</p>
  298. </Tooltip>
  299. <div className="topMsg_content">
  300. <LeftMenoyView></LeftMenoyView>
  301. </div>
  302. </div>
  303. </div>
  304. </div>
  305. <div className="centerCon">
  306. <div class="topMsg3 animate__animated animate__fadeInUp animate__slower">
  307. <div className="topMsg">
  308. <div className="topMsg2">
  309. <div className="topMsg_content">
  310. <div className="center_li">
  311. <div className="right_li">
  312. {
  313. !changNun && <span className="topMsg_number" class="shu1">{yearDecline}</span>
  314. }
  315. {
  316. changNun && <span className="topMsg_number">{getThousandNum(yearDecline)}</span>
  317. }
  318. <p className="topMsg_line"></p>
  319. <Tooltip placement="bottom" title={' ● 本年度截止更新日期的主产品(含外加工)的产量合计'}>
  320. <span className="topMsg_tip">年度发货量/吨</span>
  321. <span className="topMsg_tip topMsg_tip2">Annual Shipments / t</span>
  322. </Tooltip>
  323. </div>
  324. </div>
  325. <div className="center_li">
  326. <div className="right_li">
  327. {
  328. !changNun && <span className="topMsg_number" class="shu1">{productInventory}</span>
  329. }
  330. {
  331. changNun && <span className="topMsg_number">{getThousandNum(productInventory)}</span>
  332. }
  333. <p className="topMsg_line"></p>
  334. <Tooltip placement="bottom" title={' ● 本年度截止更新日期的主产品(含外加工)的发货量合计。'}>
  335. <span className="topMsg_tip">年度产量/吨</span>
  336. <span className="topMsg_tip topMsg_tip2">Annual Production / t</span>
  337. </Tooltip>
  338. </div>
  339. </div>
  340. <div className="center_li" style={{marginTop:'-24px',height:'78%'}}>
  341. {
  342. !changNun && <span className="topMsg_number" class="shu1">{yearSend}</span>
  343. }
  344. {
  345. changNun && <span className="topMsg_number">{getThousandNum(yearSend)}</span>
  346. }
  347. <p className="topMsg_line"></p>
  348. <Tooltip placement="bottom" title={' ● 截止更新日期的主产品库存数量。'}>
  349. <span className="topMsg_tip">年度产品一次合格率</span>
  350. <span className="topMsg_tip topMsg_tip2">Annual First Pass Yield</span>
  351. </Tooltip>
  352. </div>
  353. </div>
  354. </div>
  355. </div>
  356. </div>
  357. <div class="bottomContent3 animate__animated animate__fadeInUp animate__slower animate__delay-1s">
  358. <div className="bottomContent">
  359. <Tooltip placement="bottom" title={' ● 以更新日期为节点近30天的产量数据(含外加工)。'}>
  360. <p className="topMsg_title">近90天产量 / Net Production in the last 90 days</p>
  361. </Tooltip>
  362. <div className="topMsg_content">
  363. <BottomLineForSend></BottomLineForSend>
  364. </div>
  365. </div>
  366. </div>
  367. </div>
  368. {/* 右侧信息栏 */}
  369. <div className="rightContent">
  370. <div class="topMsg2 animate__animated animate__fadeInDown animate__slower">
  371. <div className="topMsg bigDivPd">
  372. <Tooltip placement="bottom" title={' ● 近一年的百万工时损工率。'}>
  373. <p className="topMsg_title">百万工时损工率</p>
  374. </Tooltip>
  375. <div className={changGif ? "topMsg_content changBg_topMsg_content" : "topMsg_content"} id="manHourBox">
  376. <div className="topMsg_box">
  377. <span className="topMsg_number" class="shu1"></span>
  378. <span className="topMsg_number_2"></span>
  379. <p className="topMsg_number_p"></p>
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. <div class="topMsg_22 animate__animated animate__fadeInDown animate__slower">
  385. <div className="topMsg_2">
  386. <Tooltip placement="bottom" title={' ● 近六个月的主产品一次合格率,当月的数据计算至更新日期。'}>
  387. <p className="topMsg_title">锂辉石消耗量 / Spodumene Consumption</p>
  388. </Tooltip>
  389. <div className="topMsg_content">
  390. <OneQualified></OneQualified>
  391. </div>
  392. </div>
  393. </div>
  394. <div class="bottomContent2 animate__animated animate__fadeInDown animate__slower animate__delay-1s">
  395. <div className="bottomContent bigDivPd">
  396. <Tooltip placement="bottom" title={' ● 近三年的碳排放总量、碳排放强度数据'}>
  397. <p className="topMsg_title">产品一次合格率 / First Pass Yield</p>
  398. </Tooltip>
  399. <div className="topMsg_content">
  400. <RightBottomView></RightBottomView>
  401. </div>
  402. </div>
  403. </div>
  404. </div>
  405. <div className="bottom_box">
  406. <p style={{ color: "#6a818d", lineHeight: '2px' }}>
  407. 更新日期 : {updateTime ? updateTime.split(" ")[0] : updateTime}
  408. </p>
  409. </div>
  410. </div>
  411. </div>
  412. )
  413. }
  414. }
  415. export default Home;