Tz2/Assets/Zion/Scripts/配送/AddAnswerSheet.cs

195 lines
7.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 DefaultNamespace;
using DefaultNamespace.ProcessMode;
using Framework.Manager;
using MotionFramework;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AddAnswerSheet : MonoBehaviour
{
public Button btnAddAnswer;
public Button btnDelete;
public Button btnSave;
public GameObject answerContent;
public List<GameObject> answerContents = new List<GameObject>();
public List<string> answers = new List<string>();
/// <summary>
/// 题目标题
/// </summary>
public List<TextMeshProUGUI> Titletopic = new List<TextMeshProUGUI>();
private Framework.Dto.InventoryReversalVoucherAnalyzer inventoryReversalVoucherAnalyzer;
public Button closeButton;
public TMP_InputField[] pici;
public TMP_InputField[] jine;
public TMP_InputField[] jisuanguocheng;
public TMP_InputField zongjiner;
// Start is called before the first frame update
void Start()
{
inventoryReversalVoucherAnalyzer = (Framework.Dto.InventoryReversalVoucherAnalyzer)MotionEngine.GetModule<GlobalDataStorage>().materialTaskObj;
if (btnAddAnswer)
{
btnAddAnswer.onClick.AddListener(AddAnswerContent);
btnDelete.onClick.AddListener(DeleteAnswerContent);
btnSave.onClick.AddListener(SaveAnswerContent);
}
closeButton.onClick.AddListener(delegate
{
TutorialGuideManager.Instance.HideGuide();
});
}
bool isint = false;
private void AddAnswerContent()
{
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("ELP应用") && !isint)
{
TutorialGuideManager.Instance.TriggerNextGuide();
isint = true;
}
var newContent = Instantiate(answerContent) as GameObject;
if (newContent)
{
newContent.SetActive(true);
newContent.transform.parent = answerContent.transform.parent;
newContent.transform.localScale = Vector3.one;
newContent.transform.SetSiblingIndex(answerContents.Count);
answerContents.Add(newContent);
// if (MotionEngine.GetModule<GlobalDataStorage>().ExamName == "违约索赔")
// {
// if (answerContents.Count < 3)
// {
// newContent.transform.GetChild(2).gameObject.SetActive(false);
// }
// }
if (btnDelete)
{
btnDelete.gameObject.SetActive(true);
}
if (newContent.transform.GetChild(0).GetComponentInChildren<TextMeshProUGUI>())
{
newContent.transform.GetChild(0).GetComponentInChildren<TextMeshProUGUI>(true).text = answerContents.Count.ToString();
}
answerContent.SetActive(false);
//修改item中输入框的名称为了与框架流程中输入的名称匹配
for (int i = 0; i < answerContents.Count; i++)
{
for (int j = 0; j < Titletopic.Count; j++)
{
answerContents[i].transform.GetChild(j).name = Titletopic[j].text; //获取i中的子物体数量j等于Titletopic标题的数量
}
}
}
}
private void DeleteAnswerContent()
{
if (answerContents.Count > 0)
{
GameObject tempObj = answerContents[answerContents.Count - 1];
answerContents.RemoveAt(answerContents.Count - 1);
DestroyImmediate(tempObj);
if (answerContents.Count <= 0)
{
btnDelete.gameObject.SetActive(false);
}
}
}
private void SaveAnswerContent()
{
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("ELP应用") && btnSave.name!= "btn_保存2")
{
TutorialGuideManager.Instance.TriggerNextGuide();
}
answers.Clear();
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName == "违约索赔")
{
for (int i = 0; i < pici.Length; i++)
{
answers.Add(pici[i].text);
answers.Add(jine[i].text);
// answers.Add(jisuanguocheng[i].text);
}
answers.Add(zongjiner.text);
//
//
// for (int i = 0; i < answerContents.Count; i++)
// {
// answers.Add(answerContents[i].transform.GetChild(0).GetComponent<TMP_InputField>().text);
// answers.Add(answerContents[i].transform.GetChild(1).GetComponent<TMP_InputField>().text);
// answers.Add(answerContents[i].transform.GetChild(2).GetComponent<TMP_InputField>().text);
// if (i < 2)
// {
// answers.Add(answerContents[i].transform.GetChild(0).GetComponent<TMP_InputField>().text);
// answers.Add(answerContents[i].transform.GetChild(1).GetComponent<TMP_InputField>().text);
// }
// else
// {
// answers.Add(answerContents[i].transform.GetChild(0).GetComponent<TMP_InputField>().text);
// answers.Add(answerContents[i].transform.GetChild(1).GetComponent<TMP_InputField>().text);
// answers.Add(answerContents[i].transform.GetChild(2).GetComponent<TMP_InputField>().text);
// }
// }
}
else
{
for (int i = 0; i < answerContents.Count; i++)
{
for (int j = 0; j < Titletopic.Count; j++)
{
if (answerContents[i].transform.GetChild(j).GetComponent<TMP_InputField>() != null)
{
if (!answers.Contains(answerContents[i].transform.GetChild(j).GetComponent<TMP_InputField>().text) && !string.IsNullOrEmpty(answerContents[i].transform.GetChild(j).GetComponent<TMP_InputField>().text))
{
answers.Add(answerContents[i].transform.GetChild(j).GetComponent<TMP_InputField>().text);
}
}
else if (answerContents[i].transform.GetChild(j).GetComponent<Toggle>() != null)
{
if (GameLauncher.Instance.examName.Contains("ELP应用") && inventoryReversalVoucherAnalyzer.formselection == "无资质" && answerContents[i].transform.GetChild(j).parent.name != "ELP页面1(Clone)")
{
if (answerContents[i].transform.GetChild(j).name == "True" && answerContents[i].transform.GetChild(j).GetComponent<Toggle>().isOn == false)
{
answers.Add("true");
}
}
else
{
answers.Add(answerContents[i].transform.GetChild(j).GetComponent<Toggle>().isOn.ToString().ToLower());
}
}
}
}
}
bool istrue = MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(answers);
Debug.Log(istrue);
}
public void NextGuide()
{
TutorialGuideManager.Instance.TriggerNextGuide();
}
// Update is called once per frame
void Update()
{
}
}