Toggle navigation
Toggle navigation
This project
Loading...
Sign in
runsa
/
crm
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Anthony
2016-09-07 13:18:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9d59d6bb27906da5b66ae53d033ef6dc098f771f
9d59d6bb
1 parent
5e79d492
brand 模块化
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
168 deletions
portal/portal.web/src/main/webapp/js/views/brand/index.js
portal/portal.web/src/main/webapp/js/views/brand/index.js
View file @
9d59d6b
define
([
"uploadify"
],
function
(){
return
function
(
sessionId
,
rootUrl
){
var
body
=
$
(
document
.
body
);
var
pannel
=
getSelectedPanel
();
//初始化面板
var
page
=
pannel
.
children
(
".data-brand"
).
layout
({
fit
:
true
});
//定义面板内div
var
datagrid
=
initDatagrid
();
//初始化数据表格
var
window
=
initWindow
();
//初始化添加页面
define
([
'i18n!brand/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
(
'.data-brand'
).
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
=
'22726b54-5748-4926-82ed-abe076caecfa'
;
},
initialize
:
function
()
{
initDatagrid
(
this
);
function
initDatagrid
(
inst
){
return
inst
.
grid
.
datagrid
({
url
:
'./query/'
+
inst
.
queryId
+
'.json'
,
toolbar
:
$
(
'<div class="clearfix"></div>'
).
rs_toolbar
({
title
:
resource
.
grid
.
title
,
authz
:
base
.
getAuthz
(
'brand'
),
buttons
:[{
text
:
base
.
resource
.
btn
.
select
,
iconCls
:
'btn-select select-condition'
,
code
:
'view'
,
handler
:
function
(){
showCondObject
(
'22726b54-5748-4926-82ed-abe076caecfa'
,
datagridReload
);
}
},{
text
:
base
.
resource
.
btn
.
add
,
iconCls
:
'btn-add'
,
code
:
'edit'
,
handler
:
function
(){
addWindow
.
call
(
this
,
inst
)
}
},{
text
:
base
.
resource
.
btn
.
edit
,
iconCls
:
'btn-edit'
,
code
:
'edit'
,
handler
:
function
(){
editWindow
.
call
(
this
,
inst
)
}
},{
text
:
base
.
resource
.
btn
.
remove
,
iconCls
:
'btn-remove'
,
code
:
'edit'
,
handler
:
function
()
{
deleteData
.
call
(
this
,
inst
)
}
}],
tools
:[{
text
:
base
.
resource
.
btn
.
refresh
,
iconCls
:
'btn-refresh'
,
handler
:
function
(){
datagridReload
.
call
(
inst
)
}
}]
}),
columns
:[[
{
field
:
'ck'
,
checkbox
:
true
},
/*{field:'id',title:'编号', width:100, align:"center"},*/
{
field
:
'BRNAME'
,
title
:
resource
.
grid
.
BRNAME
,
width
:
120
},
{
field
:
'BRDESC'
,
title
:
resource
.
grid
.
BRDESC
,
width
:
200
},
{
field
:
'BRCODE'
,
title
:
resource
.
grid
.
BRCODE
,
width
:
120
},
{
field
:
'PTVALID'
,
title
:
resource
.
grid
.
PTVALID
,
width
:
80
,
formatter
:
function
(
value
,
row
,
index
){
if
(
parseInt
(
value
)
==
1
){
return
base
.
resource
.
btn
.
yes
;
}
else
if
(
parseInt
(
value
)
==
0
){
return
base
.
resource
.
btn
.
no
;
}
else
{
return
""
;}
}}
]]
});
}
},
windowDialog
:
initWindow
(),
//初始化添加页面
handler
:
function
()
{
}
});
var
form
=
window
.
children
(
".addForm"
);
var
txtId
=
form
.
find
(
"input[name='id']"
);
var
txtName
=
form
.
find
(
"input[name='name']"
);
var
txtDesc
=
form
.
find
(
"input[name='desc']"
);
var
txtCode
=
form
.
find
(
"input[name='code']"
);
var
txtValid
=
form
.
find
(
"select[name='valid']"
);
form
.
find
(
"span.name"
).
html
(
resource
.
brand
.
name
);
form
.
find
(
"div.desc"
).
html
(
resource
.
brand
.
desc
);
form
.
find
(
"span.code"
).
html
(
resource
.
brand
.
code
);
form
.
find
(
"div.valid"
).
html
(
resource
.
brand
.
valid
);
form
.
find
(
"span.name"
).
html
(
resource
.
name
);
form
.
find
(
"div.desc"
).
html
(
resource
.
desc
);
form
.
find
(
"span.code"
).
html
(
resource
.
code
);
form
.
find
(
"div.valid"
).
html
(
resource
.
valid
);
maxlengthUtils
(
txtName
,
20
);
txtName
.
textbox
({
required
:
true
...
...
@@ -42,110 +115,26 @@ define(["uploadify"],function(){
});
window
.
find
(
".cancel"
).
bind
(
"click"
,
hideWindow
);
//绑定页面取消按钮
//初始化表格
function
initDatagrid
(){
return
page
.
layout
(
'panel'
,
'center'
).
children
(
'.data-brand-table'
).
datagrid
({
url
:
'./query/22726b54-5748-4926-82ed-abe076caecfa.json'
,
toolbar
:
$
(
'<div class="clearfix"></div>'
).
rs_toolbar
({
title
:
resource
.
brand
.
grid
.
title
,
authz
:
getAuthzUtils
(
'brand'
),
buttons
:[{
text
:
resource
.
btn
.
select
,
iconCls
:
'btn-select select-condition'
,
code
:
'view'
,
handler
:
function
(){
showCondObject
(
'22726b54-5748-4926-82ed-abe076caecfa'
,
datagridReload
);
// showTreeObject('22726b54-5748-4926-82ed-abe076caecfa',datagridReload);
// showCondObject({
// id:'11111111-1111-1111-1111-111111111111',
// showGrid:true,
// singleSelect:false,
// disableSelect:true,
// onCascade:{
// "5ac16b69-77e4-4710-8bcd-63fc8685fd1a":{
// change:function(newValue,oldValue){
// return "f48ab2d7-5e71-49eb-9c45-47df6cda15fb"; /*指定取field id的值*/
// }
// },
// "f48ab2d7-5e71-49eb-9c45-47df6cda15fb":{
// fields:function(params,node){
// return "5ac16b69-77e4-4710-8bcd-63fc8685fd1a"; /*指定取field id的值*/
// }
// }
// }
// },function(exps,rowCount,desc){
// alert(desc);
// });
}
},{
text
:
resource
.
btn
.
add
,
iconCls
:
'btn-add'
,
code
:
'edit'
,
handler
:
addWindow
},{
text
:
resource
.
btn
.
edit
,
iconCls
:
'btn-edit'
,
code
:
'edit'
,
handler
:
editWindow
},{
text
:
resource
.
btn
.
remove
,
iconCls
:
'btn-remove'
,
code
:
'edit'
,
handler
:
deleteData
}],
tools
:[
{
text
:
resource
.
btn
.
downloadExcel
,
iconCls
:
'btn-down'
,
handler
:
function
(){
var
fileName
=
"mtBrandTemplate.xlsx"
;
downloadExcel
(
fileName
);
}
}
,{
text
:
resource
.
btn
.
refresh
,
iconCls
:
'btn-refresh'
,
handler
:
panelRefreshUtils
}
,{
text
:
resource
.
btn
.
import
,
iconCls
:
'btn-up'
,
id
:
'btn-brand-import'
}
]
}),
columns
:[[
{
field
:
'ck'
,
checkbox
:
true
},
/*{field:'id',title:'编号', width:100, align:"center"},*/
{
field
:
'BRNAME'
,
title
:
resource
.
brand
.
grid
.
BRNAME
,
width
:
120
},
{
field
:
'BRDESC'
,
title
:
resource
.
brand
.
grid
.
BRDESC
,
width
:
200
},
{
field
:
'BRCODE'
,
title
:
resource
.
brand
.
grid
.
BRCODE
,
width
:
120
},
{
field
:
'PTVALID'
,
title
:
resource
.
brand
.
grid
.
PTVALID
,
width
:
80
,
formatter
:
function
(
value
,
row
,
index
){
if
(
parseInt
(
value
)
==
1
){
return
resource
.
btn
.
yes
;
}
else
if
(
parseInt
(
value
)
==
0
){
return
resource
.
btn
.
no
;
}
else
{
return
""
;}
}}
]]
});
}
//初始化dialog
function
initWindow
(){
$
(
document
.
body
).
children
(
".window"
).
children
(
".data-brand-dialog"
).
parent
().
remove
();
body
.
children
(
".window"
).
children
(
".data-brand-dialog"
).
remove
();
var
tempWin
=
page
.
children
(
".data-brand-dialog"
);
$
(
document
.
body
)
.
children
(
".window"
).
children
(
".data-brand-dialog"
).
remove
();
var
tempWin
=
$
(
document
.
body
)
.
children
(
".data-brand-dialog"
);
tempWin
.
dialog
({
buttons
:[{
text
:
resource
.
btn
.
confirm
,
text
:
base
.
resource
.
btn
.
confirm
,
handler
:
function
(){
editSubmit
();
}
},
{
text
:
resource
.
btn
.
cancel
,
text
:
base
.
resource
.
btn
.
cancel
,
handler
:
hideWindow
}],
closed
:
true
,
width
:
500
,
height
:
'auto'
,
closed
:
true
,
modal
:
true
});
return
tempWin
;
...
...
@@ -157,43 +146,29 @@ define(["uploadify"],function(){
}
//添加页面弹出绑定按钮
function
addWindow
(){
function
addWindow
(
inst
){
window
.
removeClass
(
"hide"
);
maxlengthUtils
(
txtName
,
20
);
maxlengthUtils
(
txtCode
,
10
);
window
.
find
(
".addForm"
).
form
(
"clear"
);
txtValid
.
combobox
(
"setValue"
,
"1"
);
window
.
window
(
"center"
).
dialog
(
'setTitle'
,
resource
.
brand
.
addDialog
.
title
).
dialog
(
"open"
);
window
.
window
(
"center"
).
dialog
(
'setTitle'
,
resource
.
addDialog
.
title
).
dialog
(
"open"
);
window
.
addClass
(
"add"
);
}
//添加确认
// function addSubmit(){
// window.removeClass("edit").find(".addForm").form('submit', {
// url : "./brand/update.json",
// onSubmit : function() {
// return $(this).form("validate");
// },
// success : function(result) {
// if(responseUtils(result)){//统一返回标准处理 responseUtils
// window.dialog("close");
// datagridReload();
// }
// }
// });
// }
//编辑页面弹出绑定按钮
function
editWindow
(){
function
editWindow
(
inst
){
maxlengthUtils
(
txtName
,
20
);
maxlengthUtils
(
txtCode
,
10
);
var
row
=
getSelectedRow
(
);
var
row
=
getSelectedRow
.
call
(
inst
);
if
(
row
==
null
){
$
.
messager
.
alert
(
resource
.
msg_title
,
resource
.
brand
.
editDialog
.
tip
);
}
else
{
window
.
removeClass
(
"hide"
);
var
edit
=
window
.
window
(
"center"
).
dialog
(
'setTitle'
,
resource
.
brand
.
editDialog
.
title
).
dialog
(
"open"
).
find
(
".addForm"
);
window
.
addClass
(
"edit"
);
edit
.
form
(
"load"
,
getSelectedRow
(
));
edit
.
form
(
"load"
,
getSelectedRow
.
call
(
inst
));
}
}
//编辑确认
...
...
@@ -216,23 +191,11 @@ define(["uploadify"],function(){
datagridReload
();
}
});
// window.find(".addForm").form('submit', {
// url : txtId.val()==""?"./brand/insert.json":"./brand/update.json",
// onSubmit : function() {
// return $(this).form("validate");
// },
// success : function(result) {
// if(responseUtils(result)){
// window.dialog("close");
// datagridReload();
// }
// }
// });
}
//删除
function
deleteData
(
){
var
accountSet
=
getSelectedRow
(
);
function
deleteData
(
inst
){
var
accountSet
=
getSelectedRow
.
call
(
inst
);
if
(
accountSet
==
null
){
return
$
.
messager
.
alert
(
resource
.
msg_title
,
resource
.
brand
.
removeDialog
.
tip
);
}
else
if
(
accountSet
.
id
==
'1'
){
...
...
@@ -242,7 +205,7 @@ define(["uploadify"],function(){
if
(
r
){
$
.
JSON
(
"./brand/delete.json"
,
accountSet
,
function
(
result
){
if
(
responseUtils
(
result
)){
datagridReload
(
);
this
.
grid
.
datagrid
(
"reload"
);
}
});
}
...
...
@@ -250,49 +213,20 @@ define(["uploadify"],function(){
}
function
datagridReload
(
params
){
if
(
params
){
data
grid
.
datagrid
(
"reload"
,
params
);
this
.
grid
.
datagrid
(
"reload"
,
params
);
}
else
{
datagrid
.
datagrid
(
"reload"
,
getCondObjectValue
(
'22726b54-5748-4926-82ed-abe076caecfa'
));
this
.
grid
.
datagrid
(
"reload"
,
base
.
getCondObjectValue
(
this
.
queryId
));
}
}
function
getSelectedRow
(){
var
row
=
data
grid
.
datagrid
(
'getSelected'
);
var
row
=
this
.
grid
.
datagrid
(
'getSelected'
);
return
row
?{
id
:
row
.
BRID
,
name
:
row
.
BRNAME
,
desc
:
row
.
BRDESC
==
undefined
?
""
:
row
.
BRDESC
,
desc
:
row
.
BRDESC
,
code
:
row
.
BRCODE
,
valid
:
row
.
PTVALID
}:
null
;
}
$
(
"#btn-brand-import"
).
uploadify
({
width
:
70
,
swf
:
'js/third/uploadify/uploadify.swf'
,
// uploader:rootUrl+'excelImport/tagUpload.json;jsessionid='+sessionId, //有参数
uploader
:
rootUrl
+
'excelImport/upload.json;jsessionid='
+
sessionId
,
//无参数
buttonText
:
''
,
buttonClass
:
'importButton'
,
multi
:
false
,
fileTypeExts
:
'*.xlsx; *.xls'
,
'formData'
:
{
'sheetCode'
:
"mtBrand"
},
onUploadSuccess
:
function
(
file
,
data
,
response
){
var
json
=
eval
(
"("
+
data
+
")"
);
var
result
=
json
.
excelResult
;
if
(
result
.
error
>
0
){
download
(
result
.
filePath
,
result
.
fileName
);
}
else
{
datagridReload
();
}
}
});
(
function
importSize
(){
$
(
"#btn-brand-import"
).
css
(
'width'
,
'90px'
);
$
(
"#btn-brand-import"
).
find
(
"#btn-brand-import-button"
).
remove
();
$
(
"#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>'
)
}())
}
});
\ No newline at end of file
...
...
Please
register
or
login
to post a comment