<!--{include file="<!--{$oapath}-->public/ins_page.tpl"}-->
 <link rel='stylesheet' type='text/css' href="<!--{$oapath}-->Ins/js/layui/css/layui.css">
 <script type='text/javascript' src='<!--{$urlpath}-->data/oaeditor/kindeditor.js'></script>
<block name="content">
	<div class="page-header">
	<h1><!--{if $opmode=='edit'}-->编辑<!--{else}-->发布<!--{/if}-->任务</h1>
</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="1">
		<input type="hidden" id="executor" name="executor" value="">
		<input type="hidden" id="opmode" name="opmode" value="<!--{$opmode}-->">
            <!--{if $opmode=='edit'}-->
                 <input type="hidden" id="id" name="id" value="<!--{$vo.id}-->">
                <!--{/if}-->
		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">标题：</label>
			<div class="col-sm-10">
				<input class="form-control" type="text" id="name" name="name" value="<!--{$vo.name}-->"  check="require" msg="请输入标题">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">指派给：</label>
			<div class="col-sm-10">
				<div id="actor_wrap" class="inputbox">
					<a class="pull-right btn btn-link text-center" onclick="popup_actor();"><i class="fa fa-user"></i> </a>
					<div class="wrap" >
						<span class="address_list"><!--{$vo.executor}--></span>
						<span class="text" >
                                                    <input class="letter" type="text"  >
						</span>
					</div>
					<div class="search dropdown ">
						<ul class="dropdown-menu"></ul>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="expected_time">期望完成时间：</label>
			<div class="col-sm-10">
                            <input class="form-control input-date-time" type="text" id="expected_time" name="expected_time" value="<!--{$vo.expected_time}-->" readonly="readonly">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="content">任务说明：</label>
			<div class="col-sm-10">
				<textarea class="editor" id="content" name="content" style="width:100%;height:300px;" check="require" msg="请输入内容"><!--{$vo.content}--></textarea>
                                                                                       <script>var editor;KindEditor.ready(function(K) {editor = K.create('#content',{afterCreate : function() {
    this.sync();
},
afterBlur:function(){
    this.sync();
} }); });</script>
			</div>
		</div>

		<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">
                                        <!--{foreach $file as  $v}-->
                                        <li class='tbody'>
                                            <input type='hidden' name='upload_file[]' value='<!--{$v.path}-->'/>
                                            <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>
                                                <span class='size text-right'><!--{$v.size}--></span>
                                                <span class='auto autocut'><!--{$v.name}--></span>
                                            </div>
                                        </li>
                                          
                         <!--{/foreach}-->
                            
                                    </ul>
                            </div>
			</div>
		</div>
		<div class="form-group">
			<div class="action col-sm-10 col-sm-offset-2">
				<input class="btn btn-sm btn-primary" type="button" value="保存" onclick="save();">
				<input class="btn btn-sm btn-default" type="button" value="取消" onclick="go_return_url();">
			</div>
		</div>
	</form>
</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/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 save() {
			$("#executor").val("");
			$("#actor_wrap span.address_list span").each(function() {
				$("#executor").val($("#executor").val() + $(this).find("b").text() + '|' + $(this).attr("data") + ";");
			});
			$html = $("#executor").val();
			var re = new RegExp("dept_", "g");
			var arr = $html.match(re);
			if (arr != null) {
				$dept_count = arr.length;
				$total_count = $html.split(';').length - 1;
				if ($dept_count != $total_count) {
					ui_error('部门和人员不能同时选择');
					return false;
				}
			}
			sendForm("form_data", "oa.php?c=Task&a=save", "oa.php?c=Task");
		}

		function popup_actor() {
			winopen("oa.php?c=popup&a=actor",560, 470);
		}

		$(document).ready(function() {
			$(document).on("click", ".inputbox .address_list a.del", function() {
				$(this).parent().parent().remove();
			});
		});
                                        $(document).on("click", "#del_li", function() {
                                                $(this).parent().parent().parent().remove();		
                                });
                </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>