<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
<link rel="shortcut icon" href="img/ic.png">
    <title>成绩修改</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/sb-admin.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="css/plugins/morris.css" rel="stylesheet">
	<link href="nuget/content/content/toastr.css" rel="stylesheet" type="text/css"/>
    <!-- Custom Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <!-- tab table-->
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="js/cdn/html5shiv-3.7.0.js"></script>
    <script src="js/cdn/respond-1.4.2.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="css/cdn/dataTables.bootstrap.css">
    <link rel="stylesheet" href="css/cdn/font_i0327076nave7b9.css">
    <link rel="stylesheet" type="text/css" href="css/datatable.css"/>
    <style>
        #example_paginate {
            float: right;
        }

        .handle-btn {
            cursor: pointer;
            margin: 0 2px;
        }

        #wrapper {
            padding-left: 0px;
        }

        .navigation {
            border-bottom: 3px solid #edebeb;
        }

        .navigation a:hover {
            color: #0F6AFC;
            border-bottom: 2px solid #01AAED;
        }

        .this {
            color: #01aaed;
            font-weight: bold;
            border-bottom: 2px solid #01AAED;
        }
        [v-cloak] {
			display: none;
		}
		.naav span{
			margin: 0 10px;
			font-weight: bold;
		}
    </style>
</head>

<body>

<div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="height: 67px; background-image:url(img/top.jpg);">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header" style=" width:225px;">
            </div>
            <!-- Top Menu Items -->
            <ul class="nav navbar-right top-nav">
                 <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <span id="userName"></span> <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="refereePwd.html"><i class="fa fa-fw fa-gear"></i> 修改密码</a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a href="login.html"><i class="fa fa-fw fa-power-off"></i> 退出</a>
                        </li>
                    </ul>
                </li>
            </ul>
            <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            
            <!-- /.navbar-collapse -->
        </nav>

    <div id="page-wrapper">

        <div class="container-fluid">
            <div class="row sss">
                <nav class="navbar navbar-default" role="navigation">
                    <div>
                        <ul class="nav navbar-nav">
                            <li><a href="index.html">首页</a></li>
                            <li><a href="achievement.html">成绩管理</a></li>
                            <li class="active"><a href="javascript:;"><span class="xuanzhong">成绩编辑</span></a></li>
                        </ul>
                    </div>
                </nav>
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="panel">
                    <div class="panel-heading">
                        <ul class="nav">
                        	<li class="naav"><span v-cloak>{{EditObj.scenesName}}</span><span>车队名称</span><span v-cloak>{{EditObj.teamName}}</span><span>赛场</span><span v-cloak>{{EditObj.stadiumName}}</span>
                        	</li>
                            <li class="naav" v-cloak><span>场景成绩</span><span style="color: red;" v-cloak>{{EditObj.scenesResult}}分</span><span>比赛时间</span><span v-cloak>{{EditObj.time}}</span>
                            </li>
                        </ul>
                    </div>
                    <div class="panel-body">
                        <div class="flot-chart">
                            <ul class="nav" id="biuuu_city_list" style="width: 100%;">
                                <li>
                                    <div class="panel panel-greens">
                                        <div class="panel-heading">
                                        </div>
                                        <div class="panel-body">
                                            <ul class="nav">
                                                <li v-cloak v-for="illega in illegalList" style="text-align: center;" >
                                                    <div class="row" style="padding-bottom: 20px; line-height: 34px;">
                                                        <div class="col-xs-3 col-sm-3 xz" v-cloak>
                                                        	{{illega.illegalName}}<span class="price" v-cloak>{{illega.illegalScore}}</span>分
                                                        </div>
                                                        <div class="col-xs-3 col-sm-3">
                                                        	<span class="glyphicon glyphicon-minus-sign jian" v-on:click="minus($event,illega.illegalId)"></span> 
															<i :id="`name${illega.illegalId}`" style="margin: 0 5px;" v-cloak>{{illega.illegalCount}}</i>  
															<span class="glyphicon glyphicon-plus-sign jia" v-on:click="add($event,illega.illegalId)"></span> 
															<i class="price" style="display: none;">{{illega.illegalScore}}</i>
														</div>
                                                        <div class="col-xs-3 col-sm-3" >
                                                        	-<span :id="`totalpriceshow${illega.illegalId}`" v-cloak>{{illega.illegalCount*illega.illegalScore}}</span>分
                                                        </div>
                                                        <div class="col-xs-3 col-sm-3" >
                                                        	<button type="button" class="btn btn-primary" v-on:click="Submit(illega.illegalId,illega.illegalResultId)">保存</button>
                                                        </div>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </li>
                                <!-- 2-->
                                <li v-if="manualInterventionList.length !== 0">
                                    <div class="panel panel-greens" >
                                        <div class="panel-heading">
                                        </div>
                                        <div class="panel-body">
                                            <ul class="nav">
                                                <li style="text-align: center;">
                                                    <div v-cloak v-for="manual in manualInterventionList" class="row" style="padding-bottom: 20px; line-height: 34px;">
                                                        <div class="col-xs-3 col-sm-3">{{manual.interveneType === 0?'人工干预':'人工代驾'}}</div>
                                                        <div class="col-xs-3 col-sm-3">{{manual.startTime}}~{{manual.endTime}}</div>
                                                        <div class="col-xs-3 col-sm-3">-{{manual.deductScore}}分</div>
                                                        <div class="col-xs-3 col-sm-3">
                                                        	<input type="hidden" id="manualInterventionId" :value="manual.manualInterveneId" />
                                                        	<span class="iconfont icon-shanchu" data-toggle="modal" data-target="#Delete" style="color:#ffbe00" v-on:click="team()" ></span>
                                                        </div>
                                                         <!-- /.删除 -->
												        <div class="modal fade" id="Delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
														    <div class="modal-dialog">
														        <div class="modal-content" style="border-top: 5px solid #12dbcd;">
														            <div class="modal-body text-center">确定要删除此项？</div>
														            <div class="text-center" style="padding-bottom: 15px;">
														            	<input type="hidden" id="interId" value=""/>
														                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
														                <button style="margin-left: 10px;" type="button" v-on:click="Delete()" class="btn btn-primary">确定</button>
														            </div>
														        </div><!-- /.modal-content -->
														    </div><!-- /.modal -->
														</div>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.row -->
        </div>
        <!-- /.container-fluid -->
    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<!-- jQuery -->
<script src="js/jquery.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- tab table-->
<script src="js/cdn/jquery.dataTables.min.js"></script>
<script src="js/cdn/dataTables.bootstrap.js"></script>
<script type="text/javascript" src="js/vue/vue.js"></script>
<script type="text/javascript" src="js/vue/vue-router.js"></script>
<script src="nuget/content/scripts/toastr.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
    var userName = localStorage.getItem("userName");    $("#userName").text(userName);
var vue = new Vue({
        el: '#page-wrapper',
        data: {
        	illega:{
        		illegalId:"",
        	},
        	EditObj:{
        		scenesScore:'',
        		scenesName:'',
        		FinalTime:'',
        	},
        	illegalList:{},
            manualInterventionList:{},//人工干预
        },
        mounted: function () {
            this.init();
        },
        methods: {
            init: function () {
                var th = this;
                $.ajax({
                    type: "get",
                    url: url + '/users/' + adminId + "/scenesResults/" + scenesResultId + "?time="+(new Date().getTime()),
                    async: false,
                    dataType: 'json',
                    contentType: "application/json; charset=utf-8",
                    beforeSend: function (request) {
                        request.setRequestHeader("accessToken", accessToken);
                    },
                    success: function (data) {
                    	if(data.code == 1){
                    		var result = data.result;
	                        th.EditObj = result;
	                        th.EditObj.time = replaceTime( result.createTime / 1000 );
	                        th.illegalList = result.illegalResultList;
	                      	th.manualInterventionList = result.manualInterventionList;
	                      	for(var i=0; i<th.manualInterventionList.length; i++){
	                      		var endTime = result.manualInterventionList[i].endTime;
	                      		th.manualInterventionList[i].endTime = replaceHourTime(endTime / 1000);
	                      		var startTime = result.manualInterventionList[i].startTime;
	                      		th.manualInterventionList[i].startTime = replaceHourTime(startTime / 1000);
	                      		
	                      	}
                    	}else{
                    		window.location.href="404.html";
                    	}
                        
                    }
                });
            },
            //赋值
		  	team : function(deviceId){
		  		var th=this;
			  	$.ajax({
		  			type: "get",
		  			url:url + '/users/' + adminId + "/scenesResults/" + scenesResultId,
		  			async: false,
		  			dataType: 'json',
					contentType: "application/json; charset=utf-8",
		  			beforeSend: function(request) {
						request.setRequestHeader("accessToken", accessToken);
					},
					success: function(data) {
						if(data.code == 1){
							th.manualInterventionteam = {}; 
							th.manualInterventionteam = data.result.manualInterventionList;
							for(var i=0; i<th.manualInterventionteam.length;i++){
								var interId = th.manualInterventionteam[i].manualInterveneId;
								$("#interId").val(interId);
							}
						}else{
							window.location.href="404.html";
						}
						
					}
		  		});
			},
			//保存
		  	Submit:function(id,illegalResultId){
		  		var name = $('#name'+id).html();
		  		var jsonStr='{"illegalResultId":'+illegalResultId+',"illegalCount":'+name+'}';
		  		
		  		var th = this;
		  		$.ajax({
		  			type: "PUT",
		  			url:url+'/users/'+adminId+'/illegalResults/'+illegalResultId,
		  			data:jsonStr,
		  			async: false,
		  			dataType: 'json',
					contentType: "application/json; charset=utf-8",
		  			beforeSend: function(request) {
						request.setRequestHeader("accessToken", accessToken);
					},
					success: function(data) {
						if(data.code!=1){
							toastr['error'](data.description); 
						}else{
							toastr['success'](data.description);
							setTimeout(function(){location.reload();},2000);
						}
					}
		  		});
		  	},
            //删除
		  	Delete :function(){
		  		var manualInterventionId = $("#interId").val();
	  			var th = this;
	  			$.ajax({
		  			type: "DELETE",
		  			url:url+'/users/'+adminId+'/manualInterventions/'+manualInterventionId,
		  			async: false,
		  			dataType: 'json',
					contentType: "application/json; charset=utf-8",
		  			beforeSend: function(request) {
						request.setRequestHeader("accessToken", accessToken);
					},
					success: function(data) {
						if(data.code!=1){
							toastr['error'](data.description); 
						}else{
							toastr['success'](data.description);
							setTimeout(function(){location.reload();},2000);
						}
					}
		  		});
		  	},
		  	add:function(event,id){
		  		var th = $(event.currentTarget);
		  		th.prevAll().css("display", "inline-block");  
				var n = th.prev().text();  
				var num = parseInt(n) + 1;  
				th.prev().text(num);  
				var danjia = th.next().text();
				var a = $('#totalpriceshow'+id).html();
				$('#totalpriceshow'+id).html((a * 1 + danjia * 1));
		  	},
		  	minus:function(event,id){
		  		var th = $(event.currentTarget);
		  		var n = th.next().text();  
				var num = parseInt(n) - 1; 
				if (num < 0) {   
					return 
				}
				th.next().text(num);//减1  
				var danjia = th.nextAll(".price").text();
				var a = $('#totalpriceshow'+id).html();
				$('#totalpriceshow'+id).html((a * 1 - danjia * 1));
				
		  	},
        },
    });


</script>
</body>

</html>
