<!--{include file="<!--{$oapath}-->public/ins_page.tpl"}-->

<block name="content">
		<div class="page-header">
	<h1>系统参数</h1>
</div>
	<div class="panel blank-panel">
		<div class="panel-heading">
			<div class="panel-options">
				<ul class="nav nav-tabs">
					<li id="tb1">
						<a href="#tab-1" onclick="set_current_tab(1)" data-toggle="tab" aria-expanded="false">基本设置</a>
						<!--<notempty name="system_license">
							<li id="tb2">
								<a href="#tab-2" onclick="set_current_tab(2)"data-toggle="tab" aria-expanded="false">微信设置</a>
							</li>
							<li id="tb3">
								<a href="#tab-3" onclick="set_current_tab(3)"data-toggle="tab" aria-expanded="false">微信菜单</a>
							</li>
						</notempty>
					<li id="tb4">
						<a href="#tab-4" onclick="set_current_tab(4)"data-toggle="tab" aria-expanded="false">其他</a>
					</li>
					<li id="tb5">
						<a href="#tab-5" onclick="set_current_tab(5)"data-toggle="tab" aria-expanded="false">推送设置</a>
					</li>-->
				</ul>
			</div>
		</div>

		<div class="panel-body">
			<div class="tab-content">
				<div class="tab-pane" id="tab-1">
					<form id="form_system" name="form_system" method="post">
						<input type="hidden" name="data_type" value="system">
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right" for="code">系统名称*：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="system_name" name="system_name" check="require" msg="请输入系统名称" value="<!--{$system_data.system_name}-->">
							</div>
						</div>
						<!--<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right" for="system_license">授权码：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="system_license" name="system_license" value="<!--{$system_data.system_license}-->" >
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right" for="upload_file_ext">上传文件类型*：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="upload_file_ext" name="upload_file_ext" value="<!--{$system_data.upload_file_ext}-->">
							</div>
						</div>-->
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right">登录验证码：</label>
							<div class="col-sm-10">
								<label>
                                                                    <input type="checkbox" value="1" name="login_verify_code" <!--{if $system_data.login_verify_code=='1'}-->checked<!--{/if}--> >
									开启</label>
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label"></label>
							<div class="col-sm-10">
								<a onclick="save_system()" class="btn btn-sm btn-primary">保存</a>
							</div>
						</div>
					</form>
				</div>
				<div class="tab-pane" id="tab-2">
					<form id="form_weixin" name="form_weixin" method="post">
						<input type="hidden" name="data_type" value="weixin">
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right">微信可信域名*：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="weixin_site_url" name="weixin_site_url" value="{$weixin_data.weixin_site_url}">
								<p>示例：http://xiaowei.smeoa.com/</p>
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right" for="weixin_corp_id">CorpID*：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="weixin_corp_id" name="weixin_corp_id" check="require" msg="请输入CorpID" value="{$weixin_data.weixin_corp_id}">
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right" for="weixin_secret">Secret*：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="weixin_secret" name="weixin_secret" check="require" msg="请输入Secret" value="{$weixin_data.weixin_secret}">
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right" for="weixin_token">Token*：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="weixin_token" name="weixin_token" value="{$weixin_data.weixin_token}" >
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label text-right">EncodingAESKey*：</label>
							<div class="col-sm-10">
								<input class="form-control" type="text" id="weixin_encoding_aes_key" name="weixin_encoding_aes_key" value="{$weixin_data.weixin_encoding_aes_key}">
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-2 control-label"></label>
							<div class="col-sm-10">
								<a onclick="save_weixin()" class="btn btn-sm btn-primary">保存</a>
							</div>
						</div>
					</form>
				</div>

				<div class="tab-pane" id="tab-3">
					<input type="hidden" name="ajax" id="ajax" value="0">
					<select name="weixin_menu_list" id="weixin_menu_list" class="hidden">
						<option value="0">无</option>
						{:fill_option($weixin_menu_list)}
					</select>
					<form id="form_search_weixin" name="form_search_weixin" method="post">
						<div class="operate panel panel-default">
							<div class="panel-body">
								<div class="pull-left">
									<select class="form-control" id="weixin_option" name="weixin_option" >
										{:fill_option($weixin_option,$weixin_option_id)}
									</select>
								</div>
								<div class="pull-right">
									<a onclick="release()" class="btn btn-sm btn-primary">发布</a>
									<a onclick="add_option()" class="btn btn-sm btn-primary">新增应用</a>
									<a onclick="add_menu()"  class="btn btn-sm btn-primary">新增菜单</a>
									<a onclick="save_menu()"  class="btn btn-sm btn-primary">保存</a>
									|
									<a onclick="del_menu()"  class="btn btn-sm btn-danger">删除</a>
								</div>
							</div>
						</div>
					</form>
					<!-- 功能操作区域结束 -->
					<!-- 列表显示区域  -->
					<form id="form_menu" name="form_menu" method="post">
						<input type="hidden" name="id" id="id" for="id">
						<div class="row">
							<div class="col-sm-4 sub_left_menu tree_menu b">
								<div class="well">
									<php>
										echo $weixin_menu
									</php>
								</div>
							</div>
					</form>
					<div class="col-sm-8 sub_content">
						<form id="form_data_weixin" name="form_data_weixin" method="post" class="weixin well form-horizontal clearfix">
							<input type="hidden" name="id" id="id">
							<div class="form-group col-xs-12">
								<label class="col-xs-3 control-label" for="name">菜单名称*：</label>
								<div class="col-xs-9">
									<input class="form-control" type="text" id="name" name="name" check="require" msg="请输入菜单名称">
								</div>
							</div>
							<div class="form-group col-xs-12">
								<label class="col-xs-3 control-label" for="val">事件选择*：</label>
								<div class="col-xs-9">
									<select class=" form-control" name="type"id="type">
										<option value="click">点击推事件</option>
										<option value="view">跳转URL</option>
										<option value="scancode_push">扫码推事件</option>
										<option value="scancode_waitmsg">扫码推事件且弹出“消息接收中”提示框</option>
										<option value="pic_sysphoto">弹出系统拍照发图</option>
										<option value="pic_photo_or_album">弹出拍照或者相册发图</option>
										<option value="location_select">弹出地理位置选择器</option>
										<option value="media_id">下发消息（除文本消息）</option>
										<option value="view_limited">跳转图文消息URL</option>
									</select>
									<p>
										注：需要进行链接的事件为view事件
									</p>
								</div>

							</div>

							<div class="form-group col-xs-12">
								<label class="col-xs-3 control-label" for="url">URL*：</label>
								<div class="col-xs-9">
									<input class="form-control" type="text" id="url" name="url"  >
									<p>注：示例链接形式：index.php?m=&c=Task&a=folder&fid=all</p>
								</div>

							</div>

							<div class="form-group col-xs-12">
								<label class="col-xs-3 control-label" for="key">Key*：</label>
								<div class="col-xs-9">
									<input class="form-control" type="text" id="key" name="key" >
									<p>
										注：每个菜单需要有单独的key
									</p>
								</div>
							</div>
							<div class="form-group col-xs-12">
								<label class="col-xs-3 control-label" for="pid_name">父级*：</label>
								<div class="col-xs-9">
									<div class="input-group">
										<input name="pid_name" class="form-control" id="pid_name" type="text" readonly="readonly" msg="请选择父级" check="require"/>
										<input name="pid" id="pid" type="hidden" msg="请选择父级" check="require" />
										<span class="input-group-btn">
											<button class="btn btn-sm btn-primary" onclick="select_weixin_pid()" type="button">
												选择
											</button> </span>
									</div>
								</div>
							</div>
							<div class="form-group col-xs-12">
								<label class="col-xs-3 control-label" for="sort">排序：</label>
								<div class="col-xs-9">
									<input class="form-control" type="text" id="sort" name="sort" >
								</div>
							</div>
						</form>
						<p>
							*一级菜单最多三个，二级菜单最多五个
						</p>
					</div>
				</div>
			</div>

			<div class="tab-pane" id="tab-4">
				<input type="hidden" name="ajax" id="ajax" value="0">
				<select name="system_config_list" id="system_config_list" class="hidden">
					<option value="0">无</option>
					{:fill_option($system_config_list)}
				</select>
				<form id="form_search" name="form_search" method="post">
					<div class="operate panel panel-default">
						<div class="panel-body">
							<div class="pull-left">
								<select name="eq_pid" id="eq_pid" class="form-control" onchange="submit_search();">
									<option value=''>全部</option>
									{:fill_option($group_list)}
								</select>
							</div>
							<div class="pull-right">
								<a onclick="add()" class="btn btn-sm btn-primary">新增</a>
								<a onclick="save()"  class="btn btn-sm btn-primary">保存</a>
								|
								<a onclick="del()"  class="btn btn-sm btn-danger">删除</a>
							</div>
						</div>
					</div>
				</form>
				<!-- 功能操作区域结束 -->
				<!-- 列表显示区域  -->
				<form id="form_data_system" name="form_data_system" method="post">
					<input type="hidden" name="menu_id" id="menu_id" >
					<div class="col-sm-4 sub_left_menu tree_menu a ">
						<div class="well">
							<php>
								echo $menu
							</php>
						</div>
					</div>
				</form>
				<div class="col-sm-8 sub_content">
					<form id="form_data" name="form_data" method="post" class="common well form-horizontal clearfix">
						<input type="hidden" name="id" id="id">
						<input type="hidden" name="data_type" value="common">
						<input type="hidden" name="opmode" id="opmode" value="">
						<div class="form-group col-xs-12">
							<label class="col-sm-4 control-label" for="code">编码*：</label>
							<div class="col-sm-8">
								<input class="form-control" type="text" id="code" name="code" check="require" msg="请输入编码">
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-4 control-label" for="name">名称*：</label>
							<div class="col-sm-8">
								<input class="form-control" type="text" id="name" name="name" check="require" msg="请输入名称">
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-4 control-label" for="val">数据*：</label>
							<div class="col-sm-8">
								<input class="form-control" type="text" id="val" name="val" check="require" msg="请输入数据">
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-4 control-label" for="pid_name">父级*：</label>
							<div class="col-sm-8">
								<div class="input-group">
									<input name="pid_name" class="form-control" id="pid_name"  type="text" readonly="readonly" msg="请选择父级" check="require"/>
									<input name="pid" id="pid" type="hidden" msg="请选择上级部门" check="require" />
									<span class="input-group-btn">
										<button class="btn btn-sm btn-primary" onclick="select_pid()" type="button">
											选择
										</button> </span>
								</div>
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="col-sm-4 control-label" for="sort">排序：</label>
							<div class="col-sm-8">
								<input class="form-control" type="text" id="sort" name="sort" >
							</div>
						</div>

						<div class="form-group col-xs-12">
							<label class="col-sm-4 control-label" for="is_del">状态*：</label>
							<div class="col-sm-8">
								<select   name="is_del" id="is_del1" class="form-control">
									<option  value="0">启用</option>
									<option value="1">禁用</option>
								</select>
							</div>
						</div>
					</form>
				</div>
			</div>

			<div class="tab-pane" id="tab-5">
				<form id="form_system_push" name="form_system_push" method="post">
					<input type="hidden" name="data_type" value="system_push">
					<div class="form-group col-xs-12">
						<label class="col-sm-2 control-label text-right" for="ws_push_config">网页推送设置：</label>
						<div class="col-sm-10">
							<input class="form-control" type="text" id="ws_push_config" name="ws_push_config" value="{$push_data.ws_push_config}">
						</div>
					</div>
					<div class="form-group col-xs-12">
						<label class="col-sm-2 control-label text-right" for="weixin_push_config">微信推送设置：</label>
						<div class="col-sm-10">
							<input class="form-control" type="text" id="weixin_push_config" name="weixin_push_config" value="{$push_data.weixin_push_config}" >
						</div>
					</div>
					<div class="form-group col-xs-12">
						<label class="col-sm-2 control-label text-right" for="msg_push_config">微信分类推送：</label>
						<div class="col-sm-10">
							<input class="form-control" type="text" id="msg_push_config" name="msg_push_config" value="{$push_data.msg_push_config}">
						</div>
					</div>

					<div class="form-group col-xs-12">
						<label class="col-sm-2 control-label"></label>
						<div class="col-sm-10">
							<a onclick="save_system_push()" class="btn btn-sm btn-primary">保存</a>
						</div>
					</div>
				</form>
			</div>
		</div>
</block>

					
				</div>
			</div>
		</div>
		<!--<iframe src="{:U('push/client')}" class="push" id="push"></iframe>-->
		<!-- 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>
		
		<include file="Layout:ins_plugin_js"/>
<block name="js">
	<script type="text/javascript">
		function add() {
			winopen("{:U('add')}",560, 470);
		}

		function add_menu($oid) {
			winopen("{:U('add_menu')}",560, 470);
		}

		function add_option() {
			winopen("{:U('add_option')}",560, 470);
		}

		function release() {
			winopen("{:U('release')}",560, 470);
		}

		function save_system() {
			sendForm("form_system", "oa.php?c=System&a=save", "oa.php?c=System&a=config");
		}

		function save_weixin() {
			sendForm("form_weixin", "{:U('save')}", "{:U('index')}");
		}

		function save_system_push() {
			sendForm("form_system_push", "{:U('save')}", "{:U('index')}");
		}

		function save() {
			sendForm("form_data", "{:U('save')}", "{:U('index')}");
		}

		function save_menu() {
			sendForm("form_data_weixin", "{:U('save_weixin_menu')}", "{:U('index')}");
		}

		function del() {
			var vars = $("#form_data").serialize();
			if ($(".sub_left_menu a.active").parent().find(".tree_menu").html() != undefined) {
				ui_error("有子目录不能删除");
				return false;
			}
			ui_confirm('确定要删除吗?', function() {
				sendAjax("{:U('del')}", vars, function(data) {
					if (data.status) {
						ui_alert(data.info, function() {
							location.reload(true);
						});
					}
				});
			});
		}

		function del_menu() {
			var vars = $("#form_data_weixin").serialize();
			if ($(".sub_left_menu a.active").parent().find(".tree_menu").html() != undefined) {
				ui_error("有子目录不能删除");
				return false;
			}
			ui_confirm('确定要删除吗?', function() {
				sendAjax("{:U('del_menu')}", vars, function(data) {
					if (data.status) {
						ui_alert(data.info, function() {
							location.reload(true);
						});
					}
				});
			});
		}

		function select_pid() {
			winopen("{:U('winpop')}",560, 470);
		}

		function select_weixin_pid() {
			winopen("{:U('winpop_weixin')}",560, 470);
		}

		function showdata_weixin(result) {
			$("#form_data_weixin #id").val(result.data['id']);
			$("#form_data_weixin #name").val(result.data['name']);
			$("#form_data_weixin #url").val(result.data['url']);
			$("#form_data_weixin #key").val(result.data['key']);
			$("#form_data_weixin #pid").val(result.data['pid']);
			$("#form_data_weixin #type").val(result.data['type']);

			$("#form_data_weixin #sort").val(result.data['sort']);

			$("#pid_name").val($("#weixin_menu_list option[value='" + $("#pid").val() + "']").text());
			$("#opmode").val("edit");
		}

		function showdata_common(result) {
			$("#form_data #code").val(result.data['code']);
			$("#form_data #name").val(result.data['name']);
			$("#form_data #val").val(result.data['val']);
			$("#form_data #sort").val(result.data['sort']);
			$("#form_data #is_del").val(result.data['is_del']);
			$("#form_data #remork").val(result.data['remork']);
			$("#form_data #pid").val(result.data['pid']);
			$("#form_data #id").val(result.data['id']);
			$("#form_data #pid_name").val($("#system_config_list option[value='" + result.data['pid'] + "']").text());
			$("#opmode").val("edit");
		}


		$("#weixin_option").change(function() {
			$('#form_search_weixin').submit();
		});

		function set_current_tab(num) {
			set_cookie('current_tab', num);
		}

		function get_current_tab() {
			if (get_cookie('current_tab') == undefined) {
				return 1;
			} else {
				return get_cookie('current_tab');
			}
		}

		//读取修改侧页
		$(document).ready(function() {

			//选择上次选择的TAB
			$current_tab = get_current_tab();
			$(".panel-heading li").removeClass("active");
			$(".tab-pane").removeClass("active");

			$("#tb" + $current_tab).addClass("active");
			$("#tab-" + $current_tab).addClass("active");

			set_val('eq_pid', '{$eq_pid}');

			$("#tab-3 .tree_menu a").click(function() {
				$(".tree_menu a.active").removeClass("active");
				$(this).addClass("active");
				sendAjax("{:U('edit')}", "id=" + $(this).attr("node") + "&name=", function(data) {
					showdata_weixin(data);
				});
				return false;
			});

			$("#tab-4 .tree_menu a").click(function() {
				$(".sub_left_menu .tree_menu a.active").removeClass("active");
				$(this).addClass("active");
				sendAjax("{:U('read')}", "id=" + $(this).attr("node") + "&name=", function(data) {
					showdata_common(data);
				});
				return false;
			});
			//跳页

			sendAjax("{:U('read')}", "id={$eq_pid}", function(data) {
				showdata(data);
			});
		});
	</script>
</block>
	</body>
</html>
