<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-header">公告管理</div>
          <div class="layui-card-body" pad15>
              <!-- 表单 -->      
              <div style="padding-bottom: 10px;">
                <a href="#J_view" class="layui-btn J_popup" title="添加公告"><i class="layui-icon layui-icon-add-circle"></i>添加</a>
                <a href="wendasns/publish/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
              </div>      
            
                      <table id="J_table_list" lay-filter="J_table_list"></table>
        
          </div>
        </div>
      </div>
    </div>
  </div>
  <script type="text/html" id="J_table_istop">
    {{# if(d.istop == 1) {}}
        <span style="color: #FF5722;">是</span>
     {{# } else {}}
        <span style="color: #5FB878;">否</span>
    {{# }}}
    
  </script>
  <script type="text/html" id="J_table_tool">
    <a href="#J_view" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="popup" title="编辑公告"><i class="layui-icon layui-icon-edit"></i>编辑</a>
    <a href="wendasns/publish/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
  </script>

  <script>
;!function(){
      var $ = layui.$
      ,table =layui.table
      ,form = layui.form;
      form.render();
  
      table.render({
      elem: '#J_table_list'
      ,height: 'auto'
      ,url: '{:url('wendasns/publish/list')}' //数据接口
      ,page: true //开启分页
      ,limit: 16
      ,cols: [[ //表头
      {type:'checkbox'}
        ,{field:'title',title:'标题',minWidth:90}
        ,{field:'content',title:'内容',minWidth:90}
        ,{field:'views',title:'访问量',width:100,align:'center'}
        ,{field:'istop',title:'置顶',width:60,align:'center',toolbar: '#J_table_istop'}
        ,{field:'create_time',title:'发布时间',width:180,align:'center'}
        ,{field:'status',title:'操作',width:150,align:'center',toolbar: '#J_table_tool'}
  
      ]]
      ,text: {
         none: '暂无数据！'
      }
  
    });

  }();
layui.data.done = function(){
    layui.colorpicker.render({
      elem: '#colorpicker-select'
      ,color: '#1c97f5'
      ,done: function(color){
        layui.$('#colorpicker-form-input').val(color);
      }
    });
    

	var index = layui.layedit.build('J_textarea');
	layui.$('#J_textarea').attr('data-id',index);
};
</script>

<script type="text/html" id="J_view" lay-done="layui.data.done()">
    <form class="layui-form" action="{:url('wendasns/publish/edit')}" method="post">
      <input type="hidden" name="id" value="{{d.id||0}}">
      
              <div class="layui-form-item">
                <label class="layui-form-label">标题</label>
                <div class="layui-input-block">
                  <input type="text" name="title" value="{{d.title||''}}" lay-verify="required" class="layui-input">
                </div>
              </div>
              
              <div class="layui-form-item" style="width: 626px;height: 325px;">
                <label class="layui-form-label">内容</label>
                <div class="layui-input-block">
                  <textarea id="J_textarea" name="content" style="display: none;" data-id="" lay-verify="content">{{d.content||''}}</textarea>
                </div>
              </div>
  
              <div class="layui-form-item">
                <label class="layui-form-label">标题颜色</label>
                <div class="layui-input-inline">
                  <input type="text" name="color" value="{{d.color||''}}" placeholder="请选择颜色" class="layui-input" id="colorpicker-form-input">
                </div>
                <div class="layui-inline" style="left: -11px;">
                  <div id="colorpicker-select"></div>
                </div>
              </div>

              <div class="layui-form-item">
                <label class="layui-form-label">访问量</label>
                <div class="layui-input-inline">
                  <input type="text" name="views" value="{{d.views||0}}" class="layui-input">
                </div>
              </div>
              
              <div class="layui-form-item">
                <label class="layui-form-label">置顶</label>
                <div class="layui-input-block">
                  <input type="radio" name="istop" value="1" title="是" {{ typeof d.istop === 'undefined' ? '' : (d.istop==1 ? 'checked':'')}}><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>是</div></div>
                  <input type="radio" name="istop" value="0" title="否" {{ typeof d.istop === 'undefined' ? 'checked' : (d.istop==0 ? 'checked':'')}}><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>否</div></div>
                  
                </div>
              </div>
              
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn"><i class="layui-icon layui-icon-ok-circle"></i>提交</button>
                </div>
              </div>
            </form>
  </script>