using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.UI;

public class Operationprocess : MonoBehaviour
{
    /// <summary>
    /// 违约类型操作页面
    /// </summary>
    public RectTransform operationpanel;
    /// <summary>
    /// 违约类型
    /// </summary>
    public Dropdown typeofbreach;
    /// <summary>
    /// 接收违约类型下拉框
    /// </summary>
    public string strtext;
    /// <summary>
    /// 接收违约现场地址和显示文本
    /// </summary>
    public InputField fieldaddress, reportinformation;
    /// <summary>
    /// 上报按钮
    /// </summary>
    public Button report;
    /// <summary>
    /// 工单编号页面
    /// </summary>
    public RectTransform workordernumber;
    /// <summary>
    /// 工作看板按钮
    /// </summary>
    public Button workpanelbtn;
    /// <summary>
    /// 代办工单页面
    /// </summary>
    public RectTransform agencyworkorder;
    /// <summary>
    /// 代办工单按钮
    /// </summary>
    public Button workorderbutton;
    /// <summary>
    /// 操作完成颜色变深
    /// </summary>
    private Sprite procedure;
    /// <summary>
    /// 操作步骤颜色变深
    /// </summary>
    public List<Image> chartletlist = new List<Image>();
    /// <summary>
    /// 工单输入编号面板
    /// </summary>
    public RectTransform incomingworkorder;
    /// <summary>
    /// 工单输入框编号
    /// </summary>
    public InputField workorderentry;
    /// <summary>
    /// 查询按钮
    /// </summary>
    public Button inquirebutton;
    /// <summary>
    /// 违约特工面板
    /// </summary>
    public RectTransform breachofcontract;
    /// <summary>
    /// 违约派工高亮图片
    /// </summary>
    public Image reveal1;
    public Image reveal2;
    /// <summary>
    /// 违约派工按钮
    /// </summary>
    public Button dispatchbutton;
    /// <summary>
    /// 签收页面
    /// </summary>
    public Signforpanl signforpanl;
    /// <summary>
    /// 第三步签收步骤面板
    /// </summary>
    public Thethirdsteppanl thethirdsteppanl;
    void Start()
    {
        procedure = Resources.Load<Sprite>("UIpanel/procedure");
        typeofbreach.onValueChanged.AddListener(delegate
        {
            OnDropdownValueChanged(typeofbreach);
        });
        report.onClick.AddListener(Reportoperation);
        workpanelbtn.onClick.AddListener(() =>
        {
            workordernumber.gameObject.SetActive(false);
            agencyworkorder.gameObject.SetActive(true);
        });
        workorderbutton.onClick.AddListener(() =>
        {
            agencyworkorder.gameObject.SetActive(false);
            incomingworkorder.gameObject.SetActive(true);

        });
        inquirebutton.onClick.AddListener(() =>
        {
            if (workorderentry.text== "1423050210000066")
            {
                incomingworkorder.gameObject.SetActive(false);
                breachofcontract.gameObject.SetActive(true);
            }
        });
        dispatchbutton.onClick.AddListener(Pagepanl);
    }
    /// <summary>
    /// 签收页面和查看人员页面
    /// </summary>
    private void Pagepanl()
    {
        reveal1.gameObject.SetActive(true);
        reveal2.gameObject.SetActive(true);
        breachofcontract.gameObject.SetActive(false);
        signforpanl.gameObject.SetActive(true);
        signforpanl.Passbyvalue(strtext, fieldaddress.text, reportinformation.text);
        signforpanl.EquippingItems(() =>
        {
            signforpanl.signforpanl.gameObject.SetActive(false);
            signforpanl.Getvalue(strtext, fieldaddress.text, reportinformation.text);
            signforpanl.controlspanl1.gameObject.SetActive(true);
        });
        signforpanl.EquippingItems2(() =>
        {
            signforpanl.controlspanl1.gameObject.SetActive(false);
            signforpanl.controlspanl2.gameObject.SetActive(true);
        });
    }

    /// <summary>
    /// 判断违约类型方法
    /// </summary>
    private void Reportoperation()
    {
        Debug.Log("进来了");
        if (strtext.Length > 0)
        {
            if (strtext.Length>1)
            {
                Debug.Log("上报成功");
                operationpanel.gameObject.SetActive(false);
                workordernumber.gameObject.SetActive(true);

            }
        }
        else
        {
            Debug.Log("请选择违约类型");
        }
    }
    /// <summary>
    /// 完成每一步替换图片方法
    /// </summary>
    public void Picturesubstitution(int value)
    {
        chartletlist[value].sprite = procedure;
    }
    /// <summary>
    /// 参数传递
    /// </summary>
    public void Transmit()
    {
        thethirdsteppanl.Getvalue(strtext, fieldaddress.text, reportinformation.text);
    }
    void Update()
    {
        
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="dropdown"></param>
    public void OnDropdownValueChanged(Dropdown dropdown)
    {
        Debug.Log("调用了");
         strtext = dropdown.options[dropdown.value].text;
    }
}
