<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-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">

		<link href="../../../css/OA-style.css" rel="stylesheet" />
		<!--标准mui.css-->
		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/mui.picker.min.css">
		<link rel="stylesheet" type="text/css" href="../../../css/app.css" />
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../../../css/flow.css" />

	</head>

	<body class="mui-fullscreen">

		<!--页面主结构开始-->
		<div id="app" class="mui-views">
			<div class="mui-view">
				<div class="mui-navbar">
				</div>
				<div class="mui-pages">
				</div>
			</div>
		</div>
		<!--页面主结构结束-->

		<!--单页面开始-->
		<div id="setting" class="mui-page">

			<!--页面标题栏开始-->
			<div class="mui-navbar-inner mui-bar mui-bar-nav">
				<a class="mui-action-back back mui-pull-left"><img src="../../../images/back.png"></a>
				<h1 class="mui-center mui-title">未签到(退)说明流程</h1>
			</div>

			<!--页面标题栏结束-->
			<!--页面主内容区开始-->
			<div class="mui-page-content">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll">
						<div class="mui-content-padded" style="margin: 5px;">
							<form class="mui-input-group" id="form_element">
								<div class="mui-content">
									<ul class="mui-table-view ">
										<li class="mui-table-view-cell mui-input-row">
											<label>姓名</label>
											<template v-for="formElement in formElements" v-if="formElement.tableField == 'form_element_23344106258004'">
												<input type="text" id="form_element_23344106258004" name="form_element_23344106258004" v-bind:value="formElement.defaultValue" class="mui-input-clear" readonly="readonly" placeholder="">
											</template>
										</li>
										<li class="mui-table-view-cell mui-input-row">
											<label>部门及职务</label>
											<template v-for="formElement in formElements" v-if="formElement.tableField == 'form_element_23344106871975'">
												<input type="text" id="form_element_23344106871975" name="form_element_23344106871975" readonly="readonly" v-bind:value="formElement.defaultValue" class="mui-input-clear" readonly="readonly" placeholder="">
											</template>
										</li>
										<li class="mui-table-view-cell mui-input-row">
											<label>未按时签到(退)时间</label>
											<template v-for="formElement in formElements" v-if="formElement.tableField == 'form_element_23344111349374'">
												<input id="endDate" name="form_element_23344111349374" type="text" readonly="readonly" v-bind:value="formElement.defaultValue" data-options='{"type":"date"}' class="dateinput" placeholder="">
											</template>
										</li>
										<li class="mui-table-view-cell mui-input-row" style="height: 100px;margin: 5px 5px;">
											<label>事由</label>
											<template v-for="formElement in formElements" v-if="formElement.tableField == 'form_element_23344108344418'">
												<textarea id="form_element_23344108344418" name="form_element_23344108344418" rows="4" readonly="readonly" placeholder="请输入请假事由">{{formElement.defaultValue}}</textarea>
											</template>
										</li>
										<li class="mui-table-view-cell mui-input-row" style="height: 100px;margin: 5px 5px;">
											<label>备注</label>
											<template v-for="formElement in formElements" v-if="formElement.tableField == 'form_element_23344110339975'">
												<textarea id="form_element_23344110339975" name="form_element_23344110339975" rows="4" v-if="formElement.canEdit == '1'" placeholder=""></textarea>
												<textarea id="form_element_23344110339975" name="form_element_23344110339975" rows="4" v-else if readonly="readonly" placeholder="">{{formElement.defaultValue}}</textarea>
											</template>
										</li>
									</ul>
									<ul class="mui-table-view ">
										<li class="mui-table-view-cell mui-input-row" style="height: 100px;margin: 5px 5px;">
											<label>主管领导意见</label>
											<template v-for="formElement in formElements" v-if="formElement.tableField == 'form_element_23344109341744'">
												<textarea id="form_element_23344109341744" name="form_element_23344109341744" rows="4" v-if="formElement.canEdit == '1'" placeholder=""></textarea>
												<textarea id="form_element_23344109341744" name="form_element_23344109341744" rows="4" v-else if readonly="readonly" placeholder="">{{formElement.defaultValue}}</textarea>
											</template>
										</li>

									</ul>
								</div>
							</form>

							<ul class="mui-table-view" id="item3mobile">
								<li class="mui-table-view-cell" v-for="item3mobileC in item3mobileCs">
									<p><span>环节名称:{{item3mobileC.tmodelName}}({{item3mobileC.name}})</span><span style="margin-left: 10px;">{{item3mobileC.dataName}}</span></p>
									<p><span>创建时间:{{item3mobileC.createdate}}</span></p>
									<template v-if="item3mobileC.finishdate != ''">
										<p><span>办理时间:{{item3mobileC.finishdate}}</span></p>
									</template>
								</li>
							</ul>

						</div>
					</div>
				</div>
			</div>
			<!--页面主内容区结束-->

		</div>
		<!--单页面结束-->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/mui.view.js"></script>
		<script src="../../../js/mui.picker.min.js"></script>
		<script src="../../../js/vue.min.js"></script>
		<script src="../../../js/config.js"></script>
		<script src="../../../js/app.js"></script>
		<script src="../../../js/jquery-1.11.2.min.js"></script>
		<script type="text/javascript">
			var url = API.API_URL();
			mui.init();

			var viewApi = mui('#app').view({
				defaultPage: '#setting'
			});

			//初始化单页的区域滚动
			mui('.mui-scroll-wrapper').scroll();

			var view = viewApi.view;

			(function($, doc) {

				//处理view的后退与webview后退
				var oldBack = $.back;
				$.back = function() {
					if(viewApi.canBack()) { //如果view可以后退，则执行view的后退
						viewApi.back();
					} else { //执行webview后退
						oldBack();
					}
				};
				//监听页面切换事件方案1,通过view元素监听所有页面切换事件，目前提供pageBeforeShow|pageShow|pageBeforeBack|pageBack四种事件(before事件为动画开始前触发)
				//第一个参数为事件名称，第二个参数为事件回调，其中e.detail.page为当前页面的html对象
				view.addEventListener('pageBeforeShow',
					function(e) {
						console.log(e.detail.page.id + ' beforeShow');
					});
				view.addEventListener('pageShow', function(e) {
					console.log(e.detail.page.id + ' show');
				});
				view.addEventListener('pageBeforeBack', function(e) {
					console.log(e.detail.page.id + ' beforeBack');
				});
				view.addEventListener('pageBack', function(e) {
					console.log(e.detail.page.id + ' back');
				});
			})(mui);
			var tinsId = "";
			var insId = "";
			mui.plusReady(function() {

				var self = plus.webview.currentWebview();
				tinsId = self.tinsId;
				insId = self.insId;
				console.log("plusReady");
				console.log("tinsId=====" + tinsId + "insId====" + insId)
				getProcessflow();
				getFormInfo();
			});

			function choosePerson(tmodelId) {
				getGroupUser(347517153919893);
				$("#selTmodelId").val(tmodelId);
				viewApi.go('#personComponent');
			};

			function selectUser(user) {
				var tmodelId = $("#selTmodelId").val()
				$("#" + tmodelId).val(user.text);
				$("#" + tmodelId).attr("userId", user.id);
				viewApi.back();
			}

			var vm = new Vue({
				el: '#item3mobile',
				data: {
					item3mobileCs: []
				}
			});

			var vm3 = new Vue({
				el: '#form_element',
				data: {
					formInfo: {},
					formElements: []
				}
			});
			//流程流转信息
			function getProcessflow() {
				var state = app.getState(); //获取登陆信息
				var staffId = state.user.useId;
				mui.ajax(url, {
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					data: {
						'serviceId': 'bpm_2013V0100PHONE007',
						'params': '{staffId:"' + staffId + '",insid:"' + insId + '"}'
					},
					timeout: 10000, //超时时间设置为10秒；
					headers: {
						'Accept': 'application/json'
					},
					success: function(data) {
						//服务器返回响应
						console.log("流转过程信息:" + JSON.stringify(data));
						if(data && data.returnCode == "0") {
							var returnParams = data.returnParams.list;
							if(returnParams.length > 0) {
								vm.item3mobileCs = vm.item3mobileCs.concat(returnParams);
							}
						} else {
							mui.toast("获取流程信息错误");
						}
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						console.log(xhr + "========" + type + "===========" + errorThrown);
					}
				});
			};

			//获取表单信息
			function getFormInfo() {
				//开启等待框
				var w = plus.nativeUI.showWaiting("处理中，请等待...", {
					loading: {
						display: "inline"
					}
				});
				var state = app.getState(); //获取登陆信息
				var staffId = state.user.useId;
				mui.ajax(url, {
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					data: {
						'serviceId': 'bpm_2013V0100PHONE006',
						'params': '{staffId:"' + staffId + '",tinsid:"' + tinsId + '",insId:"' + insId + '"}'
					},
					timeout: 10000, //超时时间设置为10秒；
					headers: {
						'Accept': 'application/json'
					},
					success: function(data) {
						//服务器返回响应
						console.log("表单信息:" + JSON.stringify(data));
						if(data && data.returnCode == "0") {
							//关闭等待框
							var t = setInterval(function() {
								w.setTitle("处理中，请等待...");
								w.close();
								clearInterval(t);
							}, 1000);
							var returnParams = data.returnParams;
							var returnParams = data.returnParams;
							vm3.formInfo = returnParams.formInfo[0];
							console.log("vm3.formInfo********" + vm3.formInfo);
							vm3.formElements = returnParams.formElements;
							console.log("vm3.formElements********" + vm3.formElements);

						} else {
							mui.toast("获取流程信息错误");
						}
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						console.log(xhr + "========" + type + "===========" + errorThrown);
					}
				});
			};
		</script>

	</body>

</html>