diff --git a/MagicLightAssistant.vcxproj.filters b/MagicLightAssistant.vcxproj.filters
index a72f223..76d381e 100644
--- a/MagicLightAssistant.vcxproj.filters
+++ b/MagicLightAssistant.vcxproj.filters
@@ -133,9 +133,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -456,6 +453,9 @@
Generated Files
+
+ Header Files
+
diff --git a/MagicLightAssistant.vcxproj.user b/MagicLightAssistant.vcxproj.user
index b3a60d5..d2465dd 100644
--- a/MagicLightAssistant.vcxproj.user
+++ b/MagicLightAssistant.vcxproj.user
@@ -2,9 +2,9 @@
- 2023-03-14T12:37:28.3943389Z
+ 2023-03-31T07:04:21.6303138Z
- 2023-03-14T12:37:28.4952107Z
+ 2023-03-31T07:04:21.8030684Z
\ No newline at end of file
diff --git a/activitymanagework.cpp b/activitymanagework.cpp
index c50b569..6ed427a 100644
--- a/activitymanagework.cpp
+++ b/activitymanagework.cpp
@@ -45,6 +45,8 @@ void ActivityManageWork::working()
tabModel->setHeaderData(tabModel->fieldIndex("editUid"), Qt::Horizontal, "发布者UID");
tabModel->setHeaderData(tabModel->fieldIndex("act_score"), Qt::Horizontal, "活动学时");
tabModel->select();
+ while(tabModel->canFetchMore())
+ tabModel->fetchMore(); //加载超过256的其余数据
memberTabModel->setTable("magic_activityMembers");
memberTabModel->setSort(memberTabModel->fieldIndex("actm_joinDate"), Qt::DescendingOrder);
@@ -54,6 +56,9 @@ void ActivityManageWork::working()
memberTabModel->setHeaderData(memberTabModel->fieldIndex("actm_joinDate"), Qt::Horizontal, "报名时间");
memberTabModel->setHeaderData(memberTabModel->fieldIndex("status"), Qt::Horizontal, "活动状态");
memberTabModel->select();
+ while (memberTabModel->canFetchMore())
+ memberTabModel->fetchMore(); //加载超过256的其余数据
+
if (type == 1)
updateActStatus(); //更新已报名活动状态并统计学时
emit activityManageWorkFinished(type);
@@ -86,7 +91,7 @@ void ActivityManageWork::updateActStatus()
}
memberTabModel->setFilter("actm_uid=" + uid);
- qDebug() << "当前待新增的总学时:" + QString::number(curScore);
+ qDebug() << "当前待新增总学时:" + QString::number(curScore);
}
void ActivityManageWork::homeWorking()//已废弃
diff --git a/approvalwork.cpp b/approvalwork.cpp
index 3b6c5ea..d4a8d45 100644
--- a/approvalwork.cpp
+++ b/approvalwork.cpp
@@ -121,6 +121,7 @@ void ApprovalWork::getUserPageApplyItems(const QString& uid)
{
DB.open();
QSqlQuery query(DB);
+ //ȡĿ
query.exec(QString("SELECT * FROM magic_applyItems WHERE isHide=0"));
applyItems.clear();
while (query.next()) {
@@ -143,9 +144,11 @@ void ApprovalWork::getUserPageApplyItems(const QString& uid)
}
}
query.clear();
+
//ȡûύ
applyForms.clear();
query.exec(QString("SELECT * FROM magic_apply WHERE uid=%1 ORDER BY apply_id DESC").arg(uid)); //id
+ DB_SECOND.open(); //getApplyProcess()ǰݿ
while(query.next())
{
QByteArray array;
@@ -166,8 +169,8 @@ void ApprovalWork::getUserPageApplyItems(const QString& uid)
}
}
query.clear();
- DB.close();
-
+ DB_SECOND.close(); //رյgetApplyProcess()ݿ
+ DB.close();
emit getUserPageApplyItemsFinished();
}
@@ -227,7 +230,7 @@ void ApprovalWork::autoExecuteSystemApplyItems()
DB_SECOND.close();
finishedNum++;
if(!mail.isEmpty())
- service::sendMail(smtp_config, mail, "WePlanet ȸ", QString("û%1\nġϢ춯롿ˣϢѸ¡\n\nע춯ϢϵԱ").arg(record.value("uid").toString()));
+ service::sendMail(smtp_config, mail, "WePlanet ȸ", QString("û%1\nġϢ춯롿ˣϢѸ¡\n\nע춯ϢϵԱ").arg(record.value("uid").toString()));
}
}
}
@@ -279,7 +282,7 @@ void ApprovalWork::autoExecuteSystemApplyItems()
DB_SECOND.close();
finishedNum++;
if (!mail.isEmpty())
- service::sendMail(smtp_config, mail, "WePlanet ȸ", QString("û%1\nġ˺֤롿ˣ˺֤ϢѸ¡\n\nע֤ϢϵԱ").arg(record.value("uid").toString()));
+ service::sendMail(smtp_config, mail, "WePlanet ȸ", QString("û%1\nġ˺֤롿ˣ˺֤ϢѸ¡\n\nע֤ϢϵԱ").arg(record.value("uid").toString()));
}
}
}
@@ -291,9 +294,9 @@ void ApprovalWork::autoExecuteSystemApplyItems()
emit autoExecuteSystemApplyItemsFinished(finishedNum);
}
-int ApprovalWork::getApplyProcess(const QString& apply_id, const QString& item_id)
+int ApprovalWork::getApplyProcess(const QString& apply_id, const QString& item_id) //ô˺ǰݿDB_SECOND
{
- DB_SECOND.open();
+ //DB_SECOND.open();
QSqlQuery query(DB_SECOND);
currentProcess.clear();
int step = 0, apply_status = 0; //ѳɹ̣ͨ״̬
@@ -329,7 +332,7 @@ int ApprovalWork::getApplyProcess(const QString& apply_id, const QString& item_i
applyFormsProcess.insert(apply_id, currentProcess); //˵IJӦidֵ
query.clear();
- DB_SECOND.close();
+ //DB_SECOND.close();
return apply_status;
}
diff --git a/approvalwork.h b/approvalwork.h
index b3293b2..0806984 100644
--- a/approvalwork.h
+++ b/approvalwork.h
@@ -25,11 +25,11 @@ class ApprovalWork : public QObject
QList smtp_config;
public:
- void getManagePageApplyItems(const QString& uid);
- void getUserPageApplyItems(const QString& uid);
+ void getManagePageApplyItems(const QString& uid); //ҳ
+ void getUserPageApplyItems(const QString& uid); //ûҳ
void getManagePageAuditorList(); //ȡȨԱб
void getAllApplyFormList(const QString& uid); //ȡйԱ
- int getApplyProcess(const QString& apply_id, const QString& item_id); //״̬
+ int getApplyProcess(const QString& apply_id, const QString& item_id); //ȡ̣״̬ô˺ǰݿDB_SECONDӣ
void addOrModifyApplyItem(int type, QByteArray array); //01 ByteArray ->ѡ->->->isHide
QByteArray getSimpleApplyItems(const QString& item_id);
QList getApplyFormList();
diff --git a/attendmanagework.cpp b/attendmanagework.cpp
index 6b47263..048c6a0 100644
--- a/attendmanagework.cpp
+++ b/attendmanagework.cpp
@@ -8,7 +8,7 @@ AttendManageWork::AttendManageWork(QObject *parent) : QObject(parent)
//DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
heartBeat = new QTimer(this);
connect(heartBeat, &QTimer::timeout, this, [=]() {
- if (isDisplay)
+ if (isDisplay && userModel != nullptr && attendModel != nullptr)
{
userModel->select();
attendModel->select();
@@ -31,8 +31,13 @@ void AttendManageWork::working()
{
if (!DB.isOpen())
DB.open();
+
+ //使用relationalModel时,这数据库不能关闭,否则外键的映射就没办法操作了...早知道不用relationalModel了,数据库连接很难管理...
+ if(userModelQueue.count() >= 2)
+ delete userModelQueue.dequeue(); //仅保留前一个model
+ userModel = new QSqlRelationalTableModel(this, DB);
+ userModelQueue.enqueue(userModel);
isDisplay = true;
- //使用relationalModel时,这数据库不能关闭,否则外键的映射就没办法操作了...早知道不用relationalModel了,数据库连接很难管理...
userModel->setTable("magic_users");
userModel->setSort(userModel->fieldIndex("uid"), Qt::AscendingOrder); //升序排列
userModel->setEditStrategy(QSqlTableModel::OnManualSubmit); //手动提交
@@ -51,6 +56,13 @@ void AttendManageWork::working()
userModel->setRelation(userModel->fieldIndex("user_group"), QSqlRelation("magic_group", "group_id", "group_name"));
userModel->setRelation(userModel->fieldIndex("user_dpt"), QSqlRelation("magic_department", "dpt_id", "dpt_name"));
userModel->select();
+ while (userModel->canFetchMore())
+ userModel->fetchMore(); //加载超过256的其余数据
+
+ if(attendModelQueue.count() >= 2)
+ delete attendModelQueue.dequeue();
+ attendModel = new QSqlRelationalTableModel(this, DB);
+ attendModelQueue.enqueue(attendModel);
attendModel->setTable("magic_attendance");
attendModel->setSort(attendModel->fieldIndex("today"), Qt::DescendingOrder); //时间降序排列
@@ -66,6 +78,8 @@ void AttendManageWork::working()
//建立外键关联
attendModel->setRelation(attendModel->fieldIndex("operator"), QSqlRelation("magic_users", "uid", "name"));
attendModel->select();
+ while (attendModel->canFetchMore())
+ attendModel->fetchMore(); //加载超过256的其余数据
//将未签退的考勤项签退,签退时间23:59:59
DB_SECOND.open();
@@ -154,19 +168,29 @@ void AttendManageWork::setCurAvatarUrl(const QString url)
avatarUrl = url;
}
-void AttendManageWork::setUserModel(QSqlRelationalTableModel *relTableModel)
+//void AttendManageWork::setUserModel(QSqlRelationalTableModel *relTableModel)
+//{
+// userModel = relTableModel;
+//}
+//
+//void AttendManageWork::setAttendModel(QSqlRelationalTableModel *relTableModel)
+//{
+// attendModel = relTableModel;
+//}
+
+QSqlDatabase AttendManageWork::getDB()
{
- userModel = relTableModel;
+ return DB;
}
-void AttendManageWork::setAttendModel(QSqlRelationalTableModel *relTableModel)
+QSqlRelationalTableModel* AttendManageWork::getUserModel()
{
- attendModel = relTableModel;
+ return userModel;
}
-QSqlDatabase AttendManageWork::getDB()
+QSqlRelationalTableModel* AttendManageWork::getAttendModel()
{
- return DB;
+ return attendModel;
}
void AttendManageWork::getComboxItems(QStringList& comboxItems_group, QStringList& comboxItems_department)
diff --git a/attendmanagework.h b/attendmanagework.h
index 81894d1..a4b2726 100644
--- a/attendmanagework.h
+++ b/attendmanagework.h
@@ -17,8 +17,8 @@ class AttendManageWork : public QObject
bool isFirst = true; //是否为首次加载model
void working();
void setCurAvatarUrl(const QString url);
- void setUserModel(QSqlRelationalTableModel *relTableModel);
- void setAttendModel(QSqlRelationalTableModel *relTableModel);
+ //void setUserModel(QSqlRelationalTableModel *relTableModel);
+ //void setAttendModel(QSqlRelationalTableModel *relTableModel);
void getComboxItems(QStringList& comboxItems_group, QStringList& comboxItems_department); //已弃用
void submitAll(int type); //1补签 0退签
void loadAvatar();
@@ -27,6 +27,8 @@ class AttendManageWork : public QObject
void setFilter(int type, const QString& filter);
bool isDisplay = false;
QSqlDatabase getDB();
+ QSqlRelationalTableModel* getUserModel();
+ QSqlRelationalTableModel* getAttendModel();
private:
service db_service;
QComboBox *m_group, *m_department;
@@ -36,6 +38,7 @@ class AttendManageWork : public QObject
QStringList comboxItems_group, comboxItems_department;
QSqlRelationalTableModel *userModel, *attendModel;
QTimer* heartBeat;
+ QQueue userModelQueue, attendModelQueue;
void getComboxItems();
signals:
void attendManageWorkFinished();
diff --git a/attendwork.cpp b/attendwork.cpp
index bc48d0a..c50e779 100644
--- a/attendwork.cpp
+++ b/attendwork.cpp
@@ -8,7 +8,7 @@ AttendWork::AttendWork(QObject *parent) : QObject(parent)
//DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
heartBeat = new QTimer(this);
connect(heartBeat, &QTimer::timeout, this, [=]() {
- if (isDisplay)
+ if (isDisplay && relTableModel != nullptr)
relTableModel->select();
else
if (DB.isOpen())
@@ -28,6 +28,11 @@ void AttendWork::working()
{
if (!DB.isOpen())
DB.open();
+
+ if (modelQueue.count() >= 2)
+ delete modelQueue.dequeue();
+ relTableModel = new QSqlRelationalTableModel(this, DB);
+ modelQueue.enqueue(relTableModel);
isDisplay = true;
relTableModel->setTable("magic_attendance");
relTableModel->setSort(relTableModel->fieldIndex("today"), Qt::DescendingOrder); //时间降序排列
@@ -44,6 +49,8 @@ void AttendWork::working()
relTableModel->setRelation(relTableModel->fieldIndex("operator"), QSqlRelation("magic_users", "uid", "name"));
relTableModel->select();
relTableModel->setFilter("a_uid='" + uid +"'");
+ while (relTableModel->canFetchMore())
+ relTableModel->fetchMore(); //加载超过256的其余数据
//将未签退的考勤项签退,签退时间23:59:59
DB_SECOND.open();
@@ -61,22 +68,17 @@ void AttendWork::working()
void AttendWork::homeChartWorking()
{
- if (!DB.isOpen())
- DB.open();
- isDisplay = true;
- relTableModel->setTable("magic_attendance");
- relTableModel->setSort(relTableModel->fieldIndex("today"), Qt::DescendingOrder); //时间降序排列
- relTableModel->setEditStrategy(QSqlTableModel::OnManualSubmit); //手动提交
- relTableModel->select();
- relTableModel->setFilter("a_uid='" + uid + "'");
- analyseWorkTime();
+ DB_SECOND.open();
+
+ QSqlQuery query(DB_SECOND);
+ query.exec(QString("SELECT * FROM magic_attendance WHERE a_uid='%1' ORDER BY today DESC").arg(uid));
+ analyseWorkTime(&query);
QJsonObject seriesObj;
QJsonArray dateArray;
seriesObj.insert("data_yStatus", weekAllWorkStatus);
seriesObj.insert("data_yTime", weekMyWorkTime);
- seriesObj.insert("data_yMem", weekWorkMem);
QString date;
QDateTime curDateTime = QDateTime::fromSecsSinceEpoch(service::getWebTime());
@@ -90,11 +92,14 @@ void AttendWork::homeChartWorking()
seriesObj.insert("data_x", dateArray);
QString jsCode = QString("init(%1, 1)").arg(QString(QJsonDocument(seriesObj).toJson()));
- isDisplay = false; //首页仅需要展示图表,并不需要model一直活动
+ isDisplay = false; //首页仅需要展示图表,并不需要model活动
+
+ query.clear();
+ DB_SECOND.close();
emit homeChartDone(jsCode);
}
-void AttendWork::analyseWorkTime()
+void AttendWork::analyseWorkTime(QSqlQuery* query)
{
int cnt = 0;
QTime workTime(0, 0, 0, 0), beginTime, endTime;
@@ -105,7 +110,12 @@ void AttendWork::analyseWorkTime()
for(int i = 0; i < 4; i++)
workTimeData[i] = 0;
do{
- curRecord = relTableModel->record(cnt);
+ if (query != nullptr && query->seek(cnt))
+ curRecord = query->record();
+ else if (query == nullptr)
+ curRecord = relTableModel->record(cnt);
+ else
+ break;
if(!curRecord.value("begin_date").isNull() && !curRecord.value("end_date").isNull())
{
beginTime = QTime::fromString(curRecord.value("begin_date").toString(), "hh:mm:ss");
@@ -123,6 +133,7 @@ void AttendWork::analyseWorkTime()
}
cnt ++;
}while(!curRecord.value("begin_date").isNull());
+
today = today.addDays(-7);
for (int i = 0; i < 7; i++)
{
@@ -130,7 +141,12 @@ void AttendWork::analyseWorkTime()
today = today.addDays(1);
workTime.setHMS(0, 0, 0);
do{
- curRecord = relTableModel->record(cnt);
+ if (query != nullptr && query->seek(cnt))
+ curRecord = query->record();
+ else if (query == nullptr)
+ curRecord = relTableModel->record(cnt);
+ else
+ break;
if (today.date().toString("yyyy-MM-dd") == curRecord.value("today").toDateTime().date().toString("yyyy-MM-dd"))
{
beginTime = QTime::fromString(curRecord.value("begin_date").toString(), "hh:mm:ss");
@@ -147,16 +163,19 @@ void AttendWork::analyseWorkTime()
}
this->weekMyWorkTime = weekMyWorkTime;
this->weekAllWorkStatus = weekAllWorkStatus;
- QString preFilter = relTableModel->filter();
- today = today.addDays(-7);
- for (int i = 0; i < 7; i++)
+ if (query == nullptr)
{
- today = today.addDays(1);
- relTableModel->setFilter("today='" + today.date().toString("yyyy-MM-dd") + "'");
- weekWorkMem[i] = relTableModel->rowCount();
+ QString preFilter = relTableModel->filter();
+ today = today.addDays(-7);
+ for (int i = 0; i < 7; i++)
+ {
+ today = today.addDays(1);
+ relTableModel->setFilter("today='" + today.date().toString("yyyy-MM-dd") + "'");
+ weekWorkMem[i] = relTableModel->rowCount();
+ }
+ relTableModel->setFilter(preFilter);
+ this->weekWorkMem = weekWorkMem;
}
- relTableModel->setFilter(preFilter);
- this->weekWorkMem = weekWorkMem;
}
void AttendWork::analyseWorkStatus()
@@ -175,10 +194,10 @@ void AttendWork::setUid(const QString &uid)
this->uid = uid;
}
-void AttendWork::setModel(QSqlRelationalTableModel *relTableModel)
-{
- this->relTableModel = relTableModel;
-}
+//void AttendWork::setModel(QSqlRelationalTableModel *relTableModel)
+//{
+// this->relTableModel = relTableModel;
+//}
int AttendWork::fieldIndex(const QString &field)
{
@@ -205,6 +224,11 @@ QJsonArray AttendWork::getWeekWorkMem()
return weekWorkMem;
}
+QSqlRelationalTableModel* AttendWork::getModel()
+{
+ return relTableModel;
+}
+
QSqlDatabase AttendWork::getDB()
{
return DB;
diff --git a/attendwork.h b/attendwork.h
index deae423..85038c2 100644
--- a/attendwork.h
+++ b/attendwork.h
@@ -21,17 +21,18 @@ class AttendWork : public QObject
~AttendWork();
void working();
void homeChartWorking();
- void analyseWorkTime();
+ void analyseWorkTime(QSqlQuery* query = nullptr);
void analyseWorkStatus();
QSqlRecord getRecord(const int index);
QSqlDatabase getDB();
void setUid(const QString& uid);
- void setModel(QSqlRelationalTableModel *relTableModel);
+ //void setModel(QSqlRelationalTableModel *relTableModel);
int fieldIndex(const QString &field);
int* getWorkTime();
QJsonArray getWeekMyWorkTime();
QJsonArray getWeekAllWorkStatus();
QJsonArray getWeekWorkMem();
+ QSqlRelationalTableModel* getModel();
bool isDisplay = false;
private slots:
void submitAll(int type); //1代表签到,0代表签退
@@ -43,6 +44,7 @@ private slots:
QSqlRelationalTableModel *relTableModel;
QJsonArray weekMyWorkTime, weekAllWorkStatus, weekWorkMem;
QTimer* heartBeat;
+ QQueue modelQueue;
signals:
void attendWorkFinished();
void attendDone(bool);
diff --git a/checkupdate.cpp b/checkupdate.cpp
index 8c841bb..3bad2ea 100644
--- a/checkupdate.cpp
+++ b/checkupdate.cpp
@@ -3,8 +3,8 @@
checkUpdate::checkUpdate()
{
- CurVersion = "1.2.8.9"; //在此处定义软件当前版本
- AutoUpdateToolVersion = 11289; //自动更新工具识别版本
+ CurVersion = "1.2.9.0"; //在此处定义软件当前版本
+ AutoUpdateToolVersion = 11290; //自动更新工具识别版本
writeVersion();
}
checkUpdate::~checkUpdate()
diff --git a/eCharts/echarts_workTime.html b/eCharts/echarts_workTime.html
index 0859dff..7e14d6f 100644
--- a/eCharts/echarts_workTime.html
+++ b/eCharts/echarts_workTime.html
@@ -22,7 +22,7 @@
myChart.clear();
option = {
title: {
- text: '工时总体数据分析',
+ text: '我的工作时长数据统计',
subtext: args['type'],
left: 'center'
},
@@ -36,7 +36,7 @@
},
series: [
{
- name: '工时数据统计',
+ name: '该区间工作时长数量',
type: 'pie',
radius: '50%',
data: args['data'],
diff --git a/excelexport.cpp b/excelexport.cpp
index 13d7950..7b71eb4 100644
--- a/excelexport.cpp
+++ b/excelexport.cpp
@@ -8,105 +8,56 @@
#include "excelexport.h"
-ExcelExport::ExcelExport(QObject *parent)
+ExcelExport::ExcelExport()
{
- this->parent = parent;
}
ExcelExport::~ExcelExport()
{
}
-// type 1 - 导出所有记录,type 2 - 导出当天所有记录,type 3 - 导出当前用户所有记录
-bool ExcelExport::WriteExcel(const QString &filePath, QSqlTableModel *tableModel, const QString &uid, int type)
+bool ExcelExport::WriteExcel(const QString &filepath, QStack& dataStack)
{
- if (filePath.isEmpty())
+ if (filepath.isEmpty())
return false;
- excel = new QAxObject(parent);
- excel->setControl("Excel.Application");
- excel->dynamicCall("SetVisible(bool Visible)", false);
- excel->setProperty("DisplayAlerts", false);
-
- QAxObject *workbooks = excel->querySubObject("WorkBooks");
- workbooks->dynamicCall("Add");
- QAxObject *workbook = excel->querySubObject("ActiveWorkBook");
- QAxObject *worksheets = workbook->querySubObject("Sheets");
- QAxObject *worksheet = worksheets->querySubObject("Item(int)", 1);
+ QFile csvfile(filepath);
+ csvfile.open(QIODevice::WriteOnly | QIODevice::Text);
+ QTextStream out(&csvfile);
QStringList headData;
- headData << "账号(UID)"
+ headData << "考勤编号"
+ << "用户账号"
<< "签到时间"
<< "签退时间"
<< "考勤日期"
<< "是否补签"
<< "签到来源";
- QSqlRecord curRecord = tableModel->record(0); //获取记录
curDateTime = QDateTime::currentDateTime();
//写入表头
- int column = 1;
- foreach (auto cur, headData)
+ int headcnt = 0;
+ foreach(auto headTitle, headData)
{
- QAxObject *Range = worksheet->querySubObject("Cells(int, int)", 1, column++);
- Range->dynamicCall("SetValue(const QString &)", cur);
+ if (++headcnt < headData.count())
+ out << headTitle << ",";
+ else
+ out << headTitle << "\n";
}
//写入考勤数据
- switch (type)
+ while(!dataStack.isEmpty())
{
- case 1:
- tableModel->setFilter("");
- for (int i = 1; curRecord.value("num").isValid(); i++)
- {
- curRecord = tableModel->record(i - 1);
- for (int j = 1; curRecord.value(j).isValid(); j++)
- {
- QAxObject *Range = worksheet->querySubObject("Cells(int, int)", i + 1, j); //从第二行开始
- Range->dynamicCall("SetValue(const QString &)", curRecord.value(j).toString());
- }
- }
- tableModel->setFilter("a_uid='" + uid +"'");
- break;
- case 2:
- tableModel->setFilter("");
- for (int i = 1; curRecord.value("num").isValid(); i++)
- {
- curRecord = tableModel->record(i - 1);
- if (curRecord.value("today") != curDateTime.date().toString("yyyy-MM-dd"))
- continue;
- for (int j = 1; curRecord.value(j).isValid(); j++)
- {
- QAxObject *Range = worksheet->querySubObject("Cells(int, int)", i + 1, j); //从第二行开始
- Range->dynamicCall("SetValue(const QString &)", curRecord.value(j).toString());
- }
- }
- tableModel->setFilter("a_uid='" + uid +"'");
- break;
- case 3:
- tableModel->setSort(tableModel->fieldIndex("a_uid"), Qt::DescendingOrder); //暂时按UID排列,避免出现空行
- for (int i = 1; curRecord.value("num").isValid(); i++)
+ QSqlRecord lineData = dataStack.pop();
+ for(int cnt = 0; cnt < lineData.count(); cnt++)
{
- curRecord = tableModel->record(i - 1);
- if (curRecord.value("a_uid") != uid)
- continue;
- for (int j = 1; curRecord.value(j).isValid(); j++)
- {
- QAxObject *Range = worksheet->querySubObject("Cells(int, int)", i + 1, j); //从第二行开始
- Range->dynamicCall("SetValue(const QString &)", curRecord.value(j).toString());
- }
+ QString data = lineData.value(cnt).toString();
+ if (cnt + 1 < lineData.count())
+ out << data << ",";
+ else
+ out << data << "\n";
}
- tableModel->setSort(tableModel->fieldIndex("today"), Qt::DescendingOrder); //恢复时间降序排列
- break;
- default:
- return false;
- }
- workbook->dynamicCall("SaveAs(const QString &)", QDir::toNativeSeparators(filePath));
- if (excel != NULL)
- {
- excel->dynamicCall("Quit()");
- delete excel;
- return true;
}
- else
- return false;
+ csvfile.flush();
+ csvfile.close();
+ return true;
}
diff --git a/excelexport.h b/excelexport.h
index 2f5f40f..6e9c4a4 100644
--- a/excelexport.h
+++ b/excelexport.h
@@ -1,9 +1,6 @@
/***************************************************/
-/* Magic Light Assistant */
-/* Copyright (c) 2017-2021 by bytecho.net */
+/* Copyright (c) 2017-2023 bytecho.net */
/* Written by Henry */
-/* Function: */
-/* Communication, activity, management and approval*/
/***************************************************/
#pragma once
#pragma execution_character_set("utf-8")
@@ -11,27 +8,26 @@
#ifndef EXCELEXPORT_H
#define EXCELEXPORT_H
-#include
-#include
-#include
#include
-#include
+#include
#include
+#include
+#include
+#include
#include
-#include
-
class ExcelExport {
public:
- ExcelExport(QObject* parent);
+ ExcelExport();
~ExcelExport();
- bool WriteExcel(const QString& filePath, QSqlTableModel* tableModel, const QString& uid, int type);
+ bool WriteExcel(const QString& filepath, QStack& dataStack);
private:
- QObject *parent;
- QAxObject *excel;
QDateTime curDateTime;
+
+signals:
+ void exportExcelFinished(bool res);
};
#endif
diff --git a/formLogin.ui b/formLogin.ui
index 0865fb4..c0e1789 100644
--- a/formLogin.ui
+++ b/formLogin.ui
@@ -44,24 +44,6 @@
- -
-
-
-
- 微软雅黑
- 9
- 75
- true
-
-
-
- --
-
-
- true
-
-
-
-
@@ -79,14 +61,42 @@
-
- :/images/color_icon/color-tips.svg
-
true
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+
+ 微软雅黑
+ 9
+ 75
+ true
+
+
+
+ --
+
+
+ true
+
+
+
@@ -159,13 +169,13 @@
- 95
+ 63
38
- 95
+ 63
38
@@ -173,7 +183,7 @@
- :/images/img/qq-nt-logo.png
+ :/images/img/nt-logo.png
true
@@ -912,7 +922,7 @@ padding: 0px 5px;
32767
- 请输入找回账号绑定的邮箱...
+ 请输入待找回账号所绑定的邮箱...
diff --git a/formlogin.cpp b/formlogin.cpp
index 05d6155..4bfae83 100644
--- a/formlogin.cpp
+++ b/formlogin.cpp
@@ -191,7 +191,7 @@ formLogin::formLogin(QDialog *parent) :
ui->label_announcement->adjustSize(); //自动调整大小
this->adjustSize();
if (loginWork->getAnnouncementTag() == 1)
- ui->label_announcementIcon->setPixmap(QPixmap(":/images/color_icon/color-tips.svg"));
+ ui->label_announcementIcon->setPixmap(QPixmap(":/images/color_icon/color-info.svg"));
else
ui->label_announcementIcon->setPixmap(QPixmap(":/images/color_icon/color-warning_2.svg"));
}
@@ -200,7 +200,7 @@ formLogin::formLogin(QDialog *parent) :
if (loginWork->getIsDebug())
{
ui->tabWidget->setEnabled(false);
- ui->btn_Login->setText("【系统维护中,预计恢复时间详见公告】");
+ ui->btn_Login->setText("系统维护中,预计恢复时间详见公告");
ui->btn_Login->setIcon(QIcon(":/images/color_icon/color-warning_2.svg"));
}
});
diff --git a/friendinfowidget.cpp b/friendinfowidget.cpp
index 78f30f6..9704eb7 100644
--- a/friendinfowidget.cpp
+++ b/friendinfowidget.cpp
@@ -181,7 +181,7 @@ void FriendInfoWidget::on_btn_sendMsg_clicked()
return;
}
Mailsending = true;
- int smtp_rescode = service::sendMail(smtp_config, m_mail, QString("WePlanet Ϣ"), QString("ĺ %1 ͨ WePlanet 㷢Ϣ뾡ǰWePlanet ġ鿴/ظϢ").arg(fromUserInfo));
+ int smtp_rescode = service::sendMail(smtp_config, m_mail, QString("WePlanet Ϣ"), QString("ĺ %1 ͨ [WePlanet ] 㷢Ϣ뾡ǰ [WePlanet ] 鿴/ظϢ").arg(fromUserInfo));
if (smtp_rescode != 1)
QMessageBox::warning(this, "", "ʼʧܣǷȷϵԱSMTPá", QMessageBox::Ok);
diff --git a/img/nt-logo.png b/img/nt-logo.png
new file mode 100644
index 0000000..7a1ab72
Binary files /dev/null and b/img/nt-logo.png differ
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 569d121..65ac31e 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -191,8 +191,8 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
setBaseInfoWork->moveToThread(sqlThread);
attendWork->moveToThread(sqlThread);
userManageWork->moveToThread(sqlThread_SECOND);
- attendManageWork->moveToThread(sqlThread);
- groupManageWork->moveToThread(sqlThread);
+ attendManageWork->moveToThread(sqlThread_SECOND);
+ groupManageWork->moveToThread(sqlThread_SECOND);
activityManageWork->moveToThread(sqlThread_SECOND);
posterWork->moveToThread(sqlThread);
msgService->moveToThread(sqlThread_MSG);
@@ -203,9 +203,10 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
updateSoftWare.moveToThread(sqlThread_SECOND);
//校验、更新本地时间,本对象中curDateTime即为10分钟更新一次的网络时间
- if (!checkLocalTime())
+ bool checkLocalTimeRes = checkLocalTime();
+ if (!checkLocalTimeRes)
{
- disableDynamicItems();
+ disableDynamicItems(true);
curDateTime = QDateTime::currentDateTime();
}
currentTimeUpdate = new QTimer(this);
@@ -216,8 +217,8 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
timeLabel->setText("程序时间:" + curDateTime.toString("yyyy年MM月dd日 hh:mm:ss"));
if (cnt > 10 * 60) //校验一次网络时间
{
- checkLocalTime();
- cnt = 0;
+ if(checkLocalTime())
+ cnt = 0;
}
});
currentTimeUpdate->start(1000);
@@ -257,10 +258,10 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
sqlWork->stopThread();
//构造model
- attendPageModel = new QSqlRelationalTableModel(this, attendWork->getDB());
- userManageModel = new QSqlRelationalTableModel(this, userManageWork->getDB());
- attendUserModel = new QSqlRelationalTableModel(this, attendManageWork->getDB());
- attendManageModel = new QSqlRelationalTableModel(this, attendManageWork->getDB());
+ //attendPageModel = new QSqlRelationalTableModel(this, attendWork->getDB());
+ //userManageModel = new QSqlRelationalTableModel(this, userManageWork->getDB());
+ //attendUserModel = new QSqlRelationalTableModel(this, attendManageWork->getDB());
+ //attendManageModel = new QSqlRelationalTableModel(this, attendManageWork->getDB());
groupModel = new QSqlTableModel(this, groupManageWork->getDB());
departmentModel = new QSqlTableModel(this, groupManageWork->getDB());
activityModel = new QSqlTableModel(this, activityManageWork->getDB());
@@ -268,8 +269,8 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
noticeModel = new QSqlTableModel(this, posterWork->getDB());
noticeManageModel = new QSqlTableModel(this, posterWork->getDB());
- userManagePageSelection = new QItemSelectionModel(userManageModel);
- attendUserSelection = new QItemSelectionModel(attendUserModel);
+ userManagePageSelection = new QItemSelectionModel(); //model在子线程
+ attendUserSelection = new QItemSelectionModel(); //model在子线程
groupPageSelection_group = new QItemSelectionModel(groupModel);
groupPageSelection_department = new QItemSelectionModel(departmentModel);
activitySelection = new QItemSelectionModel(activityModel);
@@ -285,16 +286,16 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
//初始化work
setBaseInfoWork->setUid(uid);
- attendWork->setModel(attendPageModel);
+ //attendWork->setModel(attendPageModel);
attendWork->setUid(uid);
friendsWidget->setUid(uid);
activityManageWork->setUid(uid);
- userManageWork->setModel(userManageModel);
+ //userManageWork->setModel(userManageModel);
userManageWork->setCombox(ui->comboBox_group, ui->comboBox_department);
- attendManageWork->setUserModel(attendUserModel);
- attendManageWork->setAttendModel(attendManageModel);
+ //attendManageWork->setUserModel(attendUserModel);
+ //attendManageWork->setAttendModel(attendManageModel);
attendManageWork->setCombox(ui->comboBox_group_2, ui->comboBox_department_2);
groupManageWork->setGroupModel(groupModel);
@@ -433,7 +434,7 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
on_actAttend_triggered(); //刷新信息
}
else
- QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendPageModel->lastError().text(), QMessageBox::Ok);
+ QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendWork->getModel()->lastError().text(), QMessageBox::Ok);
}, Qt::UniqueConnection);
connect(attendWork, &AttendWork::attendOutDone, this, [=](bool res){
if(res)
@@ -444,7 +445,7 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
on_actAttend_triggered(); //刷新信息
}
else
- QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendPageModel->lastError().text(), QMessageBox::Ok);
+ QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendWork->getModel()->lastError().text(), QMessageBox::Ok);
}, Qt::UniqueConnection);
//用户管理信号槽
@@ -530,7 +531,7 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
}, Qt::UniqueConnection);
connect(userManageWork, &UserManageWork::submitAllFinished, this, [=](bool res){
if(!res)
- QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + userManageModel->lastError().text(),
+ QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + userManageWork->getModel()->lastError().text(),
QMessageBox::Ok);
else{
ui->btn_editUser_check->setEnabled(false);
@@ -579,7 +580,7 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
ui->label_attendManagePage_status->setText("已签到");
}
else
- QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendManageModel->lastError().text(),
+ QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendManageWork->getAttendModel()->lastError().text(),
QMessageBox::Ok);
});
connect(attendManageWork, &AttendManageWork::submitDelFinished, this, [=](bool res){
@@ -589,7 +590,7 @@ MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
ui->label_attendManagePage_status->setText("未签到");
}
else
- QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendManageModel->lastError().text(),
+ QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendManageWork->getAttendModel()->lastError().text(),
QMessageBox::Ok);
});
//活动管理信号槽
@@ -1169,7 +1170,9 @@ void MainWindow::setHomePageBaseInfo()
ui->label_homeStatus->setPixmap(QPixmap(":/images/color_icon/approve_3.svg"));
else
ui->label_homeStatus->setPixmap(QPixmap(":/images/color_icon/approve_2.svg"));
-
+
+ trayIcon->setToolTip(QString("WePlanet - 运行中\n账号:%1\n姓名:%2\n邮箱:%3\n\n当天考勤:%4\n签到时间:%5\n签退时间:%6").arg(ui->label_home_uid->text(), ui->label_home_name->text(), ui->label_home_mail->text(), ui->label_homePage_attendStatus->text(), ui->label_homePage_beginTime->text(), ui->label_homePage_endTime->text()));
+
sqlWork->beginThread();
}
@@ -1264,7 +1267,7 @@ void MainWindow::on_actExit_triggered()
void MainWindow::on_actHome_triggered()
{
- if (homeLoading)
+ if (homeLoading || ui->stackedWidget->currentIndex() == 13)
return;
initModelViewIsDisplay();
ui->stackedWidget->setCurrentIndex(0);
@@ -1281,6 +1284,8 @@ void MainWindow::on_actHome_triggered()
void MainWindow::on_actMyInfo_triggered()
{
+ if (ui->stackedWidget->currentIndex() == 13 || homeLoading)
+ return;
initModelViewIsDisplay();
ui->stackedWidget->setCurrentIndex(1);
QRegExp regx_pwd("[0-9A-Za-z!@#$%^&*.?]{1,16}$"), regx_num("[0-9]{1,11}$");
@@ -1292,9 +1297,14 @@ void MainWindow::on_actMyInfo_triggered()
void MainWindow::on_actAttend_triggered()
{
- if (ui->stackedWidget->currentIndex() == 13)
+ if (ui->stackedWidget->currentIndex() == 13 || homeLoading)
return;
initModelViewIsDisplay();
+ if (isDisabledDynamicItems)
+ {
+ ui->stackedWidget->setCurrentIndex(18);
+ return;
+ }
ui->stackedWidget->setCurrentIndex(13);
ui->tableView_attendPage->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -1306,7 +1316,7 @@ void MainWindow::setAttendPage()
ui->stackedWidget->setCurrentIndex(4);
//curDateTime = QDateTime::fromSecsSinceEpoch(service::getWebTime());
- ui->tableView_attendPage->setModel(attendPageModel);
+ ui->tableView_attendPage->setModel(attendWork->getModel());
ui->tableView_attendPage->hideColumn(0); //隐藏考勤数据编号
ui->tableView_attendPage->setEditTriggers(QAbstractItemView::NoEditTriggers); //不可编辑
QSqlRecord curRec = attendWork->getRecord(0); //取最新的一条记录
@@ -2094,7 +2104,7 @@ void MainWindow::updateApplyItemProcess(int type, QString apply_id, QListgroupBox_22->setTitle("当前项目审批流程");
else
- ui->groupBox_22->setTitle("当前申请审批进度(点击具体流程可查看审核意见)");
+ ui->groupBox_22->setTitle("当前申请审批进度(点击流程步骤可查看审核意见)");
//清除所有widget
while (ui->ApplyProcess_Layout->count())
ui->ApplyProcess_Layout->removeItem(ui->ApplyProcess_Layout->itemAt(0));
@@ -2171,7 +2181,13 @@ void MainWindow::updateApplyItemProcess(int type, QString apply_id, QListshowMinimized();
infoWidget->showNormal();
});
- }
+ }
+ else if(type == 1)
+ {
+ connect(process, &QToolButton::clicked, this, [=]() {
+ QMessageBox::information(this, "审核意见", "等待审核中,暂无审核意见。");
+ });
+ }
ui->ApplyProcess_Layout->addWidget(process);
QLabel* arrow = new QLabel();
@@ -2309,8 +2325,8 @@ bool MainWindow::checkLocalTime()
if (webTimeSinceEpoch == -1)
{
- QMessageBox::warning(this, "时间误差警告", "获取服务器时间失败,请检查网络连接。\n考勤、活动、畅聊等已被禁用,请前往【设置】页面重新验证时间以启动部分项。");
- disableDynamicItems();
+ trayIcon->showMessage("时间校验失败", QString("获取服务器时间失败,请检查网络连接。考勤、活动、畅聊等已被禁用,请前往[设置]验证时间以重新启用。"));
+ disableDynamicItems(true);
return false;
}
curDateTime = QDateTime::fromSecsSinceEpoch(webTimeSinceEpoch); //更新网络时间
@@ -2321,20 +2337,21 @@ bool MainWindow::checkLocalTime()
if (marginMinutes > 3 || marginMinutes < -3)
{
- QMessageBox::warning(this, "时间误差警告", "本地时间与Windows服务器时间的误差超出范围。\n考勤、活动、畅聊等已被禁用,请检查本地时间后前往【设置】页面重新验证时间以启动部分项。");
- disableDynamicItems();
+ trayIcon->showMessage("时间校验失败", QString("本地时间与Windows服务器时间的不匹配。考勤、活动、畅聊等已被禁用,请检查本地时间后前往[设置]验证时间以重新启用。"));
+ disableDynamicItems(false);
return false;
}
return true;
}
-void MainWindow::disableDynamicItems()
+void MainWindow::disableDynamicItems(bool isDisabled)
{
- ui->btn_actJoin->setEnabled(false);
- ui->btn_actCancel->setEnabled(false);
- ui->btn_beginAttend->setEnabled(false);
- ui->btn_endAttend->setEnabled(false);
- ui->btn_sendMsg->setEnabled(false);
+ isDisabledDynamicItems = isDisabled;
+ ui->btn_actJoin->setEnabled(!isDisabled);
+ ui->btn_actCancel->setEnabled(!isDisabled);
+ ui->btn_beginAttend->setEnabled(!isDisabled);
+ ui->btn_endAttend->setEnabled(!isDisabled);
+ ui->btn_sendMsg->setEnabled(!isDisabled);
}
void MainWindow::on_actApply_triggered()
@@ -2361,10 +2378,11 @@ void MainWindow::on_actUserManager_triggered()
void MainWindow::setUserManagePage()
{
- ui->tableView_userManage->setModel(userManageModel);
+ ui->tableView_userManage->setModel(userManageWork->getModel()); //userManageModel
ui->tableView_userManage->hideColumn(1); //隐藏密码列
ui->tableView_userManage->hideColumn(10); //隐藏用户状态
+ userManagePageSelection->setModel(userManageWork->getModel()); //userManageModel
ui->tableView_userManage->setSelectionModel(userManagePageSelection);
/*
//当前项变化时触发currentChanged信号
@@ -2376,7 +2394,7 @@ void MainWindow::setUserManagePage()
this, SLOT(on_userManagePagecurrentRowChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
//移动到下一行(第0行为系统账号)
- QModelIndex next_index = userManageModel->index(1, 1);
+ QModelIndex next_index = userManageWork->getModel()->index(1, 1);
userManagePageSelection->setCurrentIndex(next_index, QItemSelectionModel::Select);
ui->stackedWidget->setCurrentIndex(6);
@@ -2403,12 +2421,13 @@ void MainWindow::on_actAttendManager_triggered()
void MainWindow::setAttendManagePage()
{
//用户列表
- ui->tableView_attendUsers->setModel(attendUserModel);
+ ui->tableView_attendUsers->setModel(attendManageWork->getUserModel());
ui->tableView_attendUsers->hideColumn(1); //隐藏密码
ui->tableView_attendUsers->hideColumn(8); //头像地址
ui->tableView_attendUsers->hideColumn(9); //学时
ui->tableView_attendUsers->hideColumn(10); //用户状态
+ attendUserSelection->setModel(attendManageWork->getUserModel());
ui->tableView_attendUsers->setSelectionModel(attendUserSelection);
//当前行变化时触发currentRowChanged信号
@@ -2416,7 +2435,7 @@ void MainWindow::setAttendManagePage()
this, SLOT(on_attendManagePageUserscurrentRowChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
//签到列表
- ui->tableView_attendInfo->setModel(attendManageModel);
+ ui->tableView_attendInfo->setModel(attendManageWork->getAttendModel());
ui->tableView_attendInfo->hideColumn(0); //隐藏不需要的签到编号
ui->stackedWidget->setCurrentIndex(7);
@@ -2687,6 +2706,11 @@ void MainWindow::on_action_triggered()
if (ui->stackedWidget->currentIndex() == 13)
return;
initModelViewIsDisplay();
+ if (isDisabledDynamicItems)
+ {
+ ui->stackedWidget->setCurrentIndex(18);
+ return;
+ }
ui->stackedWidget->setCurrentIndex(13);
ui->lineEdit_actSearch->clear();
if(ui->comboBox_activity->currentIndex() != 0)
@@ -2762,6 +2786,11 @@ void MainWindow::on_actMessage_triggered()
if (ui->stackedWidget->currentIndex() == 13)
return;
initModelViewIsDisplay();
+ if (isDisabledDynamicItems)
+ {
+ ui->stackedWidget->setCurrentIndex(18);
+ return;
+ }
ui->stackedWidget->setCurrentIndex(13);
emit loadMsgMemList(uid);
}
@@ -2909,7 +2938,7 @@ void MainWindow::on_actPanel_triggered()
void MainWindow::on_actRefresh_triggered()
{
emit get_statistics(); //统计心跳请求量
- trayIcon->setToolTip("WePlanet - 运行中(上次刷新" + QDateTime::currentDateTime().time().toString("hh:mm") + ")");
+ //trayIcon->setToolTip("WePlanet - 运行中(上次刷新" + QDateTime::currentDateTime().time().toString("hh:mm") + ")");
int index = ui->stackedWidget->currentIndex();
switch (index)
{
@@ -2985,10 +3014,10 @@ void MainWindow::on_userManagePagecurrentChanged(const QModelIndex ¤t, con
void MainWindow::on_userManagePagecurrentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
- QSqlRecord curRecord = userManageModel->record(current.row()), preRecord = userManageModel->record(previous.row());
+ QSqlRecord curRecord = userManageWork->getModel()->record(current.row()), preRecord = userManageWork->getModel()->record(previous.row());
- ui->btn_editUser_check->setEnabled(userManageModel->isDirty());
- ui->btn_editUser_cancel->setEnabled(userManageModel->isDirty());
+ ui->btn_editUser_check->setEnabled(userManageWork->getModel()->isDirty());
+ ui->btn_editUser_cancel->setEnabled(userManageWork->getModel()->isDirty());
//ui->tableView_userManage->setItemDelegateForRow(current.row(), readOnlyDelegate); //禁止编辑系统账号
ui->tableView_userManage->setRowHidden(current.row(), curRecord.value("uid") == "1");
@@ -3044,10 +3073,10 @@ void MainWindow::on_userManagePagecurrentRowChanged(const QModelIndex ¤t,
{
if(ui->lineEdit_editPwd->text() == ui->lineEdit_editPwdCheck->text())
{
- userManageModel->setData(userManageModel->index(previous.row(), userManageModel->fieldIndex("password")), service::pwdEncrypt(ui->lineEdit_editPwd->text()), Qt::EditRole);
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(previous.row(), userManageWork->getModel()->fieldIndex("password")), service::pwdEncrypt(ui->lineEdit_editPwd->text()), Qt::EditRole);
QMessageBox::information(this, "提示", "当前用户(UID:" + preRecord.value("uid").toString()+ ")密码已成功缓存。\n点击确认修改即可生效(请确认UID是否正确*)。\n新密码为:" + ui->lineEdit_editPwd->text(), QMessageBox::Ok);
- ui->btn_editUser_check->setEnabled(userManageModel->isDirty());
- ui->btn_editUser_cancel->setEnabled(userManageModel->isDirty());
+ ui->btn_editUser_check->setEnabled(userManageWork->getModel()->isDirty());
+ ui->btn_editUser_cancel->setEnabled(userManageWork->getModel()->isDirty());
ui->lineEdit_editPwd->clear();
ui->lineEdit_editPwdCheck->clear();
}
@@ -3062,7 +3091,7 @@ void MainWindow::on_userManagePagecurrentRowChanged(const QModelIndex ¤t,
void MainWindow::on_attendManagePageUserscurrentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
Q_UNUSED(previous);
- QSqlRecord curRecord = attendUserModel->record(current.row());
+ QSqlRecord curRecord = attendManageWork->getUserModel()->record(current.row());
QSqlRecord curAttendRecord;
//curDateTime = QDateTime::currentDateTime();
@@ -3072,12 +3101,12 @@ void MainWindow::on_attendManagePageUserscurrentRowChanged(const QModelIndex &cu
ui->label_attendManagePage_uid->setText(uid);
- for (int i = 0; i < attendManageModel->rowCount(); i++)
+ for (int i = 0; i < attendManageWork->getAttendModel()->rowCount(); i++)
{
- if (attendManageModel->record(i).value("a_uid").toString() == uid)
+ if (attendManageWork->getAttendModel()->record(i).value("a_uid").toString() == uid)
{
- if (attendManageModel->record(i).value("today").toString() == curDateTime.date().toString("yyyy-MM-dd"))
- curAttendRecord = attendManageModel->record(i); //取最新考勤记录
+ if (attendManageWork->getAttendModel()->record(i).value("today").toString() == curDateTime.date().toString("yyyy-MM-dd"))
+ curAttendRecord = attendManageWork->getAttendModel()->record(i); //取最新考勤记录
ui->tableView_attendInfo->showRow(i);
}
else
@@ -3090,7 +3119,7 @@ void MainWindow::on_attendManagePageUserscurrentRowChanged(const QModelIndex &cu
attendManageWork->setCurAvatarUrl(curRecord.value("user_avatar").toString());
emit attendManageGetAvatar();
}
- getAvatarQueue.enqueue(curRecord.value("user_avatar").toString()); //加载项入栈
+ getAvatarQueue.enqueue(curRecord.value("user_avatar").toString()); //加载项入队列
if(curAttendRecord.value("today").toString() == curDateTime.date().toString("yyyy-MM-dd"))
{
@@ -3196,9 +3225,8 @@ void MainWindow::on_myActivityPagecurrentRowChanged(const QModelIndex& current,
ui->textBrowser_activityDsc->setText(curActRec.value("act_des").toString());
ui->label_actScore_2->setText(curActRec.value("act_score").toString());
if (curRecord.value("status").toString() == "未录取")
- {
ui->label_curActStatus->setText("" + curRecord.value("status").toString() + "");
- }else
+ else
ui->label_curActStatus->setText(curRecord.value("status").toString());
}
@@ -3483,26 +3511,26 @@ void MainWindow::on_btn_editDpt_cancel_clicked()
void MainWindow::on_btn_addUser_clicked()
{
QMessageBox::information(this, "消息", "新增用户请勿填写UID,程序将自动生成。\n初始密码:123456\n", QMessageBox::Ok);
- userManageModel->insertRow(userManageModel->rowCount(), QModelIndex()); //在末尾添加一个记录
- QModelIndex curIndex = userManageModel->index(userManageModel->rowCount() - 1, 1);//创建最后一行的ModelIndex
+ userManageWork->getModel()->insertRow(userManageWork->getModel()->rowCount(), QModelIndex()); //在末尾添加一个记录
+ QModelIndex curIndex = userManageWork->getModel()->index(userManageWork->getModel()->rowCount() - 1, 1);//创建最后一行的ModelIndex
userManagePageSelection->clearSelection();//清空选择项
userManagePageSelection->setCurrentIndex(curIndex, QItemSelectionModel::Select);//设置刚插入的行为当前选择行
int currow = curIndex.row(); //获得当前行
- userManageModel->setData(userManageModel->index(currow, userManageModel->fieldIndex("password")), service::pwdEncrypt("123456")); //自动生成密码
- userManageModel->setData(userManageModel->index(currow, userManageModel->fieldIndex("group_name")), 2);
- userManageModel->setData(userManageModel->index(currow, userManageModel->fieldIndex("dpt_name")), 1);
- userManageModel->setData(userManageModel->index(currow, userManageModel->fieldIndex("score")), 0);
- userManageModel->setData(userManageModel->index(currow, userManageModel->fieldIndex("user_status")), 1);
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(currow, userManageWork->getModel()->fieldIndex("password")), service::pwdEncrypt("123456")); //自动生成密码
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(currow, userManageWork->getModel()->fieldIndex("group_name")), 2);
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(currow, userManageWork->getModel()->fieldIndex("dpt_name")), 1);
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(currow, userManageWork->getModel()->fieldIndex("score")), 0);
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(currow, userManageWork->getModel()->fieldIndex("user_status")), 1);
}
void MainWindow::on_btn_delUser_clicked()
{
QModelIndex curIndex = userManagePageSelection->currentIndex();//获取当前选择单元格的模型索引
- QString uid = userManageModel->record(curIndex.row()).value("uid").toString();
- QString name = userManageModel->record(curIndex.row()).value("name").toString();
+ QString uid = userManageWork->getModel()->record(curIndex.row()).value("uid").toString();
+ QString name = userManageWork->getModel()->record(curIndex.row()).value("name").toString();
- userManageModel->removeRow(curIndex.row()); //删除
+ userManageWork->getModel()->removeRow(curIndex.row()); //删除
QMessageBox::information(this, "消息", "用户 [" + uid + " " + name + "] 待注销,点击[确认修改]以确认操作。\n注意:该操作会将该用户数据删除,请谨慎操作,如误操作,请点击[取消操作]以撤销。", QMessageBox::Ok);
ui->btn_editUser_check->setEnabled(true);
@@ -3512,17 +3540,17 @@ void MainWindow::on_btn_delUser_clicked()
void MainWindow::on_btn_banUser_clicked()
{
QModelIndex curIndex = userManagePageSelection->currentIndex();//获取当前选择单元格的模型索引
- QString uid = userManageModel->record(curIndex.row()).value("uid").toString();
- QString name = userManageModel->record(curIndex.row()).value("name").toString();
+ QString uid = userManageWork->getModel()->record(curIndex.row()).value("uid").toString();
+ QString name = userManageWork->getModel()->record(curIndex.row()).value("name").toString();
- if (userManageModel->record(curIndex.row()).value("user_status").toInt() == 1)
+ if (userManageWork->getModel()->record(curIndex.row()).value("user_status").toInt() == 1)
{
- userManageModel->setData(userManageModel->index(curIndex.row(), 10), 0, Qt::EditRole);
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(curIndex.row(), 10), 0, Qt::EditRole);
QMessageBox::information(this, "消息", "用户 [" + uid + " " + name + "] 待封禁,点击[确认修改]以确认操作。", QMessageBox::Ok);
}
else
{
- userManageModel->setData(userManageModel->index(curIndex.row(), 10), 1, Qt::EditRole);
+ userManageWork->getModel()->setData(userManageWork->getModel()->index(curIndex.row(), 10), 1, Qt::EditRole);
QMessageBox::information(this, "消息", "用户 [" + uid + " " + name + "] 待解封,点击[确认修改]以确认操作。", QMessageBox::Ok);
}
ui->btn_editUser_check->setEnabled(true);
@@ -3536,7 +3564,7 @@ void MainWindow::on_btn_editUser_check_clicked()
void MainWindow::on_btn_editUser_cancel_clicked()
{
- userManageModel->revertAll();
+ userManageWork->getModel()->revertAll();
ui->btn_editUser_check->setEnabled(false);
ui->btn_editUser_cancel->setEnabled(false);
}
@@ -3870,15 +3898,15 @@ void MainWindow::on_btn_attendManage_reAttend_clicked()
return;
}
//curDateTime = QDateTime::currentDateTime();
- attendManageModel->insertRow(attendManageModel->rowCount(), QModelIndex()); //在末尾添加一个记录
- QModelIndex curIndex = attendManageModel->index(attendManageModel->rowCount() - 1, 1);//创建最后一行的ModelIndex
+ attendManageWork->getAttendModel()->insertRow(attendManageWork->getAttendModel()->rowCount(), QModelIndex()); //在末尾添加一个记录
+ QModelIndex curIndex = attendManageWork->getAttendModel()->index(attendManageWork->getAttendModel()->rowCount() - 1, 1);//创建最后一行的ModelIndex
int currow = curIndex.row(); //获得当前行
- attendManageModel->setData(attendManageModel->index(currow, attendManageModel->fieldIndex("a_uid")), ui->label_attendManagePage_uid->text());
- attendManageModel->setData(attendManageModel->index(currow, attendManageModel->fieldIndex("today")), curDateTime.date().toString("yyyy-MM-dd"));
- attendManageModel->setData(attendManageModel->index(currow, attendManageModel->fieldIndex("begin_date")), curDateTime.time().toString("HH:mm:ss"));
- attendManageModel->setData(attendManageModel->index(currow, attendManageModel->fieldIndex("end_date")), curDateTime.time().toString("HH:mm:ss"));
- attendManageModel->setData(attendManageModel->index(currow, attendManageModel->fieldIndex("isSupply")), "是");
- attendManageModel->setData(attendManageModel->index(currow, attendManageModel->fieldIndex("name")), uid); //这里要填外键关联的字段!
+ attendManageWork->getAttendModel()->setData(attendManageWork->getAttendModel()->index(currow, attendManageWork->getAttendModel()->fieldIndex("a_uid")), ui->label_attendManagePage_uid->text());
+ attendManageWork->getAttendModel()->setData(attendManageWork->getAttendModel()->index(currow, attendManageWork->getAttendModel()->fieldIndex("today")), curDateTime.date().toString("yyyy-MM-dd"));
+ attendManageWork->getAttendModel()->setData(attendManageWork->getAttendModel()->index(currow, attendManageWork->getAttendModel()->fieldIndex("begin_date")), curDateTime.time().toString("HH:mm:ss"));
+ attendManageWork->getAttendModel()->setData(attendManageWork->getAttendModel()->index(currow, attendManageWork->getAttendModel()->fieldIndex("end_date")), curDateTime.time().toString("HH:mm:ss"));
+ attendManageWork->getAttendModel()->setData(attendManageWork->getAttendModel()->index(currow, attendManageWork->getAttendModel()->fieldIndex("isSupply")), "是");
+ attendManageWork->getAttendModel()->setData(attendManageWork->getAttendModel()->index(currow, attendManageWork->getAttendModel()->fieldIndex("name")), uid); //这里要填外键关联的字段!
emit attendManageModelSubmitAll(1);
}
@@ -3887,11 +3915,11 @@ void MainWindow::on_btn_attendManage_cancelAttend_clicked()
//curDateTime = QDateTime::currentDateTime();
QSqlRecord curRecord;
int delete_row;
- for (delete_row = 0; delete_row < attendManageModel->rowCount(); delete_row++)
+ for (delete_row = 0; delete_row < attendManageWork->getAttendModel()->rowCount(); delete_row++)
{
- if (!ui->tableView_attendInfo->isRowHidden(delete_row) && attendManageModel->record(delete_row).value("today").toString() == curDateTime.date().toString("yyyy-MM-dd"))
+ if (!ui->tableView_attendInfo->isRowHidden(delete_row) && attendManageWork->getAttendModel()->record(delete_row).value("today").toString() == curDateTime.date().toString("yyyy-MM-dd"))
{
- curRecord = attendManageModel->record(delete_row);
+ curRecord = attendManageWork->getAttendModel()->record(delete_row);
break;
}
}
@@ -3903,7 +3931,7 @@ void MainWindow::on_btn_attendManage_cancelAttend_clicked()
//检测即将删除的数据是否与当前用户对应
if(curRecord.value("a_uid").toString() == ui->label_attendManagePage_uid->text() && curRecord.value("today").toString() == curDateTime.date().toString("yyyy-MM-dd"))
{
- attendManageModel->removeRow(delete_row); //删除顶部的数据
+ attendManageWork->getAttendModel()->removeRow(delete_row); //删除顶部的数据
emit attendManageModelSubmitAll(0);
}
else
@@ -3913,8 +3941,7 @@ void MainWindow::on_btn_attendManage_cancelAttend_clicked()
void MainWindow::on_btn_attendManagePage_exp_clicked()
{
- ExcelExport expExcel(this);
- QSqlRecord re = attendManageModel->record();
+ ExcelExport expExcel;
//导出方式
int type = -1;
if(ui->rBtn_attendManagePage_all->isChecked())
@@ -3923,9 +3950,22 @@ void MainWindow::on_btn_attendManagePage_exp_clicked()
type = 2;
if(ui->rBtn__attendManagePage_curAll->isChecked())
type = 3;
- //curDateTime = QDateTime::currentDateTime();
- QString filePath = QFileDialog::getSaveFileName(this, "导出数据", "考勤数据_" + curDateTime.toString("yyyy-MM-dd_hh-mm-ss"), "Microsoft Excel(*.xlsx)");
- if(expExcel.WriteExcel(filePath, attendManageModel, ui->label_attendManagePage_uid->text(), type))
+
+ //获取所有考勤记录
+ QStack dataStack;
+ for (int i = 0; i < attendManageWork->getAttendModel()->rowCount(); i++)
+ {
+ if (type == 3 && ui->label_attendManagePage_uid->text() == attendManageWork->getAttendModel()->record(i).value("a_uid").toString())
+ dataStack.push(attendManageWork->getAttendModel()->record(i));
+ else if (type == 2 && attendManageWork->getAttendModel()->record(i).value("today").toString() == curDateTime.date().toString("yyyy-MM-dd"))
+ dataStack.push(attendManageWork->getAttendModel()->record(i));
+ else if (type == 1)
+ dataStack.push(attendManageWork->getAttendModel()->record(i));
+ else continue;
+ }
+
+ QString filePath = QFileDialog::getSaveFileName(this, "导出数据", "考勤数据_" + curDateTime.toString("yyyy-MM-dd_hh-mm-ss"), "Microsoft Excel(*.csv)");
+ if(expExcel.WriteExcel(filePath, dataStack))
QMessageBox::information(this, "消息", "考勤数据已成功导出到:" + filePath, QMessageBox::Ok);
else
QMessageBox::warning(this, "消息", "考勤数据导出失败,请检查文件路径。", QMessageBox::Ok);
@@ -3933,11 +3973,18 @@ void MainWindow::on_btn_attendManagePage_exp_clicked()
void MainWindow::on_btn_expAttend_clicked()
{
- ExcelExport expExcel(this);
- QSqlRecord re = attendPageModel->record();
- //curDateTime = QDateTime::currentDateTime();
- QString filePath = QFileDialog::getSaveFileName(this, "导出数据", "考勤数据_" + curDateTime.toString("yyyy-MM-dd_hh-mm-ss"), "Microsoft Excel(*.xlsx)");
- if(expExcel.WriteExcel(filePath, attendPageModel, ui->label_attendPage_uid->text(), 3))
+ ExcelExport expExcel;
+ QString filePath = QFileDialog::getSaveFileName(this, "导出数据", "考勤数据_" + curDateTime.toString("yyyy-MM-dd_hh-mm-ss"), "Microsoft Excel(*.csv)");
+
+ //获取所有考勤记录
+ QStack dataStack;
+ for (int i = 0; i < attendWork->getModel()->rowCount(); i++)
+ {
+ if (uid == attendWork->getModel()->record(i).value("a_uid").toString())
+ dataStack.push(attendWork->getModel()->record(i));
+ }
+
+ if(expExcel.WriteExcel(filePath, dataStack))
QMessageBox::information(this, "消息", "考勤数据已成功导出到:" + filePath, QMessageBox::Ok);
else
QMessageBox::warning(this, "消息", "考勤数据导出失败,请检查文件路径。", QMessageBox::Ok);
@@ -3951,14 +3998,14 @@ void MainWindow::on_btn_beginAttend_clicked()
return;
}
//curDateTime = QDateTime::fromSecsSinceEpoch(service::getWebTime()); //获取网络时间
- attendPageModel->insertRow(attendPageModel->rowCount(), QModelIndex()); //在末尾添加一个记录
- QModelIndex curIndex = attendPageModel->index(attendPageModel->rowCount() - 1, 1);//创建最后一行的ModelIndex
+ attendWork->getModel()->insertRow(attendWork->getModel()->rowCount(), QModelIndex()); //在末尾添加一个记录
+ QModelIndex curIndex = attendWork->getModel()->index(attendWork->getModel()->rowCount() - 1, 1);//创建最后一行的ModelIndex
int currow = curIndex.row(); //获得当前行
- attendPageModel->setData(attendPageModel->index(currow, attendPageModel->fieldIndex("a_uid")), uid);
- attendPageModel->setData(attendPageModel->index(currow, attendPageModel->fieldIndex("today")), curDateTime.date().toString("yyyy-MM-dd"));
- attendPageModel->setData(attendPageModel->index(currow, attendPageModel->fieldIndex("begin_date")), curDateTime.time().toString("HH:mm:ss"));
- attendPageModel->setData(attendPageModel->index(currow, attendPageModel->fieldIndex("isSupply")), "否");
- attendPageModel->setData(attendPageModel->index(currow, attendPageModel->fieldIndex("name")), 1); //这里要填外键关联的字段!
+ attendWork->getModel()->setData(attendWork->getModel()->index(currow, attendWork->getModel()->fieldIndex("a_uid")), uid);
+ attendWork->getModel()->setData(attendWork->getModel()->index(currow, attendWork->getModel()->fieldIndex("today")), curDateTime.date().toString("yyyy-MM-dd"));
+ attendWork->getModel()->setData(attendWork->getModel()->index(currow, attendWork->getModel()->fieldIndex("begin_date")), curDateTime.time().toString("HH:mm:ss"));
+ attendWork->getModel()->setData(attendWork->getModel()->index(currow, attendWork->getModel()->fieldIndex("isSupply")), "否");
+ attendWork->getModel()->setData(attendWork->getModel()->index(currow, attendWork->getModel()->fieldIndex("name")), 1); //这里要填外键关联的字段!
beginAttendLoading = true;
emit attendPageModelSubmitAll(1);
@@ -4023,8 +4070,8 @@ void MainWindow::on_btn_personalSubmit_clicked()
}
if(!ui->lineEdit_personalPwd->text().isEmpty())
newPwd = ui->lineEdit_personalPwd->text();
- if(!ui->lineEdit_personalTel->text().isEmpty())
- newTel = ui->lineEdit_personalTel->text();
+ //if(!ui->lineEdit_personalTel->text().isEmpty()) 暂不支持个人修改手机号
+ // newTel = ui->lineEdit_personalTel->text();
if(!ui->lineEdit_personalMail->text().isEmpty())
newMail = ui->lineEdit_personalMail->text();
if (!ui->lineEdit_personalAvatar->text().isEmpty())
@@ -4251,20 +4298,12 @@ void MainWindow::on_btn_checkTime_clicked()
if (marginMinutes > 3 || marginMinutes < -3)
{
res = QString("校验完成,当前时间误差为:%1 分钟,不满足误差要求(3 min),考勤、活动等已禁用。").arg(marginMinutes);
- ui->btn_actJoin->setEnabled(false);
- ui->btn_actCancel->setEnabled(false);
- ui->btn_beginAttend->setEnabled(false);
- ui->btn_endAttend->setEnabled(false);
- ui->btn_sendMsg->setEnabled(false);
+ disableDynamicItems(true);
}
else
{
res = QString("校验完成,当前时间误差为:%1 分钟,满足误差要求(3 min),考勤、活动等已启用。").arg(marginMinutes);
- ui->btn_actJoin->setEnabled(true);
- ui->btn_actCancel->setEnabled(true);
- ui->btn_beginAttend->setEnabled(true);
- ui->btn_endAttend->setEnabled(true);
- ui->btn_sendMsg->setEnabled(true);
+ disableDynamicItems(false);
}
QMessageBox::information(this, "时间校验", res);
@@ -4323,7 +4362,7 @@ void MainWindow::on_btn_manageApplyModify_clicked()
void MainWindow::on_lineEdit_msgPushTime_textChanged(const QString& arg)
{
- if (arg.toInt() > 0 && arg.toInt() <= 300)
+ if (arg.toInt() >= 3 && arg.toInt() <= 300)
{
msgPushTime = arg.toInt();
config_ini->setValue("/System/MsgPushTime", msgPushTime);
diff --git a/mainwindow.h b/mainwindow.h
index 0996e07..dc670e4 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -79,6 +79,8 @@ class MainWindow : public QMainWindow
bool dbStatus = true;
+ bool isDisabledDynamicItems = false;
+
bool openChat = false; //是否开启聊天
bool isSending = false; //消息发送中
@@ -117,7 +119,7 @@ class MainWindow : public QMainWindow
QSqlTableModel *groupModel, *departmentModel, *activityModel, *activityMemModel, *noticeModel, *noticeManageModel; //数据模型
- QSqlRelationalTableModel *userManageModel, *attendUserModel, *attendManageModel, *attendPageModel;
+ //QSqlRelationalTableModel *userManageModel, *attendUserModel, *attendManageModel, *attendPageModel;
QDataWidgetMapper* actEditMapper, *noticeEditMapper;
@@ -177,9 +179,7 @@ class MainWindow : public QMainWindow
void updateManageApplyItemProcess(QList list);
- void updateApplyItemProcess(int type, QString apply_id, QList list); //0审批流程 1审批进度
-
- void updateApplyItemProcess(QList list);
+ void updateApplyItemProcess(int type, QString apply_id, QList list); //0加载审批流程 1加载审批流程和审批进度
void updateApplyItemOptions(int type, QList list);//0用户页面,1审核页面
@@ -237,7 +237,7 @@ class MainWindow : public QMainWindow
bool checkLocalTime();
- void disableDynamicItems(); //本地时间误差过大,禁用需要准确时间的项目
+ void disableDynamicItems(bool isDisabled); //本地时间误差过大,禁用需要准确时间的项目
void initModelViewIsDisplay(); //重置各work的状态
diff --git a/mainwindow.ui b/mainwindow.ui
index 91827a2..1b645ce 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -1046,13 +1046,13 @@
- 95
+ 63
38
- 95
+ 63
38
@@ -1060,7 +1060,7 @@
- :/images/img/qq-nt-logo.png
+ :/images/img/nt-logo.png
true
@@ -1849,6 +1849,9 @@ padding: 0px 5px;
-
+
+ false
+
0
@@ -1898,7 +1901,7 @@ padding: 0px 5px;
true
- 功能升级中,暂不可用...
+ 请使用[申请]->[个人信息异动申请]修改手机号
@@ -7995,7 +7998,7 @@ padding: 0px 5px;
系统将自动处理【个人信息异动】【账号认证】申请通过后的数据变动。
- 自动化处理
+ 自动化处理数据变动
@@ -10260,7 +10263,7 @@ padding: 0px 5px;
0
0
- 421
+ 439
291
@@ -10622,7 +10625,7 @@ padding: 0px 5px;
- <html><head/><body><p align="center"><span style=" font-size:22pt; font-weight:600;">畅聊系统已被系统管理员暂停使用</span></p><p align="center"><span style=" font-size:10pt; font-weight:600; color:#7a7a7a;">WePlanet权限系统</span></p></body></html>
+ <html><head/><body><p align="center"><span style=" font-size:22pt; font-weight:600;">当前板块已被系统管理员暂停使用</span></p><p align="center"><span style=" font-size:10pt; font-weight:600; color:#7a7a7a;">WePlanet权限系统</span></p></body></html>
Qt::AlignCenter
@@ -10823,7 +10826,7 @@ background-color: transparent;
:/images/color_icon/color-idcard.svg:/images/color_icon/color-idcard.svg
- 我的
+ 资料
我的资料
diff --git a/msgservice.cpp b/msgservice.cpp
index d520715..2039ded 100644
--- a/msgservice.cpp
+++ b/msgservice.cpp
@@ -7,6 +7,10 @@ MsgService::MsgService(QObject *parent, int path)
db_service.addDatabase(DB_PUSHER, "MsgService_DB_PUSHER_" + QString::number(path));
}
+MsgService::~MsgService()
+{
+}
+
void MsgService::loadMsgMemList(QString uid)
{
DB.open();
@@ -52,8 +56,10 @@ void MsgService::pushMessage(QString me, QString member, int limit)
QString from_uid, from_name, to_uid, to_name, msgText, send_time;
msgStack.clear();
- query.exec(QString("SELECT * FROM magic_message WHERE from_uid='%1' AND to_uid='%2' UNION ALL SELECT * FROM magic_message WHERE from_uid='%2' AND to_uid='%1' ORDER BY id DESC").arg(me, member)); // LIMIT 0,30
- msgStackCnt[member] = query.size(); //Ϣջ
+ query.exec(QString("SELECT COUNT(id) FROM magic_message WHERE (from_uid='%1' AND to_uid='%2') OR (from_uid='%2' AND to_uid='%1');").arg(me, member));
+ query.next();
+ msgStackCnt[member] = query.value("COUNT(id)").toInt(); //Ϣջ
+ query.exec(QString("SELECT * FROM magic_message WHERE from_uid='%1' AND to_uid='%2' UNION ALL SELECT * FROM magic_message WHERE from_uid='%2' AND to_uid='%1' ORDER BY id DESC LIMIT %3;").arg(me, member, QString::number(limit))); // LIMIT 0,30
while (query.next() && cnt <= limit) {
QByteArray array;
QDataStream stream(&array, QIODevice::WriteOnly);
@@ -84,7 +90,7 @@ void MsgService::pushMessage(QString me, QString member, int limit)
}
else
isOnline.insert(member, false);
- query.exec();
+ query.clear();
DB_PUSHER.close();
previousPushUid = member;
@@ -321,7 +327,3 @@ QString MsgService::getPreviousPushUid()
{
return previousPushUid;
}
-
-MsgService::~MsgService()
-{
-}
diff --git a/posterwork.cpp b/posterwork.cpp
index 0eef92b..d184789 100644
--- a/posterwork.cpp
+++ b/posterwork.cpp
@@ -46,7 +46,8 @@ void PosterWork::working()
tabModel->setHeaderData(tabModel->fieldIndex("author_id"), Qt::Horizontal, "");
tabModel->setFilter("isHide = 0"); //ʾδ
tabModel->select();
-
+ while (tabModel->canFetchMore())
+ tabModel->fetchMore(); //س256
emit contentsWorkFinished();
}
else
@@ -60,7 +61,8 @@ void PosterWork::working()
manageModel->setHeaderData(manageModel->fieldIndex("c_id"), Qt::Horizontal, "");
manageModel->setHeaderData(manageModel->fieldIndex("title"), Qt::Horizontal, "");
manageModel->select();
-
+ while (manageModel->canFetchMore())
+ manageModel->fetchMore(); //س256
emit contentsManageWorkFinished();
}
}
diff --git a/resource.qrc b/resource.qrc
index 50503d7..9d2b771 100644
--- a/resource.qrc
+++ b/resource.qrc
@@ -111,6 +111,7 @@
color_icon/arrow_up_2.svg
img/stable.png
img/ae_loading.gif
+ img/nt-logo.png
eCharts/echarts.html
diff --git a/usermanagework.cpp b/usermanagework.cpp
index 46b1604..ab8d62e 100644
--- a/usermanagework.cpp
+++ b/usermanagework.cpp
@@ -8,7 +8,7 @@ UserManageWork::UserManageWork(QObject *parent) : QObject(parent)
//DB.setConnectOptions("MYSQL_OPT_RECONNECT=1"); //超时重连
heartBeat = new QTimer(this);
connect(heartBeat, &QTimer::timeout, this, [=]() {
- if (isDisplay)
+ if (isDisplay && relTableModel != nullptr)
relTableModel->select();
else
if (DB.isOpen())
@@ -29,7 +29,13 @@ void UserManageWork::working()
if (!DB.isOpen())
DB.open();
isDisplay = true;
- //使用relationalModel时,这数据库不能关闭,否则外键的映射就没办法操作了...早知道不用relationalModel了,数据库连接很难管理...
+ //使用relationalModel时,这数据库不能关闭,否则外键的映射就没办法操作了...早知道不用relationalModel了,数据库连接很难管理...
+
+ if(modelQueue.count() >= 2)
+ delete modelQueue.dequeue();
+ relTableModel = new QSqlRelationalTableModel(this, DB);
+ modelQueue.enqueue(relTableModel);
+
relTableModel->setTable("magic_users");
relTableModel->setSort(relTableModel->fieldIndex("uid"), Qt::AscendingOrder); //升序排列
relTableModel->setEditStrategy(QSqlTableModel::OnManualSubmit); //手动提交
@@ -48,9 +54,12 @@ void UserManageWork::working()
relTableModel->setRelation(relTableModel->fieldIndex("user_group"), QSqlRelation("magic_group", "group_id", "group_name"));
relTableModel->setRelation(relTableModel->fieldIndex("user_dpt"), QSqlRelation("magic_department", "dpt_id", "dpt_name"));
relTableModel->select();
+ while (relTableModel->canFetchMore())
+ relTableModel->fetchMore(); //加载超过256的其余数据
//获取用户组和部门
getComboxItems();
+
emit userManageWorkFinished();
}
@@ -83,10 +92,10 @@ void UserManageWork::getComboxItems()
m_department->addItems(comboxItems_department);
}
-void UserManageWork::setModel(QSqlRelationalTableModel *model)
-{
- relTableModel = model;
-}
+//void UserManageWork::setModel(QSqlRelationalTableModel *model)
+//{
+// relTableModel = model;
+//}
void UserManageWork::submitAll()
{
@@ -213,3 +222,8 @@ QString UserManageWork::getUid()
{
return uid;
}
+
+QSqlRelationalTableModel* UserManageWork::getModel()
+{
+ return relTableModel;
+}
diff --git a/usermanagework.h b/usermanagework.h
index e433756..c45be38 100644
--- a/usermanagework.h
+++ b/usermanagework.h
@@ -15,7 +15,7 @@ class UserManageWork : public QObject
explicit UserManageWork(QObject *parent = nullptr);
~UserManageWork();
void working();
- void setModel(QSqlRelationalTableModel* model);
+ //void setModel(QSqlRelationalTableModel* model);
QSqlDatabase getDB();
void submitAll();
void setFilter(const QString& filter);
@@ -31,6 +31,7 @@ class UserManageWork : public QObject
int getVerifyTag();
QString getUid();
bool isDisplay = false;
+ QSqlRelationalTableModel* getModel();
private slots:
@@ -46,6 +47,7 @@ private slots:
QTimer *heartBeat;
int verifyTag;
void getComboxItems();
+ QQueue modelQueue;
signals:
void userManageWorkFinished();
void queryAccountFinished(QSqlRecord);