import type { VxeGridProps } from '#/adapter/vxe-table';

import { computed } from 'vue';

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

export const querySchema = computed(() => [
  {
    component: 'Input',
    fieldName: 'focusAddress',
    label: $t('abp.focus.focusAddress'),
  },
  {
    component: 'Input',
    fieldName: 'meterAddress',
    label: $t('abp.meters.meterAddress'),
  },
]);

export const tableSchema: any = computed((): VxeGridProps['columns'] => [
  { title: $t('common.seq'), type: 'seq', width: 50 },
  { field: 'dataBaseName', title: $t('abp.log.dataBaseName'), minWidth: '150' },
  {
    field: 'projectId',
    title: $t('abp.log.projectId'),
    minWidth: '150',
  },
  {
    field: 'meterAddress',
    title: $t('abp.meters.meterAddress'),
    minWidth: '150',
  },
  {
    field: 'focusAddress',
    title: $t('abp.focus.focusAddress'),
    minWidth: '100',
  },
  {
    field: 'deviceType',
    title: $t('abp.log.deviceType'),
    minWidth: '100',
    slots: { default: 'isdeviceType' },
  },
  {
    field: 'timestamps',
    title: $t('abp.log.timestamps'),
    minWidth: '100',
  },
  {
    field: 'manualOrNot',
    title: $t('abp.log.manualOrNot'),
    minWidth: '150',
    slots: { default: 'ismanualOrNot' },
  },
  {
    field: 'isTimeout',
    title: $t('abp.log.isTimeout'),
    minWidth: '150',
    slots: { default: 'isTimeout' },
  },
  { field: 'afn', title: $t('abp.log.afn'), minWidth: '150' },
  { field: 'fn', title: $t('abp.log.fn'), minWidth: '100' },
  { field: 'pn', title: $t('abp.log.pn'), minWidth: '100' },
  { field: 'itemCode', title: $t('abp.log.itemCode'), minWidth: '100' },
  {
    field: 'isSend',
    title: $t('abp.log.isSend'),
    minWidth: '150',
    slots: { default: 'isSend' },
  },
  {
    field: 'sendNum',
    title: $t('abp.log.sendNum'),
    minWidth: '100',
  },
  {
    field: 'nextSendTime',
    title: $t('abp.log.nextSendTime'),
    minWidth: '150',
  },
  {
    field: 'issuedMessageHexString',
    title: $t('abp.log.issuedMessageHexString'),
    minWidth: '150',
  },
  {
    field: 'receivedMessageHexString',
    title: $t('abp.log.receivedMessageHexString'),
    minWidth: '150',
  },
  {
    field: 'receivedTime',
    title: $t('abp.log.receivedTime'),
    minWidth: '150',
  },
  {
    field: 'isReceived',
    title: $t('abp.log.isReceived'),
    minWidth: '150',
    slots: { default: 'isReceived' },
  },
  {
    field: 'receivedRemark',
    title: $t('abp.log.receivedRemark'),
    minWidth: '150',
  },
]);
