123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- using static LangChaoJiekou;
- using Newtonsoft.Json;
- public class XJTaskItem : MonoBehaviour
- {
- public Toggle toggle;
- public TMP_Text numText;
- public TMP_Text nameText;
- public GameObject errorObj;
- public GameObject imageBG;
- public RoomItem itemData;
- public XunJianDetails xjDetails;
-
- private void Start()
- {
- toggle.onValueChanged.AddListener((b) =>
- {
- if(b)
- {
- if (XunJianInitialize.Instance.checkTaskItem != null)
- {
- XunJianInitialize.Instance.xjDetails.SubmitData();
- XunJianInitialize.Instance.checkTaskItem.nameText.color = Color.white;
- }
- XunJianInitialize.Instance.SetCheckIte(this);
- }
- });
- numText.raycastTarget = false;
- nameText.raycastTarget = false;
- }
- public void InitData(int num, RoomItem data , XunJianDetails xjDetails)
- {
- this.itemData = data;
- this.xjDetails = xjDetails;
- numText.text = num.ToString();
- nameText.text = data.inspItemName;
- if(data.recd ==null)
- {
- // 未操作过的
- errorObj.SetActive(false);
- imageBG.SetActive(false);
- }
- else
- {
- errorObj.SetActive(data.recd.recordStatus == "0");
- imageBG.SetActive(true);
- }
- }
- public void SubmitData(List<string> imageUrl, string state, string memo)
- {
- string url = JsonConvert.SerializeObject(imageUrl);
- Debug.Log("DGJ ===> SubmitData " + url + state + memo);
- // Debug.Log("DGJ ===> SubmitData " + JsonConvert.SerializeObject(itemData.recd.recordImgList) + itemData.recd.recordStatus + itemData.recd.recordMemo);
- if (itemData.recd == null)
- {
- itemData.recd = new Record();
- itemData.recd.distributeId = XunJianAllData.taskItem.distributeId;
- itemData.recd.recordTargetId = XunJianAllData.taskItem.distributeTargetId;
- itemData.recd.recordTarget = XunJianAllData.taskItem.distributeTarget;
- itemData.recd.recordTargetType = "1";
- itemData.recd.inspItemId = itemData.inspItemId;
- itemData.recd.inspItemName = itemData.inspItemName;
- itemData.recd.recordMemo = null;
- itemData.recd.recordStatus = null;
- // itemData.recd.recordImg = null;
- itemData.recd.recordImgList = null;
- }
- if(url != JsonConvert.SerializeObject(itemData.recd.recordImgList) ||state!= itemData.recd.recordStatus||memo!= itemData.recd.recordMemo)
- {
- Debug.Log("DGJ ===> Record ");
- // itemData.recd.recordImg = url;
- itemData.recd.recordStatus = state;
- itemData.recd.recordMemo = memo;
- itemData.recd.recordImgList = imageUrl;
- LangChaoJiekou.Instance.addRecord(itemData.recd, (b) => {
- if (b)
- {
- Debug.Log("DGJ ===> Record 更新成功");
- }
- });
- // 如果这周
- }
- }
- }
|