<%@ Page Title="" Language="C#" MasterPageFile="bps.Master" AutoEventWireup="true" CodeBehind="price_query.aspx.cs" Inherits="bps.bps.mat_sup_relation" %>
 
<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="code" type="text" class="form-control"   style="width:120px;" />

         物料名称 
        <input id="catname"   type="text" class="form-control"   style="width:200px;" />

   
        规格型号 
        <input id="spec"   type="text" class="form-control"   style="width:300px;" />
 
        供应商 
        <input id="supplyname"   type="text" class="form-control"   style="width:200px;" />


        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;&nbsp;

                  <a href="###" style="display:none" onclick="Pop('mat_sup_relation_add.aspx',950,600,'添加供应商提供的原料')" class="btn btn-sm btn-success  " >添加  </a>  
      
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="###;" onclick="ept('Export_Data.aspx?types=price'); return false;" class="btn btn-sm bg-fuchsia">导出</a> 

    <a href="###" onclick="ept('Import_Data.aspx?types=price'); return false;" class="btn btn-sm bg-maroon">导入</a>


        
    
    </div>

      </div>
        </div>

    






    

    <table   class="table  "  id="tbl_pro"  >
        <thead  >
            <tr>
                  <th width="40px">ID</th>
                 <th  width="120px">物料编号</th>
                 <th width="300px">物料名称</th>
                 <th width="250px">规则型号</th>

                 <th width="80px">默认单价</th>
                 <th width="80px">货币</th>

                  <th width="130px">默认供应商</th>
                  <th width="120px">供应商号Vnr</th>
                    <th width="80px">交货期</th>
                  <th width="280px">价格备注</th>
                
            </tr>
        </thead>
    </table>

     



    
    <script>


        function InitTable() {

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

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


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

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

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

            $("#spec").keyup(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/pro_data.aspx",
                        cache: false,  //禁用缓存
                        async: false,
                        data: {
                            code:   encodeURI ($("#code").val()),
                            catname: encodeURI($("#catname").val()),
                            supplyname: encodeURI($("#supplyname").val()),
                            spec: encodeURI($("#spec").val()),
                            pageIndex: data.start,
                            pageSize: data.length,
                            dir: dir,
                            colname:colname
                        },

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



                //列表表头字段
                columns: [
                     { "data": "id" },
                     { "data": "code" },
                     { "data": "catname" },
                     { "data": "spec" },

                     { "data": "price" },
                     { "data": "currency" },

                     { "data": "supplyname" },
                     { "data": "supplycode" },

                      { "data": "leadtime" },
                       { "data": "pricenote" } 
                ],



                "columnDefs": [{


                    "targets": 0,
                    "render": function (data, type, row, meta) {
                        return "<img onclick=_action(this) src='images/open.gif' /> " + data;
                    }  }
                    ,
                    {

                    "targets": 2,
                    "render": function (data, type, row, meta) {
                        return "<a   href=### onclick=Pop('material_addEdit.aspx?id=" + row.id + "',1250,650,'编辑物料'); >" + data + "</a>";
                    }



                }]



            }).api();



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

                //formatData();

            });




        }




        InitTable();
 

  



        function _action(obj)
        {
    
                var img = $(obj),
                  src = img.attr('src');
               
                var parent = $(obj).parent().parent(); //tr
             
                var _code = $(parent).find("td").eq(0).html().trim();
                
                _code= _code.split('>')[1]
               

                if (src && src.indexOf('open') !== -1) {
                    img.attr({
                        'src': 'images/close.gif'
                    });

                  
                    //GET DATA


                    $.get("ajax/pro_data_company.aspx?proid="+_code, function (res) {
                      
                        var result = "";
                        result += "<tr style='background-color:#eee;'><td>&nbsp;</td>";
                        result += "<td colspan=9>"+res+"</td>";
                        result += "</tr>";

                        parent.after(result);

                    });



                 
                     

                } else if (src && src.indexOf('close') !== -1) {
                    img.attr({
                        'src': 'images/open.gif'
                    });
                    parent.next().hide();
                }
            

        }





    </script>







</asp:Content>
