Tz2/Assets/Zion/Scripts/ERP/库存物资报表的查询与解读/QueryInventoryMaterialRepor...

134 lines
4.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using DefaultNamespace;
using DefaultNamespace.ProcessMode;
using Framework.Manager;
using MotionFramework;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Zion.Scripts.ERP.
{
public class QueryInventoryMaterialReportInTransitManager : MonoBehaviour
{
[SerializeField] private InputField factoryCode; //工厂输入框
[SerializeField] private Button _btQuery;
public GameObject queryPanel;
public GameObject answerSheet;
public Button saveButton;
private Framework.Dto.InventoryReversalVoucherAnalyzer returnRevVoucherAnalyzer;
public GameObject plane1;
public GameObject plane2;
public TMP_InputField t1;
public TMP_InputField t2;
public Button closeButton;
void Start()
{
_btQuery.onClick.AddListener(OnQueryButtonClicked);
saveButton.onClick.AddListener(OnSave答题卡);
returnRevVoucherAnalyzer = (Framework.Dto.InventoryReversalVoucherAnalyzer)MotionEngine.GetModule<GlobalDataStorage>().materialTaskObj;
closeButton.onClick.AddListener(delegate
{
TutorialGuideManager.Instance.HideGuide();
});
}
/// <summary>
/// 验证输入字段的内容是否正确
/// </summary>
/// <returns>返回验证结果</returns>
private bool ValidateInputFields()
{
bool isValid = true;
string errorMessage = "";
if (returnRevVoucherAnalyzer.formselection == "库存物资报表1")
{
// 验证表1的标准答案条目1=3条目2=9
if (t1.text != "3")
{
isValid = false;
errorMessage += "条目1输入错误正确答案应为3\n";
}
if (t2.text != "9")
{
isValid = false;
errorMessage += "条目2输入错误正确答案应为9\n";
}
}
else if (returnRevVoucherAnalyzer.formselection == "库存物资报表2")
{
// 验证表2的标准答案条目1=1条目2=7
if (t1.text != "1")
{
isValid = false;
errorMessage += "条目1输入错误正确答案应为1\n";
}
if (t2.text != "7")
{
isValid = false;
errorMessage += "条目2输入错误正确答案应为7\n";
}
}
if (isValid)
{
Debug.Log("输入验证通过:所有字段内容正确!");
List<string> list = new List<string>();
list.Add("3");
list.Add("9");
MotionEngine.GetModule<ProcessManager>().HandleClick(list);
}
else
{
List<string> list = new List<string>();
list.Add(t1.text);
list.Add(t2.text);
MotionEngine.GetModule<ProcessManager>().HandleClick(list);
Debug.LogWarning("输入验证失败:\n" + errorMessage);
}
return isValid;
}
private void OnSave答题卡()
{
// 验证输入字段内容
bool isInputValid = ValidateInputFields();
}
private void OnQueryButtonClicked()
{
if (MotionEngine.GetModule<ProcessManager>().HandleClick(factoryCode.text))
{
// queryPanel.SetActive(true);
answerSheet.SetActive(true);
if (returnRevVoucherAnalyzer.formselection == "库存物资报表1")
{
plane1.SetActive(true);
FileComponent.DownloadSingleFile("附件2库存物资报表的查询与解读--在途库存表1");
}
else
{
plane2.SetActive(true);
FileComponent.DownloadSingleFile("附件2库存物资报表的查询与解读--在途库存表2");
}
TutorialGuideManager.Instance.TriggerNextGuide(_btQuery.name);
}
}
}
}