import React, { useEffect, useMemo, useRef, useState } from "react";
import { Dropdown, Menu, Button, message } from "antd";
import AutoTable from "@/components/AutoTable";
import { doFetch } from "@/utils/doFetch";
import DrawInitForm from "@/components/DrawInitForm";
import getPrem from "@/utils/getPrem"; //权限判断fn
import { useReactToPrint } from "react-to-print";
import { useModel } from "umi";

function Errormange(props) {
  const { initialState, setInitialState } = useModel("@@initialState");
  const [activeTabKey, onTabChange] = useState("1");
  const [selectKeys, setSelectKeys] = useState([]);

  let [drawprops, setdrawprops] = useState({
      title: "",
      visible: false,
      onClose: () => {
        setdrawprops((s) => ({
          ...s,
          visible: false,
          fields: {},
        }));
      },
      fields: {},
      width: 1200,
    }),
    actionRef = useRef(),
    ChildRef = null,
    printRef = useRef(),
    mutiPrintRef = useRef();

  //操作完成后刷新
  function reload() {
    actionRef.current.reload();
    ChildRef?.onRefresh();
    message.success("操作成功");
    setdrawprops((s) => ({
      ...s,
      visible: false,
      fields: {},
    }));
  }


  const columns = useMemo(() => {
    return [
      {
        title: "设备编号",
        dataIndex: "requestEquipment",
        key: "requestEquipment",
      },
      {
        title: "错误代码",
        dataIndex: "requestErrorCode",
        search: false,
        key: "requestErrorCode",
      },
      {
        title: "错误说明",
        dataIndex: "requestErrorMsg",
        search: false,
        key: "requestErrorMsg",
      },
      {
        title: "请求时间",
        dataIndex: "apiSendTime",
        key: "apiSendTime",
        search: false,
      },
      
    ];
  }, [activeTabKey]);

  const tableprops = {
    ...props,
    columns,
    path: "/ngic-workmanship/alarmReport/queryList",
  };

  return (
    <div>
      <AutoTable
        {...tableprops}
        actionRef={actionRef}
        onRef={(node) => (ChildRef = node)}
      ></AutoTable>
    </div>
  );
}

export default Errormange;
