Tz2/Assets/Zion/Scripts/ERP/查询物资采购合同执行状态/ERP_PurchaseContractStatus.cs

273 lines
9.5 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 DefaultNamespace;
using DefaultNamespace.ProcessMode;
using MotionFramework;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Framework.Manager;
using UnityEngine;
using UnityEngine.UI;
using static InterfaceManager;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
/// <summary>
/// 查询物资采购合同执行状态
/// </summary>
public class ERP_PurchaseContractStatus : MonoBehaviour
{
/// <summary>
/// 确定按钮
/// </summary>
public Button Enterbt;
/// <summary>
/// 工厂
/// </summary>
public InputField Factory;
/// <summary>
/// 公司代码
/// </summary>
public InputField Companycode;
/// <summary>
/// 物料
/// </summary>
public InputField Material;
/// <summary>
/// 批次
/// </summary>
public InputField Batch;
/// <summary>
/// 采购订单
/// </summary>
public InputField Purchaseorder;
/// <summary>
/// 项目定义
/// </summary>
public InputField ProjectDefinition;
/// <summary>
/// 合同日期从
/// </summary>
public InputField Projectfrom;
/// <summary>
/// 合同日期至
/// </summary>
public InputField Projectend;
/// <summary>
/// 附件1
/// </summary>
public GameObject Annex1;
/// <summary>
/// 附件2
/// </summary>
public GameObject Annex2;
/// <summary>
/// 打印按钮
/// </summary>
public Button PrintBt;
/// <summary>
/// 表格页面
/// </summary>
public GameObject ExcelPanel;
public Button OpenWordBtn;
/// <summary>
/// 单据按钮
/// </summary>
public Button Order;
public Toggle weixuanze;
CombinedClass combined;
private Framework.Dto.InventoryReversalVoucherAnalyzer returnRevVoucherAnalyzer;
/// <summary>
/// word路径
/// </summary>
string WordPath;
private void Awake()
{
combined = GameManager.Instance.combinedClass;
}
void Start()
{
returnRevVoucherAnalyzer = (Framework.Dto.InventoryReversalVoucherAnalyzer)MotionEngine.GetModule<GlobalDataStorage>().materialTaskObj;
// weixuanze.onValueChanged.AddListener((arg0 =>
// {
// if (arg0) // 只在Toggle为true时触发
// {
// TutorialGuideManager.Instance.TriggerNextGuide(weixuanze.name);
// }
// }));
//Enterbt = FindObjectByName<Button>("btn确定按钮");
//Factory = FindObjectByName<InputField>("工厂");
//Companycode = FindObjectByName<InputField>("公司代码");
//Material = FindObjectByName<InputField>("物料");
//Batch = FindObjectByName<InputField>("批次");
//Purchaseorder = FindObjectByName<InputField>("采购订单");
//ProjectDefinition = FindObjectByName<InputField>("项目定义");
//Projectfrom = FindObjectByName<InputField>("合同日期start");
//Projectend = FindObjectByName<InputField>("合同日期end");
//PrintBt = FindObjectByName<Button>("打印表格");
//OpenWordBtn = FindObjectByName<Button>("OpenWordBtn");
//ExcelPanel = FindObjectByName<Transform>("查询物资采购合同执行状态_表格").gameObject;
Order = FindObjectByName<Button>("单据");
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("重点物资排产计划制定"))
{
Order.onClick.AddListener(() => { MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string>() { Factory.text, Companycode.text, Purchaseorder.text, ProjectDefinition.text, Projectfrom.text, Projectend.text }); });
}
Enterbt.onClick.AddListener(() =>
{
if (!MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("重点物资排产计划制定"))
{
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("完成出厂验收的系统上报操作"))
{
if (MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string>() { Factory.text, Companycode.text, Purchaseorder.text, ProjectDefinition.text, Projectfrom.text, Projectend.text, weixuanze.isOn.ToString() }))
{
ExcelPanel.SetActive(true);
LoadTriggerNextGuide(Enterbt.name);
}
}
else if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("ELP应用"))
{
if (MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string>() { Factory.text, Companycode.text, ProjectDefinition.text, Projectfrom.text, Projectend.text }))
{
ExcelPanel.SetActive(true);
LoadTriggerNextGuide(Enterbt.name);
}
}
else
{
if (MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string>() { Factory.text, Companycode.text, Purchaseorder.text, ProjectDefinition.text, Projectfrom.text, Projectend.text }))
{
ExcelPanel.SetActive(true);
LoadTriggerNextGuide(Enterbt.name);
}
}
}
else
{
ExcelPanel.SetActive(true);
LoadTriggerNextGuide(Enterbt.name);
}
});
PrintBt.onClick.AddListener(() =>
{
GameObject go = null;
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("重点物资排产计划制定"))
{
//go = Resources.Load<GameObject>("Prefabs/配送专业/Excel报表集合/Panel_重点物资排产计划制定_附件2");
FileComponent.DownloadSingleFile("4501693621物资合同信息.XLSX");
}
else if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("物资配送履约跟踪表维护"))
{
//go = Resources.Load<GameObject>("Prefabs/配送专业/Excel报表集合/Panel_物资配送履约跟踪表维护_001");
FileComponent.DownloadSingleFile("物资履约跟踪表模板_表单1_答题卡");
if (returnRevVoucherAnalyzer.formselection == "表单1")
{
FileComponent.DownloadSingleFile("1510501502XL物资合同清单_表单1");
}
else
{
FileComponent.DownloadSingleFile("1510501502XL物资合同清单_表单2");
}
MotionEngine.GetModule<ProcessManager>().HandleClick(new List<string>() { "保存" });
TutorialGuideManager.Instance.TriggerNextGuide(PrintBt.name);
}
else if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("完成出厂验收的系统上报操作"))
{
// go = Resources.Load<GameObject>("Prefabs/配送专业/Excel报表集合/Panel_完成出厂验收的系统上报操作_001");
FileComponent.DownloadSingleFile("出厂验收数据");
}
else if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("ELP应用"))
{
go = Resources.Load<GameObject>("Prefabs/配送专业/答题卡/ELP应用答题卡");
WordPath = Application.streamingAssetsPath + "/Word/附件2运输方案_默认.docx";
//OpenWordBtn.gameObject.SetActive(true);
FileComponent.DownloadSingleFile("1510A019000K物资合同清单_默认");
FileComponent.DownloadSingleFile("运输方案_默认");
LoadTriggerNextGuide();
}
if (Annex1 == null && go != null)
{
Annex1 = Instantiate(go, PrintBt.transform.parent.parent);
}
if (Annex1 != null)
{
LoadTriggerNextGuide("关闭");
Annex1.gameObject.SetActive(true);
}
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("完成出厂验收的系统上报操作") ||
MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("重点物资排产计划制定"))
{
LoadTriggerNextGuide();
}
else
{
LoadTriggerNextGuide("关闭");
}
});
//OpenWordBtn.onClick.AddListener(() =>
//{
// GameObject go = null;
// OpenExcelFile(WordPath);
// if (go == null)
// {
// go = Instantiate(Resources.Load<GameObject>("Prefabs/配送专业/答题卡/ELP应用答题卡"), OpenWordBtn.transform.parent);
// }
// else
// {
// go.SetActive(true);
// }
//});
}
/// <summary>
/// 打开Excel、Word文件
/// </summary>
/// <param name="filePath">文件地址</param>
public void OpenExcelFile(string filePath)
{
// 检查文件是否存在
if (File.Exists(filePath))
{
try
{
System.Diagnostics.Process.Start(filePath);
}
catch (System.Exception e)
{
UnityEngine.Debug.LogError("Error opening file: " + e.Message);
}
}
else
{
UnityEngine.Debug.LogError("File not found: " + filePath);
}
}
void Update()
{
}
}