<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>部门工作总结评分</title>
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../css/OA-style.css" rel="stylesheet" />
		
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="login">
			<a class="mui-action-back back mui-pull-left" href="../../office/office.html"><img src="../../../images/back.png"></a>
			<h1 class="mui-title">部门工作总结评分</h1>
			<!--<a class="mui-icon mui-pull-right" id="save"  onclick="saveScore()">
				<img src="../../../images/save.png" style="width: 24px;"   />
			</a>-->
			<button id="save"  type="button" data-loading-text="保存中" class="mui-pull-right"  class="mui-btn" onclick="saveScore()" >保存</button>
		</header>
		
		<div class="mui-content" id = "ScoreDiv">
			<form action="#" method="post" id="saveForm">
			<span id="title" style="text-align: center; display: block; font-size: 17px; margin: 10px;"></span>
			<span id="deptname" style="text-align: center; display: block; font-size: 17px; margin: 10px;"></span>
			<div class="mui-card" >
				<div class="mui-card-header tongzhi_title" id="firstInput" style="display: none;">
					<b>部门负责人评分</b>
					<b><input type="text" name="job_leader_score" id="job_leader_score" value="" placeholder="分管领导评分(百分制)"/>
				</div>
				<div class="mui-card-header tongzhi_title" id="secondInput" style="display: none;">
					<b>总经理评分</b>
					<b><input type="text" name="job_manager_score" id="job_manager_score" value="" placeholder="总经理评分(百分制)"/></b>
				</div>
			</div>
			<template v-for="itemA in itemAs">
				<div class="mui-card">
					<div class="mui-card-header tongzhi_title"><b>项目:{{itemA.job_project}}-----工作类别:{{itemA.job_type_of_work}}-----工作量占比:{{   Number(itemA.job_workload_share*100).toFixed(0) }}%</b></div>
					<div class="mui-card-content">
						<div class="mui-card-content-inner">
							<div >
								<div class="tongzhi_div"><img class="tongzhi_img" src="../../../images/zhiban.png"></div>
								<div class="tongzhi_div2">工作内容:{{itemA.job_content}}</div><p></p>
								<div class="tongzhi_div"><img class="tongzhi_img" src="../../../images/zhiban.png"></div>
								<div class="tongzhi_div2">评分标准:{{itemA.job_score_standard}}</div><p></p>
								<div class="tongzhi_div"><img class="tongzhi_img" src="../../../images/zhiban.png"></div>
								<div class="tongzhi_div2">评分依据:{{itemA.job_score_basis}}</div><p></p>
								
								<template v-for="it in itemBs">
<!--									当前评分人员：{{ it.score_user_deptname  }}/{{ it.score_username }}
-->									<template v-if="it.set_type  == 'job_mutual1'">
										<!--{{itemA.universialid + '-job_mutual1'}}-->
										<input type="text"  v-bind:value="itemA.job_mutual1" v-bind:id="itemA.universialid + '-job_mutual1'" v-bind:name="itemA.universialid + '-job_mutual1'" v-bind:placeholder=" it.score_user_deptname  +  it.score_username "/>
									</template>
									<template v-if="it.set_type  == 'job_mutual2'">
										<input type="text"  v-bind:value="itemA.job_mutual2" v-bind:id="itemA.universialid + '-job_mutual2'" v-bind:name="itemA.universialid + '-job_mutual2'" v-bind:placeholder=" it.score_user_deptname  +  it.score_username "/>
									</template>
									<template v-if="it.set_type  == 'job_mutual3'">
										<input type="text"  v-bind:value="itemA.job_mutual3" v-bind:id="itemA.universialid + '-job_mutual3'" v-bind:name="itemA.universialid + '-job_mutual3'" v-bind:placeholder=" it.score_user_deptname  +  it.score_username "/>
									</template>
									<template v-if="it.set_type  == 'job_mutual4'">
										<input type="text"  v-bind:value="itemA.job_mutual4" v-bind:id="itemA.universialid + '-job_mutual4'" v-bind:name="itemA.universialid + '-job_mutual4'" v-bind:placeholder=" it.score_user_deptname  +  it.score_username "/>
									</template>
									<template v-if="it.set_type  == 'job_mutual5'">
										<input type="text"  v-bind:value="itemA.job_mutual5" v-bind:id="itemA.universialid + '-job_mutual5'" v-bind:name="itemA.universialid + '-job_mutual5'" v-bind:placeholder=" it.score_user_deptname  +  it.score_username "/>
									</template>
									<template v-if="it.set_type  == 'job_mutual6'">
										<input type="text"  v-bind:value="itemA.job_mutual6" v-bind:id="itemA.universialid + '-job_mutual6'" v-bind:name="itemA.universialid + '-job_mutual6'" v-bind:placeholder=" it.score_user_deptname  +  it.score_username "/>
									</template>
								</template>
								<span class="tongzhi_div"><img class="tongzhi_img" src="../../../images/zhibanshijian.png"></span>
								<span class="tongzhi_div1">2018-05-22 16:45</span>
							</div>
						</div>
					</div>
				</div>
			</template>
			</form>
		</div>
		
		<script src="../../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../../js/jquery-1.11.2.min.js"></script>
		<script src="../../../js/config.js"></script>
		<script src="../../../js/app.js"></script>
		<script src="../../../js/vue.min.js"></script>
		<script>
			mui.init();
			var vmA = new Vue({
				el: '#ScoreDiv',
				data: {
					itemAs: [], //列表信息流数据
					itemBs: [] //列表信息流数据
				}
			});	
			
			function saveScore(){
 				mui("#save").button('loading');
				var postData = $("#saveForm").serialize();
				var data = postData.replace(/=/g,":'").replace(/&/g,"',")+"'";
				var url = API.API_URL();
				var state = app.getState(); //获取登陆信息
				var staffId = state.user.useId;
				var obj = {
					'serviceId': 'oa_2018A1207GetDeptJobScore',
					'params': '{Excelid:"' + Excelid + '",' + data + '}'
				};
				mui.ajax(url, {
					dataType: 'json', 				//服务器返回json格式数据
					type: 'post', 					//HTTP请求类型
					data: obj,
					timeout: 10000, 				//超时时间设置为10秒；
					headers: {
						'Accept': 'application/json'
					}, //超时时间设置为10秒；
					success: function(data) {
						if(data.returnCode == "0") {	
							var resultNum = data.returnParams.resultNum;
							if( resultNum > 0 ){
								mui("#save").button('reset');
								mui.toast('保存成功!');
								plus.webview.close("deptJob_folder.html");
								setTimeout(function(){
									var page = "deptJob_folder.html";
									mui.openWindow({
										url: page,
										extras: {"Excelid":Excelid,
												 "job_type":job_type,
												 "title":title,
												 "deptname":deptname }
									});
								},1000);
							}
						}					
					},
					error: function(xhr, type, errorThrown) {}
				});
			}
			var Excelid ;
			var job_type;
			var title;
			var deptname;
			
			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
			 	job_type = 	self.job_type;		//类型  工作计划 | 工作总结
				title  = 	self.title;			//excel标题
				deptname  = self.deptname;		//excel部门
				Excelid = 	self.Excelid;		//excel主键
				document.getElementById("title").innerHTML = title;
				document.getElementById("deptname").innerHTML = deptname;
				doDetail(Excelid,job_type);
			})(mui);
			function doDetail(Excelid,job_type) {  				
				var url = API.API_URL();
				var state = app.getState(); //获取登陆信息
				var staffId = state.user.useId;
				var obj = {
					'serviceId': 'oa_2018A1126GetDeptJobScoreDetail',
					'params': '{Excelid:"' + Excelid + '",useId:"' + staffId + '",jobtype:"' + job_type + '"}'
				};
				mui.ajax(url, {
					dataType: 'json', 				//服务器返回json格式数据
					type: 'post', 					//HTTP请求类型
					data: obj,
					timeout: 10000, 				//超时时间设置为10秒；
					headers: {
						'Accept': 'application/json'
					}, //超时时间设置为10秒；
					success: function(data) {
						if(data.returnCode == "0") {	
							var result = data.returnParams.Rows;
							var Rules =  data.returnParams.Rules;
							if(result.length > 0) {
								vmA.itemAs = vmA.itemAs.concat(result);
								vmA.itemBs = vmA.itemBs.concat(Rules);
								var leader_score = result[0].job_leader_score;
								var manager_score = result[0].job_manager_score;
								$("#job_leader_score").val(leader_score);
								$("#job_manager_score").val(manager_score);
								for(var p in Rules){
									if(  Rules[p].set_type == "job_leader_score"  ){
										$("#firstInput").show();
									}
									if(  Rules[p].set_type == "job_manager_score"  ){
										$("#secondInput").show();
									}
								}
							}
						}					
					},
					error: function(xhr, type, errorThrown) {}
				});
			}
		</script>
	</body>

</html>