截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

select_goods_two.html 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. {layout name="layout1" /}
  2. <div class="layui-fluid">
  3. <div class="layui-card">
  4. <div class="layui-tab layui-tab-card" lay-filter="tab-all">
  5. <div class="layui-tab-item layui-show">
  6. <div class="layui-card">
  7. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  8. <div class="layui-form-item type">
  9. <div class="layui-inline">
  10. <label class="layui-form-label">商品名称:</label>
  11. <div class="layui-input-block">
  12. <input type="text" name="keyword" id="keyword" placeholder="请输入关键词" autocomplete="off" class="layui-input">
  13. </div>
  14. </div>
  15. <div class="layui-inline">
  16. <label class="layui-form-label">商品分类:</label>
  17. <div class="layui-input-block">
  18. <select name="cid" placeholder="请选择商品分类" >
  19. <option value="0">全部</option>
  20. {foreach $category_list as $val }
  21. <option value="{$val.id}">{$val.name}</option>
  22. {/foreach}
  23. </select>
  24. </div>
  25. </div>
  26. <div class="layui-inline">
  27. <button class="layui-btn layuiadmin-btn-goods {$view_theme_color}" lay-submit lay-filter="goods-search">查询</button>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="layui-card-body">
  32. <table id="goods-lists" lay-filter="goods-lists"></table>
  33. <script type="text/html" id="goods-info">
  34. <img src="{{d.image}}" style="height:60px;width: 60px" class="image-show"> {{d.name}}
  35. </script>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="layui-form-item layui-hide">
  42. <input type="button" lay-submit lay-filter="select-submit" class="select-submit" id="select-submit" value="确认">
  43. </div>
  44. </div>
  45. <style>
  46. .layui-table-cell {
  47. height: auto;
  48. }
  49. </style>
  50. <script>
  51. var table;
  52. layui.config({
  53. version:"{$front_version}",
  54. base: '/static/lib/' //静态资源所在路径
  55. }).use(['table','form'], function(){
  56. var $ = layui.$
  57. ,form = layui.form
  58. ,element = layui.element;
  59. //监听搜索
  60. form.on('submit(goods-search)', function(data){
  61. var field = data.field;
  62. //执行重载
  63. table.reload('goods-lists', {
  64. where: field
  65. });
  66. });
  67. //清空查询
  68. form.on('submit(goods-clear-search)', function(){
  69. $('#keyword').val(''); //清空输入框
  70. $('#status_search').val(''); //清空输入框
  71. form.render('select');
  72. //刷新列表
  73. table.reload('goods-lists', {
  74. where: []
  75. });
  76. });
  77. });
  78. layui.define(['table', 'form'], function (exports) {
  79. var $ = layui.$
  80. , form = layui.form;
  81. table = layui.table;
  82. table.render({
  83. id: 'goods-lists'
  84. , elem: '#goods-lists'
  85. , url: '{:url("common/selectGoodsTwo")}' //模拟接口
  86. , cols: [[
  87. {type: 'radio'}
  88. , {field: 'name', title: '商品名称', toolbar: '#goods-info'}
  89. , {field: 'price', title: '价格'}
  90. , {field: 'stock', title: '库存'}
  91. ]]
  92. , page: true
  93. , text: {none: '暂无数据!'}
  94. , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
  95. return {
  96. "code": res.code,
  97. "msg": res.msg,
  98. "count": res.data.count, //解析数据长度
  99. "data": res.data.list, //解析数据列表
  100. };
  101. },
  102. response: {
  103. statusCode: 1
  104. }
  105. });
  106. })
  107. var callbackdata = function () {
  108. var data = table.checkStatus('goods-lists').data
  109. ,index = parent.layer.getFrameIndex(window.name);
  110. parent.layer.close(index);
  111. return data;
  112. }
  113. </script>