<%@ page contentType="text/html;charset=UTF-8" %>
<script>
	/**
	 * 项目经理判定施工交底类型页面
	 * */
$(document).ready(function() {
	jp.ajaxForm("#inputForm",function(data){
		if(data.success){
			jp.success(data.msg);
			jp.go("${ctx}/managementcenter/activiti");
		}else{
			jp.error(data.msg);
			$("#inputForm").find("button:submit").button("reset");
		}
	});


	$("#agree").click(function () {
		// var ii=document.getElementById("tuser").value;
		var tuser = $("#tuserName").val();
		console.log(tuser);
		/*				if (tuser=="") {
							jp.error("请选择用户");
							return;
						}*/
		var id = $("#id").val();
		var powerLine= $("#powerLine").val();
		var blackoutArea=$("#blackoutArea").val();
		var projectType=$("#projectType").val();
		var powerFailure=$("#powerFailure").val();
		var preliminaryJudgment=$("#preliminaryJudgment").val();
		var civilEngineering=$("#civilEngineering").val();
		var baseType=$("#baseType").val();
		var planApproval=$("#planApproval").val();
		var transformationType=$("#transformationType").val();
		var transformationEquipment=$("#transformationEquipment").val();
		var newNamed=$("#newNamed").val();
		var putInto=$("#putInto").val();
		var electricalConstruction=$("#electricalConstruction").val();
		var theAssignment=$("#theAssignment").val();
		var automation=$("#automation").val();
		var remote=$("#remote").val();
		var communicationMode=$("#communicationMode").val();
		var inSitu=$("#inSitu").val();
		var networkCabinet=$("#networkCabinet").val();
		var station=$("#station").val();

		jp.prompt("施工交底, 审批意见", function (message) {
			jp.post("${ctx}/act/task/newAudit",
				{
					"taskId":"${construction.act.taskId}",
					"taskName":"${construction.act.taskName}",
					"taskDefKey":"${construction.act.taskDefKey}",
					"procInsId":"${construction.act.procInsId}",
					"procDefId":"${construction.act.procDefId}",
					"flag":"manager",
					"comment":window.encodeURI(message),
					"tuser": tuser,
					"id":id,
					"powerLine":powerLine,
					"blackoutArea":blackoutArea,
					"projectType":projectType,
					"powerFailure":powerFailure,
					"preliminaryJudgment":preliminaryJudgment,
					"civilEngineering":civilEngineering,
					"baseType":baseType,
					"planApproval":planApproval,
					"transformationType":transformationType,
					"transformationEquipment":transformationEquipment,
					"newNamed":newNamed,
					"putInto":putInto,
					"electricalConstruction":electricalConstruction,
					"theAssignment":theAssignment,
					"automation":automation,
					"remote":remote,
					"communicationMode":communicationMode,
					"inSitu":inSitu,
					"networkCabinet":networkCabinet,
					"station":station
				},
				function (data) {
					if(data.success){
						jp.success(data.msg);
						jp.go("${ctx}/act/task/todo")
					}
				})
		});
	})

	$("#agree2").click(function () {
		// var ii=document.getElementById("tuser").value;
		var id = $("#id").val();
		var powerLine=$("#powerLine").val();
		var blackoutArea=$("#blackoutArea").val();
		var projectType=$("#projectType").val();
		var powerFailure=$("#powerFailure").val();
		var preliminaryJudgment=$("#preliminaryJudgment").val();
		var civilEngineering=$("#civilEngineering").val();
		var baseType=$("#baseType").val();
		var planApproval=$("#planApproval").val();
		var transformationType=$("#transformationType").val();
		var transformationEquipment=$("#transformationEquipment").val();
		var newNamed=$("#newNamed").val();
		var putInto=$("#putInto").val();
		var electricalConstruction=$("#electricalConstruction").val();
		var theAssignment=$("#theAssignment").val();
		var automation=$("#automation").val();
		var remote=$("#remote").val();
		var communicationMode=$("#communicationMode").val();
		var inSitu=$("#inSitu").val();
		var networkCabinet=$("#networkCabinet").val();
		var station=$("#station").val();

		jp.prompt("经理交底, 审批意见", function (message) {
			jp.post("${ctx}/act/task/newAudit",
				{
					"taskId":"${construction.act.taskId}",
					"taskName":"${construction.act.taskName}",
					"taskDefKey":"${construction.act.taskDefKey}",
					"procInsId":"${construction.act.procInsId}",
					"procDefId":"${construction.act.procDefId}",
					"flag":"company",
					"comment":window.encodeURI(message),
					"id":id,
					"powerLine":powerLine,
					"blackoutArea":blackoutArea,
					"projectType":projectType,
					"powerFailure":powerFailure,
					"preliminaryJudgment":preliminaryJudgment,
					"civilEngineering":civilEngineering,
					"baseType":baseType,
					"planApproval":planApproval,
					"transformationType":transformationType,
					"transformationEquipment":transformationEquipment,
					"newNamed":newNamed,
					"putInto":putInto,
					"electricalConstruction":electricalConstruction,
					"theAssignment":theAssignment,
					"automation":automation,
					"remote":remote,
					"communicationMode":communicationMode,
					"inSitu":inSitu,
					"networkCabinet":networkCabinet,
					"station":station
				},
				function (data) {
					if(data.success){
						jp.success(data.msg);
						jp.go("${ctx}/act/task/todo")
					}
				})
		});
	})

	/**
	 * 请求驳回
	 * */
	$("#reject").click(function () {
		jp.prompt("驳回, 审批意见", function (message) {
			jp.post("${ctx}/act/task/newAudit",
				{
					"taskId":"${construction.act.taskId}",
					"taskName":"${construction.act.taskName}",
					"taskDefKey":"${construction.act.taskDefKey}",
					"procInsId":"${construction.act.procInsId}",
					"procDefId":"${construction.act.procDefId}",
					"flag":"reject",
					"projectName":"${fns:unescapeHtml(construction.projectName)}",
					"comment":window.encodeURI(message)
				},
				function (data) {
					if(data.success){
						jp.success(data.msg);
						jp.go("${ctx}/act/task/todo")
					}
				})
		})
	})


	$('#startTime').datetimepicker({
		format: "YYYY-MM-DD HH:mm:ss"
	});
	$('#endTime').datetimepicker({
		format: "YYYY-MM-DD HH:mm:ss"
	});
	//富文本初始化
	$('#reason').summernote({
		height: 300,
		lang: 'zh-CN',
		readonly: true,
		callbacks: {
			onChange: function(contents, $editable) {
				$("input[name='reason']").val($('#reason').summernote('code'));//取富文本的值
			}
		}
	});

	/**
	 * 导入图纸审核信息
	 * */
	$("#drawingReview").click(function () {
		var id = $("#id").val();
		jp.open({
			type: 2,
			area: [500, 200],
			auto: true,
			title: "导入图纸审核信息",
			content: "${ctx}/tag/importExcel",
			btn: ['确定', '关闭'],
			btn1: function (index, layero) {
				var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
				iframeWin.contentWindow.importExcel('${ctx}/managementcenter/activiti/drawingReview?id='+id, function (data) {
					if (data.success) {
						jp.success(data.msg);
						window.location.reload();
					} else {
						jp.alert(data.msg);
					}
					jp.close(index);
				});//调用保存事件
				return false;
			},
			btn2: function (index) {
				jp.close(index);
			}
		})
	});
})
</script>
