Commit f8915e85 by 李定达

Merge branch 'feature/mainshowchange' into develop

parents 6e3fc6fd bb54d3fc
...@@ -29,5 +29,13 @@ ...@@ -29,5 +29,13 @@
<file>loginlogin.png</file> <file>loginlogin.png</file>
<file>pickupclose.png</file> <file>pickupclose.png</file>
<file>pickupwar.png</file> <file>pickupwar.png</file>
<file>yy.png</file>
<file>orders_off.png</file>
<file>orders_on.png</file>
<file>refund_off.png</file>
<file>refund_on.png</file>
<file>setting_off.png</file>
<file>setting_on.png</file>
<file>mainlogo.png</file>
</qresource> </qresource>
</RCC> </RCC>
\ No newline at end of file
...@@ -689,7 +689,14 @@ QWidget ...@@ -689,7 +689,14 @@ QWidget
/*---------------------------------PickUpForm[end]-------------------------------------*/ /*---------------------------------PickUpForm[end]-------------------------------------*/
/*---------------------------------NewMainForm[end]-------------------------------------*/
#newmainlabel_logo
{
border-image: url(:mainlogo.png);
}
/*---------------------------------NewMainForm[end]-------------------------------------*/
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "model/posorderpool.h" #include "model/posorderpool.h"
#include "view/mainForm.h" #include "view/mainForm.h"
#include "view/floatForm.h" #include "view/floatForm.h"
#include "view/newmainform.h"
#include "control/orderlocalizework.h" #include "control/orderlocalizework.h"
#include "control/orderpushwork.h" #include "control/orderpushwork.h"
#include "control/orderprintwork.h" #include "control/orderprintwork.h"
...@@ -163,12 +164,17 @@ int main(int argc, char *argv[]) ...@@ -163,12 +164,17 @@ int main(int argc, char *argv[])
prtthreadt.start(); prtthreadt.start();
prtthreadpickup.start(); prtthreadpickup.start();
//界面类定义及初始化 //界面类定义及初始化
#ifndef FM_NEW_UI
MainForm mainform; MainForm mainform;
LoginForm loginform; LoginForm loginform;
FloatForm floatform; FloatForm floatform;
//开始展示界面 //开始展示界面
mainform.MyShow(); mainform.MyShow();
loginform.showfull(); loginform.showfull();
#else
NewMainForm mainform;
mainform.FullShow();
#endif
//回归事件循环 //回归事件循环
return a.exec(); return a.exec();
} }
......
...@@ -728,5 +728,3 @@ void PosOrderPool::UpdateOrderNum(const OrderObject *order, const OrderObject *o ...@@ -728,5 +728,3 @@ void PosOrderPool::UpdateOrderNum(const OrderObject *order, const OrderObject *o
} }
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <QMutex> #include <QMutex>
#include <QTimer> #include <QTimer>
#include <QMap> #include <QMap>
#include <functional>
#include <QDateTime> #include <QDateTime>
...@@ -180,6 +181,7 @@ typedef struct ...@@ -180,6 +181,7 @@ typedef struct
} Order_Info; } Order_Info;
class PosOrderPool : public QObject class PosOrderPool : public QObject
{ {
Q_OBJECT Q_OBJECT
...@@ -206,6 +208,19 @@ public: ...@@ -206,6 +208,19 @@ public:
static bool GetOrderStatusAndOrderType(QString key, int &status, int &refund_status, int &order_type, bool &oldorder); static bool GetOrderStatusAndOrderType(QString key, int &status, int &refund_status, int &order_type, bool &oldorder);
template <typename T>
static bool GetOrderIndex(T &t, std::function<bool (OrderObject &order, T &)> fun)
{
QMutexLocker loker(&s_mutex);
if(!s_order_pool.contains(key))
return false;
Order_Info info = s_order_pool[key];
return fun(info.order_data, t);
}
virtual bool event(QEvent *e); virtual bool event(QEvent *e);
private: private:
static void UpdateOrderNum(const OrderObject *order, const OrderObject *orderold = NULL); static void UpdateOrderNum(const OrderObject *order, const OrderObject *orderold = NULL);
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#define INI_DELEORDERTIMER "all/dltordertimer" #define INI_DELEORDERTIMER "all/dltordertimer"
#define INI_NEEDPTRNUM "all/needothernum"
#define INI_NEEDPTR "all/needotherprt" #define INI_NEEDPTR "all/needotherprt"
#define INI_NEEDLABEL "all/needlabel" #define INI_NEEDLABEL "all/needlabel"
......
...@@ -22,9 +22,11 @@ LIBS += -lWs2_32 ...@@ -22,9 +22,11 @@ LIBS += -lWs2_32
LIBS += -lDbghelp LIBS += -lDbghelp
#DEFINES += USE_QAACTION #DEFINES += USE_QAACTION
DEFINES += FM_NEW_UI
#DEFINES += FM_TEST #DEFINES += FM_TEST
#DEFINES += FM_MAIN_TEST #DEFINES += FM_MAIN_TEST
DEFINES += FM_ORDER_TEST
RC_FILE += takeout.rc RC_FILE += takeout.rc
CONFIG += c++11 CONFIG += c++11
...@@ -62,7 +64,11 @@ SOURCES += main.cpp \ ...@@ -62,7 +64,11 @@ SOURCES += main.cpp \
view/prtsettingform.cpp \ view/prtsettingform.cpp \
control/workobject.cpp \ control/workobject.cpp \
view/pickupform.cpp \ view/pickupform.cpp \
control/pickuporderwork.cpp control/pickuporderwork.cpp \
view/newmainform.cpp \
view/ordertypeform.cpp \
view/orderoptform.cpp \
view/mainbtn.cpp
HEADERS += \ HEADERS += \
event/fmapplication.h \ event/fmapplication.h \
...@@ -102,7 +108,11 @@ HEADERS += \ ...@@ -102,7 +108,11 @@ HEADERS += \
base/System/GetPrinters.h \ base/System/GetPrinters.h \
control/workobject.h \ control/workobject.h \
view/pickupform.h \ view/pickupform.h \
control/pickuporderwork.h control/pickuporderwork.h \
view/newmainform.h \
view/ordertypeform.h \
view/orderoptform.h \
view/mainbtn.h
DISTFILES += takeout.rc DISTFILES += takeout.rc
...@@ -117,4 +127,8 @@ FORMS += \ ...@@ -117,4 +127,8 @@ FORMS += \
view/detailForm.ui \ view/detailForm.ui \
view/loginform.ui \ view/loginform.ui \
view/prtsettingform.ui \ view/prtsettingform.ui \
view/pickupform.ui view/pickupform.ui \
view/newmainform.ui \
view/ordertypeform.ui \
view/orderoptform.ui \
view/mainbtn.ui
#include "mainbtn.h"
#include "ui_mainbtn.h"
#include <QMouseEvent>
#include <qDebug>
MainBtn::MainBtn(QWidget *parent) :
QWidget(parent),
ui(new Ui::MainBtn)
{
ui->setupUi(this);
_checked = false;
}
MainBtn::~MainBtn()
{
delete ui;
}
void MainBtn::setChecked(bool check)
{
_checked = check;
QString type = this->property("type").toString();
//qDebug() << "====" << type << ";" << check << _type;
if(type.compare("order",Qt::CaseInsensitive) == 0)
{
if(check)
{
ui->mainbtnlabel_name->setStyleSheet("#mainbtnlabel_name{color:rgba(255,255,255,1)}");
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:orders_on.png)}");
}
else
{
ui->mainbtnlabel_name->setStyleSheet("#mainbtnlabel_name{color:rgba(54,60,66,1)}");
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:orders_off.png)}");
}
return ;
}
if(type.compare("refund",Qt::CaseInsensitive) == 0)
{
if(check)
{
ui->mainbtnlabel_name->setStyleSheet("#mainbtnlabel_name{color:rgba(255,255,255,1)}");
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:refund_on.png)}");
}
else
{
ui->mainbtnlabel_name->setStyleSheet("#mainbtnlabel_name{color:rgba(54,60,66,1)}");
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:refund_off.png)}");
}
return ;
}
if(type.compare("set",Qt::CaseInsensitive) == 0)
{
if(check)
{
ui->mainbtnlabel_name->setStyleSheet("#mainbtnlabel_name{color:rgba(255,255,255,1)}");
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:setting_on.png)}");
}
else
{
ui->mainbtnlabel_name->setStyleSheet("#mainbtnlabel_name{color:rgba(54,60,66,1)}");
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:setting_off.png)}");
}
return ;
}
}
void MainBtn::mousePressEvent(QMouseEvent *e)
{
if(e->buttons()&Qt::LeftButton)
{
emit clicked();
return ;
}
return QWidget::mousePressEvent(e);
}
void MainBtn::SetText(QString data, QString type)
{
_type = type;
ui->mainbtnlabel_name->setText(data);
ui->mainbtnlabel_name->setStyleSheet("#mainbtnlabel_name{color:rgba(255,255,255,1)}");
if(type.compare("order",Qt::CaseInsensitive) == 0)
{
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:orders_off.png)}");
return ;
}
if(type.compare("refund",Qt::CaseInsensitive) == 0)
{
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:refund_off.png)}");
return ;
}
if(type.compare("set",Qt::CaseInsensitive) == 0)
{
ui->mainbtnlabel_lg->setStyleSheet("#mainbtnlabel_lg{ border-image: url(:setting_off.png)}");
return ;
}
}
#ifndef MAINBTN_H
#define MAINBTN_H
#include <QWidget>
namespace Ui {
class MainBtn;
}
class MainBtn : public QWidget
{
Q_OBJECT
public:
explicit MainBtn(QWidget *parent = 0);
~MainBtn();
void setChecked(bool check);
void mousePressEvent(QMouseEvent *e);
void SetText(QString data, QString type);
signals:
void clicked();
private:
Ui::MainBtn *ui;
bool _checked;
QString _type;
};
#endif // MAINBTN_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainBtn</class>
<widget class="QWidget" name="MainBtn">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>160</width>
<height>80</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>160</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>160</width>
<height>80</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">#mainbtnlabel_name
{
color: rgb(255, 255, 255);
font: 16px &quot;微软雅黑&quot;;
}
#MainBtn
{
background-color: rgb(23,28,23);
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<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>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="mainbtnlabel_lg">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>14</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="mainbtnlabel_name">
<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>89</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "newmainform.h"
#include "ui_newmainform.h"
#include "model/orderObject.h"
#include "model/posorderpool.h"
#include "view/ordertypeform.h"
#include "view/orderoptform.h"
#include "QsLog.h"
#include "base/System/GetPrinters.h"
#include "event/fmapplication.h"
#include "event/posevent.h"
#include <QDebug>
#include <QScrollBar>
NewMainForm::NewMainForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::NewMainForm)
{
_curr_page_num = 1;
_curr_check_btn = NULL;
ui->setupUi(this);
InitClassify();
InitMainBtn();
InitPrtSettingWidget();
InitPrtConfig();
InitWidget(MAIN_ORDER);
ui->newmaintbwgt->setCurrentIndex(0);
InitPrtList();
InitTableWidget();
#ifdef FM_ORDER_TEST
// //订单原始状态(推了一个订单号时使用)
// DefaultOrder = -100,
// //锁定订单
// LockOrder = -1,
// //新订单
// NewOrder = 1,
// //确认订单
// FirmOrder =2,
// //取消订单
// CancelOrder=3,
// //配送中
// DispatchingOrder = 4,
// //制作完成
// InDevelopment = 5,
// //已送达
// ServiceOrder = 6,
// //申请退款
// ApplicationRefundOrder = 20,
// //申请部分退款
// ApplicationPartialRefundOrder = 22,
// //同意退款
// ApprovalRefundOrder = 30,
// //不同意退款
// RefusingRefundOrder = 40,
// //退款完成
// CompleteRefundOrder = 100,
// //完成订单
// CompleteOrder = 200,
//------------------------------------------test
OrderObject order;
order.status = NewOrder;
order.refund_status = DefaultOrder;
order.order_id = "0";
order.order_index = 0;
order.channel_name = "hungry";
order.phone = "66666666";
order.customer = "ldd";
order.shop_fee = 688;
InsertTableWidget(order);
OrderObject order1;
order1.status = FirmOrder;
order1.refund_status = DefaultOrder;
order1.order_index = 1;
InsertTableWidget(order1);
OrderObject order2;
order2.status = FirmOrder;
order2.refund_status = ApplicationRefundOrder;
order2.order_index = 2;
InsertTableWidget(order2);
OrderObject order3;
order3.status = InDevelopment;
order3.refund_status = DefaultOrder;
order3.order_index = 3;
InsertTableWidget(order3);
OrderObject order4;
order4.status = InDevelopment;
order4.refund_status = DefaultOrder;
order4.order_index = 4;
InsertTableWidget(order4);
OrderObject order5;
order5.status = InDevelopment;
order5.refund_status = DefaultOrder;
order5.order_index = 5;
InsertTableWidget(order5);
OrderObject order6;
order6.status = InDevelopment;
order6.refund_status = DefaultOrder;
order6.order_index = 6;
InsertTableWidget(order6);
OrderObject order7;
order7.status = InDevelopment;
order7.refund_status = DefaultOrder;
order7.order_index = 7;
InsertTableWidget(order7);
OrderObject order8;
order8.status = InDevelopment;
order8.refund_status = DefaultOrder;
order8.order_index = 8;
InsertTableWidget(order8);
OrderObject order9;
order9.status = InDevelopment;
order9.refund_status = DefaultOrder;
order9.order_index = 9;
InsertTableWidget(order9);
OrderObject order10;
order10.status = InDevelopment;
order10.refund_status = DefaultOrder;
order10.order_index = 10;
InsertTableWidget(order10);
OrderObject order11;
order11.status = InDevelopment;
order11.refund_status = DefaultOrder;
order11.order_index = 11;
InsertTableWidget(order11);
OrderObject order12;
order12.status = InDevelopment;
order12.refund_status = DefaultOrder;
order12.order_index = 12;
InsertTableWidget(order12);
OrderObject order13;
order13.status = InDevelopment;
order13.refund_status = DefaultOrder;
order13.order_index = 13;
InsertTableWidget(order13);
OrderObject order14;
order14.status = InDevelopment;
order14.refund_status = DefaultOrder;
order14.order_index = 14;
InsertTableWidget(order14);
OrderObject order15;
order15.status = InDevelopment;
order15.refund_status = DefaultOrder;
order15.order_index = 15;
InsertTableWidget(order15);
OrderObject order16;
order16.status = InDevelopment;
order16.refund_status = DefaultOrder;
order16.order_index = 16;
order16.order_type = AppointmentTakeout;
InsertTableWidget(order16);
OrderObject order17;
order17.status = InDevelopment;
order17.refund_status = DefaultOrder;
order17.order_index = 17;
order17.order_type = LockOrder;
order17.status = CompleteOrder;
InsertTableWidget(order17);
OrderObject order18;
order18.status = InDevelopment;
order18.refund_status = DefaultOrder;
order18.order_index = 18;
order18.order_type = AppointmentTakeout;
order18.status = DispatchingOrder;
InsertTableWidget(order18);
OrderObject order19;
order19.status = InDevelopment;
order19.refund_status = DefaultOrder;
order19.order_index = 19;
order19.order_type = AppointmentTakeout;
order19.status = FirmOrder;
InsertTableWidget(order19);
OrderObject order20;
order20.order_type = AppointmentTakeout;
order20.status = InDevelopment;
order20.refund_status = DefaultOrder;
order20.order_index = 20;
order20.order_type = AppointmentTakeout;
order20.status = NewOrder;
InsertTableWidget(order20);
OrderObject order21;
order21.order_type = AppointmentTakeout;
order21.status = InDevelopment;
order21.refund_status = DefaultOrder;
order21.order_index = 21;
order21.order_type = AppointmentTakeout;
order21.status = NewOrder;
InsertTableWidget(order21);
OrderObject order22;
order22.order_type = AppointmentTakeout;
order22.status = InDevelopment;
order22.refund_status = CompleteRefundOrder;
order22.order_index = 22;
order22.order_id = "22";
order22.order_type = AppointmentTakeout;
order22.status = NewOrder;
InsertTableWidget(order22);
OrderObject order23;
order23.order_type = AppointmentTakeout;
order23.status = InDevelopment;
order23.refund_status = DefaultOrder;
order23.order_index = 23;
order23.order_id = "23";
order23.order_type = AppointmentTakeout;
order23.status = NewOrder;
InsertTableWidget(order23);
//------------------------------------------test
#endif
FMApplication::subscibeEvent(this, PosEvent::s_login_status);
FMApplication::subscibeEvent(this, PosEvent::s_opt_status);
FMApplication::subscibeEvent(this, PosEvent::s_change_order);
FMApplication::subscibeEvent(this, PosEvent::s_get_order_status);
FMApplication::subscibeEvent(this, PosEvent::s_delete_order);
FMApplication::subscibeEvent(this, PosEvent::s_login_storeinfo);
FMApplication::subscibeEvent(this, PosEvent::s_show_mainform);
FMApplication::subscibeEvent(this, PosEvent::s_network_outtime);
this->show();
}
void NewMainForm::FullShow()
{
this->show();
InitPageNum();
}
void NewMainForm::InitPageNum()
{
int num = ui->newmaintablewidget_order->height()/36;
int page = _curr_page_num/(num - 1) ;
if(_curr_page_num %(num - 1) != 0)
++ page;
//qDebug() << "+++++++" << num << ";" << "page" << page << ";" << _curr_page_num;
_curr_page = 1;
ui->newmaintablewidget_order->verticalScrollBar()->setValue(0);
ui->newmainlabel_allnum->setText(QString::fromUtf8("\xE5\x85\xB1%1\xE6\x9D\xA1").arg(QString::number(_curr_page_num)));
if (page != 0)
ui->newmainlabel_page->setText(QString::number(_curr_page)+ "/" + QString::number(page));
else
ui->newmainlabel_page->setText(QString::number(_curr_page)+ "/" + QString("1"));
ui->newmaintablewidget_order->viewport()->setFixedHeight((num - 1) * 36);
}
void NewMainForm::InitPrtList()
{
QStringList list;
GetPrinters::HasPrintersName(list);
for(int i = 0; i < list.size(); ++ i)
{
ui->newmaincombx_name->addItem(list[i]);
}
ui->newmainline_name->setText(ui->newmaincombx_name->currentText());
}
void NewMainForm::InitPrtConfig()
{
QString needprtpath = qApp->applicationDirPath() + "/" + PREINTER_NEED;
_other_prt_num = QSettings(needprtpath, QSettings::IniFormat).value(INI_NEEDPTRNUM,0).toInt();
int labelnumber = QSettings(needprtpath, QSettings::IniFormat).value(INI_NEEDLABEL,0).toInt();
//兼容旧版本
if(_other_prt_num == 0 && QSettings(needprtpath, QSettings::IniFormat).value(INI_NEEDPTR,0).toInt() != 0)
{
_other_prt_num = 1;
NewMainFormDataProcess::SetOtherPrintNum(_other_prt_num);
}
QString section = "Printer";
QString comsection = "COMDEF";
NewMainFormDataProcess::GetPrintIni(section, comsection, _main_prt_configs);
if (labelnumber != 0)
{
NewMainFormDataProcess::GetPrintIni(section, comsection, _label_prt_configs);
}
for(int i = 0; i < _other_prt_num; ++i)
{
QString section = "OtherPrinter";
QString comsection = "OTHERCOMDEF";
QMap<QString,QString> tmpmap;
if(i == 0)
{
NewMainFormDataProcess::GetPrintIni(section, comsection, tmpmap);
}
else
{
section += QString::number(i+1);
comsection += QString::number(i+1);
NewMainFormDataProcess::GetPrintIni(section, comsection, tmpmap);
}
QString prtlist = QString::fromUtf8("\xE5\x90\x8E\xE5\x8E\xA8\xE6\x89\x93\xE5\x8D\xB0\xE6\x9C\xBA") + QString::number(i+1);
ui->newmaincombx_prttype->addItem(prtlist);
_other_prt_configs.append(tmpmap);
}
}
bool NewMainForm::ClassifyOrder(QString type)
{
int tmptype = type.toInt();
switch (tmptype) {
case TYPE_NEEDREFUND:
ClassifyOrderWithOrderStatus(ApplicationRefundOrder);
break;
case TYPE_REFUNDED:
ClassifyOrderWithOrderStatus(CancelOrder);
break;
case TYPE_ALL:
ClassifyOrderWithOrderStatus(DefaultOrder);
break;
case TYPE_NEW:
ClassifyOrderWithOrderStatus(NewOrder);
break;
case TYPE_MAKE:
ClassifyOrderWithOrderStatus(FirmOrder);
break;
case TYPE_SEND:
ClassifyOrderWithOrderStatus(DispatchingOrder);
break;
case TYPE_NAKEOVER:
ClassifyOrderWithOrderStatus(InDevelopment);
break;
case TYPE_OVER:
ClassifyOrderWithOrderStatus(CompleteOrder);
break;
case TYPE_FUTURE:
ClassifyOrderWithOrderType();
break;
default:
return false;
}
return true;
}
void NewMainForm::ClassifyOrderWithOrderType()
{
_curr_page_num = 0;
QTableWidget *table = ui->newmaintablewidget_order;
for(int i=0; i<table->rowCount(); i++)
{
OrderTypeForm *pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->order_type() == AppointmentTakeout ||
pwd->order_type() == AppointmentDining ||
pwd->order_type() == AppointmentInvite)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
{
table->setRowHidden(i, true);
}
}
}
void NewMainForm::ClassifyOrderWithOrderStatus(int order_status)
{
_curr_page_num = 0;
QTableWidget *table = ui->newmaintablewidget_order;
for(int i=0; i<table->rowCount(); i++)
{
OrderTypeForm *pwd = NULL;
switch (order_status) {
case DefaultOrder:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->GetOrderStatus() == NewOrder || pwd->GetOrderStatus() == FirmOrder ||
pwd->GetOrderStatus() == DispatchingOrder || pwd->GetOrderStatus() == DispatchingOrder ||
pwd->GetOrderStatus() == InDevelopment || pwd->GetOrderStatus() == CompleteOrder ||
pwd->GetOrderStatus() == ServiceOrder)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
case NewOrder:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->GetOrderStatus() == NewOrder)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
case FirmOrder:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->GetOrderStatus() == FirmOrder)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
case DispatchingOrder:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->GetOrderStatus() == DispatchingOrder)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
case InDevelopment:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->GetOrderStatus() == InDevelopment)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
case ApplicationRefundOrder:
case ApplicationPartialRefundOrder:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->GetOrderStatus() == ApplicationRefundOrder || pwd->GetOrderStatus() == ApplicationPartialRefundOrder)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
case LockOrder:
case CancelOrder:
case ApprovalRefundOrder:
case CompleteRefundOrder:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
//qDebug()<<"-----" << pwd->GetOrderStatus() << ";" << pwd->order_id() << ";" << pwd->refund_status() << ";" << pwd->order_status();
if(pwd->GetOrderStatus() == ApprovalRefundOrder || pwd->GetOrderStatus() == CompleteRefundOrder
|| pwd->GetOrderStatus() == LockOrder || pwd->GetOrderStatus() == CancelOrder)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
case CompleteOrder:
case ServiceOrder:
pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(pwd->GetOrderStatus() == CompleteOrder || pwd->GetOrderStatus() == ServiceOrder)
{
table->setRowHidden(i, false);
++_curr_page_num;
}
else
table->setRowHidden(i, true);
break;
default:
table->setRowHidden(i, true);
break;
}
}
}
void NewMainForm::InitMainBtn()
{
ui->newmainbtn_order->SetText("\xE8\xAE\xA2\xE5\x8D\x95\xE7\xAE\xA1\xE7\x90\x86", MAIN_ORDER);
ui->newmainbtn_refund->SetText("\xE9\x80\x80\xE5\x8D\x95", MAIN_REFUND);
ui->newmainbtn_set->SetText("\xE8\xAE\xBE\xE7\xBD\xAE", MAIN_SET);
ui->newmainbtn_order->setProperty("type", "order");
ui->newmainbtn_refund->setProperty("type", "refund");
ui->newmainbtn_set->setProperty("type", "set");
_main_btn.insert(ui->newmainbtn_order);
_main_btn.insert(ui->newmainbtn_refund);
_main_btn.insert(ui->newmainbtn_set);
}
void NewMainForm::SetMainBtnCheck(MainBtn *wgt)
{
foreach (auto var, _main_btn) {
if(wgt == var)
var->setChecked(true);
else
var->setChecked(false);
//qDebug() << "&&&&&&&&&&&&" << var->property("type").toString();
}
}
void NewMainForm::InitPrtSettingWidget()
{
_prtsetting_widget.insert(ui->newmainwidget_dv);
_prtsetting_widget.insert(ui->newmainwidget_com);
_prtsetting_widget.insert(ui->newmainwidget_net);
_prtsetting_widget.insert(ui->newmainwidget_lpt);
}
void NewMainForm::InitClassify()
{
_classify_set.insert(ui->newmainbtn_needrefund);
_classify_set.insert(ui->newmainbtn_refunded);
_classify_set.insert(ui->newmainbtn_all);
_classify_set.insert(ui->newmainbtn_new);
_classify_set.insert(ui->newmainbtn_make);
_classify_set.insert(ui->newmainbtn_makeover);
_classify_set.insert(ui->newmainbtn_send);
_classify_set.insert(ui->newmainbtn_over);
_classify_set.insert(ui->newmainbtn_future);
}
NewMainForm::~NewMainForm()
{
delete ui;
}
bool NewMainForm::event(QEvent *e)
{
if(e->type() == PosEvent::s_change_order)
{
QString orderid;
GETEVENTINFO(orderid,e,QString);
OrderObject order;
if(!PosOrderPool::GetOrderObject(orderid, order))
return true;
Order_Index tmp = {order.status, order.refund_status};
if(_order_indexs.contains(order.order_id))
{
_order_indexs.insert(order.order_id, tmp);
UpdateTableWidget(order);
}
else
{
_order_indexs.insert(order.order_id, tmp);
InsertTableWidget(order);
}
return true;
}
if(e->type() == PosEvent::s_login_storeinfo)
{
QVariantMap map;
GETEVENTINFO(map, e, QVariantMap);
_storeinfo = map;
return true;
}
if(e->type() == PosEvent::s_show_mainform)
{
this->showFullScreen();
return true;
}
if(e->type() == PosEvent::s_delete_order)
{
QVariantMap value;
GETEVENTINFO(value,e,QVariantMap);
if(value.contains(EVENT_KEY_ORDERID) && !value[EVENT_KEY_ORDERID].toString().isEmpty() &&
_order_indexs.contains(value[EVENT_KEY_ORDERID].toString()))
{
DeleteTableWidget(value[EVENT_KEY_ORDERID].toString());
_order_indexs.remove(value[EVENT_KEY_ORDERID].toString());
}
return true;
}
return QWidget::event(e);
}
void NewMainForm::SetChecked(QPushButton *btn)
{
foreach (auto var, _classify_set) {
if(btn == var)
{
_curr_check_btn = btn;
var->setChecked(true);
ClassifyOrder(_curr_check_btn->property("type").toString());
//qDebug() << "------" << _curr_page_num;
InitPageNum();
}
else
{
var->setChecked(false);
}
}
}
void NewMainForm::UpdateTableWidget(OrderObject &orderObject)
{
QTableWidget *table = ui->newmaintablewidget_order;
for(int i=0; i<table->rowCount(); i++)
{
OrderTypeForm *pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(orderObject.order_id.compare(pwd->order_id()) == 0)
{
pwd->InitShow(orderObject.order_id, orderObject.status, orderObject.refund_status, orderObject.order_type);
break;
}
}
ClassifyOrder(_curr_check_btn->property("type").toString());
}
void NewMainForm::DeleteTableWidget(QString orderid)
{
QTableWidget *table = ui->newmaintablewidget_order;
for(int i=0; i<table->rowCount(); i++)
{
OrderTypeForm *pwd = (OrderTypeForm *)table->cellWidget(i, 1);
if(orderid.compare(pwd->order_id()) == 0)
{
table->removeRow(i);
break;
}
}
ClassifyOrder(_curr_check_btn->property("type").toString());
}
void NewMainForm::InitTableWidget()
{
ui->newmaintablewidget_order->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->newmaintablewidget_order->horizontalHeader()->setFixedHeight(36);
ui->newmaintablewidget_order->verticalHeader()->setVisible(false);
}
void NewMainForm::InsertTableWidget(OrderObject &orderObject)
{
QTableWidget *table = ui->newmaintablewidget_order;
table->insertRow(0);
QTableWidgetItem *item = new QTableWidgetItem(QString::number(orderObject.order_index));
table->setItem(0, 0, item); //序号
OrderTypeForm *pWdg = new OrderTypeForm(table);
pWdg->InitShow(orderObject.order_id, orderObject.status, orderObject.refund_status, orderObject.order_type);
//pWdg->InitShow(QString::number(orderObject.order_index), orderObject.status, orderObject.refund_status, orderObject.order_type);
table->setCellWidget(0, 1, pWdg); //订单状态
QTableWidgetItem *item0 = new QTableWidgetItem(QString::number(orderObject.order_index));
item0->setTextAlignment(Qt::AlignCenter);
table->setItem(0, 2, item0); // 渠道
// QTableWidgetItem *item1 = new QTableWidgetItem(orderObject.order_id);
// item1->setTextAlignment(Qt::AlignCenter);
// table->setItem(0, 3, item1); // 订单ID
QTableWidgetItem *item2 = new QTableWidgetItem(QString::number(orderObject.shop_fee/100.0));
item2->setTextAlignment(Qt::AlignCenter);
table->setItem(0, 3, item2); // 金额
QTableWidgetItem *item3 = new QTableWidgetItem(orderObject.customer);
item3->setTextAlignment(Qt::AlignCenter);
table->setItem(0, 4, item3); // 姓名
QTableWidgetItem *item4 = new QTableWidgetItem(orderObject.phone);
item4->setTextAlignment(Qt::AlignCenter);
table->setItem(0, 5, item4); // 联系方式
// QTableWidgetItem *item5 = new QTableWidgetItem(QDateTime::fromTime_t(orderObject.create_time).toString("MM-dd hh:mm"));
// item5->setTextAlignment(Qt::AlignCenter);
// table->setItem(0, 6, item5); // 下单时间
OrderOptForm *form = new OrderOptForm(table);
table->setCellWidget(0, 6, form); //订单操作
//qDebug() << _curr_check_btn->property("type").toString();
ClassifyOrder(_curr_check_btn->property("type").toString());
table->setRowHeight(0, 36);
}
void NewMainForm::GetOrderStatus(OrderObject &order, int &order_status)
{
if(order.refund_status == ApplicationRefundOrder &&
order.refund_status == ApplicationPartialRefundOrder &&
order.refund_status == RefusingRefundOrder)
order_status = order.refund_status;
else
order_status = order.status;
}
void NewMainForm::InitOrderWidget(QString type)
{
if(type.compare(MAIN_ORDER, Qt::CaseInsensitive) == 0)
{
ui->newmainbtn_needrefund->hide();
ui->newmainbtn_refunded->hide();
ui->newmainbtn_all->show();
ui->newmainbtn_new->show();
ui->newmainbtn_make->show();
ui->newmainbtn_makeover->show();
ui->newmainbtn_over->show();
ui->newmainbtn_future->show();
ui->newmainbtn_send->show();
SetMainBtnCheck(ui->newmainbtn_order);
SetChecked(ui->newmainbtn_all);
_curr_check_btn = ui->newmainbtn_all;
}
else if(type.compare(MAIN_REFUND, Qt::CaseInsensitive) == 0)
{
ui->newmainbtn_needrefund->show();
ui->newmainbtn_refunded->show();
ui->newmainbtn_all->hide();
ui->newmainbtn_new->hide();
ui->newmainbtn_make->hide();
ui->newmainbtn_makeover->hide();
ui->newmainbtn_over->hide();
ui->newmainbtn_future->hide();
ui->newmainbtn_send->hide();
SetMainBtnCheck(ui->newmainbtn_refund);
SetChecked(ui->newmainbtn_needrefund);
_curr_check_btn = ui->newmainbtn_needrefund;
}
}
void NewMainForm::InitSetWidget()
{
SetChecked(ui->newmainbtn_needrefund);
ui->newmaincombx_prttype->setCurrentIndex(0);
SetMainBtnCheck(ui->newmainbtn_set);
InitOrderSetting();
LoadMainPrtSetting();
}
void NewMainForm::InitWidget(QString type)
{
if(type.compare(MAIN_SET, Qt::CaseInsensitive) == 0)
{
InitSetWidget();
ui->newmainwgt_order->hide();
ui->newmainwgt_set->show();
}
else
{
InitOrderWidget(type);
ui->newmainwgt_order->show();
ui->newmainwgt_set->hide();
}
}
void NewMainForm::on_newmainbtn_clicked()
{
MainBtn *pBtn = (MainBtn*)sender();
QString type = pBtn->property("type").toString();
if(!type.isEmpty())
{
InitWidget(type);
}
}
void NewMainForm::on_classifybtn_clicked()
{
QPushButton *pBtn = (QPushButton*)sender();
SetChecked(pBtn);
}
void NewMainForm::LoadMainPrtSetting()
{
ui->newmainrdbtn_com->setCheckable(true);
ui->newmainrdbtn_lpt->setCheckable(true);
//qDebug() << _main_prt_configs;
if(_main_prt_configs.isEmpty())
{
ui->newmainrdbtn_dv->setChecked(true);
InitSettingWidget(SET_PRT_DV);
}
else
{
SettingWidgetWithConf(0, _main_prt_configs);
}
}
void NewMainForm::SettingWidgetWithConf(int index, QMap<QString, QString> &map)
{
int type = 4;
if(index != 1)
{
ui->newmaincombx_cmd->hide();
ui->newmainlabel_cmd->hide();
type = map["type"].toInt();
}
else
{
ui->newmaincombx_cmd->show();
ui->newmainlabel_cmd->show();
type = map["labelprttype"].toInt();
}
switch (type) {
case 0:
ui->newmaincombx_com->setCurrentText(map["com"]);
ui->newmaincombx_bdl->setCurrentText(map["Baudrate"]);
ui->newmaincombx_control->setCurrentText(map["FlowControl"]);
ui->newmaincombx_data->setCurrentText(map["DataBits"]);
ui->newmaincombx_jy->setCurrentText(map["Parity"]);
ui->newmaincombx_stop->setCurrentText(map["StopBits"]);
ui->newmaincombx_dvwidth->setCurrentText(map["PaperWidth"]);
ui->newmainrdbtn_com->setChecked(true);
InitSettingWidget(SET_PRT_COM);
break;
case 1:
ui->newmainline_lpt->setText(map["parallel"]);
ui->newmaincombx_lptwidth->setCurrentText(map["PaperWidth"]);
ui->newmainrdbtn_lpt->setChecked(true);
InitSettingWidget(SET_PRT_LPT);
break;
case 3:
ui->newmainline_ip->setText(map["IP"]);
ui->newmaincombx_netwidth->setCurrentText(map["PaperWidth"]);
ui->newmainrdbtn_net->setChecked(true);
InitSettingWidget(SET_PRT_NET);
break;
case 4:
ui->newmainline_name->setText(map["Name"]);
ui->newmaincombx_dvwidth->setCurrentText(map["PaperWidth"]);
ui->newmainrdbtn_dv->setChecked(true);
InitSettingWidget(SET_PRT_DV);
break;
default:
ui->newmainrdbtn_dv->setChecked(true);
InitSettingWidget(SET_PRT_DV);
break;
}
}
void NewMainForm::LoadLabelPrtSetting()
{
ui->newmainrdbtn_com->setCheckable(false);
ui->newmainrdbtn_lpt->setCheckable(false);
if(_label_prt_configs.isEmpty())
{
ui->newmainrdbtn_dv->setChecked(true);
InitSettingWidget(SET_PRT_DV);
}
else
{
SettingWidgetWithConf(1, _main_prt_configs);
}
}
void NewMainForm::LoadOtherPrtSetting(int index)
{
ui->newmainrdbtn_com->setCheckable(true);
ui->newmainrdbtn_lpt->setCheckable(true);
if(index > _other_prt_configs.size())
{
ui->newmainrdbtn_dv->setChecked(true);
InitSettingWidget(SET_PRT_DV);
return ;
}
SettingWidgetWithConf(index + 1, _other_prt_configs[index - 1]);
return ;
}
void NewMainForm::InitUserSetting()
{
}
void NewMainForm::InitPrtSetting()
{
LoadMainPrtSetting();
on_newmaincombx_prttype_currentIndexChanged(0);
}
void NewMainForm::InitOrderSetting()
{
QString confpath = qApp->applicationDirPath() + "/" + CONFIG_NAME;
int autoconf = QSettings(confpath, QSettings::IniFormat).value(INI_AUTOCONFIRM,1).toInt();
int timeout = QSettings(confpath, QSettings::IniFormat).value(INI_DELEORDERTIMER,1).toInt();
if(autoconf == 1)
ui->newmainrdbtn_auto->setChecked(true);
else
ui->newmainrdbtn_self->setChecked(true);
ui->newmaincombx_del->setCurrentIndex(timeout/12 - 1);
}
void NewMainForm::InitSettingWidget(QString type)
{
foreach (auto var, _prtsetting_widget) {
if(var->property("type").toString().compare(type, Qt::CaseInsensitive) == 0)
var->show();
else
var->hide();
}
}
void NewMainForm::on_PrtSet_toggled(bool checked)
{
if(checked)
{
QRadioButton *pBtn = (QRadioButton*)sender();
QString type = pBtn->property("type").toString();
InitSettingWidget(type);
}
}
void NewMainForm::on_newmaincombx_prttype_currentIndexChanged(int index)
{
ui->newmainlabel_errmsg->hide();
if(index == 0)
LoadMainPrtSetting();
else if(index == 1)
LoadLabelPrtSetting();
else
LoadOtherPrtSetting(index - 1);
if((ui->newmaincombx_prttype->count() == 2 && index == 0) ||
(ui->newmaincombx_prttype->count() > 2 && index == ui->newmaincombx_prttype->count() - 1))
ui->newmainbtn_prtadd->show();
else
ui->newmainbtn_prtadd->hide();
if(ui->newmaincombx_prttype->count() > 2 && index == ui->newmaincombx_prttype->count() - 1)
ui->newmainbtn_prtdel->show();
else
ui->newmainbtn_prtdel->hide();
ui->newmainlabel_settitle->setText(ui->newmaincombx_prttype->currentText());
}
void NewMainForm::on_newmaintbwgt_tabBarClicked(int index)
{
ui->newmainlabel_errmsg->hide();
if(index == 0)
{
InitOrderSetting();
}
else if(index == 1)
{
InitPrtSetting();
}
}
bool NewMainForm::GetMapAndSaveSet(int index, QMap<QString, QString> &map)
{
int type = -1;
if(ui->newmainrdbtn_dv->isChecked())
type = 4;
if(ui->newmainrdbtn_net->isChecked())
type = 3;
if(ui->newmainrdbtn_lpt->isChecked())
type = 1;
if(ui->newmainrdbtn_com->isChecked())
type = 0;
if(type == -1)
{
ShowSetErrorMsg(QString::fromUtf8("\xE8\xAF\xB7\xE9\x80\x89\xE6\x8B\xA9\xE6\x89\x93\xE5\x8D\xB0\xE6\x9C\xBA\xE7\xB1\xBB\xE5\x9E\x8B"));
return false;
}
map["type"] = QString::number(type);
switch (type) {
case 0:
map.insert("com", ui->newmaincombx_com->currentText());
map.insert("Baudrate", ui->newmaincombx_bdl->currentText());
map.insert("FlowControl", ui->newmaincombx_control->currentText());
map.insert("DataBits", ui->newmaincombx_data->currentText());
map.insert("Parity", ui->newmaincombx_jy->currentText());
map.insert("StopBits", ui->newmaincombx_stop->currentText());
map.insert("PaperWidth", ui->newmaincombx_dvwidth->currentText());
break;
case 1:
map.insert("parallel",ui->newmainline_lpt->text());
map.insert("PaperWidth",ui->newmaincombx_lptwidth->currentText());
break;
case 3:
ui->newmainline_ip->setText(map["IP"]);
ui->newmaincombx_netwidth->setCurrentText(map["PaperWidth"]);
break;
case 4:
map.insert("Name",ui->newmainline_name->text());
map.insert("PaperWidth",ui->newmaincombx_dvwidth->currentText());
break;
default:
return false;
}
NewMainFormDataProcess::SetPrintIniWithInde(index, map);
return true;
}
void NewMainForm::ShowSetErrorMsg(QString str)
{
ui->newmainlabel_errmsg->setText(str);
ui->newmainlabel_errmsg->show();
}
void NewMainForm::on_newmainbtn_prtsave_clicked()
{
ui->newmainlabel_errmsg->hide();
int index = ui->newmaincombx_prttype->currentIndex();
if(index == 0)
{
GetMapAndSaveSet(index, _main_prt_configs);
}
else if(index == 1)
{
GetMapAndSaveSet(index, _label_prt_configs);
}
else
{
QMap<QString, QString> map;
if(GetMapAndSaveSet(index, map))
{
if(_other_prt_configs.size() > index - 2)
_other_prt_configs[index - 2] = map;
else
{
++_other_prt_num;
NewMainFormDataProcess::SetOtherPrintNum(_other_prt_num);
_other_prt_configs.push_back(map);
}
}
}
}
void NewMainForm::on_newmainbtn_prtadd_clicked()
{
ui->newmainlabel_errmsg->hide();
int index = _other_prt_configs.size() + 1;
if(ui->newmaincombx_prttype->currentIndex() == index || ui->newmaincombx_prttype->count() == 2)
{
ui->newmaincombx_prttype->addItem(QString::fromUtf8("\xE5\x90\x8E\xE5\x8E\xA8\xE6\x89\x93\xE5\x8D\xB0\xE6\x9C\xBA") + QString::number(index));
ui->newmaincombx_prttype->setCurrentIndex(index + 1);
}
else
{
ShowSetErrorMsg(QString::fromUtf8("\xE8\xAF\xB7\xE5\x85\x88\xE4\xBF\x9D\xE5\xAD\x98\xE5\xBD\x93\xE5\x89\x8D\xE6\x89\x93\xE5\x8D\xB0\xE9\x85\x8D\xE7\xBD\xAE\xE5\x86\x8D\xE6\xB7\xBB\xE5\x8A\xA0\xE6\x96\xB0\xE6\x9C\xBA\xE5\x99\xA8"));
}
}
void NewMainForm::on_newmainbtn_prtdel_clicked()
{
ui->newmainlabel_errmsg->hide();
if(ui->newmaincombx_prttype->count() > 2)
{
if(ui->newmaincombx_prttype->count() - 2 == _other_prt_configs.size())
{
-- _other_prt_num;
NewMainFormDataProcess::SetOtherPrintNum(_other_prt_num);
_other_prt_configs.pop_back();
}
ui->newmaincombx_prttype->removeItem(ui->newmaincombx_prttype->count() - 1);
ui->newmaincombx_prttype->setCurrentIndex(ui->newmaincombx_prttype->count() - 1);
}
}
void NewMainForm::on_newmaincombx_name_currentIndexChanged(int index)
{
ui->newmainline_name->setText(ui->newmaincombx_name->currentText());
}
void NewMainForm::on_newmainvtn_ordersave_clicked()
{
int autoconf = 0;
if(ui->newmainrdbtn_auto->isChecked())
autoconf = 1;
NewMainFormDataProcess::SetOrderConfig(QString::number(autoconf), QString::number((ui->newmaincombx_del->currentIndex() + 1)*12));
}
void NewMainForm::on_newmainbtn_down_clicked()
{
int num = ui->newmaintablewidget_order->height()/36;
int page = _curr_page_num/(num - 1) ;
if(_curr_page_num%(num - 1) != 0)
++ page;
if(_curr_page < page)
{
if(_curr_page == page - 1 && _curr_page_num%(num - 1) != 0)
{
ui->newmaintablewidget_order->viewport()->setFixedHeight(_curr_page_num%(num - 1) * 36);
}
ui->newmaintablewidget_order->verticalScrollBar()->setValue(_curr_page*(num - 1));
++ _curr_page;
ui->newmainlabel_page->setText(QString::number(_curr_page)+ "/" + QString::number(page));
}
}
void NewMainForm::on_newmainbtn_up_clicked()
{
int num = ui->newmaintablewidget_order->height()/36;
int page = _curr_page_num/(num - 1) ;
if(_curr_page_num%(num - 1) != 0)
++ page;
if(_curr_page > 1)
{
-- _curr_page;
ui->newmainlabel_page->setText(QString::number(_curr_page)+ "/" + QString::number(page));
ui->newmaintablewidget_order->verticalScrollBar()->setValue((_curr_page - 1)*(num - 1));
ui->newmaintablewidget_order->viewport()->setFixedHeight((num - 1) * 36);
}
}
void NewMainForm::on_newmainbtn_close_clicked()
{
FMApplication::exit(0);
}
void NewMainForm::on_newmainbtn_jump_clicked()
{
int num = ui->newmaintablewidget_order->height()/36;
int page = ui->newmainline_page->text().toInt();
int tmppage = _curr_page_num/(num - 1) ;
if(_curr_page_num%(num - 1) != 0)
++ tmppage;
if(page > 0 && page <= tmppage && page != _curr_page)
{
if(page == tmppage && _curr_page_num%(num - 1) != 0)
{
ui->newmaintablewidget_order->viewport()->setFixedHeight(_curr_page_num%(num - 1) * 36);
}
else
{
ui->newmaintablewidget_order->viewport()->setFixedHeight((num - 1) * 36);
}
_curr_page = page;
ui->newmaintablewidget_order->verticalScrollBar()->setValue((_curr_page-1)*(num - 1));
ui->newmainlabel_page->setText(QString::number(_curr_page)+ "/" + QString::number(tmppage));
}
}
#ifndef NEWMAINFORM_H
#define NEWMAINFORM_H
#include <QApplication>
#include <QWidget>
#include <QPushButton>
#include <QSettings>
#include <QSet>
#include <QString>
#include <QMap>
#include <QVector>
#include <QVariantMap>
#include "preDefine.h"
#include "model/posorderpool.h"
#include "view/mainbtn.h"
#define MAIN_ORDER "order"
#define MAIN_REFUND "refund"
#define MAIN_SET "set"
#define SET_PRT_DV "dv"
#define SET_PRT_COM "com"
#define SET_PRT_LPT "lpt"
#define SET_PRT_NET "net"
#define ORDER_TYPE_AUTO "auto"
#define ORDER_TYPE_SELF "self"
#define ORDER_TYPE_TIMEOUT "timeout"
#define TYPE_NEEDREFUND 0
#define TYPE_REFUNDED 1
#define TYPE_ALL 2
#define TYPE_NEW 3
#define TYPE_MAKE 4
#define TYPE_SEND 5
#define TYPE_NAKEOVER 6
#define TYPE_OVER 7
#define TYPE_FUTURE 8
typedef struct
{
int order_status;
int refund_status;
} Order_Index;
namespace Ui {
class NewMainForm;
}
class NewMainForm : public QWidget
{
Q_OBJECT
public:
explicit NewMainForm(QWidget *parent = 0);
~NewMainForm();
bool event(QEvent *e);
void FullShow();
private slots:
void on_newmainbtn_clicked();
void on_classifybtn_clicked();
void on_PrtSet_toggled(bool checked);
void on_newmaincombx_prttype_currentIndexChanged(int index);
void on_newmaintbwgt_tabBarClicked(int index);
void on_newmainbtn_prtsave_clicked();
void on_newmainbtn_prtadd_clicked();
void on_newmainbtn_prtdel_clicked();
void on_newmaincombx_name_currentIndexChanged(int index);
void on_newmainvtn_ordersave_clicked();
void on_newmainbtn_down_clicked();
void on_newmainbtn_up_clicked();
void on_newmainbtn_close_clicked();
void on_newmainbtn_jump_clicked();
private:
Ui::NewMainForm *ui;
//
QSet<MainBtn *> _main_btn;
//打印界面集合
QSet<QWidget *> _prtsetting_widget;
//分类器集合
QSet<QPushButton *> _classify_set;
//选中的分类
QPushButton * _curr_check_btn;
//后厨打印配置容器
QVector< QMap< QString, QString > > _other_prt_configs;
//小票打印机配置
QMap<QString,QString> _main_prt_configs;
//杯贴打印机配置
QMap<QString,QString> _label_prt_configs;
//其他打印机数量
int _other_prt_num;
//订单索引
QMap<QString, Order_Index> _order_indexs;
//
QVariantMap _storeinfo;
//当前总页数
int _curr_page_num;
//当前页数
int _curr_page;
private:
void InitOrderWidget(QString type);
void InitSetWidget();
void InitWidget(QString type);
void InitClassify();
void SetChecked(QPushButton *btn);
void UpdateTableWidget(OrderObject &orderObject);
void DeleteTableWidget(QString orderid);
//初始化设置界面
void InitSettingWidget(QString type);
//初始化订单界面
void InitOrderSetting();
//初始化打印机界面
void InitPrtSetting();
//初始化用户设置界面
void InitUserSetting();
void InitPrtSettingWidget();
void LoadMainPrtSetting();
void InitPrtConfig();
void LoadLabelPrtSetting();
void SettingWidgetWithConf(int index, QMap<QString, QString> &map);
void LoadOtherPrtSetting(int index);
void InitPrtList();
void ShowSetErrorMsg(QString str);
bool GetMapAndSaveSet(int index, QMap<QString, QString> &map);
void InsertTableWidget(OrderObject &orderObject);
void GetOrderStatus(OrderObject &order, int &order_status);
void InitTableWidget();
bool ClassifyOrder(QString type);
void ClassifyOrderWithOrderStatus(int order_status);
void InitPageNum();
void InitMainBtn();
void SetMainBtnCheck(MainBtn *wgt);
void ClassifyOrderWithOrderType();
};
class NewMainFormDataProcess
{
public:
friend class NewMainForm;
static bool GetOrderInde(OrderObject &order, Order_Index &order_index)
{
order_index.order_status = order.status;
order_index.refund_status = order.refund_status;
}
private:
static void SetOrderConfig(QString autoconf, QString timeout)
{
QString path = QString("%1/config.ini").arg(qApp->applicationDirPath());
QSettings config(path, QSettings::IniFormat);
config.setValue(INI_AUTOCONFIRM, autoconf);
config.setValue(INI_DELEORDERTIMER, timeout);
}
static void SetOtherPrintNum(int prt_num)
{
QString path = QString("%1/needprt.ini").arg(qApp->applicationDirPath());
QSettings config(path, QSettings::IniFormat);
config.setValue("all/needothernum", prt_num);
}
static void SetPrintIniWithInde(int index, QMap<QString, QString> &map)
{
QString section = "Printer";
QString comsection = "COMDEF";
if(index == 2)
{
section = "OtherPrinter";
comsection = "OTHERCOMDEF";
}
if(index > 2)
{
section = QString("OtherPrinter") + QString::number(index - 2 + 1);
comsection = QString("OTHERCOMDEF") + QString::number(index - 2 + 1);
}
SetPrintIni(section, comsection, map);
}
static void GetPrintIniWithInde(int index, QMap<QString, QString> &map)
{
QString section = "Printer";
QString comsection = "COMDEF";
if(index == 2)
{
section = "OtherPrinter";
comsection = "OTHERCOMDEF";
}
if(index > 2)
{
section = QString("OtherPrinter") + QString::number(index - 2 + 1);
comsection = QString("OTHERCOMDEF") + QString::number(index - 2 + 1);
}
GetPrintIni(section, comsection, map);
}
static void SetPrintIni(QString section, QString comsection, QMap<QString, QString> &map)
{
QString path = QString("%1/printer.ini").arg(qApp->applicationDirPath());
QSettings config(path, QSettings::IniFormat);
QMap<QString, QString>::iterator it;
for (it = map.begin();it != map.end(); ++it)
{
if(map["type"].compare("0") == 0 || it.key().compare("type",Qt::CaseInsensitive) != 0)
config.setValue(QString(comsection) + "/" + it.key(), it.value());
config.setValue(QString(section) + "/" + it.key(), it.value());
}
}
static void GetPrintIni(QString section, QString comsection, QMap<QString, QString> &map)
{
QString path = QString("%1/printer.ini").arg(qApp->applicationDirPath());
QSettings config(path, QSettings::IniFormat);
if(!config.value(section+"/Name").toString().isEmpty())
map.insert("Name",config.value(section+"/Name").toString());
if(!config.value(section+"/printType").toString().isEmpty())
map.insert("printType",config.value(section+"/printType").toString());
if(!config.value(section+"/PaperWidth").toString().isEmpty())
map.insert("PaperWidth",config.value(section+"/PaperWidth").toString());
// if(!config.value(section+"/levlel").toString().isEmpty())
// map.insert(section+"/levlel",config.value(section+"/levlel").toString());
if(!config.value(section+"/parallel").toString().isEmpty())
map.insert("parallel",config.value(section+"/parallel").toString());
if(!config.value(section+"/type").toString().isEmpty())
map.insert("type",config.value(section+"/type").toString());
if(!config.value(section+"/usb").toString().isEmpty())
map.insert("usb",config.value(section+"/usb").toString());
if(!config.value(section+"/IP").toString().isEmpty())
map.insert("IP",config.value(section+"/IP").toString());
if(!config.value(section+"/Printlabel").toString().isEmpty())
map.insert("Printlabel",config.value(section+"/Printlabel").toString());
// if(!config.value(section+"/LogDays").toString().isEmpty())
// map.insert(section+"/LogDays",config.value(section+"/LogDays").toString());
if(!config.value(section+"/wigth").toString().isEmpty())
map.insert("wigth",config.value(section+"/wigth").toString());
if(!config.value(section+"/high").toString().isEmpty())
map.insert("high",config.value(section+"/high").toString());
// if(!config.value(section+"/speed").toString().isEmpty())
// map.insert(section+"/speed",config.value(section+"/speed").toString());
// if(!config.value(section+"/crow").toString().isEmpty())
// map.insert(section+"/crow",config.value(section+"/crow").toString());
if(!config.value(section+"/labeltype").toString().isEmpty())
map.insert("labeltype",config.value(section+"/labeltype").toString());
if(!config.value(section+"/labelparall").toString().isEmpty())
map.insert("labelparall",config.value(section+"/labelparall").toString());
if(!config.value(section+"/labelusb").toString().isEmpty())
map.insert("labelusb",config.value(section+"/labelusb").toString());
if(!config.value(section+"/labelip").toString().isEmpty())
map.insert("labelip",config.value(section+"/labelip").toString());
if(!config.value(section+"/labelprttype").toString().isEmpty())
map.insert("labelprttype",config.value(section+"/labelprttype").toString());
//-----------------------------------------------------------------------------------
if(!config.value(comsection+"/com").toString().isEmpty())
map.insert("com", config.value(comsection+"/com").toString());
if(!config.value(comsection+"/Baudrate").toString().isEmpty())
map.insert("Baudrate", config.value(comsection+"/Baudrate").toString());
if(!config.value(comsection+"/DataBits").toString().isEmpty())
map.insert("DataBits",config.value(comsection+"/DataBits").toString());
if(!config.value(comsection+"/StopBits").toString().isEmpty())
map.insert("StopBits",config.value(comsection+"/StopBits").toString());
if(!config.value(comsection+"/Parity").toString().isEmpty())
map.insert("Parity",config.value(comsection+"/Parity").toString());
if(!config.value(comsection+"/FlowControl").toString().isEmpty())
map.insert("FlowControl",config.value(comsection+"/FlowControl").toString());
}
};
#endif // NEWMAINFORM_H
This source diff could not be displayed because it is too large. You can view the blob instead.
#include "orderoptform.h"
#include "ui_orderoptform.h"
OrderOptForm::OrderOptForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::OrderOptForm)
{
ui->setupUi(this);
}
OrderOptForm::~OrderOptForm()
{
delete ui;
}
#ifndef ORDEROPTFORM_H
#define ORDEROPTFORM_H
#include <QWidget>
namespace Ui {
class OrderOptForm;
}
class OrderOptForm : public QWidget
{
Q_OBJECT
public:
explicit OrderOptForm(QWidget *parent = 0);
~OrderOptForm();
private:
Ui::OrderOptForm *ui;
};
#endif // ORDEROPTFORM_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OrderOptForm</class>
<widget class="QWidget" name="OrderOptForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>114</width>
<height>26</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">#OrderOptForm
{
background-color: rgb(255, 255, 255);
}
#btn_orderinfo
{
width:48px;
height:20px;
border:1px solid rgba(230,230,230,1);
border-radius:4px;
}
#btn_orderopt
{
width:48px;
height:20px;
background:rgba(25,166,119,1);
border:1px solid rgba(25,166,119,1);
border-radius:4px;
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_orderopt">
<property name="minimumSize">
<size>
<width>50</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>完成</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>2</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_orderinfo">
<property name="minimumSize">
<size>
<width>50</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>22</height>
</size>
</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>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "ordertypeform.h"
#include "ui_ordertypeform.h"
OrderTypeForm::OrderTypeForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::OrderTypeForm)
{
ui->setupUi(this);
_order_id = "";
_order_status = DefaultOrder;
_refund_status = DefaultOrder;
_order_type = DefaultOrderType;
}
OrderTypeForm::~OrderTypeForm()
{
delete ui;
}
void OrderTypeForm::InitShow(QString order_id, int order_status, int refund_status, int order_type)
{
_order_id = order_id;
_order_status = order_status;
_refund_status = refund_status;
_order_type = order_type;
if(_order_type == AppointmentTakeout || _order_type == AppointmentDining || _order_type == AppointmentInvite)
{
ui->ordertypelabel_type->setStyleSheet("#ordertypelabel_type{ border-image: url(:yy.png)}");
}
int ordertype = GetOrderStatus();
SetNameStyle(ordertype);
}
void OrderTypeForm::SetNameStyle(int status)
{
switch (status) {
case NewOrder:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE6\x96\xB0\xE8\xAE\xA2\xE5\x8D\x95"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(236,67,56,1);border-radius:4px;color:rgba(236,67,56,1);}");
break;
case FirmOrder:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE5\x88\xB6\xE4\xBD\x9C\xE4\xB8\xAD"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(25,166,119,1);border-radius:4px;color:rgba(25,166,119,1);}");
break;
case CancelOrder:
case CompleteRefundOrder:
case ApprovalRefundOrder:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE5\xB7\xB2\xE9\x80\x80\xE5\x8D\x95"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(170,170,170,1);border-radius:4px;color:rgba(170,170,170,1);}");
break;
case DispatchingOrder:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE9\x85\x8D\xE9\x80\x81\xE4\xB8\xAD"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(25,108,166,1);border-radius:4px;color:rgba(25,108,166,1);}");
break;
case InDevelopment:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE5\xAE\x8C\xE6\x88\x90\xE4\xB8\xAD"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(25,108,166,1);border-radius:4px;color:rgba(25,108,166,1);}");
break;
case ApplicationRefundOrder:
case ApplicationPartialRefundOrder:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE9\x9C\x80\xE9\x80\x80\xE5\x8D\x95"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(236,67,56,1);border-radius:4px;color:rgba(236,67,56,1);}");
break;
case CompleteOrder:
case ServiceOrder:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE5\xB7\xB2\xE5\xAE\x8C\xE6\x88\x90"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(170,170,170,1);border-radius:4px;color:rgba(170,170,170,1);}");
break;
default:
ui->ordertypelabel_name->setText(QString::fromUtf8("\xE6\x97\xA0\xE6\x95\x88\xE5\x8D\x95"));
ui->ordertypelabel_name->setStyleSheet("#ordertypelabel_name{border:1px solid rgba(170,170,170,1);border-radius:4px;color:rgba(170,170,170,1);}");
break;
}
}
void OrderTypeForm::on_orderstatus_changed(int order_status, int refund_status)
{
}
int OrderTypeForm::order_type() const
{
return _order_type;
}
int OrderTypeForm::refund_status() const
{
return _refund_status;
}
int OrderTypeForm::GetOrderStatus() const
{
if(_refund_status == ApplicationRefundOrder ||
_refund_status == ApplicationPartialRefundOrder ||
_refund_status == CompleteRefundOrder ||
_refund_status == ApprovalRefundOrder)
return _refund_status;
else
return _order_status;
}
int OrderTypeForm::order_status() const
{
return _order_status;
}
QString OrderTypeForm::order_id() const
{
return _order_id;
}
#ifndef ORDERTYPEFORM_H
#define ORDERTYPEFORM_H
#include <QWidget>
#include "model/posorderpool.h"
namespace Ui {
class OrderTypeForm;
}
class OrderTypeForm : public QWidget
{
Q_OBJECT
public:
explicit OrderTypeForm(QWidget *parent = 0);
~OrderTypeForm();
void InitShow(QString order_id, int order_status, int refund_status, int order_type);
QString order_id() const;
int order_status() const;
int refund_status() const;
int GetOrderStatus() const;
int order_type() const;
void SetNameStyle(int status);
public slots:
void on_orderstatus_changed(int order_status, int refund_status);
private:
Ui::OrderTypeForm *ui;
QString _order_id;
int _order_status;
int _refund_status;
int _order_type;
};
#endif // ORDERTYPEFORM_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OrderTypeForm</class>
<widget class="QWidget" name="OrderTypeForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>74</width>
<height>28</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">#ordertypelabel_name
{
font: 10pt &quot;微软雅黑&quot;;
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,3,0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="ordertypelabel_name">
<property name="minimumSize">
<size>
<width>48</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>新订单</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>2</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="ordertypelabel_type">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<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>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment