XJTaskItem.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using TMPro;
  6. using static LangChaoJiekou;
  7. using Newtonsoft.Json;
  8. public class XJTaskItem : MonoBehaviour
  9. {
  10. public Toggle toggle;
  11. public TMP_Text numText;
  12. public TMP_Text nameText;
  13. public GameObject errorObj;
  14. public GameObject imageBG;
  15. public RoomItem itemData;
  16. public XunJianDetails xjDetails;
  17. private void Start()
  18. {
  19. toggle.onValueChanged.AddListener((b) =>
  20. {
  21. if(b)
  22. {
  23. if (XunJianInitialize.Instance.checkTaskItem != null)
  24. {
  25. XunJianInitialize.Instance.xjDetails.SubmitData();
  26. XunJianInitialize.Instance.checkTaskItem.nameText.color = Color.white;
  27. }
  28. XunJianInitialize.Instance.SetCheckIte(this);
  29. }
  30. });
  31. numText.raycastTarget = false;
  32. nameText.raycastTarget = false;
  33. }
  34. public void InitData(int num, RoomItem data , XunJianDetails xjDetails)
  35. {
  36. this.itemData = data;
  37. this.xjDetails = xjDetails;
  38. numText.text = num.ToString();
  39. nameText.text = data.inspItemName;
  40. if(data.recd ==null)
  41. {
  42. // 未操作过的
  43. errorObj.SetActive(false);
  44. imageBG.SetActive(false);
  45. }
  46. else
  47. {
  48. errorObj.SetActive(data.recd.recordStatus == "0");
  49. imageBG.SetActive(true);
  50. }
  51. }
  52. public void SubmitData(List<string> imageUrl, string state, string memo)
  53. {
  54. string url = JsonConvert.SerializeObject(imageUrl);
  55. Debug.Log("DGJ ===> SubmitData " + url + state + memo);
  56. // Debug.Log("DGJ ===> SubmitData " + JsonConvert.SerializeObject(itemData.recd.recordImgList) + itemData.recd.recordStatus + itemData.recd.recordMemo);
  57. if (itemData.recd == null)
  58. {
  59. itemData.recd = new Record();
  60. itemData.recd.distributeId = XunJianAllData.taskItem.distributeId;
  61. itemData.recd.recordTargetId = XunJianAllData.taskItem.distributeTargetId;
  62. itemData.recd.recordTarget = XunJianAllData.taskItem.distributeTarget;
  63. itemData.recd.recordTargetType = "1";
  64. itemData.recd.inspItemId = itemData.inspItemId;
  65. itemData.recd.inspItemName = itemData.inspItemName;
  66. itemData.recd.recordMemo = null;
  67. itemData.recd.recordStatus = null;
  68. // itemData.recd.recordImg = null;
  69. itemData.recd.recordImgList = null;
  70. }
  71. if(url != JsonConvert.SerializeObject(itemData.recd.recordImgList) ||state!= itemData.recd.recordStatus||memo!= itemData.recd.recordMemo)
  72. {
  73. Debug.Log("DGJ ===> Record ");
  74. // itemData.recd.recordImg = url;
  75. itemData.recd.recordStatus = state;
  76. itemData.recd.recordMemo = memo;
  77. itemData.recd.recordImgList = imageUrl;
  78. LangChaoJiekou.Instance.addRecord(itemData.recd, (b) => {
  79. if (b)
  80. {
  81. Debug.Log("DGJ ===> Record 更新成功");
  82. }
  83. });
  84. // 如果这周
  85. }
  86. }
  87. }