B08_EventListItem.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class B08_EventListItem : MonoBehaviour
  6. {
  7. public B08_TaskData data;
  8. public Text nameText;
  9. public Text dateText;
  10. public Text managerText;
  11. public Text stateText;
  12. public Text ctrlText;
  13. public GameObject more;
  14. public Text PlaneDateText;
  15. public Text CompleteDateText;
  16. public Text UseTimeText;
  17. public Text LocalText;
  18. public Button moreButton;
  19. public bool moreMessage = false;
  20. public RectTransform rect;
  21. public void Init(B08_TaskData _data)
  22. {
  23. data = _data;
  24. rect = this.GetComponent<RectTransform>();
  25. nameText = this.transform.Find("name").GetComponent<Text>();
  26. dateText = this.transform.Find("date").GetComponent<Text>();
  27. managerText = this.transform.Find("principal").GetComponent<Text>();
  28. stateText = this.transform.Find("state").GetComponent<Text>();
  29. ctrlText = this.transform.Find("ctrl").GetComponent<Text>();
  30. more = this.transform.Find("more").gameObject;
  31. PlaneDateText = more.transform.Find("PlaneDate").GetComponent<Text>();
  32. CompleteDateText = more.transform.Find("CompleteDate").GetComponent<Text>();
  33. UseTimeText = more.transform.Find("UseTime").GetComponent<Text>();
  34. LocalText = more.transform.Find("Local").GetComponent<Text>();
  35. nameText.text = data.title;
  36. dateText.text = data.updateTime;
  37. managerText.text = data.transactorName;
  38. if (data.projectStatus==null||data.projectStatus.Equals(""))
  39. {
  40. stateText.text = "<color=#EF491C>未知</color>";
  41. }
  42. else
  43. {
  44. stateText.text = data.projectStatus;
  45. }
  46. PlaneDateText.text = $"计划完成日期:2024/03/16";
  47. CompleteDateText.text = $"实际完成日期:2024/03/16";
  48. UseTimeText.text = $"已用时间:0天02:12:67";
  49. LocalText.text = $"所属部门:安全部";
  50. more.SetActive(false);
  51. moreButton = ctrlText.GetComponent<Button>();
  52. moreButton.onClick.AddListener(ChangeMoreMessage);
  53. }
  54. public void ChangeMoreMessage()
  55. {
  56. if (moreMessage)
  57. {
  58. ctrlText.text = "详情";
  59. rect.sizeDelta = new Vector2(360,24);
  60. more.SetActive(false);
  61. }
  62. else
  63. {
  64. ctrlText.text = "收起";
  65. rect.sizeDelta = new Vector2(360,72);
  66. more.SetActive(true);
  67. }
  68. moreMessage = !moreMessage;
  69. }
  70. }