<script setup lang="ts">
import TableNoData from '@/components/TableNoData/TableNoData.vue';
import TableExtendData from '@/pages/System/Info/components/TableExtendData/TableExtendData.vue';
import { loading } from '@/utils/composition';
import { deepClone, showElMessage } from '@/utils/utils';
import { IconChevronDown, IconChevronUp } from '@computing/opendesign-icons';
import type { PropType } from 'vue';
import { nextTick, ref, toRefs, computed, reactive } from 'vue';
import useStore from '@/stores';
import { useI18n } from 'vue-i18n';
import {
  IAccelerateCard,
  IDpuCard,
  IFPGACard,
  IGPUCard,
  INetCard,
  IOtherTab,
  IPCIeCard,
  IPort,
  IPorts,
  ISDICard,
  ISDIExtendCard,
  IStorageCard,
} from '../../product.datatype';
import { getBoard, sendNmi, setLevel, resetPower, setPower } from '../../service/system.service';
import { isOtherEmptyProperty } from '../../utils/system.util';
import { checkPrivil } from '@/apps/app-bmc/router/routes';
import { UserPrivil } from '@/model/base-enum';
import { traduction } from '@/utils/language';
import Dialog from '@/components/Dialog/Dialog.vue';

const store = useStore();
// 系统锁定状态
const isSystemLock = computed(() => {
  return store.state.glob.systemLocked;
});
const isPrivileges = checkPrivil(UserPrivil.powerControl);
const hasBasicConfig = checkPrivil(UserPrivil.baseConfig);
const i18n = useI18n();
const props = defineProps({
  data: {
    type: Object as PropType<IOtherTab>,
    required: true,
    default: () => {
      return {};
    },
  },
});
const tableId = 'pCIETable';
const { data } = toRefs(props);
const boardData: IOtherTab = data?.value;
const boardTableData = ref([] as any);
const currentPage = ref(1);
const pageSize = ref(10);
const total = ref(boardTableData.value.length);
const tableData = ref([]);
const tableRef = ref();
let currentRowArray: any = [];
// 不同卡对应的初始数据函数数组
const parseDataMap = new Map<string, Function>([
  ['Net Card', initNetRAIDCard],
  ['RAID Card', initNetRAIDCard],
  ['Storage DPU Card', initDPUCard],
  ['GPU Card', initGPUCard],
  ['FPGA Card', initFPGACard],
  ['NPU Card', initFPGACard],
  ['SDI Card', initSDICard],
  ['DPU Card', initSDICard],
  ['Storage Card', initStorageCard],
  ['Accelerate Card', initAccelerateCard],
]);

if (boardData.currentNumber && boardData.currentNumber > 0) {
  loading(true);
  getPCleData();
}

function getPCleData() {
  boardTableData.value = [];
  getBoard(boardData.detailLink)
    .then((res: any) => {
      if (res.data && res.data.length > 0) {
        res.data.forEach((borad: any) => {
          const d = parseData(borad);
          if (d) {
            boardTableData.value.push(d);
          }
        });
      }
      total.value = boardTableData.value.length;
      getData();
    })
    .finally(() => {
      loading(false);
    });
}

function parseData(board: any): IPCIeCard {
  const type = board.FunctionType;
  let extendAttr = {};
  if (parseDataMap.has(type)) {
    extendAttr = parseDataMap.get(type)?.call(parseDataMap.get(type), board);
  } else {
    extendAttr = initNetRAIDCard(board);
  }
  return {
    id: board?.Id ? board.Id.substring(8) : '',
    slotId: isOtherEmptyProperty(board.Description) || ' ',
    description: isOtherEmptyProperty(board.Description) || ' ',
    position: isOtherEmptyProperty(board.Position) || ' ',
    manufacturer: isOtherEmptyProperty(board.Manufacturer) || ' ',
    vendorId: isOtherEmptyProperty(board?.PCIeFunctionDate?.VendorId) || ' ',
    deviceId: isOtherEmptyProperty(board?.PCIeFunctionDate?.DeviceId) || ' ',
    subsystemVendorId: isOtherEmptyProperty(board?.PCIeFunctionDate?.SubsystemVendorId) || ' ',
    subsystemId: isOtherEmptyProperty(board?.PCIeFunctionDate?.SubsystemId) || ' ',
    associatedResource: isOtherEmptyProperty(board?.PCIeFunctionDate?.AssociatedResource) || ' ',
    partNumber: isOtherEmptyProperty(board.PartNumber) || ' ',
    componentUniqueID: isOtherEmptyProperty(board.ComponentUniqueID) || ' ',
    extendAttr,
  };
}

// 表头数组
const columns = [
  {
    title: 'COMMON_DESCRIPTION',
    width: '16%',
    show: true,
    content: 'description',
  },
  {
    title: 'OTHER_POSITION',
    width: '10%',
    show: true,
    content: 'position',
  },
  {
    title: 'COMMON_MANUFACTURER',
    width: '15%',
    show: true,
    content: 'manufacturer',
  },
  {
    title: 'OTHER_SLOT_POSITION',
    width: '8%',
    show: true,
    content: 'id',
  },
  {
    title: 'OTHER_MANUFACTURER_ID',
    width: '10%',
    show: true,
    content: 'vendorId',
  },
  {
    title: 'OTHER_DEVICE_ID',
    width: '10%',
    show: true,
    content: 'deviceId',
  },
  {
    title: 'OTHER_PART_NUMBER',
    width: '10%',
    show: true,
    content: 'partNumber',
  },
  {
    title: 'OTHER_SON_VENDOR_ID',
    width: '10%',
    show: true,
    content: 'subsystemVendorId',
  },
  {
    title: 'OTHER_SON_DEVICE_ID',
    width: '10%',
    show: true,
    content: 'subsystemId',
  },
  {
    title: 'COMMON_RESOURCE_OWNER',
    width: '10%',
    show: true,
    content: 'associatedResource',
  },
  {
    title: 'UID',
    width: '10%',
    show: true,
    content: 'componentUniqueID',
  },
];

function handleSizeChange(val: number) {
  pageSize.value = val;
  currentPage.value = 1;
  getData();
}

function handleCurrentChange(val: number) {
  getData();
}

function getData() {
  tableData.value = boardTableData.value.slice(
    (currentPage.value - 1) * pageSize.value,
    currentPage.value * pageSize.value,
  );
}

// Raid卡扩展数据
const netRAIDCardExtendArr = [
  {
    label: 'COMMON_NAME',
    content: 'productName',
    hide: true,
  },
  {
    label: 'OTHER_BOARD_ID',
    content: 'boardId',
    hide: true,
  },
  {
    label: 'COMMON_ALARM_PCB_VERSION',
    content: 'pcbVersion',
    hide: true,
  },
  {
    label: 'COMMIN_CPLD_VERSION',
    content: 'cpldVersion',
    hide: true,
  },
  {
    label: 'COMMON_FIXED_VERSION',
    content: 'firmwareVersion',
    hide: true,
  },
  {
    label: 'OTHER_CURRENT_BROAD_BAND',
    content: 'linkWidth',
    hide: true,
  },
  {
    label: 'OTHER_BROAD_BAND_SPECIFICATIONS',
    content: 'linkWidthAbility',
    hide: true,
  },
  {
    label: 'OTHER_CURRENT_RATE',
    content: 'linkSpeed',
    hide: true,
  },
  {
    label: 'OTHER_CURRENT_RATE_SPECIFICATIONS',
    content: 'linkSpeedAbility',
    hide: true,
  },
  {
    label: 'OTHER_SON_VENDOR_ID',
    content: 'subsystemVendorId',
    hide: true,
  },
  {
    label: 'OTHER_SON_DEVICE_ID',
    content: 'subsystemId',
    hide: true,
  },
  {
    label: 'OTHER_MAX_PCIE_TYPE_SPECIFICATIONS',
    content: 'maxpcietype',
    hide: true,
  },
];
function initNetRAIDCard(bodyData: any): INetCard {
  const productName = isOtherEmptyProperty(bodyData?.ExtendInfo?.ProductName) || ' ';
  const boardId = isOtherEmptyProperty(bodyData?.ExtendInfo?.BoardId) || ' ';
  const pcbVersion = isOtherEmptyProperty(bodyData?.ExtendInfo?.PCBVersion) || ' ';
  const cpldVersion = isOtherEmptyProperty(bodyData?.ExtendInfo?.CPLDVersion) || ' ';
  const firmwareVersion = isOtherEmptyProperty(bodyData.FirmwareVersion) || ' ';
  const linkWidth = isOtherEmptyProperty(bodyData?.PCIeFunctionDate?.LinkWidth) || ' ';
  const linkWidthAbility =
    isOtherEmptyProperty(bodyData?.PCIeFunctionDate?.LinkWidthAbility) || ' ';
  const linkSpeed = isOtherEmptyProperty(bodyData?.PCIeFunctionDate?.LinkSpeed) || ' ';
  const linkSpeedAbility =
    isOtherEmptyProperty(bodyData?.PCIeFunctionDate?.LinkSpeedAbility) || ' ';
  const subsystemVendorId =
    isOtherEmptyProperty(bodyData?.PCIeFunctionDate?.SubsystemVendorId) || ' ';
  const subsystemId = isOtherEmptyProperty(bodyData?.PCIeFunctionDate?.SubsystemId) || ' ';
  const maxpcietype = isOtherEmptyProperty(bodyData?.PCIeFunctionDate?.MaxPCIeType) || ' ';
  const titleArr = deepClone(netRAIDCardExtendArr);
  const extendData = {
    productName,
    boardId,
    pcbVersion,
    cpldVersion,
    firmwareVersion,
    linkWidth,
    linkWidthAbility,
    linkSpeed,
    linkSpeedAbility,
    subsystemVendorId,
    subsystemId,
    maxpcietype,
    extendTitleArr: titleArr,
  };
  extendData.extendTitleArr.forEach((element: any) => {
    element.hide = extendData[element.content] === '--';
  });

  return extendData;
}

const dpuExtendTitleArr = [
  {
    label: 'COMMON_NAME',
    content: 'productName',
    hide: true,
  },
  {
    label: 'HBA_STORAGE_IPV4',
    content: 'storageManagementIP',
    hide: true,
  },
  {
    label: 'HBA_STORAGE_IPV6',
    content: 'storageManagementIPv6',
    hide: true,
  },
  {
    label: 'OTHER_BROAD_BAND_SPECIFICATIONS',
    content: 'linkWidthAbility',
    hide: true,
  },
  {
    label: 'OTHER_SON_VENDOR_ID',
    content: 'subsystemVendorId',
    hide: true,
  },
  {
    label: 'OTHER_SON_DEVICE_ID',
    content: 'subsystemId',
    hide: true,
  },
  {
    label: 'COMMON_ALARM_PCB_VERSION',
    content: 'pcbVersion',
    hide: true,
  },
  {
    label: 'HBA_PORT_STATUS',
    content: 'portStatus',
    hide: true,
  },
];

function initDPUCard(bodyData: any): IDpuCard {
  const extendData: any = {
    productName: ' ',
    storageManagementIP: ' ',
    storageManagementIPv6: ' ',
    linkWidthAbility: ' ',
    subsystemVendorId: ' ',
    subsystemId: ' ',
    pcbVersion: ' ',
    portStatus: ' ',
    vrdInfo: null,
    extendTitleArr: deepClone(dpuExtendTitleArr),
  };

  const extendInfo = bodyData?.ExtendInfo;
  if (extendInfo) {
    extendData.productName = isOtherEmptyProperty(extendInfo?.ProductName) || ' ';
    extendData.storageManagementIP = isOtherEmptyProperty(extendInfo?.StorageManagementIP) || ' ';
    extendData.storageManagementIPv6 =
      isOtherEmptyProperty(extendInfo?.StorageManagementIPv6) || ' ';
    extendData.pcbVersion = isOtherEmptyProperty(extendInfo?.PCBVersion) || ' ';
    extendData.portStatus = isOtherEmptyProperty(extendInfo?.StorageManagementPortStatus) || ' ';
    extendData.vrdInfo = isOtherEmptyProperty(extendInfo?.VrdInfo) || null;
  }

  const pcieFunctionDate = bodyData.PCIeFunctionDate;
  if (pcieFunctionDate) {
    extendData.linkWidthAbility = isOtherEmptyProperty(pcieFunctionDate?.LinkWidthAbility) || ' ';
    extendData.subsystemVendorId = isOtherEmptyProperty(pcieFunctionDate?.SubsystemVendorId) || ' ';
    extendData.subsystemId = isOtherEmptyProperty(pcieFunctionDate?.SubsystemId) || ' ';
  }

  extendData.vrdInfo?.forEach((vrd: any) => {
    extendData[vrd.VrdName] = vrd.VrdVersion;
    extendData.extendTitleArr.push({ label: vrd.VrdName, content: vrd.VrdName, hide: true });
  });
  extendData.extendTitleArr.forEach((element: any) => {
    element.hide = extendData[element.content] === '--';
  });

  return extendData;
}

function initGPUCard(bodyData: any): IGPUCard {
  const productName = isOtherEmptyProperty(bodyData.ExtendInfo?.ProductName);
  const serialNumber = isOtherEmptyProperty(bodyData.SerialNumber) || ' ';
  const firmwareVersion = isOtherEmptyProperty(bodyData.FirmwareVersion) || ' ';
  const extendTitleArr = [
    {
      label: 'COMMON_NAME',
      content: 'productName',
      hide: productName === '--',
    },
    {
      label: 'COMMON_FIXED_VERSION',
      content: 'firmwareVersion',
      hide: firmwareVersion === '--',
    },
    {
      label: 'COMMON_FIXED_VERSION',
      content: 'firmwareVersion',
      hide: firmwareVersion === '--',
    },
  ];
  return { productName, serialNumber, firmwareVersion, extendTitleArr };
}

function getPlatformId(bodyData: any) {
  const firmwareVersion = isOtherEmptyProperty(bodyData.FirmwareVersion) || ' ';
  let platformId = null as any;
  if (firmwareVersion === 0 || firmwareVersion) {
    const firmwareVersions = firmwareVersion.split(' ');
    if (firmwareVersions.length > 1) {
      // 版本 与ID
      platformId = Number(firmwareVersions[1].substring(1, firmwareVersions[1].length - 1));
    }
  }
  return platformId;
}

function getPower(bodyData: any) {
  // 判断是否存在，且是否为小数，然后保留两位小数
  const ifPower = bodyData.Power && bodyData.Power.toString().split('.');
  let power = '';
  if (ifPower && ifPower[1]) {
    if (ifPower[1].length > 2) {
      power = isOtherEmptyProperty(bodyData.Power.toFixed(2)) || '--';
    } else {
      power = isOtherEmptyProperty(bodyData.Power) || '--';
    }
  } else {
    power = isOtherEmptyProperty(bodyData.Power);
  }
  return power;
}

function initFPGACard(bodyData: any): IFPGACard {
  const platformId = getPlatformId(bodyData);
  const power = getPower(bodyData);
  const productName = isOtherEmptyProperty(bodyData?.ExtendInfo?.ProductName) || ' ';
  const boardId = isOtherEmptyProperty(bodyData?.ExtendInfo?.BoardId) || ' ';
  const pcbVersion = isOtherEmptyProperty(bodyData?.ExtendInfo?.PCBVersion) || ' ';
  const mcuFirmwareVersion = isOtherEmptyProperty(bodyData.McuFirmwareVersion) || ' ';
  const firmwareVersion = isOtherEmptyProperty(bodyData.FirmwareVersion) || ' ';
  const memoryCapacity = isOtherEmptyProperty(bodyData.MemoryCapacityMB) || ' ';
  const extendTitleArr = [
    {
      label: 'COMMON_NAME',
      content: 'productName',
      hide: productName === '--',
    },
    {
      label: 'OTHER_BOARD_ID',
      content: 'boardId',
      hide: boardId === '--',
    },
    {
      label: 'COMMON_ALARM_PCB_VERSION',
      content: 'pcbVersion',
      hide: pcbVersion === '--',
    },
    {
      label: 'OTHER_MCU_FIXED_VERSION',
      content: 'mcuFirmwareVersion',
      hide: mcuFirmwareVersion === '--',
    },
    {
      label: 'OTHER_PLATFORM_ID',
      content: 'platformId',
      hide: !platformId,
    },
    {
      label: 'OTHER_POWER',
      content: 'power',
    },
    {
      label: 'OTHER_FIRMWARE_VERSION',
      content: 'firmwareVersion',
    },
    {
      label: 'OTHER_MEMORY_CAPACITY',
      content: 'memoryCapacity',
    },
  ];
  return {
    productName,
    boardId,
    pcbVersion,
    mcuFirmwareVersion,
    platformId,
    power,
    extendTitleArr,
    firmwareVersion,
    memoryCapacity,
  };
}

const sDICardExtendTitleArr = [
  {
    label: 'COMMON_NAME',
    content: 'productName',
    hide: true,
  },
  {
    label: 'OTHER_BOARD_ID',
    content: 'boardId',
    hide: true,
  },
  {
    label: 'COMMON_ALARM_PCB_VERSION',
    content: 'pcbVersion',
    hide: true,
  },
  { label: '', content: '' }, // M.2在位信息显示，占位置，为了顺序与V2一致
  {
    label: 'OTHER_PORT_IP',
    content: 'storageManageIP',
    hide: true,
  },
  {
    label: 'IBMC_VLAN_ID',
    content: 'vlanId',
    hide: true,
  },
  {
    label: 'OTHER_SYSMETHOD',
    content: 'bootOption',
    hide: true,
  },
  {
    label: 'OTHER_MCU_FIXED_VERSION',
    content: 'mcuFirmwareVersion',
    hide: true,
  },
  {
    label: 'OTHER_POWER',
    content: 'power',
    hide: true,
  },
  {
    label: 'OTHER_LOG_MRC_LEVEL',
    content: 'MRCLogLevel',
    hide: true,
  },
  {
    label: 'OTHER_LOG_UEFI_LEVEL',
    content: 'UEFILogLevel',
    hide: true,
  },
  {
    label: 'OTHER_VRD',
    content: 'vrdFirmwareVersion',
    hide: true,
  },
];

const extendCardTitleArr = [
  {
    label: 'COMMON_NAME',
    content: 'productName',
    hide: true,
  },
  {
    label: 'COMMON_ALARM_PCB_VERSION',
    content: 'pcbVersion',
    hide: true,
  },
  {
    label: 'OTHER_BOARDNAME',
    content: 'boardName',
    hide: true,
  },
  {
    label: 'OTHER_BOARD_ID',
    content: 'boardId',
    hide: true,
  },

  {
    label: 'OTHER_DEVICE_ID',
    content: 'deviceId',
    hide: true,
  },
  {
    label: 'OTHER_MANUFACTURER_ID',
    content: 'vendorId',
    hide: true,
  },

  {
    label: 'OTHER_SON_VENDOR_ID',
    content: 'subsystemVendorId',
    hide: true,
  },
  {
    label: 'OTHER_SON_DEVICE_ID',
    content: 'subsystemId',
    hide: true,
  },

  {
    label: 'COMMON_MANUFACTURER',
    content: 'manufacturer',
    hide: true,
  },
  {
    label: 'COMMON_DESCRIPTION',
    content: 'description',
    hide: true,
  },

  {
    label: 'OTHER_CHIP_VENDOR',
    content: 'chipManufacturer',
    hide: true,
  },
  {
    label: 'OTHER_CHIP_MODEL',
    content: 'chipModel',
    hide: true,
  },
];

const editAttr = reactive(['OTHER_LOG_MRC_LEVEL','OTHER_LOG_UEFI_LEVEL']);

function getExtendCard(extendCardInfo: any) {
  const title =
    i18n.t('OTHER_EXTEND_CARD_INFO') +
    '(' +
    i18n.t('OTHER_SLOT_POSITION') +
    extendCardInfo.Slot +
    ')';
  const extProductName = isOtherEmptyProperty(extendCardInfo.ProductName) || ' ';
  const extPcbVersion = isOtherEmptyProperty(extendCardInfo.PCBVersion) || ' ';
  const boardName = isOtherEmptyProperty(extendCardInfo.BoardName) || ' ';
  const extBoardId = isOtherEmptyProperty(extendCardInfo.BoardId) || ' ';
  const deviceId = isOtherEmptyProperty(extendCardInfo.DeviceId) || ' ';
  const vendorId = isOtherEmptyProperty(extendCardInfo.VendorId) || ' ';
  const subsystemVendorId = isOtherEmptyProperty(extendCardInfo.SubsystemVendorId) || ' ';
  const subsystemId = isOtherEmptyProperty(extendCardInfo.SubsystemId) || ' ';
  const manufacturer = isOtherEmptyProperty(extendCardInfo.Manufacturer) || ' ';
  const description = isOtherEmptyProperty(extendCardInfo.Description) || ' ';
  const chipManufacturer = isOtherEmptyProperty(extendCardInfo.ChipManufacturer) || ' ';
  const chipModel = isOtherEmptyProperty(extendCardInfo.Model) || ' ';
  const extendPorts = getPorts(extendCardInfo.PfMacInfo);
  const sDIExtendCard: ISDIExtendCard = {
    title,
    productName: extProductName,
    pcbVersion: extPcbVersion,
    boardName,
    boardId: extBoardId,
    deviceId,
    vendorId,
    subsystemVendorId,
    subsystemId,
    manufacturer,
    description,
    chipManufacturer,
    chipModel,
    ports: extendPorts,
  };

  const titleArr = deepClone(extendCardTitleArr);
  titleArr.forEach((element: any) => {
    element.hide = sDIExtendCard[element.content] === '--';
  });
  sDIExtendCard.extendCardTitleArr = titleArr;
  return sDIExtendCard;
}

function getExtendCardNum(extendInfo: any) {
  const boardId = isOtherEmptyProperty(extendInfo.BoardId) || ' ';
  const extendCard = extendInfo.ExtendCardInfo;
  let extendCardNum = null;
  const m2Device1Presence: [string, string] = ['', ''];
  m2Device1Presence[0] = i18n.t('OTHER_M2_INPOSITION_1_2');
  m2Device1Presence[1] =
    (extendInfo.M2Device1Presence ? 'Presence' : 'Absence') +
    '/' +
    (extendInfo.M2Device2Presence ? 'Presence' : 'Absence');
  // boardId:0x00a5代表SDI卡
  if (boardId === '0x005e' || boardId === '0x00a9' || boardId === '0x00a5') {
    m2Device1Presence[0] =
      boardId === '0x005e' ? i18n.t('OTHER_M2_INPOSITION_0_1') : i18n.t('OTHER_M2_INPOSITION_1_2');
    extendCardNum = calExtendCardNum(extendCard, '2');
    return { m2Device1Presence, extendCardNum };
  } else {
    if (boardId === '0x00d0' || boardId === '0x00d1') {
      m2Device1Presence[0] = i18n.t('OTHER_M2_INPOSITION_0_0');
    } else if (boardId === '0x00fd') {
      m2Device1Presence[0] = i18n.t('OTHER_M2_INPOSITION_1_2');
    }
    const sODimm =
      (extendInfo.SODIMM00Presence ? 'Presence' : 'Absence') +
      '/' +
      (extendInfo.SODIMM10Presence ? 'Presence' : 'Absence');
    extendCardNum = calExtendCardNum(extendCard, '1');
    return { m2Device1Presence, extendCardNum, sODimm };
  }
}
function calExtendCardNum(extendCard: any[], def: string) {
  if (extendCard && extendCard.length > 0) {
    return extendCard.length + '/2';
  } else {
    return '0/' + def;
  }
}
function initSDICard(bodyData: any): ISDICard {
  const productName = isOtherEmptyProperty(bodyData?.ExtendInfo?.ProductName) || ' ';
  const boardId = isOtherEmptyProperty(bodyData?.ExtendInfo?.BoardId) || ' ';
  const pcbVersion = isOtherEmptyProperty(bodyData?.ExtendInfo?.PCBVersion) || ' ';
  const storageManageIP = isOtherEmptyProperty(bodyData?.ExtendInfo?.StorageManagementIP) || ' ';
  const vlanId = isOtherEmptyProperty(bodyData?.ExtendInfo?.StorageManagementVlanId);
  const bootOption = isOtherEmptyProperty(bodyData?.ExtendInfo?.BootOption) || ' ';
  const mcuFirmwareVersion = isOtherEmptyProperty(bodyData?.McuFirmwareVersion) || ' ';
  const power = isOtherEmptyProperty(bodyData?.Power) || ' ';
  const extendCard = bodyData?.ExtendInfo?.ExtendCardInfo;
  const vrdFirmwareVersion = isOtherEmptyProperty(bodyData?.VrdFirmwareVersion) || ' ';
  const ports = getPorts(bodyData?.ExtendInfo?.SDIPfMacInfo);
  let MRCLogLevel = isOtherEmptyProperty(bodyData?.ExtendInfo?.MRCLogLevel) || ' ';
  if (MRCLogLevel !== '--' && MRCLogLevel !== ' ') {
    MRCLogLevel = MRCLogLevel === 1 ? traduction('OTHER_PRINT_SIMPLE') : traduction('OTHER_PRINT_ALL');
  }
  let UEFILogLevel = isOtherEmptyProperty(bodyData?.ExtendInfo?.UEFILogLevel) || ' ';
  if (UEFILogLevel !== '--' && UEFILogLevel !== ' ') {
    UEFILogLevel = UEFILogLevel === 1 ? traduction('OTHER_PRINT_SIMPLE') : traduction('OTHER_PRINT_ALL');
  }
  let isDpuCard = bodyData.FunctionType === 'DPU Card';
    const ossUpported = isDpuCard ? false : bodyData?.ExtendInfo?.OSSupported;
  const sDICard: ISDICard = {
    productName,
    boardId,
    pcbVersion,
    storageManageIP,
    vlanId,
    bootOption,
    mcuFirmwareVersion,
    power,
    ports,
    MRCLogLevel,
    UEFILogLevel,
    vrdFirmwareVersion,
    ossUpported,
  };
  if (Object.prototype.hasOwnProperty.call(bodyData?.ExtendInfo, 'PowerState')) {
    sDICard.powerState = isOtherEmptyProperty(bodyData?.ExtendInfo?.PowerState);
  }
  const titleArr = deepClone(sDICardExtendTitleArr);
  titleArr.forEach((element: any) => {
    element.hide = sDICard[element.content] === '--' && element.content !== 'vlanId';
  });
  sDICard.extendTitleArr = titleArr;
  const extendCardNumInfo = getExtendCardNum(bodyData.ExtendInfo);
  sDICard.m2Device1Presence = extendCardNumInfo.m2Device1Presence[1];
  titleArr[3] = {
    label: extendCardNumInfo.m2Device1Presence[0],
    content: 'm2Device1Presence',
    hide: false,
  };
  sDICard.extendCardNum = extendCardNumInfo.extendCardNum;
  titleArr.push({ label: 'OTHER_CARD_INPOSITION', content: 'extendCardNum', hide: false });
  if (extendCardNumInfo.sODimm !== undefined) {
    sDICard.sODimm = extendCardNumInfo.sODimm;
    titleArr.push({ label: 'OTHER_SODINPOSITION', content: 'sODimm', hide: false });
  }
  if (extendCard && extendCard instanceof Array && extendCard.length > 0) {
    sDICard.extendCards = [];
    extendCard.forEach((extendCardInfo: any) => {
      if (extendCardInfo !== null && extendCardInfo !== []) {
        sDICard.extendCards?.push(getExtendCard(extendCardInfo));
      }
    });
  }
  return sDICard;
}

function getStorageCardExtendArrOfNoSSD1(bodyData: any) {
  const productName = bodyData?.ExtendInfo?.ProductName;
  const boardId = bodyData.BoardID;
  const pcbVersion = bodyData.PCBVersion;
  const serialNumber = bodyData.SerialNumber;
  const model = bodyData.Model;
  const firmwareVersion = bodyData.FirmwareVersion;
  const residualWearRate = bodyData?.ExtendInfo?.RemainingWearRatePercent;
  return [
    {
      label: 'COMMON_NAME',
      content: 'productName',
      hide: productName === undefined,
    },
    {
      label: 'OTHER_BOARD_ID',
      content: 'boardId',
      hide: boardId === undefined,
    },
    {
      label: 'COMMON_ALARM_PCB_VERSION',
      content: 'pcbVersion',
      hide: pcbVersion === undefined,
    },
    {
      label: 'COMMON_SERIALNUMBER',
      content: 'serialNumber',
      hide: serialNumber === undefined,
    },
    {
      label: 'OTHER_MODEL',
      content: 'model',
      hide: model === undefined,
    },
    {
      label: 'COMMON_FIXED_VERSION',
      content: 'firmwareVersion',
      hide: firmwareVersion === undefined,
    },
    {
      label: 'WEAR_RATE',
      content: 'residualWearRate',
      hide: residualWearRate === undefined || isOtherEmptyProperty(residualWearRate) === '--',
    },
  ];
}

function getStorageCardExtendArrOfSSD1(bodyData: any) {
  const productName = bodyData?.ExtendInfo?.ProductName;
  const boardId = bodyData.BoardID;
  const pcbVersion = bodyData.PCBVersion;
  const serialNumber = bodyData.SerialNumber;
  const pcbVersionuctName = bodyData.ProdPCBVersionuctName;
  const ssd1Presence = bodyData.SSD1Presence ? 'Presence' : 'Absence';
  const ssd2Presence = bodyData.SSD2Presence ? 'Presence' : 'Absence';
  return [
    {
      label: 'COMMON_NAME',
      content: 'productName',
      hide: productName === undefined,
    },
    {
      label: 'OTHER_BOARD_ID',
      content: 'boardId',
      hide: boardId === undefined,
    },
    {
      label: 'COMMON_ALARM_PCB_VERSION',
      content: 'pcbVersion',
      hide: pcbVersion === undefined,
    },
    {
      label: 'COMMON_SERIALNUMBER',
      content: 'serialNumber',
      hide: serialNumber === undefined,
    },
    {
      label: 'COMMON_ALARM_PCB_VERSION',
      content: 'pcbVersionuctName',
      hide: pcbVersionuctName === undefined,
    },
    {
      label: 'SSD1',
      content: 'ssd1Presence',
      hide: ssd1Presence === undefined,
    },
    {
      label: 'SSD2',
      content: 'ssd2Presence',
      hide: ssd2Presence === undefined,
    },
  ];
}

function initStorageCard(bodyData: any): IStorageCard {
  const productName = bodyData?.ExtendInfo?.ProductName;
  const boardId = bodyData.BoardID;
  const pcbVersion = bodyData.PCBVersion;
  const serialNumber = bodyData.SerialNumber;

  if (bodyData.SSD1Presence === undefined) {
    const model = bodyData.Model;
    const firmwareVersion = bodyData.FirmwareVersion;
    const residualWearRate = bodyData?.ExtendInfo?.RemainingWearRatePercent;
    const extendTitleArr = getStorageCardExtendArrOfNoSSD1(bodyData);
    return {
      productName: isOtherEmptyProperty(productName),
      boardId: isOtherEmptyProperty(boardId),
      pcbVersion: isOtherEmptyProperty(pcbVersion),
      serialNumber: isOtherEmptyProperty(serialNumber),
      model: isOtherEmptyProperty(model),
      firmwareVersion: isOtherEmptyProperty(firmwareVersion),
      residualWearRate: residualWearRate + '%',
      extendTitleArr,
    };
  } else {
    const pcbVersionuctName = bodyData.ProdPCBVersionuctName;
    const ssd1Presence = bodyData.SSD1Presence ? 'Presence' : 'Absence';
    const ssd2Presence = bodyData.SSD2Presence ? 'Presence' : 'Absence';
    const extendTitleArr = getStorageCardExtendArrOfSSD1(bodyData);
    return {
      productName: isOtherEmptyProperty(productName),
      boardId: isOtherEmptyProperty(boardId),
      pcbVersion: isOtherEmptyProperty(pcbVersion),
      serialNumber: isOtherEmptyProperty(serialNumber),
      pcbVersionuctName: isOtherEmptyProperty(pcbVersionuctName),
      ssd1Presence: isOtherEmptyProperty(ssd1Presence),
      ssd2Presence: isOtherEmptyProperty(ssd2Presence),
      extendTitleArr,
    };
  }
}

function initAccelerateCard(bodyData: any): IAccelerateCard {
  const productName = bodyData?.ExtendInfo?.ProductName;
  const boardId = bodyData?.ExtendInfo?.BoardID;
  const pcbVersion = bodyData?.ExtendInfo?.PCBVersion;
  const serialNumber = bodyData.SerialNumber;
  const firmwareVersion = bodyData.FirmwareVersion;
  const bomId = bodyData.BomID;
  const extendTitleArr = [
    {
      label: 'COMMON_NAME',
      content: 'productName',
      hide: productName === undefined,
    },
    {
      label: 'OTHER_BOARD_ID',
      content: 'boardId',
      hide: boardId === undefined,
    },
    {
      label: 'COMMON_ALARM_PCB_VERSION',
      content: 'pcbVersion',
      hide: pcbVersion === undefined,
    },
    {
      label: 'COMMON_SERIALNUMBER',
      content: 'serialNumber',
      hide: serialNumber === undefined,
    },

    {
      label: 'COMMON_FIXED_VERSION',
      content: 'firmwareVersion',
      hide: firmwareVersion === undefined,
    },
    {
      label: 'COMMON_FIXED_VERSION',
      content: 'bomId',
      hide: bomId === undefined,
    },
  ];
  return { productName, boardId, pcbVersion, serialNumber, firmwareVersion, bomId, extendTitleArr };
}

function getPorts(extendPorts: any): IPorts {
  const portArray: IPort[] = [];
  if (!extendPorts || extendPorts.length < 1) {
    return null as any;
  }
  extendPorts.forEach((port: any) => {
    portArray.push({
      Port: 'Port' + port.Port,
      PfId: 'PF' + port.PfId,
      PermanentMac: port.PermanentMac,
    });
  });
  return {
    title: 'OTHER_PORT_ATTR',
    portArray,
    showPort: false,
    columns: [
      {
        title: 'SERVICE_PORT',
        content: 'Port',
      },
      {
        title: 'OTHER_PFID',
        content: 'PfId',
      },
      {
        title: 'OTHER_PERMANENT_MACADDR',
        content: 'PermanentMac',
      },
    ],
  };
}
function getRowKey(rowInfo: any) {
  return 'PCIe' + rowInfo.rowIndex;
}

function getCellClass(cellInfo: any) {
  if (cellInfo.columnIndex === 0) {
    return 'expand_cell';
  }
  return columns[cellInfo.columnIndex - 1]?.content;
}

function changePortsState(ports: any) {
  ports.showPort = !ports.showPort;
  nextTick(() => {
    currentRowArray.forEach((element: any) => {
      tableRef.value.toggleRowExpansion(element, true);
    });
  });
}

const SendNmidialogRef = ref();
const SendNmiinfo = reactive({
  id: 'interruptDialog',
  content: traduction('OTHER_INTERRUPT_WARN'),
  title: traduction('COMMON_CONFIRM'),
  okButton: {
    id: 'secondConfirm_ok_btn',
    label: traduction('COMMON_CONFIRM'),
    hide: false,
  },
});
const nmiParams = {
  SlotId: 0,
};
function clickSendNmi(id: number) {
  nmiParams.SlotId = id;
  SendNmidialogRef.value.show();
}
function sendNmidialogClose(value: boolean) {
  if (value) {
    sendNmi(nmiParams)
      .then(res => {
        showElMessage('success', traduction('COMMON_SUCCESS'));
      })
      .catch(error => {
        showElMessage('error', traduction('COMMON_FAILED'));
      })
      .finally(() => {
        nmiParams.SlotId = 0;
      });
  }
  SendNmidialogRef.value.hide();
}

const PowerRef = ref();
const Powerinfo = reactive({
  id: 'powerDialog',
  content: traduction('OTHER_INTERRUPT_WARN'),
  title: traduction('COMMON_CONFIRM'),
  okButton: {
    id: 'secondConfirm_ok_btn',
    label: traduction('COMMON_CONFIRM'),
    hide: false,
  },
});
const powerParams = {
  SlotId: 0,
};

function clickPower(id: number, type: string) {
  powerParams.SlotId = id;
  switch (type) {
    case 'On': {
      Powerinfo.content = traduction('OTHER_POWER_ON_TIP');
      break;
    }
    case 'Off': {
      Powerinfo.content = traduction('OTHER_POWER_OFF_TIP');
      break;
    }
    default: {
      Powerinfo.content = traduction('OTHER_POWER_RESET_TIP');
    }
  }
  PowerRef.value.show();
}

function powerDialogClose(value: boolean) {
  if (value) {
    if (Powerinfo.content === traduction('OTHER_POWER_ON_TIP')) {
      setPower({ SlotId: powerParams.SlotId, PowerState: 1 })
        .then((res: any) => {
          showElMessage('success', traduction('COMMON_SUCCESS'));
        })
        .catch((error: any) => {
          showElMessage('error', traduction('COMMON_FAILED'));
        })
        .finally(() => {
          powerParams.SlotId = 0;
          getPCleData();
        });
    } else if (Powerinfo.content === traduction('OTHER_POWER_OFF_TIP')) {
      setPower({ SlotId: powerParams.SlotId, PowerState: 0 })
        .then((res: any) => {
          showElMessage('success', traduction('COMMON_SUCCESS'));
        })
        .catch((error: any) => {
          showElMessage('error', traduction('COMMON_FAILED'));
        })
        .finally(() => {
          powerParams.SlotId = 0;
          getPCleData();
        });
    } else {
      resetPower({ SlotId: powerParams.SlotId })
        .then((res: any) => {
          showElMessage('success', traduction('COMMON_SUCCESS'));
        })
        .catch((error: any) => {
          showElMessage('error', traduction('COMMON_FAILED'));
        })
        .finally(() => {
          powerParams.SlotId = 0;
          getPCleData();
        });
    }
  }
  blur('powerOnBtn');
  blur('powerOffBtn');
  blur('resetBtn');
  PowerRef.value.hide();
}
 

function blur(id: String) {
  const elem: HTMLElement = document.getElementById(id as string) as HTMLElement;
  if (elem) {
    elem.blur();
  } else {}
}

const printValue = ref(1);
const printList = reactive([
  {
    label: traduction('OTHER_PRINT_SIMPLE'),
    id: 1,
  },
  {
    label: traduction('OTHER_PRINT_ALL'),
    id: 2,
  },
]);
const LevelRef = ref();
const LevelInfo = reactive({
  id: 'levelDialog',
  content: '',
  title: traduction('OTHER_LOG_LEVEL_SET'),
  okButton: {
    id: 'secondConfirm_ok_btn',
    label: traduction('COMMON_CONFIRM'),
    hide: false,
  },
});
const LevelParams = reactive({
  SlotId: 0,
  MRCPreValue: 1,
  MRCValue: 1,
  UEFIPreValue: 1,
  UEFIValue: 1,
  isMRC: true,
});

function edit(params: any) {
  LevelParams.MRCPreValue = params.params[1] === traduction('OTHER_PRINT_SIMPLE') ? 1 : 2;
  LevelParams.MRCValue = params.params[1] === traduction('OTHER_PRINT_SIMPLE') ? 1 : 2;
  LevelParams.UEFIValue = params.params[1] === traduction('OTHER_PRINT_SIMPLE') ? 1 : 2;
  LevelParams.isMRC = params.params[0].label === 'OTHER_LOG_MRC_LEVEL';
  LevelParams.SlotId = params.id;
  LevelRef.value.show();
}

function levelDialogClose(value: boolean) {
  if (value) {
    let params = {};
    if (LevelParams.isMRC) {
      params = {
        SlotId: LevelParams.SlotId,
        MRCLogLevel: LevelParams.MRCValue,
      };
    } else {
      params = {
        SlotId: LevelParams.SlotId,
        UEFILogLevel: LevelParams.UEFIValue,
      };
    }
    
    setLevel(params)
      .then((res: any) => {
        showElMessage('success', traduction('COMMON_SUCCESS'));
      })
      .catch((error: any) => {
        showElMessage('error', traduction('COMMON_FAILED'));
      })
      .finally(() => {
        LevelParams.SlotId = 0;
        getPCleData();
      });
  }
  LevelRef.value.hide();
}

const expandOpen = (row: any, expand: any) => {
  currentRowArray = expand;
};
</script>

<template>
  <div id="pciePage" class="system-info-table">
    <div v-if="boardData.maxNumber && boardData.maxNumber > 0" class="summary">
      <span id="totalLabel" v-t="'HOME_HEALTH_TOTALNUM'" class="label" />
      <span id="totalNum" class="label-content">{{ boardData.maxNumber }}</span>
      <span id="currentLabel" v-t="'HOME_HEALTH_CURRENTNUM'" class="label" />
      <span id="currentNum" class="label-content">{{ total }}</span>
    </div>
    <el-table
      ref="tableRef"
      v-addId.table="tableId"
      :data="tableData"
      :row-class-name="getRowKey"
      :cell-class-name="getCellClass"
      resizable
      border
      @expand-change="expandOpen"
    >
      <el-table-column class="expand" type="expand">
        <template #default="scope">
          <el-button
            v-if="scope.row.extendAttr.ossUpported && isPrivileges"
            id="sendNmiBtn"
            :disabled="isSystemLock"
            class="save"
            plain
            @click="clickSendNmi(Number(scope.row.id))"
          >
            {{ $t('OTHER_INTERRUPT') }}
          </el-button>
          <span
            v-if="
              scope.row.extendAttr.powerState !== undefined &&
                isPrivileges
            "
            id="sdiAttr"
            v-t="$t('FDM_POWER_STATUS')"
            class="module-title"
          />
          <el-tag
            v-if="
              scope.row.extendAttr.powerState === 'On' &&
                isPrivileges
            "
            id="powerOn"
            type="success"
          >
            {{ $t('OTHER_SDI_POWER_ON') }}
          </el-tag>
          <el-tag
            v-if="
              scope.row.extendAttr.powerState === 'Off' &&
                isPrivileges
            "
            id="powerOff"
            type="info"
          >
            {{ $t('OTHER_SDI_POWER_OFF') }}
          </el-tag>
          <span
            v-if="
              scope.row.extendAttr.powerState !== undefined &&
                isPrivileges
            "
            id="sdiKey"
            v-t="'OTHER_SDI_KEYS'"
            class="module-title"
          />
          <div v-if="scope.row.extendAttr.powerState !== undefined && isPrivileges">
            <el-button
              v-if="scope.row.extendAttr.powerState === 'Off'"
              id="powerOnBtn"
              :disabled="isSystemLock"
              @click="clickPower(Number(scope.row.id), 'On')"
            >
              {{ $t('OTHER_SDI_POWER_ON') }}
            </el-button>
            <el-button
              v-if="scope.row.extendAttr.powerState === 'On'"
              id="powerOffBtn"
              :disabled="isSystemLock"
              @click="clickPower(Number(scope.row.id), 'Off')"
            >
              {{ $t('OTHER_SDI_POWER_OFF') }}
            </el-button>
            <el-button
              id="resetBtn"
              :disabled="isSystemLock || scope.row.extendAttr.powerState === 'Off'"
              @click="clickPower(Number(scope.row.id), 'Reset')"
            >
              {{ $t('OTHER_SDI_RESET') }}
            </el-button>
          </div>
          <span v-t="'OTHER_EXTEND_INFO'" class="module-title" />
          <TableExtendData
            :id="Number(scope.row.id)"
            :data-list="scope.row.extendAttr.extendTitleArr"
            :fields="scope.row.extendAttr"
            :edit-attr="
              scope.row.extendAttr.MRCLogLevel !== '--' &&
                scope.row.extendAttr.UEFILogLevel !== '--' &&
                scope.row.extendAttr.MRCLogLevel !== ' ' &&
                scope.row.extendAttr.UEFILogLevel !== ' ' &&
                hasBasicConfig
                ? editAttr
                : []
            "
            @edit="edit"
          />

          <div v-if="scope.row.extendAttr.ports">
            <span class="module-title">
              {{ $t(scope.row.extendAttr.ports.title) }}
              <el-icon
                :size="16"
                class="port-icon"
                @click="changePortsState(scope.row.extendAttr.ports)"
              >
                <IconChevronUp v-if="scope.row.extendAttr.ports.showPort" />
                <IconChevronDown v-else />
              </el-icon>
            </span>
            <el-table
              v-if="scope.row.extendAttr.ports?.showPort"
              v-addId.table="'pcieExtendAttrPortTable'"
              :data="scope.row.extendAttr.ports.portArray"
              resizable
              border
            >
              <el-table-column
                v-for="column in scope.row.extendAttr.ports.columns"
                :key="column.content"
                :prop="column.content"
                :label="$t(column.title)"
                :width="'30%'"
              >
                <template #default="port">
                  <span :class="column.content">{{ port.row[column.content] }}</span>
                </template>
              </el-table-column>
            </el-table>
          </div>

          <div
            v-if="scope.row.extendAttr.extendCards && scope.row.extendAttr.extendCards.length > 0"
          >
            <div v-for="card in scope.row.extendAttr.extendCards" :key="card.title" class="module">
              <span v-if="card.title" v-t="card.title" class="module-title" />
              <TableExtendData :data-list="card.extendCardTitleArr" :fields="card" />

              <div v-if="card.ports">
                <span class="module-title">
                  {{ $t(card.ports.title) }}
                  <el-icon :size="16" class="port-icon" @click="changePortsState(card.ports)">
                    <IconChevronUp v-if="card.ports?.showPort" />
                    <IconChevronDown v-else />
                  </el-icon>
                </span>
                <el-table
                  v-if="card.ports?.showPort"
                  v-addId.table="'pcieCardPortTable'"
                  :data="card.ports.portArray"
                  resizable
                  border
                >
                  <el-table-column
                    v-for="column in card.ports.columns"
                    :key="column.content"
                    :prop="column.content"
                    :label="$t(column.title)"
                    :width="'30%'"
                  >
                    <template #default="cardPort">
                      <span :class="column.content">{{ cardPort.row[column.content] }}</span>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        v-for="col in columns"
        :key="col?.content"
        :label="$t(col?.title)"
        :prop="col?.content"
        :min-width="col?.width"
      >
        <template #default="attr">
          <span :class="col?.content">{{ attr.row[col?.content] }}</span>
        </template>
      </el-table-column>
      <template #empty>
        <TableNoData />
      </template>
    </el-table>
    <el-pagination
      v-if="tableData.length != 0"
      v-model:currentPage="currentPage"
      v-addId.pagination="'pciePagination'"
      :page-sizes="[10, 15, 30, 50]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
  <Dialog ref="SendNmidialogRef" :config="SendNmiinfo" @close="sendNmidialogClose"></Dialog>
  <Dialog ref="PowerRef" :config="Powerinfo" @close="powerDialogClose"></Dialog>
  <Dialog ref="LevelRef" :config="LevelInfo" @close="levelDialogClose">
    <template #other>
      <div>
        <el-form>
          <el-form-item :label="LevelParams.isMRC ? $t('OTHER_LOG_MRC_LEVEL') : $t('OTHER_LOG_UEFI_LEVEL')" class="small-item">
            <!-- 打印类型 -->
            <el-radio-group v-if="LevelParams.isMRC" v-model="LevelParams.MRCValue">
              
              <el-radio
                v-for="item in printList"
                :id="item.label"
                :key="item.label"
                :label="item.id"
              >
                {{ item.label }}
              </el-radio>
            </el-radio-group>
            <el-radio-group v-else v-model="LevelParams.UEFIValue">
              <el-radio
                v-for="item in printList"
                :id="item.label"
                :key="item.label"
                :label="item.id"
              >
                {{ item.label }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
      </div>
    </template>
    <template #footer>
      <el-button
        id="powerSetSave"
        size="small"
        type="primary"
        :disabled="
          (!LevelParams.isMRC && LevelParams.UEFIValue === LevelParams.UEFIPreValue) ||
            (LevelParams.isMRC && LevelParams.MRCPreValue === LevelParams.MRCValue)
        "
        @click="levelDialogClose"
      >
        {{ $t('COMMON_SAVE') }}
      </el-button>
      <el-button id="powerSetCancel" size="small" @click="levelDialogClose">
        {{ $t('COMMON_CANCEL') }}
      </el-button>
    </template>
  </Dialog>
</template>

<style lang="scss" scoped>
.system-info-table {
  background: var(--o-bg-color-base);
  border-radius: 4px;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 16px 16px !important;
  height: 100%;

  .el-tabs__content {
    margin-top: 0;
  }

  .summary {
    padding-top: 16px;
  }
  .label-content {
    background: var(--o-border-color-light);
    border-radius: 8px;
    width: 28px;
    height: 16px;
    display: inline-block;
    text-align: center;
    margin: 0 16px 0 8px;
    font-size: 12px;
    font-weight: 900;
  }

  .label {
    font-size: 12px;
    color: $APP-COLOR-TEXT;
    letter-spacing: 0;
    line-height: 16px;
  }
  .detail {
    width: 50%;
    float: left;
    display: flex;
    margin-top: 8px;
  }

  .module-title {
    font-weight: 700;
    margin: 16px 0;
    display: block;
  }

  .no-data {
    text-align: center;
    margin-top: 128px;
  }
  .no-data-text {
    font-size: 12px;
    color: var(--o-text-color-tertiary);
    text-align: center;
    line-height: 16px;
  }
  :deep(.el-table--border) {
    .el-table__cell:first-child .cell {
      margin-left: 8px;
      width: 16px;
      padding-left: 0;
      display: inline-block;
    }

    tr,
    colgroup {
      th:nth-child(1),
      col:nth-child(1),
      td:nth-child(1) {
        width: 40px;
        max-width: 40px;
      }
    }
  }
  :deep(.el-table__expanded-cell) {
    .cell {
      width: 100% !important;
    }

    .el-scrollbar__thumb,
    .el-scrollbar__bar {
      background-color: transparent !important;
    }
    .port-icon {
      top: 4px;
    }
  }
}
.small-item{
  margin-bottom: 0px !important;
}
</style>
