<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="list.aspx.cs" Inherits="wjdhcms_SAAS.module.category.list" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>栏目管理</title>

    <!-- start: CSS file-->
    <!-- Vendor CSS-->
    <link href="../static/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../static/vendor/skycons/css/skycons.css" rel="stylesheet" />
    <link href="../static/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" />

    <!-- Plugins CSS-->
    <link href="../static/plugins/bootkit/css/bootkit.css" rel="stylesheet" />     
    
    
    <!-- Page CSS -->   
    <link href="../static/css/style.css" rel="stylesheet" />
    <link href="../static/css/add-ons.min.css" rel="stylesheet" />
    <!-- end: CSS file--> 
      
    
    <!-- Head Libs -->
    <script src="../static/plugins/modernizr/js/modernizr.js"></script>
    
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="../static/js/html5shiv.min.js"></script>
      <script src="../static/js/respond.min.js"></script>
    <![endif]-->    
    

</head>

<body class="mainbody">
  <div class="container-fluid">
    <div class="row"> 
            <div class="col-lg-12">
              <div class="panel">
                <div class="panel-heading bk-bg-primary">
                  <div class="list-articles">
                    <a href="edit.aspx?action=add" class="release btn btn-default"><i class="fa fa-pencil-square-o"></i>新增栏目</a>
                  </div>
                </div>
                <div class="panel-body">
                  <div class="table-responsive">
                    <table class="table table-bordered table-striped table-condensed table-hover article-list">
                      <thead>
                        <tr>
                          <th width="4%">ID</th>
                          <th>类别名称</th>
                          <th width="12%">栏目类型</th>
                          <th width="16%">访问地址</th> 
                          <th width="4%">排序</th>
                          <th width="10%">操作</th>                                          
                        </tr>
                      </thead>   
                      <tbody>


                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
          </div>  
  </div>

    <!-- start: JavaScript-->
    
    <!-- Vendor JS-->       
    <script src="../static/vendor/js/jquery-2.1.1.min.js"></script>
    <script src="../static/vendor/js/jquery-migrate-1.2.1.min.js"></script>
    <script src="../static/vendor/bootstrap/js/bootstrap.min.js"></script>
    <script src="../static/vendor/skycons/js/skycons.js"></script> 
    
    <!-- Plugins JS-->  
    
    <!-- Theme JS -->   


    <!-- Pages JS -->

    <script src="../static/js/ajax.js"></script>
    <!-- end: JavaScript-->

    <script>
        $(function () {
            get_json('../../api/category.ashx?action=list', function (data) {
                var list = '';
                for (var i = 0; i < data.data.length; i++) {
                    list += ''
                      + '<tr id="l' + data.data[i].id + '">'
                        + '<td>'
                          + '<div class="checkbox-custom checkbox-inline">'
                            + '<input type="checkbox" id="inline-checkbox' + data.data[i].id + '" value="">'
                            + '<label for="inline-checkbox' + data.data[i].id + '">' + data.data[i].id + '</label>'
                          + '</div>'
                        + '</td>'
                        + '<td><i class="fa fa-folder-open-o" aria-hidden="true"></i> ' + data.data[i].catname + '</td>'
                        + '<td>' + data.data[i].model_name + '</td>'
                        + '<td><a href="' + data.data[i].url + '" target="_blank">' + data.data[i].url + '</a></td>'
                        + '<td><input type="text" name="text-input" class="form-control listorder" value="' + data.data[i].listorder + '"></td>'
                        + '<td>'
                          + '<a class="btn btn-success" href="edit.aspx?action=edit&id=' + data.data[i].id + '&cid=' + data.data[i].partenid + '" data-toggle="tooltip" title="编辑">'
                            + '<i class="fa fa-edit"></i>'
                          + '</a>'
                          + '<button class="btn btn-info delete" onClick="Delete(\'../../api/category.ashx?action=del&id=' + data.data[i].id + '\')" data-toggle="tooltip" title="删除">'
                            + '<i class="fa fa-trash-o"></i>'
                          + '</button>'
                        + '</td>'
                      + '</tr>';
                    if (data.data[i].list.length != 0) {
                        for (var k = 0; k < data.data[i].list.length; k++) {
                            list += ''
                              + '<tr id="l' + data.data[i].list[k].id + '">'
                                + '<td>'
                                  + '<div class="checkbox-custom checkbox-inline">'
                                    + '<input type="checkbox" id="inline-checkbox' + data.data[i].list[k].id + '" value="">'
                                    + '<label for="inline-checkbox' + data.data[i].list[k].id + '">' + data.data[i].list[k].id + '</label>'
                                  + '</div>'
                                + '</td>'
                                + '<td><span class="folder-line bk-margin-left-10"></span><i class="fa fa-folder-open-o" aria-hidden="true"></i> ' + data.data[i].list[k].catname + '</td>'
                                + '<td>' + data.data[i].list[k].model_name + '</td>'
                                + '<td><a href="' + data.data[i].list[k].url + '"  target="_blank">' + data.data[i].list[k].url + '</a></td>'
                                + '<td><input type="text" name="text-input" class="form-control listorder" value="' + data.data[i].list[k].listorder + '"></td>'
                                + '<td>'
                                  + '<a class="btn btn-success" href="edit.aspx?action=edit&id=' + data.data[i].list[k].id + '&cid=' + data.data[i].list[k].partenid + '" data-toggle="tooltip" title="编辑">'
                                    + '<i class="fa fa-edit"></i>'
                                  + '</a>'
                                  + '<button class="btn btn-info delete" onClick="Delete(\'../../api/category.ashx?action=del&id=' + data.data[i].list[k].id + '\')" data-toggle="tooltip" title="删除">'
                                    + '<i class="fa fa-trash-o"></i>'
                                  + '</button>'
                                + '</td>'
                              + '</tr>';
                            if (data.data[i].list[k].list.length != 0) {
                                for (var l = 0; l < data.data[i].list[k].list.length; l++) {
                                    list += ''
                                      + '<tr id="l' + data.data[i].list[k].list[l].id + '">'
                                        + '<td>'
                                          + '<div class="checkbox-custom checkbox-inline">'
                                            + '<input type="checkbox" id="inline-checkbox' + data.data[i].list[k].list[l].id + '" value="">'
                                            + '<label for="inline-checkbox' + data.data[i].list[k].list[l].id + '">' + data.data[i].list[k].list[l].id + '</label>'
                                          + '</div>'
                                        + '</td>'
                                        + '<td><span class="folder-line bk-margin-left-30"></span><i class="fa fa-folder-open-o" aria-hidden="true"></i> ' + data.data[i].list[k].list[l].catname + '</td>'
                                        + '<td>' + data.data[i].list[k].list[l].model_name + '</td>'
                                        + '<td><a href="' + data.data[i].list[k].list[l].url + '"  target="_blank">' + data.data[i].list[k].list[l].url + '</a></td>'
                                        + '<td><input type="text" name="text-input" class="form-control listorder" value="' + data.data[i].list[k].list[l].listorder + '"></td>'
                                        + '<td>'
                                          + '<a class="btn btn-success" href="edit.aspx?action=edit&id=' + data.data[i].list[k].list[l].id + '&cid=' + data.data[i].list[k].list[l].partenid + '" data-toggle="tooltip" title="编辑">'
                                            + '<i class="fa fa-edit"></i>'
                                          + '</a>'
                                          + '<button class="btn btn-info delete" onClick="Delete(\'../../api/category.ashx?action=del&id=' + data.data[i].list[k].list[l].id + '\')" data-toggle="tooltip" title="删除">'
                                            + '<i class="fa fa-trash-o"></i>'
                                          + '</button>'
                                        + '</td>'
                                      + '</tr>';
                                }
                            }
                        }
                    }
                }
                $('.table tbody').html(list);
                $("[data-toggle='tooltip']").tooltip();
            });
            //更改排序
            $('.table').on('input propertychange', '.listorder', function () {
                var that = $(this);
                var id = that.parents('tr').attr('id').replace('l', '');
                var val = that.val();
                val = val.replace(/[^0-9-]+/, '');
                that.val(val);
                if (val != '') {
                    $.post('../../api/category.ashx?action=listorder&id=' + id + '&value=' + val, function (data, textStatus, xhr) {
                        console.log(val)
                    }).error(function () {
                        console.log('cauowu')
                    });
                }
            });
        })


    </script>
    
</body>

</html>
