Commit 7402871c by 戴尚尚

增加菜品管理

parent 9a008913
#include "flowControl.h" #include "flowControl.h"
#include "fmPlugin.h" #include "fmPlugin.h"
#include "fmPrinter.h" #include "fmPrinter.h"
#include "QsLog.h" #include "QsLog.h"
...@@ -24,6 +24,7 @@ FlowControl::FlowControl() ...@@ -24,6 +24,7 @@ FlowControl::FlowControl()
m_loginSocket = NULL; m_loginSocket = NULL;
m_pullOrderSocket = NULL; m_pullOrderSocket = NULL;
m_procOrderSocket = NULL; m_procOrderSocket = NULL;
m_pullDishesSocket = NULL;
netErrorIndex = 0; netErrorIndex = 0;
QTimer::singleShot(10000,this, &FlowControl::_PostBill); QTimer::singleShot(10000,this, &FlowControl::_PostBill);
...@@ -807,6 +808,7 @@ void FlowControl::onFlowStart() ...@@ -807,6 +808,7 @@ void FlowControl::onFlowStart()
m_pullOrderSocket = new BillSocket(this); m_pullOrderSocket = new BillSocket(this);
m_procOrderSocket = new BillSocket(this); m_procOrderSocket = new BillSocket(this);
m_syncStockSocket = new BillSocket(this); m_syncStockSocket = new BillSocket(this);
m_pullDishesSocket = new BillSocket(this);
if(_GetStoreInfo()) if(_GetStoreInfo())
{ {
...@@ -991,3 +993,149 @@ void FlowControl::onRefund(const QString &orderId, const QString &reason) ...@@ -991,3 +993,149 @@ void FlowControl::onRefund(const QString &orderId, const QString &reason)
{ {
_RefundOrder(orderId,reason); _RefundOrder(orderId,reason);
} }
void FlowControl::onPullDishes()
{
QString error;
bool result;
QJsonObject sendJson;
QJsonObject recvJson;
m_dishesMap.clear();
sendJson = DataManger::GetInstance().GetStoreChannelInfoData();
emit showAlert(AlertForm::LOADING, "正在获取平台列表......");
QLOG_INFO() << QString("[---GetStoreChannelInfo---]. [requestData:%1]").arg(_GetJsonStr(sendJson));
result = m_pullDishesSocket->Request(sendJson, recvJson, error);
QLOG_INFO() << QString("GetStoreChannelInfo finsh. [result:%1][msg:%2][recvData:%3]")
.arg(result).arg(error, _GetJsonStr(recvJson));
if(!result)
{
emit showAlert(AlertForm::ERROR, "获取平台列表失败![网络错误]");
}else
{
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
{
emit showAlert(AlertForm::ERROR, QString("获取平台列表失败![%1]").arg(recvJson[JSON_MESSAGE].toString()));
}else
{
// 分别获取每个平台的菜品信息
QJsonArray jaChannels = recvJson[JSON_SHOPSTATUS].toArray();
foreach(QJsonValue v, jaChannels)
{
QJsonObject channel = v.toObject();
QString channelName = channel["name"].toString();
QString channelCode = channel["code"].toString();
sendJson = DataManger::GetInstance().GetPullDishesData(channelCode, m_storeId);
emit showAlert(AlertForm::LOADING, QString("正在获取[%1]菜品信息......").arg(channelName));
QLOG_INFO() << QString("[---pullDishes %1---]. [requestData:%2]").arg(channelName, _GetJsonStr(sendJson));
result = m_pullDishesSocket->Request(sendJson, recvJson, error);
QLOG_INFO() << QString("pullDishes finsh. [result:%1][msg:%2][recvData:%3]")
.arg(result).arg(error, _GetJsonStr(recvJson));
if(!result)
{
emit showAlert(AlertForm::ERROR, QString("获取[%1]菜品信息失败![网络超时]").arg(channelName));
break;
}else
{
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
{
//result = false;
//emit showAlert(AlertForm::ERROR, QString("获取[%1]菜品信息失败![%2]").arg(channelName, recvJson[JSON_MESSAGE].toString()));
//break;
}else
{
QJsonArray categoriesJA =recvJson["categories"].toArray();
foreach(QJsonValue jv, categoriesJA)
{
QJsonObject jo = jv.toObject();
QString categoryName = jo["name"].toString();
QJsonArray dishesJA = jo["dishes"].toArray();
foreach(QJsonValue jv1, dishesJA)
{
QJsonObject jo1 = jv1.toObject();
dishesObject dishesObj;
dishesObj.FetchDataFromJson(jo1);
QMap<QString, dishesObject> tmpMap;
if( m_dishesMap.contains(categoryName) )
{
if( m_dishesMap.value(categoryName).contains(dishesObj.name) )
{
dishesObject tmpObj = m_dishesMap.value(categoryName).value(dishesObj.name);
tmpObj.channelCode_status.insert(channelName+":"+channelCode+":"+dishesObj.code, dishesObj.status);
tmpMap = m_dishesMap.value(categoryName);
tmpMap.insert(dishesObj.name, tmpObj);
}else
{
dishesObj.channelCode_status.insert(channelName+":"+channelCode+":"+dishesObj.code, dishesObj.status);
tmpMap = m_dishesMap.value(categoryName);
tmpMap.insert(dishesObj.name, dishesObj);
}
}else
{
dishesObj.channelCode_status.insert(channelName+":"+channelCode+":"+dishesObj.code, dishesObj.status);
tmpMap.insert(dishesObj.name, dishesObj);
}
m_dishesMap.insert(categoryName, tmpMap);
}
}
}
}
}
if(!m_dishesMap.isEmpty())
{
emit hideAlert();
// 通知界面显示
emit iniDishesData(m_dishesMap);
}else
{
emit showAlert(AlertForm::ERROR, QString("未获取到菜品信息!"));
}
}
}
}
void FlowControl::onUpdDishes(QStringList channelCode, QString disheId, int status)
{
QString error;
bool result = true;
QJsonObject sendJson;
QJsonObject recvJson;
emit showAlert(AlertForm::LOADING, "正在同步菜品销售状态......");
foreach (QString channel, channelCode) {
sendJson = DataManger::GetInstance().GetUpdDishesData(channel.split(":").at(1), channel.split(":").at(2), status, m_storeId);
QLOG_INFO() << QString("[---update dishes---]. [requestData:%1]").arg(_GetJsonStr(sendJson));
result = m_pullDishesSocket->Request(sendJson, recvJson, error);
QLOG_INFO() << QString("update dishes finsh. [result:%1][msg:%2][recvData:%3]")
.arg(result).arg(error, _GetJsonStr(recvJson));
if(!result)
{
result = false;
emit showAlert(AlertForm::ERROR, "同步菜品销售状态失败![网络错误]");
break;
}else
{
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
{
result = false;
emit showAlert(AlertForm::ERROR, QString("同步菜品销售状态失败![%1]").arg(recvJson[JSON_MESSAGE].toString()));
break;
}
}
}
if(result )
{
emit hideAlert();
emit processDishiesSuccssful(channelCode, disheId, status);
}
}
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "Model/orderObject.h" #include "Model/orderObject.h"
#include "Model/deliverObject.h" #include "Model/deliverObject.h"
#include "Model/cashierObject.h" #include "Model/cashierObject.h"
#include "Model/dishesObject.h"
#include "alertForm.h" #include "alertForm.h"
#include <QMap> #include <QMap>
#include <QMutex> #include <QMutex>
...@@ -39,6 +40,7 @@ private: ...@@ -39,6 +40,7 @@ private:
BillSocket *m_pullOrderSocket; BillSocket *m_pullOrderSocket;
BillSocket *m_procOrderSocket; BillSocket *m_procOrderSocket;
BillSocket *m_syncStockSocket; BillSocket *m_syncStockSocket;
BillSocket *m_pullDishesSocket;
// 拉取订单的时间戳 // 拉取订单的时间戳
QString m_timestamp; QString m_timestamp;
// 订单容器 // 订单容器
...@@ -46,6 +48,8 @@ private: ...@@ -46,6 +48,8 @@ private:
// 当前收银员 // 当前收银员
CashierObject m_cashierObject; CashierObject m_cashierObject;
// 所有菜品信息<分类, <菜品ID, 具体菜品> >
QMap<QString, QMap<QString, dishesObject> > m_dishesMap;
// viewId _ orderId // viewId _ orderId
QMap<QString, QString> m_view2Id; QMap<QString, QString> m_view2Id;
...@@ -115,6 +119,12 @@ signals: ...@@ -115,6 +119,12 @@ signals:
void stopNetErrorRemind(); void stopNetErrorRemind();
void startRemind(int type); void startRemind(int type);
// 通知菜品管理界面初始化菜品信息
void iniDishesData(QMap<QString, QMap<QString, dishesObject> >);
// 通知菜品管理界面操作成功刷新界面 [1]平台 [2]菜品ID [3]状态
void processDishiesSuccssful(QStringList, QString, int);
private slots: private slots:
/* 功能:获取门店信息 /* 功能:获取门店信息
* 参数:NULL * 参数:NULL
...@@ -241,6 +251,17 @@ public slots: ...@@ -241,6 +251,17 @@ public slots:
* */ * */
void onSerachOrder(const QString& text); void onSerachOrder(const QString& text);
void onRefund(const QString& orderId, const QString& reason); void onRefund(const QString& orderId, const QString& reason);
/* 功能:获取菜品信息
* 参数:NULL
* 返回:NULL
* */
void onPullDishes();
/* 功能:获取菜品信息
* 参数:NULL
* 返回:NULL
* */
void onUpdDishes(QStringList channelCode, QString disheId, int status);
}; };
#endif // FLOWCONTROL_H #endif // FLOWCONTROL_H
...@@ -8,7 +8,9 @@ enum ...@@ -8,7 +8,9 @@ enum
REFUSE_ORDER,COMPLETE_ORDER = 16, REFUSE_ORDER,COMPLETE_ORDER = 16,
REFUSE_REFUND = 18,SEND_ORDER = 19, REFUSE_REFUND = 18,SEND_ORDER = 19,
REFUND_ORDER = 20, GET_DELIVER=21, REFUND_ORDER = 20, GET_DELIVER=21,
REPORT_BILL_RESULT = 23,CHARGEOFF_ORDER=71, REPORT_BILL_RESULT = 23,
PULL_DISHES = 24, UPD_DISHES_STATUS = 25,
GET_STORE_CHANNEL_INFO = 28,SET_STORE_OPERATING_STATUS = 29,CHARGEOFF_ORDER=71,
UPDATE_STOCK=80 UPDATE_STOCK=80
}; };
...@@ -189,3 +191,39 @@ QJsonObject DataManger::GetPullSingleOrder(const QString &orderId) ...@@ -189,3 +191,39 @@ QJsonObject DataManger::GetPullSingleOrder(const QString &orderId)
return rObj; return rObj;
} }
QJsonObject DataManger::GetPullDishesData(const QString &channelCode, QString storeId)
{
QJsonObject rObj;
rObj.insert(JSON_REQTYPE, PULL_DISHES);
rObj.insert(JSON_CHANNEL, channelCode);
rObj.insert(JSON_TOKEN, m_token);
return rObj;
}
QJsonObject DataManger::GetUpdDishesData(QString channelCode, QString disheId, int status, QString storeId)
{
QJsonObject rObj;
QJsonArray dishes;
QJsonObject cObj;
cObj.insert("code", disheId);
cObj.insert("status", status);
dishes.append(cObj);
rObj.insert(JSON_REQTYPE, UPD_DISHES_STATUS);
rObj.insert(JSON_CHANNEL, channelCode);
rObj.insert("dishes", dishes);
rObj.insert(JSON_TOKEN, m_token);
return rObj;
}
QJsonObject DataManger::GetStoreChannelInfoData()
{
QJsonObject rObj;
rObj.insert(JSON_REQTYPE, GET_STORE_CHANNEL_INFO);
rObj.insert(JSON_TOKEN, m_token);
return rObj;
}
...@@ -86,6 +86,24 @@ public: ...@@ -86,6 +86,24 @@ public:
* */ * */
QJsonObject GetPullSingleOrder(const QString& orderId); QJsonObject GetPullSingleOrder(const QString& orderId);
/* 功能:获取拉取菜品信息数据
* 参数:[1]时间戳
* 返回:登录数据
* */
QJsonObject GetPullDishesData(const QString &channelCode, QString storeId="");
/* 功能:获取更新菜品信息数据
* 参数:[1]时间戳
* 返回:登录数据
* */
QJsonObject GetUpdDishesData(QString channelCode, QString disheId, int status, QString storeId="");
/* 功能:获取门店平台信息数据
* 参数:NULL
* 返回:数据
* */
QJsonObject GetStoreChannelInfoData();
private: private:
DataManger(){} DataManger(){}
DataManger(DataManger const&); DataManger(DataManger const&);
......
#include "dishesObject.h"
#ifndef DISHESOBJECT_H
#define DISHESOBJECT_H
#include <QObject>
#include "baseObject.h"
class dishesObject : public BaseObject
{
Q_OBJECT
public:
explicit dishesObject(QObject *parent = 0):
BaseObject(parent){}
public:
Q_PROPERTY (QString code READ getcode WRITE setcode)
Q_PROPERTY (QString name READ getname WRITE setname)
Q_PROPERTY (int status READ getstatus WRITE setstatus)
Q_PROPERTY (QString pic READ getpic WRITE setpic)
Q_PROPERTY (int price READ getprice WRITE setprice)
Q_PROPERTY (QString unit READ getunit WRITE setunit)
Q_PROPERTY (int rank READ getrank WRITE setrank)
Q_PROPERTY (QString description READ getdescription WRITE setdescription)
QString code;
QString name;
int status;
QString pic;
int price;
QString unit;
int rank;
QString description;
// 自定义属性
QMap<QString, int> channelCode_status; // 所属平台及上下架状态
protected:
inline QString getcode(){ return code; }
inline void setcode(const QString& v){ code=v; }
inline QString getname(){ return name; }
inline void setname(const QString& v){ name=v; }
inline int getstatus(){ return status; }
inline void setstatus(const int& v){ status=v; }
inline QString getpic(){ return pic; }
inline void setpic(const QString& v){ pic=v; }
inline int getprice(){ return price; }
inline void setprice(const int& v){ price=v; }
inline QString getunit(){ return unit; }
inline void setunit(const QString& v){ unit=v; }
inline int getrank(){ return rank; }
inline void setrank(const int& v){ rank=v; }
inline QString getdescription(){ return description; }
inline void setdescription(const QString& v){ description=v; }
};
#endif // DISHESOBJECT_H
#include "disTabWdg.h"
#include "ui_disTabWdg.h"
#include "Control/flowControl.h"
#include <QScrollBar>
#include <QMapIterator>
disTabWdg::disTabWdg(QWidget *parent) :
QDialog(parent),
ui(new Ui::disTabWdg)
{
ui->setupUi(this);
ui->disTabWdg_btnsj->hide();
ui->disTabWdg_btnxj->hide();
}
disTabWdg::~disTabWdg()
{
delete ui;
}
void disTabWdg::IniDishesData(QMap<QString, dishesObject> dishesMap)
{
int index = 0;
foreach(dishesObject dObj, dishesMap.values())
{
dishesItem *item = new dishesItem(dObj, this);
int row;
if(index==0)
{
row = ui->disTabWdg_tablewdg->rowCount();
ui->disTabWdg_tablewdg->insertRow(row);
}
ui->disTabWdg_tablewdg->setCellWidget(row, index, item);
index++;
if(index==2)
{
index=0;
}
}
}
void disTabWdg::on_disTabWdg_close_clicked()
{
emit doHide();
}
void disTabWdg::on_disTabWdg_btnup_clicked()
{
ui->disTabWdg_tablewdg->verticalScrollBar()->setValue(ui->disTabWdg_tablewdg->verticalScrollBar()->value()-15);
}
void disTabWdg::on_disTabWdg_btndown_clicked()
{
ui->disTabWdg_tablewdg->verticalScrollBar()->setValue(ui->disTabWdg_tablewdg->verticalScrollBar()->value()+15);
}
void disTabWdg::on_disTabWdg_btnsj_clicked()
{
// QMap<QString, int> map;
// foreach(dishesObject obj, m_disObjList)
// {
// map.insert(obj.code, 1);
// }
// emit doUpdDishes(m_channelCode, map);
}
void disTabWdg::on_disTabWdg_btnxj_clicked()
{
// QMap<QString, int> map;
// foreach(dishesObject obj, m_disObjList)
// {
// map.insert(obj.code, 0);
// }
// emit doUpdDishes(m_channelCode, map);
}
#ifndef DISTABWDG_H
#define DISTABWDG_H
#include <QDialog>
#include "Model/dishesObject.h"
#include "dishesItem.h"
namespace Ui {
class disTabWdg;
}
class disTabWdg : public QDialog
{
Q_OBJECT
public:
explicit disTabWdg(QWidget *parent = 0);
~disTabWdg();
// 初始化菜品信息
void IniDishesData(QMap<QString, dishesObject> dishesMap);
private slots:
void on_disTabWdg_close_clicked();
void on_disTabWdg_btnup_clicked();
void on_disTabWdg_btndown_clicked();
void on_disTabWdg_btnsj_clicked();
void on_disTabWdg_btnxj_clicked();
private:
Ui::disTabWdg *ui;
QString m_channelCode;
signals:
void doHide();
// 通知工作线程更新上下架状态
void doUpdDishes(QString ,QMap<QString, int> dishes);
};
#endif // DISTABWDG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>disTabWdg</class>
<widget class="QDialog" name="disTabWdg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>520</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<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="disTabWdg_wdg" native="true">
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QTableWidget" name="disTabWdg_tablewdg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>431</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="autoScroll">
<bool>false</bool>
</property>
<property name="autoScrollMargin">
<number>1</number>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="gridStyle">
<enum>Qt::NoPen</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<property name="rowCount">
<number>0</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>380</number>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>30</number>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize">
<number>70</number>
</attribute>
<column>
<property name="text">
<string>Item1</string>
</property>
</column>
<column>
<property name="text">
<string>Item2</string>
</property>
</column>
</widget>
<widget class="QPushButton" name="disTabWdg_btnxj">
<property name="geometry">
<rect>
<x>562</x>
<y>455</y>
<width>85</width>
<height>42</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="text">
<string>全部下架</string>
</property>
</widget>
<widget class="QPushButton" name="disTabWdg_btnup">
<property name="geometry">
<rect>
<x>313</x>
<y>460</y>
<width>34</width>
<height>34</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="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="disTabWdg_btnsj">
<property name="geometry">
<rect>
<x>465</x>
<y>455</y>
<width>85</width>
<height>42</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="text">
<string>全部上架</string>
</property>
</widget>
<widget class="QPushButton" name="disTabWdg_close">
<property name="geometry">
<rect>
<x>660</x>
<y>455</y>
<width>85</width>
<height>42</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="text">
<string>退出</string>
</property>
</widget>
<widget class="QPushButton" name="disTabWdg_btndown">
<property name="geometry">
<rect>
<x>379</x>
<y>460</y>
<width>34</width>
<height>34</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="text">
<string/>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "dishesForm.h"
#include "ui_dishesForm.h"
#include <QPushButton>
#include "Control/flowControl.h"
#include <QDebug>
#include <QMapIterator>
#include "disTabWdg.h"
dishesForm::dishesForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::dishesForm)
{
ui->setupUi(this);
connect(&FlowControl::GetInstance(), &FlowControl::iniDishesData, this, &dishesForm::IniDishesData);
m_pickForm = new DishesPickForm(this);
setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
this->setModal(true);
}
dishesForm::~dishesForm()
{
delete ui;
}
void dishesForm::IniDishesData(QMap<QString, QMap<QString, dishesObject> > dishesMap)
{
// 清除TabWidget中的Tab
ui->channelTabWdg->clear();
// 清除TabWidget中的Widget控件
foreach(disTabWdg *pTabWdg, m_tabWdgList)
{
delete pTabWdg;
}
m_tabWdgList.clear();
// 初始化TabWidget
// 遍历各渠道
foreach(QString categoryName, dishesMap.keys())
{
disTabWdg *pTabWdg = new disTabWdg(this);
m_tabWdgList.append(pTabWdg);
connect(pTabWdg, &disTabWdg::doHide, this, &dishesForm::hide);
pTabWdg->IniDishesData(dishesMap.value(categoryName));
ui->channelTabWdg->addTab(pTabWdg, categoryName);
}
this->show();
qDebug() << this->pos();
}
#ifndef DISHESFORM_H
#define DISHESFORM_H
#include <QDialog>
#include "Model/dishesObject.h"
#include "disTabWdg.h"
#include <dishesPickForm.h>
class QTabWidget;
namespace Ui {
class dishesForm;
}
class dishesForm : public QDialog
{
Q_OBJECT
public:
explicit dishesForm(QWidget *parent = 0);
~dishesForm();
private:
Ui::dishesForm *ui;
QList<disTabWdg*> m_tabWdgList;
DishesPickForm *m_pickForm;
public slots:
void IniDishesData(QMap<QString, QMap<QString, dishesObject> > dishesMap);
};
#endif // DISHESFORM_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>dishesForm</class>
<widget class="QDialog" name="dishesForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>菜品管理</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<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="disWdg" native="true">
<property name="maximumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>20</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTabWidget" name="channelTabWdg">
<property name="maximumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "dishesItem.h"
#include "ui_dishesItem.h"
#include <QDebug>
#include "Control/flowControl.h"
#include <dishesForm.h>
dishesItem::dishesItem(dishesObject dishesObj, QWidget *parent) :
QDialog(parent),
ui(new Ui::dishesItem)
{
ui->setupUi(this);
ui->disItemLabSku->hide();
Init(dishesObj);
setAttribute(Qt::WA_TranslucentBackground);
connect(&FlowControl::GetInstance(), &FlowControl::processDishiesSuccssful, this, &dishesItem::onUpdDishesFinsh);
m_pickForm = new DishesPickForm((QWidget*)this->parent()->parent());
}
dishesItem::~dishesItem()
{
delete ui;
}
void dishesItem::Init(dishesObject dishesObj)
{
m_dishesObj = dishesObj;
ui->disItemLabName->setText(m_dishesObj.name);
QString text;
bool bFirst = true;
foreach(QString channelNameCode, dishesObj.channelCode_status.keys())
{
if( bFirst )
{
bFirst = false;
}else
{
text.append(", ");
}
text.append(QString("<font color='%1'>%2</font>")
.arg(dishesObj.channelCode_status.value(channelNameCode) == 0? "#ff0000" : "#55aa00")
.arg(channelNameCode.split(":").at(0)) );
}
ui->disItemLabStatus->setText(text);
}
void dishesItem::on_disItemBtn_clicked()
{
m_pickForm->Init(m_dishesObj.code, m_dishesObj.channelCode_status);
m_pickForm->show();
}
void dishesItem::onUpdDishesFinsh(QStringList channels, QString dishesId, int status)
{
if(dishesId == m_dishesObj.code)
{
foreach (QString channel, channels) {
m_dishesObj.channelCode_status.insert(channel, status);
}
QString text;
bool bFirst = true;
foreach(QString channelNameCode, m_dishesObj.channelCode_status.keys())
{
if( bFirst )
{
bFirst = false;
}else
{
text.append(", ");
}
text.append(QString("<font color='%1'>%2</font>")
.arg(m_dishesObj.channelCode_status.value(channelNameCode) == 0? "#ff0000" : "#55aa00")
.arg(channelNameCode.split(":").at(0)) );
}
ui->disItemLabStatus->setText(text);
}
}
#ifndef DISHESITEM_H
#define DISHESITEM_H
#include <QDialog>
#include "Model/dishesObject.h"
#include "dishesPickForm.h"
namespace Ui {
class dishesItem;
}
class dishesItem : public QDialog
{
Q_OBJECT
public:
explicit dishesItem(dishesObject dishesObj, QWidget *parent = 0);
~dishesItem();
void Init(dishesObject dishesObj);
dishesObject m_dishesObj;
private:
Ui::dishesItem *ui;
QString m_channelCode;
DishesPickForm *m_pickForm;
signals:
// 通知工作线程更新上下架状态
void doUpdDishes(QString ,QMap<QString, int> dishes);
private slots:
void on_disItemBtn_clicked();
public slots:
void onUpdDishesFinsh(QStringList channels, QString dishesId, int status);
};
#endif // DISHESITEM_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>dishesItem</class>
<widget class="QDialog" name="dishesItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>70</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>360</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>360</width>
<height>70</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QWidget" name="disItemWdg" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>70</height>
</rect>
</property>
<widget class="QPushButton" name="disItemBtn">
<property name="geometry">
<rect>
<x>306</x>
<y>16</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>操作</string>
</property>
</widget>
<widget class="QLabel" name="disItemLabSku">
<property name="geometry">
<rect>
<x>7</x>
<y>0</y>
<width>70</width>
<height>70</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="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
<widget class="QLabel" name="disItemLabName">
<property name="geometry">
<rect>
<x>19</x>
<y>0</y>
<width>101</width>
<height>70</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="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
<widget class="QLabel" name="disItemLabStatus">
<property name="geometry">
<rect>
<x>84</x>
<y>39</y>
<width>211</width>
<height>31</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="font">
<font>
<family>微软雅黑</family>
<pointsize>6</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
#include "dishesPickForm.h"
#include "ui_dishesPickForm.h"
#include <QDebug>
#include "Control/flowControl.h"
DishesPickForm::DishesPickForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::DishesPickForm)
{
ui->setupUi(this);
setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
this->setModal(true);
connect(this, &DishesPickForm::doUpdDishes, &FlowControl::GetInstance(), &FlowControl::onUpdDishes);
}
DishesPickForm::~DishesPickForm()
{
delete ui;
}
void DishesPickForm::Init(QString dishesId, QMap<QString, int> infos)
{
m_dishesId = dishesId;
for(int i=1; i<7; i++)
{
QPushButton *btn = findChild<QPushButton*>(QString("dpfBtn_%1").arg(i));
btn->setChecked(false);
btn->setEnabled(false);
}
int index = 1;
foreach (QString channelNameCode, infos.keys()) {
QPushButton *btn = findChild<QPushButton*>(QString("dpfBtn_%1").arg(index++));
if( btn != NULL )
{
btn->setText(channelNameCode.split(":").at(0));
btn->setProperty("channelNameCode", channelNameCode);
btn->setChecked(true);
btn->setEnabled(true);
}
}
}
void DishesPickForm::on_dpfBtn_xj_clicked()
{
QStringList channels;
for(int i=1; i<7; i++)
{
QPushButton *btn = findChild<QPushButton*>(QString("dpfBtn_%1").arg(i));
if( btn->isChecked() )
{
channels.append(btn->property("channelNameCode").toString());
}
}
emit doUpdDishes(channels, m_dishesId, 0);
this->hide();
}
void DishesPickForm::on_dpfBtn_sj_clicked()
{
QStringList channels;
for(int i=1; i<7; i++)
{
QPushButton *btn = findChild<QPushButton*>(QString("dpfBtn_%1").arg(i));
if( btn->isChecked() )
{
channels.append(btn->property("channelNameCode").toString());
}
}
emit doUpdDishes(channels, m_dishesId, 1);
this->hide();
}
void DishesPickForm::on_dpfBtn_cancle_clicked()
{
this->hide();
}
#ifndef DISHESPICKFORM_H
#define DISHESPICKFORM_H
#include <QDialog>
namespace Ui {
class DishesPickForm;
}
class DishesPickForm : public QDialog
{
Q_OBJECT
public:
explicit DishesPickForm(QWidget *parent = 0);
~DishesPickForm();
void Init(QString dishesId, QMap<QString, int> infos);
private slots:
void on_dpfBtn_xj_clicked();
void on_dpfBtn_sj_clicked();
void on_dpfBtn_cancle_clicked();
private:
Ui::DishesPickForm *ui;
QString m_dishesId;
signals:
void doUpdDishes(QStringList channelCode, QString, int);
};
#endif // DISHESPICKFORM_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DishesPickForm</class>
<widget class="QDialog" name="DishesPickForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QWidget" name="dpfWdg" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>301</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QPushButton" name="dpfBtn_sj">
<property name="geometry">
<rect>
<x>52</x>
<y>240</y>
<width>91</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>上架</string>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_1">
<property name="geometry">
<rect>
<x>57</x>
<y>25</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_2">
<property name="geometry">
<rect>
<x>217</x>
<y>25</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_3">
<property name="geometry">
<rect>
<x>57</x>
<y>92</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_4">
<property name="geometry">
<rect>
<x>217</x>
<y>92</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_5">
<property name="geometry">
<rect>
<x>57</x>
<y>160</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_6">
<property name="geometry">
<rect>
<x>217</x>
<y>160</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_xj">
<property name="geometry">
<rect>
<x>160</x>
<y>240</y>
<width>91</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>下架</string>
</property>
</widget>
<widget class="QPushButton" name="dpfBtn_cancle">
<property name="geometry">
<rect>
<x>270</x>
<y>240</y>
<width>91</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
...@@ -41,7 +41,12 @@ SOURCES += main.cpp\ ...@@ -41,7 +41,12 @@ SOURCES += main.cpp\
DTools/sysTray.cpp \ DTools/sysTray.cpp \
padForm.cpp \ padForm.cpp \
refuseForm.cpp \ refuseForm.cpp \
DTools/orderstatus.cpp DTools/orderstatus.cpp \
dishesForm.cpp \
Model/dishesObject.cpp \
dishesItem.cpp \
dishesPickForm.cpp \
disTabWdg.cpp
HEADERS += \ HEADERS += \
mainForm.h \ mainForm.h \
...@@ -68,7 +73,12 @@ HEADERS += \ ...@@ -68,7 +73,12 @@ HEADERS += \
DTools/sysTray.h \ DTools/sysTray.h \
padForm.h \ padForm.h \
refuseForm.h \ refuseForm.h \
DTools/orderstatus.h DTools/orderstatus.h \
dishesForm.h \
Model/dishesObject.h \
dishesItem.h \
dishesPickForm.h \
disTabWdg.h
FORMS += mainForm.ui \ FORMS += mainForm.ui \
alertForm.ui \ alertForm.ui \
...@@ -78,7 +88,11 @@ FORMS += mainForm.ui \ ...@@ -78,7 +88,11 @@ FORMS += mainForm.ui \
floatForm.ui \ floatForm.ui \
detailForm.ui \ detailForm.ui \
padForm.ui \ padForm.ui \
refuseForm.ui refuseForm.ui \
dishesForm.ui \
dishesItem.ui \
dishesPickForm.ui \
disTabWdg.ui
RC_FILE += fmTakeaway.rc RC_FILE += fmTakeaway.rc
......
...@@ -31,6 +31,9 @@ MainForm::MainForm(QWidget *parent) : ...@@ -31,6 +31,9 @@ MainForm::MainForm(QWidget *parent) :
qRegisterMetaType< QList<CashierObject> >("QList<CashierObject>"); qRegisterMetaType< QList<CashierObject> >("QList<CashierObject>");
qRegisterMetaType<DeliverObject>("DeliverObject"); qRegisterMetaType<DeliverObject>("DeliverObject");
qRegisterMetaType< QList<DeliverObject> >("QList<DeliverObject>"); qRegisterMetaType< QList<DeliverObject> >("QList<DeliverObject>");
qRegisterMetaType<dishesObject>("dishesObject");
qRegisterMetaType< QMap< QString, QMap<QString, dishesObject> > >("QMap<QString, QMap<QString, dishesObject>>");
qRegisterMetaType<AlertForm::Type>("AlertForm::Type"); qRegisterMetaType<AlertForm::Type>("AlertForm::Type");
// 连接信号槽 // 连接信号槽
connect(&m_timeTimer, &QTimer::timeout, this, &MainForm::onSetCurrentTime); connect(&m_timeTimer, &QTimer::timeout, this, &MainForm::onSetCurrentTime);
...@@ -38,6 +41,7 @@ MainForm::MainForm(QWidget *parent) : ...@@ -38,6 +41,7 @@ MainForm::MainForm(QWidget *parent) :
connect(this, &MainForm::processOrder, &FlowControl::GetInstance(), &FlowControl::onProcessOrder); connect(this, &MainForm::processOrder, &FlowControl::GetInstance(), &FlowControl::onProcessOrder);
connect(this, &MainForm::getOnDutyCashiers, &FlowControl::GetInstance(), &FlowControl::onGetOnDutyCashiers); connect(this, &MainForm::getOnDutyCashiers, &FlowControl::GetInstance(), &FlowControl::onGetOnDutyCashiers);
connect(this, &MainForm::getOrderDetails, &FlowControl::GetInstance(), &FlowControl::onGetOrderDetails); connect(this, &MainForm::getOrderDetails, &FlowControl::GetInstance(), &FlowControl::onGetOrderDetails);
connect(this, &MainForm::PullDishes, &FlowControl::GetInstance(), &FlowControl::onPullDishes);
connect(&FlowControl::GetInstance(), &FlowControl::hideAlert, this, &MainForm::onHideAlert); connect(&FlowControl::GetInstance(), &FlowControl::hideAlert, this, &MainForm::onHideAlert);
connect(&FlowControl::GetInstance(), &FlowControl::showAlert, this, &MainForm::onShowAlert); connect(&FlowControl::GetInstance(), &FlowControl::showAlert, this, &MainForm::onShowAlert);
connect(&FlowControl::GetInstance(), &FlowControl::setOpeStatus, this, &MainForm::onSetOpeStatus); connect(&FlowControl::GetInstance(), &FlowControl::setOpeStatus, this, &MainForm::onSetOpeStatus);
...@@ -93,6 +97,8 @@ void MainForm::MyShow() ...@@ -93,6 +97,8 @@ void MainForm::MyShow()
m_resultForm->hide(); m_resultForm->hide();
connect(m_resultForm, &QListWidget::itemClicked, this, &MainForm::onSearchResultItemClicked); connect(m_resultForm, &QListWidget::itemClicked, this, &MainForm::onSearchResultItemClicked);
m_dishesForm = new dishesForm(this);
emit flowStart(); emit flowStart();
ui->mainEdtSearch->setFocus(); ui->mainEdtSearch->setFocus();
...@@ -511,3 +517,8 @@ void MainForm::onSearchResultItemClicked(QListWidgetItem *item) ...@@ -511,3 +517,8 @@ void MainForm::onSearchResultItemClicked(QListWidgetItem *item)
m_resultForm->hide(); m_resultForm->hide();
emit getOrderDetails(item->text()); emit getOrderDetails(item->text());
} }
void MainForm::on_mainBtnDc_clicked()
{
emit PullDishes();
}
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "padForm.h" #include "padForm.h"
#include <QListWidget> #include <QListWidget>
#include <QTimer> #include <QTimer>
#include "dishesForm.h"
namespace Ui { namespace Ui {
class MainForm; class MainForm;
...@@ -67,6 +68,9 @@ private: ...@@ -67,6 +68,9 @@ private:
int m_raiseIndex; int m_raiseIndex;
// 菜品管理界面
dishesForm *m_dishesForm;
// 托盘图标 // 托盘图标
SysTray m_tray; SysTray m_tray;
...@@ -132,6 +136,12 @@ signals: ...@@ -132,6 +136,12 @@ signals:
void serachOrder(QString); void serachOrder(QString);
/* 功能:获取菜品信息
* 参数:NULL
* 返回:NULL
* */
void PullDishes();
private slots: private slots:
/* 功能:初始化 /* 功能:初始化
...@@ -210,6 +220,8 @@ private slots: ...@@ -210,6 +220,8 @@ private slots:
* */ * */
void onSearchResultItemClicked(QListWidgetItem * item); void onSearchResultItemClicked(QListWidgetItem * item);
void on_mainBtnDc_clicked();
public slots: public slots:
/* 功能:隐藏通知窗口 /* 功能:隐藏通知窗口
* 参数:NULL * 参数:NULL
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_11" stretch="0,0,0,0"> <layout class="QHBoxLayout" name="horizontalLayout_11" stretch="0,0,0,0,0">
<property name="spacing"> <property name="spacing">
<number>20</number> <number>20</number>
</property> </property>
...@@ -254,6 +254,22 @@ ...@@ -254,6 +254,22 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="mainBtnDc">
<property name="minimumSize">
<size>
<width>72</width>
<height>32</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>菜品管理</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mainBtnHide"> <widget class="QPushButton" name="mainBtnHide">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
......
No preview for this file type
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