Showing
1 changed file
with
102 additions
and
168 deletions
1 | -define(["uploadify"],function(){ | 1 | +define(['i18n!brand/nls/resource', 'cls', 'base/index', 'index/index'], function (resource, Class, base, index){ |
2 | - return function(sessionId,rootUrl){ | 2 | + return Class({ |
3 | - var body=$(document.body); | 3 | + resource: resource, |
4 | - var pannel = getSelectedPanel();//初始化面板 | 4 | + variable: function () { |
5 | - var page = pannel.children(".data-brand").layout({fit:true});//定义面板内div | 5 | + var panel = index.getSelectedPanel(); |
6 | - var datagrid = initDatagrid();//初始化数据表格 | 6 | + this.page = panel.children('.data-brand').layout({fit: true}); |
7 | - var window = initWindow();//初始化添加页面 | 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 = '22726b54-5748-4926-82ed-abe076caecfa'; | ||
11 | + }, | ||
12 | + initialize: function () { | ||
13 | + initDatagrid(this); | ||
14 | + function initDatagrid(inst){ | ||
15 | + return inst.grid.datagrid({ | ||
16 | + url:'./query/' + inst.queryId + '.json', | ||
17 | + toolbar:$('<div class="clearfix"></div>').rs_toolbar({ | ||
18 | + title: resource.grid.title, | ||
19 | + authz:base.getAuthz('brand'), | ||
20 | + buttons:[{ | ||
21 | + text:base.resource.btn.select, | ||
22 | + iconCls:'btn-select select-condition', | ||
23 | + code:'view', | ||
24 | + handler: function(){ | ||
25 | + showCondObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload); | ||
26 | + } | ||
27 | + },{ | ||
28 | + text:base.resource.btn.add, | ||
29 | + iconCls:'btn-add', | ||
30 | + code:'edit', | ||
31 | + handler: function(){ | ||
32 | + addWindow.call(this,inst) | ||
33 | + } | ||
34 | + },{ | ||
35 | + text:base.resource.btn.edit, | ||
36 | + iconCls:'btn-edit', | ||
37 | + code:'edit', | ||
38 | + handler: function(){ | ||
39 | + editWindow.call(this,inst) | ||
40 | + } | ||
41 | + },{ | ||
42 | + text:base.resource.btn.remove, | ||
43 | + iconCls:'btn-remove', | ||
44 | + code:'edit', | ||
45 | + handler: function () { | ||
46 | + deleteData.call(this,inst) | ||
47 | + } | ||
48 | + }], | ||
49 | + tools:[{ | ||
50 | + text:base.resource.btn.refresh, | ||
51 | + iconCls:'btn-refresh', | ||
52 | + handler:function(){ | ||
53 | + datagridReload.call(inst) | ||
54 | + } | ||
55 | + }] | ||
56 | + }), | ||
57 | + columns:[[ | ||
58 | + {field:'ck',checkbox:true }, | ||
59 | + /*{field:'id',title:'编号', width:100, align:"center"},*/ | ||
60 | + {field:'BRNAME',title:resource.grid.BRNAME, width:120}, | ||
61 | + {field:'BRDESC',title:resource.grid.BRDESC, width:200}, | ||
62 | + {field:'BRCODE',title:resource.grid.BRCODE, width:120}, | ||
63 | + {field:'PTVALID',title:resource.grid.PTVALID, width:80,formatter: function(value,row,index){ | ||
64 | + if(parseInt(value)==1){ | ||
65 | + return base.resource.btn.yes; | ||
66 | + }else if(parseInt(value)==0){ | ||
67 | + return base.resource.btn.no; | ||
68 | + }else{return "";} | ||
69 | + }} | ||
70 | + ]] | ||
71 | + }); | ||
72 | + } | ||
73 | + }, | ||
74 | + windowDialog: initWindow(),//初始化添加页面 | ||
75 | + handler: function () { | ||
76 | + | ||
77 | + } | ||
78 | + }); | ||
79 | + | ||
80 | + | ||
8 | var form=window.children(".addForm"); | 81 | var form=window.children(".addForm"); |
9 | var txtId=form.find("input[name='id']"); | 82 | var txtId=form.find("input[name='id']"); |
10 | var txtName=form.find("input[name='name']"); | 83 | var txtName=form.find("input[name='name']"); |
11 | var txtDesc=form.find("input[name='desc']"); | 84 | var txtDesc=form.find("input[name='desc']"); |
12 | var txtCode=form.find("input[name='code']"); | 85 | var txtCode=form.find("input[name='code']"); |
13 | var txtValid=form.find("select[name='valid']"); | 86 | var txtValid=form.find("select[name='valid']"); |
14 | - form.find("span.name").html(resource.brand.name); | 87 | + form.find("span.name").html(resource.name); |
15 | - form.find("div.desc").html(resource.brand.desc); | 88 | + form.find("div.desc").html(resource.desc); |
16 | - form.find("span.code").html(resource.brand.code); | 89 | + form.find("span.code").html(resource.code); |
17 | - form.find("div.valid").html(resource.brand.valid); | 90 | + form.find("div.valid").html(resource.valid); |
18 | maxlengthUtils(txtName,20); | 91 | maxlengthUtils(txtName,20); |
19 | txtName.textbox({ | 92 | txtName.textbox({ |
20 | required:true | 93 | required:true |
... | @@ -42,110 +115,26 @@ define(["uploadify"],function(){ | ... | @@ -42,110 +115,26 @@ define(["uploadify"],function(){ |
42 | }); | 115 | }); |
43 | window.find(".cancel").bind("click", hideWindow);//绑定页面取消按钮 | 116 | window.find(".cancel").bind("click", hideWindow);//绑定页面取消按钮 |
44 | //初始化表格 | 117 | //初始化表格 |
45 | - function initDatagrid(){ | 118 | + |
46 | - return page.layout('panel','center').children('.data-brand-table').datagrid({ | ||
47 | - url:'./query/22726b54-5748-4926-82ed-abe076caecfa.json', | ||
48 | - toolbar:$('<div class="clearfix"></div>').rs_toolbar({ | ||
49 | - title: resource.brand.grid.title, | ||
50 | - authz:getAuthzUtils('brand'), | ||
51 | - buttons:[{ | ||
52 | - text:resource.btn.select, | ||
53 | - iconCls:'btn-select select-condition', | ||
54 | - code:'view', | ||
55 | - handler: function(){ | ||
56 | - showCondObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload); | ||
57 | -// showTreeObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload); | ||
58 | -// showCondObject({ | ||
59 | -// id:'11111111-1111-1111-1111-111111111111', | ||
60 | -// showGrid:true, | ||
61 | -// singleSelect:false, | ||
62 | -// disableSelect:true, | ||
63 | -// onCascade:{ | ||
64 | -// "5ac16b69-77e4-4710-8bcd-63fc8685fd1a":{ | ||
65 | -// change:function(newValue,oldValue){ | ||
66 | -// return "f48ab2d7-5e71-49eb-9c45-47df6cda15fb"; /*指定取field id的值*/ | ||
67 | -// } | ||
68 | -// }, | ||
69 | -// "f48ab2d7-5e71-49eb-9c45-47df6cda15fb":{ | ||
70 | -// fields:function(params,node){ | ||
71 | -// return "5ac16b69-77e4-4710-8bcd-63fc8685fd1a"; /*指定取field id的值*/ | ||
72 | -// } | ||
73 | -// } | ||
74 | -// } | ||
75 | -// },function(exps,rowCount,desc){ | ||
76 | -// alert(desc); | ||
77 | -// }); | ||
78 | - } | ||
79 | - },{ | ||
80 | - text:resource.btn.add, | ||
81 | - iconCls:'btn-add', | ||
82 | - code:'edit', | ||
83 | - handler: addWindow | ||
84 | - },{ | ||
85 | - text:resource.btn.edit, | ||
86 | - iconCls:'btn-edit', | ||
87 | - code:'edit', | ||
88 | - handler: editWindow | ||
89 | - },{ | ||
90 | - text:resource.btn.remove, | ||
91 | - iconCls:'btn-remove', | ||
92 | - code:'edit', | ||
93 | - handler: deleteData | ||
94 | - }], | ||
95 | - tools:[ | ||
96 | - { | ||
97 | - text:resource.btn.downloadExcel, | ||
98 | - iconCls:'btn-down', | ||
99 | - handler:function(){ | ||
100 | - var fileName="mtBrandTemplate.xlsx"; | ||
101 | - downloadExcel(fileName); | ||
102 | - } | ||
103 | - } ,{ | ||
104 | - text:resource.btn.refresh, | ||
105 | - iconCls:'btn-refresh', | ||
106 | - handler:panelRefreshUtils | ||
107 | - } ,{ | ||
108 | - text : resource.btn.import, | ||
109 | - iconCls : 'btn-up', | ||
110 | - id:'btn-brand-import' | ||
111 | - } ] | ||
112 | - }), | ||
113 | - columns:[[ | ||
114 | - {field:'ck',checkbox:true }, | ||
115 | - /*{field:'id',title:'编号', width:100, align:"center"},*/ | ||
116 | - {field:'BRNAME',title:resource.brand.grid.BRNAME, width:120}, | ||
117 | - {field:'BRDESC',title:resource.brand.grid.BRDESC, width:200}, | ||
118 | - {field:'BRCODE',title:resource.brand.grid.BRCODE, width:120}, | ||
119 | - {field:'PTVALID',title:resource.brand.grid.PTVALID, width:80,formatter: function(value,row,index){ | ||
120 | - if(parseInt(value)==1){ | ||
121 | - return resource.btn.yes; | ||
122 | - }else if(parseInt(value)==0){ | ||
123 | - return resource.btn.no; | ||
124 | - }else{return "";} | ||
125 | - }} | ||
126 | - ]] | ||
127 | - }); | ||
128 | - } | ||
129 | //初始化dialog | 119 | //初始化dialog |
130 | function initWindow(){ | 120 | function initWindow(){ |
131 | $(document.body).children(".window").children(".data-brand-dialog").parent().remove(); | 121 | $(document.body).children(".window").children(".data-brand-dialog").parent().remove(); |
132 | - body.children(".window").children(".data-brand-dialog").remove(); | 122 | + $(document.body).children(".window").children(".data-brand-dialog").remove(); |
133 | - var tempWin = page.children(".data-brand-dialog"); | 123 | + var tempWin = $(document.body).children(".data-brand-dialog"); |
134 | tempWin.dialog({ | 124 | tempWin.dialog({ |
135 | buttons:[{ | 125 | buttons:[{ |
136 | - text: resource.btn.confirm, | 126 | + text: base.resource.btn.confirm, |
137 | handler:function(){ | 127 | handler:function(){ |
138 | editSubmit(); | 128 | editSubmit(); |
139 | } | 129 | } |
140 | }, | 130 | }, |
141 | { | 131 | { |
142 | - text: resource.btn.cancel, | 132 | + text: base.resource.btn.cancel, |
143 | handler:hideWindow | 133 | handler:hideWindow |
144 | }], | 134 | }], |
145 | closed:true, | 135 | closed:true, |
146 | width: 500, | 136 | width: 500, |
147 | height: 'auto', | 137 | height: 'auto', |
148 | - closed: true, | ||
149 | modal: true | 138 | modal: true |
150 | }); | 139 | }); |
151 | return tempWin; | 140 | return tempWin; |
... | @@ -157,43 +146,29 @@ define(["uploadify"],function(){ | ... | @@ -157,43 +146,29 @@ define(["uploadify"],function(){ |
157 | } | 146 | } |
158 | 147 | ||
159 | //添加页面弹出绑定按钮 | 148 | //添加页面弹出绑定按钮 |
160 | - function addWindow(){ | 149 | + function addWindow(inst){ |
161 | window.removeClass("hide"); | 150 | window.removeClass("hide"); |
162 | maxlengthUtils(txtName,20); | 151 | maxlengthUtils(txtName,20); |
163 | maxlengthUtils(txtCode,10); | 152 | maxlengthUtils(txtCode,10); |
164 | window.find(".addForm").form("clear"); | 153 | window.find(".addForm").form("clear"); |
165 | txtValid.combobox("setValue","1"); | 154 | txtValid.combobox("setValue","1"); |
166 | - window.window("center").dialog('setTitle',resource.brand.addDialog.title).dialog("open"); | 155 | + window.window("center").dialog('setTitle',resource.addDialog.title).dialog("open"); |
167 | window.addClass("add"); | 156 | window.addClass("add"); |
168 | } | 157 | } |
169 | 158 | ||
170 | - //添加确认 | 159 | + |
171 | -// function addSubmit(){ | ||
172 | -// window.removeClass("edit").find(".addForm").form('submit', { | ||
173 | -// url : "./brand/update.json", | ||
174 | -// onSubmit : function() { | ||
175 | -// return $(this).form("validate"); | ||
176 | -// }, | ||
177 | -// success : function(result) { | ||
178 | -// if(responseUtils(result)){//统一返回标准处理 responseUtils | ||
179 | -// window.dialog("close"); | ||
180 | -// datagridReload(); | ||
181 | -// } | ||
182 | -// } | ||
183 | -// }); | ||
184 | -// } | ||
185 | //编辑页面弹出绑定按钮 | 160 | //编辑页面弹出绑定按钮 |
186 | - function editWindow(){ | 161 | + function editWindow(inst){ |
187 | maxlengthUtils(txtName,20); | 162 | maxlengthUtils(txtName,20); |
188 | maxlengthUtils(txtCode,10); | 163 | maxlengthUtils(txtCode,10); |
189 | - var row = getSelectedRow(); | 164 | + var row = getSelectedRow.call(inst); |
190 | if(row == null){ | 165 | if(row == null){ |
191 | $.messager.alert(resource.msg_title, resource.brand.editDialog.tip); | 166 | $.messager.alert(resource.msg_title, resource.brand.editDialog.tip); |
192 | }else{ | 167 | }else{ |
193 | window.removeClass("hide"); | 168 | window.removeClass("hide"); |
194 | var edit = window.window("center").dialog('setTitle',resource.brand.editDialog.title).dialog("open").find(".addForm"); | 169 | var edit = window.window("center").dialog('setTitle',resource.brand.editDialog.title).dialog("open").find(".addForm"); |
195 | window.addClass("edit"); | 170 | window.addClass("edit"); |
196 | - edit.form("load", getSelectedRow()); | 171 | + edit.form("load", getSelectedRow.call(inst)); |
197 | } | 172 | } |
198 | } | 173 | } |
199 | //编辑确认 | 174 | //编辑确认 |
... | @@ -216,23 +191,11 @@ define(["uploadify"],function(){ | ... | @@ -216,23 +191,11 @@ define(["uploadify"],function(){ |
216 | datagridReload(); | 191 | datagridReload(); |
217 | } | 192 | } |
218 | }); | 193 | }); |
219 | -// window.find(".addForm").form('submit', { | ||
220 | -// url : txtId.val()==""?"./brand/insert.json":"./brand/update.json", | ||
221 | -// onSubmit : function() { | ||
222 | -// return $(this).form("validate"); | ||
223 | -// }, | ||
224 | -// success : function(result) { | ||
225 | -// if(responseUtils(result)){ | ||
226 | -// window.dialog("close"); | ||
227 | -// datagridReload(); | ||
228 | -// } | ||
229 | -// } | ||
230 | -// }); | ||
231 | } | 194 | } |
232 | 195 | ||
233 | //删除 | 196 | //删除 |
234 | - function deleteData(){ | 197 | + function deleteData(inst){ |
235 | - var accountSet = getSelectedRow(); | 198 | + var accountSet = getSelectedRow.call(inst); |
236 | if(accountSet == null){ | 199 | if(accountSet == null){ |
237 | return $.messager.alert(resource.msg_title, resource.brand.removeDialog.tip); | 200 | return $.messager.alert(resource.msg_title, resource.brand.removeDialog.tip); |
238 | }else if(accountSet.id=='1'){ | 201 | }else if(accountSet.id=='1'){ |
... | @@ -242,7 +205,7 @@ define(["uploadify"],function(){ | ... | @@ -242,7 +205,7 @@ define(["uploadify"],function(){ |
242 | if (r){ | 205 | if (r){ |
243 | $.JSON("./brand/delete.json", accountSet, function(result){ | 206 | $.JSON("./brand/delete.json", accountSet, function(result){ |
244 | if(responseUtils(result)){ | 207 | if(responseUtils(result)){ |
245 | - datagridReload(); | 208 | + this.grid.datagrid("reload"); |
246 | } | 209 | } |
247 | }); | 210 | }); |
248 | } | 211 | } |
... | @@ -250,49 +213,20 @@ define(["uploadify"],function(){ | ... | @@ -250,49 +213,20 @@ define(["uploadify"],function(){ |
250 | } | 213 | } |
251 | function datagridReload(params){ | 214 | function datagridReload(params){ |
252 | if(params){ | 215 | if(params){ |
253 | - datagrid.datagrid("reload",params); | 216 | + this.grid.datagrid("reload",params); |
254 | }else{ | 217 | }else{ |
255 | - datagrid.datagrid("reload",getCondObjectValue('22726b54-5748-4926-82ed-abe076caecfa')); | 218 | + this.grid.datagrid("reload",base.getCondObjectValue(this.queryId)); |
256 | } | 219 | } |
257 | } | 220 | } |
258 | function getSelectedRow(){ | 221 | function getSelectedRow(){ |
259 | - var row = datagrid.datagrid('getSelected'); | 222 | + var row = this.grid.datagrid('getSelected'); |
260 | return row?{ | 223 | return row?{ |
261 | id:row.BRID, | 224 | id:row.BRID, |
262 | name:row.BRNAME, | 225 | name:row.BRNAME, |
263 | - desc:row.BRDESC==undefined?"":row.BRDESC, | 226 | + desc:row.BRDESC, |
264 | code:row.BRCODE, | 227 | code:row.BRCODE, |
265 | valid:row.PTVALID | 228 | valid:row.PTVALID |
266 | }:null; | 229 | }:null; |
267 | } | 230 | } |
268 | 231 | ||
269 | - | ||
270 | - $("#btn-brand-import").uploadify({ | ||
271 | - width: 70, | ||
272 | - swf:'js/third/uploadify/uploadify.swf', | ||
273 | -// uploader:rootUrl+'excelImport/tagUpload.json;jsessionid='+sessionId, //有参数 | ||
274 | - uploader:rootUrl+'excelImport/upload.json;jsessionid='+sessionId, //无参数 | ||
275 | - buttonText:'', | ||
276 | - buttonClass:'importButton', | ||
277 | - multi :false, | ||
278 | - fileTypeExts: '*.xlsx; *.xls', | ||
279 | - 'formData': { 'sheetCode': "mtBrand" }, | ||
280 | - onUploadSuccess:function (file, data, response){ | ||
281 | - var json=eval("("+data+")"); | ||
282 | - var result = json.excelResult; | ||
283 | - if(result.error>0){ | ||
284 | - download(result.filePath, result.fileName); | ||
285 | - }else{ | ||
286 | - datagridReload(); | ||
287 | - } | ||
288 | - } | ||
289 | - }); | ||
290 | - | ||
291 | - (function importSize(){ | ||
292 | - $("#btn-brand-import").css('width','90px'); | ||
293 | - $("#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"> </span></span></a>') | ||
295 | - }()) | ||
296 | - | ||
297 | - } | ||
298 | }); | 232 | }); |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment