/*
 * @Description: 文件内容描述
 * @Author: 陈益
 * @Date: 2025-06-25 17:07:53
 * @LastEditors: 陈益
 */
import type { VxeGridProps } from '#/adapter/vxe-table';

import { computed } from 'vue';

import dayjs from 'dayjs';

import { $t } from '#/locales';

export const querySchema = computed(() => [
  {
    component: 'TableModelDeviceSelect',
    fieldName: 'deviceAddress',
    label: $t('abp.log.deviceInfo'),
    componentProps: {
      placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'),
      allowClear: true,
    },
  },
]);

export const tableSchema: any = computed((): VxeGridProps['columns'] => [
  { title: $t('common.seq'), type: 'seq', width: 50 },
  {
    field: 'timestampStr',
    title: $t('abp.IoTDBBase.Timestamps'),
    minWidth: 150,
    slots: {},
  },
  {
    field: 'formattedTimestamps',
    title: $t('abp.IoTDBBase.FormattedTimestamps'),
    minWidth: '150',
    formatter: ({ cellValue }) => {
      return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
    },
  },
  {
    field: 'ioTPlatformName',
    title: $t('common.BelongingIoTPlatform'),
    minWidth: '120',
    slots: { default: 'ioTPlatformName' },
  },
  {
    field: 'accountPhoneNumber',
    title: $t('common.BelongingAccountName'),
    minWidth: '120',
  },
  {
    field: 'ioTPlatformProductName',
    title: $t('common.BelongingProductName'),
    minWidth: '120',
  },
  {
    field: 'ioTPlatformDeviceOpenInfo',
    title: $t('abp.deviceInfos.ioTPlatformDeviceOpenInfo'),
    minWidth: '150',
  },
  {
    field: 'ioTDataType',
    title: $t('abp.IoTDBBase.IoTDataType'),
    minWidth: '120',
  },
  {
    field: 'deviceType',
    title: $t('abp.IoTDBBase.DeviceType'),
    minWidth: '120',
  },
  {
    field: 'deviceAddress',
    title: $t('abp.IoTDBBase.DeviceAddress'),
    minWidth: '120',
  },
  {
    field: 'messageType',
    title: $t('abp.CTWingLog.MessageType'),
    minWidth: '120',
  },
  {
    field: 'issueRawMessage',
    title: $t('abp.telemetryLog.IssueRawMessage'),
    minWidth: '200',
  },
  {
    field: 'issuePayload',
    title: $t('abp.telemetryLog.IssuePayload'),
    minWidth: '200',
  },
  {
    field: 'responseRawMessage',
    title: $t('abp.telemetryLog.ResponseRawMessage'),
    minWidth: '200',
  },
  {
    field: 'responsePayload',
    title: $t('abp.telemetryLog.ResponsePayload'),
    minWidth: '150',
  },
  {
    field: 'telemetrySourceName',
    title: $t('abp.telemetryLog.TelemetrySourceName'),
    minWidth: '120',
  },
]);
