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().materialTaskObj; closeButton.onClick.AddListener(delegate { TutorialGuideManager.Instance.HideGuide(); }); } /// /// 验证输入字段的内容是否正确 /// /// 返回验证结果 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 list = new List(); list.Add("3"); list.Add("9"); MotionEngine.GetModule().HandleClick(list); } else { List list = new List(); list.Add(t1.text); list.Add(t2.text); MotionEngine.GetModule().HandleClick(list); Debug.LogWarning("输入验证失败:\n" + errorMessage); } return isValid; } private void OnSave答题卡() { // 验证输入字段内容 bool isInputValid = ValidateInputFields(); } private void OnQueryButtonClicked() { if (MotionEngine.GetModule().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); } } } }