Files
ChunilENG/Assets/WorkSpace/Personal/JYM/UI_MachineKPI.cs

88 lines
2.4 KiB
C#
Raw Normal View History

2025-02-20 09:59:37 +09:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.EventSystems;
using WI;
2025-02-25 10:23:33 +09:00
using System;
2025-02-20 09:59:37 +09:00
2025-02-25 10:23:33 +09:00
public class UI_MachineKPI : UIBase, IPointerClickHandler
2025-02-20 09:59:37 +09:00
{
public KPIData data;
2025-02-25 10:23:33 +09:00
public RectTransform DefaultKPI;
public RectTransform DetailsKPI;
2025-04-01 13:47:45 +09:00
private TextMeshProUGUI Default_machineName;
private TextMeshProUGUI Details_machineName;
2025-02-25 10:23:33 +09:00
private TextMeshProUGUI Default_eorate;
private TextMeshProUGUI Details_eorate;
private TextMeshProUGUI porate;
private TextMeshProUGUI goodqtyrate;
private TextMeshProUGUI lct;
private TextMeshProUGUI wct;
2025-02-20 09:59:37 +09:00
public bool isExpand;
2025-02-25 10:23:33 +09:00
private float eorate;
public Action<UI_MachineKPI> onClickKPI;
2025-02-20 09:59:37 +09:00
public void SetData(KPIData kpiData)
{
data = kpiData;
2025-02-20 09:59:37 +09:00
eorate = DecimalPointCalculate(kpiData.eorate);
2025-04-01 13:47:45 +09:00
Default_machineName.SetText(kpiData.worknm);
Details_machineName.SetText(kpiData.worknm);
Default_eorate.SetText(eorate.ToString() + "%");
Details_eorate.SetText(eorate.ToString() + "%");
2025-02-25 10:23:33 +09:00
lct.SetText(DecimalPointCalculate(kpiData.lct).ToString());
wct.SetText(DecimalPointCalculate(kpiData.wct).ToString());
goodqtyrate.SetText(DecimalPointCalculate(kpiData.goodqtyrate).ToString());
porate.SetText(DecimalPointCalculate(kpiData.porate).ToString());
2025-02-20 09:59:37 +09:00
2025-02-25 10:23:33 +09:00
DetailsKPI.gameObject.SetActive(false);
2025-02-20 09:59:37 +09:00
}
private float DecimalPointCalculate(string value)
{
var originFloatValue = float.Parse(value);
2025-04-01 13:47:45 +09:00
var floatValue = Mathf.Round(originFloatValue * 10f) / 10f;
2025-02-20 09:59:37 +09:00
return floatValue;
}
2025-02-25 10:23:33 +09:00
public void OnPointerClick(PointerEventData eventData)
{
onClickKPI?.Invoke(this);
}
public void Expand()
{
2025-02-20 09:59:37 +09:00
if (!isExpand)
{
2025-03-12 14:57:35 +09:00
DefaultKPI.gameObject.SetActive(false);
DetailsKPI.gameObject.SetActive(true);
2025-02-25 10:23:33 +09:00
isExpand = true;
2025-02-20 09:59:37 +09:00
}
}
2025-02-25 10:23:33 +09:00
public void Shrink()
2025-02-20 09:59:37 +09:00
{
if (isExpand)
{
2025-03-12 14:57:35 +09:00
DefaultKPI.gameObject.SetActive(true);
DetailsKPI.gameObject.SetActive(false);
2025-02-20 09:59:37 +09:00
isExpand = false;
}
}
2025-02-25 10:23:33 +09:00
public void Active()
2025-02-20 09:59:37 +09:00
{
2025-02-25 10:23:33 +09:00
gameObject.SetActive(true);
2025-02-20 09:59:37 +09:00
}
2025-02-25 10:23:33 +09:00
public void Deactive()
2025-03-12 14:57:35 +09:00
{
2025-02-25 10:45:32 +09:00
DefaultKPI.gameObject.SetActive(true);
DetailsKPI.gameObject.SetActive(false);
isExpand = false;
2025-02-25 10:23:33 +09:00
gameObject.SetActive(false);
2025-02-20 09:59:37 +09:00
}
2025-02-25 10:23:33 +09:00
}