Anthony

accountset 模块化

define(function(){
return {
init : function(){
define(['i18n!accountset/nls/resource', 'cls', 'base/index', 'index/index'], function (resource, Class, base, index){
return Class({
resource: resource,
plId:function getPlId(){
var plId = $.cookie("rs-platform-id");
var pannel = getSelectedPanel();//初始化面板
var page = pannel.children(".crm-accountset").show().layout({fit:true});//定义面板内div
var datagrid = initDatagrid();//初始化数据表格
//初始化表格
function initDatagrid(){
return page.layout("panel","center").children(".crm-accountset-table").datagrid({
url:"./query/0996fdd2-ad85-4d1b-acc6-04b412496428.json",
//不是系统管理平台,不能使用新增功能
if(plId != 1){
var buttons = page.find(".rs-toolbar").find(".button");// 按钮组
buttons.eq(1).linkbutton('disable');
buttons.eq(1).unbind("click");
}
},
variable: function () {
var panel = index.getSelectedPanel();
this.page = panel.children('.crm-accountset').layout({fit: true});
this.north = this.page.layout("panel", "north");
this.center = this.page.layout("panel", "center");
this.grid = $('<div></div>').appendTo(this.center);
this.queryId = '0996fdd2-ad85-4d1b-acc6-04b412496428';
},
initialize: function () {
initDatagrid(this);
function initDatagrid(inst){
inst.grid.datagrid({
url:'./query/' + inst.queryId + '.json',
toolbar:$('<div class="clearfix"></div>').rs_toolbar({
title:resource.accountset.title.name,
authz:getAuthzUtils('accountSet'),
buttons:
[{
text: resource.btn.select,
title:resource.title.name,
authz:base.getAuthz('accountSet'),
buttons: [{
text: base.resource.btn.select,
iconCls:'btn-select select-condition',
handler: function(){
showCondObject('0996fdd2-ad85-4d1b-acc6-04b412496428', datagridReload);
base.showCondObject(inst.queryId, function(){
datagridReload.call(inst);
});
}
},{
code:'edit',
text: resource.btn.add,
text: base.resource.btn.add,
iconCls:'btn-add',
handler: addWindow
handler:function(){
addWindow.call(this,inst)
}
},{
code:'edit',
text: resource.btn.edit,
text: base.resource.btn.edit,
iconCls:'btn-edit',
handler: editWindow
handler: function(){
editWindow.call(this,inst)
}
},{
code:'edit',
text: resource.btn.remove,
text: base.resource.btn.remove,
iconCls:'btn-remove',
handler: deleteData
handler: function(){
deleteData.call(this,inst)
}
}],
tools:[
// {
// text:resource.btn.print,
// iconCls:'btn-print',
// handler:panelRefreshUtils
// },
{
text:resource.btn.refresh,
text:base.resource.btn.refresh,
iconCls:'btn-refresh',
handler:panelRefreshUtils
handler:function(){
datagridReload.call(inst)
}
}
// ,{
// text:resource.btn.more,
// iconCls:'btn-more',
// handler:panelRefreshUtils
// }
]
}),
fitColumns:true,//使列自动展开/收缩到合适的DataGrid宽度
columns:[[
{field:'ck',checkbox:true },
{field:'ACT_CODE',title:resource.accountset.grid.actcode, width:100, align:"center"},
{field:'ACT_NAME',title:resource.accountset.grid.actname, width:100, align:"center"},
{field:'ACT_DESC',title:resource.accountset.grid.actdesc, width:200, align:"center"},
{field:'PLNAME',title:resource.accountset.grid.plname, width:200, align:"center"},
{field:'ACT_TYPE',title:resource.accountset.grid.acttype, width:200, align:"center"},
{field:'ENABLE',title:resource.accountset.grid.enable, width:60, align:"center"}
{field:'ACT_CODE',title:resource.grid.actcode, width:100, align:"center"},
{field:'ACT_NAME',title:resource.grid.actname, width:100, align:"center"},
{field:'ACT_DESC',title:resource.grid.actdesc, width:200, align:"center"},
{field:'PLNAME',title:resource.grid.plname, width:200, align:"center"},
{field:'ACT_TYPE',title:resource.grid.acttype, width:200, align:"center"},
{field:'ENABLE',title:resource.grid.enable, width:60, align:"center"}
]]
});
}
//不是系统管理平台,不能使用新增功能
if(plId != 1){
var buttons = page.find(".rs-toolbar").find(".button");// 按钮组
buttons.eq(1).linkbutton('disable');
buttons.eq(1).unbind("click");
},
handler: function () {
}
});
//行转换
function getSelectedRow(){
var row = datagrid.datagrid('getSelected');
var row = this.grid.datagrid('getSelected');
return row?{
actId:row.ACT_ID,
actCode:row.ACT_CODE,
......@@ -87,33 +100,32 @@ define(function(){
}
function datagridReload(params){
if(params){
datagrid.datagrid("reload",params);
this.grid.datagrid("reload",params);
}else{
datagrid.datagrid("reload",getCondObjectValue('0996fdd2-ad85-4d1b-acc6-04b412496428'));
this.grid.datagrid("reload",base.getCondObjectValue(this.queryId));
}
}
//添加到账套详情页面
function addWindow(){
function addWindow(inst){
//添加账套详情页面
showTabUtils({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailAdd"}, true, function(){
datagrid.datagrid("reload");
index.showPanel({text:resource.title.detail,url:"./accountSetDetail/accountSetDetailAdd"}, true, function(){
this.grid.datagrid("reload");
});
}
//编辑页面弹出绑定按钮
function editWindow(){
var row = getSelectedRow();
function editWindow(inst){
var row = getSelectedRow.call(this);
if(row == null){
$.messager.alert(resource.msg_title, resource.msgEditTip);
}else{
showTabUtils({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+row.actId+"&actCode="+row.actCode}, true, function(){
datagrid.datagrid("reload");
index.showPanel({text:resource.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+row.actId+"&actCode="+row.actCode}, true, function(){
this.grid.datagrid("reload");
});
}
}
//删除
function deleteData(){
var accountSet = getSelectedRow();
function deleteData(inst){
var accountSet = getSelectedRow.call(this);
if(accountSet == null){
$.messager.alert(resource.msg_title, resource.msgRemoveTip);
}else{
......@@ -123,7 +135,7 @@ define(function(){
accountSet.enable = "";
$.JSON("./accountSet/delete.json", accountSet, function(result){
if(responseUtils(result)){
datagrid.datagrid("reload");
this.grid.datagrid("reload");
}
});
}
......@@ -134,6 +146,4 @@ define(function(){
}
}
}
}
});
\ No newline at end of file
......
define(function(){
return {
init : function(actId, actCode,usId){
define(['i18n!accountset/nls/resource', 'cls', 'base/index', 'index/index'], function (resource, Class, base, index){
return Class({
resource: resource,
variable: function () { //全局变量
var panel = index.getSelectedPanel();
this.page = panel.children('.crm-accountset-detail').layout({fit: true});
this.north = this.page.layout("panel", "north");
this.center = this.page.layout("panel", "center");
this.grid = $('<div></div>').appendTo(this.center);
this.queryId = 'f1fd6213-c928-4e72-87f2-f8bfe8589b19';
this.tabs=this.center.children("div").tabs({closable : false, fit:true});
this.netDetail = this.page.find(".netDetail");
},
initialize: function () {//界面布局
initNetDataGrid(this);
},
handler: function(actId, actCode,usId){ //事件绑定
var brandCount = 0; //品牌searchbox渲染次数,第一次渲染的时候,需要刷新
var panel=getSelectedPanel();
var query="f1fd6213-c928-4e72-87f2-f8bfe8589b19";
var layout=panel.children('.crm-accountset-detail').layout({ fit:true });
//声明整个登录账户选项卡容器
var page=panel.children('.crm-accountset-detail');
var north=page.layout("panel","north");
var center=page.layout("panel","center");
var wxgzh = "";
var index = 0;
var div = "<div class='easyui-tabs l-btn-left l-btn-icon-left'></div>";
......@@ -37,7 +46,7 @@ define(function(){
});
var accsetDetail=north.find(".accountSet");
var accsetDetailform = accsetDetail.find(".accountSetForm");
var netDetail = page.find(".netDetail");
//经营主体和短信通道联动
var netDataGrid = initNetDataGrid();
......@@ -385,7 +394,7 @@ define(function(){
if(responseUtils(result)){
var actId = result.value.actId;
var actCode = result.value.actCode;
showTabUtils({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+result.value.actId+"&actCode="+result.value.actCode}, true, function(){
base.showPanel({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+result.value.actId+"&actCode="+result.value.actCode}, true, function(){
panelRefreshUtils();
});
}
......@@ -610,47 +619,7 @@ define(function(){
// return cc;
// }
// 初始化网点组datagrid
function initNetDataGrid(){
return tabs.find(".netwooks").datagrid({
singleSelect : false,
// onLoadSuccess : aaatest,
// onBeforeLoad : bbbtest,
// loadFilter: ccctest,
//url:"./query/e0e0f773-34a1-450c-8868-60433a245eb8.json",
toolbar:$('<div class="clearfix"></div>').rs_toolbar({
content:netDetail,
title:resource.accountset.title.suitSite,
authz:getAuthzUtils('accountSet'),
buttons:[
{
text:resource.btn.select,
iconCls:"btn-select select-condition",
handler: function(){
showCondObject(query,datagridReload);
}
},
{
code:'edit',
text: resource.btn.add,
iconCls:'btn-add',
handler: addNet
},{
code:'edit',
text: resource.btn.remove,
iconCls:'btn-remove',
handler:removeNet
}]
}),
columns:[[
{field:'ck',checkbox:true },
{field:'SICODE',title:resource.accountset.grid.sicode, width:100, align:"center"},
{field:'SINAME',title:resource.accountset.grid.siname, width:100, align:"center"},
{field:'BENAME',title:resource.accountset.grid.bename, width:100, align:"center"},
{field:'BEBNAME',title:resource.accountset.grid.bebname, width:100, align:"center"}
]]
});
}
//新增一个tab
function addNetTab(){
......@@ -747,14 +716,56 @@ define(function(){
return html;
}
function tabClose(){
alert("todo zhangweijiang");
}
function datagridReload(params){
var param =getCondObjectValue(query);
tabs.find(".netwooks").datagrid("reload",param);
if(params){
this.tabs.find(".netwooks").datagrid("reload",params);
}else{
this.tabs.find(".netwooks").datagrid("reload",base.getCondObjectValue(this.queryId));
}
}
}
})
function initNetDataGrid(inst){
return inst.tabs.find(".netwooks").datagrid({
singleSelect : false,
// onLoadSuccess : aaatest,
// onBeforeLoad : bbbtest,
// loadFilter: ccctest,
//url:"./query/e0e0f773-34a1-450c-8868-60433a245eb8.json",
toolbar:$('<div class="clearfix"></div>').rs_toolbar({
content:inst.netDetail,
title:resource.title.suitSite,
authz:base.getAuthz('accountSet'),
buttons:[
{
text:base.resource.btn.select,
iconCls:"btn-select select-condition",
handler: function() {
base.showCondObject(inst.queryId, function () {
datagridReload.call(inst);
});
}
},{
code:'edit',
text: base.resource.btn.add,
iconCls:'btn-add',
handler: addNet
},{
code:'edit',
text: base.resource.btn.remove,
iconCls:'btn-remove',
handler:removeNet
}]
}),
columns:[[
{field:'ck',checkbox:true },
{field:'SICODE',title:resource.grid.sicode, width:100, align:"center"},
{field:'SINAME',title:resource.grid.siname, width:100, align:"center"},
{field:'BENAME',title:resource.grid.bename, width:100, align:"center"},
{field:'BEBNAME',title:resource.grid.bebname, width:100, align:"center"}
]]
});
}
});
\ No newline at end of file
......