using System.Collections; using System.Collections.Generic; using DefaultNamespace.ProcessMode; using MotionFramework; using UnityEngine; using TMPro; using UnityEngine.UI; using DefaultNamespace; using Framework.Manager; public class ScrapMaterialEntryRequestManager : MonoBehaviour { /// /// 报废物资归属工厂输入字段 /// [Header("报废物资归属工厂")] public TMP_InputField ScrapMaterialBelongingFactory; /// /// 移交人输入字段 /// [Header("移交人")] public TMP_InputField Transferor; /// /// 移交人电话输入字段 /// [Header("移交人电话")] public TMP_InputField TransferorPhone; /// /// 物料编码输入字段 /// [Header("物料编码")] public TMP_InputField MaterialCode; /// /// 项目名称输入字段 /// [Header("项目名称")] public TMP_InputField ProjectName; /// /// 资产报废单扫描件输入字段 /// [Header("资产报废单扫描件")] public TMP_InputField AssetScrapDocumentScan; /// /// 自动填充字段1 /// [Header("自动填充字段1")] public TMP_InputField text1; /// /// 自动填充字段2 /// [Header("自动填充字段2")] public TMP_InputField text2; /// /// 自动填充字段3 /// [Header("自动填充字段3")] public TMP_InputField text3; /// /// 自动填充字段4 /// [Header("自动填充字段4")] public TMP_InputField text4; /// /// 自动填充字段5 /// [Header("自动填充字段5")] public TMP_InputField text5; /// /// 自动填充字段6 /// [Header("自动填充字段6")] public TMP_InputField text6; /// /// 保存按钮 /// [Header("保存按钮")] public Button btnSaveScrapMaterialEntry; /// /// 组件初始化方法 /// private void Start() { // 为物料编码输入框添加值变化监听器 if (MaterialCode != null) { MaterialCode.onValueChanged.AddListener(OnMaterialCodeInputChanged); } // 为保存按钮添加点击事件监听器 if (btnSaveScrapMaterialEntry != null) { btnSaveScrapMaterialEntry.onClick.AddListener(OnSaveButtonClicked); } } /// /// 处理物料编码输入框内容变化事件 /// /// 输入框当前的值 private void OnMaterialCodeInputChanged(string inputValue) { Debug.Log("物料编码输入检测:用户输入了特殊编码 1111,正在自动填充相关字段"); // 自动填充text1到text6字段 if (text1 != null) text1.text = "工程结余线缆"; if (text2 != null) text2.text = "XXX"; if (text3 != null) text3.text = "1"; if (text4 != null) text4.text = "02"; if (text5 != null) text5.text = "千米"; if (text6 != null) text6.text = "XXXX"; } /// /// 处理保存按钮点击事件 /// private void OnSaveButtonClicked() { Debug.Log("报废物资入库申请单:开始保存数据"); // 收集所有字段的数据 List scrapMaterialData = new List(); // 添加主要字段数据 scrapMaterialData.Add(ScrapMaterialBelongingFactory != null ? ScrapMaterialBelongingFactory.text : ""); scrapMaterialData.Add(ProjectName != null ? ProjectName.text : ""); scrapMaterialData.Add(AssetScrapDocumentScan != null ? AssetScrapDocumentScan.text : ""); scrapMaterialData.Add(Transferor != null ? Transferor.text : ""); scrapMaterialData.Add(TransferorPhone != null ? TransferorPhone.text : ""); scrapMaterialData.Add(MaterialCode != null ? MaterialCode.text : ""); // // 添加自动填充字段数据 // scrapMaterialData.Add(text1 != null ? text1.text : ""); // scrapMaterialData.Add(text2 != null ? text2.text : ""); // scrapMaterialData.Add(text3 != null ? text3.text : ""); // scrapMaterialData.Add(text4 != null ? text4.text : ""); // scrapMaterialData.Add(text5 != null ? text5.text : ""); // scrapMaterialData.Add(text6 != null ? text6.text : ""); // 执行保存操作 bool saveResult = MotionEngine.GetModule().HandleClick(scrapMaterialData); if (saveResult) { Debug.Log("报废物资入库申请单:保存成功"); if (MotionEngine.GetModule().ExamName.Contains("库存物资报废") || MotionEngine.GetModule().ExamName.Contains("电力电缆报废系统操作")) { TutorialGuideManager.Instance.TriggerNextGuide(); } } else { Debug.Log("报废物资入库申请单:保存失败"); } } }