131 lines
3.8 KiB
C#
131 lines
3.8 KiB
C#
using Components;
|
||
using JData;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author YangHua
|
||
//@create 20230914
|
||
//@company Adam
|
||
//
|
||
//@description:工作卡控制器
|
||
//============================================================
|
||
namespace Adam
|
||
{
|
||
public class JobCardController : MonoBehaviour
|
||
{
|
||
public string nameAndAdressUrl;
|
||
public string aqcsAndFxdfxUrl;
|
||
public InputField[] userIDs;
|
||
public InputField[] userNames;
|
||
public InputField[] workSpace;
|
||
|
||
public InputField[] aqcss;
|
||
public InputField[] fxdfx;
|
||
|
||
public GameObject jobCardPanel;
|
||
public GameObject jobChoiceQuestionPanel;
|
||
public OptionItem optionItemPrefab;
|
||
public Transform optionItemContent;
|
||
/// <summary>
|
||
/// 风险点分析
|
||
/// </summary>
|
||
public Button RiskPointAnalysisBtn;
|
||
/// <summary>
|
||
/// 安全措施
|
||
/// </summary>
|
||
public Button SafetyMeasuresBtn;
|
||
// Use this for initialization
|
||
private void Start()
|
||
{
|
||
for (int i = 0; i < userIDs.Length; i++)
|
||
{
|
||
int index = i;
|
||
userIDs[index].onSubmit.AddListener((string numb) =>
|
||
{
|
||
GetValue(numb, index);
|
||
});
|
||
}
|
||
RiskPointAnalysisBtn.onClick.AddListener(() =>
|
||
{
|
||
OnClick(0);
|
||
});
|
||
SafetyMeasuresBtn.onClick.AddListener(() =>
|
||
{
|
||
OnClick(1);
|
||
});
|
||
jobCardPanel.SetActive(false);
|
||
jobChoiceQuestionPanel.SetActive(false);
|
||
}
|
||
|
||
public async void GetValue(string numb, int _index)
|
||
{
|
||
Debug.Log(numb);
|
||
string _url = nameAndAdressUrl + numb;
|
||
JobCardData jData = await AsyncWebReq.Get<JobCardData>(_url);
|
||
userNames[_index].text = jData.data.name;
|
||
workSpace[_index].text = jData.data.adress;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 0- 风险点,1-安全措施
|
||
/// </summary>
|
||
/// <param name="index"></param>
|
||
public void OnClick(int index)
|
||
{
|
||
jobChoiceQuestionPanel.SetActive(true);
|
||
if (index == 0)
|
||
{
|
||
GetAQCSandFXDFX("FXDFX");
|
||
}
|
||
else if (index == 1)
|
||
{
|
||
GetAQCSandFXDFX("AQCS");
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
private async void GetAQCSandFXDFX(string name)
|
||
{
|
||
if (optionItemContent.childCount > 0)
|
||
{
|
||
for (int i = 0; i < optionItemContent.childCount; i++)
|
||
{
|
||
Destroy(optionItemContent.GetChild(i).gameObject);
|
||
}
|
||
}
|
||
AQCSandFXDFX af = await AsyncWebReq.Get<AQCSandFXDFX>(aqcsAndFxdfxUrl + name);
|
||
for (int i = 0; i < af.data.Length; i++)
|
||
{
|
||
int index = i;
|
||
string infoTemp = af.data[index];
|
||
OptionItem optionItemTemp = Instantiate(optionItemPrefab, optionItemContent);
|
||
optionItemTemp.SetValue(index.ToString(), infoTemp);
|
||
optionItemTemp.selfBtn.onClick.AddListener(() =>
|
||
{
|
||
OnOptionItemClick(index, infoTemp, name);
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
private void OnOptionItemClick(int index, string info,string name)
|
||
{
|
||
if (name == "FXDFX")
|
||
{
|
||
fxdfx[index].text = info;
|
||
}
|
||
else if (name == "AQCS")
|
||
{
|
||
aqcss[index].text = info;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|