<template>
  <div class="alarm-history-table">
    <BasicTable @register="registerTable" />
  </div>
</template>

<script lang="ts" name="system-user" setup>
  //ts语法
  import { BasicTable } from '/@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
  import { defHttp } from '/@/utils/http/axios';

  const list = (params) => defHttp.get({ url: '/ventanaly-device/safety/ventanalyAlarmLog/list', params });

  const props = defineProps({
    columnsType: {
      type: String,
      required: true,
    },
    deviceType: {
      type: String,
      required: true,
    },
    deviceListApi: {
      type: Function,
      required: true,
    },
    designScope: {
      type: String,
    },
  });

  const columns = getTableHeaderColumns(props.columnsType);
  // 列表页面公共参数、方法
  const { tableContext } = useListPage({
    tableProps: {
      api: list,
      columns: columns,
      canResize: true,
      showTableSetting: false,
      showActionColumn: false,
      bordered: false,
      size: 'small',
      formConfig: {
        labelAlign: 'left',
        showAdvancedButton: false,
        // autoAdvancedCol: 2,
        schemas: [
          {
            label: '时间范围',
            field: 'createTime',
            component: 'RangePicker',
            componentProps: {
              valueFormat: 'YYYY-MM-DD HH:mm:ss',
            },
          },
          {
            label: '查询设备',
            field: 'gdeviceid',
            component: 'ApiSelect',
            componentProps: {
              api: props.deviceListApi,
              resultField: 'records',
              labelField: 'strname',
              valueField: 'id',
            },
          },
        ],
        fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], '']],
      },
      fetchSetting: {
        listField: 'records',
      },
      pagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['5', '10', '20'],
      },
      beforeFetch(params) {
        params.gdevicetype = props.deviceType + '*';
      },
    },
  });
  //注册table数据
  const [registerTable] = tableContext;
</script>

<style scoped lang="less">
  :deep(.ant-table-body) {
    height: auto !important;
  }
  .alarm-history-table {
    width: 100%;
    :deep(.jeecg-basic-table-form-container) {
      .ant-form {
        padding: 0 !important;
        border: none !important;
        margin-bottom: 0 !important;
        .ant-picker,
        .ant-select-selector {
          width: 100% !important;
          background: #00000017;
          border: 1px solid #b7b7b7;
          input,
          .ant-select-selection-item,
          .ant-picker-suffix {
            color: #fff;
          }
          .ant-select-selection-placeholder {
            color: #ffffffaa;
          }
        }
      }
      .ant-table-title {
        min-height: 0 !important;
      }
    }
  }
</style>
