index.js
27.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
/*
* @Author: Sakura
* @LastEditors: Sakura
* @FilePath: \ebc-mes\src\mes\common\siderInfoComponent\index.js
* @Description: 生产执行内容块 --- 左侧收缩组件
*/
import React, { useEffect, useRef, useState, useContext } from "react";
import { Carousel, Row, Col, Spin, Button, Tooltip } from "antd";
import { LeftOutlined, RightOutlined } from "@ant-design/icons";
import classNames from "classnames/bind";
import moment from "moment";
import * as commonBusiness from "@/components/Common/commonBusiness";
import * as commonFunc from "@/components/Common/commonFunc";
import StaticEditTable from "@/components/Common/CommonTable";
import ShowType from "@/components/Common/CommonComponent";
import ClockComponent from "./clockComponent";
import * as commonUtils from "@/utils/utils";
import * as commonConfig from "@/utils/config";
import styles from "./index.less";
import { Space } from "antd";
const iocnObj = {
taskIcon: require("./assets/facilityIcon.png"),
facilityIcon: require("./assets/facilityIcon.png"),
groupIcon: require("./assets/groupIcon.png"),
userImg: require("./assets/user.jpg")
};
const { myContext } = commonUtils;
const cx = classNames.bind(styles);
const useSiderInfoComponentEvent = props => {
const { formData = [], app, refreshMachineDataFlag } = props;
const { userinfo = {} } = app;
const { iInterface } = userinfo;
const [pageloading1, setPagesLoading1] = useState(true);
// 初始化事件
useEffect(
async () => {
if (commonUtils.isEmptyArr(formData)) return;
let addState = {};
const list = [
{
sName: "workOrderInfo",
sGrd: iInterface === 0 ? "qz_machinedata" : "machinedata"
}, // 工单信息
{
sName: "deviceTargetInfo",
sGrd:
iInterface === 2
? "elemachine1"
: iInterface === 9
? "elemachine2"
: "elemachine"
}, // 设备及目标信息
{ sName: "employee", sGrd: "teamInfo" }, // 班组信息
{ sName: "teamShiftInfo", sGrd: "teamShiftInfo" } // 机长班次信息
];
for (let i = 0; i < list.length; i++) {
const item = list[i];
const { sName, sGrd } = item;
const config = formData.find(item => item.sGrd === sGrd);
if (config) {
addState = {
execListExtra: list,
...addState,
...handleGetColumnData(config, sName),
...(await handleGetData(config, sName))
};
}
}
addState.bFinish1 = true;
props.onSaveState(addState, () => {
setPagesLoading1(false);
});
},
[formData.length]
);
// 扫码后刷新工单信息
const { productionTableList = [] } = props;
useEffect(
async () => {
if (!refreshMachineDataFlag) return;
const tempList = {
sName: "workOrderInfo",
sGrd: iInterface === 0 ? "qz_machinedata" : "machinedata"
};
const { sName, sGrd } = tempList;
const config = formData.find(item => item.sGrd === sGrd);
const addState = {
...(await handleGetData(config, sName)),
refreshTableList: productionTableList
};
props.onSaveState(addState);
},
[refreshMachineDataFlag]
);
// 获取表头数据
const handleGetColumnData = (config, name) => {
const column = commonFunc.getHeaderConfig(config);
return {
[`${name}Column`]: column,
[`${name}Config`]: config
};
};
// 获取数据集
const handleGetData = async (config, name) => {
const conditonValues = props.onGetSqlConditionValues(config);
// 如果是设备及目标信息,则异步加载
if (name === "deviceTargetInfo") {
props.onGetDataSet({
name: name,
configData: config,
condition: { sSqlCondition: { ...conditonValues } },
isWait: false
});
return {};
}
try {
const addState =
(await props.onGetDataSet({
name: name,
configData: config,
condition: { sSqlCondition: { ...conditonValues } },
isWait: true
})) || {};
return addState;
} catch (error) {
console.log("=====error", error);
return {};
}
};
useEffect(() => {
window.bChangeMachineData = true;
return () => {
window.bChangeMachineData = false;
};
}, []);
const [changeExecInfo, setChangeExecInfo] = useState({});
const changeExecInfoRef = useRef({});
useEffect(() => {
const getValue = () => {
const changeExecInfoNew = commonUtils.getAppData("changeExecInfo");
const { sTime } = changeExecInfoNew;
delete changeExecInfoNew.sTime;
if (
JSON.stringify(changeExecInfoNew) !==
JSON.stringify(changeExecInfoRef.current)
) {
changeExecInfoRef.current = changeExecInfoNew;
setChangeExecInfo({ ...changeExecInfoNew, sTime });
}
};
getValue();
const timer = setInterval(() => {
getValue();
}, 1000);
return () => {
clearInterval(timer);
};
}, []);
// 将工单信息存到全局
const { workOrderInfoData = [] } = props;
const [workOrderInfoDataOne = {}] = workOrderInfoData;
const currentWorkOrderInfo = commonUtils.getAppData(
"globalData",
"currentWorkOrderInfo"
);
useEffect(
() => {
const globalData = commonUtils.getAppData(globalData);
globalData.currentWorkOrderInfo = {
...currentWorkOrderInfo,
...workOrderInfoDataOne,
...changeExecInfo
};
commonUtils.setAppData("globalData", globalData);
},
[JSON.stringify(workOrderInfoDataOne), changeExecInfo]
);
// 刷新设备及目标信息
const { refreshDeviceTargetInfo } = props;
useEffect(
() => {
if (refreshDeviceTargetInfo) {
handleRefreshDeviceTargetInfo();
}
},
[refreshDeviceTargetInfo]
);
const handleRefreshDeviceTargetInfo = async () => {
const { deviceTargetInfoConfig, deviceTargetInfoData = [{}] } = props;
const conditonValues = props.onGetSqlConditionValues(
deviceTargetInfoConfig
);
const addState = await props.onGetDataSet({
name: "deviceTargetInfo",
configData: deviceTargetInfoConfig,
condition: { sSqlCondition: { ...conditonValues } },
isWait: true
});
addState.deviceTargetInfoData = [
{ ...deviceTargetInfoData[0], ...addState.deviceTargetInfoData[0] }
];
addState.refreshDeviceTargetInfo = false;
props.onSaveState(addState);
};
return {
...props,
pageloading1,
changeExecInfo
};
};
const SiderInfoComponent = baseProps => {
const props = useSiderInfoComponentEvent(baseProps);
const workLoading = commonFunc.showLocalMessage(props, 'workLoading', '工单数据加载中...');
const waitWorkLoading = commonFunc.showLocalMessage(props, 'waitWorkLoading', '工单数据加载中...');
const leftClass = cx({
siderInfoComponent: true
});
return (
<myContext.Provider
value={{
props
}}
>
<div className={leftClass}>
{props.pageloading1 ? (
<div className="mesPageloadingDiv">
<Spin
spinning={props.pageloading1}
size="large"
tip={workLoading}
/>
</div>
) : (
<CommonInfoComponent {...baseProps} />
)}
</div>
</myContext.Provider>
);
};
const CommonInfoComponent = props => {
return (
<div className="commonInfo">
<WorkOrderTypeComponent />
<DeviceTargetInfoComponent />
{/* <TeamInfoComponent /> */}
</div>
);
};
// 工单类型
const WorkOrderTypeComponent = () => {
const { props } = useContext(myContext);
const {
workOrderInfoConfig = {},
workOrderInfoData = [],
changeExecInfo = {}
} = props;
const ref = useRef(null);
const carouselRef = useRef(null);
const [contentHeight, setContentHeight] = useState(0);
useEffect(() => {
const handleSetHeight = () => {
if (ref.current) {
const oCarousel = ref.current.querySelector(".ant-carousel");
const { height } = oCarousel.getBoundingClientRect();
setContentHeight(height - 8);
}
};
handleSetHeight();
window.addEventListener("resize", handleSetHeight);
return () => {
window.removeEventListener("resize", handleSetHeight);
};
}, []);
const timer = useRef(null);
const [pageSize, setPageSize] = useState(1);
useEffect(
() => {
clearTimeout(timer.current);
timer.current = null;
timer.current = setTimeout(() => {
let pageSize = Math.floor(contentHeight / 36);
pageSize = Math.max(pageSize, 1);
setPageSize(pageSize);
}, 200);
},
[contentHeight]
);
const [showConfig, setShowConfig] = useState([]);
useEffect(
() => {
const { gdsconfigformslave = [] } = workOrderInfoConfig;
const showConfig = gdsconfigformslave.filter(
item =>
item.sName && item.bControl && item.sControlName.indexOf("Btn") === -1
);
setShowConfig(showConfig);
},
[props.bFinish1]
);
const viewRowOld = workOrderInfoData[0] || {};
const viewRow = { ...viewRowOld, ...changeExecInfo };
const handleGetShowTypeProps = config => {
// const viewRow = workOrderInfoData[dataIndex] || {};
return {
...commonBusiness.getShowTypes("workOrderInfo", props),
showConfig: config,
dataValue: viewRow[config.sName],
enabled: false,
bSideInfo: true
};
};
const productionRef = useRef(null);
const [productionDivId] = useState(
`productionDivId_${commonUtils.createSid()}`
);
const task = commonFunc.showLocalMessage(props, 'task', '任务:工单信息');
const specialFocus = commonFunc.showLocalMessage(props, 'specialFocus', '任务:工单信息');
return (
<div className={styles.workOrdertype} ref={ref}>
<div className="mesTitle">
<img src={iocnObj.taskIcon} />
{task}
</div>
<Carousel ref={carouselRef}>
{/* {
workOrderInfoData.map((item,index)=>{
return(
<div>
{ showConfig.map((e,i)=>{
const className = cx({ mesShowType: true,odd: i % 2 === 0 });
return (
<div className={className}>
<ShowType {...handleGetShowTypeProps( e, item[e.sName] )} />
</div>
)
})}
</div>
)
})
} */}
{new Array(Math.ceil(showConfig.length / pageSize))
.fill("")
.map((_, page) => {
return (
<div>
{new Array(pageSize).fill("").map((_, index) => {
const config = showConfig[page * pageSize + index];
if (commonUtils.isEmptyObject(config)) {
return "";
}
const className = cx({
mesShowType: true,
odd: index % 2 === 0
});
// 生产进度
if (config.sName === "sProduction") {
const productionArr = commonUtils.convertStrToObj(
viewRow[config.sName],
[]
);
const showValue = productionArr.map((item, i) => {
const { sProcessName, sState } = item;
let colorValue;
switch (
Number(sState) // 根据状态显示颜色
) {
case 2:
colorValue = "#FF7E37"; /* 2:等待:黄色 */
break;
case 4:
colorValue = "#52C41A"; /* 4:已完成:绿色 */
break;
case 1:
case 3:
colorValue = "#106abe"; /* 1、3:进行中:蓝色 */
break;
default:
colorValue = "#000000";
}
return (
<>
<span style={{ color: colorValue }}>
{sProcessName}
</span>
{i < productionArr.length - 1 ? (
<RightOutlined
style={{
color: [1, 3].includes(sState)
? "#000"
: colorValue
}}
/>
) : (
""
)}
</>
);
});
return (
<div className={className} ref={productionRef}>
<Row style={{ flexWrap: "nowrap" }}>
<Col
flex={"160px"}
className={styles.productionTitle}
>
生产进度:
{/* <Button
type="link"
icon={<LeftOutlined />}
className={styles.productionBtnLeft}
onClick={() => {
document.querySelector(
`#${productionDivId}`
).scrollLeft -= 100;
}}
/>
<Button
type="link"
icon={<RightOutlined />}
className={styles.productionBtnRight}
onClick={() => {
document.querySelector(
`#${productionDivId}`
).scrollLeft += 100;
}}
/> */}
</Col>
<Col
flex={1}
className={styles.productionContent1}
id={productionDivId}
>
<Tooltip
title={showValue}
color="#fff"
overlayInnerStyle={{ fontSize: 18 }}
>
{showValue}
</Tooltip>
</Col>
</Row>
</div>
);
} else if (config.sName === "specialMemo") {
return (
<div className={className}>
<Row style={{ flexWrap: "nowrap" }}>
<Col
flex={"160px"}
className={styles.productionTitle}
>
{specialFocus}
</Col>
<Col
flex={1}
className={styles.productionContent}
style={{ cursor: "not-allowed", gap: 5 }}
>
{viewRow.specialMemo
? viewRow.specialMemo
.split(",")
.map(item => (
<div className={styles.mesSpecial}>
{item}
</div>
))
: ""}
</Col>
</Row>
</div>
);
} else if (config.sName === "sLabelColor") {
const colorList = "白粉青蓝橙绿黄红".split("");
let colorIndex = colorList.findIndex(
item => item === viewRow.sLabelColor
);
colorIndex = colorIndex === -1 ? 0 : colorIndex;
return (
<div className={className}>
<Row style={{ flexWrap: "nowrap" }}>
<Col
flex={"160px"}
className={styles.productionTitle}
>
{config.showName}:
</Col>
<Col
flex={1}
className={styles.productionContent}
style={{ cursor: "not-allowed", gap: 5 }}
>
<span
className={`noInput ${viewRow.sLabelColor
? styles[`mesColor${colorIndex}`]
: ""
}`}
>
<span>{viewRow.sLabelColor}</span>
</span>
</Col>
</Row>
</div>
);
} else {
const showTypeProps = handleGetShowTypeProps(config);
return (
<div className={className}>
<ShowType {...showTypeProps} />
</div>
);
}
})}
</div>
);
})}
</Carousel>
<div className="rightBottomBtns">
<Space>
<LeftOutlined
onClick={() => {
carouselRef.current && carouselRef.current.prev();
}}
/>
<RightOutlined
onClick={() => {
carouselRef.current && carouselRef.current.next();
}}
/>
</Space>
</div>
</div>
);
};
// 设备及目标信息
const DeviceTargetInfoComponent = () => {
const { props } = useContext(myContext);
const {
deviceTargetInfoConfig = {},
deviceTargetInfoData = [],
changeExecInfo = {}
} = props;
const { gdsconfigformslave = [] } = deviceTargetInfoConfig;
const showConfig = gdsconfigformslave.filter(
item =>
item.sName && item.bControl && item.sControlName.indexOf("Btn") === -1
);
const viewRowOld = deviceTargetInfoData[0] || {};
const viewRow = { ...viewRowOld, ...changeExecInfo };
const {
sStatusName,
dProduceHour = 0,
bPopup = false,
iPopDuration = 0
} = viewRow;
const settingId = useRef(`settingId_${commonUtils.createSid()}`);
const timer = useRef(null);
useEffect(
() => {
if (sStatusName?.includes("停") && bPopup && iPopDuration) {
const restTime = Math.max(
iPopDuration * 60 * 1000 - dProduceHour * 1000,
0
);
clearTimeout(timer.current);
timer.current = null;
timer.current = setTimeout(() => {
window.deviceTargetInfoModalAutoShow = true;
document.getElementById(settingId.current)?.click();
}, restTime);
}
return () => {
clearTimeout(timer.current);
};
},
[sStatusName]
);
const handleGetShowTypeProps = config => {
return {
...commonBusiness.getShowTypes("deviceTargetInfo", props),
showConfig: config,
dataValue: viewRow[config.sName],
enabled: false
};
};
const equipmentTargetInformation = commonFunc.showLocalMessage(props, 'equipmentTargetInformation', '设备及目标信息');
const { workOrderInfoData = [] } = props;
const sColumnConfig = JSON.parse(workOrderInfoData[0]?.sColumnConfig || '[]');
const visibleFieldNames = new Set(
sColumnConfig
.slice(1)
.filter(col => col?.bVisible === 1)
.map(col => col.sName)
);
const result = showConfig.filter(field => visibleFieldNames.has(field.sName)); // 筛选数据
return (
<div className={styles.deviceTargetInfo}>
<div className="mesTitle" style={{ padding: "10px 10px 5px" }}>
<img src={iocnObj.facilityIcon} />
{first.showName}
</div>
{result.map((config, index) => {
// if (index > 4) return "";
// bPushDiff
const { bPushDiff = false } = props?.app?.userinfo
const className = cx({
mesShowType: true,
odd: index % 2 === 0
});
const showTypeProps = handleGetShowTypeProps(config);
// if (
// ['dPieceDefectAQty', 'dPieceDefectBQty'].includes(config?.sName) &&
// !bPushDiff
// ) {
// return null; // 不满足条件,不渲染
// }
// 'dTotalAdjust', 'dSpeed'
if (config?.sName?.endsWith("Qty")) {
return (
<div className={`${className} dynamicClock`}>
<div className={styles.clock}>
<ClockComponent
num={viewRow[config.sName]}
sName={config.sName}
{...props}
/>
</div>
<Row style={{ flexWrap: "nowrap" }}>
<Col flex={"160px"} className={styles.dynamicNumTitle}>
{config.showName}:
</Col>
<Col
flex={1}
className={styles.dynamicNumContent}
style={{ cursor: "not-allowed" }}
>
<div className={styles.mesDynamicNum}>
<MesDynamicNum
num={viewRow[config.sName]}
sName={config.sName}
/>
</div>
</Col>
</Row>
</div>
);
} else if (false && config.showName === "更新时间") {
return (
<div className={`${className}`}>
<Row style={{ flexWrap: "nowrap" }}>
<Col flex={"160px"} className={styles.dynamicNumTitle}>
{config.showName}:
</Col>
<Col
flex={1}
className={styles.dynamicNumContent}
style={{ cursor: "not-allowed" }}
>
<div className={styles.mesDynamicNum}>
<CurrentTimeComponent />
</div>
</Col>
</Row>
</div>
);
} else if (config.showName === "设备状态") {
return (
<div className={className}>
<ShowType {...showTypeProps} />
<div className={styles.statusSetting}>
<Button
type="link"
size="large"
id={settingId.current}
onClick={() => {
window.deviceTargetInfoModal = true;
props.onTableBtnClick({
name: "deviceTargetInfo",
record: viewRow,
config
});
}}
>
设置
</Button>
</div>
</div>
);
} else {
return (
<div className={className}>
<ShowType {...showTypeProps} />
</div>
);
}
})}
</div>
);
};
// 班组信息
const TeamInfoComponent = () => {
const { props } = useContext(myContext);
const rowStyle = {
height: "100%"
};
const tableProps = {
...commonBusiness.getTableTypes("employee", {
...props
}),
footer: "hidden", // 合计栏
// setOpterationColumn: "Y", // 操作栏
tableProps: {
rowSelection: null, // 显示单选框还是复选框
AutoTableHeight: "175px" // 表格高度
}
};
const teamShiftInfo = props.teamShiftInfoData?.[0] || {};
const { sEmployeeName = "", sEmployeeNo = "" } = teamShiftInfo;
const teamInformation = commonFunc.showLocalMessage(props, 'teamInformation', '班组信息');
const captain = commonFunc.showLocalMessage(props, 'captain', '机长');
const shift = commonFunc.showLocalMessage(props, 'shift', '班次');
const classGroup = commonFunc.showLocalMessage(props, 'classGroup', '班组');
const userinfo = props.app.userinfo || {};
const { sShift = "", sTeamNo = "" } = userinfo;
return (
<div className={styles.teamInfo}>
<div className="mesTitle">
<img src={iocnObj.groupIcon} />
{teamInformation}
</div>
<Row gutter="5" wrap={false}>
<Col flex={"160px"}>
<Row style={rowStyle}>
<Col flex={1}>
{props.app.userinfo.sJzPicturePath ? (
<img
src={`${commonConfig.file_host}file/download?savePathStr=${props.app.userinfo.sJzPicturePath}&sModelsId=100&token=${props.token}`}
onError={event => {
event.target.src = iocnObj.userImg;
}}
/>
) : (
<img src={iocnObj.userImg} />
)}
<div className="user">
<span>{captain}:</span>
<span>{sEmployeeName}</span>
</div>
<div>
<span>{classGroup}:</span>
<span>{sTeamNo}</span>
</div>
<div>
<span>{shift}:</span>
<span>{sShift == 1 ? "白班" : "夜班"}</span>
</div>
</Col>
</Row>
</Col>
<Col flex={1}>
<StaticEditTable {...tableProps} />
</Col>
</Row>
</div>
);
};
const MesDynamicNum = ({ num: numNew = 0, sName }) => {
const fontColor = () => {
if (["dTrayQty"].includes(sName)) {
return "red";
}
return "#1890FF";
};
// 将数字转换为字符串并分割成整数和小数部分
const parts = numNew.toString().split(".");
// 对整数部分应用逗号分隔
const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
// 如果有小数部分,将其与格式化的整数部分重新组合
const decimalPart = parts.length > 1 ? "." + parts[1] : "";
const showNum = integerPart + decimalPart;
return (
<span
style={{ fontSize: 22, fontWeight: 600, color: fontColor() }}
className={styles.MesDynamicNumItem}
id={`MesDynamicNum_${sName}`}
>
{showNum}
</span>
);
};
const CurrentTimeComponent = () => {
const [time, setTime] = useState(moment().format("HH:mm:ss"));
useEffect(() => {
const getTime = () => {
const currentTime = moment().format("HH:mm:ss");
setTime(currentTime);
};
getTime();
const timer = setInterval(() => {
getTime();
}, 1000);
return () => {
clearInterval(timer);
};
}, []);
return <span>{time}</span>;
};
export default SiderInfoComponent;