Joyveb.jlbos.gameParams.js_merchant = function() {
/* ----------------------- private属性 ----------------------- */
var grid, ds, panel;
var searchBtn;
var pageSize = 20;
var searchTbar, searchUname;
var addBtn, saveBtn, delBtn, impGameInfo, oneKeyImp;
var addForm, addWindow;
var pageTbar, pageTextField, pageButton;
var buttonTbar, searchPlat, searchFKey;
var gridDSURL='merchant__initList.action';
var updateDSURL='merchant__update.action';
var deleteDSURL='merchant__delete.action';
/* ----------------------- private方法 ----------------------- */
/*
* 创建表格
*/
function createGrid() {
//定义每一行显示的字段,其中mapping为json传入时的名称
var recordDef = Ext.data.Record.create([ {
name : 'merchantnum',
mapping : 'merchantnum',
type : 'string'
}, {
name : 'merchantname',
mapping : 'merchantname',
type : 'string'
}, {
name : 'ipaddr',
mapping : 'ipaddr',
type : 'string'
}, {
name : 'ftppath',
mapping : 'ftppath',
type : 'string'
}, {
name : 'ftpip',
mapping : 'ftpip',
type : 'string'
}, {
name : 'ftpport',
mapping : 'ftpport',
type : 'string'
}, {
name : 'ftpuser',
mapping : 'ftpuser',
type : 'string'
}, {
name : 'ftppwd',
mapping : 'ftppwd',
type : 'string'
}, {
name : 'merchantkey',
mapping : 'merchantkey',
type : 'string'
}, {
name : 'totalAmount',
mapping : 'totalAmount',
type : 'double'
}, {
name : 'msgurl',
mapping : 'msgurl',
type : 'string'
},{
name : 'merchantPrefix',
mapping : 'merchantPrefix',
type : 'string'
}, {
name : 'isWagerControl',
mapping : 'isWagerControl',
type : 'string'
}, {
name : 'ordermerchant',
mapping : 'ordermerchant',
type : 'short'
}, {
name : 'ifacedetails',
mapping : 'ifacedetails',
type : 'string'
}, {
name : 'queuedetails',
mapping : 'queuedetails',
type : 'string'
},
{
name : 'ifacetype',
mapping : 'ifacetype',
type : 'string'
},
{
name : 'pattern',
mapping : 'pattern',
type : 'string'
}
]);
var sm = new Ext.grid.CheckboxSelectionModel({
handleMouseDown : Ext.emptyFn
}); // 将鼠标按下事件置空
//定义列模式(行号和列头)
var cm = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), sm, {
header : '商户编号',
sortable : false,
dataIndex : 'merchantnum',
sortable : true
}, {
header : '商户名称',
sortable : false,
dataIndex : 'merchantname',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : false,
maxLength : 100
})
}, {
header : '商户注册ip',
sortable : false,
dataIndex : 'ipaddr',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : false,
maxLength : 100
})
},{
header : '目录',
sortable : false,
dataIndex : 'ftppath',
width : 145,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : false,
maxLength : 100
})
}, {
header : '商户安全码',
sortable : false,
dataIndex : 'merchantkey',
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 : '端口',
sortable : false,
dataIndex : 'ftpport',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '用户名',
sortable : false,
dataIndex : 'ftpuser',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '密码',
sortable : false,
dataIndex : 'ftppwd',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '消息通知URL',
sortable : false,
dataIndex : 'msgurl',
width : 100,
sortable : true,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
}, {
header : '押金金额(分)',
dataIndex : 'totalAmount',
width : 120,
editor : new Ext.form.NumberField({
allowBlank : true,
maxLength : 100
})
}, {
header : '投注卡号前缀',
dataIndex : 'merchantPrefix',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
} ,{
header : '是否是大商户',
dataIndex : 'isWagerControl',
width : 120,
editor : new Ext.form.ComboBox({
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '1', '是' ],['0', '否'] ]
}),
triggerAction : 'all',
mode : 'local',
width : 70,
value : '0',
valueField : 'value',
displayField : 'text'
}),
renderer : function(v, p, record, rowIndex) {
if (v == "0") {
return "否";
}
if (v == "1") {
return "是";
}
}
}, {
header : '排序号',
dataIndex : 'ordermerchant',
width : 120,
editor : new Ext.form.TextField({
allowBlank : true,
maxLength : 100
})
},
{
header : '商户通信接口方式',
dataIndex : 'ifacetype',
width : 120,
editor : new Ext.form.ComboBox({
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '1', '异步' ],['0', '同步'] ]
}),
triggerAction : 'all',
mode : 'local',
width : 70,
value : '0',
valueField : 'value',
displayField : 'text'
}),
renderer : function(v, p, record, rowIndex) {
if (v == "0") {
return "同步";
}
if (v == "1") {
return "异步";
}
}
},
{
header : '商户付费模式',
dataIndex : 'pattern',
width : 120,
editor : new Ext.form.ComboBox({
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '1', '后付费' ],['0', '预付费'] ]
}),
triggerAction : 'all',
mode : 'local',
width : 70,
value : '0',
valueField : 'value',
displayField : 'text'
}),
renderer : function(v, p, record, rowIndex) {
if (v == "0") {
return "预付费";
}
if (v == "1") {
return "后付费";
}
}
},{
header : '接口详情',
dataIndex : 'ifacedetails',
align : 'center',
width : 100,
renderer : function(value, metadata, record, rowIndex,
colIndex, store) {
if (record.get("merchantnum") == '') {
return "";
} else {
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 + '"/>');
}
},
sortable : false
}, {
header : '队列详情',
dataIndex : 'queuedetails',
align : 'center',
width : 100,
renderer : function(value, metadata, record, rowIndex,
colIndex, store) {
if (record.get("merchantnum") == '') {
return "";
} else {
var contentId = Ext.id();
function createGridButton() {
return new Ext.Button({
text : '队列详情',
iconCls : 'select',
handler : function() {
createViewWindowS(record);
}
}).render(document.body, contentId);
}
var btn = createGridButton.defer(1, this,
[ contentId ]);
return ('<div id="' + contentId + '"/>');
}
},
sortable : false
} ]);
ds = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : gridDSURL
}),
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 = Ext.tools.components.getSearchBtn();
searchBtn.setHandler(search);
searchTbar.push('搜索条件:', searchUname, '-', searchBtn);
buttonTbar = [];
addBtn = new Ext.Button({
text : '新增',
iconCls : 'add',
handler : function() {
createForm();
addWindow.show();
}
});
//保存按钮
saveBtn = Ext.tools.components.getSaveBtn();
saveBtn.setHandler(save);
//删除按钮
delBtn = Ext.tools.components.getDelBtn();
delBtn.setHandler(del);
//将组件放入工具条
buttonTbar.push(addBtn, '-', saveBtn, '-', delBtn, '-');
}
/*
* 创建表单
*/
function createForm() {
// 状态下拉列表
var saleStatusCmb = new Ext.form.ComboBox(
{
editable : false,
fieldLabel : '状态',
allowBlank : false,
name : 'status',
hiddenName : 'status',
width : 150,
mode : 'local',
triggerAction : 'all',
store : new Ext.data.SimpleStore({
fields : ['value','text'],
data : [ ['1','正常投注'],['0','关闭投注'] ]
}),
valueField : 'value',
value:0,
displayField : 'text',
editable : false
});
var notifyStatusCmb = new Ext.form.ComboBox(
{
editable : false,
fieldLabel : '通知状态',
allowBlank : false,
name : 'notifyStatus',
hiddenName : 'notifyStatus',
width : 150,
mode : 'local',
triggerAction : 'all',
store : new Ext.data.SimpleStore({
fields : ['value','text'],
data : [ ['0','初始化状态'],['1','已入库未通知'],['2','正在通知'],['3','通知成功'],['4','通知失败'],['5','通知超时丢弃'],['6','通知返回失败'] ]
}),
valueField : 'value',
value:0,
displayField : 'text',
editable : false
});
var merchantNumText = new Ext.form.TextField({
fieldLabel : '商户编码',
invalidText : '该商户编码已存在',
name : 'merchantnum',
hiddenName : 'merchantnum',
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", "merchant__check?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 : '押金金额',
name : 'totalAmount',
hiddenName : 'totalAmount',
allowBlank : false,
minValue : 0,
minText : '不能输入负数'
});
var isWagerControlCmp = new Ext.form.ComboBox({
fieldLabel : '是否为大商户',
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '1', '是' ], [ '0', '否' ] ]
}),
name:'isWagerControl',
hiddenName : 'isWagerControl',
mode : 'local',
triggerAction : 'all',
valueField : 'value',
value:0,
displayField : 'text',
editable : false
});
var ifacetype = new Ext.form.ComboBox({
fieldLabel : '商户通信接口方式',
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '1', '异步' ], [ '0', '同步' ] ]
}),
name:'ifacetype',
hiddenName : 'ifacetype',
mode : 'local',
triggerAction : 'all',
valueField : 'value',
value:0,
displayField : 'text',
editable : false
});
var pattern = new Ext.form.ComboBox({
fieldLabel : '商户付费模式',
store : new Ext.data.SimpleStore({
fields : [ 'value', 'text' ],
data : [ [ '1', '后付费' ], [ '0', '预付费' ] ]
}),
name:'pattern',
hiddenName : 'pattern',
mode : 'local',
triggerAction : 'all',
valueField : 'value',
value:0,
displayField : 'text',
editable : false
});
//添加接口
var treeIface = new Ext.tree.TreePanel({
title : '接口',
split : true,
frame:false,
border : true,
collapsible : true,
width : 250,
minSize : 80,
maxSize : 250,
enableDD : true,
autoScroll : true,
loader : new Ext.tree.TreeLoader({
//applyLoader : true,
url : 'merchant__loadAddFormIface.action'
}),
root: new Ext.tree.AsyncTreeNode( {
id : "0",
text : "添加接口"
}),
rootVisible: false,
listeners : {
checkchange : function(node, event) {
//获取所有子节点 (全选 或 全部取消)
node.expand();
node.cascade( function( node ){
node.attributes.checked = event;
node.ui.checkbox.checked = event;
return true;
});
// var pnode = node.parentNode;
// var child = pnode.childNodes;
// var ch = child.childNodes;
// if(node.attributes.id != 0){
// node.eachChild(function(child) {
// child.ui.toggleCheck(event);
// child.attributes.checked = event;
// child.fireEvent('checkchange', child, event);
// });
// }
var parentNode = node.parentNode;
var childs = parentNode.childNodes;// 获得子节点
//获取所有父节点
for(; parentNode.id !="0"; parentNode = parentNode.parentNode ){
if (event) {
parentNode.ui.checkbox.checked = event;
parentNode.attributes.checked = event;
}
}
//子节点选中 父节点 选中
if (node.ui.isChecked() == true) {
parentNode.attributes.checked = true;
parentNode.ui.toggleCheck(true);
} else {
var flag = false;
node.attributes.checked = flag;
for ( var i = 0; i < childs.length; i++) {
if (childs[i].ui.isChecked() == true) {
flag = true;
}
}
if (flag == false) {
parentNode.attributes.checked = flag;
parentNode.ui.toggleCheck(flag);
}
if(parentNode.attributes.id == 0){
node.cascade( function( node ){
node.attributes.checked = event;
node.ui.checkbox.checked = event;
return true;
});
}
}
},
click : function(node, event) {
node.expand();
},
expandnode : function(node, event) {
}
}
});
treeIface.addListener(
'expandnode',function(){
// treeIface.expandAll();
// treeIface.collapseAll();
}
);
var iface = new Ext.form.ComboBox(
{
editable : false,
fieldLabel : '接口',
name : 'iface',
hiddenName : 'iface',
width : 150,
mode : 'local',
triggerAction : 'all',
tpl: '<div id="treeIface" style="height:200px;width:144px;"></div>',
store : new Ext.data.SimpleStore({ fields: [], data: [[]] }),
valueField : 'value',
value:'',
displayField : 'text',
editable : false
});
iface.on('expand', function() { treeIface.render('treeIface'); });
var nodeIfaceArray = new Array();
var treeIface_click = function(node, e) {
var nodeIfaceValue = '';
if (node.attributes.checked == true) {
var temp =1;
if(node.id <11){
for(var i = 0;i<node.childNodes.length;i++){
nodeIfaceArray.push(node.childNodes[i]);
}
}
for ( var j = 0; j < nodeIfaceArray.length; j++) {
if(nodeIfaceArray[j].attributes.id==node.attributes.id){
temp +=1;
}
}
if(temp==1){
nodeIfaceArray.push(node);
}
}
if (node.attributes.checked == false) {
if(node.id <11){
for(var k = 0;k<node.childNodes.length;k++){
for ( var i = 0; i < nodeIfaceArray.length; i++) {
if(nodeIfaceArray[i].attributes.id==node.childNodes[k].attributes.id){
nodeIfaceArray.splice(i,1);
}
}
}
}
for ( var i = 0; i < nodeIfaceArray.length; i++) {
if(nodeIfaceArray[i].attributes.id==node.attributes.id){
nodeIfaceArray.splice(i,1);
}
}
}
for ( var i = 0; i < nodeIfaceArray.length; i++) {
if(nodeIfaceArray[i].attributes.id!=''){
nodeIfaceValue +=nodeIfaceArray[i].attributes.id+" ";
}
}
iface.setValue(nodeIfaceValue);
};
treeIface.on("checkchange", treeIface_click);
//添加 队列
var tree = new Ext.tree.TreePanel({
title : '队列',
split : true,
frame:false,
border : true,
collapsible : true,
width : 175,
minSize : 80,
maxSize : 250,
enableDD : true,
autoScroll : true,
loader : new Ext.tree.TreeLoader({
//applyLoader : true,
url : 'merchant__loadAllQueue.action'
}),
root: new Ext.tree.AsyncTreeNode( {
id : "0",
text : "添加队列"
//expandable: true,
//expanded: true
}),
rootVisible: false,
listeners : {
checkchange : function(node, event) {
var parentNode = node.parentNode;
var childs = parentNode.childNodes;// 获得兄弟节点
if (node.ui.isChecked() == true) {
parentNode.attributes.checked = true;
parentNode.ui.toggleCheck(true);
} else {
var flag = false;
node.attributes.checked = flag;
for ( var i = 0; i < childs.length; i++) {
if (childs[i].ui.isChecked() == true) {
flag = true;
}
}
if (flag == false) {
parentNode.attributes.checked = flag;
parentNode.ui.toggleCheck(flag);
}
}
},
click : function(node, event) {
node.expand();
},
expandnode : function(node, event) {
}
}
});
var queueid = new Ext.form.ComboBox(
{
editable : false,
fieldLabel : '队列',
name : 'quequeid',
hiddenName : 'queueid',
width : 150,
mode : 'local',
triggerAction : 'all',
tpl: '<div id="tree" style="height:200px;width:144px;"></div>',
store : new Ext.data.SimpleStore({ fields: [], data: [[]] }),
valueField : 'value',
value:'',
displayField : 'text',
editable : false
});
queueid.on('expand', function() { tree.render('tree'); });
var nodeArray = new Array();
var tree_click = function(node, e) {
var nodeValue ='';
// if (node.attributes.leaf) {
if (node.attributes.checked == true) {
var temp =1;
for ( var j = 0; j < nodeArray.length; j++) {
if(nodeArray[j].attributes.id==node.attributes.id){
temp +=1;
}
}
if(temp==1){
nodeArray.push(node);
}
}
if (node.attributes.checked == false) {
for ( var i = 0; i < nodeArray.length; i++) {
if(nodeArray[i].attributes.id==node.attributes.id){
nodeArray.splice(i,1);
//nodeArray[i].attributes.id='';
}
}
}
for ( var i = 0; i < nodeArray.length; i++) {
if(nodeArray[i].attributes.id!=''){
nodeValue +=nodeArray[i].attributes.id;
//nodeValue +=' ';
}
}
queueid.setValue(nodeValue);
};
// tree.on("click", tree_click);
tree.on("checkchange", tree_click);
addForm = new Ext.FormPanel(
{
url : 'merchant__add.action',
defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 120,
autoHeight : true,
bodyStyle : 'padding:5px',
border : false,
// fileUpload : true,
baseCls : 'x-plain',
items : [
merchantNumText,
{
fieldLabel : '商户名称',
name : 'merchantname',
hiddenName : 'merchantname',
allowBlank : false,
maxLength : 50
},
{
fieldLabel : '商户注册ip',
name : 'ipaddr',
hiddenName : 'ipaddr',
maxLength : 50,
allowBlank : true,
regex : /((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/,
regexText : '请输入正确的ip地址'
},
/*saleStatusCmb,
notifyStatusCmb,*/
queueid,iface,
{
fieldLabel : '目录',
name : 'ftppath',
hiddenName : 'ftppath',
allowBlank : false,
maxLength : 200
},
{
fieldLabel : '商户安全码',
name : 'merchantkey',
hiddenName : 'merchantkey',
allowBlank : false,
maxLength : 50
},
{
fieldLabel : 'FTPIP',
name : 'ftpip',
hiddenName : '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地址'
}, {
fieldLabel : '端口',
name : 'ftpport',
hiddenName : 'ftpport',
allowBlank : true,
maxLength : 50
}, {
fieldLabel : '用户名',
name : 'ftpuser',
hiddenName : 'ftpuser',
allowBlank : true,
maxLength : 50
}, {
fieldLabel : '密码',
name : 'ftppwd',
hiddenName : 'ftppwd',
allowBlank : true,
maxLength : 50
}, {
fieldLabel : '消息通知URL',
name : 'msgurl',
hiddenName : 'msgurl',
allowBlank : true,
maxLength : 500
}, {
fieldLabel : '排序号',
name : 'ordermerchant',
hiddenName : 'ordermerchant',
allowBlank : false,
maxLength : 500
}, totalText,isWagerControlCmp,ifacetype,pattern ],
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('错误', '无法访问后台');
/*
* if (action.failureType ==
* Ext.form.Action.SERVER_INVALID) { }
* else { Ext.Msg.alert('错误', '无法访问后台'); }
*/
}
});
btn.enable();
}
}
}, {
text : '重置',
handler : function() {
addForm.getForm().reset();
}
}, {
text : '取消',
handler : function() {
addWindow.close();
}
} ]
});
addWindow = new Ext.Window({
title : '添加',
width : 320,
resizable : false,
autoHeight : true,
modal : true,
closeAction : 'close',
items : [ addForm ]
});
}
function createViewWindow(record) {
var viewWindow = new Ext.Window({
title : '接口详情',
width : 500,
autoWidth : false,
autoHeight : false,
resizable : false,
resizable : false,
modal : true,
closable : true,
closeAction : 'hide'
});
var merchantnum=record.get('merchantnum');
var viewpanel =Joyveb.jlbos.gameParams.js_merchant_view.show(merchantnum);
viewWindow.add(viewpanel);
viewWindow.show();
}
function createViewWindowS(record) {
var viewWindow = new Ext.Window({
title : '队列详情',
width : 600,
autoWidth : false,
autoHeight : false,
resizable : false,
modal : true,
closable : true,
closeAction : 'hide'
});
var merchantnum=record.get('merchantnum');
var viewpanel =Joyveb.jlbos.gameParams.js_merchant_view_que.show(merchantnum);
viewWindow.add(viewpanel);
viewWindow.show();
}
/*--------------------功能方法--------------------*/
// 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("merchantnum");
} else {
jsondata_newsid += "," + records[i].get("merchantnum");
}
}
Ext.Msg.confirm('确认删除', '你确定删除选中的记录?', function(btn) {
if (btn == 'yes') {
Ext.Ajax.request({
url :deleteDSURL ,
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',updateDSURL, {
success : function(response) {
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;
}
};
}();merchant.js
merchant_view.js
Joyveb.jlbos.gameParams.js_merchant_view = function() {
/* ----------------------- private属性 ----------------------- */
var totalPanel;
var merchantnum;
var searchTbar, mainTbar;
var group_array;
var treeloader = new Ext.tree.TreeLoader({});
var saveButton;
var treePanel = new Ext.tree.TreePanel({
title : '接口详情',
region : 'center',
align : 'center',
split : true,
frame : false,
border : true,
collapsible : true,
width : 565,
height : 475,
minSize : 600,
maxSize : 600,
autoScroll : true,
preloadChildren : true,
loader : treeloader,
animate:false,
root : new Ext.tree.AsyncTreeNode({
id : 0,
text : "根"
}),
rootVisible : false,
listeners : {
checkchange : function(node, event) {
var parentNode = node.parentNode;
var childs = parentNode.childNodes;// 获得兄弟节点
if (node.ui.isChecked() == true) {
parentNode.attributes.checked = true;
parentNode.ui.toggleCheck(true);
} else {
var flag = false;
node.attributes.checked = flag;
for ( var i = 0; i < childs.length; i++) {
if (childs[i].ui.isChecked() == true) {
flag = true;
}
}
if (flag == false) {
parentNode.attributes.checked = flag;
parentNode.ui.toggleCheck(flag);
}
}
},
click : function(node, event) {
node.expand();
},
expandnode : function(node, event) {
}
}
});
treePanel.on('beforeload',function(node) {
treePanel.loader.dataUrl = 'merchant__loadIface?merchantnum='+merchantnum; // 定义子节点的Loader
});
treePanel.on('load', function(node){});
/*
* 创建工具条按钮
*/
function createToolbar() {
/*
* searchTbar businessName,searchBtn
*/
searchTbar = [];
totalPanel = new Ext.Panel({
align : 'center'
});
saveButton = new Ext.Button({
text : '保存',
iconCls : 'update',
handler : save
});
searchTbar.push(saveButton);
var config = {
border : false,
pruneModifiedRecords : true,
enableHdMenu : false,
loadMask : {
msg : '数据加载中...'
},
clicksToEdit : 1,
stripeRows : true,
align : 'center',
tbar : searchTbar
};
totalPanel.add(config);
}
/*--------------------功能方法--------------------*/
function searchAnthority() {
if(treePanel.root){
treePanel.root.reload();
}
}
function createPanel() {
mainTbar = [];
mainTbar.push(treePanel);
var config = {
border : false,
pruneModifiedRecords : true,
enableHdMenu : false,
loadMask : {
msg : '数据加载中...'
},
clicksToEdit : 1,
stripeRows : true,
align : 'center',
tbar : mainTbar
};
totalPanel.add(config);
}
function save(){
var checkedNodeArray = new Array();
var checkedNodes = getCheckedNodes();
var jsonArray = [];
// 请求后台
Ext.each(checkedNodes, function(item) {
jsonArray.push(item.id);
});
Ext.lib.Ajax.request('POST','merchant__deleteAddIface?merchantnum=' + merchantnum, {
success : function(response) {
Ext.Msg.alert("正确", "保存成功!");
},
failure : function() {
Ext.Msg.alert("错误", "与后台联系的时候出现了问题!");
}
}, '&data=' + encodeURIComponent(Ext.encode(jsonArray)));
}
// 得到所有选中节点
function getCheckedNodes() {
var nodeArray = new Array();
// 得到所有节点
function getChildsNodes(node) {
var childs;
if (node == treePanel.root) {
childs = node.childNodes;
} else if (node.attributes) {
childs = node.attributes.children;
} else {
childs = node.children;
}
if ((node.attributes && node.attributes.checked == true)
|| node.checked == true) {
// nodeArray[index++]=node;
nodeArray.push(node);
}
var bbb = nodeArray;
for ( var i = 0; i < childs.length; i++) {
getChildsNodes(childs[i]);
}
}
var chekedNodeArray = new Array();
getChildsNodes(treePanel.root);
var aaaa= nodeArray;
for ( var i = 0; i < nodeArray.length; i++) {
var nodeCheck;
if (nodeArray[i].attributes) {
nodeCheck = nodeArray[i].attributes.checked;
} else {
nodeCheck = nodeArray[i].checked;
}
if (nodeCheck == true) {
chekedNodeArray.push(nodeArray[i]);
}
}
return chekedNodeArray;
}
/* ----------------------- public方法 ----------------------- */
return {
show : function(mernum) {
merchantnum=mernum;
// 创建工具栏和搜索栏
createToolbar();
//刷新
searchAnthority();
// 创建Grid
createPanel();
return totalPanel;
}
};
}();
merchant_view_que
Joyveb.jlbos.gameParams.js_merchant_view_que = function() {
/* ----------------------- private属性 ----------------------- */
var totalPanel;
var merchantnum;
var searchTbar, mainTbar;
var group_array;
var treeloader = new Ext.tree.TreeLoader({});
var saveButton;
var treePanel = new Ext.tree.TreePanel({
title : '队列详情',
region : 'center',
align : 'center',
split : true,
frame : false,
border : true,
collapsible : true,
width : 565,
height : 475,
minSize : 600,
maxSize : 600,
autoScroll : true,
preloadChildren : true,
loader : treeloader,
animate:false,
root : new Ext.tree.AsyncTreeNode({
id : 0,
text : "根"
}),
rootVisible : false,
listeners : {
checkchange : function(node, event) {
var parentNode = node.parentNode;
var childs = parentNode.childNodes;// 获得兄弟节点
if (node.ui.isChecked() == true) {
parentNode.attributes.checked = true;
parentNode.ui.toggleCheck(true);
} else {
var flag = false;
node.attributes.checked = flag;
for ( var i = 0; i < childs.length; i++) {
if (childs[i].ui.isChecked() == true) {
flag = true;
}
}
if (flag == false) {
parentNode.attributes.checked = flag;
parentNode.ui.toggleCheck(flag);
}
}
},
click : function(node, event) {
node.expand();
},
expandnode : function(node, event) {
}
}
});
treePanel.on('beforeload',function(node) {
treePanel.loader.dataUrl = 'merchant__loadQue?merchantnum='+merchantnum; // 定义子节点的Loader
});
treePanel.on('load', function(node){});
/*
* 创建工具条按钮
*/
function createToolbar() {
/*
* searchTbar businessName,searchBtn
*/
searchTbar = [];
totalPanel = new Ext.Panel({
align : 'center'
});
saveButton = new Ext.Button({
text : '保存',
iconCls : 'update',
handler : save
});
searchTbar.push(saveButton);
var config = {
border : false,
pruneModifiedRecords : true,
enableHdMenu : false,
loadMask : {
msg : '数据加载中...'
},
clicksToEdit : 1,
stripeRows : true,
align : 'center',
tbar : searchTbar
};
totalPanel.add(config);
}
/*--------------------功能方法--------------------*/
function searchAnthority() {
treePanel.root.reload();
}
function createPanel() {
mainTbar = [];
mainTbar.push(treePanel);
var config = {
border : false,
pruneModifiedRecords : true,
enableHdMenu : false,
loadMask : {
msg : '数据加载中...'
},
clicksToEdit : 1,
stripeRows : true,
align : 'center',
tbar : mainTbar
};
totalPanel.add(config);
}
function save(){
var checkedNodeArray = new Array();
var checkedNodes = getCheckedNodes();
var jsonArray = [];
// 请求后台
Ext.each(checkedNodes, function(item) {
jsonArray.push(item.id);
});
Ext.lib.Ajax.request('POST','merchant__deleteAddQue?merchantnum=' + merchantnum, {
success : function(response) {
Ext.Msg.alert("正确", "保存成功!");
},
failure : function() {
Ext.Msg.alert("错误", "与后台联系的时候出现了问题!");
}
}, '&data=' + encodeURIComponent(Ext.encode(jsonArray)));
}
// 得到所有选中节点
function getCheckedNodes() {
var nodeArray = new Array();
// 得到所有节点
function getChildsNodes(node) {
var childs;
if (node == treePanel.root) {
childs = node.childNodes;
} else if (node.attributes) {
childs = node.attributes.children;
} else {
childs = node.children;
}
if ((node.attributes && node.attributes.checked == true)
|| node.checked == true) {
// nodeArray[index++]=node;
nodeArray.push(node);
}
var bbb = nodeArray;
for ( var i = 0; i < childs.length; i++) {
getChildsNodes(childs[i]);
}
}
var chekedNodeArray = new Array();
getChildsNodes(treePanel.root);
var aaaa= nodeArray;
for ( var i = 0; i < nodeArray.length; i++) {
var nodeCheck;
if (nodeArray[i].attributes) {
nodeCheck = nodeArray[i].attributes.checked;
} else {
nodeCheck = nodeArray[i].checked;
}
if (nodeCheck == true) {
chekedNodeArray.push(nodeArray[i]);
}
}
return chekedNodeArray;
}
/* ----------------------- public方法 ----------------------- */
return {
show : function(mernum) {
merchantnum=mernum;
// 创建工具栏和搜索栏
createToolbar();
//刷新
searchAnthority();
// 创建Grid
createPanel();
return totalPanel;
}
};
}();
merchant.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%@ include file="../ext-package.html"%>
<script type="text/javascript" src="<%=path%>/js/gameParams/merchant.js"></script>
<script type="text/javascript" src="<%=path%>/js/gameParams/merchant_view.js"></script>
<script type="text/javascript" src="<%=path%>/js/gameParams/merchant_view_que.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.form.Field.prototype.magTarget='side';
Ext.BLANK_IMAGE_URL="extjs/resources/images/default/s.gif"; //空图片途径
var v_item = Joyveb.jlbos.gameParams.js_merchant.show();
var viewPort=new Ext.Viewport({
layout:'fit',
items:
[
v_item
]
});
});
</script>
</head>
<body>
</body>
</html>