packdetailform.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include "packdetailform.h"
  2. #include "ui_packdetailform.h"
  3. PackDetailForm::PackDetailForm(QWidget *parent) :
  4. QWidget(parent),
  5. ui(new Ui::PackDetailForm)
  6. {
  7. ui->setupUi(this);
  8. // connect(&packConfig,&RemotePackConfig::configUpdate,this,&PackDetailForm::upconfig);
  9. productList();
  10. detailsList();
  11. }
  12. PackDetailForm::~PackDetailForm()
  13. {
  14. delete ui;
  15. }
  16. void PackDetailForm::on_pushBack_clicked()
  17. {
  18. emit back();
  19. }
  20. void PackDetailForm::on_pushButton_clicked()
  21. {
  22. changeTable(database.GetValues("product",productSqlList));
  23. }
  24. //往QTableWidget里添加数据
  25. void PackDetailForm::changeTable(QList<QMap<QString,QString>> productList)
  26. {
  27. // qDebug()<<productList.at(0).value("goods_id");
  28. if(productList.isEmpty()){
  29. QMessageBox::information(this,tr("提示"),tr("数据为空"));
  30. return;
  31. }
  32. product = productList;
  33. ui->tableWidget->setColumnCount(11);
  34. for(int i = 0;i<productList.size();i++){
  35. ui->tableWidget->insertRow(i);
  36. ui->tableWidget->setItem(i,0,new QTableWidgetItem(productList.at(i).value("tongbu") == "0" ? "未同步" : "同步"));
  37. ui->tableWidget->setItem(i,1,new QTableWidgetItem(productList.at(i).value("code_single")));
  38. ui->tableWidget->setItem(i,2,new QTableWidgetItem(productList.at(i).value("batch_no")));
  39. ui->tableWidget->setItem(i,3,new QTableWidgetItem(productList.at(i).value("gross_weight")));
  40. ui->tableWidget->setItem(i,4,new QTableWidgetItem(productList.at(i).value("net_weight")));
  41. ui->tableWidget->setItem(i,5,new QTableWidgetItem(productList.at(i).value("quantity")));
  42. ui->tableWidget->setItem(i,6,new QTableWidgetItem(productList.at(i).value("packing_time")));
  43. auto tongbu_btn = new QPushButton("同步");
  44. connect(tongbu_btn,&QPushButton::clicked,[i,this](){this->tongbu_clicked(i);});
  45. // connect(tongbu_btn, SIGNAL(clicked(bool)), this, SLOT(tongbu_clicked()));
  46. auto code_single_btn = new QPushButton("打印码单");
  47. connect(code_single_btn,SIGNAL(clicked(bool)),this,SLOT(code_single_clicked()));
  48. auto case_nember_btn = new QPushButton("打印箱单");
  49. connect(case_nember_btn,SIGNAL(clicked(bool)),this,SLOT(case_number_clicked()));
  50. auto details = new QTreeWidget(this);
  51. ui->tableWidget->setCellWidget(i,7,tongbu_btn);
  52. ui->tableWidget->setCellWidget(i,8,code_single_btn);
  53. ui->tableWidget->setCellWidget(i,9,case_nember_btn);
  54. ui->tableWidget->setCellWidget(i,10,details);
  55. }
  56. }
  57. //同步
  58. void PackDetailForm::tongbu_clicked(int row)
  59. {
  60. // qDebug()<<"行数:" << row;
  61. if(ui->tableWidget->item(row,0)->text()!="未同步"){
  62. QMessageBox::information(this,tr("垃圾"),tr("打我啊"));
  63. return;
  64. }
  65. QString condition = " where code_single="+product.at(row).value("code_single");
  66. details = database.GetValues("details",detailSqlList,condition);
  67. autoPack.doSend(autoPack.toJsonMap(product.at(row),details));
  68. ui->tableWidget->setItem(row,0,new QTableWidgetItem("请刷新"));
  69. }
  70. void PackDetailForm::code_single_clicked()
  71. {
  72. qDebug()<<"打印码单";
  73. }
  74. void PackDetailForm::case_number_clicked()
  75. {
  76. qDebug()<<"打印箱单";
  77. }
  78. void PackDetailForm::productList()
  79. {
  80. productSqlList.append("tongbu");
  81. productSqlList.append("goods_id");
  82. productSqlList.append("code_single");
  83. productSqlList.append("quantity");
  84. productSqlList.append("batch_no");
  85. productSqlList.append("level_id");
  86. productSqlList.append("tube_number");
  87. productSqlList.append("gross_weight");
  88. productSqlList.append("net_weight");
  89. productSqlList.append("machine_no");
  90. productSqlList.append("packing_time");
  91. productSqlList.append("packing_type");
  92. productSqlList.append("carton_type");
  93. productSqlList.append("operator_id");
  94. productSqlList.append("remark");
  95. }
  96. void PackDetailForm::detailsList()
  97. {
  98. detailSqlList.append("code_single");
  99. detailSqlList.append("case_number");
  100. detailSqlList.append("box_weight");
  101. detailSqlList.append("tube_number");
  102. detailSqlList.append("bucket_weight");
  103. detailSqlList.append("gross_weight");
  104. detailSqlList.append("net_weight");
  105. detailSqlList.append("sort");
  106. detailSqlList.append("remark");
  107. }