  <title>回收站</title>

  <div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
      <a lay-href="">主页</a>
      <a><cite>问答管理</cite></a>
      <a><cite>回收站</cite></a>
    </div>
  </div>
  
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">

      <div class="layui-card-body">
          <div class="layui-tab layui-tab-brief" lay-filter="J_tabLi">
            <ul class="layui-tab-title">
              <li class="layui-this" lay-id="question">问题回收站</li>
              <li lay-id="answer">回答回收站</li>
              <li lay-id="article">文章回收站</li>
              <li lay-id="comment">评论回收站</li>
            </ul>
          </div>
      </div>
      
      <div class="layui-card-body">
      <form id="J_ajaxForm" class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="J_ajaxForm">
      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label">举报原因</label>
          <div class="layui-input-block">
            <input type="text" name="reason" class="layui-input">
          </div>
        </div>
        
        <div class="layui-inline">
          <input type="button" class="layui-btn" lay-submit lay-filter="btn_submit" value="添加">
          <button type="button" class="layui-btn btn_action" data-type="del">删除</button>
        </div>
      </form>
      </div>
      
      
          <div class="layui-card-body">
        <div style="padding-bottom: 10px;">
          <a href="wendasns/recycler/restore" class="layui-btn J_req" title="确定要还原吗？">还原</a>
          <a href="wendasns/recycler/delete" class="layui-btn J_req" title="确定要删除吗？">删除</a>
        </div>
        
            <table class="layui-hide" id="J_table_list" lay-filter="J_table_list"></table>
          </div>
          
        </div>
      </div>
    </div>
  </div>

<script type="text/html" id="J_a_tpl">
  <a style="color:#3a7ead !important;" href="" target="_blank">{{d.source_id}}</a>
</script>

<script type="text/html" id="J_status_tpl">
  {{# if(d.status==1){ }}
  <span style="color: #5FB878;">已处理</span>
  {{# }else{ }}
  <span style="color: #FFB800;">待处理</span>
  {{# } }}
</script>

<script type="text/html" id="J_type_tpl">
  {{# if(d.type=='question'){ }}
  <span>问题</span>
  {{# }else if(d.type=='answer'){ }}
  <span>回答</span>
  {{# }else if(d.type=='article'){ }}
  <span>文章</span>
  {{# }else{ }}
  <span>评论</span>
  {{# } }}
</script>

<script type="text/html" id="J_table_tool">
  <a href="wendasns/recycler/restore" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="req" title="确定要还原吗？">还原</a>
  <a href="wendasns/recycler/delete" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？">删除</a>
</script>

<script>
;!function(){
    var $ = layui.$
    ,admin = layui.admin
    ,view = layui.view
    ,form = layui.form
    ,element = layui.element
    ,router = layui.router()
    ,table = layui.table;

  /* Hash地址的定位 */
  layid = router.hash.replace(/^#layid=/, '');
  layid && element.tabChange('J_tabLi', layid);
  
  element.on('tab(J_tabLi)', function(elem){
    location.hash = '/'+ router.path.join('/') + '#layid=' + $(this).attr('lay-id');
  });
  
    form.render('select');
    
    table.render({
      elem: '#J_table_list'
      ,url: '{:url('wendasns/recycler/list')}?type=' + layid
      ,cols: [[
        {type:'checkbox'}
        ,{field:'title', title:'标题', minWidth:120}
        ,{field:'username', title:'作者', width:100,align:'center'}
        ,{field:'create_time', title:'发帖时间', width:160}
        ,{field:'update_time', title:'删除时间', width:160}
        ,{field:'username', title:'删除人', width:150}
        ,{field:'reason', title:'删除理由',width:120}
        ,{title:'操作',width:120,align:'center',toolbar:'#J_table_tool'}
      ]]
  ,page: true
    ,limit: 20
    ,height: 'auto'
     ,text: '对不起，加载出现异常！'
    })

  form.on('select(J_select)', function(obj){
		var data = table.checkStatus('J_table_list'),post = [];
  	  	$.each(data.data,function(){
  	  		post.push(this.id);
        });
			if(post.length === 0){
				return layer.msg('\u8bf7\u9009\u62e9\u6570\u636e');
			}
		admin.req({
			url: '{:url('wendasns/report/chuli')}'
			,type: 'post'
			,data: {status:obj.value,id:post}
			,done: function(res){
				
			}
		});
  });


  $(document).on('click', 'a.J_reasonSee', function(){
    var id = $(this).data('id');

  	  	  admin.popup({
      	  title: '举报原因/举报人'
          ,area: ['700px', '500px']
          ,id: 'LAY-popup-table'
          ,success: function(layero, index){
        	view(this.id).render('wendasns/report/reason', {id:id}).done(function(){
              
          });
        }
      	  });
      
  });
  
}();
</script>