using UnityEngine.UI;
using Blue;
using GHZLangChao;
using TMPro;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 设备信息控制面板
/// </summary>
public class DeviceDetailsControl : AbstractController
{
    //public Text deviceId; // 设备ID
    //public Text deviceName; // 设备名称
    public TextMeshProUGUI deviceModel; // 设备型号
    public TextMeshProUGUI deviceType; // 设备类型
    public TextMeshProUGUI assetTagNumber; // 资产标签号
    public TextMeshProUGUI serialNumber; // 序列号
    public TextMeshProUGUI equipmentNumber; // 设备编码
    public TextMeshProUGUI assetStatus; // 资产状态
    public TextMeshProUGUI deviceStatus; // 设备状态
    public TextMeshProUGUI deliveryData; // 交付日期

    public TextMeshProUGUI enabledDate; // 启用日期
    public TextMeshProUGUI serverUsageType; // 服务器使用类型
    public TextMeshProUGUI typicalModel; // 典配模型
    public TextMeshProUGUI equipmentBrand; // 设备品牌
    public TextMeshProUGUI manufacturer; // 生产厂商
    public TextMeshProUGUI equipmentWeight; // 设备重量(KG)
    public TextMeshProUGUI equipmentPower; // 设备功率(W)
    public TextMeshProUGUI originType; // 产地类型
    public TextMeshProUGUI collectionCPName; // 集采目录产品名称
    public TextMeshProUGUI resourcePool; // 所在资源池

    public TextMeshProUGUI wherePOD; // 所在POD
    public TextMeshProUGUI networkDomain; // 所在网络域
    public TextMeshProUGUI city; // 所在城市
    public TextMeshProUGUI building; // 所在楼宇
    public TextMeshProUGUI floor; // 所在楼层
    public TextMeshProUGUI computerRoomName; // 所在机房名称
    public TextMeshProUGUI computerRoomCoding; // 所在机房编码
    public TextMeshProUGUI cabinetNumber; // 机柜编号
    public TextMeshProUGUI uMessage; // U位信息
    public TextMeshProUGUI deviceOrientation; // 设备朝向

    public TextMeshProUGUI manageIP; // 管理IP
    public TextMeshProUGUI saveIP; // 存储IP
    public TextMeshProUGUI iPMIIP; // IPMIP
    public TextMeshProUGUI businessIP; // 业务IP
    public TextMeshProUGUI projectName; // 项目名称
    public TextMeshProUGUI equipmentSupplier; // 设备供货商
    public TextMeshProUGUI assetOwner; // 资产责任人
    public TextMeshProUGUI territorialPAManager; // 属地省资产负责人
    public TextMeshProUGUI equipmentBTTOrganization; // 设备归属组织
    public TextMeshProUGUI facilityManagementOrganization; // 设备管理组织
    public TextMeshProUGUI equipmentMaintenanceOrganization; // 设备维护组织

    public TextMeshProUGUI businessSystem; // 业务系统
    public DataItem item;
    public void UpdateData(DeviceParameters DeviceParameter, DataItem item)
    {
        this.item = item;
        if (item != null)
            item.gameObject.SetActive(false);
        //deviceId.text = DeviceParameter.deviceId.ToString();
        //deviceName.text = DeviceParameter.deviceName;
        if (string.IsNullOrEmpty(DeviceParameter.deviceModel))
            deviceModel.text = "--";
        else
            deviceModel.text = DeviceParameter.deviceModel;
        if (string.IsNullOrEmpty(DeviceParameter.assetNumber))
            assetTagNumber.text = "--";
        else
            assetTagNumber.text = DeviceParameter.assetNumber;
        if (string.IsNullOrEmpty(DeviceParameter.serialNumber))
            serialNumber.text = "--";
        else
            serialNumber.text = DeviceParameter.serialNumber;
        if (string.IsNullOrEmpty(DeviceParameter.deviceNumber))
            equipmentNumber.text = "--";
        else
            equipmentNumber.text = DeviceParameter.deviceNumber;
        if (string.IsNullOrEmpty(DeviceParameter.assetStatus))
            assetStatus.text = "--";
        else
            assetStatus.text = DeviceParameter.assetStatus;
        if (string.IsNullOrEmpty(DeviceParameter.deviceStatus))
            deviceStatus.text = "--";
        else
            deviceStatus.text = DeviceParameter.deviceStatus;
        if (string.IsNullOrEmpty(DeviceParameter.deliveryDate))
            deliveryData.text = "--";
        else
            deliveryData.text = DeviceParameter.deliveryDate;
        if (string.IsNullOrEmpty(DeviceParameter.activationDate))
            enabledDate.text = "--";
        else
            enabledDate.text = DeviceParameter.activationDate;
        if (string.IsNullOrEmpty(DeviceParameter.serverUsageType))
            serverUsageType.text = "--";
        else
            serverUsageType.text = DeviceParameter.serverUsageType;
        if (string.IsNullOrEmpty(DeviceParameter.typical))
            typicalModel.text = "--";
        else
            typicalModel.text = DeviceParameter.typical;
        if (string.IsNullOrEmpty(DeviceParameter.deviceNumber))
            equipmentBrand.text = "--";
        else
            equipmentBrand.text = DeviceParameter.deviceNumber;
        if (string.IsNullOrEmpty(DeviceParameter.manufacturer))
            manufacturer.text = "--";
        else
            manufacturer.text = DeviceParameter.manufacturer;
        if (string.IsNullOrEmpty(DeviceParameter.eight))
            equipmentWeight.text = "--";
        else
            equipmentWeight.text = DeviceParameter.eight;
        if (string.IsNullOrEmpty(DeviceParameter.power))
            equipmentPower.text = "--";
        else
            equipmentPower.text = DeviceParameter.power;
        if (string.IsNullOrEmpty(DeviceParameter.origin))
            originType.text = "--";
        else
            originType.text = DeviceParameter.origin;
        if (string.IsNullOrEmpty(DeviceParameter.catalogProductName))
            collectionCPName.text = "--";
        else
            collectionCPName.text = DeviceParameter.catalogProductName;
        if (string.IsNullOrEmpty(DeviceParameter.resourcePool))
            resourcePool.text = "--";
        else
            resourcePool.text = DeviceParameter.resourcePool;

        if (string.IsNullOrEmpty(DeviceParameter.pod))
            wherePOD.text = "--";
        else
            wherePOD.text = DeviceParameter.pod;
        if (string.IsNullOrEmpty(DeviceParameter.network))
            networkDomain.text = "--";
        else
            networkDomain.text = DeviceParameter.network;
        if (string.IsNullOrEmpty(DeviceParameter.province))
            city.text = "--";
        else
            city.text = DeviceParameter.province;
        if (string.IsNullOrEmpty(DeviceParameter.building))
            building.text = "--";
        else
            building.text = DeviceParameter.building;
        if (string.IsNullOrEmpty(DeviceParameter.floor))
            floor.text = "--";
        else
            floor.text = DeviceParameter.floor;
        if (string.IsNullOrEmpty(DeviceParameter.engineRoomName))
            computerRoomName.text = "--";
        else
            computerRoomName.text = DeviceParameter.engineRoomName;
        if (string.IsNullOrEmpty(DeviceParameter.cabinetNumber))
            cabinetNumber.text = "--";
        else
            cabinetNumber.text = DeviceParameter.cabinetNumber;
        if (string.IsNullOrEmpty(DeviceParameter.u))
            uMessage.text = "--";
        else
            uMessage.text = DeviceParameter.u;
        if (string.IsNullOrEmpty(DeviceParameter.deviceOrientation))
            deviceOrientation.text = "--";
        else
            deviceOrientation.text = DeviceParameter.deviceOrientation;

        if (string.IsNullOrEmpty(DeviceParameter.managementIP))
            manageIP.text = "--";
        else
            manageIP.text = DeviceParameter.managementIP;
        if (string.IsNullOrEmpty(DeviceParameter.saveIP))
            saveIP.text = "--";
        else
            saveIP.text = DeviceParameter.saveIP;
        if (string.IsNullOrEmpty(DeviceParameter.iPMIIP))
            iPMIIP.text = "--";
        else
            iPMIIP.text = DeviceParameter.iPMIIP;
        if (string.IsNullOrEmpty(DeviceParameter.businessIP))
            businessIP.text = "--";
        else
            businessIP.text = DeviceParameter.businessIP;
        if (string.IsNullOrEmpty(DeviceParameter.supplier))
            equipmentSupplier.text = "--";
        else
            equipmentSupplier.text = DeviceParameter.supplier;
        if (string.IsNullOrEmpty(DeviceParameter.provincePrincipal))
            territorialPAManager.text = "--";
        else
            territorialPAManager.text = DeviceParameter.provincePrincipal;
        if (string.IsNullOrEmpty(DeviceParameter.ownershipOrganization))
            equipmentBTTOrganization.text = "--";
        else
            equipmentBTTOrganization.text = DeviceParameter.ownershipOrganization;
        if (string.IsNullOrEmpty(DeviceParameter.managementOrganization))
            facilityManagementOrganization.text = "--";
        else
            facilityManagementOrganization.text = DeviceParameter.managementOrganization;
        if (string.IsNullOrEmpty(DeviceParameter.maintenanceOrganization))
            equipmentMaintenanceOrganization.text = "--";
        else
            equipmentMaintenanceOrganization.text = DeviceParameter.maintenanceOrganization;

        if (string.IsNullOrEmpty(DeviceParameter.businessSystem))
            businessSystem.text = "--";
        else
            businessSystem.text = DeviceParameter.businessSystem;
    }

    public void CloseOnClick()
    {
        gameObject.SetActive(false);
        if (item != null)
        {
            item.gameObject.SetActive(true);
            item = null;
        }
    }
}