|
|
@@ -7,8 +7,13 @@ PackDetailForm::PackDetailForm(QWidget *parent) :
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
// connect(&packConfig,&RemotePackConfig::configUpdate,this,&PackDetailForm::upconfig);
|
|
|
+// ui->tableWidget->resizeColumnsToContents();
|
|
|
+// ui->tableWidget->resizeRowsToContents();
|
|
|
+// ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
+// ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
productList();
|
|
|
detailsList();
|
|
|
+ ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
|
}
|
|
|
|
|
|
PackDetailForm::~PackDetailForm()
|
|
|
@@ -23,55 +28,87 @@ void PackDetailForm::on_pushBack_clicked()
|
|
|
|
|
|
void PackDetailForm::on_pushButton_clicked()
|
|
|
{
|
|
|
- changeTable(database.GetValues("product",productSqlList));
|
|
|
+ nowPageNum = 0;
|
|
|
+// changeTable(database.GetValues("product",productSqlLi st));
|
|
|
+ changeTreeWidget(database.GetValues("product",productSqlList,"limit 0,20"));
|
|
|
+// ui->pagesNum->setText(QString::number(pageNum)+"/"+QString::number(product.size()/20));
|
|
|
+ int pageListNum = database.GetTablePage();
|
|
|
+ pageNumAll = pageListNum / 20;
|
|
|
+ if(pageListNum % 20 > 0)
|
|
|
+ pageNumAll ++;
|
|
|
+ ui->pagesNum->setText(QString("%1/%2").arg(nowPageNum+1).arg(pageNumAll));
|
|
|
}
|
|
|
|
|
|
-//往QTableWidget里添加数据
|
|
|
-void PackDetailForm::changeTable(QList<QMap<QString,QString>> productList)
|
|
|
+//往treewidget添加数据
|
|
|
+void PackDetailForm::changeTreeWidget(QList<QMap<QString,QString>> productList)
|
|
|
{
|
|
|
-// qDebug()<<productList.at(0).value("goods_id");
|
|
|
- if(productList.isEmpty()){
|
|
|
- QMessageBox::information(this,tr("提示"),tr("数据为空"));
|
|
|
- return;
|
|
|
- }
|
|
|
- product = productList;
|
|
|
- ui->tableWidget->setColumnCount(11);
|
|
|
- for(int i = 0;i<productList.size();i++){
|
|
|
- ui->tableWidget->insertRow(i);
|
|
|
- ui->tableWidget->setItem(i,0,new QTableWidgetItem(productList.at(i).value("tongbu") == "0" ? "未同步" : "同步"));
|
|
|
- ui->tableWidget->setItem(i,1,new QTableWidgetItem(productList.at(i).value("code_single")));
|
|
|
- ui->tableWidget->setItem(i,2,new QTableWidgetItem(productList.at(i).value("batch_no")));
|
|
|
- ui->tableWidget->setItem(i,3,new QTableWidgetItem(productList.at(i).value("gross_weight")));
|
|
|
- ui->tableWidget->setItem(i,4,new QTableWidgetItem(productList.at(i).value("net_weight")));
|
|
|
- ui->tableWidget->setItem(i,5,new QTableWidgetItem(productList.at(i).value("quantity")));
|
|
|
- ui->tableWidget->setItem(i,6,new QTableWidgetItem(productList.at(i).value("packing_time")));
|
|
|
- auto tongbu_btn = new QPushButton("同步");
|
|
|
- connect(tongbu_btn,&QPushButton::clicked,[i,this](){this->tongbu_clicked(i);});
|
|
|
-// connect(tongbu_btn, SIGNAL(clicked(bool)), this, SLOT(tongbu_clicked()));
|
|
|
- auto code_single_btn = new QPushButton("打印码单");
|
|
|
- connect(code_single_btn,SIGNAL(clicked(bool)),this,SLOT(code_single_clicked()));
|
|
|
- auto case_nember_btn = new QPushButton("打印箱单");
|
|
|
- connect(case_nember_btn,SIGNAL(clicked(bool)),this,SLOT(case_number_clicked()));
|
|
|
- auto details = new QTreeWidget(this);
|
|
|
- ui->tableWidget->setCellWidget(i,7,tongbu_btn);
|
|
|
- ui->tableWidget->setCellWidget(i,8,code_single_btn);
|
|
|
- ui->tableWidget->setCellWidget(i,9,case_nember_btn);
|
|
|
- ui->tableWidget->setCellWidget(i,10,details);
|
|
|
- }
|
|
|
+ if(productList.isEmpty()){
|
|
|
+ QMessageBox::information(this,tr("提示"),tr("数据为空"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ui->treeWidget->clear();
|
|
|
+ product = productList;
|
|
|
+/**********************************************************************************************/
|
|
|
+ //循环添加数据
|
|
|
+ for(int i = 0;i<productList.size();i++){
|
|
|
+ QStringList list;
|
|
|
+ list.append(productList.at(i).value("tongbu") == "0" ? "未同步" : "已同步");
|
|
|
+ if(productList.at(i).value("tongbu") == "0"){
|
|
|
+ }
|
|
|
+ list.append(productList.at(i).value("code_single"));
|
|
|
+ list.append(productList.at(i).value("batch_no"));
|
|
|
+ list.append(productList.at(i).value("gross_weight"));
|
|
|
+ list.append(productList.at(i).value("net_weight"));
|
|
|
+ list.append(productList.at(i).value("quantity"));
|
|
|
+ list.append(productList.at(i).value("packing_time"));
|
|
|
+
|
|
|
+
|
|
|
+ auto item = new QTreeWidgetItem(list);
|
|
|
+ auto tongbu_btn = new QPushButton("同步");
|
|
|
+ connect(tongbu_btn,&QPushButton::clicked,[item,i,this](){this->tongbu_clicked(item,i);});
|
|
|
+ // connect(tongbu_btn, SIGNAL(clicked(bool)), this, SLOT(tongbu_clicked()));
|
|
|
+ auto code_single_btn = new QPushButton("打印码单");
|
|
|
+ connect(code_single_btn,SIGNAL(clicked(bool)),this,SLOT(code_single_clicked()));
|
|
|
+ auto case_nember_btn = new QPushButton("打印箱单");
|
|
|
+ connect(case_nember_btn,SIGNAL(clicked(bool)),this,SLOT(case_number_clicked()));
|
|
|
+
|
|
|
+ ui->treeWidget->addTopLevelItem(item);
|
|
|
+ ui->treeWidget->setItemWidget(item,7,tongbu_btn);
|
|
|
+ ui->treeWidget->setItemWidget(item,8,code_single_btn);
|
|
|
+ ui->treeWidget->setItemWidget(item,9,case_nember_btn);
|
|
|
+
|
|
|
+ details = database.GetValues("details",detailSqlList," where code_single = "+product.at(i).value("code_single"));
|
|
|
+ for(int i=0; i<details.length(); ++i)//给A添加子项目
|
|
|
+ {
|
|
|
+ QStringList columItemList;
|
|
|
+ QTreeWidgetItem *child;
|
|
|
+ columItemList<<details.at(i).value("case_number");
|
|
|
+ child = new QTreeWidgetItem(columItemList);
|
|
|
+ item->addChild(child);
|
|
|
+ // ui->tree->setItemWidget(child,1,new QSpinBox);
|
|
|
+ ui->treeWidget->setCurrentItem(child,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ui->pageDataNum->setText("本页数据:"+QString::number(product.length()));
|
|
|
+ ui->pagesNum->setText(QString("%1/%2").arg(nowPageNum+1).arg(pageNumAll));
|
|
|
}
|
|
|
|
|
|
-//同步
|
|
|
-void PackDetailForm::tongbu_clicked(int row)
|
|
|
+//同步按钮
|
|
|
+void PackDetailForm::tongbu_clicked(QTreeWidgetItem * item,int row)
|
|
|
{
|
|
|
-// qDebug()<<"行数:" << row;
|
|
|
- if(ui->tableWidget->item(row,0)->text()!="未同步"){
|
|
|
- QMessageBox::information(this,tr("垃圾"),tr("打我啊"));
|
|
|
+ qDebug()<<"行数:" << row;
|
|
|
+ qDebug()<<item->text(0);
|
|
|
+ if(item->text(0) != "未同步"){
|
|
|
+ QMessageBox::information(this,tr("提示"),tr("请刷新"));
|
|
|
return;
|
|
|
}
|
|
|
QString condition = " where code_single="+product.at(row).value("code_single");
|
|
|
details = database.GetValues("details",detailSqlList,condition);
|
|
|
autoPack.doSend(autoPack.toJsonMap(product.at(row),details));
|
|
|
- ui->tableWidget->setItem(row,0,new QTableWidgetItem("请刷新"));
|
|
|
+ item->setText(0,"请刷新");
|
|
|
+ item->setBackground(0,QBrush(QColor(255,255,0)));
|
|
|
}
|
|
|
|
|
|
void PackDetailForm::code_single_clicked()
|
|
|
@@ -84,6 +121,35 @@ void PackDetailForm::case_number_clicked()
|
|
|
qDebug()<<"打印箱单";
|
|
|
}
|
|
|
|
|
|
+//上一页
|
|
|
+void PackDetailForm::on_prevoiusPage_clicked()
|
|
|
+{
|
|
|
+ if(nowPageNum<=0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ nowPageNum--;
|
|
|
+ changeTreeWidget(database.GetValues("product",productSqlList,"limit "+QString::number(nowPageNum)+",20"));
|
|
|
+}
|
|
|
+
|
|
|
+//下一页
|
|
|
+void PackDetailForm::on_nextPage_clicked()
|
|
|
+{
|
|
|
+ if(nowPageNum>=pageNumAll-1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ nowPageNum++;
|
|
|
+ changeTreeWidget(database.GetValues("product",productSqlList,"limit "+QString::number(nowPageNum)+",20"));
|
|
|
+}
|
|
|
+
|
|
|
+//跳转
|
|
|
+void PackDetailForm::on_jump_clicked()
|
|
|
+{
|
|
|
+ if(ui->jumpPage->text().toInt()>pageNumAll){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ changeTreeWidget(database.GetValues("product",productSqlList,"limit "+ui->jumpPage->text()+",20"));
|
|
|
+}
|
|
|
+
|
|
|
void PackDetailForm::productList()
|
|
|
{
|
|
|
productSqlList.append("tongbu");
|
|
|
@@ -115,3 +181,79 @@ void PackDetailForm::detailsList()
|
|
|
detailSqlList.append("sort");
|
|
|
detailSqlList.append("remark");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+////往QTableWidget里添加数据
|
|
|
+//void PackDetailForm::changeTable(QList<QMap<QString,QString>> productList)
|
|
|
+//{
|
|
|
+//// qDebug()<<productList.at(0).value("goods_id");
|
|
|
+// if(productList.isEmpty()){
|
|
|
+// QMessageBox::information(this,tr("提示"),tr("数据为空"));
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// product = productList;
|
|
|
+// ui->tableWidget->setColumnCount(11);
|
|
|
+// for(int i = 0;i<productList.size();i++){
|
|
|
+// ui->tableWidget->insertRow(i);
|
|
|
+// ui->tableWidget->setItem(i,0,new QTableWidgetItem(productList.at(i).value("tongbu") == "0" ? "未同步" : "同步"));
|
|
|
+// if(ui->tableWidget->item(i,0)->text()=="未同步"){
|
|
|
+// ui->tableWidget->item(i,0)->setBackground(QBrush(QColor(255, 0, 0,180)));
|
|
|
+// }else{
|
|
|
+// ui->tableWidget->item(i,0)->setBackground(QBrush(QColor(0, 255, 255)));
|
|
|
+// }
|
|
|
+// ui->tableWidget->setItem(i,1,new QTableWidgetItem(productList.at(i).value("code_single")));
|
|
|
+// ui->tableWidget->setItem(i,2,new QTableWidgetItem(productList.at(i).value("batch_no")));
|
|
|
+// ui->tableWidget->setItem(i,3,new QTableWidgetItem(productList.at(i).value("gross_weight")));
|
|
|
+// ui->tableWidget->setItem(i,4,new QTableWidgetItem(productList.at(i).value("net_weight")));
|
|
|
+// ui->tableWidget->setItem(i,5,new QTableWidgetItem(productList.at(i).value("quantity")));
|
|
|
+// ui->tableWidget->setItem(i,6,new QTableWidgetItem(productList.at(i).value("packing_time")));
|
|
|
+// auto tongbu_btn = new QPushButton("同步");
|
|
|
+// connect(tongbu_btn,&QPushButton::clicked,[i,this](){this->tongbu_clicked(i);});
|
|
|
+//// connect(tongbu_btn, SIGNAL(clicked(bool)), this, SLOT(tongbu_clicked()));
|
|
|
+// auto code_single_btn = new QPushButton("打印码单");
|
|
|
+// connect(code_single_btn,SIGNAL(clicked(bool)),this,SLOT(code_single_clicked()));
|
|
|
+// auto case_nember_btn = new QPushButton("打印箱单");
|
|
|
+// connect(case_nember_btn,SIGNAL(clicked(bool)),this,SLOT(case_number_clicked()));
|
|
|
+// auto details = new QTreeWidget(this);
|
|
|
+//// auto details_btn = new QPushButton("");
|
|
|
+// ui->tableWidget->setCellWidget(i,7,tongbu_btn);
|
|
|
+// ui->tableWidget->setCellWidget(i,8,code_single_btn);
|
|
|
+// ui->tableWidget->setCellWidget(i,9,case_nember_btn);
|
|
|
+// ui->tableWidget->setCellWidget(i,10,details);
|
|
|
+
|
|
|
+// details->setWindowTitle("tree");
|
|
|
+// QTreeWidgetItem* detail = new QTreeWidgetItem(QStringList()<<"详情");
|
|
|
+//// detail->setCheckState(0, Qt::Checked);
|
|
|
+//// details->setSortingEnabled(true);
|
|
|
+// details->header()->setSortIndicator(0,Qt::AscendingOrder);
|
|
|
+// details->addTopLevelItem(detail);
|
|
|
+// details->header()->setVisible(false);
|
|
|
+// for(int i=0; i<10; ++i)
|
|
|
+// {
|
|
|
+
|
|
|
+// QStringList columItemList;
|
|
|
+// QTreeWidgetItem *child;
|
|
|
+// columItemList<<"list";
|
|
|
+// child = new QTreeWidgetItem(columItemList);
|
|
|
+// detail->addChild(child);
|
|
|
+// details->setItemWidget(child,1,new QSpinBox);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//}
|
|
|
+
|
|
|
+//同步
|
|
|
+//void PackDetailForm::tongbu_clicked(int row)
|
|
|
+//{
|
|
|
+// qDebug()<<"行数:" << row;
|
|
|
+// if(ui->tableWidget->item(row,0)->text()!="未同步"){
|
|
|
+// QMessageBox::information(this,tr("提示"),tr("请刷新"));
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// QString condition = " where code_single="+product.at(row).value("code_single");
|
|
|
+// details = database.GetValues("details",detailSqlList,condition);
|
|
|
+// autoPack.doSend(autoPack.toJsonMap(product.at(row),details));
|
|
|
+// ui->tableWidget->setItem(row,0,new QTableWidgetItem("请刷新"));
|
|
|
+// ui->tableWidget->item(row,0)->setBackground(QBrush(QColor(255,255,0)));
|
|
|
+//}
|
|
|
+
|
|
|
+
|