<!--{include file="<!--{$oapath}-->public/ins_page.tpl"}-->
  <link rel='stylesheet' type='text/css' href="<!--{$oapath}-->Ins/js/layui/css/layui.css">
 <block name="content">

	<div class="operate panel panel-default">
		<div class="panel-body">
			<div class="pull-left">
				<a onclick="go_return_url();" class="btn btn-sm btn-primary">返回</a>
			</div>
			<div class="pull-right">
				<!--{if $no_assign=='1'}--> 
					<a onclick="let_me_do(<!--{$task_id}-->)" class="btn btn-sm btn-primary">我来处理</a>
				<!--{/if}-->
			</div>
		</div>
	</div>
	<form method='post' id="form_data" name="form_data" enctype="multipart/form-data"   class="well form-horizontal">
		<input type="hidden" id="ajax" name="ajax" value="0">
		<input type="hidden" id="executor" name="executor" value="<!--{$vo.executor}-->">
		<input type="hidden" id="opmode" name="opmode" value="add">

		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">标题：</label>
			<div class="col-sm-10">
				<p class="form-control-static">
					<!--{$vo.name}-->
				</p>
			</div>
		</div>
		<div class="form-group col-sm-6">
			<label class="col-sm-4 control-label" for="name">发起人：</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					<!--{$vo.user_name}-->
				</p>
			</div>
		</div>
		<div class="form-group col-sm-6">
			<label class="col-sm-4 control-label" for="name">发起时间：</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					<!--{$vo.create_time|date_format:'%Y-%m-%d %H:%M:%S'}-->
				</p>
			</div>
		</div>
		<div class="form-group col-sm-6">
			<label class="col-sm-4 control-label" for="name">谁来执行：</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					<!--{$vo.executor1}-->
				</p>
			</div>
		</div>
		<div class="form-group col-sm-6">
			<label class="col-sm-4 control-label" for="expected_time">期望完成时间：</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					<!--{$vo.expected_time}-->
				</p>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label" for="content">任务说明：</label>
			<div class="col-xs-10">
				<div class="task_content form-control-static">
					<!--{$vo.content}-->
				</div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">附件：</label>
			<div class="col-sm-10">
			   <ul class="file_list">
                            <!--{foreach $file as  $v}-->
                                          <li class="tbody">
                                                    <div class="loading"></div>
                                                    <div class="data">
                                                            <span class="del text-center"> <a class="link down" target="_blank" href="<!--{$v.path}-->">下载</a> </span>

                                                            <span class="auto autocut" title="<!--{$v.name}-->	"><!--{$v.name}-->						</span>
                                                    </div>
                                            </li>
                     <!--{/foreach}-->
                    </ul>
			</div>
		</div>
	</form>

	
	<div class="ul_table border-bottom">
		<ul>
			<li class="thead">
				<span class="col-9 text-center">指派给</span>
				<span class="col-6 text-center">状态</span>
				<span class="col-6 text-center">执行人</span>
				<span class="col-13 text-center">计划完成时间</span>
				<span class="col-13 text-center">已完成情况</span>
				<span class="col-13 pull-right">附件</span>
				<span class="auto">执行内容</span>
				
			</li>
			
                             <!--{foreach $task_log as  $item}-->
                                    <li class="tbody">
                                            <span class="col-9 text-center">&nbsp;<!--{$item.executor_name}--></span>
                                            <span class="col-6 text-center">&nbsp;<!--{if $item.status=='0'}--> 
                                                                        待处理
                                                           <!--{elseif $item.status=='10'}-->
                                                                        进行中
                                                           <!--{elseif $item.status=='20'}-->
                                                                        已完成
                                                           <!--{elseif $item.status=='22'}-->
                                                                        已拒绝
                                                            <!--{elseif $item.status=='30'}-->
                                                                        已完成
                                                            <!--{/if}--></span>
                                            <span class="col-6 text-center">&nbsp;<!--{$item.transactor_name}-->&nbsp;</span>
                                            <span class="col-13 text-center">&nbsp;<!--{$item.plan_time}-->&nbsp;</span>
                                            <span class="col-13 text-center"> &nbsp;
                                                 
                                                    <!--{$item.finish_rate}-->
                                                  
                                            </span>
                                                   <span class="col-13 pull-right">
                                                            <!--{foreach $item.add_file as  $v}-->
                                                     
						
						
                                                             <a class="link down" download="" target="_blank" href="<!--{$v.path}-->"><!--{$v.name}--></a> <br/>
					
				
                                                             <!--{/foreach}-->
                                                   </span>

                                            <span class="auto">
                                                    <div style="overflow:hidden">
                                                            <!--{$item.feed_back}-->
                                                    </div> </span>
                                    </li>
			    <!--{/foreach}-->
		</ul>
	</div>

        <!--{if $is_working=='1'}--> 
		<div class="ibox task_todo">
			<div class="ibox-title">
				<h5 class="smaller">我的执行情况</h5>
				<div class="ibox-tools no-border">
					<ul class="nav nav-tabs" id="myTab">
						<li class="active">
							<a href="#working" data-toggle="tab">执行情况</a>
						</li>
						<li>
							<a href="#reject" data-toggle="tab">拒绝接受</a>
						</li>
					</ul>
				</div>
			</div>
			<div class="ibox-content">
				<div class="tab-content">
					<div class="tab-pane active" id="working">
						<form method='post' id="form_data_working" name="form_data_working" >
							<input type="hidden" name="status" value="10">
							<input type="hidden" name="id" value="<!--{$task_working.id}-->">
							<div class="form-group col-sm-6">
								<label class="col-sm-4 control-label" >计划完成时间：</label>
								<div class="col-sm-8">
									<input class="input-date-time form-control" name="plan_time" value="<!--{$task_working.plan_time}-->" check="require" msg="请输入计划完成时间" readonly="readonly">
								</div>
							</div>
							<div class="form-group col-sm-6">
								<label class="col-sm-4 control-label" >完成率：</label>
								<div class="col-sm-8">
									<div class="form-control-static" >
										<input type="hidden" id="finish_rate" name="finish_rate"/>
										<div  class="slider_box" >
											<div id="basic_slider"></div>
											<div class="right" id="basic_slider_val">
												<!--{$task_working.finish_rate}-->%
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label" >执行内容：</label>
								<div class="col-sm-10">
									<p>
									<textarea id="feed_back" name="feed_back" class="col-xs-12 simple " style="height:120px"><!--{$task_working.feed_back}--></textarea>
									</p>
								</div>
							</div>
                                                                      <br/>     <br/>
							<div class="form-group">
								<label class="col-sm-2 control-label" for="name">附件：</label>
								<div class="col-sm-10">
									<div class="uploader" id="uploader_add_file" add_file_id="add_file">
                                                                            <a class="btn btn-sm btn-primary" id="testList">添加附件</a>

                                                                            <ul class="file_list" new_upload="" id="file_list"></ul>
                                                                    </div>
									<p></p>
                                                                        
                                                                        <br/>
								</div>
							</div>
						</form>
					</div>

					<div class="tab-pane" id="reject">
						<form method='post' id="form_data_reject" name="form_data_reject" >
							<input type="hidden" name="status" value="22">
							<input type="hidden" name="id" value="<!--{$task_working.id}-->">
							<div class="form-group">
								<label class="col-sm-2 control-label" >执行内容：</label>
								<div class="col-sm-10">
									<textarea id="feed_back" name="feed_back" class="col-xs-12 simple" style="height:120px" ><!--{$task_working.feed_back}--></textarea>
									<p></p>
								</div>
							</div>
						</form>
					</div>
				</div>
				<div class="widget-toolbox clearfix">
					<div class="pull-left col-sm-8 col-sm-offset-2">
						<a onclick="save_log();" class="btn btn-sm btn-primary col-6">提交</a>
						<a onclick="go_return_url();" class="btn btn-sm btn-default">取消</a>
					</div>
				</div>
			</div>
		</div>
            <!--{/if}-->
</block>

                                		</div>
		<!-- Mainly scripts -->
		<script src="<!--{$oapath}-->Ins/js/jquery-2.1.1.js"></script>
		<script src="<!--{$oapath}-->Ins/js/bootstrap.min.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/metisMenu/jquery.metisMenu.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
		<!-- Custom and plugin javascript -->
		<script src="<!--{$oapath}-->Ins/js/inspinia.js"></script>
		<script src="<!--{$oapath}-->Ins/js/common.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/pace/pace.min.js"></script>
                
		<script src="<!--{$oapath}-->Ins/js/plugins/toastr/toastr.min.js"></script>
                <script src="<!--{$oapath}-->Ins/js/plugins/gritter/jquery.gritter.min.js"></script>
                <script src="<!--{$oapath}-->Ins/js/plugins/bootbox/bootbox.min.js"></script>
		
        <script src="<!--{$oapath}-->Ins/js/plugins/jquery-ui/jquery-ui.min.js"></script>
	<script src="<!--{$oapath}-->Ins/js/plugins/nouslider/jquery.nouislider.min.js"></script>
        <script src="<!--{$oapath}-->Ins/js/plugins/date-time/moment-with-locales.js"></script>
	<script src="<!--{$oapath}-->Ins/js/plugins/date-time/bootstrap-datetimepicker.js"></script>
          <script type="text/javascript" src="<!--{$oapath}-->Ins/js/layui/layui.js"></script>

		<block name="js"></block>
		<script>
			$(document).ready(function() {
				$(".popup-container").width($("#dialog", parent.document).width());
				if (is_mobile()) {
					$(".popup-container").height(window.screen.height - 40);
					$(".popup-container").css('overflow', 'auto');
				}
			});
		</script>
        <block name="js">
             <script type="text/javascript">
	$(document).ready(function() {
		$('.input-date').datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn',
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});
		
		$(".input-daterange input").datetimepicker({
			format : "YYYY-MM-DD",
			locale : 'zh-cn',
			showTodayButton : true,
			showClose : true,
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});

		$("#start_date").on("dp.change", function(e) {
			if ($("#end_date").length > 0) {
				$('#end_date').data("DateTimePicker").minDate(e.date);
			}
		});
		
		$("#end_date").on("dp.change", function(e) {
			if ($("#start_date").length > 0) {
				$('#start_date').data("DateTimePicker").maxDate(e.date);
			}
		});

		$(".input-date-time").datetimepicker({
			format : 'YYYY-MM-DD HH:mm',
			locale : 'zh-cn',
			sideBySide : true,
			showTodayButton : true,
			showClose : true,
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});		 
	}); 
</script>
                <script type="text/javascript">
		$(function() {
			show_content();
		});
                $(document).on("click", "#del_li", function() {
				$(this).parent().parent().parent().remove();		
		});
		function popup_actor() {
			winopen("{:U('popup/task')}",560, 470);
		}

	

		function let_me_do($task_id) {
			sendAjax("oa.php?c=Task&a=let_me_do", 'task_id=' + $task_id, function(data) {
				if (data.status) {
					ui_alert(data.info, function() {
						location.reload(true);
					});
				}
			});
		}

		function save_log() {
			$status_name = $(".task_todo .tab-pane.active").attr('id');
			if ($status_name == "forword") {
				if ($(".address_list span").length == 0) {
					ui_error('请选择要转交的人');
					return false;
				} else {
					$("#forword_executor").val("");
					$("#actor_wrap span.address_list span").each(function() {
						$("#forword_executor").val($("#forword_executor").val() + $(this).find("b").text() + '|' + $(this).attr("data") + ";");
					});
				}
			}
			$form_name = "form_data_" + $status_name;
			if (check_form($form_name)) {
				var vars = $("#" + $form_name).serialize();
				if ($status_name == "working") {
					sendAjax("oa.php?c=Task&a=save_log", vars, function(data) {
						if (data.status) {
							ui_alert(data.info, function() {
								location.reload(true);
							});
						} else {
							ui_error(data.info);
						}
					});
				}

		

				if ($status_name == "reject") {
					ui_confirm('选择拒绝以后不能修改了,是否提交?', function() {
						sendAjax("{:U('oa.php?c=Task&a=save_log')}", vars, function(data) {
							if (data.status) {
								ui_alert(data.info, function() {
									location.reload(true);
								});
							} else {
								ui_error(data.info);
							}
						});
					});
				}
			}
		}


		$(document).ready(function() {
			$(document).on("click", ".inputbox .address_list a.del", function() {
				$(this).parent().parent().remove();
			});

			$("#basic_slider").noUiSlider({
				start : parseInt('<!--{$task_working.finish_rate}-->'),
				step : 1,
				behaviour : 'tap',
				connect : 'upper',
				range : {
					'min' : 0,
					'max' : 100,
				},
			});
			$("#basic_slider").on('slide', function() {
				$("#finish_rate").val($(this).val());
				$("div.slider_box .right").text(Math.abs($(this).val()) + "%");
			});

			set_val('status', '<!--{$task_working.finish_rate}-->');
			$("#slider-range-priority").slider({
				range : "min",
				min : 0,
				max : 100,
				value : '<!--{$task_working.finish_rate}-->',
				slide : function(event, ui) {
					$("#finish_rate").val(ui.value);
					$("#slider_val").text(ui.value + "%");
				}
			});
		});
	</script>
                 <script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
  //普通图片上传
  var uploadInst = upload.render({
    elem: '#testList'
    ,url: 'oa.php?c=Popup&a=upload'
    ,accept: 'file'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.code > 0){
        return layer.msg('上传失败');
      }else{
          var html="<li class='tbody'><input type='hidden' name='upload_file[]' value='"+res.name1+"'/><div class='loading' style='width: 100%;'></div><div class='data'><span class='del text-center'><a class='link del' id='del_li' style='display: inline;'>删除</a></span>";
          html+="<span class='size text-right'>"+res.size+"</span>";
          html+="<span class='auto autocut'>"+res.name2+"</span></div></li>";
          var demoText = $('#file_list');
          demoText.append(html);
      }
      //上传成功
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  });
  

  
  //绑定原始文件域
  upload.render({
    elem: '#test20'
    ,url: '/upload/'
    ,done: function(res){
      console.log(res)
    }
  });
  
});
</script>
        </block>
	</body>
</html>