<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>KGCMS企业应用管理平台 - Powered by KGCMS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<!-- <meta http-equiv="cache-control" content="no-siteapp" /> -->
<link rel="stylesheet" href="{{ kg['tpl_url'] }}style/upload_manage.css">
<script src="{{ kg['tpl_url'] }}script/jquery.min.js"></script>
<script src="{{ kg['server']['HTTP_HOST'] }}/tools/amazeui/js/amazeui.min.js"></script>
<script src="{{kg['tpl_url']}}script/common.js"></script>
<script src="{{kg['tpl_url']}}script/upload_manage.js"></script>
</head>
<body data-type="generalComponents">
	{% include 'component_header.tpl' %}
	<div class="tpl-page-container tpl-page-header-fixed">
		<div class="scrollbar-wrap">
		{% include 'component_left.tpl' %}
		<div class="tpl-content-wrapper">
			<div class="tpl-content-page-title">
				服务器附件管理
			</div>
			<ol class="am-breadcrumb">
				<li><a href="./" class="am-icon-home">首页</a></li>
				{% if path %}<li><a href="upload_manage">服务器附件管理</a></li>{% else %}<li class="am-active">服务器附件管理</li>{% endif %}
				{% for row in path %}
				{% if loop.index == path|length %}
				<li class="am-active">{{row['name']}}</li>
				{% else %}
				<li><a href="upload_manage?action=open&dir={{row['url']}}">{{row['name']}}</a></li>
				{% endif %}
				{% endfor %}
			</ol>
			<div class="tpl-portlet-components">
				<div class="portlet-title">
					<div class="caption font-green bold">
						<span class="am-icon-code"></span>&nbsp;服务器上传附件管理
					</div>
					<div class="tpl-portlet-input tpl-fz-ml am-no-margintop">
						<div class="am-btn-toolbar ngre-Hdadd-paddidngT ngco-No-paddingR">
							<div class="am-btn-group am-btn-group-xs">
								{% if kg['cookie']["KGCMS_PAGE_VIEW"] == "list"%}
								<a href="/api/admin_process?action=set_view&value=simple" class="am-btn am-btn-success"><span class="am-icon-plus"></span>&nbsp;缩略视图</a>
								{%else%}
								<a href="/api/admin_process?action=set_view&value=list" class="am-btn am-btn-success"><span class="am-icon-plus"></span>&nbsp;列表视图</a>
								{%endif%}
							</div>
						</div>
					</div>
				</div>
				{% if kg['cookie']["KGCMS_PAGE_VIEW"] == "list"%}
				<div class="am-g list-view">
					<div class="am-u-sm-12 ngco-No-paddingR">
						<form  method="post" id="ty-form">
							<table class="am-table am-table-striped am-table-hover table-main ngco-Esz-mgibdr">
								<thead>
									<tr>
										{% if path %}
										<th class="table-title">选择</th>
										{%endif%}
										<th class="table-title">文件名称</th>
										<th class="table-title">创建时间</th>
										<th class="table-title">文件大小</th>
										{% if path|length > 0 %}
										<th class="table-title">操作</th>
										{% endif %}
									</tr>
								</thead>
								{% if not list %}<div class="no-data"> <ul>没有相关数据</ul> </div>{% endif %}
								<tbody>
									{% for row in list %}
									<tr>
										{% if path %}
										<td>
											<input type="checkbox" class="ty-checkbox">
											<input type="hidden" value="{{row['path']}}" class="ty-checkbox2">
										</td>
										{%endif%}
										{%if row['type'] == "image" %}
										<td>
											<img class="upload-img" src="{{kg['tpl_url']}}{{row['logo']}}" alt="" style="width:20px;height: 20px;" alt="" />
											<a target="_blank" href="{{kg['server']['HTTP_HOST']}}/{{row['path']}}">{{row['name']}}</a></td>
										{% else %}
										<td>
											<img class="upload-img" src="{{kg['tpl_url']}}{{row['logo']}}" alt="" style="width:20px;height: 20px;" alt="" />
											<a href="upload_manage?action=open&dir={{row['path']}}">{{row['name']}}</a>
										</td>
										{% endif %}
										<td>{{row['addtime']}}</td>
										<td>{{row['size']}}</td>
										{% if path|length > 0 %}
										<td>
											<div class="am-btn-toolbar ngco-KNo-padding">
												<div class="am-btn-group am-btn-group-xs">
													<input type="hidden" value="{{row['type']}}">
													<a href="upload_manage?action=del&dir={{row['path']}}" class="ngro-Jclick-shanchubi am-btn am-btn-default am-btn-xs am-text-danger"><span class="am-icon-trash-o"></span>&nbsp;删除</a>
												</div>
											</div>
										</td>
										{% endif %}
									</tr>
									{% endfor %}
								</tbody>
							</table>
							<input type="hidden" name="action" value="del">
						</form>
					</div>
				</div>
				{% if path|length > 0 %}
				<div class="am-u-sm-12 am-u-md-6">
					<div class="am-btn-toolbar ng-xno-borderL" id="select-handle">
						<span class="am-input-group-btn add-span">
							<a class="add am-btn am-btn-default am-select am-back ngco-Ono-radiusR" href="javascript:;">全选</a>
						</span>
						<a type="submit" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span>&nbsp;删除</a>
					</div>
				</div>
				
				{% endif %}
				{% else %}
				<div class="tpl-block simple-view">
					<div class="am-g">
						<form  method="post" id="ty-form">
							{% for row in list %}
							<div class="upload-table-images {% if row['type'] not in ['dir', 'file'] %}upload-box{%endif%}">
								<div>
									<input type="hidden" value="{{row['path']}}" class="ty-checkbox2">
									<div class="upload-table-images-content">
										{%if row['type'] == "image" %}
										<a target="_blank" href="{{kg['server']['HTTP_HOST']}}/upload/{{row['path']|replace('|','/')}}" class="tpl-table-images-content-i">
											{%elif row['type'] == 'dir'%}
											<a href="upload_manage?action=open&dir={{row['path']}}" class="tpl-table-images-content-i">
												{% else %}
												<a href="../api/admin_process?action=download&name={{ row["name"] }}&code={{ row["code"] }}" class="tpl-table-images-content-i">
													{%endif%}
													<img class="upload-img" onload="kg.img_auto_size(this)" src="{% if row['type'] == 'image' %}/upload/{{row['path']|replace('|','/')}}{% else %}{{kg['tpl_url']}}{{row['logo']}}{%endif%}" alt="" />
												</a>
												<div class="upload-dui"><img src="http://test.kgcms.com/template/backend/default/images/ok.png" alt="" /></div>
												<div class="upload-check am-btn am-btn-secondary"><a href="javascript:;"><span class="am-icon-check"></span>&nbsp;选&nbsp;择</a></div>
												{% if row['type'] == 'file' %}
												<div class="upload-search bg-black am-btn am-btn-success"><a href="../upload/{{row['path']|replace('|','/')}}"><span class="am-icon-search"></span>&nbsp;查&nbsp;看</a></div>
												{% else %}
												<div class="upload-search1 upload-search bg-black am-btn am-btn-success"><a href="javascript:;"><span class="am-icon-search"></span>&nbsp;查&nbsp;看</a></div>
												{% endif %}
												{% if row['type'] == 'dir' %}
												<div class="upload-correct am-btn am-btn-secondary"><a href="upload_manage?action=open&dir={{row['path']}}"><span class="am-icon-folder-open-o"></span>&nbsp;打&nbsp;开</a></div>
												{% endif %}
												{% if row['type'] in ['file', 'image'] %}
												<div class="upload-correct am-btn am-btn-secondary"><a target="_blank" href="../upload/{{row['path']|replace('|','/')}}"><span class="am-icon-folder-open-o"></span>&nbsp;打&nbsp;开</a></div>
												{% endif %}
												<div class="upload-del upload-trash am-btn am-btn-danger"><a href="upload_manage?action=del&dir={{row['path']}}"><span class="am-icon-trash-o"></span>&nbsp;删&nbsp;除</a></div>
									</div>
									{%if path%}
									<input type="hidden" value="{{row['path']}}" class="ty-checkbox2">
									{%endif%}
									<div class="upload-name">{{row['name']}}</div>
									<div class="upload-time">{{row['addtime']}}</div>
									<div class="upload-size">{{row['size']}}</div>
								</div>
							</div>
							{% endfor %}
							<input type="hidden" name="action" value="del">
						</form>
					</div>
					<hr class="am-no-margintop tpl-table" />
					<!-- <div style="clear: both;"></div> -->
					{% if path|length >0 and page_data['total_rows'] %}
					<div class="am-btn-toolbar ng-xno-borderL" id="select-handle">
						<a class="add am-btn am-btn-default am-select am-back ngco-Ono-radiusR" href="javascript:;">全选</a>
						<a href="javascript:;" type="submit" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span>&nbsp;删除</a>
					</div>
					{%endif%}
				</div>
				{% endif %}
				{% if page_data['total_page'] > 1 %}
				{{pagehtml}}
				{% endif %}
			</div>
			{% include 'component_footer.tpl' %}
		</div>
		</div><!-- /.scrollbar-wrap -->
	</div>
	<!-- 模态框 -->
	<div class="modal-frame">
		<div class="return-btn"><a class="am-icon-chevron-left" href="javascript: void(0)"></a></div>
		<ul class="modal-frame-img">
			<li>
				<img src="/" alt="" />
				<img src="/upload/advertise/201912/191210175925.png" alt="">
			</li>
		</ul>
		<ul class="am-pureview-direction">
			<li class="am-pureview-prev"><a href="javascript: void(0)"></a></li>
			<li class="am-pureview-next"><a href="javascript: void(0)"></a></li>
		</ul>
		<div class="modal-title">
			<span class="am-pureview-title">g</span>
			<span class="am-pureview-time"></span>
			<span class="am-pureview-size"></span>
			<div class="am-pureview-counter"><span class="am-pureview-current">1</span> / <span class="am-pureview-total">1</span></div>
		</div>
	</div>
	<script>
	$(function() {
		// 图片根据窗口大小缩放
		$(window).resize(function() {
			$(".tpl-table-images-content-i").height($(".upload-table-images").width());
			$(".tpl-table-images-content-i").width($(".upload-table-images").width());
		});
		$(".tpl-table-images-content-i").height($(".upload-table-images").width());
		$(".tpl-table-images-content-i").width($(".upload-table-images").width());
		// 处理样式
		var level = {{ path | length }};
		if (level == 0) {
			$(".upload-check").remove();
			$(".upload-search").remove();
			$(".upload-correct").remove();
			$(".upload-del").remove();
			$(".tpl-table-images-content-i").addClass("upload-opacity upload-del-hover")
		}
		if (level != 0) {
			$(".tpl-table-images-content-i").removeClass("upload-opacity")
		}
		$(".am-g").children("form").children().each(function() {
			var flagUpload = $(this).is(".upload-box");
			if (flagUpload) {
				$(this).find(".upload-correct").remove();
				$(this).find(".upload-trash").removeClass("upload-del");
			} else {
				$(this).find(".upload-check").remove();
				$(this).find(".upload-search").remove();
				$(this).find(".tpl-table-images-content-i img").css("width", "64%").css("height", "64%");
				$(this).find(".upload-dui").hide();
				$(this).find(".upload-table-images-content>a").css("display", "flex");
			}
			if ($(this).find(".upload-size").text() == "--") {
				$(this).find(".upload-size").text("文件夹");
			}
		})
		// 选择/不选择
		$(".upload-check").on("click", function() {
			var choiceIndex = $(this).parents(".upload-box").index();
			if ($(".tpl-table-images-content-i").eq(choiceIndex).hasClass("upload-js-opacity") == false) {
				$(".upload-table-images-content").eq(choiceIndex).addClass("upload-hover-img");
				$(".tpl-table-images-content-i").eq(choiceIndex).addClass("upload-js-opacity");
				$(".upload-dui").eq(choiceIndex).show();
				$(this).parent().prev().attr('name', 'dir');
				$(this).children("a").html('<span class="am-icon-check"></span>&nbsp;取&nbsp;消');
			} else {
				$(".upload-table-images-content").eq(choiceIndex).removeClass("upload-hover-img");
				$(".tpl-table-images-content-i").eq(choiceIndex).removeClass("upload-js-opacity");
				$(this).children("a").html('<span class="am-icon-check"></span>&nbsp;选&nbsp;择');
				$(".upload-dui").eq(choiceIndex).hide();
				$(this).parent().prev().removeAttr('name');
			}
		})
		// 单个删除
		$(".upload-trash").on("click", function() {
			var txt = $(this).parents().is(".upload-box") ? "图片" : "文件";
			return confirm('确定要删除该' + txt + '吗？');

		})
		$('.ngro-Jclick-shanchubi').on("click", function() {
			var txt = $(this).prev().val();
			var msg = '目录'
			if (txt == "image") {
				msg = "图片";
			}
			if (txt == "file") {
				msg = "文件";
			}
			return confirm('确定要删除该' + msg + '内容吗？');
		})
		// 列表视图单个选中
		$("ty-checkbox").click(function() {
			if ($('this').prop('checked')) {
				$(this).next().attr('name', 'dir');
			} else {
				$(this).next().removeAttr('name');
			}
		})
		var a = 1;
		$('.add').click(function(event) {
			if (a) {
				$("input[type='checkbox']").prop('checked', true);
				if ($('.am-select')) {
					$('.am-select').text('取消');
					$(".ty-checkbox2").attr('name', 'dir');
					$(".upload-table-images-content").addClass("upload-hover-img");
					$(".tpl-table-images-content-i").addClass("upload-js-opacity");
					$(".upload-check>a").html('<span class="am-icon-check"></span>&nbsp;取&nbsp;消');
					$(".upload-dui").show();
				}
			} else {
				$("input[type='checkbox']").prop('checked', false);
				if ($('.am-select')) {
					$('.am-select').text('全选');
					$(".ty-checkbox2").removeAttr('name');
					$(".upload-table-images-content").removeClass("upload-hover-img");
					$(".tpl-table-images-content-i").removeClass("upload-js-opacity");
					$(".upload-check>a").html('<span class="am-icon-check"></span>&nbsp;选&nbsp;择');
					$(".upload-dui").hide();
				}
			}
			a = !a
			event.stopPropagation();
		})
		// 全选删除
		$("div#select-handle a.am-btn.am-btn-default.am-btn-danger").on("click", function() {
			var del_bool = confirm('确定要进行删除操作吗？');
			if (del_bool) {
				$("#ty-form").submit();
			}
		})
		// 模态框
		$(".upload-search1").on("click", function() {
			$(".modal-frame").show().css("zIndex", "1100");
			var oThis = $(this);
			fis(oThis);
		})
		$(".return-btn").on("click", function() {
			$(".modal-frame").hide().css("zIndex", "-1");
		})
		// 封装查看事件函数
		function fis(oThis) {
			// 获取图片,图片名称,图片大小,创建时间
			var modalIndex = $(oThis).parents(".upload-table-images").index();
			var modalImg = $("a.tpl-table-images-content-i>img").eq(modalIndex).attr("src");
			$(".modal-frame-img>li>img").attr("src", modalImg);
			var modalName = $(".upload-name").eq(modalIndex).text();
			$(".am-pureview-title").text(modalName);
			var modalTime = $(".upload-time").eq(modalIndex).text();
			$(".am-pureview-time").text(modalTime);
			var modalSize = $(".upload-size").eq(modalIndex).text();
			$(".am-pureview-size").text(modalSize);
			// 判断图片大小是否大于浏览器宽高
			var oImg = $(".upload-img").get(modalIndex);
			if (oImg.naturalWidth > $(document).width() || oImg.naturalHenght > $(document).height()) {
				$(".modal-frame-img>li>img").addClass("modal-img");
			} else {
				$(".modal-frame-img>li>img").removeClass("modal-img");
			}
		}
		// 判断有几张图片,大有1则显示左右滑动按钮
		if ($(".am-pureview-total").text() > 1) {
			$(".am-pureview-direction").show();
		} else {
			$(".am-pureview-direction").hide();
		}
	})
	</script>
</body>
</html>