#ifndef EQUIPMENTPAGE_H
#define EQUIPMENTPAGE_H

#include <QWidget>
#include <QStandardItemModel>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include "../buttondelegate.h"
#include "../HttpClient.h"
#include "../PageWidget.h"

namespace Ui {
class EquipmentPage;
}

class EquipmentPage : public QWidget
{
    Q_OBJECT

public:
    explicit EquipmentPage(QWidget *parent = nullptr);
    ~EquipmentPage();
private slots:
    void on_btnSearch_clicked();

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

private:
    Ui::EquipmentPage *ui;
    PageWidget *m_pPageWidget;
    int pageSize;  //每页显示的记录数量
    int currentPage;      //当前页面
    int totalCount;
    QString *equipmentSn;
    HttpClient *m_httpClient;
    QStandardItemModel *model;
    QJsonArray dataArray;

};

#endif // EQUIPMENTPAGE_H
