Anthony

brand 模块化

1 -define(["uploadify"],function(){ 1 +define(['i18n!brand/nls/resource', 'cls', 'base/index', 'index/index','uploadify'], function (resource, Class, base, indexlayout,uploadify){
2 - return function(sessionId,rootUrl){ 2 + return {
3 + resource:resource,
4 + init :function(sessionId,rootUrl){
3 var body=$(document.body); 5 var body=$(document.body);
4 - var pannel = getSelectedPanel();//初始化面板 6 + var pannel = indexlayout.getSelectedPanel();//初始化面板
5 var page = pannel.children(".data-brand").layout({fit:true});//定义面板内div 7 var page = pannel.children(".data-brand").layout({fit:true});//定义面板内div
6 var datagrid = initDatagrid();//初始化数据表格 8 var datagrid = initDatagrid();//初始化数据表格
7 var window = initWindow();//初始化添加页面 9 var window = initWindow();//初始化添加页面
...@@ -11,33 +13,33 @@ define(["uploadify"],function(){ ...@@ -11,33 +13,33 @@ define(["uploadify"],function(){
11 var txtDesc=form.find("input[name='desc']"); 13 var txtDesc=form.find("input[name='desc']");
12 var txtCode=form.find("input[name='code']"); 14 var txtCode=form.find("input[name='code']");
13 var txtValid=form.find("select[name='valid']"); 15 var txtValid=form.find("select[name='valid']");
14 - form.find("span.name").html(resource.brand.name); 16 + form.find("span.name").html(resource.name);
15 - form.find("div.desc").html(resource.brand.desc); 17 + form.find("div.desc").html(resource.desc);
16 - form.find("span.code").html(resource.brand.code); 18 + form.find("span.code").html(resource.code);
17 - form.find("div.valid").html(resource.brand.valid); 19 + form.find("div.valid").html(resource.valid);
18 - maxlengthUtils(txtName,20); 20 + base.maxlength(txtName,20);
19 txtName.textbox({ 21 txtName.textbox({
20 required:true 22 required:true
21 }); 23 });
22 - maxlengthUtils(txtDesc,100); 24 + base.maxlength(txtDesc,100);
23 txtDesc.textbox({ 25 txtDesc.textbox({
24 multiline:true, 26 multiline:true,
25 height:75, 27 height:75,
26 onChange:function(val){ 28 onChange:function(val){
27 if(val.length>100){ 29 if(val.length>100){
28 - $.messager.alert(resource.msg_title,resource.brand.deaclength); 30 + $.messager.alert(resource.msg_title,resource.deaclength);
29 txtDesc.textbox("setValue",txtDesc.textbox("getValue").substring(0,60)); 31 txtDesc.textbox("setValue",txtDesc.textbox("getValue").substring(0,60));
30 } 32 }
31 } 33 }
32 }); 34 });
33 - maxlengthUtils(txtCode,10); 35 + base.maxlength(txtCode,10);
34 txtCode.textbox({ 36 txtCode.textbox({
35 required:true 37 required:true
36 }); 38 });
37 txtValid.combobox({ 39 txtValid.combobox({
38 data:[ 40 data:[
39 - {text:resource.btn.yes,value:'1',selected:true}, 41 + {text:base.resource.btn.yes,value:'1',selected:true},
40 - {text:resource.btn.no,value:'0'} 42 + {text:base.resource.btn.no,value:'0'}
41 ] 43 ]
42 }); 44 });
43 window.find(".cancel").bind("click", hideWindow);//绑定页面取消按钮 45 window.find(".cancel").bind("click", hideWindow);//绑定页面取消按钮
...@@ -46,14 +48,14 @@ define(["uploadify"],function(){ ...@@ -46,14 +48,14 @@ define(["uploadify"],function(){
46 return page.layout('panel','center').children('.data-brand-table').datagrid({ 48 return page.layout('panel','center').children('.data-brand-table').datagrid({
47 url:'./query/22726b54-5748-4926-82ed-abe076caecfa.json', 49 url:'./query/22726b54-5748-4926-82ed-abe076caecfa.json',
48 toolbar:$('<div class="clearfix"></div>').rs_toolbar({ 50 toolbar:$('<div class="clearfix"></div>').rs_toolbar({
49 - title: resource.brand.grid.title, 51 + title: resource.grid.title,
50 - authz:getAuthzUtils('brand'), 52 + authz:base.getAuthz('brand'),
51 buttons:[{ 53 buttons:[{
52 - text:resource.btn.select, 54 + text:base.resource.btn.select,
53 - iconCls:'btn-select select-condition', 55 + iconCls:'btn-select select-condition',
54 - code:'view', 56 + code:'view',
55 - handler: function(){ 57 + handler: function(){
56 - showCondObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload); 58 + base.showCondObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload);
57 // showTreeObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload); 59 // showTreeObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload);
58 // showCondObject({ 60 // showCondObject({
59 // id:'11111111-1111-1111-1111-111111111111', 61 // id:'11111111-1111-1111-1111-111111111111',
...@@ -76,54 +78,56 @@ define(["uploadify"],function(){ ...@@ -76,54 +78,56 @@ define(["uploadify"],function(){
76 // alert(desc); 78 // alert(desc);
77 // }); 79 // });
78 } 80 }
79 - },{ 81 + },{
80 - text:resource.btn.add, 82 + text:base.resource.btn.add,
81 - iconCls:'btn-add', 83 + iconCls:'btn-add',
82 - code:'edit', 84 + code:'edit',
83 - handler: addWindow 85 + handler: addWindow
84 - },{ 86 + },{
85 - text:resource.btn.edit, 87 + text:base.resource.btn.edit,
86 - iconCls:'btn-edit', 88 + iconCls:'btn-edit',
87 - code:'edit', 89 + code:'edit',
88 - handler: editWindow 90 + handler: editWindow
89 - },{ 91 + },{
90 - text:resource.btn.remove, 92 + text:base.resource.btn.remove,
91 - iconCls:'btn-remove', 93 + iconCls:'btn-remove',
92 - code:'edit', 94 + code:'edit',
93 - handler: deleteData 95 + handler: deleteData
94 - }], 96 + }],
95 - tools:[ 97 + tools:[
96 - { 98 + {
97 - text:resource.btn.downloadExcel, 99 + text:base.resource.btn.downloadExcel,
98 - iconCls:'btn-down', 100 + iconCls:'btn-down',
99 - handler:function(){ 101 + handler:function(){
100 - var fileName="mtBrandTemplate.xlsx"; 102 + var fileName="mtBrandTemplate.xlsx";
101 - downloadExcel(fileName); 103 + base.downloadExcelTemplate(fileName);
102 - } 104 + }
103 - } ,{ 105 + } ,{
104 - text:resource.btn.refresh, 106 + text:base.resource.btn.refresh,
105 - iconCls:'btn-refresh', 107 + iconCls:'btn-refresh',
106 - handler:panelRefreshUtils 108 + handler:function(){
107 - } ,{ 109 + indexlayout.getSelectedPanel().panel("refresh");
108 - text : resource.btn.import, 110 + }
109 - iconCls : 'btn-up', 111 + } ,{
110 - id:'btn-brand-import' 112 + text : base.resource.btn.addByFile,
111 - } ] 113 + iconCls : 'btn-up',
114 + id:'btn-brand-import'
115 + } ]
112 }), 116 }),
113 - columns:[[ 117 + columns:[[
114 - {field:'ck',checkbox:true }, 118 + {field:'ck',checkbox:true },
115 - /*{field:'id',title:'编号', width:100, align:"center"},*/ 119 + /*{field:'id',title:'编号', width:100, align:"center"},*/
116 - {field:'BRNAME',title:resource.brand.grid.BRNAME, width:120}, 120 + {field:'BRNAME',title:resource.grid.BRNAME, width:120},
117 - {field:'BRDESC',title:resource.brand.grid.BRDESC, width:200}, 121 + {field:'BRDESC',title:resource.grid.BRDESC, width:200},
118 - {field:'BRCODE',title:resource.brand.grid.BRCODE, width:120}, 122 + {field:'BRCODE',title:resource.grid.BRCODE, width:120},
119 - {field:'PTVALID',title:resource.brand.grid.PTVALID, width:80,formatter: function(value,row,index){ 123 + {field:'PTVALID',title:resource.grid.PTVALID, width:80,formatter: function(value,row,index){
120 - if(parseInt(value)==1){ 124 + if(parseInt(value)==1){
121 - return resource.btn.yes; 125 + return base.resource.btn.yes;
122 - }else if(parseInt(value)==0){ 126 + }else if(parseInt(value)==0){
123 - return resource.btn.no; 127 + return base.resource.btn.no;
124 - }else{return "";} 128 + }else{return "";}
125 - }} 129 + }}
126 - ]] 130 + ]]
127 }); 131 });
128 } 132 }
129 //初始化dialog 133 //初始化dialog
...@@ -131,20 +135,20 @@ define(["uploadify"],function(){ ...@@ -131,20 +135,20 @@ define(["uploadify"],function(){
131 $(document.body).children(".window").children(".data-brand-dialog").parent().remove(); 135 $(document.body).children(".window").children(".data-brand-dialog").parent().remove();
132 body.children(".window").children(".data-brand-dialog").remove(); 136 body.children(".window").children(".data-brand-dialog").remove();
133 var tempWin = page.children(".data-brand-dialog"); 137 var tempWin = page.children(".data-brand-dialog");
134 - tempWin.dialog({ 138 + tempWin.dialog({
135 buttons:[{ 139 buttons:[{
136 - text: resource.btn.confirm, 140 + text: base.resource.btn.confirm,
137 - handler:function(){ 141 + handler:function(){
138 - editSubmit(); 142 + editSubmit();
139 - } 143 + }
140 - }, 144 + },
141 - { 145 + {
142 - text: resource.btn.cancel, 146 + text: base.resource.btn.cancel,
143 - handler:hideWindow 147 + handler:hideWindow
144 - }], 148 + }],
145 closed:true, 149 closed:true,
146 width: 500, 150 width: 500,
147 - height: 'auto', 151 + height: 'auto',
148 closed: true, 152 closed: true,
149 modal: true 153 modal: true
150 }); 154 });
...@@ -155,18 +159,18 @@ define(["uploadify"],function(){ ...@@ -155,18 +159,18 @@ define(["uploadify"],function(){
155 function hideWindow(){ 159 function hideWindow(){
156 window.dialog("close"); 160 window.dialog("close");
157 } 161 }
158 - 162 +
159 //添加页面弹出绑定按钮 163 //添加页面弹出绑定按钮
160 function addWindow(){ 164 function addWindow(){
161 window.removeClass("hide"); 165 window.removeClass("hide");
162 - maxlengthUtils(txtName,20); 166 + base.maxlength(txtName,20);
163 - maxlengthUtils(txtCode,10); 167 + base.maxlength(txtCode,10);
164 window.find(".addForm").form("clear"); 168 window.find(".addForm").form("clear");
165 - txtValid.combobox("setValue","1"); 169 + txtValid.combobox("setValue","1");
166 - window.window("center").dialog('setTitle',resource.brand.addDialog.title).dialog("open"); 170 + window.window("center").dialog('setTitle',resource.addDialog.title).dialog("open");
167 window.addClass("add"); 171 window.addClass("add");
168 } 172 }
169 - 173 +
170 //添加确认 174 //添加确认
171 // function addSubmit(){ 175 // function addSubmit(){
172 // window.removeClass("edit").find(".addForm").form('submit', { 176 // window.removeClass("edit").find(".addForm").form('submit', {
...@@ -182,16 +186,16 @@ define(["uploadify"],function(){ ...@@ -182,16 +186,16 @@ define(["uploadify"],function(){
182 // } 186 // }
183 // }); 187 // });
184 // } 188 // }
185 - //编辑页面弹出绑定按钮 189 + //编辑页面弹出绑定按钮
186 function editWindow(){ 190 function editWindow(){
187 - maxlengthUtils(txtName,20); 191 + base.maxlength(txtName,20);
188 - maxlengthUtils(txtCode,10); 192 + base.maxlength(txtCode,10);
189 var row = getSelectedRow(); 193 var row = getSelectedRow();
190 if(row == null){ 194 if(row == null){
191 - $.messager.alert(resource.msg_title, resource.brand.editDialog.tip); 195 + $.messager.alert(base.resource.msg_title, resource.editDialog.tip);
192 }else{ 196 }else{
193 window.removeClass("hide"); 197 window.removeClass("hide");
194 - var edit = window.window("center").dialog('setTitle',resource.brand.editDialog.title).dialog("open").find(".addForm"); 198 + var edit = window.window("center").dialog('setTitle',resource.editDialog.title).dialog("open").find(".addForm");
195 window.addClass("edit"); 199 window.addClass("edit");
196 edit.form("load", getSelectedRow()); 200 edit.form("load", getSelectedRow());
197 } 201 }
...@@ -199,23 +203,23 @@ define(["uploadify"],function(){ ...@@ -199,23 +203,23 @@ define(["uploadify"],function(){
199 //编辑确认 203 //编辑确认
200 function editSubmit(){ 204 function editSubmit(){
201 if(!window.find(".addForm").form("validate")){ 205 if(!window.find(".addForm").form("validate")){
202 - return; 206 + return;
203 - } 207 + }
204 var param={ 208 var param={
205 - name:txtName.textbox('getValue'), 209 + name:txtName.textbox('getValue'),
206 - desc:txtDesc.textbox('getValue'), 210 + desc:txtDesc.textbox('getValue'),
207 - code:txtCode.textbox('getValue'), 211 + code:txtCode.textbox('getValue'),
208 - valid:txtValid.combobox('getValue') 212 + valid:txtValid.combobox('getValue')
209 }; 213 };
210 if(txtId.val()!=""){ 214 if(txtId.val()!=""){
211 param["id"]=txtId.val(); 215 param["id"]=txtId.val();
212 } 216 }
213 $.JSON(txtId.val()==""?"./brand/insert.json":"./brand/update.json",param,function(result){ 217 $.JSON(txtId.val()==""?"./brand/insert.json":"./brand/update.json",param,function(result){
214 - if(responseUtils(result)){ 218 + if($.response(result)){
215 window.dialog("close"); 219 window.dialog("close");
216 datagridReload(); 220 datagridReload();
217 } 221 }
218 - }); 222 + });
219 // window.find(".addForm").form('submit', { 223 // window.find(".addForm").form('submit', {
220 // url : txtId.val()==""?"./brand/insert.json":"./brand/update.json", 224 // url : txtId.val()==""?"./brand/insert.json":"./brand/update.json",
221 // onSubmit : function() { 225 // onSubmit : function() {
...@@ -229,19 +233,19 @@ define(["uploadify"],function(){ ...@@ -229,19 +233,19 @@ define(["uploadify"],function(){
229 // } 233 // }
230 // }); 234 // });
231 } 235 }
232 - 236 +
233 //删除 237 //删除
234 function deleteData(){ 238 function deleteData(){
235 var accountSet = getSelectedRow(); 239 var accountSet = getSelectedRow();
236 if(accountSet == null){ 240 if(accountSet == null){
237 - return $.messager.alert(resource.msg_title, resource.brand.removeDialog.tip); 241 + return $.messager.alert(base.resource.msg_title, resource.removeDialog.tip);
238 }else if(accountSet.id=='1'){ 242 }else if(accountSet.id=='1'){
239 - return $.messager.alert(resource.msg_title, resource.brand.removeDialog.deBrand); 243 + return $.messager.alert(base.resource.msg_title, resource.removeDialog.deBrand);
240 } 244 }
241 - $.messager.confirm(resource.msg_title, resource.brand.removeDialog.title, function(r){ 245 + $.messager.confirm(base.resource.msg_title, resource.removeDialog.title, function(r){
242 if (r){ 246 if (r){
243 $.JSON("./brand/delete.json", accountSet, function(result){ 247 $.JSON("./brand/delete.json", accountSet, function(result){
244 - if(responseUtils(result)){ 248 + if($.response(result)){
245 datagridReload(); 249 datagridReload();
246 } 250 }
247 }); 251 });
...@@ -252,7 +256,7 @@ define(["uploadify"],function(){ ...@@ -252,7 +256,7 @@ define(["uploadify"],function(){
252 if(params){ 256 if(params){
253 datagrid.datagrid("reload",params); 257 datagrid.datagrid("reload",params);
254 }else{ 258 }else{
255 - datagrid.datagrid("reload",getCondObjectValue('22726b54-5748-4926-82ed-abe076caecfa')); 259 + datagrid.datagrid("reload",base.getCondObjectValue('22726b54-5748-4926-82ed-abe076caecfa'));
256 } 260 }
257 } 261 }
258 function getSelectedRow(){ 262 function getSelectedRow(){
...@@ -265,8 +269,8 @@ define(["uploadify"],function(){ ...@@ -265,8 +269,8 @@ define(["uploadify"],function(){
265 valid:row.PTVALID 269 valid:row.PTVALID
266 }:null; 270 }:null;
267 } 271 }
268 - 272 +
269 - 273 +
270 $("#btn-brand-import").uploadify({ 274 $("#btn-brand-import").uploadify({
271 width: 70, 275 width: 70,
272 swf:'js/third/uploadify/uploadify.swf', 276 swf:'js/third/uploadify/uploadify.swf',
...@@ -293,6 +297,7 @@ define(["uploadify"],function(){ ...@@ -293,6 +297,7 @@ define(["uploadify"],function(){
293 $("#btn-brand-import").find("#btn-brand-import-button").remove(); 297 $("#btn-brand-import").find("#btn-brand-import-button").remove();
294 $("#btn-brand-import").append('<a href="javascript:void(0);" class="button l-btn l-btn-small" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">导入</span><span class="l-btn-icon btn-up">&nbsp;</span></span></a>') 298 $("#btn-brand-import").append('<a href="javascript:void(0);" class="button l-btn l-btn-small" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">导入</span><span class="l-btn-icon btn-up">&nbsp;</span></span></a>')
295 }()) 299 }())
296 - 300 +
301 + }
297 } 302 }
298 }); 303 });
...\ No newline at end of file ...\ No newline at end of file
......