Tz2/Assets/Zion/Scripts/ERP/到货验收/CheckApprovalStatusDemand.cs

177 lines
6.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;
using System.Collections;
using System.Collections.Generic;
using DefaultNamespace;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using static InterfaceManager;
using DefaultNamespace.ProcessMode;
using Framework.Manager;
using MotionFramework;
/// <summary>
/// 查询需求计划审批状态
/// </summary>
public class CheckApprovalStatusDemand : MonoBehaviour
{
public TMP_InputField startDate;
public TMP_InputField endDate;
/// <summary>
///
/// </summary>
public Button BtnFindCheckApprovalStatusDemand;
/// <summary>
/// 工厂
/// </summary>
public TMP_InputField FactoryCheckApprovalStatusDemand;
/// <summary>
/// 计划批次
/// </summary>
public TMP_InputField PlanBatchCheckApprovalStatusDemand;
/// <summary>
/// 采购申请号
/// </summary>
public TMP_InputField PurchaseApplicationCheckApprovalStatusDemand;
/// <summary>
/// Panel2
/// </summary>
public Transform CheckApprovalStatusDemandPanelTwo;
/// <summary>
/// 答题卡
/// </summary>
public GameObject AnswerSheet;
public TMP_Dropdown[] ;
public TMP_Dropdown[] ;
public Button saveBt;
public Button saveBt2;
// Start is called before the first frame update
void Start()
{
saveBt2.onClick.AddListener(delegate
{
FileComponent.DownloadSingleFile("附件2需求计划审批状态反馈_答题卡1");
FileComponent.DownloadSingleFile("附件1需求计划审批状态查询情况报表");
MotionEngine.GetModule<ProcessManager>().HandleClick("保存");
});
BtnFindCheckApprovalStatusDemand = FindObjectByName<Button>("BtnFindCheckApprovalStatusDemand");
FactoryCheckApprovalStatusDemand = FindObjectByName<TMP_InputField>("FactoryCheckApprovalStatusDemand");
PlanBatchCheckApprovalStatusDemand = FindObjectByName<TMP_InputField>("PlanBatchCheckApprovalStatusDemand");
PurchaseApplicationCheckApprovalStatusDemand = FindObjectByName<TMP_InputField>("PurchaseApplicationCheckApprovalStatusDemand");
CheckApprovalStatusDemandPanelTwo = FindObjectByName<Transform>("CheckApprovalStatusDemandPanelTwo");
if (BtnFindCheckApprovalStatusDemand != null && FactoryCheckApprovalStatusDemand != null && PlanBatchCheckApprovalStatusDemand != null && PurchaseApplicationCheckApprovalStatusDemand != null)
{
BtnFindCheckApprovalStatusDemand.onClick.AddListener(() =>
{
// // 验证日期范围是否在2025.1.1-2025.2.28区间内
// if (!ValidateDateRange())
// {
// Debug.LogError("日期范围必须在2025年1月1日到2025年2月28日之间");
// return;
// }
List<string> list = new List<string>();
list.Add(startDate.text);
list.Add(endDate.text);
list.Add(FactoryCheckApprovalStatusDemand.text);
list.Add(PlanBatchCheckApprovalStatusDemand.text);
list.Add(PurchaseApplicationCheckApprovalStatusDemand.text);
// 你可以在这里调用其他方法来处理订单号
bool isTrue = MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(list);
if (CheckApprovalStatusDemandPanelTwo)
{
CheckApprovalStatusDemandPanelTwo.gameObject.SetActive(isTrue);
TutorialGuideManager.Instance.TriggerNextGuide(BtnFindCheckApprovalStatusDemand.name);
}
else
{
AnswerSheet.SetActive(true);
}
});
}
saveBt.onClick.AddListener(delegate
{
List<string> list = new List<string>();
// 遍历前 7 个元素
for (int i = 0; i < 7; i++)
{
if (i < .Length && [i].options.Count > [i].value)
{
list.Add([i].options[[i].value].text);
}
if (i < .Length && [i].options.Count > [i].value)
{
list.Add([i].options[[i].value].text);
}
}
bool isTrue = MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(list);
});
}
// /// <summary>
// /// 验证日期范围是否在2025年1月1日到2025年2月28日之间
// /// </summary>
// /// <returns>验证通过返回true否则返回false</returns>
// private bool ValidateDateRange()
// {
// // 检查日期字段是否为空
// if (string.IsNullOrEmpty(startDate.text) || string.IsNullOrEmpty(endDate.text))
// {
// Debug.LogError("开始日期和结束日期不能为空");
// return false;
// }
//
// // 尝试解析日期
// if (!DateTime.TryParse(startDate.text, out DateTime startDateTime) ||
// !DateTime.TryParse(endDate.text, out DateTime endDateTime))
// {
// Debug.LogError("日期格式不正确,请使用正确的日期格式");
// return false;
// }
//
// // 定义允许的日期范围
// DateTime minDate = new DateTime(2025, 1, 1);
// DateTime maxDate = new DateTime(2025, 2, 28);
//
// // 验证日期是否在允许范围内(包含边界)
// if (startDateTime < minDate || startDateTime > maxDate)
// {
// Debug.LogError($"开始日期必须在{minDate:yyyy年MM月dd日}到{maxDate:yyyy年MM月dd日}之间(包含边界)");
// return false;
// }
//
// if (endDateTime < minDate || endDateTime > maxDate)
// {
// Debug.LogError($"结束日期必须在{minDate:yyyy年MM月dd日}到{maxDate:yyyy年MM月dd日}之间(包含边界)");
// return false;
// }
//
// // 验证开始日期不能晚于结束日期
// if (startDateTime > endDateTime)
// {
// Debug.LogError("开始日期不能晚于结束日期");
// return false;
// }
//
// return true;
// }
}