using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using static UnityEngine.LightProbeProxyVolume;

public class Stepfourpanl : MonoBehaviour
{
    /// <summary>
    /// 初始化面板
    /// </summary>
    public RectTransform stepfourpanl;
    /// <summary>
    /// 页面1
    /// </summary>
    public RectTransform stepfourpanl1;
    /// <summary>
    /// 复制的工单号
    /// </summary>
    public InputField workorderinput;
    /// <summary>
    /// 工单确认按钮
    /// </summary>
    public Button workorderbutton4;
    /// <summary>
    /// 页面2
    /// </summary>
    public RectTransform stepfourpanl2;
    /// <summary>
    /// 输入id
    /// </summary>
    public InputField inputid;
    /// <summary>
    /// 查询按钮
    /// </summary>
    public Button buttoninquire;
    /// <summary>
    /// 选择按钮
    /// </summary>
    public Toggle selecttoggle;
    /// <summary>
    /// 图片显示
    /// </summary>
    public Image select2;
    /// <summary>
    /// 合同违约按钮
    /// </summary>
    public Button breakbutton;
    /// <summary>
    /// 签收按钮
    /// </summary>
    public Button signforbutton4;
    /// <summary>
    /// 签收成功图片
    /// </summary>
    public Image tipsiamge;
    /// <summary>
    /// 页面3
    /// </summary>
    public RectTransform stepfourpanl3;
    /// <summary>
    /// 退补按钮
    /// </summary>
    public Button refundbutton;
    /// <summary>
    /// 页面4
    /// </summary>
    public RectTransform stepfourpanl4;
    /// <summary>
    /// 选择的选项
    /// </summary>
    public Dropdown dropdownprice;
    /// <summary>
    /// 新增按钮
    /// </summary>
    public Button newbutton;
    /// <summary>
    /// 提示选择图片
    /// </summary>
    public Image promptpicture;
    /// <summary>
    /// 页面5
    /// </summary>
    public RectTransform stepfourpanl5;
    /// <summary>
    /// 选择日期按钮
    /// </summary>
    public Button databutton3;
    /// <summary>
    /// 页面6
    /// </summary>
    public RectTransform stepfourpanl6;
    /// <summary>
    /// 输入日期的初始时间
    /// </summary>
    public InputField inputdata1;
    /// <summary>
    /// 输入日期结束时间
    /// </summary>
    public InputField inputdata2;
    /// <summary>
    /// 查询按钮
    /// </summary>
    public Button inquirebutton6;
    // 定义日期格式，可以根据需要添加更多格式
    private string[] dateFormats = new string[] { "yyyy-MM-dd", "dd/MM/yyyy", "MM/dd/yyyy" };
    /// <summary>
    /// 页面7
    /// </summary>
    public RectTransform stepfourpanl7;
    /// <summary>
    /// 显示的文本
    /// </summary>
    public Text revealtext1, revealtext2, revealtext3, revealtext4;
    /// <summary>
    /// 勾选选择显示
    /// </summary>
    public Toggle selecttoggle3;
    /// <summary>
    /// 显示勾选图片
    /// </summary>
    public Image select6;
    /// <summary>
    /// 确认按钮
    /// </summary>
    public Button verifybutton6;
    /// <summary>
    /// 页面8
    /// </summary>
    public RectTransform stepfourpanl8;
    /// <summary>
    /// 查询的按钮
    /// </summary>
    public Button inquirebutton7;
    /// <summary>
    /// 页面9
    /// </summary>
    public RectTransform stepfourpanl9;
    /// <summary>
    /// 勾线显示
    /// </summary>
    public Toggle checktoggle2;
    /// <summary>
    /// 图片显示
    /// </summary>
    public Image check2;
    /// <summary>
    /// 确认按钮
    /// </summary>
    public Button verifybutton8;
    /// <summary>
    /// 页面10
    /// </summary>
    public RectTransform stepfourpanl10;
    /// <summary>
    /// 保存按钮
    /// </summary>
    public Button savebutton4;
    /// <summary>
    /// 页面11
    /// </summary>
    public RectTransform stepfourpanl11;
    /// <summary>
    /// 输入电费的倍数
    /// </summary>
    public InputField electricityinput;
    /// <summary>
    /// 保存按钮
    /// </summary>
    public Button savebutton8;
    /// <summary>
    /// 显示保存的图片
    /// </summary>
    public Image saveimage6;
    /// <summary>
    /// 发送按钮
    /// </summary>
    public Button sendbutton6;
    void Start()
    {
        workorderbutton4.onClick.AddListener(() =>
        {
            stepfourpanl1.gameObject.SetActive(false);
            stepfourpanl2.gameObject.SetActive(true);
        });
        selecttoggle.onValueChanged.AddListener((ison) =>
        {
            if (ison)
            {
                select2.gameObject.SetActive(true);
            }
            else
            {
                select2.gameObject.SetActive(false);
            }
        });
        breakbutton.onClick.AddListener(() =>
        {
            stepfourpanl2.gameObject.SetActive(false);
            stepfourpanl3.gameObject.SetActive(true);
        });
        signforbutton4.onClick.AddListener(() =>
        {
            tipsiamge.gameObject.SetActive(true);
            Invoke("Getreveal", 1.5f);
        });
        refundbutton.onClick.AddListener(() =>
        {
            stepfourpanl3.gameObject.SetActive(false);
            stepfourpanl4.gameObject.SetActive(true);   
        });
        newbutton.onClick.AddListener(() =>
        {
            if (dropdownprice.captionText.text=="价格表")
            {
                stepfourpanl4.gameObject.SetActive(false);
                stepfourpanl5.gameObject.SetActive(true);
            }
            else
            {
                promptpicture.gameObject.SetActive(true);
                Invoke("Getreveal2", 1.5f);
            }
        });
        databutton3.onClick.AddListener(() =>
        {
            stepfourpanl5.gameObject.SetActive(false);
            stepfourpanl6.gameObject.SetActive(true);
        });
        inquirebutton6.onClick.AddListener(Comparedata);
        selecttoggle3.onValueChanged.AddListener(delegate
        {
            Getpicture(selecttoggle3);
        });
        verifybutton6.onClick.AddListener(() =>
        {
            stepfourpanl7.gameObject.SetActive(false);
            stepfourpanl8.gameObject.SetActive(true);
        });
        inquirebutton7.onClick.AddListener(() =>
        {
            stepfourpanl8.gameObject.SetActive(false);
            stepfourpanl9.gameObject.SetActive(true);
        });
        checktoggle2.onValueChanged.AddListener(delegate
        {
            Getpicture2(checktoggle2);
        });
        verifybutton8.onClick.AddListener(() =>
        {
            stepfourpanl9.gameObject.SetActive(false);
            stepfourpanl10.gameObject.SetActive(true);
        });
        savebutton4.onClick.AddListener(() =>
        {
            stepfourpanl10.gameObject.SetActive(false);
            stepfourpanl11.gameObject.SetActive(true);
        });
        savebutton8.onClick.AddListener(() =>
        {
            if (electricityinput.text.Length>0)
            {
                saveimage6.gameObject.SetActive(true);
                Invoke("Getpicture3", 1.5f);
            }
        });
        sendbutton6.onClick.AddListener(() =>
        {
            stepfourpanl11.gameObject.SetActive(false);
        });
    }
    /// <summary>
    /// 消失保存图片
    /// </summary>
    private void Getpicture3()
    {
        saveimage6.gameObject.SetActive(false);
    }

    /// <summary>
    /// 显示对应图片
    /// </summary>
    /// <param name="toggle"></param>
    private void Getpicture2(Toggle toggle)
    {
        if (toggle.isOn)
        {
            check2.gameObject.SetActive(true);
        }
        else
        {
            check2.gameObject.SetActive(false);
        }
    }

    /// <summary>
    /// 比较两个日期的大小
    /// </summary>
    private void Comparedata()
    {
        DateTime datevalue1;
        DateTime datevalue2;
        if (DateTime.TryParseExact(inputdata1.text, dateFormats, null, System.Globalization.DateTimeStyles.None, out datevalue1)&&
            DateTime.TryParseExact(inputdata2.text, dateFormats, null, System.Globalization.DateTimeStyles.None, out datevalue2))
        {
            if (DateTime.Compare(DateTime.Parse(inputdata1.text),DateTime.Parse(inputdata2.text)) <0)
            {
                stepfourpanl6.gameObject.SetActive(false);
                revealtext1.text = inputdata1.text;
                revealtext2.text = inputdata2.text;
                revealtext3.text = inputdata1.text;
                revealtext4.text = inputdata2.text;
                stepfourpanl7.gameObject.SetActive(true);
            }
        }
    }

    /// <summary>
    /// 关闭提示
    /// </summary>
    private void Getreveal2()
    {
        promptpicture.gameObject.SetActive(false);
    }

    /// <summary>
    /// 关闭提示
    /// </summary>
    private void Getreveal()
    {
        tipsiamge.gameObject.SetActive(false);
    }

    /// <summary>
    /// 初始化显示面板方法
    /// </summary>
    public void Getinception(bool bol)
    {
        stepfourpanl.gameObject.SetActive(bol);
    }
    /// <summary>
    /// 显示的勾选图片
    /// </summary>
    public void Getpicture(Toggle toggle)
    {
        if (toggle.isOn)
        {
            select6.gameObject.SetActive(true);
        }
        else
        {
            select6.gameObject.SetActive(false);
        }
    }
    void Update()
    {
        
    }
    
}
