截流自动化的商城平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

select_goods.html 4.1KB

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