Joyveb.GenLotWBOS.fallGroundBussiness.js_controlPre= function(){
/* ----------------------- private属性 ----------------------- */
var grid, ds;
var searchBtn,dcBtn;
var searchTbar,searchStartNum,searchEndNum,searchKey,searchValue;
var impGameInfo,oneKeyImp;
var addForm,addWindow;
var addBtn, saveBtn, delBtn;
var pageTbar, pageTextField, pageButton;
var buttonTbar,searchPlat,searchFKey;
var gameCodeValue,qhCmb,ssqData;
var searchGameName,awardNum;
var gameMap,task_CheckState;
var allGameDS = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
'url' : 'gameinfo__listGames.action',
'method' : 'post'
}),
reader : new Ext.data.JsonReader({}, [ {
name : 'value'
}, {
name : 'text'
} ])
});
var qhCmb = new Ext.data.JsonStore({
fields : [ 'value', 'text', 'status' ],
url : 'drawNumber__loadNowCmb.action'
});
task_CheckState = {
run: check,//执行任务时执行的函数
interval: 10000//任务间隔,毫秒为单位,这里是10秒
};
/* ----------------------- private方法 ----------------------- */
//发送请求获取游戏名称
Ext.Ajax.request({
url:'gameinfo__listGames.action',
method:'post',
callback:function(options,success,request)
{
gameMap=Ext.util.JSON.decode(request.responseText);
}
});
/* ----------------------- private方法 ----------------------- */
/*
*创建表格
*/
function createGrid() {
var recordDef = Ext.data.Record.create([
{
name : 'seq',
mapping : 'seq',
type : 'long'
},
{
name : 'money',
mapping : 'money',
type : 'string'
}
]);
var sm = new Ext.grid.CheckboxSelectionModel({
handleMouseDown : Ext.emptyFn
}); //将鼠标按下事件置空
var cm = new Ext.grid.ColumnModel([
sm,
new Ext.grid.RowNumberer(),
{
header : 'seq',
dataIndex : 'seq',
width: 85,
hidden : true
},
{
header : '金额',
dataIndex : 'money',
width: 85,
hidden:true
}
]);
ds = new Ext.data.Store( {
proxy : new Ext.data.HttpProxy( {
url : 'calprize__calPrize.action'
}),
reader : new Ext.data.JsonReader( {
root : 'data',
totalProperty : 'totalCount',
successProperty: 'success'
}, recordDef),
remoteSort : false
});
pageTextField = new Ext.form.NumberField( {
width : 100,
minValue:1,
maxValue:maxPageSize,
allowNegative:false,
allowDecimals:false,
emptyText : pageSize,
listeners : {
'specialkey' : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
pageSize = pageTextField.getValue();
pageTbar.pageSize = pageSize;
if(pageTextField.isValid()==false)
{
return;
}
search();
}
}
}
});
pageButton = new Ext.Button( {
text : '确定',
handler : function() {
if(pageTextField.isValid()==false)
{
return;
}
pageSize = pageTextField.getValue();
pageTbar.pageSize = pageSize;
search();
}
});
pageTbar = new Ext.PagingToolbar( {
pageSize : pageSize,
store : ds,
displayInfo : true
});
pageTbar.addSeparator();
pageTbar.addText("每页显示");
pageTbar.addItem(pageTextField);
pageTbar.addText("条");
pageTbar.addButton(pageButton);
var config = {
border:false,
pruneModifiedRecords: true,
store : ds,
sm : sm,
cm : cm,
enableHdMenu :false,
loadMask : {
msg : '正在算奖...'
},
clicksToEdit : 1,
stripeRows:true,
tbar: searchTbar,
bbar : pageTbar,
listeners : {
'render' : function() {
var ttbar = new Ext.Toolbar({
items : buttonTbar
});
ttbar.render(grid.tbar);
},
'afteredit':function(obj){
var _index=ds.indexOf(obj.record);
grid.getSelectionModel().selectRow(_index, true);
}
}
};
grid = new Ext.grid.EditorGridPanel(config);
}
/*
*创建工具条按钮
*/
function createToolbar() {
//--------------------------------------------------------------------------
/*
* buttonTbar
* addBtn,saveBtn,editBtn,delBtn,incomeBtn,outcomeBtn
*/
buttonTbar = [];
/*
* searchTbar
* searchUname,searchBtn
*/
searchTbar = [];
allGameDS.on('load', function(ds, records, o) {
if (records.length > 0) {
searchGameName.setValue(records[0].data.value);
}
});
searchGameName = new Ext.form.ComboBox({
store : allGameDS,
width : 80,
mode : 'remote',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : false,
listeners : {
'select':function(){
changePeriod();
},
'specialkey' : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
search();
}
}
}
});
qhCmb.on('load', function(ds, records, o) {
if (records.length > 0) {
searchStartNum.setValue(records[0].data.value);
}
});
// 期号
searchStartNum = new Ext.form.ComboBox({
store : qhCmb,
triggerAction : 'all',
width : 80,
mode : 'local',
allowBlank : false,
valueField : 'value',
displayField : 'text',
listeners : {
'specialkey' : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
search();
}
}
}
});
awardNum = new Ext.form.TextField({
width : 120,
allowBlank : true,
disabled : false
});
searchBtn = new Ext.Button({
text : '算奖',
iconCls : 'select',
handler : search
});
searchTbar.push('游戏:',searchGameName,'-','期号:',searchStartNum,'-','开奖号码:',awardNum,'(格式:01|02|23|24|25|26-05或4|9|0)','-',searchBtn);
}
/*--------------------功能方法--------------------*/
function changePeriod() {
searchStartNum.clearValue();
qhCmb.load({
params : {
ltype : searchGameName.getValue(),
startDate : new Date().format('Y-m-d'),
endDate : new Date().format('Y-m-d')
}
});
}
// search
function search(){
if (awardNum.getValue()==''||awardNum.isValid() == false) {
Ext.Msg.show({
title : '提示',
msg : '号码输入不正确!',
buttons : Ext.MessageBox.OK,
icon : Ext.Msg.INFO
});
return;
}
ds.removeAll();
/* ds.baseParams = {
searchGameName:searchGameName.getValue(),
searchStartNum : searchStartNum.getValue(),
awardNum : awardNum.getValue()
};
ds.load({
params : {
start : 0,
limit : pageSize
}
});*/
Ext.Ajax.request({
url : 'calprize__calPrize.action',
params : {
searchGameName:searchGameName.getValue(),
searchStartNum : searchStartNum.getValue(),
awardNum : awardNum.getValue()
},
success : function(response) {
Ext.MessageBox.show({
title: '',
msg: '确认算奖',
buttons: Ext.Msg.OK,
fn: function(btn, text){
if (btn == 'ok') {
var myMask = new Ext.LoadMask(Ext.getBody(), {
msg: '正在算奖,请稍后!',
removeMask: true //完成后移除
});
Ext.TaskMgr.start(task_CheckState);//初始化时就启动任务
myMask.show();
}
}
});
},
failure : function() {
Ext.Msg.show({
title : '错误提示',
msg : '发生错误!',
buttons : Ext.Msg.OK,
icon : Ext.Msg.ERROR
});
}
});
}
function check(){
Ext.Ajax.request({
url: 'calprize__waitPrize.action',
disableCaching: true,//是否禁用缓存,当然要禁用
timeout: 10000,//最大等待时间,超出则会触发超时
params : {
searchGameName:searchGameName.getValue(),
searchStartNum : searchStartNum.getValue(),
awardNum : awardNum.getValue()
},
success: function(response, option){//ajax请求发送成功时执行
if (!response || response.responseText == '') {//返回的内容为空,即服务器停止响应时
myMask.hide();
Ext.TaskMgr.stop(task_CheckState);
Ext.MessageBox.show({
title: '错误',
msg: '算奖发生错误',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
/* fn: function(btn, text){
if (btn == 'ok') {
}
}*/
});
return;
} else {
result = response.responseText;
if (result == 'success') {
myMask.hide();
Ext.TaskMgr.stop(task_CheckState);
Ext.MessageBox.show({
title: '',
msg: '算奖成功',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.INFO
});
return false;
}else if(result == 'fail'){
myMask.hide();
Ext.TaskMgr.stop(task_CheckState);
Ext.MessageBox.show({
title: '',
msg: '算奖失败',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.INFO
});
return false;
}
}
},
failure: function(data){
myMask.hide();//ajax请求发送失败或超时
Ext.TaskMgr.stop(task_CheckState);
Ext.MessageBox.show({
title: '错误',
msg: '发生网络错误',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
}
});
}
function sleep(n)
{
var start=new Date().getTime();
while(true){
if(new Date().getTime()-start> n){
break;
}
}
}
/* ----------------------- public方法 ----------------------- */
return {
show:function(){
// 创建工具栏和搜索栏
createToolbar();
// 创建Grid
createGrid();
// 执行查询
//search();
return grid;
}
};
}();