dushibaiyu 6 éve
szülő
commit
acffbf9eb6

+ 3 - 0
JxcClient.pro

@@ -38,6 +38,7 @@ SOURCES += \
     struct_/packinfo.cpp \
     struct_/projectinfo.cpp \
     widget/addnewspecsform.cpp \
+    widget/editboxinfodialog.cpp \
     widget/fixedweightpackform.cpp \
     widget/loginform.cpp \
     main.cpp \
@@ -68,6 +69,7 @@ HEADERS += \
     struct_/packinfo.h \
     struct_/projectinfo.h \
     widget/addnewspecsform.h \
+    widget/editboxinfodialog.h \
     widget/fixedweightpackform.h \
     widget/loginform.h \
     mainwindow.h \
@@ -78,6 +80,7 @@ HEADERS += \
 
 FORMS += \
     widget/addnewspecsform.ui \
+    widget/editboxinfodialog.ui \
     widget/fixedweightpackform.ui \
     widget/loginform.ui \
     mainwindow.ui \

+ 21 - 0
globalinfo.cpp

@@ -34,6 +34,7 @@ bool GlobalInfo::addCacheInfo(QSharedPointer<ProjectInfo> & info)
     _cacheInfo.append(info);
     _project.insert(info->batch_no,info);
     packmanger->syncLocalProjectInfo(_cacheInfo);
+    return true;
 }
 
 
@@ -109,3 +110,23 @@ void GlobalInfo::dengJIConfigUp(const QList<DengJiConfigItem> & dengJis)
     _dengJiList = dengJis;
     emit dengJiUped();
 }
+
+
+QList<QSharedPointer<ProjectInfo>> GlobalInfo::searchProject(const QString & name)
+{
+    QList<QSharedPointer<ProjectInfo>> ret;
+    for(int i = 0; i < _cacheInfo.size(); ++i){
+        auto info = _cacheInfo.at(i);
+        if(info->batch_no.contains(name)){
+            ret.append(info);
+        }
+    }
+
+    for(int i = 0; i < _serverInfo.size(); ++i){
+        auto info = _serverInfo.at(i);
+        if(info->batch_no.contains(name)){
+            ret.append(info);
+        }
+    }
+    return ret;
+}

+ 2 - 0
globalinfo.h

@@ -30,6 +30,8 @@ public:
     inline QList<QSharedPointer<ProjectInfo>> serverInfo() {return _serverInfo;}
     inline QList<QSharedPointer<ProjectInfo>> cacheInfo() {return _cacheInfo;}
 
+    QList<QSharedPointer<ProjectInfo>> searchProject(const QString & name);
+
     bool addCacheInfo(QSharedPointer<ProjectInfo> & info);
     inline PackInfoManger * packInfoManger() {return packmanger;}
 

+ 4 - 0
handle/packinfomanger.h

@@ -13,6 +13,10 @@ struct PackSaveInfo
 {
     QSharedPointer<PackInfo> packInfo;
     QString absPath;
+
+    inline bool isSync() const{
+        return !absPath.contains("_sync");
+    }
 };
 
 class PackInfoManger : public QObject

+ 0 - 1
mainwindow.cpp

@@ -73,7 +73,6 @@ void MainWindow::FixedAndUncertain(QString batchno)
     ui->stackedWidget->setCurrentWidget(ui->pageAutoPack);
     ui->dingzhongButton->setChecked(true);
     ui->dingzhong->setProInfo(GlobalInfo::this_()->project().value(batchno));
-    ui->dingzhong->init();
 }
 
 void MainWindow::changedjmb(QImage image)

+ 3 - 1
struct_/packinfo.cpp

@@ -46,6 +46,7 @@ QString getDecimalbit(double v, int i)
 
 PackInfo::PackInfo(const QSharedPointer<ProjectInfo> & info) : _info(info)
 {
+    _boxIndex = 0;
     code_single = buildPackId();
     if(!info.isNull())
         goods_id = info->goods_id;
@@ -175,7 +176,8 @@ QString PackInfo::buildPackId()
 
 QString PackInfo::buildBoxId()
 {
-     int nowNum = boxes().size() + 1;
+    _boxIndex ++;
+     int nowNum = _boxIndex;
      QDateTime now = QDateTime::currentDateTime();
      QString id = now.toString("yyMMddhhmmss") + /*GlobalInfo::this_()->packNum() +*/ QString::asprintf("%03d",nowNum);
      return id;

+ 1 - 0
struct_/packinfo.h

@@ -96,6 +96,7 @@ private:
     QString code_single;
     int goods_id;
     qint64 _time;
+    int _boxIndex;
     static int lastMin;
     static int lastNum;
 };

+ 38 - 0
widget/editboxinfodialog.cpp

@@ -0,0 +1,38 @@
+#include "editboxinfodialog.h"
+#include "ui_editboxinfodialog.h"
+
+EditBoxInfoDialog::EditBoxInfoDialog(QSharedPointer<BoxInfo> &box, QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::EditBoxInfoDialog),_box(box)
+{
+    ui->setupUi(this);
+
+    ui->ts->setValue(_box->tube_number);
+    ui->tz->setValue(_box->bucket_weight / 1000.00);
+    ui->pz->setValue(_box->box_weight / 1000.00);
+    ui->netW->setValue(_box->net_weight / 1000.00);
+    ui->grossW->setValue(_box->gross_weight / 1000.0);
+}
+
+EditBoxInfoDialog::~EditBoxInfoDialog()
+{
+    delete ui;
+}
+
+
+
+void EditBoxInfoDialog::on_pushClose_clicked()
+{
+    this->close();
+}
+
+void EditBoxInfoDialog::on_pushSave_clicked()
+{
+    _box->tube_number = ui->ts->value();
+    _box->bucket_weight = ui->tz->value() * 1000;
+    _box->box_weight = ui->pz->value() * 1000;
+    _box->net_weight = ui->netW->value() * 1000;
+    _box->gross_weight = ui->grossW->value() * 1000;
+
+    this->close();
+}

+ 30 - 0
widget/editboxinfodialog.h

@@ -0,0 +1,30 @@
+#ifndef EDITBOXINFODIALOG_H
+#define EDITBOXINFODIALOG_H
+
+#include <QDialog>
+#include "struct_/packinfo.h"
+
+namespace Ui {
+class EditBoxInfoDialog;
+}
+
+//TODO:小宋,编辑箱号
+class EditBoxInfoDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit EditBoxInfoDialog(QSharedPointer<BoxInfo> & box,QWidget *parent = nullptr);
+    ~EditBoxInfoDialog();
+
+private slots:
+    void on_pushClose_clicked();
+
+    void on_pushSave_clicked();
+
+private:
+    Ui::EditBoxInfoDialog *ui;
+    QSharedPointer<BoxInfo> _box;
+};
+
+#endif // EDITBOXINFODIALOG_H

+ 89 - 0
widget/editboxinfodialog.ui

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditBoxInfoDialog</class>
+ <widget class="QDialog" name="EditBoxInfoDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>369</width>
+    <height>327</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>编辑箱单</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>毛重</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QDoubleSpinBox" name="grossW"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>净重</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QDoubleSpinBox" name="netW"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>桶数</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="label_4">
+     <property name="text">
+      <string>总桶重</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1">
+    <widget class="QDoubleSpinBox" name="tz"/>
+   </item>
+   <item row="4" column="0">
+    <widget class="QLabel" name="label_5">
+     <property name="text">
+      <string>皮重</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="1">
+    <widget class="QDoubleSpinBox" name="pz"/>
+   </item>
+   <item row="5" column="0">
+    <widget class="QPushButton" name="pushClose">
+     <property name="text">
+      <string>关闭</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="1">
+    <widget class="QPushButton" name="pushSave">
+     <property name="text">
+      <string>保存</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="QSpinBox" name="ts">
+     <property name="maximum">
+      <number>999999999</number>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 200 - 110
widget/fixedweightpackform.cpp

@@ -1,17 +1,18 @@
 #include "fixedweightpackform.h"
 #include "ui_fixedweightpackform.h"
 #include <pqQtlib/utils/pqfileutils.h>
+#include "editboxinfodialog.h"
 
 using namespace PQ;
 
 FixedWeightPackForm::FixedWeightPackForm(QWidget *parent) :
     QWidget(parent),
-    ui(new Ui::FixedWeightPackForm)
+    ui(new Ui::FixedWeightPackForm),packServer(nullptr),Manger(nullptr)
 {
     ui->setupUi(this);
-    QTimer *timer = new QTimer(this);
-    connect(timer,&QTimer::timeout,this,&FixedWeightPackForm::calcData);
-    timer->start(500);
+//    QTimer *timer = new QTimer(this);
+//    connect(timer,&QTimer::timeout,this,&FixedWeightPackForm::calcData);
+//    timer->start(500);
     connect(glo,&GlobalInfo::dbConfigUpdated,this,&FixedWeightPackForm::upconfig);
     connect(glo,&GlobalInfo::dengJiUped,this,&FixedWeightPackForm::upDengjiInfo);
     connect(glo,&GlobalInfo::doInited,this,&FixedWeightPackForm::changeSpecs);
@@ -22,8 +23,10 @@ FixedWeightPackForm::FixedWeightPackForm(QWidget *parent) :
         ui->taiPhone->setText(list.at(1));
     }
     ui->tableWidget_2->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
-    ui->pushStart->hide();
-    packServer = new PackInfoSeed2Server(Manger);
+//    packServer = new PackInfoSeed2Server(Manger);
+    // todo: 暂时隐藏同步
+    ui->pushNoSyncList->hide();
+    ui->pushSync->hide();
 }
 
 FixedWeightPackForm::~FixedWeightPackForm()
@@ -34,14 +37,17 @@ FixedWeightPackForm::~FixedWeightPackForm()
 //从秤中获取毛重、皮重、净重、筒数------每100毫秒一次
 void FixedWeightPackForm::calcData()
 {
+    double pz = ui->pizhong->currentText().toDouble();
+    double tz = ui->tongzhong->currentText().toDouble();
+    double ts = ui->tongshu->text().toDouble();
+    if(ui->showMaoZhong->isChecked()){
+        gross_weight = ui->grossWeight_2->text().toDouble();
+        netNum = gross_weight - pz - tz * ts;
 
-//    ui->grossWeight_2->setText(ui->type->currentText());
-    netNum = ui->grossWeight_2->text().toDouble()-ui->pizhong->currentText().toDouble()-ui->tongshu->text().toDouble()*ui->tongzhong->currentText().toDouble();
-    if(netNum<0){
-        netNum = 0.00;
+    } else {
+        netNum = ui->grossWeight_2->text().toDouble();
+        gross_weight = netNum + pz + ts*ts;
     }
-//    ui->netWeight_2->setText(QString::number(netNum));
-//    ui->tongshu->setText(QString::number(GlobalInfo::this_()->GetScaleData().tongshu));
 }
 
 
@@ -50,7 +56,6 @@ void FixedWeightPackForm::on_pushBack_clicked()
     emit back();
     QStringList list;
     list << ui->taitou->text() <<  ui->taiPhone->text();
-//    CacheFile f;
     PQ::CacheFile::writeFile("dingzhongInfo.cache",list.join("[,]").toUtf8());
 
 }
@@ -68,52 +73,32 @@ void FixedWeightPackForm::on_addPackList_clicked()
         packinfo->telephone = ui->taiPhone->text();
     }
 //    qDebug()<<packinfo->boxes().at(0)->tube_number;
-    packServer->send(packinfo);
-    GlobalInfo::this_()->packInfoManger()->savePackInfo(packinfo);
+    if(ui->autoSync->isChecked() && !GlobalInfo::this_()->isNoLine())
+        packServer->send(packinfo);
+    Manger->savePackInfo(packinfo);
 //    GlobalInfo::this_()->packInfoManger()->setPackInfoSync(packinfo->codeSingle(),packinfo->time(),true);
-    GlobalInfo::this_()->printerPack(packinfo);
-
-//    //把数据添加到数据库里
-//    aputils.insertProductSQL(packinfo);
-//    //TODO: 缓存箱单数据,页面显示情空
+    if(ui->madanPrint->isChecked())
+        GlobalInfo::this_()->printerPack(packinfo);
 
-//    //发送码单 packinfo 数据, 转换为 json数据发送
-//    aputils.doSend(aputils.toJson(packinfo));
-    //TODO: 初始化码单信息
     packinfo.clear();
 }
 
-void FixedWeightPackForm::on_pushStart_clicked()
-{
-//    _info.customer = ui->taitou->text();
-//    _info.telephone = ui->taiPhone->text();
-
-    if(ui->pushStart->isChecked()){
-        ui->pushStart->setChecked(true);
-        ui->addBoxList->setDisabled(false);
-        ui->addPackList->setDisabled(false);
-        ui->widget_2->setEnabled(false);
-        ui->pushPiLiang->setDisabled(false);
-    } else {
-//        init();
-    }
-}
-
 void FixedWeightPackForm::on_addBoxList_clicked()
 {
+    checkPackInfo(); //检查packinfo isNull
     //当当前箱数大于等于最大箱数是启动on_addPackList_clicked();
     if(packinfo->boxes().size() >= ui->comboBox->currentText().toInt()){
         on_addPackList_clicked();
+        checkPackInfo();
     }
 
-    setTableWidget();//检查packinfo isNull
-
+    auto index = packinfo->boxInfoSize();
     auto box = packinfo->addBoxInfo();
-
+    calcData();
     box->box_weight = int(ui->pizhong->currentText().toDouble()*1000);
     box->tube_number = ui->tongshu->text().toInt();
-    box->bucket_weight = int(ui->pizhong->currentText().toInt()*ui->tongshu->text().toDouble()*1000);
-    box->gross_weight = int(ui->grossWeight_2->text().toDouble()*1000);
+    box->bucket_weight = int(ui->tongzhong->currentText().toInt()*ui->tongshu->text().toDouble()*1000);
+    box->gross_weight = int(gross_weight*1000);
     box->net_weight = int(netNum*1000);
     box->Level = ui->dengji->currentText();
     box->twist_type = ui->nianxiang->currentText();
@@ -123,96 +108,95 @@ void FixedWeightPackForm::on_addBoxList_clicked()
     packinfo->level = ui->dengji->currentText();
     packinfo->level_id = ui->dengji->currentData().toInt();
 
-    ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1);
-    addTableWidget(box);
+    addTableWidget(box,index);
 
 
 //    把box数据添加到packinfo的boxes数据表里;
     packinfo->addBoxInfoList(box);
-    GlobalInfo::this_()->printerBox(box);
-
+    if(ui->xiangdanPrint->isChecked())
+        GlobalInfo::this_()->printerBox(box);
+    upSum();
     //添加数据库
 //    aputils.insertDetailsSQL(box,packinfo->codeSingle());
-    ui->labelTongZHong->setText(QString::number(packinfo->tube_number()));
-    ui->labelWight->setText(getDecimalbit(packinfo->gross_weight() / 1000.00));
-    ui->labelJing->setText(getDecimalbit(packinfo->net_weight() / 1000.00));
+
+}
+
+void FixedWeightPackForm::upSum()
+{
+    if(packinfo.isNull()){
+        ui->labelTongZHong->setText("0");
+        ui->labelWight->setText("0");
+        ui->labelJing->setText("0");
+    } else {
+        ui->labelTongZHong->setText(QString::number(packinfo->tube_number()));
+        ui->labelWight->setText(getDecimalbit(packinfo->gross_weight() / 1000.00));
+        ui->labelJing->setText(getDecimalbit(packinfo->net_weight() / 1000.00));
+    }
 }
 
 //检查packinfo isNull
-void FixedWeightPackForm::setTableWidget()
+void FixedWeightPackForm::checkPackInfo()
 {
     if(packinfo.isNull()){
         packinfo.reset(new PackInfo(_info));
         packinfo->operator_id = GlobalInfo::this_()->user().userId;
         packinfo->packing_time = QDate::currentDate().toString("yy-MM-dd");
         packinfo->packing_type = _info->category;
-        ui->tableWidget->clearContents();
-        ui->tableWidget->setRowCount(0);
-        ui->tableWidget->setColumnWidth(0,20);
-        ui->tableWidget->setColumnWidth(1,20);
-        ui->tableWidget->setColumnWidth(2,80);
-        ui->tableWidget->setColumnWidth(3,80);
-        ui->tableWidget->setColumnWidth(4,80);
-        ui->tableWidget->setColumnWidth(5,40);
+        packinfo->packType = 0;
+        restTableWidget();
     }
 }
 
 //往tablewidget里添加数据
-void FixedWeightPackForm::addTableWidget(QSharedPointer<BoxInfo> box)
+void FixedWeightPackForm::addTableWidget(QSharedPointer<BoxInfo> box, int row)
 {
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,0,new QTableWidgetItem(QString::number(ui->tableWidget->rowCount())));
-
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,1,new QTableWidgetItem(QString::number(box->tube_number)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,2,new QTableWidgetItem(getDecimalbit(box->gross_weight / 1000.00)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,3,new QTableWidgetItem(getDecimalbit(box->box_weight / 1000.00)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,4,new QTableWidgetItem(getDecimalbit(box->net_weight / 1000.00)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,5,new QTableWidgetItem(box->caseNumber()));
-
-    auto btn_1 = new QPushButton("删除");
-    auto btn_2 = new QPushButton("修改");
-    auto btn_3 = new QPushButton("补打");
+    ui->tableWidget->insertRow(row);
 
+    ui->tableWidget->setItem(row,0,new QTableWidgetItem(QString::number(box->tube_number)));
+    ui->tableWidget->setItem(row,1,new QTableWidgetItem(getDecimalbit(box->gross_weight / 1000.00)));
+    ui->tableWidget->setItem(row,2,new QTableWidgetItem(getDecimalbit(box->box_weight / 1000.00)));
+    ui->tableWidget->setItem(row,3,new QTableWidgetItem(getDecimalbit(box->net_weight / 1000.00)));
+    ui->tableWidget->setItem(row,4,new QTableWidgetItem(box->caseNumber()));
 
     QWidget *tmp_widget = new QWidget();
     QHBoxLayout *tmp_layout = new QHBoxLayout(tmp_widget);
+    auto btn_1 = new QPushButton("删除",tmp_widget);
+    auto btn_2 = new QPushButton("修改",tmp_widget);
+    auto btn_3 = new QPushButton("补打",tmp_widget);
     tmp_layout->addWidget(btn_1);
     tmp_layout->addWidget(btn_2);
     tmp_layout->addWidget(btn_3);
     tmp_layout->setMargin(0);
-    int i = ui->tableWidget->rowCount()-1;
+    int i = row;
     connect(btn_1,&QPushButton::clicked,[i,this](){this->del_clicked(i);});
+    connect(btn_2,&QPushButton::clicked,[i,this](){this->edit_clicked(i);});
     connect(btn_3,&QPushButton::clicked,[i,this](){this->Makeup_clicked(i);});
-    ui->tableWidget->setCellWidget(ui->tableWidget->rowCount()-1,6,tmp_widget);
+    ui->tableWidget->setCellWidget(row,5,tmp_widget);
 }
 
 void FixedWeightPackForm::init()
 {
-//    ui->pushStart->setChecked(false);
-//    ui->addBoxList->setDisabled(true);
-//    ui->addPackList->setDisabled(true);
-//    ui->pushPiLiang->setDisabled(true);
-//    ui->widget_2->setEnabled(true);
+    if(packServer == nullptr){
+        Manger = GlobalInfo::this_()->packInfoManger();
+        packServer = new PackInfoSeed2Server(Manger);
 
+    }
     ui->pizhong->setCurrentText(QString(_info->box_weight));
     ui->guanse->setCurrentText(_info->bucket_color);
     ui->zhixiang->setCurrentText(_info->carton_type);
     ui->tongzhong->setCurrentText(_info->bucket_weight);
-
-    ui->comboBox->clear();
-    for(int i = 1;i<=20;i++){
-        ui->comboBox->addItem(QString::number(i));
-    }
-    ui->comboBox->setCurrentText("20");
-    setTableWidget();
-//    specs.getInfo(0,20);
-//    setTableWidget();//检查packinfo isNull
+    restTableWidget();
 }
 
 void FixedWeightPackForm::upconfig()
 {
 
     DaBaoConfig config = glo->dbConfig();
-
+    // 码数
+    ui->comboBox->clear();
+    for(int i = 0; i < config.mashu.size(); ++i){
+        ui->comboBox->addItem(QString::number(config.mashu.at(i)));
+    }
     //机台
     ui->jitai->clear();
     ui->jitai->addItems(config.jitai);
@@ -244,12 +228,6 @@ void FixedWeightPackForm::upconfig()
     for(int i = 0;i<config.tongZhong.size();i++){
         ui->tongzhong->addItem(QString::number(config.tongZhong.at(i)));
     }
-
-    //设置选择打包界面的数据为首个;
-//    ui->pizhong->setCurrentText(QString(_info->box_weight));
-//    ui->guanse->setCurrentText(_info->bucket_color);
-//    ui->zhixiang->setCurrentText(_info->carton_type);
-//    ui->tongzhong->setCurrentText(_info->bucket_weight);
 }
 void FixedWeightPackForm::upDengjiInfo()
 {
@@ -265,9 +243,9 @@ void FixedWeightPackForm::upDengjiInfo()
 
 void FixedWeightPackForm::on_pushPiLiang_clicked()
 {
-    int tsize = 0;
-    if(!packinfo.isNull()) tsize = packinfo->boxes().size();
-    auto size = ui->comboBox->currentText().toInt() - tsize;
+//    int tsize = 0;
+//    if(!packinfo.isNull()) tsize = packinfo->boxes().size();
+    auto size = ui->spinBox->value();
     for(int i = 0; i < size; ++i){
         on_addBoxList_clicked();
     }
@@ -276,16 +254,28 @@ void FixedWeightPackForm::on_pushPiLiang_clicked()
 //获取品目信息
 void FixedWeightPackForm::on_searchButton_clicked()
 {
-//    specs.getInfo(0,20);
+    auto str = ui->lineEdit->text();
+    if(str.isEmpty()){
+        updateTableWidget(prolist);
+    } else {
+        auto list = GlobalInfo::this_()->searchProject(str);
+        updateTableWidget(list);
+    }
 }
 
 void FixedWeightPackForm::changeSpecs()
+{
+    prolist = GlobalInfo::this_()->project().values();
+    updateTableWidget(prolist);
+}
+
+void FixedWeightPackForm::updateTableWidget(QList<QSharedPointer<ProjectInfo>> & list)
 {
     ui->tableWidget_2->clearContents();
     ui->tableWidget_2->setRowCount(0);
-    prolist = GlobalInfo::this_()->project().values();
-    for(int i = 0; i < prolist.size(); ++i){
-        auto & v = prolist.at(i);
+    int currt = -1;
+    for(int i = 0; i < list.size(); ++i){
+        auto & v = list.at(i);
         ui->tableWidget_2->insertRow(i);
         auto xuanze_btn =  new QRadioButton();
         QString batchno = prolist.at(i)->batch_no;
@@ -295,31 +285,131 @@ void FixedWeightPackForm::changeSpecs()
         ui->tableWidget_2->setItem(i,2,new QTableWidgetItem(v->category));
         ui->tableWidget_2->setItem(i,3,new QTableWidgetItem(v->batch_no));
         ui->tableWidget_2->setItem(i,4,new QTableWidgetItem(v->color));
+        if(!_info.isNull() && _info->batch_no == v->batch_no){
+            xuanze_btn->setChecked(true);
+            currt = i;
+        }
     }
+    if(currt >= 0)
+        ui->tableWidget_2->setCurrentCell(currt,0);
+}
+
+void FixedWeightPackForm::setProInfo(const QSharedPointer<ProjectInfo> & info)
+{
+    _info = info;
+    if(!packinfo.isNull()){
+        packinfo->upInfo(_info);
+        packinfo->packing_type = _info->category;
+    }
+    init();
 }
 
 void FixedWeightPackForm::xuanZe_clicked(QString batchno)
 {
-//    setProInfo(specs.currtInfo.at(row));
-//    packConfig.refConfig();
-//    qDebug()<<batchno;
     setProInfo(GlobalInfo::this_()->project().value(batchno));
-    init();
 }
 
 void FixedWeightPackForm::del_clicked(int row)
 {
+    if(packinfo.isNull()) return;
     qDebug()<<row;
     packinfo->delBoxInfoAt(row);
-    ui->tableWidget->clear();
+    restTableWidget();
+}
+
+void FixedWeightPackForm::restTableWidget()
+{
+    ui->tableWidget->clearContents();
     ui->tableWidget->setRowCount(0);
-    for(int i = 0;i<packinfo->boxInfoSize();i++){
-        ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1);
-        addTableWidget(packinfo->boxInfoAt(row));
+    ui->tableWidget->setColumnWidth(0,20);
+    ui->tableWidget->setColumnWidth(1,20);
+    ui->tableWidget->setColumnWidth(2,80);
+    ui->tableWidget->setColumnWidth(3,80);
+    ui->tableWidget->setColumnWidth(4,200);
+    ui->tableWidget->setColumnWidth(5,200);
+    if(!packinfo.isNull()){
+        for(int i =  0; i < packinfo->boxInfoSize(); ++i){
+            addTableWidget(packinfo->boxInfoAt(i),i);
+        }
     }
+    upSum();
 }
 
 void FixedWeightPackForm::Makeup_clicked(int row)
 {
+    if(packinfo.isNull()) return;
+    auto box =  packinfo->boxInfoAt(row);
+    GlobalInfo::this_()->printerBox(box);
+}
 
+
+void FixedWeightPackForm::edit_clicked(int row)
+{
+    if(packinfo.isNull()) return;
+    auto box =  packinfo->boxInfoAt(row);
+    EditBoxInfoDialog dig(box,this);
+    dig.exec();
+    restTableWidget();
+}
+
+void FixedWeightPackForm::on_pushContinue_clicked()
+{
+    auto dt = QDate::currentDate();
+    auto list = Manger->getPackInfo(dt);
+    if(list.isEmpty()){
+        dt = dt.addDays(-1);
+        list = Manger->getPackInfo(dt);
+    }
+    if(list.isEmpty()){
+        QMessageBox::warning(this,tr("无可接续码单"),tr("无可接续码单"));
+    }
+    std::sort(list.begin(),list.end(),[](const PackSaveInfo & item1, const PackSaveInfo & item2){
+        return item1.packInfo->time() < item2.packInfo->time();
+    });
+    QSharedPointer<PackInfo> pInfo;
+    for (int i = list.size() - 1;i >= 0 ; --i) {
+        auto & v = list.at(i);
+        if(v.packInfo->packType != 0) continue;
+        if(v.packInfo->boxInfoSize() < ui->comboBox->currentText().toInt()){
+            pInfo = v.packInfo;
+            break;
+        }
+    }
+    if(pInfo.isNull()){
+        QMessageBox::warning(this,tr("无可接续码单"),tr("无可接续码单"));
+    }
+    packinfo = pInfo;
+    setProInfo(packinfo->info());
+}
+
+void FixedWeightPackForm::on_showMaoZhong_stateChanged(int )
+{
+    if(ui->showMaoZhong->isChecked()){
+        ui->labelWidget->setText(tr("毛重"));
+    } else {
+        ui->labelWidget->setText(tr("净重"));
+    }
+}
+
+void FixedWeightPackForm::on_pushEditBatch_clicked()
+{
+    if(packinfo.isNull()) return;
+    for(int i =  0; i < packinfo->boxInfoSize(); ++i){
+        auto box = packinfo->boxInfoAt(i);
+        calcData();
+        box->box_weight = int(ui->pizhong->currentText().toDouble()*1000);
+        box->tube_number = ui->tongshu->text().toInt();
+        box->bucket_weight = int(ui->pizhong->currentText().toInt()*ui->tongshu->text().toDouble()*1000);
+        box->gross_weight = int(gross_weight*1000);
+        box->net_weight = int(netNum*1000);
+        box->Level = ui->dengji->currentText();
+        box->twist_type = ui->nianxiang->currentText();
+        box->bucket_color = ui->guanse->currentText();
+        box->sort = "1";
+//        box->remark = ui->beizhu->toPlainText();
+
+    }
+    packinfo->level = ui->dengji->currentText();
+    packinfo->level_id = ui->dengji->currentData().toInt();
+    restTableWidget();
 }

+ 17 - 9
widget/fixedweightpackform.h

@@ -20,13 +20,11 @@ public:
     explicit FixedWeightPackForm(QWidget *parent = nullptr);
     ~FixedWeightPackForm();
 
-    inline void setProInfo(const QSharedPointer<ProjectInfo> & info){_info = info;}
+    void setProInfo(const QSharedPointer<ProjectInfo> & info);
 
 private slots:
     void on_pushBack_clicked();
 
-    void on_pushStart_clicked();
-
     void on_addBoxList_clicked();
 
     void on_addPackList_clicked();
@@ -37,19 +35,28 @@ private slots:
 
     void on_searchButton_clicked();
 
+    void on_pushContinue_clicked();
+
+    void on_showMaoZhong_stateChanged(int);
+
+    void on_pushEditBatch_clicked();
+
 public slots:
     void upconfig(/*const DaBaoConfig & config*/);
     void upDengjiInfo(/*const QList<DengJiConfigItem> & dengJis*/);
-    void init();
     void changeSpecs();
     void xuanZe_clicked(QString batchno);
     void del_clicked(int row);
     void Makeup_clicked(int row);
+    void edit_clicked(int row);
 
-public:
-    void setTableWidget();
-    void addTableWidget(QSharedPointer<BoxInfo> box);
-
+private:
+    void init();
+    void checkPackInfo();
+    void addTableWidget(QSharedPointer<BoxInfo> box, int row);
+    void restTableWidget();
+    void updateTableWidget(QList<QSharedPointer<ProjectInfo>> & list);
+    void upSum();
 signals:
     void back();
 
@@ -64,9 +71,10 @@ private:
 
     GlobalInfo * glo = GlobalInfo::this_();
     PackInfoSeed2Server *packServer;
-    PackInfoManger *Manger = GlobalInfo::this_()->packInfoManger();
+    PackInfoManger *Manger;// = GlobalInfo::this_()->packInfoManger();
 
     double netNum = 0.00;
+    double gross_weight = 0.0;
     int row;
 };
 

+ 35 - 44
widget/fixedweightpackform.ui

@@ -93,23 +93,33 @@
           <item row="0" column="2">
            <layout class="QGridLayout" name="gridLayout_2">
             <item row="0" column="0">
-             <widget class="QPushButton" name="pushButton">
+             <widget class="QPushButton" name="pushNoSyncList">
               <property name="text">
                <string>未同步列表</string>
               </property>
              </widget>
             </item>
+            <item row="0" column="3">
+             <widget class="QPushButton" name="pushContinue">
+              <property name="text">
+               <string>接续</string>
+              </property>
+             </widget>
+            </item>
             <item row="0" column="1">
-             <widget class="QPushButton" name="pushButton_2">
+             <widget class="QCheckBox" name="autoSync">
               <property name="text">
-               <string>同步</string>
+               <string>自动同步</string>
+              </property>
+              <property name="checked">
+               <bool>true</bool>
               </property>
              </widget>
             </item>
             <item row="0" column="2">
-             <widget class="QPushButton" name="pushButton_3">
+             <widget class="QPushButton" name="pushSync">
               <property name="text">
-               <string>接续</string>
+               <string>同步</string>
               </property>
              </widget>
             </item>
@@ -150,11 +160,6 @@
                 <height>16777215</height>
                </size>
               </property>
-              <column>
-               <property name="text">
-                <string>序号</string>
-               </property>
-              </column>
               <column>
                <property name="text">
                 <string>筒数</string>
@@ -180,6 +185,11 @@
                 <string>箱号</string>
                </property>
               </column>
+              <column>
+               <property name="text">
+                <string>操作</string>
+               </property>
+              </column>
               <column>
                <property name="text">
                 <string/>
@@ -219,7 +229,7 @@
         <item row="0" column="0">
          <layout class="QGridLayout" name="gridLayout_9">
           <item row="0" column="0">
-           <widget class="QLabel" name="label_23">
+           <widget class="QLabel" name="labelWidget">
             <property name="minimumSize">
              <size>
               <width>31</width>
@@ -380,32 +390,6 @@ color: rgb(0, 170, 255);</string>
           </item>
           <item row="0" column="1">
            <layout class="QHBoxLayout" name="horizontalLayout_3">
-            <item>
-             <widget class="QPushButton" name="pushStart">
-              <property name="minimumSize">
-               <size>
-                <width>136</width>
-                <height>50</height>
-               </size>
-              </property>
-              <property name="maximumSize">
-               <size>
-                <width>999</width>
-                <height>50</height>
-               </size>
-              </property>
-              <property name="styleSheet">
-               <string notr="true">background-color: rgb(255, 255, 255);
-color: rgb(0, 170, 255);</string>
-              </property>
-              <property name="text">
-               <string>开始打包</string>
-              </property>
-              <property name="checkable">
-               <bool>true</bool>
-              </property>
-             </widget>
-            </item>
             <item>
              <widget class="QPushButton" name="pushPiLiang">
               <property name="sizePolicy">
@@ -724,6 +708,13 @@ color: rgb(0, 170, 255);</string>
         </item>
         <item row="4" column="0">
          <layout class="QGridLayout" name="gridLayout_7">
+          <item row="0" column="1">
+           <widget class="QLineEdit" name="lineEdit">
+            <property name="placeholderText">
+             <string>请输入批号</string>
+            </property>
+           </widget>
+          </item>
           <item row="0" column="0">
            <widget class="QLabel" name="label_5">
             <property name="font">
@@ -736,13 +727,6 @@ color: rgb(0, 170, 255);</string>
             </property>
            </widget>
           </item>
-          <item row="0" column="1">
-           <widget class="QLineEdit" name="lineEdit">
-            <property name="placeholderText">
-             <string>请输入批号</string>
-            </property>
-           </widget>
-          </item>
           <item row="0" column="2">
            <widget class="QPushButton" name="searchButton">
             <property name="text">
@@ -763,6 +747,13 @@ color: rgb(0, 170, 255);</string>
             </property>
            </spacer>
           </item>
+          <item row="0" column="4">
+           <widget class="QPushButton" name="pushEditBatch">
+            <property name="text">
+             <string>批量修改</string>
+            </property>
+           </widget>
+          </item>
          </layout>
         </item>
         <item row="5" column="0">

+ 0 - 1
widget/selectvalueform.cpp

@@ -8,7 +8,6 @@ SelectValueForm::SelectValueForm(QWidget *parent) :
 {
     ui->setupUi(this);
     connect(&_request,&HttpRequest::result,this,&SelectValueForm::result);
-    ui->widget->hide();
     nowPage = 0;
     connect(glo,&GlobalInfo::doInited,this,&SelectValueForm::Start);
 }

+ 0 - 148
widget/selectvalueform.ui

@@ -144,154 +144,6 @@
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_9">
-     <item>
-      <widget class="QWidget" name="widget" native="true">
-       <property name="minimumSize">
-        <size>
-         <width>211</width>
-         <height>491</height>
-        </size>
-       </property>
-       <property name="styleSheet">
-        <string notr="true">background-color: rgb(255, 255, 255);</string>
-       </property>
-       <widget class="QPushButton" name="pushButton">
-        <property name="geometry">
-         <rect>
-          <x>60</x>
-          <y>290</y>
-          <width>91</width>
-          <height>31</height>
-         </rect>
-        </property>
-        <property name="styleSheet">
-         <string notr="true"/>
-        </property>
-        <property name="text">
-         <string>搜索</string>
-        </property>
-        <property name="icon">
-         <iconset>
-          <normaloff>:/image/sousuo.png</normaloff>:/image/sousuo.png</iconset>
-        </property>
-        <property name="iconSize">
-         <size>
-          <width>124</width>
-          <height>32</height>
-         </size>
-        </property>
-       </widget>
-       <widget class="QWidget" name="layoutWidget_2">
-        <property name="geometry">
-         <rect>
-          <x>0</x>
-          <y>10</y>
-          <width>191</width>
-          <height>239</height>
-         </rect>
-        </property>
-        <layout class="QVBoxLayout" name="verticalLayout">
-         <item>
-          <widget class="QLabel" name="label">
-           <property name="text">
-            <string>筛选</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout">
-           <item>
-            <widget class="QLabel" name="label_2">
-             <property name="text">
-              <string>旦数</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QComboBox" name="comboBox">
-             <property name="styleSheet">
-              <string notr="true">background-color: rgb(255, 255, 255,0);</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout_2">
-           <item>
-            <widget class="QLabel" name="label_3">
-             <property name="text">
-              <string>分特</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QComboBox" name="comboBox_2">
-             <property name="styleSheet">
-              <string notr="true">background-color: rgb(255, 255, 255,0);</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout_3">
-           <item>
-            <widget class="QLabel" name="label_4">
-             <property name="text">
-              <string>孔数</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QComboBox" name="comboBox_3">
-             <property name="styleSheet">
-              <string notr="true">background-color: rgb(255, 255, 255,0);</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout_4">
-           <item>
-            <widget class="QLabel" name="label_5">
-             <property name="text">
-              <string>类型</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QComboBox" name="comboBox_4">
-             <property name="styleSheet">
-              <string notr="true">background-color: rgb(255, 255, 255,0);</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout_5">
-           <item>
-            <widget class="QLabel" name="label_6">
-             <property name="text">
-              <string>机台</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QComboBox" name="comboBox_5">
-             <property name="styleSheet">
-              <string notr="true">background-color: rgb(255, 255, 255,0);</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-        </layout>
-       </widget>
-      </widget>
-     </item>
      <item>
       <layout class="QVBoxLayout" name="verticalLayout_2">
        <property name="spacing">