Tz2/Assets/Zion/Scripts/ERP/在途库存物资报表的查询与解读/TransitInventoryReportQuery.cs

153 lines
4.6 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;
using System.Collections;
using System.Collections.Generic;
using DefaultNamespace;
using DefaultNamespace.ProcessMode;
using Framework.Manager;
using MotionFramework;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 在途库存物资报表的查询与解读
/// </summary>
public class TransitInventoryReportQuery : MonoBehaviour
{
[SerializeField] private InputField factoryCode; //工厂输入框
[SerializeField] private Button _btQuery;
public GameObject queryPanel1;
public GameObject queryPanel2;
public GameObject answerSheet;
public Button saveButton;
private Framework.Dto.InventoryReversalVoucherAnalyzer returnRevVoucherAnalyzer;
public TMP_InputField t1;
public TMP_InputField t2;
public Button closeButton;
public Button lingcunBt;
public Button lingcunBt2;
private void Awake()
{
// queryButton = transform.Find("Panel1/工厂").GetComponent<InputField>();
// _btQuery = transform.Find("Panel1/查询").GetComponent<Button>();
}
// 初始化方法
void Start()
{
_btQuery.onClick.AddListener(OnQueryButtonClicked);
saveButton.onClick.AddListener(OnSaveButtonClicked);
returnRevVoucherAnalyzer = (Framework.Dto.InventoryReversalVoucherAnalyzer)MotionEngine.GetModule<GlobalDataStorage>().materialTaskObj;
closeButton.onClick.AddListener(delegate
{
TutorialGuideManager.Instance.HideGuide();
});
lingcunBt.onClick.AddListener(SaveFun);
lingcunBt2.onClick.AddListener(SaveFun);
}
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 OnSaveButtonClicked()
{
ValidateInputFields();
}
public void SaveFun()
{
if (returnRevVoucherAnalyzer.formselection == "库存物资报表1")
{
queryPanel1.SetActive(true);
FileComponent.DownloadSingleFile("在途库存物资报表的查询与解读--在途库存表1");
}
else
{
queryPanel2.SetActive(true);
FileComponent.DownloadSingleFile("在途库存物资报表的查询与解读--在途库存表2");
}
// MotionEngine.GetModule<ProcessManager>().HandleClick("保存");
answerSheet.SetActive(true);
}
// 查询按钮点击事件处理
private void OnQueryButtonClicked()
{
if (MotionEngine.GetModule<ProcessManager>().HandleClick(factoryCode.text))
{
if (returnRevVoucherAnalyzer.formselection == "库存物资报表1")
{
queryPanel1.SetActive(true);
}
else if (returnRevVoucherAnalyzer.formselection == "库存物资报表2")
{
queryPanel2.SetActive(true);
}
TutorialGuideManager.Instance.TriggerNextGuide(_btQuery.name);
//answerSheet.SetActive(true);
}
}
}