#ifndef DETINFOPAGE_H
#define DETINFOPAGE_H

#include <QWidget>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrlQuery>
#include <QEventLoop>
#include <QStandardItemModel>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include <QLabel>
#include <QMoveEvent>
#include "detdialog.h"
#include "../global.h"
#include "../PageWidget.h"
#include "../HttpClient.h"

namespace Ui {
class DetInfoPage;
}

class DetInfoPage : public QWidget
{
    Q_OBJECT

public:
    explicit DetInfoPage(QWidget *parent = nullptr);
    ~DetInfoPage();
    void insertDet(const QJsonDocument &jsonDoc);


private slots:
    void on_pushButton_clicked();


private:
    void loadAndRefreshData();
    void PageChanged(int page);
    void onComboBoxIndexChanged(int index);
    void dataTable(const QJsonDocument &jsonDoc);
    void loadDataFromSource(int currentPage, int pageSize, const QString& equipmentSn="");
    QList<QStandardItem *> jsonToItem(const QJsonObject &jsonObj);
    void parseJsonString(const QJsonDocument &jsonDoc);

private:
    Ui::DetInfoPage *ui;
    DetDialog *dialog;
    PageWidget *m_pPageWidget;
    int pageSize;  //每页显示的记录数量
    int currentPage;      //当前页面
    int totalCount;
    QString *equipmentSn;
    HttpClient *m_httpClient;
    QStandardItemModel *model;
    QJsonArray dataArray;
    QLabel *loadingLabel;  // 用于显示加载图片的标签
    QPoint lastPos;

};

#endif // DETINFOPAGE_H
