定时任务显示表格的基类

定时任务显示的基类
eams.dc.taskMK.TaskItemGrid = Ext.extend(Ext.grid.GridPanel, {
myInfoPanel : null,
mystore : null,
myPStore: null,
actions : null,
searchValue : ' ',
constructor : function(_cfg) {
this.actions = [new Ext.Action({
text : '查询',
iconCls : 'db-icn-back',
handler : function() {
this.onSearch();
},
scope : this
})];
this.myPStore = this.getMyPStore();
this.mystore = this.getStore();

var _tmpcfg = {
border : 0,
autoScroll : true,
clicksToEdit : 0,
cm : this.getCM(),
store : this.mystore,
selModel : new Ext.grid.RowSelectionModel({
singleSelect : true
}),// 设置单行选中模式, 否则将无法删除数据
tbar : [{
xtype : 'label',
text : '任务项名称:'
}, {
xtype : 'textfield',
width : 300,
id : 'srchField'
}, this.actions[0]]
};
var __cfg = Ext.applyIf(_cfg,_tmpcfg);
eams.dc.taskMK.TaskItemGrid.superclass.constructor.call(this, __cfg);
},
onSearch : function() {
var store = this.mystore;
var toolBar = Ext.get('srchField');
this.searchValue = toolBar.getValue();

if(this.searchValue==null||this.searchValue=='undefined') this.searchValue=' ';
store.proxy = new Ext.data.HttpProxy({
url : 'TaskItemAction?op=query&ex=' + encodeURI(this.searchValue)
});
store.load();
},
//var records = this.getSelectionModel().getSelections();
getCM : function() {
var self = this;
return new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer({
header : '序号',
width : 35
}), {
header : '标识',
dataIndex : 'uri',
width:150,
editable : false,
hidden:true
}, {
header : '任务项名称',
dataIndex : 'name',
width:150,
sortable : true
},

{
header : '终端协议标识',
dataIndex : 'protocolUri',
width:200,
renderer: function(v){
if(v){
var comboxStore = self.myPStore;
var index = comboxStore.find('uri',v);
if(index<0) return;
return comboxStore.getAt(index).get('name');
}
}
},

{
header : '终端数据单元',
dataIndex : 'termBuff',
width:150,
editor : new Ext.form.TextField({
allowBlank : false
})
},
{
header : '表计协议标识',
dataIndex : 'ammeterProtocolUri',
width:200,
renderer: function(v){
if(v){
var comboxStore = self.myPStore;
var index = comboxStore.find('uri',v);
if(index<0) return;
return comboxStore.getAt(index).get('name');
}
}
},
{
header : '表计数据单元',
dataIndex : 'ammeterBuff',
width:150,
editor : new Ext.form.TextField({
allowBlank : false
})
}]);
},
getStore : function() {
var store = new Ext.data.JsonStore({
url : 'TaskItemAction?op=query',
method : 'POST',
root : 'datas',
fields : ['name', 'uri', 'termBuff', 'ammeterBuff','protocolUri','ammeterProtocolUri'],
totalProperty : 'totalProperty'
});

store.load();

return store;
},
getMyPStore:function()
{
var store = new Ext.data.JsonStore({ // 填充的数据
fields : ['name','uri'],
url:'ProtocolAction',
root:'PList',
method:'POST'
});
store.load();//实例化时即加载,这样mode:可以设置成local
return store;
}
});
#ifndef TASKWIDGET_H #define TASKWIDGET_H #include <QWidget> #include <QMap> #include <QVector> #include <QList> #include <QMenu> #include <QAction> #include "../protocol.h" #include "../table/taskinfo.h" #include <QSet> #include <QTimer> #include <QMutex> namespace Ui { class TaskWidget; } class TaskWidget : public QWidget { Q_OBJECT public: enum Task { TASK_NAME, TASK_ID, TASK_TIME, TASK_IS_PERIOD, TASK_PERIOD_TIME, TASK_SEND_TIME, TASK_SEND_MODE, TASK_REMAINING_TIME, TASK_STATE }; Q_ENUM(Task) public: explicit TaskWidget(QWidget *parent = nullptr); ~TaskWidget(); void setTaskState(int newTaskState); signals: void handleScheduledTask(int taskId); void startScheduledTask(); public slots: void addRoute(const QVector<RoutePoint>& route); private slots: void appendTaskSetting(const QString &taskName, const QString &taskID, const QString & taskTime, bool period, const QString & periodTime, int sendMode = 0); void updateTaskSetting(const QString &taskName, const QString &taskID, const QString & taskTime, bool period, const QString & periodTime, int sendMode = 0); /** * @brief showContextMenuOnTableWidget 右键显示菜单 * @param pos */ void showContextMenuOnTableWidget(const QPoint &pos); void deleteSelectedRows(); void editSelectedRows(); void sendNonScheduledTask(); void manStopSendNonScheduledTask(); void manAdddedTaskRouteToServer(); /** * @brief updateTaskRemainingTime 计算任务开始剩余时间 */ void updateTaskStartRemainingTime(); private: void initTaskTableSetting(); void initTaskTableContent(); void showTaskSettingWidget(); void addTaskRow(const TaskInfo& taskInfo); QList<int> getSelectedRows(); void initMenu(); void sendCurTaskRoute(); private: Ui::TaskWidget *ui; private: QSet<int> m_taskIdRecorder; TaskInfo m_curTaskInfo; int m_maxRowCount; QTimer m_timer; QMutex m_mutex; // 任务执行状态, 0: 执行中; 1:未执行 int m_taskState; // 当前执行任务行号 int m_curTaskRowNum; private: QMenu m_menu; }; #endif // TASKWIDGET_H 注释上述代码
09-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值