Joyveb.GenLotWBOS.tmp.js_business = function() {
/* ----------------------- private属性 ----------------------- */
var grid, ds, panel;
var searchBtn;
var searchTbar, searchUname;
var addBtn, saveBtn, delBtn;
var addForm, addWindow;
var pageTbar, pageTextField, pageButton;
var buttonTbar;
/* ----------------------- private方法 ----------------------- */
/*
* 创建表格
*/
function createGrid() {
var recordDef = Ext.data.Record.create([ {
name : 'merchantid',
mapping : 'merchantid',
type : 'string'
}, {
name : 'merchantname',
mapping : 'merchantname',
type : 'string'
}, {
name : 'ipaddr',
mapping : 'ipaddr',
type : 'string'
}, {
name : 'wagerstatus',
mapping : 'wagerstatus',
type : 'string'
}, {
name : 'wagerstatushidden',
mapping : 'wagerstatus',
type : 'string'
}, {
name : 'merchantkey',
mapping : 'merchantkey',
type : 'string'
}, {
name : 'ftppath',
mapping : 'ftppath',
type : 'string'
}, {
name : 'ftpip',
mapping : 'ftpip',
type : 'string'
}, {
name : 'ftpuser',
mapping : 'ftpuser',
type : 'string'
}, {
name : 'ftppwd',
mapping : 'ftppwd',
type : 'string'
}, {
name : 'ftpport',
mapping : 'ftpport',
type : 'string'
}, {
name : 'msgurl',
mapping : 'msgurl',
type : 'string'
}, {
name : 'totalamount',
mapping : 'totalamount',
type : 'string'
}, {
name : 'key',
mapping : 'key',
type : 'string'
}, {
name : 'maxrecord',
mapping : 'maxrecord',
type : 'string'
}, {
name : 'maxwager',
mapping : 'maxwager',
type : 'string'
}, {
name : 'merchantprefix',
mapping : 'merchantprefix',
type : 'string'
}, {
name : 'allowamount',
mapping : 'allowamount',
type : 'string'
} , {
name : 'wagertype',
mapping : 'wagertype',
type : 'string'
}, {
name : 'paymenttype',
mapping : 'paymenttype',
type : 'string'
}, {
name : 'maxwagernum',
mapping : 'maxwagernum',
type : 'string'
}, {
name : 'maxwagertime',
mapping : 'maxwagertime',
type : 'string'
}, {
name : 'resulttype',
mapping : 'resulttype',
type : 'string'
}, {
name : 'encrypt',
mapping : 'encrypt',
type : 'string'
}]);
var sm = new Ext.grid.CheckboxSelectionModel({
handleMouseDown : Ext.emptyFn
}); // 将鼠标按下事件置空
panel = new Ext.Panel({
title : '设置权限',
frame : true,
height : 300,
width : 150,
items : [ new Ext.form.Checkbox({
boxLabel : '所有',
inputValue : '1'
}),new Ext.form.Checkbox({
boxLabel : '双色球',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '七乐彩',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '福彩3D',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '广西快乐双彩',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '广西快乐十分',
inputValue : '1'
}),new Ext.Button({
text : '确定',
width : 50,
handler : function() {
var allCheckbox = panel.getComponent(0);
var qgsltoCheckbox = panel.getComponent(1);
var qglotoCheckbox = panel.getComponent(2);
var bgpck3Checkbox = panel.getComponent(3);
var gxklscCheckbox = panel.getComponent(4);
var gxklsfCheckbox = panel.getComponent(5);
var authority = "";
if (qgsltoCheckbox.getValue()) {
authority += qgsltoCheckbox.inputValue;
} else {
authority += '0';
}
if (qglotoCheckbox.getValue()) {
authority += qglotoCheckbox.inputValue;
} else {
authority += '0';
}
if (bgpck3Checkbox.getValue()) {
authority += bgpck3Checkbox.inputValue;
} else {
authority += '0';
}
if (gxklscCheckbox.getValue()) {
authority += gxklscCheckbox.inputValue;
} else {
authority += '0';
}
if (gxklsfCheckbox.getValue()) {
authority += gxklsfCheckbox.inputValue;
} else {
authority += '0';
}
if (allCheckbox.getValue()) {
authority = '000001';
} else {
authority += '0';
}
if (authority == '111110' || authority == '11111') {
authority = '000001';
}
statusEditor.setValue(authority);
statusEditor.collapse();
}
}) ]
});
var statusEditor = new Ext.form.ComboBox(
{
editable : false,
name : 'status',
hiddenName : 'status',
width : 150,
mode : 'local',
triggerAction : 'all',
tpl : '<div id="statusPanel" style="height:100px;width:150px;"></div>',
store : new Ext.data.SimpleStore({
fields : [],
data : [ [] ]
})
});
statusEditor.on('expand', function() {
var allCheckbox = panel.getComponent(0);
var qgsltoCheckbox = panel.getComponent(1);
var qglotoCheckbox = panel.getComponent(2);
var bgpck3Checkbox = panel.getComponent(3);
var gxklscCheckbox = panel.getComponent(4);
var gxklsfCheckbox = panel.getComponent(5);
var sValue = statusEditor.getValue();
for ( var i = 0; i <= 5; i++) {
panel.getComponent(i).setValue(false);
}
while(sValue.length<6){
sValue="0"+sValue;
}
for ( var i = 0; i < sValue.length; i++) {
if (sValue.charAt(i) == '1' && i == 0) {
qgsltoCheckbox .setValue(true);
}
if (sValue.charAt(i) == '1' && i == 1) {
qglotoCheckbox .setValue(true);
}
if (sValue.charAt(i) == '1' && i == 2) {
bgpck3Checkbox .setValue(true);
}
if (sValue.charAt(i) == '1' && i == 3) {
gxklscCheckbox .setValue(true);
}
if (sValue.charAt(i) == '1' && i == 4) {
gxklsfCheckbox .setValue(true);
}
if (sValue.charAt(i) == '1' && i == 5) {
allCheckbox.setValue(true);
}
}
panel.doLayout();
panel.render('statusPanel');
});
var cm = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), sm, {
header : '商户代码',
sortable : false,
dataIndex : 'merchantid',
sortable : true
}, {
header : '商户名称',
sortable : false,
dataIndex : 'merchantname',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : false,
maxLength : 100
})
},
{
header : '销售状态',
sortable : true,
dataIndex : 'wagerstatus',
width : 150,
editor : statusEditor,
renderer : function(v, p, record, rowIndex) {
var sValue = v;
var rValue = "";
while(sValue.length<6){
sValue="0"+sValue;
}
for ( var i = 0; i < sValue.length; i++) {
if (sValue.charAt(i) == '1' && i == 0) {
rValue = "双色球,";
}
if (sValue.charAt(i) == '1' && i == 1) {
rValue = rValue + "七乐彩,";
}
if (sValue.charAt(i) == '1' && i == 2) {
rValue = rValue + "福彩3D,";
}
if (sValue.charAt(i) == '1' && i == 3) {
rValue = rValue + "广西快乐双彩,";
}
if (sValue.charAt(i) == '1' && i == 4) {
rValue = rValue + "广西快乐十分,";
}
if (sValue.charAt(i) == '1' && i == 5) {
rValue = "全部打开,";
}
}
if (rValue == "") {
return "全部关闭";
} else {
return rValue.substring(0, rValue.length - 1);
}
}
},{
dataIndex : 'wagerstatushidden',
hidden:true
},{
header : '商户安全码',
sortable : false,
dataIndex : 'merchantkey',
width : 145,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : false,
maxLength : 100
})
}, {
header : 'FTP文件目录',
sortable : false,
dataIndex : 'ftppath',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : false,
maxLength : 100
})
}, {
header : 'FTPIP',
sortable : false,
dataIndex : 'ftpip',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : 'FTPUSER',
sortable : false,
dataIndex : 'ftpuser',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : 'FTPPWD',
sortable : false,
dataIndex : 'ftppwd',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : 'FTPPRORT',
sortable : false,
dataIndex : 'ftpport',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '消息通知',
sortable : false,
dataIndex : 'msgurl',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '押金金额',
dataIndex : 'totalamount',
width : 120,
renderer : function (value){
return Ext.tools.RMBMoney(value/100);
}
},{
header : '每天最大投注限额',
dataIndex : 'allowamount',
width : 120,
renderer : function (value){
return Ext.tools.RMBMoney(value/100);
},
editor : new Ext.form.NumberField({
allowBlank : true,
maxLength : 100
})
}, {
header : '投注密钥',
dataIndex : 'key',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : 'RECORD最大数量',
dataIndex : 'maxrecord',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '期最大投注笔数',
dataIndex : 'maxwager',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '商户前缀',
dataIndex : 'merchantprefix',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '投注类型',
dataIndex : 'wagertype',
width : 120,
editor : new Ext.form.ComboBox({
width : 80,
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '多次投注' ], [ '1', '快速投注' ]]
})
}),
renderer:function(value)
{
if(value==0){
return '多次投注';
}else if(value==1){
return '快速投注';
}else
{
return value;
}
}
}
, {
header : '付款方式',
dataIndex : 'paymenttype',
width : 120,
editor : new Ext.form.ComboBox({
width : 80,
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '后付费' ], [ '1', '预付费' ]]
})
}),
renderer:function(value)
{
if(value==1){
return '预付费';
}else if(value==0){
return '后付费';
}else
{
return value;
}
}
}, {
header : '最大投注次数',
dataIndex : 'maxwagernum',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '最大投注时间(秒)',
dataIndex : 'maxwagertime',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '出票方式',
dataIndex : 'resulttype',
width : 120,
editor : new Ext.form.ComboBox({
width : 80,
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '整单成功/失败' ], [ '1', '部分成功/失败' ]]
})
}),
renderer:function(value)
{
if(value==1){
return '部分成功/失败';
}else if(value==0){
return '整单成功/失败';
}else
{
return value;
}
}
} ,{
header : '加密方式',
dataIndex : 'encrypt',
width : 120,
editor : new Ext.form.ComboBox({
width : 80,
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '未加密' ], [ '1', 'DES加密' ]]
})
}),
renderer:function(value)
{
if(value==1){
return 'DES加密';
}else if(value==0){
return '未加密';
}else
{
return value;
}
}
}, {
header : '商户注册ip',
sortable : false,
dataIndex : 'ipaddr',
align : 'center',
width : 100,
renderer : function(value, metadata, record, rowIndex,
colIndex, store) {
var contentId = Ext.id();
function createGridButton() {
return new Ext.Button({
text : '详情',
iconCls : 'select',
handler : function() {
createViewWindow(record);
}
}).render(document.body, contentId);
}
var btn = createGridButton.defer(1, this,
[ contentId ]);
return ('<div id="' + contentId + '"/>');
}
}
]);
ds = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : 'business__initList.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
*/
/*
* searchTbar searchUname,searchBtn
*/
searchTbar = [];
searchUname = new Ext.form.TextField({
// name : 'query_',
width : 100,
emptyText : '商户名称',
listeners : {
'specialkey' : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
search();
}
}
}
});
searchBtn = new Ext.Button({
text : '查询',
iconCls : 'select',
handler : search
});
searchTbar.push('搜索条件:', searchUname, '-', searchBtn);
buttonTbar = [];
addBtn = new Ext.Button({
text : '新增',
iconCls : 'add',
handler : function() {
createForm();
addWindow.show();
}
});
saveBtn = new Ext.Button({
text : '保存',
iconCls : 'update',
handler : save
});
delBtn = new Ext.Button({
text : '删除',
iconCls : 'delete',
handler : del
});
buttonTbar.push(addBtn, '-', saveBtn, '-', delBtn, '-');
}
function createPanel(statusCmb) {
var panel1 = new Ext.Panel({
title : '设置权限',
frame : true,
height : 300,
width : 150,
items : [ new Ext.form.Checkbox({
boxLabel : '所有',
inputValue : '1'
}),new Ext.form.Checkbox({
boxLabel : '双色球',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '七乐彩',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '福彩3D',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '广西快乐双彩',
inputValue : '1'
}), new Ext.form.Checkbox({
boxLabel : '广西快乐十分',
inputValue : '1'
}),new Ext.Button({
text : '确定',
width : 50,
handler : function() {
var allCheckbox = panel1.getComponent(0);
var qgsltoCheckbox = panel1.getComponent(1);
var qglotoCheckbox = panel1.getComponent(2);
var bgpck3Checkbox = panel1.getComponent(3);
var gxklscCheckbox = panel1.getComponent(4);
var gxklsfCheckbox = panel1.getComponent(5);
var authority = "";
if (qgsltoCheckbox.getValue()) {
authority += qgsltoCheckbox.inputValue;
} else {
authority += '0';
}
if (qglotoCheckbox.getValue()) {
authority += qglotoCheckbox.inputValue;
} else {
authority += '0';
}
if (bgpck3Checkbox.getValue()) {
authority += bgpck3Checkbox.inputValue;
} else {
authority += '0';
}
if (gxklscCheckbox.getValue()) {
authority += gxklscCheckbox.inputValue;
} else {
authority += '0';
}
if (gxklsfCheckbox.getValue()) {
authority += gxklsfCheckbox.inputValue;
} else {
authority += '0';
}
if (allCheckbox.getValue()) {
authority = '000001';
} else {
authority += '0';
}
if (authority == '111110' || authority == '11111') {
authority = '000001';
}
statusCmb.setValue(authority);
statusCmb.collapse();
}
})]
});
return panel1;
}
function statusPanelSettings(statusPanel, statusCmb) {
var allCheckbox = statusPanel.getComponent(0);
var qgsltoCheckbox = statusPanel.getComponent(1);
var qglotoCheckbox = statusPanel.getComponent(2);
var bgpck3Checkbox = statusPanel.getComponent(3);
var gxklscCheckbox = statusPanel.getComponent(4);
var gxklsfCheckbox = statusPanel.getComponent(5);
var sValue = statusCmb.getValue();
for ( var i = 0; i <= 5; i++) {
panel.getComponent(i).setValue(false);
}
for ( var i = 0; i < sValue.length; i++) {
if (sValue.charAt(i) == '1' && i == 0) {
qgsltoCheckbox .setValue(true);
}
if (sValue.charAt(i) == '1' && i == 1) {
qglotoCheckbox.setValue(true);
}
if (sValue.charAt(i) == '1' && i == 2) {
bgpck3Checkbox.setValue(true);
}
if (sValue.charAt(i) == '1' && i == 3) {
gxklscCheckbox.setValue(true);
}
if (sValue.charAt(i) == '1' && i == 4) {
gxklsfCheckbox.setValue(true);
}
if (sValue.charAt(i) == '1' && i == 5) {
allCheckbox.setValue(true);
}
}
return statusPanel;
}
/*
* 创建表单
*/
function createForm() {
// 状态下拉列表
var wagerStatusCmb = new Ext.form.ComboBox(
{
editable : false,
fieldLabel : '销售状态',
allowBlank : false,
name : 'business.wagerstatus',
hiddenName : 'business.wagerstatus',
width : 150,
mode : 'local',
triggerAction : 'all',
tpl : '<div id="saleStatusPanel" style="height:100px;width:150px;"></div>',
store : new Ext.data.SimpleStore({
fields : [],
data : [ [] ]
})
});
var panelSaleStatus = createPanel(wagerStatusCmb);
wagerStatusCmb.on('expand', function() {
panelSaleStatus = statusPanelSettings(panelSaleStatus,
wagerStatusCmb);
panelSaleStatus.doLayout();
panelSaleStatus.render('saleStatusPanel');
});
var merchantIdText = new Ext.form.TextField({
fieldLabel : '商户编码',
width : 100,
invalidText : '该商户编码已存在',
name : 'business.merchantid',
hiddenName : 'business.merchantid',
maxLength : 6,
minLength : 6,
vtype : 'alphanum',
allowBlank : false,
validateOnBlur : true,
validator : function(thisText) {
function createXhrObject() {
var http;
var activeX = [ 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP',
'Microsoft.XMLHTTP' ];
try {
http = new XMLHttpRequest();
} catch (e) {
for ( var i = 0; i < activeX.length; ++i) {
try {
http = new ActiveXObject(activeX[i]);
break;
} catch (e) {
}
}
} finally {
return http;
}
}
;
var conn = createXhrObject();
// 同步提交
conn.open("post", "business__checkMerchantId.action?vtext=" + thisText,
false);
conn.send(null);
if (conn.responseText != '') {
var res = Ext.util.JSON.decode(conn.responseText);
return res.valid;
} else {
return false;
}
}
});
var totalText = new Ext.form.NumberField({
fieldLabel : '押金金额',
width : 100,
name : 'business.totalamount',
hiddenName : 'business.totalamount',
allowBlank : false,
minValue : 0,
minText : '不能输入负数'
});
var maxRecord = new Ext.form.NumberField({
fieldLabel : 'RECORD最大数量',
width : 100,
name : 'business.maxrecord',
hiddenName : 'business.maxrecord',
allowBlank : false,
minValue : 0,
minText : '不能输入负数'
});
var maxWager = new Ext.form.NumberField({
fieldLabel : '期最大投注笔数',
width : 100,
name : 'business.maxwager',
hiddenName : 'business.maxwager',
allowBlank : false,
minValue : 0,
minText : '不能输入负数'
});
var wagerType = new Ext.form.ComboBox({
width : 100,
fieldLabel : '投注类型',
name : 'business.wagertype',
hiddenName : 'business.wagertype',
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '多次投注' ], [ '1', '快速投注' ]]
}),
listeners : {
'expand' : function() {
this.innerList.dom.style.overflowX = "auto"; // 改变横向overflow的样式,显示横向的滚动条
},
'select' : function(field, newValue, oldValue) {
if(field.value==0){
maxWagernum.show();
maxWagertime.reset();
maxWagertime.hide();
/*maxWagernum.enable();
maxWagertime.disable();*/
}else{
maxWagernum.reset();
maxWagernum.hide();
maxWagertime.show();
/*maxWagernum.disable();
maxWagertime.enable();*/
}
}
}
});
var paymentType = new Ext.form.ComboBox({
width : 100,
fieldLabel : '付款方式',
name : 'business.paymenttype',
hiddenName : 'business.paymenttype',
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '后付费' ], [ '1', '预付费' ]]
})
});
var resultType = new Ext.form. ComboBox({
width : 100,
fieldLabel : '出票方式',
name : 'business.resulttype',
hiddenName : 'business.resulttype',
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '整单成功/失败' ], [ '1', '部分成功/失败' ]]
})
});
var maxWagernum = new Ext.form.NumberField({
fieldLabel : '最大投注次数',
width : 100,
name : 'business.maxwagernum',
hiddenName : 'business.maxwagernum',
allowBlank : true,
minValue : 0,
minText : '不能输入负数'
});
var maxWagertime = new Ext.form.NumberField({
fieldLabel : '最大投注时间(秒)',
width : 100,
name : 'business.maxwagertime',
hiddenName : 'business.maxwagertime',
allowBlank : true,
minValue : 0,
minText : '不能输入负数'
});
var encrypt = new Ext.form. ComboBox({
width : 100,
fieldLabel : '加密方式',
name : 'business.encrypt',
hiddenName : 'business.encrypt',
mode : 'local',
triggerAction : 'all',
valueField : 'value',
displayField : 'text',
editable : true,
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '0', '未加密' ], [ '1', 'DES加密' ]]
})
});
addForm = new Ext.FormPanel(
{
url : 'business__save.action',
// defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 120,
// autoHeight : true,
bodyStyle : 'padding:5px',
border : false,
// fileUpload : true,
baseCls : 'x-plain',
items :
[
{
layout : 'table',
layoutConfig : {
columns : 2
},
items : [
{
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
editable : false,
baseCls : 'x-plain',
items : [ merchantIdText]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '商户名称',
width : 100,
name : 'business.merchantname',
hiddenName : 'business.merchantname',
allowBlank : false,
maxLength : 50
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '商户注册ip',
width : 100,
name : 'business.ipaddr',
hiddenName : 'business.ipaddr',
allowBlank : false,
maxLength : 50,
regex : /((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/,
regexText : '请输入正确的ip地址'
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ wagerStatusCmb]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {fieldLabel : '目录',
name : 'business.ftppath',
width : 100,
hiddenName : 'business.ftppath',
allowBlank : false,
maxLength : 200
}]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '商户安全码',
width : 100,
name : 'business.merchantkey',
hiddenName : 'business.merchantkey',
allowBlank : false,
maxLength : 50
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : 'FTPIP',
width : 100,
name : 'business.ftpip',
hiddenName : 'business.ftpip',
allowBlank : true,
maxLength : 50,
regex : /((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/,
regexText : '请输入正确的ip地址'
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '端口',
width : 100,
name : 'business.ftpport',
hiddenName : 'business.ftpport',
allowBlank : true,
maxLength : 50
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '用户名',
width : 100,
name : 'business.ftpuser',
hiddenName : 'business.ftpuser',
allowBlank : true,
maxLength : 50
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '密码',
width : 100,
name : 'business.ftppwd',
hiddenName : 'business.ftppwd',
allowBlank : true,
maxLength : 50
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [{
fieldLabel : '消息通知URL',
width : 100,
name : 'business.msgurl',
hiddenName : 'business.msgurl',
allowBlank : true,
maxLength : 500
}
]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '投注密钥',
width : 100,
name : 'business.key',
hiddenName : 'business.key',
allowBlank : true,
maxLength : 500
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ maxRecord ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ maxWager ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ {
fieldLabel : '商户前缀',
width : 100,
name : 'business.merchantprefix',
hiddenName : 'business.merchantprefix',
allowBlank : true,
maxLength : 500
} ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ wagerType ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ paymentType ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ maxWagernum ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ maxWagertime ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ resultType ]
}, {
colspan : 1,
layout : 'form',
frame : true,
defaultType : 'textfield',
border : false,
baseCls : 'x-plain',
items : [ encrypt ]
} ]
}
],
buttonAlign : 'center',
minButtonWidth : 60,
buttons : [ {
text : '添加',
handler : function(btn) {
if (addForm.getForm().isValid() == false) {
Ext.Msg.show({
title : '提示',
msg : '无法提交,请检查输入项!',
buttons : Ext.MessageBox.OK,
icon : Ext.Msg.INFO
});
return;
}
if (addForm.getForm().isValid()) {
btn.disable();
addForm.getForm().submit({
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
Ext.Msg.show({ title : '提示', msg :
'添加成功!!', buttons :
Ext.MessageBox.OK, icon :
Ext.Msg.INFO });
ds.reload();
addWindow.close();
},
failure : function(form, action) {
Ext.Msg.alert('错误', '添加失败!!');
}
});
btn.enable();
}
}
}, {
text : '重置',
handler : function() {
addForm.getForm().reset();
}
}, {
text : '取消',
handler : function() {
addWindow.close();
}
} ]
});
addWindow = new Ext.Window({
title : '添加',
//layout:'fit',
width : 650,
resizable : false,
autoHeight : true,
modal : true,
closeAction : 'hide',
items : [ addForm ]
});
}
function createViewWindow(record) {
Ext.lib.Ajax
.request('POST',
'business__searchipaddr.action?merchantid='
+ record.get("merchantid"), {
success : function(response) {
var viewWindow = new Ext.Window({
title : '详情',
width:500,
height:320,
autoWidth : false,
autoHeight : false,
//layout:'form',
resizable : false,
modal : true,
closeAction : 'hide'
});
var viewpanel = new Ext.Panel({
title : '',
frame : true,
autoWidth : true,
autoHeight : true
});
var checkpanel = new Ext.Panel({
title : '',
frame : true,
height : 200,
autoWidth : true,
autoHeight : false,
autoScroll : true
});
var checkedBoxs = new Array();
checkedBoxs[0]=checkpanel;
var ipaddrs;
ipaddrs=response.responseText;
if(ipaddrs==null||ipaddrs==""){
}else{
var splitstr=":";
var strarray=ipaddrs.split(splitstr);
var i=0;
var firstbox=new Ext.form.Checkbox({
boxLabel : '全选/全不选',
inputValue : '全选'
});
firstbox.on('check',function(){
if(firstbox.getValue()){
for(var i=0;i<myCheckbox.items.keys.length;i++){
myCheckbox.items.item(myCheckbox.items.keys[i]).setValue(true);
}
}else{
for(var i=0;i<myCheckbox.items.keys.length;i++){
myCheckbox.items.item(myCheckbox.items.keys[i]).setValue(false);
}
}
});
checkpanel.add(firstbox);
var myCheckbox = new Ext.form.CheckboxGroup({
xtype: 'checkboxgroup',
fieldLabel: 'Double Column',
columns: 2,
items:[{
xtype: 'checkbox',
fieldLabel: 'Auto Layout'
}
]
});
for (i;i<strarray.length;i++){
var checkedBox=new Ext.form.Checkbox({
boxLabel : strarray[i],
inputValue : strarray[i]
});
myCheckbox.items[i]=checkedBox;
}
checkpanel.add(myCheckbox);
}
checkedBoxs[1]=new Ext.Button({
text : '删除',
width : 50,
handler : function() {
var count=0;
for(var i=0;i<myCheckbox.items.keys.length;i++){
if(myCheckbox.items.item(myCheckbox.items.keys[i]).getValue()){
count++;
}
}
if(count!=0){
var ipCheckboxArray="";
for (var j=0;j<myCheckbox.items.keys.length;j++){
var ipCheckbox=myCheckbox.items.item(myCheckbox.items.keys[j]);
if (!ipCheckbox.getValue()) {
if(ipCheckboxArray!=""){
ipCheckboxArray += splitstr+ipCheckbox.inputValue;
}else{
ipCheckboxArray+=ipCheckbox.inputValue;
}
}
}
Ext.lib.Ajax
.request('POST',
'business__updateipaddr.action?merchantid='
+ record.get("merchantid"), {
success : function(response) {
Ext.Msg.alert("正确", "删除成功!");
checkpanel.removeAll();
ipaddrs=response.responseText;
if(ipaddrs==null||ipaddrs==""){
}else{
var splitstr=":";
var strarray=ipaddrs.split(splitstr);
var i=0;
var firstbox=new Ext.form.Checkbox({
boxLabel : '全选/全不选',
inputValue : '全选'
});
firstbox.on('check',function(){
if(firstbox.getValue()){
for(var i=0;i<myCheckbox.items.keys.length;i++){
myCheckbox.items.item(myCheckbox.items.keys[i]).setValue(true);
}
}else{
for(var i=0;i<myCheckbox.items.keys.length;i++){
myCheckbox.items.item(myCheckbox.items.keys[i]).setValue(false);
}
}
});
checkpanel.add(firstbox);
myCheckbox = new Ext.form.CheckboxGroup({
xtype: 'checkboxgroup',
fieldLabel: 'Double Column',
columns: 2,
items:[{
xtype: 'checkbox',
fieldLabel: 'Auto Layout'
}
]
});
for (i;i<strarray.length;i++){
var checkedBox=new Ext.form.Checkbox({
boxLabel : strarray[i],
inputValue : strarray[i]
});
myCheckbox.items[i]=checkedBox;
}
checkpanel.add(myCheckbox);
ds.reload();
checkpanel.doLayout();
}
},
failure : function() {
Ext.Msg.alert("错误",
"与后台联系的时候出现了问题!");
}
}, '&ipaddr=' + ipCheckboxArray);
}else{
Ext.Msg.alert("错误","请选择要删除的IP");
}
}
});
var textfield=new Ext.form.TextField({
allowBlank : false,
maxLength : 100,
regex : /((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/,
regexText : '请输入正确的ip地址'
});
var obutton = new Ext.Button({
text : '添加新IP',
iconCls : 'insert',
handler : insertNewInterface
});
function insertNewInterface() {
if(textfield.getValue().trim()!=""){
if(textfield.isValid()){
Ext.lib.Ajax
.request('POST',
'business__searchipaddr.action?merchantid='
+ record.get("merchantid"), {
success : function(response) {
var ipaddrs;
var splitstr=":";
var ipstr=response.responseText;
if(ipstr==""||ipstr==null){
ipaddrs=textfield.getValue().trim();
}else{
ipaddrs=ipstr+splitstr+textfield.getValue().trim();
}
Ext.lib.Ajax
.request('POST',
'business__updateipaddr.action?merchantid='
+ record.get("merchantid"), {
success : function(response) {
Ext.Msg.alert("正确", "添加成功!");
ipaddrs=response.responseText;
checkpanel.removeAll();
var splitstr=":";
var strarray=ipaddrs.split(splitstr);
var i=0;
var firstbox=new Ext.form.Checkbox({
boxLabel : '全选/全不选',
inputValue : '全选'
});
firstbox.on('check',function(){
if(firstbox.getValue()){
for(var i=0;i<myCheckbox.items.keys.length;i++){
myCheckbox.items.item(myCheckbox.items.keys[i]).setValue(true);
}
}else{
for(var i=0;i<myCheckbox.items.keys.length;i++){
myCheckbox.items.item(myCheckbox.items.keys[i]).setValue(false);
}
}
});
checkpanel.add(firstbox);
myCheckbox = new Ext.form.CheckboxGroup({
xtype: 'checkboxgroup',
fieldLabel: 'Double Column',
columns: 2,
items:[{
xtype: 'checkbox',
fieldLabel: 'Auto Layout'
}
]
});
for (i;i<strarray.length;i++){
var checkedBox=new Ext.form.Checkbox({
boxLabel : strarray[i],
inputValue : strarray[i]
});
myCheckbox.items[i]=checkedBox;
}
checkpanel.add(myCheckbox);
ds.reload();
checkpanel.doLayout();
},
failure : function() {
Ext.Msg.alert("错误",
"与后台联系的时候出现了问题!");
}
}, '&ipaddr=' +ipaddrs );
},
failure : function() {
Ext.Msg.alert("错误",
"与后台联系的时候出现了问题!");
}
},'');
}else{
Ext.Msg.alert("错误","输入的IP有误");
}}else{
Ext.Msg.alert("错误","请输入要添加的IP");
}
}
viewpanel.add(textfield);
viewpanel.add(obutton);
viewpanel.add(checkedBoxs);
viewWindow.add(viewpanel);
viewWindow.show();
},
failure : function() {
Ext.Msg.alert("错误",
"与后台联系的时候出现了问题!");
}
},'');
}
/*--------------------功能方法--------------------*/
// search
function search() {
// 清除原有记录,否则未出现新结果时会显示原先存在的数据
ds.removeAll();
ds.baseParams = {
merchantname : searchUname.getValue()
};
ds.load({
params : {
start : 0,
limit : pageSize
}
});
}
// delete
function del() {
var records = grid.getSelectionModel().getSelections();
if (records.length > 0) {
var jsondata_newsid = "";
for (i = 0; i < records.length; i++) {
if (i == 0) {
jsondata_newsid += records[i].get("merchantid");
} else {
jsondata_newsid += "," + records[i].get("merchantid");
}
}
Ext.Msg.confirm('确认删除', '你确定删除选中的记录?', function(btn) {
if (btn == 'yes') {
Ext.Ajax.request({
url : 'business__delete.action',
params : {
ids : jsondata_newsid
},
success : function() {
/*
* for(i=0; i<records.length; i++){
* grid.getStore().remove(records[i]); }
*/
ds.reload();
},
failure : function() {
Ext.Msg.show({
title : '错误提示',
msg : '删除时发生错误!',
buttons : Ext.Msg.OK,
icon : Ext.Msg.ERROR
});
}
});
}
});
} else {
Ext.Msg.alert('信息', '请选择需要删除的记录!');
}
}
// 保存
function save() {
// var m = ds.modified.slice(0);
var m = grid.getSelectionModel().getSelections();
var jsonArray = [];
Ext.each(m, function(item) {
jsonArray.push(item.data);
});
if (jsonArray.length > 0) {
Ext.lib.Ajax.request('POST', 'business__update.action', {
success : function(response) {
Ext.Msg.alert("提示", "保存成功!");
ds.reload();
},
failure : function() {
Ext.Msg.alert("错误", "与后台联系的时候出现了问题!");
}
}, 'data=' + encodeURIComponent(Ext.encode(jsonArray)));
}
}
function dateRenderer(value) {
if (value != null) {
return new Date(value.time).format('Y-m-d');
} else {
return null;
}
}
/* ----------------------- public方法 ----------------------- */
return {
show : function() {
// 创建工具栏和搜索栏
createToolbar();
// 创建Grid
createGrid();
// 执行查询
search();
return grid;
}
};
}();