Explorar o código

添加模板功能,按网站修改精度

error %!s(int64=6) %!d(string=hai) anos
pai
achega
e5cbff6487
Modificáronse 42 ficheiros con 3608 adicións e 1505 borrados
  1. 5 0
      JxcClient.pro
  2. 33 0
      globalinfo.cpp
  3. 13 0
      globalinfo.h
  4. 44 0
      handle/packinfomanger.cpp
  5. 11 0
      handle/packinfomanger.h
  6. 9 44
      handle/packinfoseed2server.cpp
  7. 3 5
      handle/packinfoseed2server.h
  8. 5 2
      handle/printer/baseboxprinter.h
  9. 329 28
      handle/printer/boxtemlateone.cpp
  10. 11 2
      handle/printer/boxtemlateone.h
  11. 29 1
      handle/printer/printermanger.cpp
  12. 4 0
      handle/printer/printermanger.h
  13. 2 0
      handle/printerthreadhandle.cpp
  14. 2 0
      handle/printerthreadhandle.h
  15. 1 0
      images.qrc
  16. BIN=BIN
      images/Pmoren.bmp
  17. 45 27
      mainwindow.cpp
  18. 8 11
      mainwindow.h
  19. 28 2
      mainwindow.ui
  20. 129 0
      struct_/modelinfo.cpp
  21. 70 0
      struct_/modelinfo.h
  22. 2 0
      struct_/packinfo.cpp
  23. 3 0
      struct_/packinfo.h
  24. 8 8
      struct_/projectinfo.h
  25. 131 20
      widget/fixedweightpackform.cpp
  26. 12 1
      widget/fixedweightpackform.h
  27. 717 566
      widget/fixedweightpackform.ui
  28. 11 4
      widget/loginform.cpp
  29. 228 0
      widget/modelselectform.cpp
  30. 74 0
      widget/modelselectform.h
  31. 259 0
      widget/modelselectform.ui
  32. 2 2
      widget/packdetailform.cpp
  33. 4 0
      widget/selectvalueform.cpp
  34. 246 0
      widget/showmadanlabelform.cpp
  35. 37 0
      widget/showmadanlabelform.h
  36. 376 404
      widget/showmadanlabelform.ui
  37. 168 95
      widget/showxiangdanlabelform.cpp
  38. 37 28
      widget/showxiangdanlabelform.h
  39. 156 99
      widget/showxiangdanlabelform.ui
  40. 116 16
      widget/uncertainweightpackform.cpp
  41. 15 1
      widget/uncertainweightpackform.h
  42. 225 139
      widget/uncertainweightpackform.ui

+ 5 - 0
JxcClient.pro

@@ -36,6 +36,7 @@ SOURCES += \
     handle/seriport/assictscalet2000.cpp \
     handle/seriport/serialbasehandle.cpp \
     handle/serialthreadhandle.cpp \
+    struct_/modelinfo.cpp \
     struct_/packinfo.cpp \
     struct_/projectinfo.cpp \
     widget/addnewspecsform.cpp \
@@ -45,6 +46,7 @@ SOURCES += \
     widget/loginform.cpp \
     main.cpp \
     mainwindow.cpp \
+    widget/modelselectform.cpp \
     widget/packdetailform.cpp \
     widget/selectvalueform.cpp \
     widget/settingsform.cpp \
@@ -72,6 +74,7 @@ HEADERS += \
     handle/seriport/assictscalet2000.h \
     handle/seriport/serialbasehandle.h \
     handle/serialthreadhandle.h \
+    struct_/modelinfo.h \
     struct_/packinfo.h \
     struct_/projectinfo.h \
     widget/addnewspecsform.h \
@@ -80,6 +83,7 @@ HEADERS += \
     widget/fixedweightpackform.h \
     widget/loginform.h \
     mainwindow.h \
+    widget/modelselectform.h \
     widget/packdetailform.h \
     widget/selectvalueform.h \
     widget/settingsform.h \
@@ -95,6 +99,7 @@ FORMS += \
     widget/fixedweightpackform.ui \
     widget/loginform.ui \
     mainwindow.ui \
+    widget/modelselectform.ui \
     widget/packdetailform.ui \
     widget/selectvalueform.ui \
     widget/settingsform.ui \

+ 33 - 0
globalinfo.cpp

@@ -52,6 +52,23 @@ void GlobalInfo::start(UserInfo & user,bool online)
     } else {
         _projectmanger->loadServerList(false);
     }
+    selectBoxModel();
+    selectPackModel();
+}
+
+void GlobalInfo::selectBoxModel()
+{
+    boxModelList =  packmanger->getBoxModel();
+    emit boxModelUped();
+}
+
+void GlobalInfo::selectPackModel()
+{
+    packModelList = packmanger->getPackModel();
+//    for(int i = 0;i<packModelList.size();i++){
+//        qDebug()<<packModelList.at(i)->toObject();
+//    }
+    emit packModelUpde();
 }
 
 void GlobalInfo::initInfo()
@@ -81,6 +98,14 @@ void GlobalInfo::printerBox(QSharedPointer<BoxInfo> info)
     }
 }
 
+void GlobalInfo::printerBoxModel(QSharedPointer<BoxInfo> info,int ModelIndex)
+{
+    if(_printer){
+//        qDebug()<<"this";
+        emit _printer->printerBoxModel(info,ModelIndex);
+    }
+}
+
 void GlobalInfo::doSync(QDate & tm)
 {
     if(_syncPack == nullptr || isNoLine()) return;
@@ -94,6 +119,14 @@ void GlobalInfo::printerPack(QSharedPointer<PackInfo> info)
     }
 }
 
+void GlobalInfo::printerPackModel(QSharedPointer<PackInfo> info,int ModelIndex)
+{
+    if(_printer){
+//        qDebug()<<"this";
+        emit _printer->printerPackModel(info,ModelIndex);
+    }
+}
+
 
 void GlobalInfo::syncProject(ProjectInfoManger * manger, bool )
 {

+ 13 - 0
globalinfo.h

@@ -12,6 +12,7 @@
 #include "handle/remotepackconfig.h"
 #include "handle/projectinfomanger.h"
 #include "handle/autosyncpackinfo.h"
+#include "struct_/modelinfo.h"
 
 class GlobalInfo : public QObject
 {
@@ -52,9 +53,15 @@ public:
     inline const QList<DengJiConfigItem> & dengJiList() {return _dengJiList;}
     //仓库配置
     inline const QList<WarehouseConfig> & wareList() {return _wareList;}
+    //箱单模板
+    inline const QList<QSharedPointer<BoxModel>> & BoxModelList() {return boxModelList;}
+    //码单模板
+    inline const QList<QSharedPointer<PackModel>> & PackModelList() {return packModelList;}
 
     void printerBox(QSharedPointer<BoxInfo> info);
+    void printerBoxModel(QSharedPointer<BoxInfo> info,int ModelIndex);
     void printerPack(QSharedPointer<PackInfo> info);
+    void printerPackModel(QSharedPointer<PackInfo> info,int ModelIndex);
 
     // 同步调用
     void doSync(QDate & tm);
@@ -66,8 +73,12 @@ signals:
     void doInited();
     void logOuted();
     void wareUped();
+    void boxModelUped();
+    void packModelUpde();
 public slots:
     void start(UserInfo & user,bool online);
+    void selectBoxModel();
+    void selectPackModel();
 
 private slots:
     void syncProject(ProjectInfoManger * manger, bool inited);
@@ -83,6 +94,8 @@ private:
     DaBaoConfig _dbConfig;
     QList<DengJiConfigItem> _dengJiList;
     QList<WarehouseConfig> _wareList;
+    QList<QSharedPointer<BoxModel>> boxModelList;
+    QList<QSharedPointer<PackModel>> packModelList;
 
     void initInfo();
 private:

+ 44 - 0
handle/packinfomanger.cpp

@@ -90,6 +90,50 @@ QList<PackSaveInfo> PackInfoManger::getPackInfo(const QDate & tm,bool noSync)
     return ret;
 }
 
+QList<QSharedPointer<BoxModel>> PackInfoManger::getBoxModel()
+{
+    auto dir =PQ::AppPath::this_()->dataDir();
+    if(!dir.exists("BoxModel")){
+        dir.mkdir("BoxModel");
+    }
+    dir.cd("BoxModel");
+
+    auto list  = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files);
+    QList<QSharedPointer<BoxModel>> ret;
+    for(int i = 0; i < list.size(); ++i){
+        auto & finfo = list.at(i);
+        auto obj = QJsonDocument::fromJson(readAbsoluteFile(finfo.absoluteFilePath())).object();
+        auto info = BoxModel::fromObject(obj);
+        if(!info.isNull()){
+            ret.append(info);
+        }
+    }
+    return ret;
+}
+
+QList<QSharedPointer<PackModel>> PackInfoManger::getPackModel()
+{
+    auto dir =PQ::AppPath::this_()->dataDir();
+    if(!dir.exists("PackModel")){
+        dir.mkdir("PackModel");
+    }
+    dir.cd("PackModel");
+
+//    QList<QSharedPointer<PackModel>> packmodel;
+
+    auto list  = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files);
+    QList<QSharedPointer<PackModel>> ret;
+    for(int i = 0; i < list.size(); ++i){
+        auto & finfo = list.at(i);
+        auto obj = QJsonDocument::fromJson(readAbsoluteFile(finfo.absoluteFilePath())).object();
+        auto info = PackModel::fromObject(obj);
+        if(!info.isNull()){
+            ret.append(info);
+        }
+    }
+    return ret;
+}
+
 QList<PackSaveInfo> PackInfoManger::getPackInfoSync(const QDate &tm)
 {
     auto dir = getDir(tm);

+ 11 - 0
handle/packinfomanger.h

@@ -6,6 +6,7 @@
 #include <QList>
 #include <QDate>
 #include "struct_/packinfo.h"
+#include "struct_/modelinfo.h"
 // 管理本地码单(箱单) 的类
 // 管理本地批号的类
 
@@ -19,6 +20,12 @@ struct PackSaveInfo
     }
 };
 
+struct BoxModelSaveInfo
+{
+    QSharedPointer<BoxModel> boxModel;
+};
+
+
 class PackInfoManger : public QObject
 {
     Q_OBJECT
@@ -38,6 +45,10 @@ public slots:
     QString setPackInfoSync(const QString & code, qint64 time = -1,bool autoSync = false);
 
     bool syncLocalProjectInfo(QList<QSharedPointer<ProjectInfo>> & projects);
+
+    QList<QSharedPointer<BoxModel>> getBoxModel();
+
+    QList<QSharedPointer<PackModel>> getPackModel();
 private:
     QDir getDir(const QDate & tm,bool create = false);
 private:

+ 9 - 44
handle/packinfoseed2server.cpp

@@ -7,16 +7,13 @@ PackInfoSeed2Server::PackInfoSeed2Server(PackInfoManger * manger, QObject *paren
     _manger(manger),_autoSync(autoSync)
 {
     connect(&_requst,&HttpRequest::result,this,&PackInfoSeed2Server::result);
-    connect(&_rukuRequest,&HttpRequest::result,this,&PackInfoSeed2Server::rukuResult);
     _netErrorCount = 0;
     _oneSyncError = 0;
     log = PQ::PQLogManger::this_()->getLog("PackInfoSeed2Server");
 }
 
-
-void PackInfoSeed2Server::send(QSharedPointer<PackInfo> & info,bool isruku)
+void PackInfoSeed2Server::send(QSharedPointer<PackInfo> & info)
 {
-    isRuKu = isruku;
     if(_manger == nullptr) return;
     _queue.append(info);
     QTimer::singleShot(20,this,&PackInfoSeed2Server::doSend);
@@ -32,6 +29,12 @@ void PackInfoSeed2Server::doSend()
         }
         _current = _queue.first();
         //docs: http://doc.vanlai.net:3001/web/#/1?page_id=64
+        if(_current->autoRuku == true){
+            QString url = GlobalInfo::this_()->config()->baseUrl+"/v1/product/directly/into";
+            _requst.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
+            _requst.post(url,_current->toObject());
+            return;
+        }
         QString url = GlobalInfo::this_()->config()->baseUrl+"/v1/product/pending";
         _requst.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
         _requst.post(url,_current->toObject());
@@ -45,41 +48,6 @@ void PackInfoSeed2Server::sendList(QList<QSharedPointer<PackInfo>> & infos)
     QTimer::singleShot(20,this,&PackInfoSeed2Server::doSend);
 }
 
-void PackInfoSeed2Server::ruKu(QSharedPointer<PackInfo> current,int product)
-{
-    QJsonObject obj;
-    QJsonArray array;
-    for(int i = 0;i<current->boxInfoSize();i++){
-        array.append(current->boxes().at(i)->caseNumber());
-    }
-    obj.insert("product_id",product);
-    obj.insert("details",array);
-
-    _rukuCurrent.warehouse_id = current->warehouse_id;
-    _rukuCurrent.way = 2;
-    _rukuCurrent.product_details.append(obj);
-    _rukuCurrent.remark = current->remark;
-    _rukuQueue.append(_rukuCurrent);
-
-    QTimer::singleShot(20,this,&PackInfoSeed2Server::doRuKu);
-}
-
-void PackInfoSeed2Server::doRuKu()
-{
-
-    if(_rukuQueue.isEmpty()){
-        return;
-    }
-    QString url = GlobalInfo::this_()->config()->baseUrl+"/v1/product/inbound";
-    _rukuRequest.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
-    _rukuRequest.post(url,_rukuCurrent.toObject());
-    _rukuQueue.dequeue();
-}
-
-void PackInfoSeed2Server::rukuResult(int code, const QJsonObject & body){
-    qDebug()<<body;
-}
-
 void PackInfoSeed2Server::result(int code, const QJsonObject & body)
 {
     qDebug()<<body;
@@ -95,17 +63,14 @@ void PackInfoSeed2Server::result(int code, const QJsonObject & body)
         _queue.dequeue();
         _manger->setPackInfoSync(_current->codeSingle(),_current->time(),_autoSync);
 
-        int product_id = body.value("data").toObject().value("product_id").toInt();
-        if(isRuKu){
-            ruKu(_current,product_id);
-        }
+//        int product_id = body.value("data").toObject().value("product_id").toInt();
 
         _current.clear();
         QTimer::singleShot(20,this,&PackInfoSeed2Server::doSend);
         _netErrorCount = 0;
         _oneSyncError = 0;
 
-    } else {
+    }else {
         _oneSyncError ++;
         if(_oneSyncError > 3){
             pqWarning(log) << "sync error,and to skip: data : \n" << QJsonDocument(_current->toObject()).toJson() <<

+ 3 - 5
handle/packinfoseed2server.h

@@ -17,15 +17,12 @@ public:
 signals:
     void syncEnd();
 public slots:
-    void send(QSharedPointer<PackInfo> & info,bool isruku);
-    void ruKu(QSharedPointer<PackInfo> current,int product_id);
+    void send(QSharedPointer<PackInfo> & info);
     void sendList(QList<QSharedPointer<PackInfo>> & infos);
 
 private slots:
     void doSend();
-    void doRuKu();
     void result(int code, const QJsonObject & body);
-    void rukuResult(int code, const QJsonObject & body);
 private:
     uint _netErrorCount;
     QQueue<QSharedPointer<PackInfo>> _queue;
@@ -34,7 +31,8 @@ private:
     RuKuInfo _rukuCurrent;
     PackInfoManger * _manger;
     HttpRequest _requst;
-    HttpRequest _rukuRequest;
+    HttpRequest _rukuRequest;//获取最近一次产品入库里的product_details_id
+    HttpRequest _rukurequest;//把产品入库
     bool _autoSync;
     uint _oneSyncError;
     PQ::PQLog * log;

+ 5 - 2
handle/printer/baseboxprinter.h

@@ -6,6 +6,7 @@
 #include <QPainter>
 #include "code39.h"
 #include <QImage>
+#include "struct_/modelinfo.h"
 
 class BaseBoxPrinter
 {
@@ -14,7 +15,8 @@ public:
     virtual ~BaseBoxPrinter();
 
     virtual QImage doPrinter(QSharedPointer<BoxInfo> box) = 0;
-    virtual QImage BoxModel() = 0;
+    virtual QImage doPrinter(QSharedPointer<BoxInfo> box,int ModelIndex) = 0;
+    virtual QImage Boxmodel() = 0;
     virtual QSize printSize() = 0;
 protected:
     Code39 code;
@@ -28,7 +30,8 @@ public:
     virtual ~BasePackinfoPrinter();
 
     virtual QImage doPrinter(QSharedPointer<PackInfo> box) = 0;
-
+    virtual QImage doPrinter(QSharedPointer<PackInfo> box,int ModelIndex) = 0;
+    virtual QImage Packmodel() = 0;
     virtual QSize printSize() = 0;
 
 protected:

+ 329 - 28
handle/printer/boxtemlateone.cpp

@@ -8,13 +8,6 @@ BoxTemlateOne::BoxTemlateOne()
 
 QImage BoxTemlateOne::doPrinter(QSharedPointer<BoxInfo> box)
 {
-    //TODO: 小宋,迁移打印 箱单的逻辑
-
-    // TODO: 测试打印出来的单子
-//    if(datalist.isEmpty()){
-//        return;
-//    }
-//    QLogInfo(log) << "prnter " << bar<< "  " << info->caseNumber();
     QSharedPointer<PackInfo> pinfo = box->parentPack();
     if(pinfo.isNull()) return QImage();
     QSize size(MAXWIDTH*5,MAXHEIGHT*5);
@@ -67,7 +60,7 @@ QImage BoxTemlateOne::doPrinter(QSharedPointer<BoxInfo> box)
     painter.drawText(21*5,25*5,pinfo->info()->product_type_code);
     painter.drawText(21*5,32*5,pinfo->info()->batch_no);
     painter.drawText(21*5,39*5,pinfo->info()->specs);
-    painter.drawText(67*5,25*5,QString("%1 kg").arg(getDecimalbit( box->gross_weight / 1000.00)));//datalist.at(0));
+    painter.drawText(67*5,25*5,QString("%1 kg").arg(getDecimalbit(box->gross_weight / 1000.00)));//datalist.at(0));
 
     painter.drawText(67*5,32*5,QString("%1 kg").arg(getDecimalbit(box->net_weight / 1000.00)));//datalist.at(1));
 
@@ -85,20 +78,158 @@ QImage BoxTemlateOne::doPrinter(QSharedPointer<BoxInfo> box)
 
 //    print(image);
 
-    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
+//    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
 //    if(save)
-        image.save(path+"/xiangdan/code"+bar+".bmp");
+//        image.save(path+"/xiangdan/code"+bar+".bmp");
     return image;
 
 //    return img;
 }
 
+QImage BoxTemlateOne::doPrinter(QSharedPointer<BoxInfo> box,int ModelIndex)
+{
+//    qDebug()<<GlobalInfo::this_()->BoxModelList().size();
+    boxM = GlobalInfo::this_()->BoxModelList().at(ModelIndex);
+
+    QSharedPointer<PackInfo> pinfo = box->parentPack();
+    QJsonObject info = pinfo->info()->toObject();
+    QJsonObject obj =  box->toObject();
+    if(pinfo.isNull()) return QImage();
+    QSize size(MAXWIDTH*5,MAXHEIGHT*5);
+    QImage image(size,QImage::Format_ARGB32);
+    image.fill(qRgba(255, 255, 255, 255));
+    QPainter painter(&image);
+    painter.drawRect(5*5,5*5,90*5,15*5);
+    painter.drawRect(5*5,20*5,90*5,35*5);
+    painter.drawLine(20*5,20*5,20*5,55*5);
+    painter.drawLine(50*5,20*5,50*5,55*5);
+    painter.drawLine(66*5,20*5,66*5,55*5);
+    painter.drawLine(5*5,27*5,95*5,27*5);
+    painter.drawLine(5*5,34*5,95*5,34*5);
+    painter.drawLine(5*5,41*5,95*5,41*5);
+    painter.drawLine(5*5,48*5,95*5,48*5);
+    painter.drawRect(5*5,55*5,90*5,15*5);
+    painter.drawRect(5*5,70*5,90*5,7*5);
+
+    QRect target(0*5, 57*5, 100*5, 65*5);
+//    QRect source(-10*5, 0, 65*5, 40*5);
+    QString bar = box->caseNumber();
+    code.draw(painter,target,bar);
+//    painter.drawImage(target,barCode.draw(barCode.CodeBinary(bar),bar),source);
+
+    painter.setRenderHint(QPainter::Antialiasing,true);
+    painter.setRenderHint(QPainter::TextAntialiasing,true);
+    painter.setRenderHint(QPainter::HighQualityAntialiasing,true);
+    QFont font;
+    font.setFamily("宋体");
+    font.setPixelSize(40);
+    font.setWeight(QFont::ExtraLight);
+    painter.setFont(font);
+    painter.drawText(6*5,15*5,box->parentPack()->customer);
+//    qDebug()<< "公司名称:" <<box->parentPack()->customer;
+
+    font.setPixelSize(20);
+    font.setBold(true);
+    painter.setFont(font);
+//    painter.drawText(8*5,25*5,boxM->text1_1);
+//    painter.drawText(53*5,25*5,boxM->text1_2);
+//    painter.drawText(8*5,32*5,boxM->text2_1);
+//    painter.drawText(53*5,32*5,boxM->text2_2);
+//    painter.drawText(8*5,39*5,boxM->text3_1);
+//    painter.drawText(53*5,39*5,boxM->text3_2);
+//    painter.drawText(8*5,46*5,boxM->text4_1);
+//    painter.drawText(53*5,46*5,boxM->text4_2);
+//    painter.drawText(8*5,53*5,boxM->text5_1);
+//    painter.drawText(50*5,53*5,boxM->text5_2);
+
+    painter.drawText(8*5,25*5,boxM->Type_Name.at(0).toString());
+    painter.drawText(53*5,25*5,boxM->Type_Name.at(5).toString());
+    painter.drawText(8*5,32*5,boxM->Type_Name.at(1).toString());
+    painter.drawText(53*5,32*5,boxM->Type_Name.at(6).toString());
+    painter.drawText(8*5,39*5,boxM->Type_Name.at(2).toString());
+    painter.drawText(53*5,39*5,boxM->Type_Name.at(7).toString());
+    painter.drawText(8*5,46*5,boxM->Type_Name.at(3).toString());
+    painter.drawText(53*5,46*5,boxM->Type_Name.at(8).toString());
+    painter.drawText(8*5,53*5,boxM->Type_Name.at(4).toString());
+    painter.drawText(53*5,53*5,boxM->Type_Name.at(9).toString());
+//    painter.drawText(50*5,53*5,boxM->Type_Name.at(9).toString());
+
+
+
+    painter.drawText(21*5,25*5,FindData(box,boxM->Type_Data.at(0).toString()));
+    painter.drawText(21*5,32*5,FindData(box,boxM->Type_Data.at(1).toString()));
+    painter.drawText(21*5,39*5,FindData(box,boxM->Type_Data.at(2).toString()));
+    painter.drawText(21*5,46*5,FindData(box,boxM->Type_Data.at(3).toString()));
+    painter.drawText(21*5,53*5,FindData(box,boxM->Type_Data.at(4).toString()));
+    painter.drawText(67*5,25*5,FindData(box,boxM->Type_Data.at(5).toString()));//datalist.at(0));
+    painter.drawText(67*5,32*5,FindData(box,boxM->Type_Data.at(6).toString()));
+    painter.drawText(67*5,39*5,FindData(box,boxM->Type_Data.at(7).toString()));//datalist.at(2));
+    painter.drawText(67*5,46*5,FindData(box,boxM->Type_Data.at(8).toString()));//datalist.at(4));
+    painter.drawText(67*5,53*5,FindData(box,boxM->Type_Data.at(9).toString()));//datalist.at(6));
+
+    font.setPixelSize(17);
+    painter.setFont(font);
+
+
+    painter.drawText(4*5,75*5," 电话:"+ box->parentPack()->telephone);
+
+//    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
+//        image.save(path+"/xiangdan/code"+bar+".bmp");
+    return image;
+}
+
+QString BoxTemlateOne::FindData(QSharedPointer<BoxInfo> box,QString data){
+
+    QSharedPointer<PackInfo> pinfo = box->parentPack();
+//    QJsonObject info = pinfo->info()->toObject();
+//    QJsonObject obj =  box->toObject();
+    if(data=="品名"){
+        return pinfo->info()->product_type_code;
+    }else if(data=="批号"){
+        return pinfo->info()->batch_no;
+    }else if(data=="规格"){
+        return pinfo->info()->specs;
+    }else if(data=="毛重"){
+        return QString("%1 kg").arg(getDecimalbit( box->gross_weight / 1000.00));
+    }else if(data=="净重"){
+        return QString("%1 kg").arg(getDecimalbit(box->net_weight / 1000.00));
+    }else if(data=="筒数"){
+        return QString::number(box->tube_number);
+    }else if(data=="等级"){
+        return box->Level;
+    }else if(data=="捻向"){
+        return box->twist_type;
+    }else if(data=="管色"){
+        return box->bucket_color;
+    }else if(data=="箱号"){
+        return box->caseNumber();
+    }else if(data=="类型"){
+        return pinfo->info()->category;
+    }else if(data=="旦数"){
+        return pinfo->info()->denier;
+    }else if(data=="分特"){
+        return pinfo->info()->dtex;
+    }else if(data=="孔数"){
+        return pinfo->info()->fiber;
+    }else if(data=="颜色"){
+        return pinfo->info()->color;
+    }else if(data=="皮重"){
+        return pinfo->info()->box_weight;
+    }else if(data=="筒重"){
+        return pinfo->info()->bucket_weight;
+    }else if(data!="空"){
+        return data;
+    }
+
+    return "";
+}
+
 QSize BoxTemlateOne::printSize()
 {
     return QSize(100,80);
 }
 
-QImage BoxTemlateOne::BoxModel()
+QImage BoxTemlateOne::Boxmodel()
 {
     qDebug()<<"this";
     QSize size(MAXWIDTH*5,MAXHEIGHT*5);
@@ -116,9 +247,22 @@ QImage BoxTemlateOne::BoxModel()
     painter.drawLine(5*5,48*5,95*5,48*5);
     painter.drawRect(5*5,55*5,90*5,15*5);
     painter.drawRect(5*5,70*5,90*5,7*5);
-    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
+
+    QRect target(0*5, 57*5, 100*5, 65*5);
+    QString bar = "200324155812001";
+    code.draw(painter,target,bar);
+
+    QFont font;
+    font.setPixelSize(40);
+    painter.setFont(font);
+    painter.drawText(5*5,15*5,"公司名称");
+
+    font.setPixelSize(17);
+    painter.setFont(font);
+    painter.drawText(4*5,75*5," 电话:11111111111");
+//    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
 //    if(save)
-        image.save(path+"/xiangdan/code"+"11111"+".bmp");
+//        image.save(path+"/xiangdan/code"+"11111"+".bmp");
     return image;
 }
 
@@ -136,17 +280,6 @@ QImage PackTemlateOne::doPrinter(QSharedPointer<PackInfo> pack)
     QPainter painter(&image);
     painter.drawRect(4*5,4*5,92*5,68*5);
 
-//    painter.drawLine(50*5,0,50*5,80*5);
-//    painter.drawLine(4*5,16*5,96*5,16*5);
-//    painter.drawLine(4*5,22*5,96*5,22*5);
-//    painter.drawLine(4*5,28*5,96*5,28*5);
-//    painter.drawLine(4*5,34*5,96*5,34*5);
-//    painter.drawLine(4*5,40*5,96*5,40*5);
-//    painter.drawLine(4*5,46*5,96*5,46*5);
-//    painter.drawLine(4*5,52*5,96*5,52*5);
-//    painter.drawLine(4*5,58*5,96*5,58*5);
-//    painter.drawLine(4*5,65*5,96*5,65*5);
-
     QFont font;
     font.setFamily("宋体");
     font.setPixelSize(30);
@@ -192,7 +325,7 @@ QImage PackTemlateOne::doPrinter(QSharedPointer<PackInfo> pack)
     painter.drawText(70*5,21*5,pack->level);//info.at(0));
     for(int i = 0; i < boxSize; ++i)
     {
-        QString code = getDecimalbit(pack->boxes().at(i)->net_weight / 1000);
+        QString code = getDecimalbit(pack->boxes().at(i)->net_weight / 1000.00);
         int line = i / 5;
         int cloun = i % 5;
         painter.drawText((13 + line * 19)*5,(27.5 + cloun * 6 )*5 ,code);
@@ -202,14 +335,182 @@ QImage PackTemlateOne::doPrinter(QSharedPointer<PackInfo> pack)
     painter.drawText(48*5,64*5,QString("%1 kg").arg(getDecimalbit(pack->net_weight() / 1000.00)));
     painter.drawText(78*5,64*5,QString::number(pack->tube_number()));
 
-    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
-//        print(image);
-        image.save(path+"/rukudan/code"+bar+".bmp");
+//    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
+//        image.save(path+"/rukudan/code"+bar+".bmp");
+
+    return image;
+}
+
+QImage PackTemlateOne::doPrinter(QSharedPointer<PackInfo> pack, int ModelIndex)
+{
+    //TODO: 小宋,迁移打印 码单的逻辑
+
+    packM = GlobalInfo::this_()->PackModelList().at(ModelIndex);
+
+    QSize size(MAXWIDTH*5,MAXHEIGHT*5);
+    QImage image(size,QImage::Format_ARGB32);
+    image.fill(qRgba(255, 255, 255, 255));
+    QPainter painter(&image);
+    painter.drawRect(4*5,4*5,92*5,68*5);
+
+    QFont font;
+    font.setFamily("宋体");
+    font.setPixelSize(30);
+    font.setWeight(QFont::ExtraLight);
+    painter.setFont(font);
+    painter.drawText(38*5,10*5,QStringLiteral("入 库 单"));
+
+
+    font.setPixelSize(20);
+    painter.setFont(font);
+    painter.drawText(8*5,15*5,packM->Type_Name.at(0).toString());
+    painter.drawText(59*5,15*5,packM->Type_Name.at(1).toString());
+    painter.drawText(8*5,21*5,packM->Type_Name.at(2).toString());
+    painter.drawText(59*5,21*5,packM->Type_Name.at(3).toString());
+
+    font.setPixelSize(15);
+    painter.setFont(font);
+
+    painter.drawText(8*5,64*5,packM->Type_Name.at(4).toString());
+    painter.drawText(38*5,64*5,packM->Type_Name.at(5).toString());
+    painter.drawText(68*5,64*5,packM->Type_Name.at(6).toString());
+
+//    QFont font;
+    font.setPixelSize(15);
+    painter.setFont(font);
+    int boxSize =  pack->boxes().size();
+    for(int i = 0; i < boxSize; ++i){
+        int line = i / 5;
+        int cloun = i % 5;
+        painter.drawText((9 + line * 19)*5,(27 + cloun * 6)*5,QString("%1.").arg(i + 1));
+    }
+
+    QRect target(0*5, 67*5, 100*5, 75*5);
+    QString bar = pack->codeSingle();
+    code.draw(painter,target,bar);
+    font.setPixelSize(20);
+    font.setFamily("黑体");
+
+    painter.setFont(font);
+    painter.drawText(19*5,15*5,FindData(pack,packM->Type_Data.at(0).toString()));//QStringLiteral("规格"));
+    painter.drawText(70*5,15*5,FindData(pack,packM->Type_Data.at(1).toString()));//QStringLiteral("类型"));
+    painter.drawText(19*5,21*5,FindData(pack,packM->Type_Data.at(2).toString()));//QStringLiteral("批号"));
+    painter.drawText(70*5,21*5,FindData(pack,packM->Type_Data.at(3).toString()));//info.at(0));
+    for(int i = 0; i < boxSize; ++i)
+    {
+        QString code = Find20Data(pack,packM->Type_Data.at(4).toString(),i);
+        int line = i / 5;
+        int cloun = i % 5;
+        painter.drawText((13 + line * 19)*5,(27.5 + cloun * 6 )*5 ,code);
+    }
+
+    painter.drawText(15*5,64*5,FindData(pack,packM->Type_Data.at(5).toString()));
+    painter.drawText(48*5,64*5,FindData(pack,packM->Type_Data.at(6).toString()));
+    painter.drawText(78*5,64*5,FindData(pack,packM->Type_Data.at(7).toString()));
+
+//    QString path = PQ::PQLogManger::this_()->getSaveFilePath();
+//        image.save(path+"/rukudan/code"+bar+".bmp");
+
+    return image;
+}
+
+QImage PackTemlateOne::Packmodel()
+{
+    QSize size(MAXWIDTH*5,MAXHEIGHT*5);
+    QImage image(size,QImage::Format_ARGB32);
+    image.fill(qRgba(255, 255, 255, 255));
+    QPainter painter(&image);
+    painter.drawRect(4*5,4*5,92*5,68*5);
+
+    QFont font;
+    font.setFamily("宋体");
+    font.setPixelSize(30);
+    font.setWeight(QFont::ExtraLight);
+    painter.setFont(font);
+    painter.drawText(38*5,10*5,QStringLiteral("入 库 单"));
+
+
+    QRect target(0*5, 67*5, 100*5, 75*5);
+    QString bar = "0000200313170054032";
+    code.draw(painter,target,bar);
+    font.setPixelSize(20);
+    font.setFamily("黑体");
 
     return image;
 }
 
+QString PackTemlateOne::FindData(QSharedPointer<PackInfo> pack, QString data)
+{
+    if(data=="批号"){
+        return pack->info()->batch_no;
+    }else if(data=="类型"){
+        return pack->info()->category;
+    }else if(data=="品种"){
+        return pack->info()->product_type_code;
+    }else if(data=="旦数"){
+        return pack->info()->denier;
+    }else if(data=="分特"){
+        return pack->info()->dtex;
+    }else if(data=="等级"){
+        return pack->level;
+    }else if(data=="孔数"){
+        return pack->info()->fiber;
+    }else if(data=="规格"){
+        return pack->info()->specs;
+    }else if(data=="颜色"){
+        return pack->info()->color;
+    }else if(data=="捻向"){
+        return pack->info()->twist_type;
+    }else if(data=="管色"){
+        return pack->info()->bucket_color;
+    }else if(data=="皮重"){
+        return pack->info()->box_weight;
+    }else if(data=="机台"){
+        return pack->info()->machine_no;
+    }else if(data=="纸箱"){
+        return pack->info()->carton_type;
+    }else if(data=="总筒数"){
+        return QString::number(pack->tube_number());
+    }else if(data=="总毛重"){
+        return QString("%1 kg").arg(getDecimalbit(pack->gross_weight() / 1000.00));
+    }else if(data=="总净重"){
+        return QString("%1 kg").arg(getDecimalbit(pack->net_weight() / 1000.00));
+    }else if(data!="空"){
+        return data;
+    }
+
+    return "";
+}
+
+QString PackTemlateOne::Find20Data(QSharedPointer<PackInfo> pack, QString data, int index)
+{
+    if(data=="毛重"){
+        return QString("%1 kg").arg(getDecimalbit(pack->boxInfoAt(index)->gross_weight / 1000.00));
+    }else if(data=="净重"){
+        return QString("%1 kg").arg(getDecimalbit(pack->boxInfoAt(index)->net_weight / 1000.00));
+    }else if(data=="筒重"){
+        return QString::number(pack->boxInfoAt(index)->tube_number);
+    }else if(data=="捻向"){
+        return pack->boxInfoAt(index)->twist_type;
+    }else if(data=="管色"){
+        return pack->boxInfoAt(index)->bucket_color;
+    }else if(data=="总筒重"){
+        return QString("%1 kg").arg(getDecimalbit(pack->boxInfoAt(index)->bucket_weight / 1000.00));
+    }else if(data=="筒数"){
+        return QString::number(pack->boxInfoAt(index)->tube_number);
+    }else if(data!="空"){
+        return data;
+    }
+
+    return "";
+}
+
 QSize PackTemlateOne::printSize()
 {
     return QSize(100,80);
 }
+
+
+
+
+

+ 11 - 2
handle/printer/boxtemlateone.h

@@ -10,8 +10,13 @@ public:
     BoxTemlateOne();
 
     virtual QImage doPrinter(QSharedPointer<BoxInfo> box);
-    virtual QImage BoxModel();
+    virtual QImage doPrinter(QSharedPointer<BoxInfo> box,int ModelIndex);
+    virtual QImage Boxmodel();
     virtual QSize printSize();
+    QString FindData(QSharedPointer<BoxInfo> box,QString data);
+
+private:
+    QSharedPointer<BoxModel> boxM;
 
 private:
     const int MAXWIDTH=100;
@@ -25,9 +30,13 @@ public:
     PackTemlateOne();
 
     virtual QImage doPrinter(QSharedPointer<PackInfo> pack);
-
+    virtual QImage doPrinter(QSharedPointer<PackInfo> pack,int ModelIndex);
+    virtual QImage Packmodel();
     virtual QSize printSize();
+    QString FindData(QSharedPointer<PackInfo> pack,QString data);
+    QString Find20Data(QSharedPointer<PackInfo> pack,QString data,int index);
 private:
+    QSharedPointer<PackModel> packM;
 private:
     const int MAXWIDTH=100;
     const int MAXHEIGHT=80;

+ 29 - 1
handle/printer/printermanger.cpp

@@ -42,6 +42,20 @@ void PrinterManger::printerBox(QSharedPointer<BoxInfo> info)
     }
 }
 
+void PrinterManger::printerBoxModel(QSharedPointer<BoxInfo> info,int ModelIndex)
+{
+    if(_boxPrinter.isNull()) return;
+    auto image = _boxPrinter->doPrinter(info,ModelIndex);
+    if(image.isNull()) return;
+    QPrinter printer(QPrinterInfo::printerInfo(_printerName));
+    printer.setPageSize(QPrinter::Custom);
+    printer.setPageSizeMM(_boxPrinter->printSize());
+//    for(int i = 0; i < count; ++i) // TODO:
+    {
+        doPrinter(printer,image);
+    }
+
+}
 
 void PrinterManger::doPrinter(QPrinter & printer,QImage & image)
 {
@@ -80,7 +94,7 @@ void PrinterManger::doPrinter(QPrinter & printer,QImage & image)
 
 void PrinterManger::printerPack(QSharedPointer<PackInfo> info)
 {
-    if(_boxPrinter.isNull()) return;
+    if(_packPrinter.isNull()) return;
     auto image = _packPrinter->doPrinter(info);
     if(image.isNull()) return;
     QPrinter printer(QPrinterInfo::printerInfo(_printerName));
@@ -91,3 +105,17 @@ void PrinterManger::printerPack(QSharedPointer<PackInfo> info)
         doPrinter(printer,image);
     }
 }
+
+void PrinterManger::printerPackModel(QSharedPointer<PackInfo> info,int ModelIndex)
+{
+    if(_packPrinter.isNull()) return;
+    auto image = _packPrinter->doPrinter(info,ModelIndex);
+    if(image.isNull()) return;
+    QPrinter printer(QPrinterInfo::printerInfo(_printerName));
+    printer.setPageSize(QPrinter::Custom);
+    printer.setPageSizeMM(_packPrinter->printSize());
+//    for(int i = 0; i < count; ++i) // TODO:
+    {
+        doPrinter(printer,image);
+    }
+}

+ 4 - 0
handle/printer/printermanger.h

@@ -3,6 +3,7 @@
 
 #include <QObject>
 #include "baseboxprinter.h"
+#include "struct_/modelinfo.h"
 
 class PrinterManger : public QObject
 {
@@ -16,7 +17,10 @@ public:
 signals:
 public slots:
     void printerBox(QSharedPointer<BoxInfo> info);
+    void printerBoxModel(QSharedPointer<BoxInfo> info,int ModelIndex);
+
     void printerPack(QSharedPointer<PackInfo> info);
+    void printerPackModel(QSharedPointer<PackInfo> info,int ModelIndex);
 
 private:
     void doPrinter(QPrinter & printer,QImage & img);

+ 2 - 0
handle/printerthreadhandle.cpp

@@ -20,7 +20,9 @@ void PrinterThreadHandle::start()
         connect(thread,&QThread::started,this,&PrinterThreadHandle::updateConfig);
         manger = new PrinterManger(this);
         connect(this,&PrinterThreadHandle::printerBox,manger,&PrinterManger::printerBox,Qt::QueuedConnection);
+        connect(this,&PrinterThreadHandle::printerBoxModel,manger,&PrinterManger::printerBoxModel,Qt::QueuedConnection);
         connect(this,&PrinterThreadHandle::printerPack,manger,&PrinterManger::printerPack,Qt::QueuedConnection);
+        connect(this,&PrinterThreadHandle::printerPackModel,manger,&PrinterManger::printerPackModel,Qt::QueuedConnection);
         auto config = GlobalInfo::this_()->config();
         connect(config,&ConfigInfo::configUpdate,this,&PrinterThreadHandle::updateConfig,Qt::QueuedConnection);
         manger->setPrinter(QSharedPointer<BaseBoxPrinter>(new BoxTemlateOne()),QSharedPointer<BasePackinfoPrinter>(new PackTemlateOne()));

+ 2 - 0
handle/printerthreadhandle.h

@@ -14,7 +14,9 @@ public:
 
 signals:
     void printerBox(QSharedPointer<BoxInfo> info);
+    void printerBoxModel(QSharedPointer<BoxInfo> info,int ModelIndex);
     void printerPack(QSharedPointer<PackInfo> info);
+    void printerPackModel(QSharedPointer<PackInfo> info,int ModelIndex);
 public slots:
     void start();
 

+ 1 - 0
images.qrc

@@ -2,5 +2,6 @@
     <qresource prefix="/">
         <file>images/backImage.jpg</file>
         <file>images/moren.bmp</file>
+        <file>images/Pmoren.bmp</file>
     </qresource>
 </RCC>

BIN=BIN
images/Pmoren.bmp


+ 45 - 27
mainwindow.cpp

@@ -17,19 +17,31 @@ MainWindow::MainWindow(QWidget *parent)
     connect(ui->pagePackDetail,&PackDetailForm::back,this,&MainWindow::backMenu);
     connect(ui->pageAddNew,&AddNewSpecsForm::back,this,&MainWindow::backMenu);
 
+    //定重页面
     connect(ui->dingzhong,&FixedWeightPackForm::backup,this,&MainWindow::backSelect);
     connect(ui->dingzhong,&FixedWeightPackForm::NoSyncList,this,&MainWindow::changeToPackDetail);
     connect(ui->dingzhong,&FixedWeightPackForm::buding,this,&MainWindow::on_buding);
     connect(ui->dingzhong,&FixedWeightPackForm::back,this,&MainWindow::backMenu);
 
+    //不定页面
     connect(ui->buding,&UncertainWeightPackForm::back,this,&MainWindow::backMenu);
     connect(ui->buding,&UncertainWeightPackForm::dingzhong,this,&MainWindow::on_dingzhong);
     connect(ui->buding,&UncertainWeightPackForm::backup,this,&MainWindow::backSelect);
     connect(ui->buding,&UncertainWeightPackForm::NoSyncList,this,&MainWindow::changeToPackDetail);
 
-    connect(ui->pageShowXiangDan,&ShowXiangDanLabelForm::back,this,&MainWindow::backMenu);
+    //模板页面
+    connect(ui->pageSelectModel,&ModelSelectForm::back,this,&MainWindow::backMenu);
+    connect(ui->pageSelectModel,&ModelSelectForm::addBoxModel,this,&MainWindow::changeToShowXiangDan);
+    connect(ui->pageSelectModel,&ModelSelectForm::showBaseBoxModel,this,&MainWindow::changeToShowXiangDan);
+    connect(ui->pageSelectModel,&ModelSelectForm::editBoxModeled,this,&MainWindow::changeToShowXiangDan);
 
-    connect(ui->pageShowMaDan,&ShowMaDanLabelForm::back,this,&MainWindow::backMenu);
+    connect(ui->pageSelectModel,&ModelSelectForm::addPackModel,this,&MainWindow::changeToShowMaDan);
+    connect(ui->pageSelectModel,&ModelSelectForm::showBasePackModel,this,&MainWindow::changeToShowMaDan);
+    connect(ui->pageSelectModel,&ModelSelectForm::editPackModeled,this,&MainWindow::changeToShowMaDan);
+
+    connect(ui->pageShowXiangDan,&ShowXiangDanLabelForm::back,this,&MainWindow::changeToShowBoxModel);
+
+    connect(ui->pageShowMaDan,&ShowMaDanLabelForm::back,this,&MainWindow::changeToShowPackModel);
 
 
     connect(ui->actionSetting,&QAction::triggered,this,&MainWindow::changeToSettings);
@@ -37,10 +49,14 @@ MainWindow::MainWindow(QWidget *parent)
     connect(ui->actionPack,&QAction::triggered,this,&MainWindow::changeToPackDetail);
     connect(ui->actionSelectvalue,&QAction::triggered,this,&MainWindow::backSelect);
     connect(ui->actionLogout,&QAction::triggered,this,&MainWindow::logout);
-    connect(ui->actionXiangDanModel,&QAction::triggered,this,&MainWindow::changeToShowXiangDan);
-    connect(ui->actionMaDanModel,&QAction::triggered,this,&MainWindow::changeToShowMaDan);
-//    connect(ui->backButton,&QPushButton::clicked,this,&MainWindow::backMenu);
+    connect(ui->actionXiangDan,&QAction::triggered,this,&MainWindow::changeToShowBoxModel);
+    connect(ui->actionMaDan,&QAction::triggered,this,&MainWindow::changeToShowPackModel);
+
     ui->stackedWidget->setCurrentWidget(ui->pageLogin);
+    ui->menu_5->setVisible(false);
+    ui->actionXiangDan->setVisible(true);
+    ui->actionMaDan->setVisible(true);
+    ui->actionXiangDan->setData(1);
 }
 
 MainWindow::~MainWindow()
@@ -48,16 +64,6 @@ MainWindow::~MainWindow()
     delete ui;
 }
 
-void MainWindow::on_pushDingZHong_clicked()
-{
-
-}
-
-void MainWindow::on_pushBuDingZhong_clicked()
-{
-
-}
-
 void MainWindow::on_pushAuto_clicked()
 {
     backSelect();
@@ -73,11 +79,6 @@ void MainWindow::on_pushConfig_clicked()
     changeToSettings();
 }
 
-void MainWindow::pageStatusChange(const ProjectInfo & info, int status)
-{
-
-}
-
 void MainWindow::changeToSettings()
 {
     ui->stackedWidget->setCurrentWidget(ui->pageSettings);
@@ -148,13 +149,35 @@ void MainWindow::changeToPackDetail()
     ui->pagePackDetail->changeTreeWidget(0,5);
 }
 
-void MainWindow::changeToShowMaDan()
+void MainWindow::changeToShowMaDan(QString baseModelName,int status ,QString modelName)
 {
+    ui->pageShowMaDan->init(baseModelName,status,modelName);
     ui->stackedWidget->setCurrentWidget(ui->pageShowMaDan);
 }
 
-void MainWindow::changeToShowXiangDan()
+void MainWindow::changeToShowBoxModel()
 {
+    if(GlobalInfo::this_()->user().userName == ""){
+        QMessageBox::information(this,tr("注意"),tr("请登录"));
+        return;
+    }
+    ui->pageSelectModel->changeStackedWidget(1);
+    ui->stackedWidget->setCurrentWidget(ui->pageSelectModel);
+}
+
+void MainWindow::changeToShowPackModel()
+{
+    if(GlobalInfo::this_()->user().userName == ""){
+        QMessageBox::information(this,tr("注意"),tr("请登录"));
+        return;
+    }
+    ui->pageSelectModel->changeStackedWidget(2);
+    ui->stackedWidget->setCurrentWidget(ui->pageSelectModel);
+}
+
+void MainWindow::changeToShowXiangDan(QString baseModelName,int status,QString modelName)
+{
+    ui->pageShowXiangDan->init(baseModelName,status,modelName);
     ui->stackedWidget->setCurrentWidget(ui->pageShowXiangDan);
 }
 
@@ -194,8 +217,3 @@ void MainWindow::on_backButton_clicked()
     qDebug()<<"this";
     ui->stackedWidget->setCurrentWidget(ui->pageMain);
 }
-
-void MainWindow::on_autoSync_stateChanged(int arg1)
-{
-
-}

+ 8 - 11
mainwindow.h

@@ -3,9 +3,9 @@
 
 #include <QMainWindow>
 #include "configinfo.h"
-//#include "handle/seriport/rtuport.h"
 #include "struct_/projectinfo.h"
 #include "handle/packinfomanger.h"
+#include "handle/packinfoseed2server.h"
 
 QT_BEGIN_NAMESPACE
 namespace Ui { class MainWindow; }
@@ -26,34 +26,31 @@ private slots:
 
     void on_pushConfig_clicked();
 
-    void on_pushDingZHong_clicked();
-
-    void on_pushBuDingZhong_clicked();
-
     void on_backButton_clicked();
 
-    void on_autoSync_stateChanged(int arg1);
-
 private:
     void backMenu();
     void backSelect(int i = 0);
-    void pageStatusChange(const ProjectInfo & info, int status);
     void changeToSettings();
     void changeToAddNew();
     void FixedAndUncertain(QString batchno);
     void backFAndU();
     void changeToPackDetail();
-    void changeToShowMaDan();
-    void changeToShowXiangDan();
+    void changeToShowMaDan(QString baseModelName,int status,QString modelName = nullptr);
+    void changeToShowXiangDan(QString baseModelName,int status,QString modelName = nullptr);
+    void changeToShowBoxModel();
+    void changeToShowPackModel();
 
     void on_buding();
     void on_dingzhong();
-    void logout();
 //    RtuPort rtuport;
+public slots:
+    void logout();
 
 protected:
     void closeEvent(QCloseEvent *event); // 关闭时调用
 private:
     Ui::MainWindow *ui;
+    HttpRequest *httprequest;
 };
 #endif // MAINWINDOW_H

+ 28 - 2
mainwindow.ui

@@ -194,6 +194,7 @@
         </item>
        </layout>
       </widget>
+      <widget class="ModelSelectForm" name="pageSelectModel"/>
       <widget class="SelectValueForm" name="pageSelectValue"/>
       <widget class="PackDetailForm" name="pagePackDetail"/>
       <widget class="UncertainWeightPackForm" name="pageBuDing"/>
@@ -239,11 +240,14 @@
     </property>
    </widget>
    <widget class="QMenu" name="menu_5">
+    <property name="enabled">
+     <bool>true</bool>
+    </property>
     <property name="title">
      <string>模板管理</string>
     </property>
-    <addaction name="actionXiangDanModel"/>
-    <addaction name="actionMaDanModel"/>
+    <addaction name="actionXiangDan"/>
+    <addaction name="actionMaDan"/>
    </widget>
    <addaction name="menu"/>
    <addaction name="menu_2"/>
@@ -304,11 +308,27 @@
    <property name="text">
     <string>箱单管理</string>
    </property>
+   <property name="visible">
+    <bool>true</bool>
+   </property>
   </action>
   <action name="actionMaDanModel">
    <property name="text">
     <string>码单管理</string>
    </property>
+   <property name="visible">
+    <bool>true</bool>
+   </property>
+  </action>
+  <action name="actionXiangDan">
+   <property name="text">
+    <string>箱单模板</string>
+   </property>
+  </action>
+  <action name="actionMaDan">
+   <property name="text">
+    <string>码单模板</string>
+   </property>
   </action>
  </widget>
  <customwidgets>
@@ -366,6 +386,12 @@
    <header>widget/showxiangdanlabelform.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>ModelSelectForm</class>
+   <extends>QWidget</extends>
+   <header>widget/modelselectform.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>

+ 129 - 0
struct_/modelinfo.cpp

@@ -0,0 +1,129 @@
+#include "modelinfo.h"
+
+ModelInfo::ModelInfo()
+{
+
+}
+
+//QJsonObject BoxModel::toObject()
+//{
+//    QJsonObject obj;
+//    QJsonObject line1;//文本和下拉框的第一排
+//    QJsonObject line2;//文本和下拉框的第二排
+
+//    obj.insert("ModelName",ModelName);
+
+//    line1.insert("text1_1",text1_1);
+//    line1.insert("text2_1",text2_1);
+//    line1.insert("text3_1",text3_1);
+//    line1.insert("text4_1",text4_1);
+//    line1.insert("text5_1",text5_1);
+
+//    line2.insert("text1_2",text1_2);
+//    line2.insert("text2_2",text2_2);
+//    line2.insert("text3_2",text3_2);
+//    line2.insert("text4_2",text4_2);
+//    line2.insert("text5_2",text5_2);
+
+//    line1.insert("data1_1",data1_1);
+//    line1.insert("data2_1",data2_1);
+//    line1.insert("data3_1",data3_1);
+//    line1.insert("data4_1",data4_1);
+//    line1.insert("data5_1",data5_1);
+
+//    line2.insert("data1_2",data1_2);
+//    line2.insert("data2_2",data2_2);
+//    line2.insert("data3_2",data3_2);
+//    line2.insert("data4_2",data4_2);
+//    line2.insert("data5_2",data5_2);
+
+//    obj.insert("line1",line1);
+//    obj.insert("line2",line2);
+
+//    return obj;
+//}
+
+//QSharedPointer<BoxModel> BoxModel::fromObject(QJsonObject &obj)
+//{
+//    QString model_name = obj.value("ModelName").toString();
+//    if(model_name.isEmpty()) return QSharedPointer<BoxModel>();
+//    QSharedPointer<BoxModel> ret(new BoxModel);
+
+//    QJsonObject line1 = obj.value("line1").toObject();
+//    QJsonObject line2 = obj.value("line2").toObject();
+
+//    ret->ModelName = obj.value("ModelName").toString();
+
+//    ret->text1_1 = line1.value("text1_1").toString();
+//    ret->text2_1 = line1.value("text2_1").toString();
+//    ret->text3_1 = line1.value("text3_1").toString();
+//    ret->text4_1 = line1.value("text4_1").toString();
+//    ret->text5_1 = line1.value("text5_1").toString();
+//    ret->text1_2 = line2.value("text1_2").toString();
+//    ret->text2_2 = line2.value("text2_2").toString();
+//    ret->text3_2 = line2.value("text3_2").toString();
+//    ret->text4_2 = line2.value("text4_2").toString();
+//    ret->text5_2 = line2.value("text5_2").toString();
+
+//    ret->data1_1 = line1.value("data1_1").toString();
+//    ret->data2_1 = line1.value("data2_1").toString();
+//    ret->data3_1 = line1.value("data3_1").toString();
+//    ret->data4_1 = line1.value("data4_1").toString();
+//    ret->data5_1 = line1.value("data5_1").toString();
+//    ret->data1_2 = line2.value("data1_2").toString();
+//    ret->data2_2 = line2.value("data2_2").toString();
+//    ret->data3_2 = line2.value("data3_2").toString();
+//    ret->data4_2 = line2.value("data4_2").toString();
+//    ret->data5_2 = line2.value("data5_2").toString();
+
+//    return ret;
+//}
+
+QJsonObject BoxModel::toObject()
+{
+    QJsonObject obj;
+    obj.insert("baseModel_Name",baseModel_Name);
+    obj.insert("Model_Name",Model_Name);
+    obj.insert("Type_Name",Type_Name);
+    obj.insert("Type_Data",Type_Data);
+
+    return obj;
+}
+
+QSharedPointer<BoxModel> BoxModel::fromObject(QJsonObject &obj)
+{
+    QSharedPointer<BoxModel> ret(new BoxModel);
+
+    ret->baseModel_Name = obj.value("baseModel_Name").toString();
+    ret->Model_Name = obj.value("Model_Name").toString();
+
+    ret->Type_Name = obj.value("Type_Name").toArray();
+    ret->Type_Data = obj.value("Type_Data").toArray();
+
+    return ret;
+}
+
+QJsonObject PackModel::toObject()
+{
+    QJsonObject obj;
+
+    obj.insert("BaseModel_Name",BaseModel_Name);
+    obj.insert("Model_Name",Model_Name);
+    obj.insert("Type_Name",Type_Name);
+    obj.insert("Type_Data",Type_Data);
+
+    return obj;
+}
+
+QSharedPointer<PackModel> PackModel::fromObject(QJsonObject &obj)
+{
+    QSharedPointer<PackModel> ret(new PackModel);
+
+    ret->BaseModel_Name = obj.value("BaseModel_Name").toString();
+    ret->Model_Name = obj.value("Model_Name").toString();
+
+    ret->Type_Name = obj.value("Type_Name").toArray();
+    ret->Type_Data = obj.value("Type_Data").toArray();
+
+    return ret;
+}

+ 70 - 0
struct_/modelinfo.h

@@ -0,0 +1,70 @@
+#ifndef MODELINFO_H
+#define MODELINFO_H
+
+#include <QObject>
+#include "QJsonObject"
+#include "QJsonArray"
+#include <QSharedPointer>
+
+//struct BoxModel{
+
+//    QString ModelName;
+
+//    QString text1_1;  //text输入框第一行第一排
+//    QString text2_1;
+//    QString text3_1;
+//    QString text4_1;
+//    QString text5_1;
+//    QString text1_2;    //text输入框第一行第二排
+//    QString text2_2;
+//    QString text3_2;
+//    QString text4_2;
+//    QString text5_2;
+
+//    QString data1_1;  //下拉选框第一行第一排
+//    QString data2_1;
+//    QString data3_1;
+//    QString data4_1;
+//    QString data5_1;
+//    QString data1_2;    //下拉选框第一行第二排
+//    QString data2_2;
+//    QString data3_2;
+//    QString data4_2;
+//    QString data5_2;
+
+//    QJsonObject toObject();
+//    static QSharedPointer<BoxModel> fromObject(QJsonObject &obj);
+//};
+
+struct BoxModel{
+    QString baseModel_Name;
+
+    QString Model_Name;
+
+    QJsonArray Type_Name;
+    QJsonArray Type_Data;
+
+    QJsonObject toObject();
+    static QSharedPointer<BoxModel> fromObject(QJsonObject &obj);
+};
+
+struct PackModel{
+
+    QString BaseModel_Name;
+    QString Model_Name;
+
+    QJsonArray Type_Name;
+    QJsonArray Type_Data;
+
+    QJsonObject toObject();
+    static QSharedPointer<PackModel> fromObject(QJsonObject &obj);
+
+};
+
+class ModelInfo
+{
+public:
+    ModelInfo();
+};
+
+#endif // MODELINFO_H

+ 2 - 0
struct_/packinfo.cpp

@@ -117,6 +117,7 @@ QJsonObject PackInfo::toObject()
     ret.insert("telephone",telephone);
     ret.insert("customer",customer);
     ret.insert("batch_no",batch_no);
+    ret.insert("autoRuku",autoRuku);
     ret.insert("warehouse_id",warehouse_id);
 
     ret.insert("packType",packType);
@@ -153,6 +154,7 @@ QSharedPointer<PackInfo> PackInfo::fromObject(QJsonObject &obj)
     ret->telephone = obj.value("telephone").toString();
     ret->customer = obj.value("customer").toString();
     ret->batch_no = obj.value("batch_no").toString();
+    ret->autoRuku = obj.value("autoRuku").toBool();
     ret->warehouse_id = obj.value("warehouse_id").toInt();
 
     ret->packType = obj.value("packType").toInt();

+ 3 - 0
struct_/packinfo.h

@@ -15,6 +15,7 @@ struct RuKuInfo
     int warehouse_id;
     int way;
     QJsonArray product_details;
+    int product_id;
     QString remark;
 
     QJsonObject toObject();
@@ -39,6 +40,7 @@ struct BoxInfo
     QString sort;//	是	string	排序
     QString remark;//	否	string	备注
 
+
     QJsonObject toObject();
 
     static QSharedPointer<BoxInfo> fromObject(QSharedPointer<PackInfo> & pack, QJsonObject &obj);
@@ -65,6 +67,7 @@ public:
     QString carton_type;//	是	string	纸箱
     int operator_id = 0;//	是	int	操作员ID
     QString batch_no;//批号
+    bool autoRuku;//    打包及入库是否点击
     int warehouse_id;//仓库id
 
     QString remark;//	否	string

+ 8 - 8
struct_/projectinfo.h

@@ -35,17 +35,17 @@ struct ProjectInfo
     QString bucket_weight;//	string	筒重
     QString machine_no;//	string	机台
     QString carton_type;//	string	纸箱
-    QString limit_number;//	string	限制打包
+    QString limit_number;//	string	限制打包*
     QString bucket_number;//	string	筒数
-    QString cake_float;//	string	丝饼浮动
-    QString box_float;//	string	纸箱浮动
-    QString box_rule;//	string	箱号规则
+    QString cake_float;//	string	丝饼浮动*
+    QString box_float;//	string	纸箱浮动*
+    QString box_rule;//	string	箱号规则*
     QString customer;//	string	箱单抬头
     QString tel;//电话
-    QString remark;//	string	备注
-    bool is_disable;//	bool	是否禁用
-    qint64 create_time;//	int	创建时间
-    qint64 modified_time;//	int	更新时间
+    QString remark;//	string	备注*
+    bool is_disable;//	bool	是否禁用*
+    qint64 create_time;//	int	创建时间*
+    qint64 modified_time;//	int	更新时间*
 
     QJsonObject toObject();
 

+ 131 - 20
widget/fixedweightpackform.cpp

@@ -17,6 +17,9 @@ FixedWeightPackForm::FixedWeightPackForm(QWidget *parent) :
     connect(glo,&GlobalInfo::dengJiUped,this,&FixedWeightPackForm::upDengjiInfo);
     connect(glo,&GlobalInfo::doInited,this,&FixedWeightPackForm::changeSpecs);
     connect(glo,&GlobalInfo::wareUped,this,&FixedWeightPackForm::upWare);
+    connect(glo,&GlobalInfo::boxModelUped,this,&FixedWeightPackForm::upBoxModelList);
+    connect(glo,&GlobalInfo::packModelUpde,this,&FixedWeightPackForm::upPackModelList);
+
     auto dt = CacheFile::readFile("dingzhongInfo.cache");
     auto list = QString::fromUtf8(dt).split("[,]");
     if(list.size() == 2){
@@ -39,16 +42,22 @@ void FixedWeightPackForm::calcData()
     double tz = ui->tongzhong->currentText().toDouble();
     double ts = ui->tongshu->text().toDouble();
     if(ui->showMaoZhong->isChecked()){
-        gross_weight = ui->grossWeight_2->text().toDouble();
+        gross_weight = floor((ui->grossWeight_2->text().toDouble()+chengZhongJingDuModel_Num)*100)/100;
+        netNum = floor(((ui->grossWeight_2->text().toDouble() - pz - tz * ts)+chengZhongJingDuModel_Num)*100)/100;
 
-        netNum = gross_weight - pz - tz * ts;
+        f_gross_weight = float(floor((gross_weight+f_chengZhongJingDuModel_Num)*10))/10;
+        f_netNum = float(floor((netNum+f_chengZhongJingDuModel_Num)*10))/10;
 
     } else {
-        netNum = ui->grossWeight_2->text().toDouble();
-        gross_weight = netNum + pz + tz*ts;
+        netNum = floor((ui->grossWeight_2->text().toDouble()+chengZhongJingDuModel_Num)*100)/100;
+        gross_weight = floor(((ui->grossWeight_2->text().toDouble() + pz + tz*ts)+chengZhongJingDuModel_Num)*100)/100;
+
+        f_gross_weight = float(floor((gross_weight+f_chengZhongJingDuModel_Num)*10))/10;
+        f_netNum = float(floor((netNum+f_chengZhongJingDuModel_Num)*10))/10;
     }
     if(netNum<0){
         netNum = 0.00;
+        f_netNum = 0.0;
     }
 }
 
@@ -66,7 +75,6 @@ void FixedWeightPackForm::save()
 
 void FixedWeightPackForm::on_addPackList_clicked()
 {
-
     if(packinfo.isNull()) return;
     if(!packinfo.isNull()&&packinfo->boxes().size()>0){
         packinfo->quantity = packinfo->boxes().size();
@@ -77,12 +85,19 @@ void FixedWeightPackForm::on_addPackList_clicked()
         packinfo->telephone = ui->taiPhone->text();
     }
 //    qDebug()<<packinfo->boxes().at(0)->tube_number;
+
+    packinfo->autoRuku = ui->ruku->isChecked();
     if(ui->AutoSync->isChecked() && !GlobalInfo::this_()->isNoLine())
-        packServer->send(packinfo,isRuku);
+        packServer->send(packinfo);
     Manger->savePackInfo(packinfo);
 //    GlobalInfo::this_()->packInfoManger()->setPackInfoSync(packinfo->codeSingle(),packinfo->time(),true);
-    if(ui->madanPrint->isChecked())
-        GlobalInfo::this_()->printerPack(packinfo);
+    if(ui->madanPrint->isChecked()){
+        if(ui->madan->currentIndex() == 0){
+            GlobalInfo::this_()->printerPack(packinfo);
+        }else{
+            GlobalInfo::this_()->printerPackModel(packinfo,ui->madan->currentIndex()-1);
+        }
+    }
     ui->tableWidget->clearContents();
     ui->tableWidget->setRowCount(0);
 
@@ -102,12 +117,22 @@ void FixedWeightPackForm::on_addBoxList_clicked()
         return;
     }
     calcData();
-    if(netNum<=0){
-//        netNum = 0.00;
-        QMessageBox::information(this,tr("注意"),tr("重量异常"));
-        return;
+
+    if(chengZhongJingDu == 2){
+        if(netNum<=0){
+    //        netNum = 0.00;
+            QMessageBox::information(this,tr("注意"),tr("重量异常"));
+            return;
+        }
+    }else if(chengZhongJingDu == 1){
+        if(f_netNum<=0){
+    //        netNum = 0.00;
+            QMessageBox::information(this,tr("注意"),tr("重量异常"));
+            return;
+        }
     }
 
+
     checkPackInfo(); //检查packinfo isNull
     //当当前箱数大于等于最大箱数是启动on_addPackList_clicked();
     if(packinfo->boxes().size() >= ui->comboBox->currentText().toInt()){
@@ -121,9 +146,15 @@ void FixedWeightPackForm::on_addBoxList_clicked()
     calcData();
     box->box_weight = int(ui->pizhong->currentText().toDouble()*1000);
     box->tube_number = ui->tongshu->text().toInt();
-    box->bucket_weight = int((ui->tongzhong->currentText().toDouble()*ui->tongshu->text().toDouble())*1000);
-    box->gross_weight = int(gross_weight*1000);
-    box->net_weight = int(netNum*1000);
+//    box->bucket_weight = int((ui->tongzhong->currentText().toDouble()*ui->tongshu->text().toDouble())*1000);
+    box->bucket_weight = int(floor((ui->tongzhong->currentText().toDouble()*ui->tongshu->text().toDouble()+0.005)*100)*10);
+    if(chengZhongJingDu == 2){
+        box->gross_weight = int(gross_weight*1000);
+        box->net_weight = int(netNum*1000);
+    }else if(chengZhongJingDu == 1){
+        box->gross_weight = int(f_gross_weight*1000);
+        box->net_weight = int(f_netNum*1000);
+    }
     box->Level = ui->dengji->currentText();
     box->twist_type = ui->nianxiang->currentText();
     box->bucket_color = ui->guanse->currentText();
@@ -132,13 +163,27 @@ void FixedWeightPackForm::on_addBoxList_clicked()
     packinfo->level = ui->dengji->currentText();
     packinfo->level_id = ui->dengji->currentData().toInt();
     packinfo->warehouse_id = ui->wareBox->currentData().toInt();
+    packinfo->autoRuku = ui->ruku->isChecked();
     addTableWidget(box,index);
 
 
 //    把box数据添加到packinfo的boxes数据表里;
     packinfo->addBoxInfoList(box);
-    if(ui->xiangdanPrint->isChecked())
-        GlobalInfo::this_()->printerBox(box);
+//    qDebug()<<"currentindex"<<ui->xiangdan->currentIndex();
+    if(ui->xiangdanPrint->isChecked()){
+        if(ui->xiangdan->currentIndex() == 0){
+            GlobalInfo::this_()->printerBox(box);
+        }else{
+            GlobalInfo::this_()->printerBoxModel(box,ui->xiangdan->currentIndex()-1);
+        }
+    }
+
+//    if(ui->xiangdanPrint->isChecked()){
+//        if(ui->xiangdan->currentIndex()==0){
+//            GlobalInfo::this_()->printerBox(box);
+//        }
+//    }
+//    qDebug()<<ui->xiangdan->currentIndex();
     upSum();
     //添加数据库
 //    aputils.insertDetailsSQL(box,packinfo->codeSingle());
@@ -164,7 +209,7 @@ 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_time = QDate::currentDate().toString("yyyy-MM-dd");
         packinfo->packing_type = _info->category;
         packinfo->packType = 0;
 
@@ -192,10 +237,10 @@ void FixedWeightPackForm::addTableWidget(QSharedPointer<BoxInfo> box, int row)
 
     ui->tableWidget->setItem(row,0,new QTableWidgetItem(box->caseNumber()));
     ui->tableWidget->setItem(row,1,new QTableWidgetItem(QString::number(box->tube_number)));
-    ui->tableWidget->setItem(row,2,new QTableWidgetItem(getDecimalbit(box->gross_weight / 1000.00)));
+    ui->tableWidget->setItem(row,2,new QTableWidgetItem(QString::number(box->gross_weight / 1000.00)));
     ui->tableWidget->setItem(row,3,new QTableWidgetItem(ui->tongzhong->currentText()));
     ui->tableWidget->setItem(row,4,new QTableWidgetItem(box->bucket_color));
-    ui->tableWidget->setItem(row,5,new QTableWidgetItem(getDecimalbit(box->net_weight / 1000.00)));
+    ui->tableWidget->setItem(row,5,new QTableWidgetItem(QString::number(box->net_weight / 1000.00)));
     ui->tableWidget->item(row,0)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
     ui->tableWidget->item(row,1)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
     ui->tableWidget->item(row,2)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
@@ -252,6 +297,27 @@ void FixedWeightPackForm::upconfig()
 {
 
     DaBaoConfig config = glo->dbConfig();
+
+    //称重精度
+    chengZhongJingDu = config.chengZhongJIngDu;
+
+    //称重精度方式//4:四舍五入 5:二舍三入 6:一舍二入
+    chengZhongJingDuModel = config.chengZhongJingDuMode;
+    switch (chengZhongJingDuModel) {
+        case 4:
+            chengZhongJingDuModel_Num = 0.005;
+            f_chengZhongJingDuModel_Num = 0.05;
+            break;
+        case 5:
+            chengZhongJingDuModel_Num = 0.007;
+            f_chengZhongJingDuModel_Num = 0.07;
+            break;
+        case 6:
+            chengZhongJingDuModel_Num = 0.008;
+            f_chengZhongJingDuModel_Num = 0.08;
+            break;
+    }
+//    qDebug()<<"称重精度数据"<<chengZhongJingDuModel_Num;
     // 码数
     ui->comboBox->clear();
     for(int i = 0; i < config.mashu.size(); ++i){
@@ -312,6 +378,26 @@ void FixedWeightPackForm::upWare()
     }
 }
 
+void FixedWeightPackForm::upBoxModelList()
+{
+    ui->xiangdan->clear();
+    ui->xiangdan->addItem("默认箱单");
+    QList<QSharedPointer<BoxModel>> boxList = glo->BoxModelList();
+    for(int i = 0;i<boxList.size();i++){
+        ui->xiangdan->addItem(boxList.at(i)->Model_Name);
+    }
+}
+
+void FixedWeightPackForm::upPackModelList()
+{
+    ui->madan->clear();
+    ui->madan->addItem("默认码单");
+    QList<QSharedPointer<PackModel>> packList = glo->PackModelList();
+    for(int i = 0;i<packList.size();i++){
+        ui->madan->addItem(packList.at(i)->Model_Name);
+    }
+}
+
 void FixedWeightPackForm::on_pushPiLiang_clicked()
 {
 //    int tsize = 0;
@@ -565,3 +651,28 @@ void FixedWeightPackForm::on_ruku_stateChanged(int arg1)
     }
     isRuku = false;
 }
+
+void FixedWeightPackForm::on_useNewDataButton_clicked()
+{
+    if(packinfo.isNull()) return;
+    for(int i =  0; i < packinfo->boxInfoSize(); ++i){
+        QSharedPointer<BoxInfo> 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->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();
+        box->bucket_color = ui->guanse->currentText();
+        box->sort = "1";
+    }
+    packinfo->level = ui->dengji->currentText();
+    packinfo->level_id = ui->dengji->currentData().toInt();
+    packinfo->customer = ui->taitou->text();
+    packinfo->telephone = ui->taiPhone->text();
+    packinfo->autoRuku = ui->ruku->isChecked();
+    packinfo->warehouse_id = ui->wareBox->currentData().toInt();
+    restTableWidget();
+}

+ 12 - 1
widget/fixedweightpackform.h

@@ -50,11 +50,15 @@ private slots:
 
     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:
@@ -90,10 +94,17 @@ private:
     PackInfoManger *Manger;// = GlobalInfo::this_()->packInfoManger();
 
     double netNum = 0.00;
-    double gross_weight = 0.0;
+    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.00;//打包精度计算时所需的数,类似四舍五入时把double+0.5在向下取整;
+    double f_chengZhongJingDuModel_Num = 0.00;//单精度计算时的数;
 };
 
 #endif // FIXEDWEIGHTPACKFORM_H

+ 717 - 566
widget/fixedweightpackform.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1270</width>
-    <height>697</height>
+    <width>1303</width>
+    <height>797</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -17,99 +17,167 @@
    <property name="topMargin">
     <number>0</number>
    </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
    <property name="bottomMargin">
     <number>0</number>
    </property>
-   <item row="0" column="0">
-    <layout class="QHBoxLayout" name="horizontalLayout_6">
-     <property name="spacing">
-      <number>0</number>
+   <property name="verticalSpacing">
+    <number>0</number>
+   </property>
+   <item row="1" column="0">
+    <widget class="QWidget" name="widget" native="true">
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>30</height>
+      </size>
      </property>
-     <item>
-      <widget class="QWidget" name="widget_4" native="true">
-       <layout class="QGridLayout" name="gridLayout_4">
-        <property name="bottomMargin">
-         <number>11</number>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_13">
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <item row="0" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <property name="spacing">
+         <number>7</number>
         </property>
-        <item row="1" column="0" colspan="5">
-         <widget class="QTableWidget" name="tableWidget">
-          <property name="minimumSize">
-           <size>
-            <width>0</width>
-            <height>0</height>
-           </size>
+        <item>
+         <widget class="QLabel" name="label">
+          <property name="text">
+           <string>合计</string>
           </property>
-          <property name="maximumSize">
-           <size>
-            <width>9999</width>
-            <height>16777215</height>
-           </size>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_2">
+          <property name="text">
+           <string>筒数:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="labelTongZHong">
+          <property name="text">
+           <string>0</string>
           </property>
-          <column>
-           <property name="text">
-            <string>箱号</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>筒数</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>毛重</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>筒重</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>管色</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>净重</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>操作</string>
-           </property>
-          </column>
          </widget>
         </item>
-        <item row="0" column="4">
-         <widget class="QCheckBox" name="AutoSync">
+        <item>
+         <widget class="QLabel" name="label_3">
+          <property name="text">
+           <string>毛重:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="labelWight">
+          <property name="text">
+           <string>0</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_4">
           <property name="text">
-           <string>自动同步</string>
+           <string>净重:</string>
           </property>
-          <property name="checked">
-           <bool>true</bool>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="labelJing">
+          <property name="text">
+           <string>0</string>
           </property>
          </widget>
         </item>
-        <item row="0" column="3">
-         <widget class="QRadioButton" name="buding">
+        <item>
+         <widget class="QLabel" name="label_7">
           <property name="text">
-           <string>不定重打包</string>
+           <string>码单:</string>
           </property>
          </widget>
         </item>
-        <item row="0" column="2">
-         <widget class="QRadioButton" name="dingzhong">
+        <item>
+         <widget class="QLabel" name="nowCode">
           <property name="text">
-           <string>定重打包</string>
+           <string>0</string>
           </property>
          </widget>
         </item>
+       </layout>
+      </item>
+      <item row="0" column="2">
+       <widget class="QPushButton" name="backButton">
+        <property name="minimumSize">
+         <size>
+          <width>93</width>
+          <height>28</height>
+         </size>
+        </property>
+        <property name="text">
+         <string>返回主页</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <spacer name="horizontalSpacer_4">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>980</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="0" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout_6">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QWidget" name="widget_4" native="true">
+       <layout class="QGridLayout" name="gridLayout_4">
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>3</number>
+        </property>
         <item row="0" column="0">
          <layout class="QGridLayout" name="gridLayout_3">
+          <property name="spacing">
+           <number>0</number>
+          </property>
           <item row="0" column="0">
            <widget class="QPushButton" name="pushEditBatch">
+            <property name="minimumSize">
+             <size>
+              <width>55</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="font">
+             <font>
+              <pointsize>9</pointsize>
+             </font>
+            </property>
             <property name="text">
              <string>批量修改</string>
             </property>
@@ -117,20 +185,46 @@
           </item>
           <item row="0" column="4">
            <layout class="QGridLayout" name="gridLayout_2">
-            <item row="0" column="2">
+            <property name="horizontalSpacing">
+             <number>0</number>
+            </property>
+            <item row="0" column="6">
              <widget class="QPushButton" name="pushContinue">
+              <property name="minimumSize">
+               <size>
+                <width>30</width>
+                <height>0</height>
+               </size>
+              </property>
               <property name="maximumSize">
                <size>
-                <width>50</width>
+                <width>34</width>
                 <height>16777215</height>
                </size>
               </property>
+              <property name="font">
+               <font>
+                <pointsize>9</pointsize>
+               </font>
+              </property>
               <property name="text">
                <string>接续</string>
               </property>
              </widget>
             </item>
-            <item row="0" column="3">
+            <item row="0" column="9">
+             <widget class="QRadioButton" name="dingzhong">
+              <property name="font">
+               <font>
+                <pointsize>9</pointsize>
+               </font>
+              </property>
+              <property name="text">
+               <string>定重打包</string>
+              </property>
+             </widget>
+            </item>
+            <item row="0" column="7">
              <spacer name="horizontalSpacer">
               <property name="orientation">
                <enum>Qt::Horizontal</enum>
@@ -143,23 +237,90 @@
               </property>
              </spacer>
             </item>
-            <item row="0" column="1">
+            <item row="0" column="11">
+             <widget class="QCheckBox" name="AutoSync">
+              <property name="minimumSize">
+               <size>
+                <width>70</width>
+                <height>0</height>
+               </size>
+              </property>
+              <property name="font">
+               <font>
+                <pointsize>9</pointsize>
+               </font>
+              </property>
+              <property name="text">
+               <string>自动同步</string>
+              </property>
+              <property name="checked">
+               <bool>true</bool>
+              </property>
+             </widget>
+            </item>
+            <item row="0" column="3">
+             <widget class="QPushButton" name="pushNoSyncList">
+              <property name="minimumSize">
+               <size>
+                <width>0</width>
+                <height>0</height>
+               </size>
+              </property>
+              <property name="font">
+               <font>
+                <pointsize>9</pointsize>
+               </font>
+              </property>
+              <property name="text">
+               <string>未同步列表</string>
+              </property>
+             </widget>
+            </item>
+            <item row="0" column="10">
+             <widget class="QRadioButton" name="buding">
+              <property name="font">
+               <font>
+                <pointsize>9</pointsize>
+               </font>
+              </property>
+              <property name="text">
+               <string>不定重打包</string>
+              </property>
+             </widget>
+            </item>
+            <item row="0" column="5">
              <widget class="QPushButton" name="pushSync">
+              <property name="minimumSize">
+               <size>
+                <width>30</width>
+                <height>0</height>
+               </size>
+              </property>
               <property name="maximumSize">
                <size>
-                <width>50</width>
+                <width>34</width>
                 <height>16777215</height>
                </size>
               </property>
+              <property name="font">
+               <font>
+                <pointsize>9</pointsize>
+               </font>
+              </property>
               <property name="text">
                <string>同步</string>
               </property>
              </widget>
             </item>
-            <item row="0" column="0">
-             <widget class="QPushButton" name="pushNoSyncList">
+            <item row="0" column="8">
+             <widget class="QCheckBox" name="ruku">
+              <property name="font">
+               <font>
+                <pointsize>9</pointsize>
+               </font>
+              </property>
               <property name="text">
-               <string>未同步列表</string>
+               <string>打包及入库</string>
               </property>
              </widget>
             </item>
@@ -167,42 +328,95 @@
           </item>
          </layout>
         </item>
-        <item row="0" column="1">
-         <widget class="QCheckBox" name="ruku">
-          <property name="text">
-           <string>打包及入库</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </widget>
-     </item>
-     <item>
-      <widget class="QWidget" name="widget_3" native="true">
-       <property name="minimumSize">
-        <size>
-         <width>500</width>
-         <height>0</height>
-        </size>
-       </property>
-       <property name="maximumSize">
-        <size>
-         <width>500</width>
-         <height>16777215</height>
-        </size>
-       </property>
-       <layout class="QGridLayout" name="gridLayout_9">
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>11</number>
-        </property>
         <item row="1" column="0">
-         <layout class="QHBoxLayout" name="horizontalLayout_2">
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_4">
-            <item>
+         <widget class="QTableWidget" name="tableWidget">
+          <property name="minimumSize">
+           <size>
+            <width>0</width>
+            <height>0</height>
+           </size>
+          </property>
+          <property name="maximumSize">
+           <size>
+            <width>9999</width>
+            <height>16777215</height>
+           </size>
+          </property>
+          <column>
+           <property name="text">
+            <string>箱号</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>筒数</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>毛重</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>筒重</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>管色</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>净重</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>操作</string>
+           </property>
+          </column>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item>
+      <widget class="QWidget" name="widget_3" native="true">
+       <property name="minimumSize">
+        <size>
+         <width>500</width>
+         <height>0</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>500</width>
+         <height>16777215</height>
+        </size>
+       </property>
+       <layout class="QGridLayout" name="gridLayout_9">
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <property name="horizontalSpacing">
+         <number>7</number>
+        </property>
+        <item row="1" column="0">
+         <layout class="QHBoxLayout" name="horizontalLayout_2">
+          <item>
+           <layout class="QVBoxLayout" name="verticalLayout_4">
+            <item>
              <widget class="QLabel" name="label_8">
               <property name="text">
                <string>码数</string>
@@ -249,76 +463,409 @@
           </item>
          </layout>
         </item>
-        <item row="5" column="0">
-         <widget class="QTableWidget" name="tableWidget_2">
-          <column>
-           <property name="text">
-            <string>选择</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>规格</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>类型</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>批号</string>
-           </property>
-          </column>
-          <column>
-           <property name="text">
-            <string>颜色</string>
-           </property>
-          </column>
-         </widget>
-        </item>
-        <item row="2" column="0">
-         <layout class="QHBoxLayout" name="horizontalLayout_11">
-          <item>
-           <widget class="QCheckBox" name="xiangdanPrint">
-            <property name="text">
-             <string>打印箱单</string>
+        <item row="0" column="0">
+         <layout class="QGridLayout" name="gridLayout_8">
+          <item row="0" column="5">
+           <widget class="QSpinBox" name="tongshu">
+            <property name="minimumSize">
+             <size>
+              <width>120</width>
+              <height>61</height>
+             </size>
             </property>
-            <property name="checked">
+            <property name="maximumSize">
+             <size>
+              <width>141</width>
+              <height>61</height>
+             </size>
+            </property>
+            <property name="font">
+             <font>
+              <pointsize>30</pointsize>
+             </font>
+            </property>
+            <property name="value">
+             <number>6</number>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1" colspan="3">
+           <widget class="QPushButton" name="addBoxList">
+            <property name="enabled">
              <bool>true</bool>
             </property>
+            <property name="minimumSize">
+             <size>
+              <width>120</width>
+              <height>50</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>136</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>
            </widget>
           </item>
-          <item>
-           <widget class="QCheckBox" name="madanPrint">
+          <item row="0" column="8">
+           <widget class="QSpinBox" name="spinBox">
+            <property name="minimumSize">
+             <size>
+              <width>120</width>
+              <height>61</height>
+             </size>
+            </property>
+            <property name="font">
+             <font>
+              <pointsize>30</pointsize>
+             </font>
+            </property>
+            <property name="alignment">
+             <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+            </property>
+            <property name="maximum">
+             <number>999</number>
+            </property>
+            <property name="value">
+             <number>20</number>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0" colspan="2">
+           <widget class="QLabel" name="labelWidget">
+            <property name="minimumSize">
+             <size>
+              <width>0</width>
+              <height>16</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>41</width>
+              <height>999</height>
+             </size>
+            </property>
+            <property name="font">
+             <font>
+              <pointsize>10</pointsize>
+             </font>
+            </property>
             <property name="text">
-             <string>打印码单</string>
+             <string>毛重</string>
             </property>
-            <property name="checked">
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
+            <property name="wordWrap">
              <bool>true</bool>
             </property>
            </widget>
           </item>
-          <item>
-           <widget class="QCheckBox" name="showMaoZhong">
+          <item row="1" column="4">
+           <spacer name="horizontalSpacer_6">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>13</width>
+              <height>17</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="0" column="3" colspan="2">
+           <widget class="QLabel" name="label_24">
+            <property name="minimumSize">
+             <size>
+              <width>0</width>
+              <height>16</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>31</width>
+              <height>999</height>
+             </size>
+            </property>
+            <property name="font">
+             <font>
+              <pointsize>10</pointsize>
+             </font>
+            </property>
             <property name="text">
-             <string>显示毛重</string>
+             <string>筒数</string>
             </property>
-            <property name="checked">
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
+            <property name="wordWrap">
              <bool>true</bool>
             </property>
            </widget>
           </item>
-         </layout>
-        </item>
-        <item row="3" column="0">
-         <widget class="QWidget" name="widget_2" native="true">
-          <property name="minimumSize">
-           <size>
-            <width>470</width>
-            <height>0</height>
-           </size>
+          <item row="0" column="6" colspan="2">
+           <widget class="QLabel" name="label_6">
+            <property name="maximumSize">
+             <size>
+              <width>29</width>
+              <height>16777215</height>
+             </size>
+            </property>
+            <property name="font">
+             <font>
+              <pointsize>10</pointsize>
+             </font>
+            </property>
+            <property name="layoutDirection">
+             <enum>Qt::LeftToRight</enum>
+            </property>
+            <property name="text">
+             <string>箱数</string>
+            </property>
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
+            <property name="wordWrap">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="7">
+           <spacer name="horizontalSpacer_7">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>13</width>
+              <height>17</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="1" column="5" colspan="2">
+           <widget class="QPushButton" name="addPackList">
+            <property name="enabled">
+             <bool>true</bool>
+            </property>
+            <property name="minimumSize">
+             <size>
+              <width>120</width>
+              <height>50</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>136</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>
+           </widget>
+          </item>
+          <item row="1" column="8">
+           <widget class="QPushButton" name="pushPiLiang">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="minimumSize">
+             <size>
+              <width>120</width>
+              <height>50</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>135</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>
+           </widget>
+          </item>
+          <item row="1" column="0">
+           <spacer name="horizontalSpacer_5">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>17</width>
+              <height>17</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="0" column="2">
+           <widget class="QLineEdit" name="grossWeight_2">
+            <property name="minimumSize">
+             <size>
+              <width>0</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>141</width>
+              <height>61</height>
+             </size>
+            </property>
+            <property name="font">
+             <font>
+              <pointsize>30</pointsize>
+             </font>
+            </property>
+            <property name="text">
+             <string/>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item row="2" column="0">
+         <layout class="QHBoxLayout" name="horizontalLayout_11">
+          <item>
+           <widget class="QCheckBox" name="xiangdanPrint">
+            <property name="text">
+             <string>打印箱单</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QCheckBox" name="madanPrint">
+            <property name="text">
+             <string>打印码单</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QCheckBox" name="showMaoZhong">
+            <property name="text">
+             <string>显示毛重</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item row="5" column="0">
+         <widget class="QTableWidget" name="tableWidget_2">
+          <column>
+           <property name="text">
+            <string>选择</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>规格</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>类型</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>批号</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>颜色</string>
+           </property>
+          </column>
+         </widget>
+        </item>
+        <item row="4" column="0">
+         <layout class="QGridLayout" name="gridLayout_7">
+          <item row="0" column="3">
+           <spacer name="horizontalSpacer_2">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>168</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="0" column="2">
+           <widget class="QPushButton" name="searchButton">
+            <property name="text">
+             <string>搜索</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0">
+           <widget class="QLabel" name="label_5">
+            <property name="font">
+             <font>
+              <pointsize>11</pointsize>
+             </font>
+            </property>
+            <property name="text">
+             <string>快速查找</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="4">
+           <widget class="QPushButton" name="useNewDataButton">
+            <property name="text">
+             <string>应用</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item row="3" column="0">
+         <widget class="QWidget" name="widget_2" native="true">
+          <property name="minimumSize">
+           <size>
+            <width>500</width>
+            <height>0</height>
+           </size>
           </property>
           <property name="maximumSize">
            <size>
@@ -495,7 +1042,11 @@
                 </widget>
                </item>
                <item>
-                <widget class="QComboBox" name="tongzhong"/>
+                <widget class="QComboBox" name="tongzhong">
+                 <property name="editable">
+                  <bool>true</bool>
+                 </property>
+                </widget>
                </item>
               </layout>
              </item>
@@ -550,411 +1101,11 @@
           </layout>
          </widget>
         </item>
-        <item row="0" column="0">
-         <layout class="QGridLayout" name="gridLayout_8">
-          <item row="0" column="0" colspan="2">
-           <widget class="QLabel" name="labelWidget">
-            <property name="minimumSize">
-             <size>
-              <width>31</width>
-              <height>16</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>41</width>
-              <height>16</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>9</pointsize>
-             </font>
-            </property>
-            <property name="text">
-             <string>毛重</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="2">
-           <widget class="QLineEdit" name="grossWeight_2">
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>0</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>141</width>
-              <height>61</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>25</pointsize>
-             </font>
-            </property>
-            <property name="text">
-             <string>0</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="3" colspan="2">
-           <widget class="QLabel" name="label_24">
-            <property name="minimumSize">
-             <size>
-              <width>31</width>
-              <height>16</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>31</width>
-              <height>16</height>
-             </size>
-            </property>
-            <property name="text">
-             <string>筒数</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="5">
-           <widget class="QSpinBox" name="tongshu">
-            <property name="minimumSize">
-             <size>
-              <width>120</width>
-              <height>61</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>141</width>
-              <height>61</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>25</pointsize>
-             </font>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="6" colspan="2">
-           <widget class="QLabel" name="label_6">
-            <property name="text">
-             <string>箱数</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="8">
-           <widget class="QSpinBox" name="spinBox">
-            <property name="minimumSize">
-             <size>
-              <width>120</width>
-              <height>61</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>25</pointsize>
-             </font>
-            </property>
-            <property name="alignment">
-             <set>Qt::AlignCenter</set>
-            </property>
-            <property name="maximum">
-             <number>999</number>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="0">
-           <spacer name="horizontalSpacer_5">
-            <property name="orientation">
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>17</width>
-              <height>17</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-          <item row="1" column="1" colspan="3">
-           <widget class="QPushButton" name="addBoxList">
-            <property name="enabled">
-             <bool>true</bool>
-            </property>
-            <property name="minimumSize">
-             <size>
-              <width>120</width>
-              <height>50</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>136</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>
-           </widget>
-          </item>
-          <item row="1" column="4">
-           <spacer name="horizontalSpacer_6">
-            <property name="orientation">
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>13</width>
-              <height>17</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-          <item row="1" column="5" colspan="2">
-           <widget class="QPushButton" name="addPackList">
-            <property name="enabled">
-             <bool>true</bool>
-            </property>
-            <property name="minimumSize">
-             <size>
-              <width>120</width>
-              <height>50</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>136</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>
-           </widget>
-          </item>
-          <item row="1" column="7">
-           <spacer name="horizontalSpacer_7">
-            <property name="orientation">
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>13</width>
-              <height>17</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-          <item row="1" column="8">
-           <widget class="QPushButton" name="pushPiLiang">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="minimumSize">
-             <size>
-              <width>120</width>
-              <height>50</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>135</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>
-           </widget>
-          </item>
-         </layout>
-        </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">
-             <font>
-              <pointsize>11</pointsize>
-             </font>
-            </property>
-            <property name="text">
-             <string>快速查找</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="2">
-           <widget class="QPushButton" name="searchButton">
-            <property name="text">
-             <string>搜索</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="3">
-           <spacer name="horizontalSpacer_2">
-            <property name="orientation">
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>168</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-         </layout>
-        </item>
        </layout>
       </widget>
      </item>
     </layout>
    </item>
-   <item row="1" column="0">
-    <widget class="QWidget" name="widget" native="true">
-     <property name="minimumSize">
-      <size>
-       <width>0</width>
-       <height>30</height>
-      </size>
-     </property>
-     <property name="styleSheet">
-      <string notr="true"/>
-     </property>
-     <layout class="QGridLayout" name="gridLayout_13">
-      <property name="topMargin">
-       <number>0</number>
-      </property>
-      <property name="rightMargin">
-       <number>0</number>
-      </property>
-      <item row="0" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout">
-        <property name="spacing">
-         <number>7</number>
-        </property>
-        <item>
-         <widget class="QLabel" name="label">
-          <property name="text">
-           <string>合计</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_2">
-          <property name="text">
-           <string>筒数:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="labelTongZHong">
-          <property name="text">
-           <string>0</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_3">
-          <property name="text">
-           <string>毛重:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="labelWight">
-          <property name="text">
-           <string>0</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_4">
-          <property name="text">
-           <string>净重:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="labelJing">
-          <property name="text">
-           <string>0</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_7">
-          <property name="text">
-           <string>码单:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="nowCode">
-          <property name="text">
-           <string>0</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-      <item row="0" column="1">
-       <spacer name="horizontalSpacer_4">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>980</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
-      <item row="0" column="2">
-       <widget class="QPushButton" name="backButton">
-        <property name="minimumSize">
-         <size>
-          <width>93</width>
-          <height>28</height>
-         </size>
-        </property>
-        <property name="text">
-         <string>返回主页</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
   </layout>
  </widget>
  <resources/>

+ 11 - 4
widget/loginform.cpp

@@ -3,6 +3,7 @@
 #include <QMessageBox>
 #include <pqQtlib/utils/pqfileutils.h>
 #include <QJsonDocument>
+#include "QJsonObject"
 
 using namespace PQ;
 
@@ -43,10 +44,16 @@ void LoginForm::on_pushLogin_clicked()
     auto uname = this->ui->lineUser->text();
     auto upass = this->ui->linePass->text();
     auto url = glo->config()->baseUrl+"/v1/signin";
-    QMap<QString,QString> params;
-    params.insert("password",upass);
-    params.insert("username",uname);
-    request()->post(url,params);
+//    QMap<QString,QString> params;
+//    params.insert("password",upass);
+//    params.insert("username",uname);
+
+    QJsonObject obj;
+    obj.insert("password",upass);
+    obj.insert("username",uname);
+    obj.insert("platform",2);
+
+    request()->post(url,obj);
     ui->status->setVisible(true);
     this->setEnabled(false);
 }

+ 228 - 0
widget/modelselectform.cpp

@@ -0,0 +1,228 @@
+#include "modelselectform.h"
+#include "ui_modelselectform.h"
+#include "QDebug"
+
+ModelSelectForm::ModelSelectForm(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::ModelSelectForm)
+{
+    ui->setupUi(this);
+    connect(glo,&GlobalInfo::boxModelUped,this,&ModelSelectForm::changeToSelectBoxWidget);
+    connect(glo,&GlobalInfo::packModelUpde,this,&ModelSelectForm::changeToSelectPackWidget);
+//    changeToSelectWidget();
+}
+
+ModelSelectForm::~ModelSelectForm()
+{
+    delete ui;
+}
+
+void ModelSelectForm::changeStackedWidget(int status)
+{
+    if(status == 1){
+        changeToSelectBoxWidget();
+        ui->stackedWidget->setCurrentWidget(ui->pageXiangDan);
+    }else if(status == 2){
+        changeToSelectPackWidget();
+        ui->stackedWidget->setCurrentWidget(ui->pageMaDan);
+    }
+}
+
+void ModelSelectForm::changeToSelectBoxWidget()
+{
+    boxModelList = glo->BoxModelList();
+//    qDebug()<<"size:"<<boxModelList.size();
+//    for(int i = 0;i<boxModelList.size();i++){
+//        qDebug()<<boxModelList.at(i)->toObject();
+//    }
+    ui->boxModelSelectWidget->clear();
+    selectBoxModelFoName("基础模板1");
+}
+
+void ModelSelectForm::changeToSelectPackWidget()
+{
+    packModelList = glo->PackModelList();
+    ui->packModelSelectWidget->clear();
+    selectPackModelFoName("基础模板1");
+}
+
+void ModelSelectForm::selectBoxModelFoName(QString baseModelName)
+{
+    auto item = new QTreeWidgetItem(QStringList()<<baseModelName);
+
+    QWidget *tmp_widget = new QWidget();
+    tmp_widget->setMaximumWidth(200);
+    QHBoxLayout *tmp_layout = new QHBoxLayout(tmp_widget);
+    auto addNew = new QPushButton("新建",tmp_widget);
+    addNew->setMaximumWidth(40);
+    auto modelView = new QPushButton("查看",tmp_widget);
+    modelView->setMaximumWidth(40);
+    tmp_layout->addWidget(addNew);
+    tmp_layout->addWidget(modelView);
+    tmp_layout->setSpacing(0);
+    tmp_layout->setMargin(0);
+
+    connect(addNew,&QPushButton::clicked,[baseModelName,this](){this->addNewBoxModel(baseModelName);});
+    connect(modelView,&QPushButton::clicked,[baseModelName,this](){this->boxModelView(baseModelName);});
+    ui->boxModelSelectWidget->addTopLevelItem(item);
+    ui->boxModelSelectWidget->setItemWidget(item,1,tmp_widget);
+
+    QStringList modelName;
+    for(int i = 0;i<boxModelList.size();i++){
+        if(boxModelList.at(i)->baseModel_Name!=baseModelName){
+            qDebug()<<boxModelList.at(i)->baseModel_Name;
+            continue;
+        }
+        modelName.append(boxModelList.at(i)->Model_Name);
+    }
+
+    for(int i = 0;i<modelName.size();i++){
+        QWidget *tep_widget = new QWidget();
+        tep_widget->setMaximumWidth(200);
+        QHBoxLayout *tep_layout = new QHBoxLayout(tep_widget);
+        QPushButton *edit = new QPushButton("编辑");
+        edit->setMaximumWidth(40);
+        QPushButton *del = new QPushButton("删除");
+        del->setMaximumWidth(40);
+        tep_layout->addWidget(edit);
+        tep_layout->addWidget(del);
+        tep_layout->setSpacing(0);
+        tep_layout->setMargin(0);
+
+        QTreeWidgetItem *childitem = new QTreeWidgetItem(QStringList()<<modelName.at(i));
+        item->addChild(childitem);
+        ui->boxModelSelectWidget->setItemWidget(childitem,1,tep_widget);
+        QString ModelName = modelName.at(i);
+        connect(edit,&QPushButton::clicked,[baseModelName,ModelName,this](){this->editBoxModel(baseModelName,ModelName);});
+        connect(del,&QPushButton::clicked,[ModelName,this](){this->delBoxModel(ModelName);});
+    }
+}
+
+void ModelSelectForm::on_backButton_clicked()
+{
+    emit back();
+}
+
+void ModelSelectForm::addNewBoxModel(QString baseModelName)
+{
+    if(baseModelName == "基础模板1"){
+        emit addBoxModel(baseModelName,1);
+    }
+}
+
+void ModelSelectForm::boxModelView(QString baseModelName)
+{
+    qDebug()<<"modelView";
+    emit showBaseBoxModel(baseModelName,2);
+}
+
+void ModelSelectForm::editBoxModel(QString baseModelName,QString modelName)
+{
+    emit editBoxModeled(baseModelName,3,modelName);
+}
+
+void ModelSelectForm::delBoxModel(QString ModelName)
+{
+    _dataDir = PQ::AppPath::this_()->dataDir();
+    if(!_dataDir.exists("BoxModel")){
+        _dataDir.mkdir("BoxModel");
+    }
+    _dataDir.cd("BoxModel");
+    QString fileName = ModelName+"_Model.json";
+    if(_dataDir.remove(fileName)){
+        QMessageBox::information(this,tr("提示"),tr("删除成功"));
+        glo->selectBoxModel();
+    }
+}
+
+//以下是码单
+void ModelSelectForm::selectPackModelFoName(QString baseModelName)
+{
+    auto item = new QTreeWidgetItem(QStringList()<<baseModelName);
+
+    QWidget *tmp_widget = new QWidget();
+    tmp_widget->setMaximumWidth(200);
+    QHBoxLayout *tmp_layout = new QHBoxLayout(tmp_widget);
+    auto addNew = new QPushButton("新建",tmp_widget);
+    addNew->setMaximumWidth(40);
+    auto modelView = new QPushButton("查看",tmp_widget);
+    modelView->setMaximumWidth(40);
+    tmp_layout->addWidget(addNew);
+    tmp_layout->addWidget(modelView);
+    tmp_layout->setSpacing(0);
+    tmp_layout->setMargin(0);
+
+    connect(addNew,&QPushButton::clicked,[baseModelName,this](){this->addNewPackModel(baseModelName);});
+    connect(modelView,&QPushButton::clicked,[baseModelName,this](){this->packModelView(baseModelName);});
+    ui->packModelSelectWidget->addTopLevelItem(item);
+    ui->packModelSelectWidget->setItemWidget(item,1,tmp_widget);
+
+    QStringList modelName;
+    for(int i = 0;i<packModelList.size();i++){
+        if(packModelList.at(i)->BaseModel_Name!=baseModelName){
+            continue;
+        }
+        modelName.append(packModelList.at(i)->Model_Name);
+    }
+
+
+    for(int i = 0;i<modelName.size();i++){
+
+        QWidget *tep_widget = new QWidget();
+        tep_widget->setMaximumWidth(200);
+        QHBoxLayout *tep_layout = new QHBoxLayout(tep_widget);
+        QPushButton *edit = new QPushButton("编辑");
+        edit->setMaximumWidth(40);
+        QPushButton *del = new QPushButton("删除");
+        del->setMaximumWidth(40);
+        tep_layout->addWidget(edit);
+        tep_layout->addWidget(del);
+        tep_layout->setSpacing(0);
+        tep_layout->setMargin(0);
+
+        QTreeWidgetItem *childitem = new QTreeWidgetItem(QStringList()<<modelName.at(i));
+        item->addChild(childitem);
+        ui->packModelSelectWidget->setItemWidget(childitem,1,tep_widget);
+
+        QString ModelName = modelName.at(i);
+        connect(edit,&QPushButton::clicked,[baseModelName,ModelName,this](){this->editPackModel(baseModelName,ModelName);});
+        connect(del,&QPushButton::clicked,[ModelName,this](){this->delPackModel(ModelName);});
+    }
+}
+
+void ModelSelectForm::on_backButton_2_clicked()
+{
+    emit back();
+}
+
+void ModelSelectForm::addNewPackModel(QString baseModelName)
+{
+    if(baseModelName == "基础模板1"){
+        emit addPackModel(baseModelName,1);
+    }
+}
+
+void ModelSelectForm::packModelView(QString baseModelName)
+{
+    qDebug()<<"modelView";
+    emit showBasePackModel(baseModelName,2);
+}
+
+void ModelSelectForm::editPackModel(QString baseModelName , QString ModelName)
+{
+    emit editPackModeled(baseModelName,3,ModelName);
+}
+
+void ModelSelectForm::delPackModel(QString ModelName)
+{
+    _dataDir = PQ::AppPath::this_()->dataDir();
+    if(!_dataDir.exists("PackModel")){
+        _dataDir.mkdir("PackModel");
+    }
+    _dataDir.cd("PackModel");
+    QString fileName = ModelName+"_Model.json";
+    if(_dataDir.remove(fileName)){
+        QMessageBox::information(this,tr("提示"),tr("删除成功"));
+        glo->selectPackModel();
+    }
+}

+ 74 - 0
widget/modelselectform.h

@@ -0,0 +1,74 @@
+#ifndef MODELSELECTFORM_H
+#define MODELSELECTFORM_H
+
+#include <QWidget>
+#include "struct_/modelinfo.h"
+#include "globalinfo.h"
+#include <pqQtlib/core/pqapppath.h>
+#include "pqQtlib/utils/pqfileutils.h"
+
+namespace Ui {
+class ModelSelectForm;
+}
+
+class ModelSelectForm : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit ModelSelectForm(QWidget *parent = nullptr);
+    ~ModelSelectForm();
+
+public slots:
+    void changeStackedWidget(int status);
+
+    void changeToSelectBoxWidget();//获取箱单列表
+    void changeToSelectPackWidget();//获取码单列表
+    void selectBoxModelFoName(QString BaseModelName);//根据基础模板添加tablewidget
+    void selectPackModelFoName(QString baseModelName);//根据基础模板添加tablewidget
+
+signals:
+    void back();
+    //箱单信号
+    void addBoxModel(QString baseModelName,int status,QString ModelName = nullptr);
+    void showBaseBoxModel(QString baseModelName,int status,QString ModelName = nullptr);
+    void editBoxModeled(QString baseModelName,int status,QString modelName);
+
+    //码单信号
+    void addPackModel(QString baseModelName,int status,QString ModelName = nullptr);
+    void showBasePackModel(QString baseModelName,int status,QString ModelName = nullptr);
+    void editPackModeled(QString baseModelName,int status,QString ModelName);
+
+private slots:
+    void on_backButton_clicked();
+
+    void on_backButton_2_clicked();
+
+private slots:
+    //箱单按钮功能
+    void addNewBoxModel(QString baseModelName);
+    void boxModelView(QString baseModelName);
+    void editBoxModel(QString baseModelName,QString ModelName);
+    void delBoxModel(QString ModelName);
+
+    //码单按钮功能
+    void addNewPackModel(QString baseModelName);
+    void packModelView(QString baseMOdelName);
+    void editPackModel(QString baseModelName,QString ModelName);
+    void delPackModel(QString ModelName);
+
+
+private:
+    void test();
+
+
+private:
+    Ui::ModelSelectForm *ui;
+    GlobalInfo * glo = GlobalInfo::this_();
+    QList<QSharedPointer<BoxModel>> boxModelList;
+    QList<QSharedPointer<PackModel>> packModelList;
+
+    QDir _dataDir;
+};
+
+#endif // MODELSELECTFORM_H

+ 259 - 0
widget/modelselectform.ui

@@ -0,0 +1,259 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ModelSelectForm</class>
+ <widget class="QWidget" name="ModelSelectForm">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1097</width>
+    <height>627</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout_2">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QStackedWidget" name="stackedWidget">
+     <property name="currentIndex">
+      <number>1</number>
+     </property>
+     <widget class="QWidget" name="pageXiangDan">
+      <layout class="QGridLayout" name="gridLayout_4">
+       <property name="leftMargin">
+        <number>0</number>
+       </property>
+       <property name="topMargin">
+        <number>0</number>
+       </property>
+       <property name="rightMargin">
+        <number>0</number>
+       </property>
+       <property name="bottomMargin">
+        <number>0</number>
+       </property>
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item row="0" column="0">
+        <widget class="QWidget" name="widget" native="true">
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>45</height>
+          </size>
+         </property>
+         <property name="styleSheet">
+          <string notr="true"/>
+         </property>
+         <layout class="QGridLayout" name="gridLayout">
+          <property name="topMargin">
+           <number>11</number>
+          </property>
+          <property name="bottomMargin">
+           <number>11</number>
+          </property>
+          <item row="0" column="0">
+           <widget class="QPushButton" name="backButton">
+            <property name="text">
+             <string>返回首页</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1">
+           <spacer name="horizontalSpacer">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>335</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="0" column="2">
+           <widget class="QLabel" name="label">
+            <property name="font">
+             <font>
+              <pointsize>14</pointsize>
+             </font>
+            </property>
+            <property name="text">
+             <string>箱单模板</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="3">
+           <spacer name="horizontalSpacer_2">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>528</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QWidget" name="widget_2" native="true">
+         <layout class="QGridLayout" name="gridLayout_3">
+          <property name="topMargin">
+           <number>0</number>
+          </property>
+          <item row="0" column="0">
+           <widget class="QTreeWidget" name="boxModelSelectWidget">
+            <column>
+             <property name="text">
+              <string notr="true">模板名称</string>
+             </property>
+            </column>
+            <column>
+             <property name="text">
+              <string>操作</string>
+             </property>
+            </column>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="pageMaDan">
+      <layout class="QGridLayout" name="gridLayout_7">
+       <property name="leftMargin">
+        <number>0</number>
+       </property>
+       <property name="topMargin">
+        <number>0</number>
+       </property>
+       <property name="rightMargin">
+        <number>0</number>
+       </property>
+       <property name="bottomMargin">
+        <number>0</number>
+       </property>
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item row="0" column="0">
+        <widget class="QWidget" name="widget_4" native="true">
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>45</height>
+          </size>
+         </property>
+         <property name="styleSheet">
+          <string notr="true"/>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_6">
+          <property name="topMargin">
+           <number>11</number>
+          </property>
+          <property name="bottomMargin">
+           <number>11</number>
+          </property>
+          <item row="0" column="0">
+           <widget class="QPushButton" name="backButton_2">
+            <property name="text">
+             <string>返回首页</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1">
+           <spacer name="horizontalSpacer_3">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>335</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="0" column="2">
+           <widget class="QLabel" name="label_2">
+            <property name="font">
+             <font>
+              <pointsize>14</pointsize>
+             </font>
+            </property>
+            <property name="text">
+             <string>码单模板</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="3">
+           <spacer name="horizontalSpacer_4">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>528</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QWidget" name="widget_3" native="true">
+         <layout class="QGridLayout" name="gridLayout_5">
+          <property name="topMargin">
+           <number>0</number>
+          </property>
+          <item row="0" column="0">
+           <widget class="QTreeWidget" name="packModelSelectWidget">
+            <column>
+             <property name="text">
+              <string notr="true">模板名称</string>
+             </property>
+            </column>
+            <column>
+             <property name="text">
+              <string>操作</string>
+             </property>
+            </column>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 2 - 2
widget/packdetailform.cpp

@@ -188,7 +188,7 @@ void PackDetailForm::changeTreeWidget(/*QList<QMap<QString,QString>> productList
                     columItemList<<boxes.at(j)->caseNumber()<<QString::number(boxes.at(j)->gross_weight/1000)<<QString::number(boxes.at(j)->net_weight/1000);
                     child = new QTreeWidgetItem(columItemList);
                     item->addChild(child);
-                    ui->treeWidget->setCurrentItem(child);
+//                    ui->treeWidget->setCurrentItem(child);
                 }
         }
 /**************************************************************/
@@ -212,7 +212,7 @@ void PackDetailForm::tongbu_clicked(QTreeWidgetItem * item,int row)
     packServer = new PackInfoSeed2Server(Manger,this,true);
     QSharedPointer<PackInfo> pack = saveInfo.at(limits*nowPageNum+row).packInfo;
     connect(packServer,&PackInfoSeed2Server::syncEnd,this,&PackDetailForm::SynReturn);
-    packServer->send(pack,false);
+    packServer->send(pack);
     item->setText(0,"同步中");
 }
 

+ 4 - 0
widget/selectvalueform.cpp

@@ -147,6 +147,10 @@ void SelectValueForm::on_pushNext_clicked()
 void SelectValueForm::on_pushButton_2_clicked()
 {
     int now = ui->tableWidget->currentRow();
+    if(now<0){
+        QMessageBox::information(this,tr("注意"),tr("请先选择一个数据"));
+        return;
+    }
         emit selectProject(ui->tableWidget->item(now,0)->text());
 
 }

+ 246 - 0
widget/showmadanlabelform.cpp

@@ -1,11 +1,70 @@
 #include "showmadanlabelform.h"
 #include "ui_showmadanlabelform.h"
+#include "QPainter"
 
 ShowMaDanLabelForm::ShowMaDanLabelForm(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::ShowMaDanLabelForm)
 {
     ui->setupUi(this);
+
+    ui->showWidget->setAutoFillBackground(true);
+
+    _dataDir = PQ::AppPath::this_()->dataDir();
+    if(!_dataDir.exists("PackModel")){
+        _dataDir.mkdir("PackModel");
+    }
+    _dataDir.cd("PackModel");
+
+//    QImage image;
+//    image.load(":/images/Pmoren.bmp");
+//    QPalette palette;
+//    _packPrinter.reset(new PackTemlateOne());
+//    palette.setBrush(ui->showWidget->backgroundRole(), QBrush(_packPrinter->Packmodel().scaled(
+//        ui->showWidget->size(),
+//        Qt::IgnoreAspectRatio,
+//        Qt::SmoothTransformation)));
+//    ui->showWidget->setPalette(palette);
+
+    addComboBox();
+}
+
+void ShowMaDanLabelForm::init(QString baseModelName, int status,QString modelName)
+{
+    ui->saveButton->hide();
+    ui->upModel->hide();
+    BaseModel = baseModelName;
+    qDebug()<<BaseModel;
+    Status = status;
+
+    QPalette palette;
+    _packPrinter.reset(new PackTemlateOne());
+    palette.setBrush(ui->showWidget->backgroundRole(), QBrush(_packPrinter->Packmodel().scaled(// 缩放背景图.
+        ui->showWidget->size(),
+        Qt::IgnoreAspectRatio,
+        Qt::SmoothTransformation)));
+    ui->showWidget->setPalette(palette);
+
+    if(status == 1){
+        ui->modelName->clear();
+        ui->saveButton->show();
+        controlShow();
+
+    }else if(status == 2){
+        controlHide();
+        showBaseModel();
+    }else if(status == 3){
+        controlShow();
+        ui->upModel->show();
+        ModelName = modelName;
+        for(int i = 0;i<glo->PackModelList().size();i++){
+            if(ModelName == glo->PackModelList().at(i)->Model_Name){
+                upData(glo->PackModelList().at(i));
+                ui->modelName->setText(ModelName);
+                break;
+            }
+        }
+    }
 }
 
 ShowMaDanLabelForm::~ShowMaDanLabelForm()
@@ -17,3 +76,190 @@ void ShowMaDanLabelForm::on_backButton_clicked()
 {
     emit back();
 }
+
+void ShowMaDanLabelForm::upData(QSharedPointer<PackModel> puckModelData)
+{
+    ui->text1->setText(puckModelData->Type_Name.at(0).toString());
+    ui->text1_2->setText(puckModelData->Type_Name.at(1).toString());
+    ui->text2->setText(puckModelData->Type_Name.at(2).toString());
+    ui->text2_2->setText(puckModelData->Type_Name.at(3).toString());
+    ui->text4->setText(puckModelData->Type_Name.at(4).toString());
+    ui->text4_2->setText(puckModelData->Type_Name.at(5).toString());
+    ui->text4_3->setText(puckModelData->Type_Name.at(6).toString());
+
+    ui->data1->setCurrentText(puckModelData->Type_Data.at(0).toString());
+    ui->data1_2->setCurrentText(puckModelData->Type_Data.at(1).toString());
+    ui->data2->setCurrentText(puckModelData->Type_Data.at(2).toString());
+    ui->data2_2->setCurrentText(puckModelData->Type_Data.at(3).toString());
+    ui->data3->setCurrentText(puckModelData->Type_Data.at(4).toString());
+    ui->data4->setCurrentText(puckModelData->Type_Data.at(5).toString());
+    ui->data4_2->setCurrentText(puckModelData->Type_Data.at(6).toString());
+    ui->data4_3->setCurrentText(puckModelData->Type_Data.at(7).toString());
+}
+
+void ShowMaDanLabelForm::showBaseModel()
+{
+        QImage image;
+        image.load(":/images/Pmoren.bmp");
+        QPalette palette;
+        palette.setBrush(ui->showWidget->backgroundRole(), QBrush(image.scaled(
+            ui->showWidget->size(),
+            Qt::IgnoreAspectRatio,
+            Qt::SmoothTransformation)));
+        ui->showWidget->setPalette(palette);
+}
+
+void ShowMaDanLabelForm::on_saveButton_clicked()
+{
+
+    if(ui->modelName->text().isEmpty()){
+        QMessageBox::information(this,tr("注意"),tr("请输入模板名称"));
+        return;
+    }
+
+    packModel.reset(new PackModel);
+
+    packModel->BaseModel_Name = BaseModel;
+
+    packModel->Model_Name = ui->modelName->text();
+
+    addPackData();
+
+    QString name = packModel->Model_Name;
+    name += "_Model.json";
+    QString ret = _dataDir.absoluteFilePath(name);
+
+    if(PQ::writeAbsoluteFile(ret,QJsonDocument(packModel->toObject()).toJson())){
+        QMessageBox::information(this,tr("提示"),tr("保存成功"));
+        glo->selectPackModel();
+        return;
+    }
+        QMessageBox::information(this,tr("提示"),tr("保存失败"));
+}
+
+void ShowMaDanLabelForm::addPackData()
+{
+    packModel->Type_Name.append(ui->text1->text());
+    packModel->Type_Name.append(ui->text1_2->text());
+    packModel->Type_Name.append(ui->text2->text());
+    packModel->Type_Name.append(ui->text2_2->text());
+    packModel->Type_Name.append(ui->text4->text());
+    packModel->Type_Name.append(ui->text4_2->text());
+    packModel->Type_Name.append(ui->text4_3->text());
+
+    packModel->Type_Data.append(ui->data1->currentText());
+    packModel->Type_Data.append(ui->data1_2->currentText());
+    packModel->Type_Data.append(ui->data2->currentText());
+    packModel->Type_Data.append(ui->data2_2->currentText());
+    packModel->Type_Data.append(ui->data3->currentText());
+    packModel->Type_Data.append(ui->data4->currentText());
+    packModel->Type_Data.append(ui->data4_2->currentText());
+    packModel->Type_Data.append(ui->data4_3->currentText());
+}
+
+void ShowMaDanLabelForm::addComboBox()
+{
+    QStringList list;
+    list.append("空");
+    list.append("批号");
+    list.append("类型");
+    list.append("品种");
+    list.append("旦数");
+    list.append("分特");
+    list.append("等级");
+    list.append("孔数");
+    list.append("规格");
+    list.append("颜色");
+    list.append("捻向");
+    list.append("管色");
+    list.append("皮重");
+    list.append("机台");
+    list.append("纸箱");
+    list.append("总筒数");
+    list.append("总毛重");
+    list.append("总净重");
+
+    QStringList list20;
+    list20.append("空");
+    list20.append("毛重");
+    list20.append("净重");
+    list20.append("筒数");
+    list20.append("捻向");
+    list20.append("管色");
+    list20.append("总筒重");
+
+    ui->data1->addItems(list);
+    ui->data1_2->addItems(list);
+    ui->data2->addItems(list);
+    ui->data2_2->addItems(list);
+    ui->data3->addItems(list20);
+    ui->data4->addItems(list);
+    ui->data4_2->addItems(list);
+    ui->data4_3->addItems(list);
+
+}
+
+void ShowMaDanLabelForm::controlHide()
+{
+    ui->text1->hide();
+    ui->text1_2->hide();
+    ui->text2->hide();
+    ui->text2_2->hide();
+    ui->label_4->hide();
+    ui->text4->hide();
+    ui->text4_2->hide();
+    ui->text4_3->hide();
+
+    ui->data1->hide();
+    ui->data1_2->hide();
+    ui->data2->hide();
+    ui->data2_2->hide();
+    ui->data3->hide();
+    ui->data4->hide();
+    ui->data4_2->hide();
+    ui->data4_3->hide();
+}
+
+
+void ShowMaDanLabelForm::controlShow()
+{
+    ui->text1->show();
+    ui->text1_2->show();
+    ui->text2->show();
+    ui->text2_2->show();
+    ui->label_4->show();
+    ui->text4->show();
+    ui->text4_2->show();
+    ui->text4_3->show();
+
+    ui->data1->show();
+    ui->data1_2->show();
+    ui->data2->show();
+    ui->data2_2->show();
+    ui->data3->show();
+    ui->data4->show();
+    ui->data4_2->show();
+    ui->data4_3->show();
+}
+
+void ShowMaDanLabelForm::on_upModel_clicked()
+{
+    packModel.reset(new PackModel);
+
+    packModel->BaseModel_Name = BaseModel;
+
+    packModel->Model_Name =ModelName;
+
+    addPackData();
+
+    QString name = packModel->Model_Name;
+    name += "_Model.json";
+    QString ret = _dataDir.absoluteFilePath(name);
+
+    if(PQ::writeAbsoluteFile(ret,QJsonDocument(packModel->toObject()).toJson())){
+        QMessageBox::information(this,tr("提示"),tr("更新成功"));
+        glo->selectPackModel();
+        return;
+    }
+        QMessageBox::information(this,tr("提示"),tr("更新失败"));
+}

+ 37 - 0
widget/showmadanlabelform.h

@@ -2,6 +2,13 @@
 #define SHOWMADANLABELFORM_H
 
 #include <QWidget>
+#include "handle/printer/baseboxprinter.h"
+#include "handle/printer/boxtemlateone.h"
+#include <pqQtlib/core/pqapppath.h>
+#include <pqQtlib/utils/pqfileutils.h>
+#include "QMessageBox"
+#include "QDir"
+#include "struct_/modelinfo.h"
 
 namespace Ui {
 class ShowMaDanLabelForm;
@@ -21,8 +28,38 @@ signals:
 private slots:
     void on_backButton_clicked();
 
+    void on_saveButton_clicked();
+
+public slots:
+    void init(QString baseModelName, int status ,QString modelName = nullptr);
+    void addComboBox();
+    void upData(QSharedPointer<PackModel> packModelData);
+    void addPackData();
+
+private slots:
+    void controlHide();
+    void controlShow();
+    void showBaseModel();
+
+    void on_upModel_clicked();
+
 private:
     Ui::ShowMaDanLabelForm *ui;
+
+    QSharedPointer<BasePackinfoPrinter> _packPrinter;
+
+    QSharedPointer<PackModel> packModel;
+//    QList<QSharedPointer<BoxModel>> boxModelList;
+
+    PackInfoManger *pack;
+    GlobalInfo * glo = GlobalInfo::this_();
+
+private:
+    QDir _dataDir;
+    QString BaseModel;
+    QString ModelName;
+
+    int Status;
 };
 
 #endif // SHOWMADANLABELFORM_H

+ 376 - 404
widget/showmadanlabelform.ui

@@ -6,337 +6,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>851</width>
-    <height>491</height>
+    <width>1038</width>
+    <height>779</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="1" column="0">
-    <widget class="QWidget" name="widget" native="true">
-     <property name="styleSheet">
-      <string notr="true">background-color: rgb(255, 255, 255);</string>
-     </property>
-     <widget class="QWidget" name="widget_3" native="true">
-      <property name="geometry">
-       <rect>
-        <x>11</x>
-        <y>11</y>
-        <width>500</width>
-        <height>400</height>
-       </rect>
-      </property>
-      <property name="minimumSize">
-       <size>
-        <width>500</width>
-        <height>400</height>
-       </size>
-      </property>
-      <property name="maximumSize">
-       <size>
-        <width>500</width>
-        <height>400</height>
-       </size>
-      </property>
-      <property name="styleSheet">
-       <string notr="true">background-image: url(:/images/moren.bmp);</string>
-      </property>
-      <widget class="QLineEdit" name="text1">
-       <property name="geometry">
-        <rect>
-         <x>29</x>
-         <y>109</y>
-         <width>71</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text2">
-       <property name="geometry">
-        <rect>
-         <x>29</x>
-         <y>141</y>
-         <width>71</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text3">
-       <property name="geometry">
-        <rect>
-         <x>29</x>
-         <y>179</y>
-         <width>71</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text4">
-       <property name="geometry">
-        <rect>
-         <x>29</x>
-         <y>211</y>
-         <width>71</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text5">
-       <property name="geometry">
-        <rect>
-         <x>29</x>
-         <y>249</y>
-         <width>71</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text5_2">
-       <property name="geometry">
-        <rect>
-         <x>253</x>
-         <y>249</y>
-         <width>75</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text3_2">
-       <property name="geometry">
-        <rect>
-         <x>253</x>
-         <y>179</y>
-         <width>75</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text1_2">
-       <property name="geometry">
-        <rect>
-         <x>253</x>
-         <y>109</y>
-         <width>75</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text4_2">
-       <property name="geometry">
-        <rect>
-         <x>253</x>
-         <y>211</y>
-         <width>75</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-      <widget class="QLineEdit" name="text2_2">
-       <property name="geometry">
-        <rect>
-         <x>253</x>
-         <y>141</y>
-         <width>75</width>
-         <height>21</height>
-        </rect>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>12</pointsize>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
-       <property name="styleSheet">
-        <string notr="true"/>
-       </property>
-       <property name="text">
-        <string>品名</string>
-       </property>
-       <property name="frame">
-        <bool>false</bool>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
-       </property>
-      </widget>
-     </widget>
-    </widget>
-   </item>
-   <item row="0" column="0" colspan="2">
+  <layout class="QGridLayout" name="gridLayout_2">
+   <item row="0" column="0">
     <widget class="QWidget" name="widget_4" native="true">
      <property name="maximumSize">
       <size>
@@ -405,7 +83,314 @@
      </layout>
     </widget>
    </item>
-   <item row="1" column="1">
+   <item row="1" column="0">
+    <widget class="QWidget" name="widget" native="true">
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_4">
+      <item row="0" column="0">
+       <widget class="QWidget" name="showWidget" native="true">
+        <property name="minimumSize">
+         <size>
+          <width>500</width>
+          <height>400</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>500</width>
+          <height>400</height>
+         </size>
+        </property>
+        <property name="styleSheet">
+         <string notr="true"/>
+        </property>
+        <widget class="QLineEdit" name="text1">
+         <property name="geometry">
+          <rect>
+           <x>40</x>
+           <y>59</y>
+           <width>61</width>
+           <height>21</height>
+          </rect>
+         </property>
+         <property name="font">
+          <font>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="frame">
+          <bool>false</bool>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
+        </widget>
+        <widget class="QLineEdit" name="text2">
+         <property name="geometry">
+          <rect>
+           <x>40</x>
+           <y>89</y>
+           <width>61</width>
+           <height>21</height>
+          </rect>
+         </property>
+         <property name="font">
+          <font>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="frame">
+          <bool>false</bool>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
+        </widget>
+        <widget class="QLineEdit" name="text1_2">
+         <property name="geometry">
+          <rect>
+           <x>290</x>
+           <y>59</y>
+           <width>61</width>
+           <height>21</height>
+          </rect>
+         </property>
+         <property name="font">
+          <font>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string/>
+         </property>
+         <property name="frame">
+          <bool>false</bool>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
+        </widget>
+        <widget class="QLineEdit" name="text2_2">
+         <property name="geometry">
+          <rect>
+           <x>290</x>
+           <y>89</y>
+           <width>61</width>
+           <height>21</height>
+          </rect>
+         </property>
+         <property name="font">
+          <font>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="frame">
+          <bool>false</bool>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data1">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="geometry">
+          <rect>
+           <x>100</x>
+           <y>60</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data2">
+         <property name="geometry">
+          <rect>
+           <x>100</x>
+           <y>90</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data1_2">
+         <property name="geometry">
+          <rect>
+           <x>350</x>
+           <y>60</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data2_2">
+         <property name="geometry">
+          <rect>
+           <x>350</x>
+           <y>90</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QLabel" name="label_4">
+         <property name="geometry">
+          <rect>
+           <x>40</x>
+           <y>120</y>
+           <width>21</width>
+           <height>16</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string>1.</string>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data3">
+         <property name="geometry">
+          <rect>
+           <x>60</x>
+           <y>118</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QLineEdit" name="text4">
+         <property name="geometry">
+          <rect>
+           <x>30</x>
+           <y>300</y>
+           <width>51</width>
+           <height>21</height>
+          </rect>
+         </property>
+         <property name="frame">
+          <bool>false</bool>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data4">
+         <property name="geometry">
+          <rect>
+           <x>80</x>
+           <y>300</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QLineEdit" name="text4_2">
+         <property name="geometry">
+          <rect>
+           <x>190</x>
+           <y>300</y>
+           <width>51</width>
+           <height>21</height>
+          </rect>
+         </property>
+         <property name="frame">
+          <bool>false</bool>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data4_2">
+         <property name="geometry">
+          <rect>
+           <x>240</x>
+           <y>300</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QLineEdit" name="text4_3">
+         <property name="geometry">
+          <rect>
+           <x>340</x>
+           <y>300</y>
+           <width>51</width>
+           <height>21</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string/>
+         </property>
+         <property name="frame">
+          <bool>false</bool>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="data4_3">
+         <property name="geometry">
+          <rect>
+           <x>390</x>
+           <y>300</y>
+           <width>87</width>
+           <height>22</height>
+          </rect>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="2" column="0">
     <widget class="QWidget" name="widget_2" native="true">
      <property name="minimumSize">
       <size>
@@ -415,85 +400,72 @@
      </property>
      <property name="maximumSize">
       <size>
-       <width>300</width>
-       <height>16777215</height>
+       <width>16777215</width>
+       <height>50</height>
       </size>
      </property>
-     <widget class="QLabel" name="label_2">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>30</y>
-        <width>71</width>
-        <height>21</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>当前模板:</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_3">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>30</y>
-        <width>91</width>
-        <height>16</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>默认模板</string>
-      </property>
-     </widget>
-     <widget class="QTableWidget" name="tableWidget">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>60</y>
-        <width>271</width>
-        <height>141</height>
-       </rect>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pushButton_2">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>220</y>
-        <width>93</width>
-        <height>28</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>新建模板</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pushButton_3">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>260</y>
-        <width>93</width>
-        <height>28</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>更新模板</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pushButton_4">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>300</y>
-        <width>93</width>
-        <height>28</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>删除模板</string>
-      </property>
-     </widget>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="4">
+       <widget class="QPushButton" name="upModel">
+        <property name="text">
+         <string>更新模板</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>默认模板1</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>当前模板:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2">
+       <widget class="QLineEdit" name="modelName">
+        <property name="minimumSize">
+         <size>
+          <width>111</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>111</width>
+          <height>16777215</height>
+         </size>
+        </property>
+        <property name="placeholderText">
+         <string>请输入模板名称</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="5">
+       <spacer name="horizontalSpacer_4">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>318</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="0" column="3">
+       <widget class="QPushButton" name="saveButton">
+        <property name="text">
+         <string> 保存模板</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
     </widget>
    </item>
   </layout>

+ 168 - 95
widget/showxiangdanlabelform.cpp

@@ -7,11 +7,18 @@ ShowXiangDanLabelForm::ShowXiangDanLabelForm(QWidget *parent) :
     ui(new Ui::ShowXiangDanLabelForm)
 {
     ui->setupUi(this);
-    ui->ModelList->setRowCount(1);
-    ui->ModelList->setItem(0,0,new QTableWidgetItem("test"));
     ui->showWidget->setAutoFillBackground(true);
+//    addComboBox();
+//    controlHide();
+
+    _dataDir = PQ::AppPath::this_()->dataDir();
+    if(!_dataDir.exists("BoxModel")){
+        _dataDir.mkdir("BoxModel");
+    }
+    _dataDir.cd("BoxModel");
+
+//    connect(glo,&GlobalInfo::boxModelUped,this,&ShowXiangDanLabelForm::upBoxModel);
     addComboBox();
-    controlHide();
 }
 
 ShowXiangDanLabelForm::~ShowXiangDanLabelForm()
@@ -24,61 +31,84 @@ void ShowXiangDanLabelForm::on_backButton_clicked()
     emit back();
 }
 
-void ShowXiangDanLabelForm::on_ModelList_cellClicked(int row, int column)
+void ShowXiangDanLabelForm::init(QString baseModelName,int status,QString modelName)
 {
-    if(ui->addNewModel->text() == "保存模板"){
-        if(row!=ui->ModelList->rowCount()-1){
-        QMessageBox::information(this,tr("警告"),tr("请先保存当前新建模板"));
-        return;
+    ui->saveButton->hide();
+    ui->upModel->hide();
+    BaseModel = baseModelName;
+    Status = status;
+
+    QPalette palette;
+    _boxPrinter.reset(new BoxTemlateOne());
+    palette.setBrush(ui->showWidget->backgroundRole(), QBrush(_boxPrinter->Boxmodel().scaled(// 缩放背景图.
+        ui->showWidget->size(),
+        Qt::IgnoreAspectRatio,
+        Qt::SmoothTransformation)));
+    ui->showWidget->setPalette(palette);
+
+    if(status == 1){
+        ui->modelName->clear();
+        ui->saveButton->show();
+        controlShow();
+    }else if(status == 2){
+        controlHide();
+        showBaseModel();
+    }else if(status == 3){
+        ui->upModel->show();
+        ModelName = modelName;
+        controlShow();
+        ui->modelName->setText(ModelName);
+        for(int i = 0;i<glo->BoxModelList().size();i++){
+            if(ModelName == glo->BoxModelList().at(i)->Model_Name){
+                upData(glo->BoxModelList().at(i));
+                ui->modelName->setText(ModelName);
+                break;
+            }
         }
     }
-    if(row == 0){
-        QImage image;
-        image.load(":/images/moren.bmp");
-        QPalette palette;
-        _boxPrinter.reset(new BoxTemlateOne());
-        palette.setBrush(ui->showWidget->backgroundRole(), QBrush(image.scaled(// 缩放背景图.
-            ui->showWidget->size(),
-            Qt::IgnoreAspectRatio,
-            Qt::SmoothTransformation)));
-        ui->showWidget->setPalette(palette);
-    }
-
 }
 
-void ShowXiangDanLabelForm::on_addNewModel_clicked()
+void ShowXiangDanLabelForm::upData(QSharedPointer<BoxModel> boxModelData)
 {
-    if(ui->addNewModel->text() == "新建模板"){
-//    qDebug()<<ui->ModelList->rowCount();
-        ui->ModelList->setRowCount(ui->ModelList->rowCount()+1);
-        ui->ModelList->setItem(ui->ModelList->rowCount()-1,0,new QTableWidgetItem("请输入名称"));
-
-        controlShow();
-        QPalette palette;
-        _boxPrinter.reset(new BoxTemlateOne());
-        palette.setBrush(ui->showWidget->backgroundRole(), QBrush(_boxPrinter->BoxModel().scaled(// 缩放背景图.
-            ui->showWidget->size(),
-            Qt::IgnoreAspectRatio,
-            Qt::SmoothTransformation)));
-        ui->showWidget->setPalette(palette);
-
-        ui->addNewModel->setText("保存模板");
-    }else if(ui->addNewModel->text() == "保存模板"){
-        if(ui->ModelList->item(ui->ModelList->rowCount(),0)->text()=="请输入名称"){
-           QMessageBox::information(this,tr("提示"),tr("请输入名称"));
-           return;
-        }
-        QMessageBox::information(this,tr("提示"),tr("保存成功"));
-        ui->addNewModel->setText("新建模板");
-    }
-
+    ui->text1->setText(boxModelData->Type_Name.at(0).toString());
+    ui->text2->setText(boxModelData->Type_Name.at(1).toString());
+    ui->text3->setText(boxModelData->Type_Name.at(2).toString());
+    ui->text4->setText(boxModelData->Type_Name.at(3).toString());
+    ui->text5->setText(boxModelData->Type_Name.at(4).toString());
+    ui->text1_2->setText(boxModelData->Type_Name.at(5).toString());
+    ui->text2_2->setText(boxModelData->Type_Name.at(6).toString());
+    ui->text3_2->setText(boxModelData->Type_Name.at(7).toString());
+    ui->text4_2->setText(boxModelData->Type_Name.at(8).toString());
+    ui->text5_2->setText(boxModelData->Type_Name.at(9).toString());
+
+    ui->data1->setCurrentText(boxModelData->Type_Data.at(0).toString());
+    ui->data2->setCurrentText(boxModelData->Type_Data.at(1).toString());
+    ui->data3->setCurrentText(boxModelData->Type_Data.at(2).toString());
+    ui->data4->setCurrentText(boxModelData->Type_Data.at(3).toString());
+    ui->data5->setCurrentText(boxModelData->Type_Data.at(4).toString());
+    ui->data1_2->setCurrentText(boxModelData->Type_Data.at(5).toString());
+    ui->data2_2->setCurrentText(boxModelData->Type_Data.at(6).toString());
+    ui->data3_2->setCurrentText(boxModelData->Type_Data.at(7).toString());
+    ui->data4_2->setCurrentText(boxModelData->Type_Data.at(8).toString());
+    ui->data5_2->setCurrentText(boxModelData->Type_Data.at(9).toString());
 }
 
-void ShowXiangDanLabelForm::on_upModel_clicked()
+void ShowXiangDanLabelForm::showBaseModel()
 {
-    controlShow();
+            QImage image;
+            image.load(":/images/moren.bmp");
+            QPalette palette;
+    //        _boxPrinter.reset(new BoxTemlateOne());
+            palette.setBrush(ui->showWidget->backgroundRole(), QBrush(image.scaled(
+                ui->showWidget->size(),
+                Qt::IgnoreAspectRatio,
+                Qt::SmoothTransformation)));
+            ui->showWidget->setPalette(palette);
 }
 
+
+
+
 void ShowXiangDanLabelForm::controlHide()
 {
     ui->text1->hide();//第一行从上而下
@@ -132,74 +162,117 @@ void ShowXiangDanLabelForm::controlShow()
 
 void ShowXiangDanLabelForm::addComboBox()
 {
+
     QList<QString> text;
+    text.append("空");
     text.append("品名");
     text.append("批号");
     text.append("规格");
     text.append("等级");
-    text.append("箱号");
+//    text.append("箱号");
     text.append("毛重");
     text.append("净重");
     text.append("筒数");
     text.append("捻向");
-    text.append("纸管颜色");
-
-    QList<QString> data;
-    data.append("product_type_code");
-    data.append("batch_no");
-    data.append("specs");
-    data.append("level");
-    data.append("case_number");
-    data.append("gross_weight");
-    data.append("net_weight");
-    data.append("tube_number");
-    data.append("twist_type");
-    data.append("bucket_color");
-
-    for(int i = 0;i<text.size();i++){
-        ui->data1->addItem(text.at(i),data.at(i));
-    }
+    text.append("类型");
+    text.append("旦数");
+    text.append("分特");
+    text.append("孔数");
+    text.append("颜色");
+    text.append("皮重");
+    text.append("筒重");
+    text.append("管色");
+
+    ui->data1->addItems(text);
+    ui->data2->addItems(text);
+    ui->data3->addItems(text);
+    ui->data4->addItems(text);
+    ui->data5->addItems(text);
+    ui->data1_2->addItems(text);
+    ui->data2_2->addItems(text);
+    ui->data3_2->addItems(text);
+    ui->data4_2->addItems(text);
+    ui->data5_2->addItems(text);
+}
 
-    for(int i = 0;i<text.size();i++){
-        ui->data2->addItem(text.at(i),data.at(i));
-    }
+void ShowXiangDanLabelForm::on_delModel_clicked()
+{
+    pack->getBoxModel();
+}
 
-    for(int i = 0;i<text.size();i++){
-        ui->data3->addItem(text.at(i),data.at(i));
-    }
+void ShowXiangDanLabelForm::on_saveButton_clicked()
+{
 
-    for(int i = 0;i<text.size();i++){
-        ui->data4->addItem(text.at(i),data.at(i));
+    if(ui->modelName->text().isEmpty()){
+        QMessageBox::information(this,tr("注意"),tr("请输入模板名称"));
+        return;
     }
 
-    for(int i = 0;i<text.size();i++){
-        ui->data5->addItem(text.at(i),data.at(i));
-    }
+    boxModel.reset(new BoxModel);
 
-    for(int i = 0;i<text.size();i++){
-        ui->data1_2->addItem(text.at(i),data.at(i));
-    }
+    boxModel->baseModel_Name = BaseModel;
+    boxModel->Model_Name = ui->modelName->text();
+    addBoxData();
 
-    for(int i = 0;i<text.size();i++){
-        ui->data2_2->addItem(text.at(i),data.at(i));
-    }
+    QString name = boxModel->Model_Name;
+    name += "_Model.json";
+    QString ret = _dataDir.absoluteFilePath(name);
 
-    for(int i = 0;i<text.size();i++){
-        ui->data3_2->addItem(text.at(i),data.at(i));
+    if(PQ::writeAbsoluteFile(ret,QJsonDocument(boxModel->toObject()).toJson())){
+        QMessageBox::information(this,tr("提示"),tr("保存成功"));
+//        ui->addNewModel->setText("新建模板");
+        glo->selectBoxModel();
+        return;
     }
+        QMessageBox::information(this,tr("提示"),tr("保存失败"));
+}
 
-    for(int i = 0;i<text.size();i++){
-        ui->data4_2->addItem(text.at(i),data.at(i));
-    }
+void ShowXiangDanLabelForm::addBoxData()
+{
+    boxModel->Type_Name.append(ui->text1->text());
+    boxModel->Type_Name.append(ui->text2->text());
+    boxModel->Type_Name.append(ui->text3->text());
+    boxModel->Type_Name.append(ui->text4->text());
+    boxModel->Type_Name.append(ui->text5->text());
+    boxModel->Type_Name.append(ui->text1_2->text());
+    boxModel->Type_Name.append(ui->text2_2->text());
+    boxModel->Type_Name.append(ui->text3_2->text());
+    boxModel->Type_Name.append(ui->text4_2->text());
+    boxModel->Type_Name.append(ui->text5_2->text());
+
+    boxModel->Type_Data.append(ui->data1->currentText());
+    boxModel->Type_Data.append(ui->data2->currentText());
+    boxModel->Type_Data.append(ui->data3->currentText());
+    boxModel->Type_Data.append(ui->data4->currentText());
+    boxModel->Type_Data.append(ui->data5->currentText());
+    boxModel->Type_Data.append(ui->data1_2->currentText());
+    boxModel->Type_Data.append(ui->data2_2->currentText());
+    boxModel->Type_Data.append(ui->data3_2->currentText());
+    boxModel->Type_Data.append(ui->data4_2->currentText());
+    boxModel->Type_Data.append(ui->data5_2->currentText());
+}
 
-    for(int i = 0;i<text.size();i++){
-        ui->data5_2->addItem(text.at(i),data.at(i));
+void ShowXiangDanLabelForm::on_upModel_clicked()
+{
+//    QList<QSharedPointer<BoxModel>> boxModelList = glo->BoxModelList();
+//    for(int i = 0;i<boxModelList.size();i++){
+
+//    }
+    boxModel.reset(new BoxModel);
+    boxModel->baseModel_Name = BaseModel;
+    boxModel->Model_Name = ModelName;
+    addBoxData();
+
+    QString name = boxModel->Model_Name;
+    name += "_Model.json";
+    QString ret = _dataDir.absoluteFilePath(name);
+
+    if(PQ::writeAbsoluteFile(ret,QJsonDocument(boxModel->toObject()).toJson())){
+        QMessageBox::information(this,tr("提示"),tr("更新成功"));
+//        ui->addNewModel->setText("新建模板");
+        glo->selectBoxModel();
+        return;
     }
-
-
+        QMessageBox::information(this,tr("提示"),tr("更新失败"));
 
 }
-
-
-
-

+ 37 - 28
widget/showxiangdanlabelform.h

@@ -4,37 +4,16 @@
 #include <QWidget>
 #include "handle/printer/baseboxprinter.h"
 #include "handle/printer/boxtemlateone.h"
+#include <pqQtlib/core/pqapppath.h>
+#include <pqQtlib/utils/pqfileutils.h>
 #include "QMessageBox"
+#include "QDir"
+#include "struct_/modelinfo.h"
 
 namespace Ui {
 class ShowXiangDanLabelForm;
 }
 
-struct BoxModel{
-    QString text1;
-    QString text2;
-    QString text3;
-    QString text4;
-    QString text5;
-    QString text1_2;
-    QString text2_2;
-    QString text3_2;
-    QString text4_2;
-    QString text5_2;
-
-    QString data1;
-    QString data2;
-    QString data3;
-    QString data4;
-    QString data5;
-    QString data1_2;
-    QString data2_2;
-    QString data3_2;
-    QString data4_2;
-    QString data5_2;
-
-};
-
 class ShowXiangDanLabelForm : public QWidget
 {
     Q_OBJECT
@@ -42,6 +21,12 @@ class ShowXiangDanLabelForm : public QWidget
 public:
     explicit ShowXiangDanLabelForm(QWidget *parent = nullptr);
     ~ShowXiangDanLabelForm();
+    inline void setBaseModelName(QString baseModelName){BaseModel = baseModelName;}
+    inline void setStatus(int status){Status = status;}
+
+    inline void setModelName(QString ModelName){this->ModelName = ModelName;}
+
+    void init(QString baseModelName,int status,QString ModelName = nullptr);
 
 signals:
     void back();
@@ -50,19 +35,43 @@ private slots:
     void controlHide();
     void controlShow();
     void addComboBox();
+//    void changeData(int index);
+    void showBaseModel();//显示默认模板
+    void addBoxData();//添加数据到BoxModel的方法
+    void upData(QSharedPointer<BoxModel> boxModelData);//进入更新页面时添加原始数据
 
-    void on_addNewModel_clicked();
 
-    void on_upModel_clicked();
+private slots:
+//    void on_addNewModel_clicked();
+
+//    void on_upModel_clicked();
 
-    void on_ModelList_cellClicked(int row, int column);
+//    void on_ModelList_cellClicked(int row, int column);
 
     void on_backButton_clicked();
 
+    void on_delModel_clicked();
+
+    void on_saveButton_clicked();
+
+    void on_upModel_clicked();
 
 private:
     Ui::ShowXiangDanLabelForm *ui;
     QSharedPointer<BaseBoxPrinter> _boxPrinter;
+
+    QSharedPointer<BoxModel> boxModel;
+    QList<QSharedPointer<BoxModel>> boxModelList;
+
+    PackInfoManger *pack;
+    GlobalInfo * glo = GlobalInfo::this_();
+
+private:
+    QDir _dataDir;
+    QString BaseModel;//添加新自定义模板时参数
+    QString ModelName;//更新自定义模板时参数
+
+    int Status;
 };
 
 #endif // SHOWXIANGDANLABELFORM_H

+ 156 - 99
widget/showxiangdanlabelform.ui

@@ -6,15 +6,18 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>851</width>
-    <height>491</height>
+    <width>977</width>
+    <height>647</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0" colspan="2">
+  <property name="styleSheet">
+   <string notr="true"/>
+  </property>
+  <layout class="QGridLayout" name="gridLayout_4">
+   <item row="0" column="0">
     <widget class="QWidget" name="widget_4" native="true">
      <property name="maximumSize">
       <size>
@@ -32,7 +35,7 @@
          </size>
         </property>
         <property name="text">
-         <string>返回首页</string>
+         <string>返回</string>
         </property>
        </widget>
       </item>
@@ -126,7 +129,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -134,6 +137,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text2">
          <property name="geometry">
@@ -155,7 +161,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -163,6 +169,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text3">
          <property name="geometry">
@@ -184,7 +193,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -192,6 +201,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text4">
          <property name="geometry">
@@ -213,7 +225,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -221,6 +233,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text5">
          <property name="geometry">
@@ -242,7 +257,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -250,6 +265,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text5_2">
          <property name="geometry">
@@ -271,7 +289,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -279,6 +297,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text3_2">
          <property name="geometry">
@@ -300,7 +321,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -308,6 +329,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text1_2">
          <property name="geometry">
@@ -329,7 +353,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -337,6 +361,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text4_2">
          <property name="geometry">
@@ -358,7 +385,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -366,6 +393,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QLineEdit" name="text2_2">
          <property name="geometry">
@@ -387,7 +417,7 @@
           <string notr="true"/>
          </property>
          <property name="text">
-          <string>品名</string>
+          <string/>
          </property>
          <property name="frame">
           <bool>false</bool>
@@ -395,6 +425,9 @@
          <property name="alignment">
           <set>Qt::AlignCenter</set>
          </property>
+         <property name="placeholderText">
+          <string>空</string>
+         </property>
         </widget>
         <widget class="QComboBox" name="data1">
          <property name="geometry">
@@ -405,6 +438,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data2">
          <property name="geometry">
@@ -415,6 +451,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data3">
          <property name="geometry">
@@ -425,6 +464,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data4">
          <property name="geometry">
@@ -435,6 +477,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data5">
          <property name="geometry">
@@ -445,6 +490,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data2_2">
          <property name="geometry">
@@ -455,6 +503,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data3_2">
          <property name="geometry">
@@ -465,6 +516,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data5_2">
          <property name="geometry">
@@ -475,6 +529,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data4_2">
          <property name="geometry">
@@ -485,6 +542,9 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
         <widget class="QComboBox" name="data1_2">
          <property name="geometry">
@@ -495,106 +555,103 @@
            <height>22</height>
           </rect>
          </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
         </widget>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
-   <item row="1" column="1">
+   <item row="2" column="0">
     <widget class="QWidget" name="widget_2" native="true">
      <property name="minimumSize">
       <size>
-       <width>300</width>
+       <width>0</width>
        <height>0</height>
       </size>
      </property>
      <property name="maximumSize">
       <size>
-       <width>300</width>
-       <height>16777215</height>
+       <width>16777215</width>
+       <height>50</height>
       </size>
      </property>
-     <widget class="QLabel" name="label_2">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>30</y>
-        <width>71</width>
-        <height>21</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>当前模板:</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_3">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>30</y>
-        <width>91</width>
-        <height>16</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>默认模板</string>
-      </property>
-     </widget>
-     <widget class="QTableWidget" name="ModelList">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>60</y>
-        <width>271</width>
-        <height>141</height>
-       </rect>
-      </property>
-      <column>
-       <property name="text">
-        <string>名称</string>
-       </property>
-      </column>
-     </widget>
-     <widget class="QPushButton" name="addNewModel">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>220</y>
-        <width>93</width>
-        <height>28</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>新建模板</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="upModel">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>260</y>
-        <width>93</width>
-        <height>28</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>更新模板</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="delModel">
-      <property name="geometry">
-       <rect>
-        <x>90</x>
-        <y>300</y>
-        <width>93</width>
-        <height>28</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>删除模板</string>
-      </property>
-     </widget>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="3">
+       <widget class="QPushButton" name="saveButton">
+        <property name="maximumSize">
+         <size>
+          <width>93</width>
+          <height>28</height>
+         </size>
+        </property>
+        <property name="text">
+         <string>保存模板</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="4">
+       <widget class="QPushButton" name="upModel">
+        <property name="maximumSize">
+         <size>
+          <width>93</width>
+          <height>28</height>
+         </size>
+        </property>
+        <property name="text">
+         <string>更新模板</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_2">
+        <property name="maximumSize">
+         <size>
+          <width>70</width>
+          <height>16777215</height>
+         </size>
+        </property>
+        <property name="text">
+         <string>当前模板:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2">
+       <widget class="QLineEdit" name="modelName">
+        <property name="maximumSize">
+         <size>
+          <width>111</width>
+          <height>16777215</height>
+         </size>
+        </property>
+        <property name="placeholderText">
+         <string>请输入模板名称</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>默认模板1</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="5">
+       <spacer name="horizontalSpacer_4">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
     </widget>
    </item>
   </layout>

+ 116 - 16
widget/uncertainweightpackform.cpp

@@ -24,6 +24,8 @@ UncertainWeightPackForm::UncertainWeightPackForm(QWidget *parent) :
     connect(glo,&GlobalInfo::dengJiUped,this,&UncertainWeightPackForm::upDengjiInfo);
     connect(glo,&GlobalInfo::doInited,this,&UncertainWeightPackForm::changeSpecs);
     connect(glo,&GlobalInfo::wareUped,this,&UncertainWeightPackForm::upWare);
+    connect(glo,&GlobalInfo::boxModelUped,this,&UncertainWeightPackForm::upBoxModelList);
+    connect(glo,&GlobalInfo::packModelUpde,this,&UncertainWeightPackForm::upPackModelList);
 
     auto dt = CacheFile::readFile("budingInfo.cache");
     auto list = QString::fromUtf8(dt).split("[,]");
@@ -54,12 +56,18 @@ void UncertainWeightPackForm::calcData()
 //    qDebug()<<autoRead;
 //    netNum = ui->grossWeight->text().toDouble()-ui->pizhong->currentText().toDouble()-ui->tongshu->text().toDouble()*ui->tongzhong->currentText().toDouble();
     if(ui->showMaoZhong->isChecked()){
-        gross_weight = ui->grossWeight->text().toDouble();
-        netNum = gross_weight - pz - tz * ts;
+        gross_weight = floor((ui->grossWeight->text().toDouble()+chengZhongJingDuModel_Num)*100)/100;
+        netNum = floor(((ui->grossWeight->text().toDouble() - pz - tz * ts)+chengZhongJingDuModel_Num)*100)/100;
+
+        f_gross_weight = float(floor((gross_weight+f_chengZhongJingDuModel_Num)*10))/10;
+        f_netNum = float(floor((netNum+f_chengZhongJingDuModel_Num)*10))/10;
 
     } else {
-        netNum = ui->grossWeight->text().toDouble();
-        gross_weight = netNum + pz + tz * ts;
+        netNum = floor((ui->grossWeight->text().toDouble()+chengZhongJingDuModel_Num)*100)/100;
+        gross_weight = floor(((ui->grossWeight->text().toDouble() + pz + tz*ts)+chengZhongJingDuModel_Num)*100)/100;
+
+        f_gross_weight = float(floor((gross_weight+f_chengZhongJingDuModel_Num)*10))/10;
+        f_netNum = float(floor((netNum+f_chengZhongJingDuModel_Num)*10))/10;
     }
 
     if(istubeNumTure){
@@ -94,12 +102,19 @@ void UncertainWeightPackForm::on_addPackList_clicked()
         packinfo->telephone = ui->taiPhone->text();
     }
 //    qDebug()<<packinfo->boxes().at(0)->tube_number;
+    packinfo->autoRuku = ui->ruku->isChecked();
     if(ui->autoSync->isChecked() && !GlobalInfo::this_()->isNoLine())
-        packServer->send(packinfo,isRuku);
+        packServer->send(packinfo);
     Manger->savePackInfo(packinfo);
 //    GlobalInfo::this_()->packInfoManger()->setPackInfoSync(packinfo->codeSingle(),packinfo->time(),true);
-    if(ui->madanPrint->isChecked())
-        GlobalInfo::this_()->printerPack(packinfo);
+    if(ui->madanPrint->isChecked()){
+        if(ui->madan->currentIndex() == 0){
+            GlobalInfo::this_()->printerPack(packinfo);
+        }else{
+            GlobalInfo::this_()->printerPackModel(packinfo,ui->madan->currentIndex()-1);
+        }
+    }
+
     ui->tableWidget->clearContents();
     ui->tableWidget->setRowCount(0);
 
@@ -137,9 +152,14 @@ void UncertainWeightPackForm::on_addBoxList_clicked()
     calcData();
     box->box_weight = int(ui->pizhong->currentText().toDouble()*1000);
     box->tube_number = ui->tongshu->text().toInt();
-    box->bucket_weight = int((ui->tongzhong->currentText().toDouble()*ui->tongshu->text().toDouble())*1000);
-    box->gross_weight = int(gross_weight*1000);
-    box->net_weight = int(netNum*1000);
+    box->bucket_weight = int(floor((ui->tongzhong->currentText().toDouble()*ui->tongshu->text().toDouble()+0.005)*100)*10);
+    if(chengZhongJingDu == 2){
+        box->gross_weight = int(gross_weight*1000);
+        box->net_weight = int(netNum*1000);
+    }else if(chengZhongJingDu == 1){
+        box->gross_weight = int(f_gross_weight*1000);
+        box->net_weight = int(f_netNum*1000);
+    }
     box->Level = ui->dengji->currentText();
     box->twist_type = ui->nianxiang->currentText();
     box->bucket_color = ui->guanse->currentText();
@@ -147,14 +167,21 @@ void UncertainWeightPackForm::on_addBoxList_clicked()
 //    box->remark = ui->beizhu->toPlainText();
     packinfo->level = ui->dengji->currentText();
     packinfo->level_id = ui->dengji->currentData().toInt();
+    packinfo->warehouse_id = ui->wareBox->currentData().toInt();
+    packinfo->autoRuku = ui->ruku->isChecked();
 
     addTableWidget(box,index);
 
 
 //    把box数据添加到packinfo的boxes数据表里;
     packinfo->addBoxInfoList(box);
-    if(ui->xiangdanPrint->isChecked())
-        GlobalInfo::this_()->printerBox(box);
+    if(ui->xiangdanPrint->isChecked()){
+        if(ui->xiangdan->currentIndex() == 0){
+            GlobalInfo::this_()->printerBox(box);
+        }else{
+            GlobalInfo::this_()->printerBoxModel(box,ui->xiangdan->currentIndex()-1);
+        }
+    }
     upSum();
         //添加数据库
     //    aputils.insertDetailsSQL(box,packinfo->codeSingle());
@@ -216,7 +243,7 @@ void UncertainWeightPackForm::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_time = QDate::currentDate().toString("yyyy-MM-dd");
         packinfo->packing_type = _info->category;
         packinfo->packType = 0;
 
@@ -238,10 +265,10 @@ void UncertainWeightPackForm::addTableWidget(QSharedPointer<BoxInfo> box, int ro
 
     ui->tableWidget->setItem(row,0,new QTableWidgetItem(box->caseNumber()));
     ui->tableWidget->setItem(row,1,new QTableWidgetItem(QString::number(box->tube_number)));
-    ui->tableWidget->setItem(row,2,new QTableWidgetItem(getDecimalbit(box->gross_weight / 1000.00)));
+    ui->tableWidget->setItem(row,2,new QTableWidgetItem(QString::number(box->gross_weight / 1000.00)));
     ui->tableWidget->setItem(row,3,new QTableWidgetItem(ui->tongzhong->currentText()));
     ui->tableWidget->setItem(row,4,new QTableWidgetItem(box->bucket_color));
-    ui->tableWidget->setItem(row,5,new QTableWidgetItem(getDecimalbit(box->net_weight / 1000.00)));
+    ui->tableWidget->setItem(row,5,new QTableWidgetItem(QString::number(box->net_weight / 1000.00)));
     ui->tableWidget->item(row,0)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
     ui->tableWidget->item(row,1)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
     ui->tableWidget->item(row,2)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
@@ -252,8 +279,11 @@ void UncertainWeightPackForm::addTableWidget(QSharedPointer<BoxInfo> box, int ro
     QWidget *tmp_widget = new QWidget();
     QHBoxLayout *tmp_layout = new QHBoxLayout(tmp_widget);
     auto btn_1 = new QPushButton("删除",tmp_widget);
+    btn_1->setMaximumWidth(40);
     auto btn_2 = new QPushButton("修改",tmp_widget);
+    btn_2->setMaximumWidth(40);
     auto btn_3 = new QPushButton("补打",tmp_widget);
+    btn_3->setMaximumWidth(40);
     tmp_layout->addWidget(btn_1);
     tmp_layout->addWidget(btn_2);
     tmp_layout->addWidget(btn_3);
@@ -263,7 +293,10 @@ void UncertainWeightPackForm::addTableWidget(QSharedPointer<BoxInfo> box, int ro
     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(row,6,tmp_widget);
-    ui->tableWidget->resizeColumnsToContents();
+
+    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);    //x先自适应宽度
+    ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
+    ui->tableWidget->horizontalHeader()->setSectionResizeMode(6, QHeaderView::ResizeToContents);
 }
 
 void UncertainWeightPackForm::init()
@@ -291,6 +324,28 @@ void UncertainWeightPackForm::upconfig()
 {
     // TODO:打包配置更新
     DaBaoConfig config = glo->dbConfig();
+
+    //称重精度
+    chengZhongJingDu = config.chengZhongJIngDu;
+
+    //称重精度方式//4:四舍五入 5:二舍三入 6:一舍二入
+    chengZhongJingDuModel = config.chengZhongJingDuMode;
+    switch (chengZhongJingDuModel) {
+        case 4:
+            chengZhongJingDuModel_Num = 0.005;
+            f_chengZhongJingDuModel_Num = 0.05;
+            break;
+        case 5:
+            chengZhongJingDuModel_Num = 0.007;
+            f_chengZhongJingDuModel_Num = 0.07;
+            break;
+        case 6:
+            chengZhongJingDuModel_Num = 0.008;
+            f_chengZhongJingDuModel_Num = 0.08;
+            break;
+    }
+//    qDebug()<<"称重精度数据"<<chengZhongJingDuModel_Num;
+
     // 码数
     ui->mashu->clear();
     for(int i = 0; i < config.mashu.size(); ++i){
@@ -353,6 +408,26 @@ void UncertainWeightPackForm::upWare()
     }
 }
 
+void UncertainWeightPackForm::upBoxModelList()
+{
+    ui->xiangdan->clear();
+    ui->xiangdan->addItem("默认箱单");
+    QList<QSharedPointer<BoxModel>> boxList = glo->BoxModelList();
+    for(int i = 0;i<boxList.size();i++){
+        ui->xiangdan->addItem(boxList.at(i)->Model_Name);
+    }
+}
+
+void UncertainWeightPackForm::upPackModelList()
+{
+    ui->madan->clear();
+    ui->madan->addItem("默认码单");
+    QList<QSharedPointer<PackModel>> packList = glo->PackModelList();
+    for(int i = 0;i<packList.size();i++){
+        ui->madan->addItem(packList.at(i)->Model_Name);
+    }
+}
+
 //获取品目信息
 void UncertainWeightPackForm::on_searchButton_clicked()
 {
@@ -579,3 +654,28 @@ void UncertainWeightPackForm::on_ruku_stateChanged(int arg1)
     }
     isRuku = false;
 }
+
+void UncertainWeightPackForm::on_useNewDataButton_clicked()
+{
+    if(packinfo.isNull()) return;
+    for(int i =  0; i < packinfo->boxInfoSize(); ++i){
+        QSharedPointer<BoxInfo> 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->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();
+        box->bucket_color = ui->guanse->currentText();
+        box->sort = "1";
+    }
+    packinfo->level = ui->dengji->currentText();
+    packinfo->level_id = ui->dengji->currentData().toInt();
+    packinfo->customer = ui->taitou->text();
+    packinfo->telephone = ui->taiPhone->text();
+    packinfo->autoRuku = ui->ruku->isChecked();
+    packinfo->warehouse_id = ui->wareBox->currentData().toInt();
+    restTableWidget();
+}

+ 15 - 1
widget/uncertainweightpackform.h

@@ -53,6 +53,12 @@ private slots:
 
     void on_ruku_stateChanged(int arg1);
 
+private slots:
+    void upBoxModelList();//获取箱单模板
+    void upPackModelList();//获取码单模板
+
+    void on_useNewDataButton_clicked();
+
 private:
     void updateTableWidget(QList<QSharedPointer<ProjectInfo>> & list);
     void init();
@@ -101,7 +107,15 @@ private:
     PackInfoManger *Manger;
 
     double netNum = 0.00;
-    double gross_weight = 0.0;
+    double gross_weight = 0.00;
+    float f_gross_weight = 0.0;
+    float f_netNum = 0.0;
+
+    int chengZhongJingDu;
+    int chengZhongJingDuModel;
+    double chengZhongJingDuModel_Num = 0.00;//打包精度计算时所需的数,类似四舍五入时把double+0.5在向下取整;
+    double f_chengZhongJingDuModel_Num = 0.00;//单精度计算时的数;
+
     bool istubeNumTure;
     int tubeNumMax;
     int tubeNumMin;

+ 225 - 139
widget/uncertainweightpackform.ui

@@ -29,139 +29,6 @@
    <property name="spacing">
     <number>0</number>
    </property>
-   <item row="0" column="0">
-    <widget class="QWidget" name="widget_8" native="true">
-     <layout class="QGridLayout" name="gridLayout_12">
-      <item row="0" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout_5">
-        <item>
-         <widget class="QPushButton" name="pushEditBatch">
-          <property name="text">
-           <string>批量修改</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="pushNoSyncList">
-          <property name="text">
-           <string>未同步列表</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="pushSync">
-          <property name="text">
-           <string>同步</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="pushContinue">
-          <property name="text">
-           <string>接续</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer_3">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>15</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-        <item>
-         <widget class="QCheckBox" name="ruku">
-          <property name="text">
-           <string>打包及入库</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QRadioButton" name="dingzhong">
-          <property name="text">
-           <string>定重打包</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QRadioButton" name="buding">
-          <property name="text">
-           <string>不定重打包</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QCheckBox" name="autoSync">
-          <property name="text">
-           <string>自动同步</string>
-          </property>
-          <property name="checked">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-      <item row="1" column="0">
-       <widget class="QTableWidget" name="tableWidget">
-        <property name="minimumSize">
-         <size>
-          <width>0</width>
-          <height>0</height>
-         </size>
-        </property>
-        <property name="maximumSize">
-         <size>
-          <width>9999</width>
-          <height>16777215</height>
-         </size>
-        </property>
-        <column>
-         <property name="text">
-          <string>筒数</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>筒数</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>毛重</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>筒重</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>管色</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>净重</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>操作</string>
-         </property>
-        </column>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
    <item row="1" column="0" colspan="2">
     <widget class="QWidget" name="widget" native="true">
      <property name="minimumSize">
@@ -291,6 +158,15 @@
       </size>
      </property>
      <layout class="QGridLayout" name="gridLayout_6">
+      <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
       <item row="0" column="0">
        <layout class="QGridLayout" name="gridLayout_13">
         <item row="0" column="2">
@@ -336,9 +212,12 @@
           </property>
           <property name="font">
            <font>
-            <pointsize>25</pointsize>
+            <pointsize>30</pointsize>
            </font>
           </property>
+          <property name="value">
+           <number>6</number>
+          </property>
          </widget>
         </item>
         <item row="1" column="2">
@@ -436,7 +315,7 @@ color: rgb(0, 170, 255);</string>
           </property>
           <property name="font">
            <font>
-            <pointsize>25</pointsize>
+            <pointsize>30</pointsize>
            </font>
           </property>
           <property name="text">
@@ -964,6 +843,13 @@ 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="0">
          <widget class="QLabel" name="label_5">
           <property name="font">
@@ -989,10 +875,10 @@ color: rgb(0, 170, 255);</string>
           </property>
          </spacer>
         </item>
-        <item row="0" column="1">
-         <widget class="QLineEdit" name="lineEdit">
-          <property name="placeholderText">
-           <string>请输入规格或批号</string>
+        <item row="0" column="4">
+         <widget class="QPushButton" name="useNewDataButton">
+          <property name="text">
+           <string>应用</string>
           </property>
          </widget>
         </item>
@@ -1030,6 +916,206 @@ color: rgb(0, 170, 255);</string>
      </layout>
     </widget>
    </item>
+   <item row="0" column="0">
+    <widget class="QWidget" name="widget_8" native="true">
+     <layout class="QGridLayout" name="gridLayout_12">
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>3</number>
+      </property>
+      <item row="0" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_5">
+        <property name="spacing">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QPushButton" name="pushEditBatch">
+          <property name="minimumSize">
+           <size>
+            <width>55</width>
+            <height>0</height>
+           </size>
+          </property>
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>批量修改</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pushNoSyncList">
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>未同步列表</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pushSync">
+          <property name="maximumSize">
+           <size>
+            <width>34</width>
+            <height>16777215</height>
+           </size>
+          </property>
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>同步</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pushContinue">
+          <property name="maximumSize">
+           <size>
+            <width>34</width>
+            <height>16777215</height>
+           </size>
+          </property>
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>接续</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_3">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>15</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="ruku">
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>打包及入库</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="dingzhong">
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>定重打包</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="buding">
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>不定重打包</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="autoSync">
+          <property name="font">
+           <font>
+            <pointsize>9</pointsize>
+           </font>
+          </property>
+          <property name="text">
+           <string>自动同步</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item row="1" column="0">
+       <widget class="QTableWidget" name="tableWidget">
+        <property name="minimumSize">
+         <size>
+          <width>0</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>9999</width>
+          <height>16777215</height>
+         </size>
+        </property>
+        <column>
+         <property name="text">
+          <string>筒数</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>筒数</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>毛重</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>筒重</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>管色</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>净重</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>操作</string>
+         </property>
+        </column>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>