Anthony

accountset 模块化

1 -define(function(){ 1 +define(['i18n!accountset/nls/resource', 'cls', 'base/index', 'index/index'], function (resource, Class, base, index){
2 - return { 2 +
3 - init : function(){ 3 + return Class({
4 + resource: resource,
5 + plId:function getPlId(){
4 var plId = $.cookie("rs-platform-id"); 6 var plId = $.cookie("rs-platform-id");
5 - var pannel = getSelectedPanel();//初始化面板 7 + //不是系统管理平台,不能使用新增功能
6 - var page = pannel.children(".crm-accountset").show().layout({fit:true});//定义面板内div 8 + if(plId != 1){
7 - var datagrid = initDatagrid();//初始化数据表格 9 + var buttons = page.find(".rs-toolbar").find(".button");// 按钮组
8 - //初始化表格 10 + buttons.eq(1).linkbutton('disable');
9 - function initDatagrid(){ 11 + buttons.eq(1).unbind("click");
10 - return page.layout("panel","center").children(".crm-accountset-table").datagrid({ 12 + }
11 - url:"./query/0996fdd2-ad85-4d1b-acc6-04b412496428.json", 13 + },
14 + variable: function () {
15 + var panel = index.getSelectedPanel();
16 + this.page = panel.children('.crm-accountset').layout({fit: true});
17 + this.north = this.page.layout("panel", "north");
18 + this.center = this.page.layout("panel", "center");
19 + this.grid = $('<div></div>').appendTo(this.center);
20 + this.queryId = '0996fdd2-ad85-4d1b-acc6-04b412496428';
21 + },
22 + initialize: function () {
23 + initDatagrid(this);
24 + function initDatagrid(inst){
25 + inst.grid.datagrid({
26 + url:'./query/' + inst.queryId + '.json',
12 toolbar:$('<div class="clearfix"></div>').rs_toolbar({ 27 toolbar:$('<div class="clearfix"></div>').rs_toolbar({
13 - title:resource.accountset.title.name, 28 + title:resource.title.name,
14 - authz:getAuthzUtils('accountSet'), 29 + authz:base.getAuthz('accountSet'),
15 - buttons: 30 + buttons: [{
16 - [{ 31 + text: base.resource.btn.select,
17 - text: resource.btn.select,
18 iconCls:'btn-select select-condition', 32 iconCls:'btn-select select-condition',
19 handler: function(){ 33 handler: function(){
20 - showCondObject('0996fdd2-ad85-4d1b-acc6-04b412496428', datagridReload); 34 + base.showCondObject(inst.queryId, function(){
35 + datagridReload.call(inst);
36 + });
21 } 37 }
22 },{ 38 },{
23 code:'edit', 39 code:'edit',
24 - text: resource.btn.add, 40 + text: base.resource.btn.add,
25 iconCls:'btn-add', 41 iconCls:'btn-add',
26 - handler: addWindow 42 + handler:function(){
43 + addWindow.call(this,inst)
44 + }
27 },{ 45 },{
28 code:'edit', 46 code:'edit',
29 - text: resource.btn.edit, 47 + text: base.resource.btn.edit,
30 iconCls:'btn-edit', 48 iconCls:'btn-edit',
31 - handler: editWindow 49 + handler: function(){
50 + editWindow.call(this,inst)
51 + }
32 },{ 52 },{
33 code:'edit', 53 code:'edit',
34 - text: resource.btn.remove, 54 + text: base.resource.btn.remove,
35 iconCls:'btn-remove', 55 iconCls:'btn-remove',
36 - handler: deleteData 56 + handler: function(){
57 + deleteData.call(this,inst)
58 + }
37 }], 59 }],
38 tools:[ 60 tools:[
39 -// {
40 -// text:resource.btn.print,
41 -// iconCls:'btn-print',
42 -// handler:panelRefreshUtils
43 -// },
44 { 61 {
45 - text:resource.btn.refresh, 62 + text:base.resource.btn.refresh,
46 iconCls:'btn-refresh', 63 iconCls:'btn-refresh',
47 - handler:panelRefreshUtils 64 + handler:function(){
65 + datagridReload.call(inst)
66 + }
48 } 67 }
49 -// ,{
50 -// text:resource.btn.more,
51 -// iconCls:'btn-more',
52 -// handler:panelRefreshUtils
53 -// }
54 ] 68 ]
55 }), 69 }),
56 fitColumns:true,//使列自动展开/收缩到合适的DataGrid宽度 70 fitColumns:true,//使列自动展开/收缩到合适的DataGrid宽度
57 columns:[[ 71 columns:[[
58 {field:'ck',checkbox:true }, 72 {field:'ck',checkbox:true },
59 - {field:'ACT_CODE',title:resource.accountset.grid.actcode, width:100, align:"center"}, 73 + {field:'ACT_CODE',title:resource.grid.actcode, width:100, align:"center"},
60 - {field:'ACT_NAME',title:resource.accountset.grid.actname, width:100, align:"center"}, 74 + {field:'ACT_NAME',title:resource.grid.actname, width:100, align:"center"},
61 - {field:'ACT_DESC',title:resource.accountset.grid.actdesc, width:200, align:"center"}, 75 + {field:'ACT_DESC',title:resource.grid.actdesc, width:200, align:"center"},
62 - {field:'PLNAME',title:resource.accountset.grid.plname, width:200, align:"center"}, 76 + {field:'PLNAME',title:resource.grid.plname, width:200, align:"center"},
63 - {field:'ACT_TYPE',title:resource.accountset.grid.acttype, width:200, align:"center"}, 77 + {field:'ACT_TYPE',title:resource.grid.acttype, width:200, align:"center"},
64 - {field:'ENABLE',title:resource.accountset.grid.enable, width:60, align:"center"} 78 + {field:'ENABLE',title:resource.grid.enable, width:60, align:"center"}
65 ]] 79 ]]
66 }); 80 });
67 } 81 }
68 - //不是系统管理平台,不能使用新增功能 82 + },
69 - if(plId != 1){ 83 + handler: function () {
70 - var buttons = page.find(".rs-toolbar").find(".button");// 按钮组 84 +
71 - buttons.eq(1).linkbutton('disable');
72 - buttons.eq(1).unbind("click");
73 } 85 }
86 + });
74 87
75 //行转换 88 //行转换
76 function getSelectedRow(){ 89 function getSelectedRow(){
77 - var row = datagrid.datagrid('getSelected'); 90 + var row = this.grid.datagrid('getSelected');
78 return row?{ 91 return row?{
79 actId:row.ACT_ID, 92 actId:row.ACT_ID,
80 actCode:row.ACT_CODE, 93 actCode:row.ACT_CODE,
...@@ -87,33 +100,32 @@ define(function(){ ...@@ -87,33 +100,32 @@ define(function(){
87 } 100 }
88 function datagridReload(params){ 101 function datagridReload(params){
89 if(params){ 102 if(params){
90 - datagrid.datagrid("reload",params); 103 + this.grid.datagrid("reload",params);
91 }else{ 104 }else{
92 - datagrid.datagrid("reload",getCondObjectValue('0996fdd2-ad85-4d1b-acc6-04b412496428')); 105 + this.grid.datagrid("reload",base.getCondObjectValue(this.queryId));
93 } 106 }
94 } 107 }
95 -
96 //添加到账套详情页面 108 //添加到账套详情页面
97 - function addWindow(){ 109 + function addWindow(inst){
98 //添加账套详情页面 110 //添加账套详情页面
99 - showTabUtils({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailAdd"}, true, function(){ 111 + index.showPanel({text:resource.title.detail,url:"./accountSetDetail/accountSetDetailAdd"}, true, function(){
100 - datagrid.datagrid("reload"); 112 + this.grid.datagrid("reload");
101 }); 113 });
102 } 114 }
103 //编辑页面弹出绑定按钮 115 //编辑页面弹出绑定按钮
104 - function editWindow(){ 116 + function editWindow(inst){
105 - var row = getSelectedRow(); 117 + var row = getSelectedRow.call(this);
106 if(row == null){ 118 if(row == null){
107 $.messager.alert(resource.msg_title, resource.msgEditTip); 119 $.messager.alert(resource.msg_title, resource.msgEditTip);
108 }else{ 120 }else{
109 - showTabUtils({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+row.actId+"&actCode="+row.actCode}, true, function(){ 121 + index.showPanel({text:resource.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+row.actId+"&actCode="+row.actCode}, true, function(){
110 - datagrid.datagrid("reload"); 122 + this.grid.datagrid("reload");
111 }); 123 });
112 } 124 }
113 } 125 }
114 //删除 126 //删除
115 - function deleteData(){ 127 + function deleteData(inst){
116 - var accountSet = getSelectedRow(); 128 + var accountSet = getSelectedRow.call(this);
117 if(accountSet == null){ 129 if(accountSet == null){
118 $.messager.alert(resource.msg_title, resource.msgRemoveTip); 130 $.messager.alert(resource.msg_title, resource.msgRemoveTip);
119 }else{ 131 }else{
...@@ -123,7 +135,7 @@ define(function(){ ...@@ -123,7 +135,7 @@ define(function(){
123 accountSet.enable = ""; 135 accountSet.enable = "";
124 $.JSON("./accountSet/delete.json", accountSet, function(result){ 136 $.JSON("./accountSet/delete.json", accountSet, function(result){
125 if(responseUtils(result)){ 137 if(responseUtils(result)){
126 - datagrid.datagrid("reload"); 138 + this.grid.datagrid("reload");
127 } 139 }
128 }); 140 });
129 } 141 }
...@@ -134,6 +146,4 @@ define(function(){ ...@@ -134,6 +146,4 @@ define(function(){
134 } 146 }
135 } 147 }
136 148
137 - }
138 - }
139 }); 149 });
...\ No newline at end of file ...\ No newline at end of file
......
1 -define(function(){ 1 +define(['i18n!accountset/nls/resource', 'cls', 'base/index', 'index/index'], function (resource, Class, base, index){
2 - return { 2 + return Class({
3 - init : function(actId, actCode,usId){ 3 + resource: resource,
4 + variable: function () { //全局变量
5 + var panel = index.getSelectedPanel();
6 + this.page = panel.children('.crm-accountset-detail').layout({fit: true});
7 + this.north = this.page.layout("panel", "north");
8 + this.center = this.page.layout("panel", "center");
9 + this.grid = $('<div></div>').appendTo(this.center);
10 + this.queryId = 'f1fd6213-c928-4e72-87f2-f8bfe8589b19';
11 + this.tabs=this.center.children("div").tabs({closable : false, fit:true});
12 + this.netDetail = this.page.find(".netDetail");
13 +
14 + },
15 + initialize: function () {//界面布局
16 + initNetDataGrid(this);
17 + },
18 + handler: function(actId, actCode,usId){ //事件绑定
4 var brandCount = 0; //品牌searchbox渲染次数,第一次渲染的时候,需要刷新 19 var brandCount = 0; //品牌searchbox渲染次数,第一次渲染的时候,需要刷新
5 - var panel=getSelectedPanel(); 20 +
6 - var query="f1fd6213-c928-4e72-87f2-f8bfe8589b19";
7 - var layout=panel.children('.crm-accountset-detail').layout({ fit:true });
8 - //声明整个登录账户选项卡容器
9 - var page=panel.children('.crm-accountset-detail');
10 - var north=page.layout("panel","north");
11 - var center=page.layout("panel","center");
12 var wxgzh = ""; 21 var wxgzh = "";
13 var index = 0; 22 var index = 0;
14 var div = "<div class='easyui-tabs l-btn-left l-btn-icon-left'></div>"; 23 var div = "<div class='easyui-tabs l-btn-left l-btn-icon-left'></div>";
...@@ -37,7 +46,7 @@ define(function(){ ...@@ -37,7 +46,7 @@ define(function(){
37 }); 46 });
38 var accsetDetail=north.find(".accountSet"); 47 var accsetDetail=north.find(".accountSet");
39 var accsetDetailform = accsetDetail.find(".accountSetForm"); 48 var accsetDetailform = accsetDetail.find(".accountSetForm");
40 - var netDetail = page.find(".netDetail"); 49 +
41 50
42 //经营主体和短信通道联动 51 //经营主体和短信通道联动
43 var netDataGrid = initNetDataGrid(); 52 var netDataGrid = initNetDataGrid();
...@@ -385,7 +394,7 @@ define(function(){ ...@@ -385,7 +394,7 @@ define(function(){
385 if(responseUtils(result)){ 394 if(responseUtils(result)){
386 var actId = result.value.actId; 395 var actId = result.value.actId;
387 var actCode = result.value.actCode; 396 var actCode = result.value.actCode;
388 - showTabUtils({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+result.value.actId+"&actCode="+result.value.actCode}, true, function(){ 397 + base.showPanel({text:resource.accountset.title.detail,url:"./accountSetDetail/accountSetDetailEdit?actId="+result.value.actId+"&actCode="+result.value.actCode}, true, function(){
389 panelRefreshUtils(); 398 panelRefreshUtils();
390 }); 399 });
391 } 400 }
...@@ -610,47 +619,7 @@ define(function(){ ...@@ -610,47 +619,7 @@ define(function(){
610 // return cc; 619 // return cc;
611 // } 620 // }
612 // 初始化网点组datagrid 621 // 初始化网点组datagrid
613 - function initNetDataGrid(){
614 - return tabs.find(".netwooks").datagrid({
615 - singleSelect : false,
616 -// onLoadSuccess : aaatest,
617 -// onBeforeLoad : bbbtest,
618 -// loadFilter: ccctest,
619 622
620 - //url:"./query/e0e0f773-34a1-450c-8868-60433a245eb8.json",
621 - toolbar:$('<div class="clearfix"></div>').rs_toolbar({
622 - content:netDetail,
623 - title:resource.accountset.title.suitSite,
624 - authz:getAuthzUtils('accountSet'),
625 - buttons:[
626 - {
627 - text:resource.btn.select,
628 - iconCls:"btn-select select-condition",
629 - handler: function(){
630 - showCondObject(query,datagridReload);
631 - }
632 - },
633 - {
634 - code:'edit',
635 - text: resource.btn.add,
636 - iconCls:'btn-add',
637 - handler: addNet
638 - },{
639 - code:'edit',
640 - text: resource.btn.remove,
641 - iconCls:'btn-remove',
642 - handler:removeNet
643 - }]
644 - }),
645 - columns:[[
646 - {field:'ck',checkbox:true },
647 - {field:'SICODE',title:resource.accountset.grid.sicode, width:100, align:"center"},
648 - {field:'SINAME',title:resource.accountset.grid.siname, width:100, align:"center"},
649 - {field:'BENAME',title:resource.accountset.grid.bename, width:100, align:"center"},
650 - {field:'BEBNAME',title:resource.accountset.grid.bebname, width:100, align:"center"}
651 - ]]
652 - });
653 - }
654 623
655 //新增一个tab 624 //新增一个tab
656 function addNetTab(){ 625 function addNetTab(){
...@@ -747,14 +716,56 @@ define(function(){ ...@@ -747,14 +716,56 @@ define(function(){
747 return html; 716 return html;
748 } 717 }
749 718
750 - function tabClose(){
751 - alert("todo zhangweijiang");
752 - }
753 719
754 function datagridReload(params){ 720 function datagridReload(params){
755 - var param =getCondObjectValue(query); 721 + if(params){
756 - tabs.find(".netwooks").datagrid("reload",param); 722 + this.tabs.find(".netwooks").datagrid("reload",params);
723 + }else{
724 + this.tabs.find(".netwooks").datagrid("reload",base.getCondObjectValue(this.queryId));
725 + }
757 } 726 }
758 } 727 }
728 + })
729 + function initNetDataGrid(inst){
730 + return inst.tabs.find(".netwooks").datagrid({
731 + singleSelect : false,
732 +// onLoadSuccess : aaatest,
733 +// onBeforeLoad : bbbtest,
734 +// loadFilter: ccctest,
735 +
736 + //url:"./query/e0e0f773-34a1-450c-8868-60433a245eb8.json",
737 + toolbar:$('<div class="clearfix"></div>').rs_toolbar({
738 + content:inst.netDetail,
739 + title:resource.title.suitSite,
740 + authz:base.getAuthz('accountSet'),
741 + buttons:[
742 + {
743 + text:base.resource.btn.select,
744 + iconCls:"btn-select select-condition",
745 + handler: function() {
746 + base.showCondObject(inst.queryId, function () {
747 + datagridReload.call(inst);
748 + });
749 + }
750 + },{
751 + code:'edit',
752 + text: base.resource.btn.add,
753 + iconCls:'btn-add',
754 + handler: addNet
755 + },{
756 + code:'edit',
757 + text: base.resource.btn.remove,
758 + iconCls:'btn-remove',
759 + handler:removeNet
760 + }]
761 + }),
762 + columns:[[
763 + {field:'ck',checkbox:true },
764 + {field:'SICODE',title:resource.grid.sicode, width:100, align:"center"},
765 + {field:'SINAME',title:resource.grid.siname, width:100, align:"center"},
766 + {field:'BENAME',title:resource.grid.bename, width:100, align:"center"},
767 + {field:'BEBNAME',title:resource.grid.bebname, width:100, align:"center"}
768 + ]]
769 + });
759 } 770 }
760 }); 771 });
...\ No newline at end of file ...\ No newline at end of file
......