#ifndef FIXEDWEIGHTPACKFORM_H
#define FIXEDWEIGHTPACKFORM_H

#include <QWidget>
#include "handle/remotepackconfig.h"
#include "QTimer"
#include "globalinfo.h"
#include "handle/packinfoseed2server.h"
#include "handle/packinfomanger.h"

namespace Ui {
class FixedWeightPackForm;
}

class FixedWeightPackForm : public QWidget
{
    Q_OBJECT

public:
    explicit FixedWeightPackForm(QWidget *parent = nullptr);
    ~FixedWeightPackForm();

    void setProInfo(const QSharedPointer<ProjectInfo> & info);
    inline void setAutoSync(const bool sync){AutoSync = sync;}
    void setShortcutConfig();
private slots:
    void on_addBoxList_clicked();

    void on_addPackList_clicked();

    void calcData();

    void on_pushPiLiang_clicked();

    void on_searchButton_clicked();

    void on_pushContinue_clicked();

    void on_showMaoZhong_stateChanged(int);

    void on_pushEditBatch_clicked();

    void on_pushNoSyncList_clicked();

    void on_pushSync_clicked();

    void on_buding_clicked();

    void on_backButton_clicked();

    void on_ruku_stateChanged(int arg1);

    void on_useNewDataButton_clicked();


public slots:
    void upconfig(/*const DaBaoConfig & config*/);
    void upDengjiInfo(/*const QList<DengJiConfigItem> & dengJis*/);
    void changeSpecs();
    void upWare();
    void upBoxModelList();//获取箱单模板
    void upPackModelList();//获取码单模板

    void save(); // 程序关闭的时候调用，保存当前未完成的码单
private:

    void xuanZe_clicked(QString batchno);
    void del_clicked(int row);
    void Makeup_clicked(int row);
    void edit_clicked(int row);
    void init();
    void checkPackInfo();//检查packinfo isNull
    void addTableWidget(QSharedPointer<BoxInfo> box, int row);
    void restTableWidget();
    void updateTableWidget(QList<QSharedPointer<ProjectInfo>> & list);
    void upSum();
    void EditBatch();

signals:
    void back();
    void backup(int i);
    void NoSyncList();
    void buding();

private:
    Ui::FixedWeightPackForm *ui;
    QSharedPointer<ProjectInfo> _info;
    QSharedPointer<PackInfo> packinfo;
    QMap<QString,DengJiConfigItem> dengjiMap;// <name,详细信息>
    HttpRequest _request;
    QList<QSharedPointer<ProjectInfo>> prolist;

    GlobalInfo * glo = GlobalInfo::this_();
    PackInfoSeed2Server *packServer;
    PackInfoManger *Manger;// = GlobalInfo::this_()->packInfoManger();

    double netNum = 0.00;
    double gross_weight = 0.00;
    float f_netNum = 0.0;
    float f_gross_weight = 0.0;
    int row;
    bool AutoSync = true;
    bool isRuku = false;

    int chengZhongJingDu;
    int chengZhongJingDuModel;
    double chengZhongJingDuModel_Num = 0.005;//打包精度计算时所需的数，类似四舍五入时把double+0.5在向下取整；
    double f_chengZhongJingDuModel_Num = 0.05;//单精度计算时的数；
};

#endif // FIXEDWEIGHTPACKFORM_H
