<bdo id='klel2'></bdo><ul id='klel2'></ul>
    1. <tfoot id='klel2'></tfoot>

        <legend id='klel2'><style id='klel2'><dir id='klel2'><q id='klel2'></q></dir></style></legend>
        <i id='klel2'><tr id='klel2'><dt id='klel2'><q id='klel2'><span id='klel2'><b id='klel2'><form id='klel2'><ins id='klel2'></ins><ul id='klel2'></ul><sub id='klel2'></sub></form><legend id='klel2'></legend><bdo id='klel2'><pre id='klel2'><center id='klel2'></center></pre></bdo></b><th id='klel2'></th></span></q></dt></tr></i><div id='klel2'><tfoot id='klel2'></tfoot><dl id='klel2'><fieldset id='klel2'></fieldset></dl></div>
      1. <small id='klel2'></small><noframes id='klel2'>

      2. layui Table自定义工具栏和搜索参数

        时间:2024-06-12
        • <i id='MAFb4'><tr id='MAFb4'><dt id='MAFb4'><q id='MAFb4'><span id='MAFb4'><b id='MAFb4'><form id='MAFb4'><ins id='MAFb4'></ins><ul id='MAFb4'></ul><sub id='MAFb4'></sub></form><legend id='MAFb4'></legend><bdo id='MAFb4'><pre id='MAFb4'><center id='MAFb4'></center></pre></bdo></b><th id='MAFb4'></th></span></q></dt></tr></i><div id='MAFb4'><tfoot id='MAFb4'></tfoot><dl id='MAFb4'><fieldset id='MAFb4'></fieldset></dl></div>

              <bdo id='MAFb4'></bdo><ul id='MAFb4'></ul>
            • <legend id='MAFb4'><style id='MAFb4'><dir id='MAFb4'><q id='MAFb4'></q></dir></style></legend>

              <small id='MAFb4'></small><noframes id='MAFb4'>

              <tfoot id='MAFb4'></tfoot>

                    <tbody id='MAFb4'></tbody>
                1. layUI Table自定义工具栏和搜索参数,先看实现效果:

                  HTML代码部分:

                  <div class="container-fluid">
                      <table class="layui-hide" id="test" lay-filter="test"></table>
                  </div>
                  <style>
                      .layui-input, .layui-unselect, .layui-select-title {
                          height: 30px;
                      }
                  </style>
                  <script type="text/html" id="toolbarDemo">
                      <div class="layui-btn-group">
                              <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-event="add" style="padding:0px 3px 0px 5px">
                                  <i class="layui-icon">&#xe654;</i>
                              </button>
                              <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-event="update" style="padding:0px 3px 0px 5px">
                                  <i class="layui-icon">&#xe642;</i>
                              </button>
                              <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-event="delete" style="padding:0px 3px 0px 5px">
                                  <i class="layui-icon">&#xe640;</i>
                              </button>
                          </div>
                   
                      <div class="layui-inline ">
                          <input type="text" id="orderID"  placeholder="订单号" autocomplete="off" class="layui-input" style="height:30px;width:110px">
                      </div>
                      <div class="layui-inline " style="width:100px">
                          <select id="orderState">
                              <option value="0">所有状态</option>
                              <option value="1">已支付</option>
                              <option value="2">未支付</option>
                              <option value="3">已结算</option>
                          </select>
                      </div>
                      <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-event="search" style="padding:0px 3px 0px 5px">
                          <i class="layui-icon">&#xe615;</i>
                      </button>
                  </script>

                  js代码部分:

                  layui.use(['table', 'layer', 'jquery'], function () {
                      var table = layui.table,
                          layer = layui.layer, //弹层
                          $ = layui.jquery
                      if (localStorage.getItem("layuiPageSize") == null || localStorage.getItem("layuiPageSize") == 'undefined') {
                          localStorage.setItem("layuiPageSize", 20);//添加每页默认数据条数
                      }
                      let guid = getGUID();
                      table.render({
                          elem: '#test',
                          url: '../api/OrderInfo/Query', //获取数据url地址
                          title: '用户数据表',
                          toolbar: '#toolbarDemo',//开启工具栏,此处显示默认图标,可以自定义模板,详见文档
                          defaultToolbar: false,//表头上面的右侧工具栏去掉
                          page: {
                              limit: localStorage.getItem("layuiPageSize")//默认每页多少条
                              , limits: [20, 30, 50, 100, 200, 300, 500]//选择  显示每页多少条
                              //, first: '首页'
                              //,last: '尾页'
                          },
                          where: {
                              orderid: $('#orderID').val(),
                              UserName: $.cookie('uName'),
                              GUID: guid,
                              state: $("#orderState").val()
                          },
                          id: 'testReload',
                          cols: [
                              [{
                                  type: 'checkbox',
                                  fixed: 'left'
                              }, {
                                  field: 'orderid',
                                  title: '订单号',
                                  width: 205,
                                  //fixed: 'left',
                                  //unresize: true,
                                  //sort: true
                              }, {
                                  field: 'UserName',
                                  title: '用户名',
                                  width: 120,
                                  edit: 'text'
                              }, {
                                  field: 'money',
                                  title: '金额',
                                  width: 80,
                                  edit: 'text'
                              }, {
                                  field: 'subject',
                                  title: '摘要',
                                  width: 120,
                                  edit: 'text'
                              }, {
                                  field: 'body',
                                  title: '月数',
                                  width: 60
                              }, {
                                  field: 'state',
                                  title: '状态',
                                      width: 75, templet: function (d) {
                                          if (d.state == 1) {
                                              return '已支付'
                                          } else if (d.state == 2) {
                                              return '未支付'
                                          } else if (d.state == 3) {
                                              return '已结算'
                                          }
                                      }
                              }, {
                                  field: 'OrderTime',
                                  title: '订单时间'
                              }]
                          ],
                          done: function (obj, first) {
                              let pageSize = $(".layui-laypage-limits").find("option:selected").val();
                              localStorage.setItem("layuiPageSize", pageSize);//添加数据
                          }
                      });
                      //监听头工具栏事件
                      table.on('toolbar(test)', function (obj) {
                          var checkStatus = table.checkStatus(obj.config.id)
                              , data = checkStatus.data; //获取选中的数据
                          switch (obj.event) {
                              case 'add':
                                  alert("功能没开放");
                                  break;
                              case 'update':
                                  alert("功能没开放");
                                  break;
                              case 'search':
                                  let search = $('#orderID').val();
                                  let state = $("#orderState").val();
                                  table.reload('testReload',{
                                      page: {
                                          curr: 1 //重新从第 1 页开始
                                      },
                                      where: {
                                          orderid: $('#orderID').val(),
                                          UserName: $.cookie('uName'),
                                          GUID: guid,
                                          state: $("#orderState").val()
                                      }
                                  });
                                  $('#orderID').val(search);//重加载后,重新赋值上次搜索的内容
                                  $("#orderState").val(state);
                                  break;
                              case 'delete':
                                  alert("功能没开放");
                                  break;
                          };
                      });
                  })

                  上一篇:layui表格中使用自定义templet模板 下一篇:没有了

                  相关文章

                      <tfoot id='7qp2i'></tfoot>
                        <bdo id='7qp2i'></bdo><ul id='7qp2i'></ul>
                    1. <small id='7qp2i'></small><noframes id='7qp2i'>

                    2. <i id='7qp2i'><tr id='7qp2i'><dt id='7qp2i'><q id='7qp2i'><span id='7qp2i'><b id='7qp2i'><form id='7qp2i'><ins id='7qp2i'></ins><ul id='7qp2i'></ul><sub id='7qp2i'></sub></form><legend id='7qp2i'></legend><bdo id='7qp2i'><pre id='7qp2i'><center id='7qp2i'></center></pre></bdo></b><th id='7qp2i'></th></span></q></dt></tr></i><div id='7qp2i'><tfoot id='7qp2i'></tfoot><dl id='7qp2i'><fieldset id='7qp2i'></fieldset></dl></div>

                      <legend id='7qp2i'><style id='7qp2i'><dir id='7qp2i'><q id='7qp2i'></q></dir></style></legend>