394 lines
18 KiB
C#
394 lines
18 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_PowerDistributionSecondWorkTicketPanel : UI_BaseTicket
|
|
{
|
|
protected override void OnClick(string btnName)
|
|
{
|
|
base.OnClick(btnName);
|
|
switch (btnName)
|
|
{
|
|
case "closeBtn":
|
|
GameManager.UIMgr.HidePanel<UI_PowerDistributionSecondWorkTicketPanel>();
|
|
break;
|
|
case "ConfirmBtn":
|
|
if (GameManager.RunModelMgr.SceneType == E_SceneType.Office)
|
|
{
|
|
SaveTicketValue();
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study && !ToolFuncManager.GetChild(transform, "ConfirmBtn_ImageTips").gameObject.activeInHierarchy)
|
|
{
|
|
TipPanel.ShowTip("请完成表格填写!");
|
|
}
|
|
else
|
|
{
|
|
if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, true) == 0)
|
|
{
|
|
ScoreManager.instance.Check(triggerName, null);
|
|
GameManager.UIMgr.HidePanel<UI_PowerDistributionSecondWorkTicketPanel>();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GameManager.UIMgr.HidePanel<UI_PowerDistributionSecondWorkTicketPanel>();
|
|
GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID("办理工作票终结_确定", true);
|
|
}
|
|
break;
|
|
case "NewAddBtn":
|
|
WorkingLineNameOrEquipmentDualName temp = Instantiate(itemUIPrefab, backpack);
|
|
temp.transform.GetChild(0).gameObject.name = "mission_InputField_" + backpack.transform.childCount;
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(backpack);
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(allContent);
|
|
temp.callBack += OnSetUIRect;
|
|
break;
|
|
case "BackBtn":
|
|
GameManager.UIMgr.ShowPanel<UI_SelectWorkTicketPanel>();
|
|
GameManager.UIMgr.HidePanel<UI_PowerDistributionSecondWorkTicketPanel>();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
public override void LoadDefaultValue()//学习模式下填充正确值,并且记录每个空应该填的内容
|
|
{
|
|
bool Mis_Initialized = (MissionMgr.Instance.defaultTicketValues.Count > 0);
|
|
JObject jsonObj = JObject.Parse(MissionMgr.Instance.missionText);
|
|
JObject configurations = (JObject)jsonObj["configurations"];
|
|
foreach (var config in configurations.Properties())
|
|
{
|
|
Transform target = ToolFuncManager.GetChild(transform, config.Name + "_InputField");//找InputField填入默认值
|
|
if (target != null)
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
{
|
|
TMP_InputField input = target.GetComponent<TMP_InputField>();
|
|
input.onSelect.AddListener((str) => {
|
|
input.text = config.Value.ToString();
|
|
input.interactable = false;
|
|
ImageTips tips = ToolFuncManager.FindChildWithComponent<ImageTips>(input.transform);
|
|
if (tips != null) tips.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
InitialDefaultValues(config.Name + "_InputField", config.Value.ToString(), Mis_Initialized);
|
|
}
|
|
}
|
|
|
|
Transform mc = ToolFuncManager.GetChild(transform, "member_count_InputField");
|
|
if (mc != null)
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
{
|
|
TMP_InputField input = mc.GetComponent<TMP_InputField>();
|
|
input.onSelect.AddListener((str) =>
|
|
{
|
|
input.text = MissionMgr.Instance.mission.configurations.member.Split(missionSplitChar).Length.ToString();
|
|
input.interactable = false;
|
|
ImageTips tips = ToolFuncManager.FindChildWithComponent<ImageTips>(input.transform);
|
|
if (tips != null) tips.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
InitialDefaultValues("member_count_InputField", MissionMgr.Instance.mission.configurations.member.Split(missionSplitChar).Length.ToString(), Mis_Initialized);
|
|
}
|
|
|
|
Transform targetTrigger = ToolFuncManager.GetChild(transform, "mission_InputField_1");
|
|
if (targetTrigger != null)
|
|
{
|
|
targetTrigger.GetComponent<TMP_InputField>().onSelect.AddListener((str) =>
|
|
{
|
|
List<string> list = new List<string>(MissionMgr.Instance.mission.configurations.mission.Split(missionSplitChar));
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
{
|
|
Transform target = ToolFuncManager.GetChild(transform, "mission_InputField_" + (i + 1));
|
|
if (target == null)
|
|
{
|
|
OnClick("NewAddBtn");
|
|
target = ToolFuncManager.GetChild(transform, "mission_InputField_" + (i + 1));
|
|
}
|
|
TMP_InputField input = target.GetComponent<TMP_InputField>();
|
|
input.text = list[i];
|
|
input.interactable = false;
|
|
Transform targetDev = ToolFuncManager.GetChild(target, " targetDevice_InputField");
|
|
if (targetDev != null)
|
|
{
|
|
TMP_InputField inputDev = targetDev.GetComponent<TMP_InputField>();
|
|
string devInfo = MissionMgr.Instance.mission.configurations.line
|
|
+ MissionMgr.Instance.mission.configurations.station + MissionMgr.Instance.mission.configurations.userName;
|
|
inputDev.text = devInfo;
|
|
inputDev.interactable = false;
|
|
}
|
|
}
|
|
InitialDefaultValues("mission_InputField_" + (i + 1), list[i], Mis_Initialized);
|
|
}
|
|
ImageTips tips = ToolFuncManager.FindChildWithComponent<ImageTips>(targetTrigger.transform);
|
|
if (tips != null) tips.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
|
|
//DateTime start_dt = DateTime.Parse(MissionMgr.Instance.mission.configurations.startdate);
|
|
//DateTime end_dt = DateTime.Parse(MissionMgr.Instance.mission.configurations.enddate);
|
|
|
|
//SetDateTimeField(transform, "startdate", start_dt, Mis_Initialized);//开始日期
|
|
//SetDateTimeField(transform, "enddate", end_dt, Mis_Initialized);//结束日期
|
|
|
|
Transform elc_drop = ToolFuncManager.GetChild(transform, "hasElectric_Dropdown");//是否需要电
|
|
if (elc_drop != null)
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
{
|
|
Transform btn_stu = ToolFuncManager.GetChild(elc_drop, "Study_Button");
|
|
if (btn_stu != null)
|
|
{
|
|
ImageTips tips = ToolFuncManager.FindChildWithComponent<ImageTips>(elc_drop.transform);
|
|
|
|
btn_stu.gameObject.SetActive(true);
|
|
ToolFuncManager.ActiveEmbededTip(tips.gameObject);
|
|
btn_stu.GetComponent<Button>().onClick.AddListener(() => {
|
|
TMP_Dropdown input = elc_drop.GetComponent<TMP_Dropdown>();
|
|
input.value = MissionMgr.Instance.mission.configurations.hasElectric == "停电" ? 0 : 1;
|
|
|
|
if (tips != null) tips.gameObject.SetActive(false);
|
|
btn_stu.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
}
|
|
|
|
InitialDefaultValues("hasElectric_Dropdown", MissionMgr.Instance.mission.configurations.hasElectric, Mis_Initialized);
|
|
}
|
|
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
{
|
|
Transform AutoToggles_Button = ToolFuncManager.GetChild(transform, "AutoToggles_Button");
|
|
AutoToggles_Button.gameObject.SetActive(true);
|
|
|
|
AutoToggles_Button.GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
for (int i = 0; i < workTickeContent.transform.childCount; i++)
|
|
{
|
|
Transform child = workTickeContent.transform.GetChild(i);
|
|
if (child != null)
|
|
{
|
|
TMP_Text text = ToolFuncManager.FindChildWithComponent<TMP_Text>(child);
|
|
if (text != null)
|
|
{
|
|
if (MissionMgr.Instance.mission.workTicketLabelsSelect.Contains(text.text))
|
|
{
|
|
Toggle toggle = ToolFuncManager.FindChildWithComponent<Toggle>(child);
|
|
if (toggle != null)
|
|
{
|
|
toggle.isOn = true;
|
|
toggle.interactable = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
CheckAllToggle();//点亮全选那个按钮
|
|
allToggle.interactable = false;
|
|
AutoToggles_Button.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
|
|
string req = "";
|
|
foreach (var item in MissionMgr.Instance.mission.workTicketLabelsSelect)
|
|
{
|
|
req += (item + "&");
|
|
}
|
|
InitialDefaultValues("workTicketLabelsSelect", req, Mis_Initialized);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载低压工作票内容,用于完成操作后的最后加载;学习模式加载默认数据,其他模式加载已保存的数据
|
|
/// </summary>
|
|
public override void LoadTicketValue()
|
|
{
|
|
if ((GameManager.MissionMgr.selectedTicketValues != null && GameManager.MissionMgr.selectedTicketValues.Count > 0) && GameManager.MissionMgr.selectedWorkTicketType != workTicketType)
|
|
return;
|
|
//加载默认数据
|
|
if (NeedLoadTicketDefaultValue())
|
|
{
|
|
bool Mis_Initialized = (MissionMgr.Instance.defaultTicketValues.Count > 0);
|
|
JObject jsonObj = JObject.Parse(MissionMgr.Instance.missionText);
|
|
JObject configurations = (JObject)jsonObj["configurations"];
|
|
foreach (var config in configurations.Properties())
|
|
{
|
|
Transform target = ToolFuncManager.GetChild(transform, config.Name + "_InputField");//找InputField填入默认值
|
|
if (target != null)
|
|
{
|
|
TMP_InputField input = target.GetComponent<TMP_InputField>();
|
|
input.text = config.Value.ToString();
|
|
input.interactable = false;
|
|
}
|
|
}
|
|
Transform mc = ToolFuncManager.GetChild(transform, "member_count_InputField");
|
|
if (mc != null)
|
|
{
|
|
TMP_InputField input = mc.GetComponent<TMP_InputField>();
|
|
input.text = MissionMgr.Instance.mission.configurations.member.Split(missionSplitChar).Length.ToString();
|
|
input.interactable = false;
|
|
}
|
|
Transform targetTrigger = ToolFuncManager.GetChild(transform, "mission_InputField_1");
|
|
if (targetTrigger != null)
|
|
{
|
|
List<string> list = new List<string>(MissionMgr.Instance.mission.configurations.mission.Split(missionSplitChar));
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
Transform target = ToolFuncManager.GetChild(transform, "mission_InputField_" + (i + 1));
|
|
if (target == null)
|
|
{
|
|
OnClick("NewAddBtn");
|
|
target = ToolFuncManager.GetChild(transform, "mission_InputField_" + (i + 1));
|
|
}
|
|
TMP_InputField input = target.GetComponent<TMP_InputField>();
|
|
input.text = list[i];
|
|
input.interactable = false;
|
|
}
|
|
|
|
GetControl<Button>("NewAddBtn").interactable = false;
|
|
}
|
|
|
|
Transform elc_drop = ToolFuncManager.GetChild(transform, "hasElectric_Dropdown");//是否需要电
|
|
if (elc_drop != null)
|
|
{
|
|
TMP_Dropdown input = elc_drop.GetComponent<TMP_Dropdown>();
|
|
input.value = MissionMgr.Instance.mission.configurations.hasElectric == "停电" ? 0 : 1;
|
|
input.interactable = false;
|
|
}
|
|
|
|
for (int i = 0; i < workTickeContent.transform.childCount; i++)
|
|
{
|
|
Transform child = workTickeContent.transform.GetChild(i);
|
|
if (child != null)
|
|
{
|
|
TMP_Text text = ToolFuncManager.FindChildWithComponent<TMP_Text>(child);
|
|
if (text != null)
|
|
{
|
|
if (MissionMgr.Instance.mission.workTicketLabelsSelect.Contains(text.text))
|
|
{
|
|
Toggle toggle = ToolFuncManager.FindChildWithComponent<Toggle>(child);
|
|
if (toggle != null)
|
|
{
|
|
toggle.isOn = true;
|
|
toggle.interactable = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
CheckAllToggle();//点亮全选那个按钮
|
|
allToggle.interactable = false;
|
|
|
|
|
|
}
|
|
else//学习模式加载默认数据
|
|
{
|
|
base.LoadTicketValue();
|
|
|
|
int num = 0;
|
|
while (true)
|
|
{
|
|
num++;
|
|
if (MissionMgr.Instance.selectedTicketValues.ContainsKey("mission_InputField_" + num))
|
|
{
|
|
Transform target = ToolFuncManager.GetChild(transform, "mission_InputField_" + num);
|
|
if (target == null)
|
|
{
|
|
OnClick("NewAddBtn");
|
|
target = ToolFuncManager.GetChild(transform, "mission_InputField_" + num);
|
|
}
|
|
List<string> infos = new List<string>(MissionMgr.Instance.selectedTicketValues["mission_InputField_" + num].Split('$'));
|
|
TMP_InputField input = target.GetComponent<TMP_InputField>();
|
|
input.text = infos[1];
|
|
|
|
Transform tra = ToolFuncManager.GetChild(input.transform, "targetDevice_InputField");
|
|
if (tra != null && input != null)
|
|
{
|
|
TMP_InputField tD_if = tra.GetComponentInChildren<TMP_InputField>();
|
|
tD_if.text = infos[0];
|
|
}
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
|
|
if (MissionMgr.Instance.selectedTicketValues.ContainsKey("workTicketLabelsSelect"))
|
|
{
|
|
List<string> selectedicon = new List<string>(MissionMgr.Instance.selectedTicketValues["workTicketLabelsSelect"].Split('&'));
|
|
for (int i = 0; i < workTickeContent.transform.childCount; i++)
|
|
{
|
|
Transform child = workTickeContent.transform.GetChild(i);
|
|
if (child != null)
|
|
{
|
|
TMP_Text text = ToolFuncManager.FindChildWithComponent<TMP_Text>(child);
|
|
if (text != null)
|
|
{
|
|
if (selectedicon.Contains(text.text))
|
|
{
|
|
Toggle toggle = ToolFuncManager.FindChildWithComponent<Toggle>(child);
|
|
if (toggle != null)
|
|
{
|
|
toggle.isOn = true;
|
|
toggle.onValueChanged.AddListener(delegate { CheckAllToggle(); });
|
|
//toggle.interactable = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//allToggle.interactable = false;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void SaveTicketValue()
|
|
{
|
|
base.SaveTicketValue();
|
|
|
|
for (int i = 0; i < backpack.transform.childCount; i++)//保存安全措施和注意事项
|
|
{
|
|
GameObject obj = backpack.transform.GetChild(i).gameObject;
|
|
if (obj != null)
|
|
{
|
|
TMP_InputField t_if = obj.GetComponentInChildren<TMP_InputField>();
|
|
Transform tra = ToolFuncManager.GetChild(t_if.transform, "targetDevice_InputField");
|
|
if (tra != null && t_if != null)
|
|
{
|
|
TMP_InputField tD_if = tra.GetComponentInChildren<TMP_InputField>();
|
|
string tif_text = t_if.text;
|
|
string tDif_text = tD_if.text;
|
|
if (t_if.text != "" || tD_if.text != "")
|
|
{
|
|
if (t_if.gameObject.name.StartsWith("mission_InputField_"))
|
|
{
|
|
//if (MissionMgr.Instance.selectedTicketValues.ContainsKey(t_if.gameObject.name) == false)
|
|
MissionMgr.Instance.selectedTicketValues.Add(t_if.gameObject.name, tD_if.text + "$" + t_if.text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
string req = "";
|
|
for (int i = 0; i < workTickeRequstContent.transform.childCount; i++)//保存其他安全措施和注意事项
|
|
{
|
|
Transform child = workTickeRequstContent.transform.GetChild(i);
|
|
if (child != null)
|
|
{
|
|
TMP_Text text = ToolFuncManager.FindChildWithComponent<TMP_Text>(child);
|
|
if (text != null)
|
|
req += (text.text + "&");
|
|
}
|
|
}
|
|
MissionMgr.Instance.selectedTicketValues.Add("workTicketLabelsSelect", req);
|
|
Debug.Log("保存工作票");
|
|
}
|
|
}
|