284 lines
10 KiB
C#
284 lines
10 KiB
C#
using DefaultNamespace.ProcessMode;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using DefaultNamespace;
|
|
using Framework.Manager;
|
|
using MotionFramework;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static InterfaceManager;
|
|
/// <summary>
|
|
/// 物资控制中心
|
|
/// </summary>
|
|
public class MaterialCenter : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 单例
|
|
/// </summary>
|
|
public static MaterialCenter Instance;
|
|
/// <summary>
|
|
/// 物资检查
|
|
/// </summary>
|
|
public GameObject panelMaterialInspection;
|
|
/// <summary>
|
|
/// 物资检查按钮
|
|
/// </summary>
|
|
public Button btnMaterialInspection;
|
|
/// <summary>
|
|
/// 物资配套资料
|
|
/// </summary>
|
|
public Toggle[] toggles;
|
|
/// <summary>
|
|
/// 应收物资数量输入框
|
|
/// </summary>
|
|
public TMP_InputField inputQuantityReceivableMaterials;
|
|
/// <summary>
|
|
/// 应收物资单位显示
|
|
/// </summary>
|
|
public TextMeshProUGUI TextInputQuantityReceivableMaterials;
|
|
/// <summary>
|
|
/// 应收物资数量爆保存按钮
|
|
/// </summary>
|
|
public Button btnQuantityReceivableMaterials;
|
|
/// <summary>
|
|
/// 物资检查附件按钮
|
|
/// </summary>
|
|
public Button btnCheckAttachments;
|
|
/// <summary>
|
|
/// 物资卡片
|
|
/// </summary>
|
|
public Button btnMaterialCard;
|
|
/// <summary>
|
|
/// 物资卡片
|
|
/// </summary>
|
|
public MaterialCard PanelMaterialCard;
|
|
/// <summary>
|
|
/// 悬挂物资卡片
|
|
/// </summary>
|
|
public Button btnHangMaterialCard;
|
|
/// <summary>
|
|
/// 关闭物资检查面板
|
|
/// </summary>
|
|
public Button btnClosePanelMaterialInspection;
|
|
/// <summary>
|
|
/// 地磅检查按钮
|
|
/// </summary>
|
|
public Button WeighCheckbt;
|
|
/// <summary>
|
|
/// 地磅检查完毕保存按钮
|
|
/// </summary>
|
|
public Button WeighChecksavebt;
|
|
/// <summary>
|
|
/// 卸货按钮
|
|
/// </summary>
|
|
public Button Unload;
|
|
/// <summary>
|
|
/// 地磅检查面板
|
|
/// </summary>
|
|
public GameObject WeighChecksPanel;
|
|
/// <summary>
|
|
/// 地磅检查toggle
|
|
/// </summary>
|
|
public List<Toggle> choosetoggle;
|
|
|
|
|
|
public Button btupload;
|
|
|
|
public GameObject plane1;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
//在场景中找出隐藏的PanelMaterialInspection的Transform
|
|
panelMaterialInspection = FindHiddenPanel("PanelMaterialInspection");
|
|
btnMaterialInspection = FindObjectByName<Button>("btnMaterialInspection");
|
|
btnClosePanelMaterialInspection = FindObjectByName<Button>("btnClosePanelMaterialInspection");
|
|
|
|
WeighCheckbt = FindObjectByName<Button>("btnWeighbridgeInspection");
|
|
Unload = FindObjectByName<Button>("btnUnload");
|
|
WeighChecksavebt = FindObjectByName<Button>("btnCheckWeigh");
|
|
WeighChecksPanel = FindHiddenPanel("地磅检查");
|
|
choosetoggle = WeighChecksPanel.GetComponentsInChildren<Toggle>().ToList();
|
|
|
|
inputQuantityReceivableMaterials = FindObjectByName<TMP_InputField>("inputQuantityReceivableMaterials");
|
|
TextInputQuantityReceivableMaterials = FindObjectByName<TextMeshProUGUI>("TextInputQuantityReceivableMaterials");
|
|
btnQuantityReceivableMaterials = FindObjectByName<Button>("btnSaveQuantityReceivableMaterials");
|
|
btnCheckAttachments = FindObjectByName<Button>("btnCheckAttachments");
|
|
btnMaterialCard = FindObjectByName<Button>("btnMaterialCard");
|
|
PanelMaterialCard = FindObjectByName<MaterialCard>("PanelMaterialCard");
|
|
btnHangMaterialCard = FindObjectByName<Button>("btnHangMaterialCard");
|
|
if (panelMaterialInspection != null)
|
|
{
|
|
toggles = panelMaterialInspection.GetComponentsInChildren<Toggle>();
|
|
}
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
WeighCheckbt.onClick.AddListener(() =>
|
|
{
|
|
LoadTriggerNextGuide(WeighCheckbt.name);
|
|
});
|
|
// btupload.onClick.AddListener(() =>
|
|
// {
|
|
// FileComponent.UploadExamFiles();
|
|
// });
|
|
|
|
|
|
if (panelMaterialInspection != null && btnMaterialInspection != null)
|
|
{
|
|
btnMaterialInspection.onClick.AddListener(() =>
|
|
{
|
|
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("库存物资报废"))
|
|
{
|
|
// panelMaterialInspection.SetActive(true);
|
|
plane1.SetActive(true);
|
|
LoadTriggerNextGuide(btnMaterialInspection.name);
|
|
}
|
|
else
|
|
{
|
|
panelMaterialInspection.SetActive(true);
|
|
LoadTriggerNextGuide(btnMaterialInspection.name);
|
|
}
|
|
|
|
|
|
});
|
|
}
|
|
//关闭面板
|
|
if (btnClosePanelMaterialInspection)
|
|
{
|
|
btnClosePanelMaterialInspection.onClick.AddListener(() =>
|
|
{
|
|
panelMaterialInspection.SetActive(false);
|
|
if (btnCheckAttachments.gameObject.activeSelf)
|
|
{
|
|
LoadTriggerNextGuide("关闭"); ;
|
|
}
|
|
else
|
|
{
|
|
LoadTriggerNextGuide(panelMaterialInspection.name);
|
|
}
|
|
});
|
|
}
|
|
//数量清点
|
|
if (inputQuantityReceivableMaterials && btnQuantityReceivableMaterials)
|
|
{
|
|
btnQuantityReceivableMaterials.onClick.AddListener(() =>
|
|
{
|
|
//数量清点
|
|
bool isMatch = MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(inputQuantityReceivableMaterials.text);
|
|
|
|
btnQuantityReceivableMaterials.gameObject.SetActive(false);
|
|
LoadTriggerNextGuide(btnQuantityReceivableMaterials.name);
|
|
});
|
|
}
|
|
//检查附件及产品相关资料
|
|
if (btnCheckAttachments != null && toggles != null && toggles.Length > 5)
|
|
{
|
|
btnCheckAttachments.onClick.AddListener(() =>
|
|
{
|
|
string isTrueOne = toggles[0].isOn ? "true" : "false";
|
|
string isTrueTwo = toggles[1].isOn ? "true" : "false";
|
|
string isTrueThree = toggles[2].isOn ? "true" : "false";
|
|
string isTrueFour = toggles[3].isOn ? "true" : "false";
|
|
string isTrueFive = toggles[4].isOn ? "true" : "false";
|
|
string isTrueSix = toggles[5].isOn ? "true" : "false";
|
|
//检查附件及产品相关资料
|
|
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode.教学模式 ||
|
|
MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode.课程预览)
|
|
{
|
|
if (MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string> { isTrueOne, isTrueTwo, isTrueThree, isTrueFour, isTrueFive, isTrueSix }))
|
|
{
|
|
|
|
btnCheckAttachments.gameObject.SetActive(false);
|
|
LoadTriggerNextGuide(btnCheckAttachments.name);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string> { isTrueOne, isTrueTwo, isTrueThree, isTrueFour, isTrueFive, isTrueSix });
|
|
btnCheckAttachments.gameObject.SetActive(false);
|
|
LoadTriggerNextGuide(btnCheckAttachments.name);
|
|
}
|
|
});
|
|
|
|
}
|
|
if (WeighChecksavebt != null)
|
|
{
|
|
WeighChecksavebt.onClick.AddListener(() =>
|
|
{
|
|
string isTrue1 = choosetoggle[0].isOn ? "true" : "false";
|
|
string isTrue2 = choosetoggle[1].isOn ? "true" : "false";
|
|
string isTrue3 = choosetoggle[2].isOn ? "true" : "false";
|
|
string isTrue4 = choosetoggle[3].isOn ? "true" : "false";
|
|
if (MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string> { isTrue1, isTrue2, isTrue3, isTrue4 }))
|
|
{
|
|
|
|
WeighChecksPanel.SetActive(false);
|
|
|
|
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("库存物资报废"))
|
|
{
|
|
TutorialGuideManager.Instance.HideGuide();
|
|
}
|
|
else
|
|
{
|
|
LoadTriggerNextGuide(WeighChecksavebt.name);
|
|
}
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
Unload.onClick.AddListener(() =>
|
|
{
|
|
// CarMoverToWeigh.Instance.CloneModel.SetActive(false);
|
|
CarMoverToWeigh.Instance.IsUnload = true;
|
|
MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick("true");
|
|
UI_Tips.instance.ShowPanel("卸货成功!", true);
|
|
WeighBridgeCheck.instance.weightips.SetActive(true);
|
|
LoadTriggerNextGuide("关闭"); ;
|
|
|
|
});
|
|
if (btnMaterialCard != null && PanelMaterialCard != null)
|
|
{
|
|
btnMaterialCard.onClick.AddListener(() =>
|
|
{
|
|
PanelMaterialCard.gameObject.SetActive(true);
|
|
LoadTriggerNextGuide(btnMaterialCard.name);
|
|
});
|
|
}
|
|
if (btnHangMaterialCard != null)
|
|
{
|
|
btnHangMaterialCard.onClick.AddListener(() =>
|
|
{
|
|
PanelMaterialCard.HangModerController(btnHangMaterialCard.name);
|
|
StartCoroutine(WaitEnable(btnHangMaterialCard, 1.5f));
|
|
});
|
|
}
|
|
|
|
if (TextInputQuantityReceivableMaterials != null)
|
|
{
|
|
CombinedClass combinedClass = GameManager.Instance.combinedClass;
|
|
if (combinedClass != null)
|
|
{
|
|
TextInputQuantityReceivableMaterials.text = combinedClass.materialUnit;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 添加按钮点击完后延迟后才能再点
|
|
/// </summary>
|
|
/// <param name="bt"></param>
|
|
/// <param name="time"></param>
|
|
/// <returns></returns>
|
|
IEnumerator WaitEnable(Button bt, float time)
|
|
{
|
|
bt.enabled = false;
|
|
yield return new WaitForSeconds(time);
|
|
bt.enabled = true;
|
|
}
|
|
}
|