B08_EventListItem.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.createTime;
  37. managerText.text = data.memberNames;
  38. stateText.text = data.exportStatus is null or "" ? "<color=#EF491C>未知</color>" : data.exportStatus;
  39. PlaneDateText.text = $"计划完成日期:{data.planTime}";
  40. CompleteDateText.text = $"实际完成日期:{data.completeTime}";
  41. UseTimeText.text = $"";
  42. LocalText.text = $"";
  43. // UseTimeText.text = $"已用时间:0天02:12:67";
  44. // LocalText.text = $"所属部门:安全部";
  45. more.SetActive(false);
  46. moreButton = ctrlText.GetComponent<Button>();
  47. moreButton.onClick.AddListener(ChangeMoreMessage);
  48. }
  49. public void ChangeMoreMessage()
  50. {
  51. if (moreMessage)
  52. {
  53. ctrlText.text = "详情";
  54. rect.sizeDelta = new Vector2(360,24);
  55. more.SetActive(false);
  56. }
  57. else
  58. {
  59. ctrlText.text = "收起";
  60. rect.sizeDelta = new Vector2(360,72);
  61. more.SetActive(true);
  62. }
  63. moreMessage = !moreMessage;
  64. }
  65. }