<%@ Page Title="" Language="C#" MasterPageFile="~/bps/bps.Master" AutoEventWireup="true" CodeBehind="quote_list.aspx.cs" Inherits="bps.bps.quote_list" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   

    

                   
      <link href="../javascript/datatables/datatables.css" rel="stylesheet" />
      <script src="../javascript/datatables/datatables.min.js"></script>


      <div class="panel panel-default">
  <div class="panel-heading">报价单搜索</div>
  <div class="panel-body">

    <div class="form-inline">
  
         
         报价单号 
        <input id="quotecode" type="text" class="form-control"   style="width:100px;" />


         成品编号 
        <input id="productcode" type="text" class="form-control"   style="width:100px;" />

         成品名称 
        <input id="productname"   type="text" class="form-control"   style="width:180px;" />

   
        客户编号 
        <input id="customercode"   type="text" class="form-control"   style="width:100px;" />

        客户名称 
        <input id="customername"   type="text" class="form-control"   style="width:180px;" />
 

        
     审批状态     <asp:DropDownList runat="server" ID="auditstatus" ClientIDMode="Static" 
         CssClass="form-control" Width="120"    >
         <asp:ListItem Text="==不限==" Value=""></asp:ListItem> 
         <asp:ListItem Text="同意" Value="1"></asp:ListItem>
         <asp:ListItem Text="审批中" Value="0"></asp:ListItem>
         <asp:ListItem Text="拒绝" Value="-1"></asp:ListItem>
 </asp:DropDownList>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;&nbsp;
           <a href="quote_add.aspx" class="btn btn-danger " >添加报价单  </a>  

        
    
    </div>

      </div>
        </div>

    






    

    <table   class="table  table-hover  "  id="tbl_pro"  >
        <thead  >
            <tr>
                  <th width="40px">ID</th>
                  <th  width="100px">报价单号</th>

                  <th  width="100px">成品编号</th>
                  <th width="150px">成品名称</th>
                  
                  <th width="100px">客户编号</th>
                  <th width="250px">客户名称</th>
                  <th width="60px">版本</th>
                 
                  <th width="100px">报价日期</th>
                    <th width="100px">审核人</th>
                  <th width="100px">确认人</th>
                 <th width="180px">备注</th>
                 <th width="90px">状态</th>
                
            </tr>
        </thead>
    </table>

     



    
    <script>


        function InitTable() {

            var table = $('#tbl_pro').DataTable(); 

            if ($.fn.dataTable.isDataTable('#tbl_pro')) {
                table.destroy();
            }


            $("#quotecode").keyup(function () {
                table.ajax.reload();
            });


            $("#productcode").keyup(function () {
                table.ajax.reload();
            });

            $("#productname").keyup(function () {
                table.ajax.reload();
            });

            $("#customercode").keyup(function () {
                table.ajax.reload();
            });

            $("#customername").keyup(function () {
                table.ajax.reload();
            });

            $("#auditstatus").change(function () {
                table.ajax.reload();
            });


            /*
                     $('#tbl_pro').unbind();
                     $('#tbl_pro').on('click', 'tr', function () { 
                         $(this).toggleClass('selected');
                     });
            */

            //提示信息
            var lang = {
                "sProcessing": "处理中...",
                "sLengthMenu": "每页 _MENU_ 项",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "<b>&nbsp;&nbsp; 每页 20 条 当前显示第 _PAGE_页 共 _PAGES_ 页，共 _TOTAL_ 条</b> ",
                "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页",
                    "sJump": "跳转"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            };




            //初始化表格
            table = $("#tbl_pro").dataTable({

                language: lang,  //提示信息
                autoWidth: false,  //禁用自动调整列宽 
                processing: true,  //隐藏加载提示,自行处理
                serverSide: true,  //启用服务器端分页
                searching: false,  //禁用原生搜索
                orderMulti: false,  //启用多列排序
                ordering: true,//禁止排序
                order: [],  //取消默认排序查询,否则复选框一列会出现小箭头
                pageLength: 20,
                lengthMenu: [[20, 50, -1], [20, 50, "All"]],

                dom: 'ifrtp',//lfrtip frtip
                pagingType: "simple_numbers",  //分页样式：simple,simple_numbers,full,full_numbers 
                columnDefs: [{}],




                ajax: function (data, callback, settings) {
                    var colname = "";
                    var dir = "";
                    if (data.order != "") {
                        colname = data.columns[data.order[0].column]["data"];
                        dir = data.order[0].dir;
                    }


                    $.ajax({
                        type: "GET",
                        url: "ajax/data_quote.aspx",
                        cache: false,  //禁用缓存
                        async: false,
                        data: {
                            quotecode: encodeURI($("#quotecode").val()),
                            productcode: encodeURI($("#productcode").val()),
                            productname: encodeURI($("#productname").val()),
                            customername: encodeURI($("#customername").val()),
                            customercode: encodeURI($("#customercode").val()),
                            auditstatus: encodeURI($("#auditstatus").val()),
                            pageIndex: data.start,
                            pageSize: data.length,
                            dir: dir,
                            colname:colname
                        },

                        dataType: "json",
                        success: function (result) {
                            callback(result);
                        }
                    });
                },



                //列表表头字段
                columns: [
                     { "data": "id" },
                       { "data": "quotecode" },
                     { "data": "productcode" },
                     { "data": "productname" },
                    

                     { "data": "customercode" },
                     { "data": "customername" },
                      { "data": "bomrevision" },
                    
                     { "data": "quotedate" },

                      { "data": "audit1name" },
                      { "data": "audit2name" },
                      { "data": "note" },
                      { "data": "auditstatus" }

                ],



                "columnDefs": [ 


                    { "targets": 1,
                      "render": function (data, type, row, meta) { 
                        return "<a     href=quote_detail.aspx?id=" + row.id + ">" + data + "</a>";
                      }
                    }
                    ,


                    
                {

                    "targets": 11,
                    "render": function (data, type, row, meta) {
                        var _isdraft = row.isdraft;
                        var k = row.auditstatus;
                        var result = "";

                        if (_isdraft == "1") {
                            return "<span class='label label-default'>草稿</span> ";
                        }
                        else {

                            switch (k) {
                                case 1:
                                    result = " <span class='label label-success'>已同意</span> ";
                                    break;

                                case -1:
                                    result = "<span class='label label-danger'>已拒绝</span>";
                                    break;

                                case 0:
                                    result = " <span class='label label-info'>审批中</span> ";
                                    break;

                            }


                        }

                       
                        return result;

            }
        }

                ]



            }).api();



            $('#tbl_pro').on('draw.dt', function () {

                formatData();

            });




        }




        InitTable();
 

  
        function formatData()
        {


        }




    </script>







     






















</asp:Content>
