using DefaultNamespace;
using DefaultNamespace.ProcessMode;
using MotionFramework;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using static InterfaceManager;
///
/// 维护到货验收单
///
public class ERPMaintainArrivalInspectionForm : MonoBehaviour
{
///
/// 货物交接单号
///
[Header("货物交接单号")] public string deliveryListNumber;
///
/// 货物交接单
///
[Header("货物交接单")] public InputField input_DeliveryList;
///
/// 公司代码
///
[Header("公司代码")] public InputField input_CompanyCode;
///
/// 实际验收日期
///
[Header("实际验收日期")] public InputField input_ActualInspectionDate;
///
/// 过账日期
///
[Header("过账日期")] public InputField input_PostingDate;
///
/// 供应商名称
///
[Header("供应商名称")] public InputField input_SupplierName;
///
/// 物资供应公司签字
///
[Header("物资供应公司签字")] public InputField input_SupplierSign;
///
/// 物资供应公司签字日期
///
[Header("物资供应公司签字日期")] public InputField input_SupplierSignDate;
///
/// 项目单位接收人签字
///
[Header("项目单位接收人签字")] public InputField input_ProjectUnitSign;
///
/// 项目单位接收人签字日期
///
[Header("项目单位接收人签字日期")] public InputField input_ProjectUnitSignDate;
///
/// 供应商交付人签字
///
[Header("供应商交付人签字")] public InputField input_SupplierDeliverySign;
///
/// 供应商交付人签字日期
///
[Header("供应商交付人签字日期")] public InputField input_SupplierDeliverySignDate;
///
/// 查询显示
///
public List panel_QueryShow;
///
/// 正常收获
///
public Button btnNormal;
///
/// 过账
///
public Button btnPosting;
///
/// 行项目
///
public List input_ERPDeliveryLists;
///
/// 物资身份码
///
public List materialToggle;
///
/// 选择身份码
///
public Button ChooseToggle;
///
/// 身份码面板
///
public ScrollRect IDcarPanel;
// Start is called before the first frame update
void Start()
{
//初始化UI
if (btnNormal != null)
{
btnNormal.onClick.AddListener(() =>
{
if (input_DeliveryList != null
) //查询
{
MotionFramework.MotionEngine.GetModule().HandleClick(input_DeliveryList.text);
Normal();
}
else
{
Debug.Log("货物交接单号不匹配或UI组件未正确初始化");
}
});
}
else
{
Debug.LogError("btn_Query UI组件未正确初始化");
}
//过账
if (btnPosting != null)
{
btnPosting.onClick.AddListener(() =>
{
if (input_SupplierSign != null && input_ProjectUnitSign != null && input_SupplierDeliverySign != null)
{
//无身份码
if (RemoveIDcode(MotionEngine.GetModule().ExamName))
{
if (MotionFramework.MotionEngine.GetModule().HandleClick(new List { input_SupplierSign.text, input_ProjectUnitSign.text, input_SupplierDeliverySign.text }))
ResetUI();
} //有身份码
else
{
if (MotionFramework.MotionEngine.GetModule().HandleClick(new List { input_SupplierSign.text, input_ProjectUnitSign.text, input_SupplierDeliverySign.text, ischoosetrue }))
ResetUI();
}
}
else
{
Debug.LogError("eRPDeliveryListMain 或 UI组件未正确初始化");
}
});
}
//电力电缆对应两个身份码
if (MotionEngine.GetModule().ExamName == "电力电缆到货验收入库")
{
int number = GameManager.Instance.marteialnumber * 2;
for (int i = 0; i < materialToggle.Count; i++)
{
if (i >= number)
{
materialToggle[i].gameObject.SetActive(false);
}
else
{
materialToggle[i].gameObject.SetActive(true);
}
}
ChooseToggle.onClick.AddListener(() =>
{
int trues = 1;
for (int i = 0; i < materialToggle.Count; i++)
{
if (materialToggle[i].isOn)
{
trues++;
}
}
if (trues >= GameManager.Instance.marteialnumber)
{
ischoosetrue = "true";
LoadTriggerNextGuide();
}
else
{
ischoosetrue = "false";
}
});
}
else
{
int number = GameManager.Instance.marteialnumber;
for (int i = 0; i < materialToggle.Count; i++)
{
if (i >= number)
{
materialToggle[i].gameObject.SetActive(false);
}
else
{
materialToggle[i].gameObject.SetActive(true);
}
}
ChooseToggle.onClick.AddListener(() =>
{
int trues = 1;
for (int i = 0; i < materialToggle.Count; i++)
{
if (materialToggle[i].isOn)
{
trues++;
}
}
if (trues >= GameManager.Instance.marteialnumber)
{
ischoosetrue = "true";
LoadTriggerNextGuide();
}
else
{
ischoosetrue = "false";
}
});
}
//有身份码
if (!RemoveIDcode(MotionEngine.GetModule().ExamName))
{
IDcarPanel = FindObjectByName("身份码面版");
input_SupplierDeliverySign.onValueChanged.AddListener((s) =>
{
if (input_SupplierDeliverySign.text == "刘一" && IDcarPanel.horizontalNormalizedPosition != 1)
{
IDcarPanel.horizontalNormalizedPosition = 1f;
LoadTriggerNextGuide();
}
});
}
}
bool isnextstoggle = false;
private void Update()
{
if (materialToggle[0].isOn && !isnextstoggle)
{
int clicktoggle = 0;
for (int i = 0; i < materialToggle.Count; i++)
{
if (materialToggle[i].isOn)
{
clicktoggle++;
}
if (clicktoggle >= GameManager.Instance.marteialnumber && !isnextstoggle)
{
LoadTriggerNextGuide();
ChooseToggle.interactable = true;
isnextstoggle = true;
}
}
}
else if (!isnextstoggle)
{
ChooseToggle.interactable = false;
}
}
string ischoosetrue;
///
/// 正常收货
///
public void Normal()
{
for (int i = 0; i < panel_QueryShow.Count; i++)
{
panel_QueryShow[i].gameObject.SetActive(true);
}
CombinedClass combinedClass = GameManager.Instance.combinedClass;
if (combinedClass != null)
{
input_CompanyCode.text = combinedClass.CompanyCode;
input_ActualInspectionDate.text = "2025.03.04";
input_PostingDate.text = "2025.03.04";
input_SupplierName.text = combinedClass.SupplierName;
input_SupplierSignDate.text = combinedClass.SupplierSignatureDate;
input_ProjectUnitSignDate.text = combinedClass.ProjectUnitSignatureDate;
input_SupplierDeliverySignDate.text = combinedClass.SupplierDeliverySignatureDate;
input_ERPDeliveryLists[0].text = MotionEngine.GetModule().GetTaskBookValueByMapping("物料编码");
input_ERPDeliveryLists[1].text = combinedClass.materialName; //物料名称
input_ERPDeliveryLists[2].text = combinedClass.incomeQuantity; //实际到货数量
input_ERPDeliveryLists[3].text = GameManager.Instance.unit; //单位
input_ERPDeliveryLists[4].text = combinedClass.StockLocationCode; //库位
input_ERPDeliveryLists[5].text = combinedClass.goodsTransferNumber; //物料凭证号
input_ERPDeliveryLists[6].text = combinedClass.FactoryCode; //工厂
}
else
{
Debug.LogError("arrivalInspectionForm 未正确初始化");
}
LoadTriggerNextGuide();
}
///
/// 重置界面
///
public void ResetUI()
{
for (int i = 0; i < panel_QueryShow.Count; i++)
{
panel_QueryShow[i].gameObject.SetActive(false);
}
input_CompanyCode.text = "";
input_ActualInspectionDate.text = "";
input_PostingDate.text = "";
input_SupplierName.text = "";
input_SupplierSignDate.text = "";
input_ProjectUnitSignDate.text = "";
input_SupplierDeliverySignDate.text = "";
for (int i = 0; i < input_ERPDeliveryLists.Count; i++)
{
input_ERPDeliveryLists[i].text = "";
}
LoadTriggerNextGuide();
}
///
/// 剔除没有身份码的考试
///
///
public bool RemoveIDcode(string ExamName)
{
if (ExamName == "1KV电缆终端到货验收入库" ||
ExamName == "10KV电缆终端到货验收入库" ||
ExamName == "布电线到货验收入库" ||
ExamName == "低压电流互感器到货验收入库" ||
ExamName == "蝶式绝缘子到货验收入库" ||
ExamName == "高压熔断器到货验收入库" ||
ExamName == "交流盘形悬式瓷绝缘子到货验收入库" ||
ExamName == "接地短路故障指示器到货验收入库" ||
ExamName == "接续金具-接地线夹到货验收入库" ||
ExamName == "联结金具-直角挂板到货验收入库" ||
ExamName == "线路柱式瓷绝缘子到货验收入库")
{
return true;
}
else
{
return false;
}
}
}