<script>
angular.module(
"myModule"
,[]).controller(
'myCtrl'
,
function
(
$scope
) {
$scope
.kaohzbTitle =
"考核指标维护"
;
$scope
.search =
new
Object();
$scope
.isdisabled=false;
$scope
.isInfo=false;
$scope
.saveDate=
""
;
var
datalist=[{
id:1,zbname:
"中亚赛区比赛"
,zbtime:
"2015-12-03"
,zbrul1:
"胜利"
,zbrul2:
"失败"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持红方"
},{
id:2,zbname:
"日韩赛区比赛"
,zbtime:
"2015-11-11"
,zbrul1:
"胜利"
,zbrul2:
"胜利"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持蓝方"
},{
id:3,zbname:
"欧美赛区比赛"
,zbtime:
"2015-3-03"
,zbrul1:
"失败"
,zbrul2:
"胜利"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"双方相同"
},{
id:4,zbname:
"中东赛区比赛"
,zbtime:
"2016-1-05"
,zbrul1:
"胜利"
,zbrul2:
"失败"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持蓝方"
},{
id:5,zbname:
"北京赛区比赛"
,zbtime:
"2014-12-23"
,zbrul1:
"失败"
,zbrul2:
"胜利"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"双方相同"
},{
id:6,zbname:
"韩国赛区比赛"
,zbtime:
"2015-11-01"
,zbrul1:
"失败"
,zbrul2:
"胜利"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"双方相同"
},{
id:7,zbname:
"日本赛区比赛"
,zbtime:
"2011-1-23"
,zbrul1:
"胜利"
,zbrul2:
"失败"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持红方"
},{
id:8,zbname:
"中亚赛区比赛"
,zbtime:
"2013-12-15"
,zbrul1:
"失败"
,zbrul2:
"胜利"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持蓝方"
},{
id:9,zbname:
"中亚赛区比赛"
,zbtime:
"2015-10-17"
,zbrul1:
"失败"
,zbrul2:
"胜利"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持红方"
},{
id:10,zbname:
"中亚赛区比赛"
,zbtime:
"2015-11-21"
,zbrul1:
"胜利"
,zbrul2:
"胜利"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持蓝方"
},{
id:11,zbname:
"中亚赛区比赛"
,zbtime:
"2015-2-02"
,zbrul1:
"失败"
,zbrul2:
"失败"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"支持红方"
},{
id:12,zbname:
"中亚赛区比赛"
,zbtime:
"2015-2-05"
,zbrul1:
"胜利"
,zbrul2:
"失败"
,por:
"请输入说明内容"
,score:
"2:1"
,type:
"双方相同"
}];
$scope
.fun=
function
(){
var
e=window.event||arguments[0];
var
src=e.srcElement||e.target;
if
(src.nodeName==
"TD"
){
var
par=src.parentNode;
var
sd=par.getElementsByTagName(
"td"
)[0];
if
(sd.firstChild.checked==true){
sd.firstChild.checked=false;
}
else
{
$(
"tr td"
).attr(
"checked"
,false);
sd.firstChild.checked=true;
}
}
}
$scope
.refresh=
function
(){
$scope
.saveDate=datalist;
$scope
.
$watch
(
"saveDate"
,
function
(){
table_page();
$scope
.isshow=true;
});
}
$scope
.save=
function
(){
console.log(
"准备保存"
);
console.log(
$scope
.saveDate);
}
function
table_page(){
var
show_page=5;
var
page_all=$(
"#page"
).children().size();
var
current_page=1;
var
page_num=Math.
ceil
(page_all/show_page);
var
current_num=0;
var
li=
""
;
while
(page_num>current_num){
li+=
'<li class="page_num"><a href="javasctip:(0)">'
+(current_num+1)+
'</a></li>'
;
current_num++;
}
$(
"#page_num_all"
).html(li);
$(
'#page tr'
).css(
'display'
,
'none'
);
$(
'#page tr'
).slice(0, show_page).css(
'display'
,
''
);
$(
"#current_page"
).html(
" "
+current_page+
" "
);
$(
"#page_all"
).html(
" "
+page_num+
" "
);
$(
"#previous"
).click(
function
(){
var
new_page=parseInt($(
"#current_page"
).text())-1;
if
(new_page>0){
$(
"#current_page"
).html(
" "
+new_page+
" "
);
tab_page(new_page);
}
});
$(
"#next"
).click(
function
(){
var
new_page=parseInt($(
"#current_page"
).text())+1;
if
(new_page<=page_num){
$(
"#current_page"
).html(
" "
+new_page+
" "
);
tab_page(new_page);
}
});
$(
".page_num"
).click(
function
(){
var
new_page=parseInt($(this).text());
tab_page(new_page);
});
function
tab_page(index){
var
start=(index-1)*show_page;
var
end
=start+show_page;
$(
'#page'
).children().css(
'display'
,
'none'
).slice(start,
end
).css(
'display'
,
''
);
current_page=index;
$(
"#current_page"
).html(
" "
+current_page+
" "
);
}
}
}).directive(
'contenteditable'
,
function
() {
return
{
restrict:
'A'
,
require
:
'?ngModel'
,
link:
function
(scope, element, attrs, ngModel) {
if
(!ngModel) {
return
;
}
ngModel.
$render
=
function
() {
element.html(ngModel.
$viewValue
||
''
);
};
element.on(
'blur keyup change'
,
function
() {
scope.
$apply
(readViewText);
});
function
readViewText() {
var
html = element.html();
if
(attrs.stripBr && html ===
'<br>'
) {
html =
''
;
}
ngModel.
$setViewValue
(html);
}
}
};
})
</script>