<?php
if (!defined('ROOT'))
	exit ;
?>
<!DOCTYPE html>
<html>

	<head>
		<title>回收站</title>
		<meta name="description" content="">
		<meta name="keywords" content="">
		<?php
		include 'Inc_files.php';
		?>
		<style type="text/css">
		#list_folder{ color: #333;}
		#list_folder li{ padding-bottom: 10px; cursor: default; height: 135px;}
		#list_folder .iconfont{color: #FFD215; font-size: 18px;}
		#list_folder input{ margin: -10px auto 0; border: none;}
		#list_folder .about{ color: #999;}
		#list_folder th{font-size: 14px; font-weight: 400; border-top: none;}
		#list_folder.am-table-hover>tbody>tr:hover>td,#list_folder.am-table-hover>tbody>tr:hover>th{background:#F6FAFF;}
		#list_folder .tools{display: none;}
		#list_folder tr:hover .tools{ display: block;}
		#list_folder .tools .iconfont{ color: #3B8CFF;cursor:pointer}
		#list_folder .notice{display:none; color:#999}
		#list_folder tr:hover .notice{ display: block;}
		#list_folder th,#list_folder td{ height: 45px;}
		
		.folder_current_handle{ cursor:pointer;}
		
		
		#folder .nofolder{ text-align: center;}
		#folder .nofolder .iconfont{ font-size: 50px; vertical-align:middle;}
		.ng_hide{ display:none;}
		
		#upload{width: 600px;height: auto;border: 1px solid #efefef;position: fixed;bottom: 0;right: 0;z-index: 99999;background: #FFF;padding: 10px 0; display: none;}
		#upload dl{margin: 0;}
		#upload dl dt{line-height: 40px;font-size: 14px;padding: 0 10px;}
		#upload dl dt .iconfont{float: right;width: 40px;height: 40px;text-align: center;}
		#upload dl dt .huifu{display: none;}
		#upload dl dd{line-height: 30px;font-size: 12px;color: #FFF;background: #5FA5FB;padding: 0 10px;}
		#upload ul{padding: 0;}
		#upload ul li{padding: 0 5px;border-bottom: 1px solid #efefef ;position: relative;height: 50px; line-height:50px;width: 100%; overflow: hidden; font-size: 14px;}
		#upload ul li span{display: inline-block;color: #52525A;font-size: 12px;}
		#upload ul li .icon{width: 60px;}
		#upload ul li .icon .iconfont{font-size: 30px;color: #FF7742;}
		#upload ul li .name{width: 200px;}
		#upload ul li .size{width: 120px;}
		#upload ul li .wja{width: 120px;color: #5E9EFF;}
		#upload ul li .file{z-index: 999999;width: 100%;position: absolute;}
		#upload ul li .jindu{background: rgba(226,237,255,0.5);position: absolute;left: 0;top: 0;height: 100%;}
		</style>
	</head>

	<body data-base64 >
		<div class="am-g tpl-g">
			<?php include 'Inc_head.php'
			?>
			<!-- 侧边导航栏 -->
			<?php
			include 'Inc_left.php';
			?>
			<!-- 内容区域 -->
			<div class="tpl-content-wrapper">
				<div class="row-content am-cf" id="folder">
					<div class="row">
						<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
							<div class="widget am-cf">
								<div class="widget-head am-cf">
									<div class="widget-title  am-cf">
										<div class="am-u-sm-6">
											<a href="javascript:;" id="folder_root">回收站</a> <span ng-if="folder_current_name_str"><span ng-bind-html="folder_current_name_str|html"></span></span>
										</div>
										
										<div class="am-u-sm-6" style="text-align: right;">
		                                	<button type="button" class="am-btn am-btn-sm am-btn-secondary btn_file_huifu"><i class="iconfont">&#xe609;</i> 批量恢复</button>
		                                	<button type="button" class="am-btn am-btn-sm am-btn-warning btn_delete_checked"><i class="iconfont">&#xe609;</i> 批量删除</button> 
		                                	<button type="button" class="am-btn am-btn-sm am-btn-warning btn_delete_all"><i class="iconfont">&#xe609;</i> 清空回收站</button> 
		                                </div>
									</div>
								</div>
								<div class="widget-body  ng_hide">
									<form id="list">
										<table class="am-table am-table-hover"  id="list_folder">
											<colgroup>
												<col width="40" />
												<col />
												<col width="150" />
												<col width="150" />
												<col width="100" />
												<col width="150" />
											</colgroup>
											<thead>
												<tr>
													<th class="tc"><input type="checkbox" id="check_all" /></th>
													<th class="tl">名称 </th>
													<th class="tc"></th>
													<th class="tr"></th>
													<th class="tc">大小</th>
													<th class="tc">修改日期</th>
												</tr>
											</thead>
											<tbody>
												<tr class="file" ng-repeat="v in list_file" data-pk1='{{v.pk1}}' data-pk2='{{v.pk2}}' data-pk3='{{v.pk3}}' data-pk4='{{v.pk4}}' data-name='{{v.name}}' data-file_key='{{v.file_key}}'  data-about='{{v.about}}' data-price='{{v.price}}' data-key='{{v.key}}' data-type='{{v.type}}'>
													<td class="tc"><input type="checkbox" name="pk[]" value="{{v.pk1}},{{v.pk2}},{{v.pk3}},{{v.pk4}}" /></td>
													<td>
														<img class="icon" src="{{v.icon}}" onerror="<?php echo S('STATIC');?>/static/public/images/filetype/reg.gif" />
														{{v.name}} <span class="about">{{v.about}}</span>
													</td>
													<td class="tc"></td>
													<td class="tr">
														<span class="tools"><i class="iconfont btn_file_del" title="删除">&#xe609;</i> <i class="iconfont btn_file_huifu" title="还原">&#xe6c0;</i></span>
													</td>
													<td class="tc">
														{{v.size|filesize}}
													</td>
													<td class="tr">
														{{v.pk4|date:'Y-m-d H:i'}}
													</td>
												</tr>
											</tbody>
										</table>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="am-modal am-modal-prompt" tabindex="-1" id="modal_erjimima">
			<div class="am-modal-dialog">
				<div class="am-modal-hd">二级密码</div>
			    <div class="am-modal-bd">
			      	<input type="text" class="am-modal-prompt-input">
			    </div>
			    <div class="am-modal-footer">
			      	<span class="am-modal-btn" data-am-modal-cancel>取消</span>
			      	<span class="am-modal-btn" data-am-modal-confirm>提交</span>
			    </div>
			</div>
		</div>
		<?php
		include 'Inc_files_boot.php';
		?>
		<link rel="stylesheet" href="/static/member/css/smartMenu.css">
		<script src="/static/member/js/jquery-smartMenu.js" type="text/javascript"></script>
		<script src="<?php echo C('TMPL_PARSE_STRING.__TPL__'); ?>/assets/js/theme.js"></script>
		<script type="text/javascript">
			jQuery(document).ready(function($){ 
				scope.upload_status='正在上传';
				scope.folder_current_name=[];
				scope.folder_current_id=[];
				scope.folder_current_name_str='';
				scope.folder_current='';
				scope.$apply();
				folder();
			});
			/***********操作事件开始**********/
			//多选
			jQuery(document).on('click','#check_all',function () {
				var the=jQuery(this);
				if (the.prop('checked')) {
					jQuery("[name='pk[]']").prop('checked',true);
				}else{
					jQuery("[name='pk[]']").prop('checked',false);
				}
			});
			//恢复文件
			jQuery(document).on('click','.btn_file_huifu',function () {
			    var the=jQuery(this);
			    jQuery('#modal_erjimima').modal({
			    	relatedTarget: this,
			      	onconfirm: function(e) {
			        	jQuery.ajax({
			        		url:"/api/check_password2",
			        	    data:{
			        	    	password:e.data
			        	    },
			        	    dataType: "json",
			        	    type: "post",
			        	    timeout: 10000,
			        	    success: function(data) {
			        	    	if (data.status!=1) {
			        	    		wd_alert({
			        	    			msg:data.info,
			        	    			background:'#f00'
			        	    		})
			        	    	}else{
			        	    		the.closest('tr').find('[name="pk[]"]').prop('checked',true);
								    jQuery.ajax({
								    	url:"/recycle/huifu",
								        data:jQuery("#list").serializeArray(),
								        dataType: "json",
								        type: "post",
								        timeout: 10000,
								        success: function(data) {
								           console.log(data); 
								        },
								        error: function() {
								            mui.toast("网络连接超时");
								        }
								    });
								    jQuery("[name='pk[]']").each(function (index) {
					       				if (jQuery(this).prop('checked')) {
					       					jQuery(this).closest('tr').remove();
					       				}
					       			}); 
			        	    	}
			        	    },
			        	    error: function() {
			        	        mui.toast("网络连接超时");
			        	    }
			        	});
			      	},
			      	onCancel: function(e) {
			      	}
			    }).on('closed.modal.amui', function() {
					jQuery(this).removeData('amui.modal');
				});
			})
			//清空回收站
			jQuery(document).on('click','.btn_delete_all',function () {
				jQuery('#modal_erjimima').modal({
			    	relatedTarget: this,
			      	onconfirm: function(e) {
			        	jQuery.ajax({
			        		url:"/api/check_password2",
			        	    data:{
			        	    	password:e.data
			        	    },
			        	    dataType: "json",
			        	    type: "post",
			        	    timeout: 10000,
			        	    success: function(data) {
			        	    	if (data.status!=1) {
			        	    		wd_alert({
			        	    			msg:data.info,
			        	    			background:'#f00'
			        	    		})
			        	    	}else{
			        	    		jQuery.ajax({
								    	url:"<?php echo U('File/del_all')?>",
								        data:{},
								        dataType: "json",
								        type: "post",
								        timeout: 10000,
								        success: function(data) {
								           folder();
								        },
								        error: function() {
								            mui.toast("网络连接超时");
								        }
								    }); 
			        	    	}
			        	    },
			        	    error: function() {
			        	        mui.toast("网络连接超时");
			        	    }
			        	});
			      	},
			      	onCancel: function(e) {
			      	}
			    }).on('closed.modal.amui', function() {
					jQuery(this).removeData('amui.modal');
				});
			})
			//批量删除
			jQuery(document).on('click','.btn_delete_checked',function () {
				jQuery('#modal_erjimima').modal({
			    	relatedTarget: this,
			      	onconfirm: function(e) {
			        	jQuery.ajax({
			        		url:"/api/check_password2",
			        	    data:{
			        	    	password:e.data
			        	    },
			        	    dataType: "json",
			        	    type: "post",
			        	    timeout: 10000,
			        	    success: function(data) {
			        	    	if (data.status!=1) {
			        	    		wd_alert({
			        	    			msg:data.info,
			        	    			background:'#f00'
			        	    		})
			        	    	}else{
			        	    		jQuery.ajax({
								    	url:"<?php echo U('File/del_more')?>",
								        data:jQuery("#list").serializeArray(),
								        dataType: "json",
								        type: "post",
								        timeout: 10000,
								        success: function(data) {
								       		if (data.status==1) {
								       		}
								        },
								        error: function() {
								            mui.toast("网络连接超时");
								        }
								    });   
								    jQuery("[name='pk[]']").each(function (index) {
					       				if (jQuery(this).prop('checked')) {
					       					jQuery(this).closest('tr').remove();
					       				}
					       			}); 
			        	    	}
			        	    },
			        	    error: function() {
			        	        mui.toast("网络连接超时");
			        	    }
			        	});
			      	},
			      	onCancel: function(e) {
			      	}
			    }).on('closed.modal.amui', function() {
					jQuery(this).removeData('amui.modal');
				});
			});
			
			//文件删除
			jQuery(document).on('click','.btn_file_del',function () {
			    var the=jQuery(this);
			    jQuery('#modal_erjimima').modal({
			    	relatedTarget: this,
			      	onconfirm: function(e) {
			        	jQuery.ajax({
			        		url:"/api/check_password2",
			        	    data:{
			        	    	password:e.data
			        	    },
			        	    dataType: "json",
			        	    type: "post",
			        	    timeout: 10000,
			        	    success: function(data) {
			        	    	if (data.status!=1) {
			        	    		wd_alert({
			        	    			msg:data.info,
			        	    			background:'#f00'
			        	    		})
			        	    	}else{
			        	    		the.closest('tr').remove();
								    file_del({
								    	pk2:the.closest('tr').data('pk2'),
								    	pk3:the.closest('tr').data('pk3'),
								    	pk4:the.closest('tr').data('pk4'),
								    	file_key:the.closest('tr').data('file_key')
								    }); 
			        	    	}
			        	    },
			        	    error: function() {
			        	        mui.toast("网络连接超时");
			        	    }
			        	});
			      	},
			      	onCancel: function(e) {
			      	}
			    }).on('closed.modal.amui', function() {
					jQuery(this).removeData('amui.modal');
				});
			})
			
			/***********操作事件结束**********/
			
			function folder(){
				var opts=typeof(arguments[0])!="undefined"?arguments[0]:{};
				//读文件夹
				jQuery.ajax({
					url:'/recycle/files',
				    data:{},
				    dataType: "json",
				    type: "post",
				    timeout: 10000,
				    success: function(data) {
				    	scope.list_file=data;
				    	scope.$apply();
				    },
				    error: function() {
				        mui.toast("网络连接超时");
				    }
				});
			}
			
			//文件删除
			function file_del(data){
				jQuery.ajax({
					url: "/file/del",
					data: data,
					dataType: "json",
					type: "post",
					timeout: 10000,
					success: function(data) {
					},
					error: function() {
						mui.toast("网络连接超时");
					}
				});
			}
			
			//文件夹删除
			function folder_del(){
				var opts=typeof(arguments[0])!="undefined"?arguments[0]:{};
				jQuery.ajax({
					url: "/file/del_folder",
					data: opts.data,
					dataType: "json",
					type: "post",
					timeout: 10000,
					success: function(data) {
						if (typeof(opts.callback)=="function") {
							opts.callback();
						}else{
							folder({
								reid:scope.folder_current,
								callback:function () {
									scope.$apply();
								}
							});
						}
						
					},
					error: function() {
						mui.toast("网络连接超时");
					}
				});
			}
			
			
			myAngular.filter("filesize", function() {
				return function(x) {
					if (x<1048576) {
						x=Math.floor(x/1024)+'KB';
					}else if(x<1073741824){
						x=Math.floor(x/1048576)+'MB';
					}else if(x<1073741824){
						x=Math.floor(x/1099511627776*100)/100+'GB';
					}
					return x;
				}
			});
			
		</script>
		
	</body>

</html>