156 lines
5.1 KiB
C#
156 lines
5.1 KiB
C#
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
|
||
{
|
||
/// <summary>
|
||
/// 报废物资归属工厂输入字段
|
||
/// </summary>
|
||
[Header("报废物资归属工厂")] public TMP_InputField ScrapMaterialBelongingFactory;
|
||
|
||
/// <summary>
|
||
/// 移交人输入字段
|
||
/// </summary>
|
||
[Header("移交人")] public TMP_InputField Transferor;
|
||
|
||
/// <summary>
|
||
/// 移交人电话输入字段
|
||
/// </summary>
|
||
[Header("移交人电话")] public TMP_InputField TransferorPhone;
|
||
|
||
/// <summary>
|
||
/// 物料编码输入字段
|
||
/// </summary>
|
||
[Header("物料编码")] public TMP_InputField MaterialCode;
|
||
|
||
/// <summary>
|
||
/// 项目名称输入字段
|
||
/// </summary>
|
||
[Header("项目名称")] public TMP_InputField ProjectName;
|
||
|
||
/// <summary>
|
||
/// 资产报废单扫描件输入字段
|
||
/// </summary>
|
||
[Header("资产报废单扫描件")] public TMP_InputField AssetScrapDocumentScan;
|
||
|
||
/// <summary>
|
||
/// 自动填充字段1
|
||
/// </summary>
|
||
[Header("自动填充字段1")] public TMP_InputField text1;
|
||
|
||
/// <summary>
|
||
/// 自动填充字段2
|
||
/// </summary>
|
||
[Header("自动填充字段2")] public TMP_InputField text2;
|
||
|
||
/// <summary>
|
||
/// 自动填充字段3
|
||
/// </summary>
|
||
[Header("自动填充字段3")] public TMP_InputField text3;
|
||
|
||
/// <summary>
|
||
/// 自动填充字段4
|
||
/// </summary>
|
||
[Header("自动填充字段4")] public TMP_InputField text4;
|
||
|
||
/// <summary>
|
||
/// 自动填充字段5
|
||
/// </summary>
|
||
[Header("自动填充字段5")] public TMP_InputField text5;
|
||
|
||
/// <summary>
|
||
/// 自动填充字段6
|
||
/// </summary>
|
||
[Header("自动填充字段6")] public TMP_InputField text6;
|
||
|
||
/// <summary>
|
||
/// 保存按钮
|
||
/// </summary>
|
||
[Header("保存按钮")] public Button btnSaveScrapMaterialEntry;
|
||
|
||
/// <summary>
|
||
/// 组件初始化方法
|
||
/// </summary>
|
||
private void Start()
|
||
{
|
||
// 为物料编码输入框添加值变化监听器
|
||
if (MaterialCode != null)
|
||
{
|
||
MaterialCode.onValueChanged.AddListener(OnMaterialCodeInputChanged);
|
||
}
|
||
|
||
// 为保存按钮添加点击事件监听器
|
||
if (btnSaveScrapMaterialEntry != null)
|
||
{
|
||
btnSaveScrapMaterialEntry.onClick.AddListener(OnSaveButtonClicked);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 处理物料编码输入框内容变化事件
|
||
/// </summary>
|
||
/// <param name="inputValue">输入框当前的值</param>
|
||
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";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 处理保存按钮点击事件
|
||
/// </summary>
|
||
private void OnSaveButtonClicked()
|
||
{
|
||
Debug.Log("报废物资入库申请单:开始保存数据");
|
||
|
||
// 收集所有字段的数据
|
||
List<string> scrapMaterialData = new List<string>();
|
||
|
||
// 添加主要字段数据
|
||
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<ProcessManager>().HandleClick(scrapMaterialData);
|
||
|
||
if (saveResult)
|
||
{
|
||
Debug.Log("报废物资入库申请单:保存成功");
|
||
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("库存物资报废") ||
|
||
MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("电力电缆报废系统操作"))
|
||
{
|
||
TutorialGuideManager.Instance.TriggerNextGuide();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("报废物资入库申请单:保存失败");
|
||
}
|
||
}
|
||
} |