list.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  6. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  7. <meta name="renderer" content="webkit"/>
  8. <link rel="stylesheet" href="assets/common/css/amazeui.min.css"/>
  9. <link rel="stylesheet" href="assets/store/css/app.css?v=<?= $version ?>"/>
  10. <script src="assets/common/js/jquery.min.js"></script>
  11. <title>商品列表</title>
  12. </head>
  13. <body class="select-data">
  14. <!-- 工具栏 -->
  15. <div class="page_toolbar am-u-sm-12 am-margin-bottom-xs am-cf">
  16. <form class="toolbar-form" action="">
  17. <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
  18. <div class="am fr">
  19. <div class="am-form-group am-fl">
  20. <?php $categoryId = $request->get('category_id') ?: null; ?>
  21. <select name="category_id"
  22. data-am-selected="{searchBox: 1, btnSize: 'sm', placeholder: '商品分类', maxHeight: 400}">
  23. <option value=""></option>
  24. <?php if (isset($catgory)): foreach ($catgory as $first): ?>
  25. <option value="<?= $first['category_id'] ?>"
  26. <?= $categoryId == $first['category_id'] ? 'selected' : '' ?>>
  27. <?= $first['name'] ?></option>
  28. <?php if (isset($first['child'])): foreach ($first['child'] as $two): ?>
  29. <option value="<?= $two['category_id'] ?>"
  30. <?= $categoryId == $two['category_id'] ? 'selected' : '' ?>>
  31.   <?= $two['name'] ?></option>
  32. <?php endforeach; endif; ?>
  33. <?php endforeach; endif; ?>
  34. </select>
  35. </div>
  36. <div class="am-form-group am-fl">
  37. <?php $status = $request->get('status') ?: null; ?>
  38. <select name="status"
  39. data-am-selected="{btnSize: 'sm', placeholder: '商品状态'}">
  40. <option value=""></option>
  41. <option value="10"
  42. <?= $status == 10 ? 'selected' : '' ?>>上架
  43. </option>
  44. <option value="20"
  45. <?= $status == 20 ? 'selected' : '' ?>>下架
  46. </option>
  47. </select>
  48. </div>
  49. <div class="am-form-group am-fl">
  50. <div class="am-input-group am-input-group-sm tpl-form-border-form">
  51. <input type="text" class="am-form-field" name="search"
  52. placeholder="请输入商品名称"
  53. value="<?= $request->get('search') ?>">
  54. <div class="am-input-group-btn">
  55. <button class="am-btn am-btn-default am-icon-search"
  56. type="submit"></button>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </form>
  62. </div>
  63. <div class="am-scrollable-horizontal am-u-sm-12">
  64. <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black am-text-nowrap">
  65. <thead>
  66. <tr>
  67. <th>
  68. <label class="am-checkbox">
  69. <input data-am-ucheck data-check="all" type="checkbox">
  70. </label>
  71. </th>
  72. <th>商品ID</th>
  73. <th>商品图片</th>
  74. <th>商品名称</th>
  75. <th>商品分类</th>
  76. <th>添加时间</th>
  77. </tr>
  78. </thead>
  79. <tbody>
  80. <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
  81. <tr>
  82. <td class="am-text-middle">
  83. <label class="am-checkbox">
  84. <input data-am-ucheck data-check="item" data-params='<?= json_encode([
  85. 'goods_id' => (string)$item['goods_id'],
  86. 'goods_name' => $item['goods_name'],
  87. 'selling_point' => $item['selling_point'],
  88. 'image' => $item['image'][0]['file_path'],
  89. 'goods_image' => $item['image'][0]['file_path'],
  90. 'goods_price' => $item['sku'][0]['goods_price'],
  91. 'line_price' => $item['sku'][0]['line_price'],
  92. 'goods_sales' => $item['goods_sales'],
  93. ], JSON_UNESCAPED_SLASHES) ?>' type="checkbox">
  94. </label>
  95. </td>
  96. <td class="am-text-middle"><?= $item['goods_id'] ?></td>
  97. <td class="am-text-middle">
  98. <a href="<?= $item['image'][0]['file_path'] ?>"
  99. title="点击查看大图" target="_blank">
  100. <img src="<?= $item['image'][0]['file_path'] ?>"
  101. width="50" height="50" alt="商品图片">
  102. </a>
  103. </td>
  104. <td class="am-text-middle">
  105. <p class="item-title"><?= $item['goods_name'] ?></p>
  106. </td>
  107. <td class="am-text-middle"><?= $item['category']['name'] ?></td>
  108. <td class="am-text-middle"><?= $item['create_time'] ?></td>
  109. </tr>
  110. <?php endforeach; else: ?>
  111. <tr>
  112. <td colspan="9" class="am-text-center">暂无记录</td>
  113. </tr>
  114. <?php endif; ?>
  115. </tbody>
  116. </table>
  117. </div>
  118. <div class="am-u-lg-12 am-cf">
  119. <div class="am-fr"><?= $list->render() ?> </div>
  120. <div class="am-fr pagination-total am-margin-right">
  121. <div class="am-vertical-align-middle">总记录:<?= $list->total() ?></div>
  122. </div>
  123. </div>
  124. <script src="assets/common/js/amazeui.min.js"></script>
  125. <script>
  126. /**
  127. * 获取已选择的数据
  128. * @returns {Array}
  129. */
  130. function getSelectedData() {
  131. var data = [];
  132. $('input[data-check=item]:checked').each(function () {
  133. data.push($(this).data('params'));
  134. });
  135. return data;
  136. }
  137. $(function () {
  138. // 全选框元素
  139. var $checkAll = $('input[data-check=all]')
  140. , $checkItem = $('input[data-check=item]')
  141. , itemCount = $checkItem.length;
  142. // 复选框: 全选和反选
  143. $checkAll.change(function () {
  144. $checkItem.prop('checked', this.checked);
  145. });
  146. // 复选框: 子元素
  147. $checkItem.change(function () {
  148. if (!this.checked) {
  149. $checkAll.prop('checked', false);
  150. } else {
  151. var checkedItemNum = $checkItem.filter(':checked').length;
  152. checkedItemNum === itemCount && $checkAll.prop('checked', true);
  153. }
  154. });
  155. });
  156. </script>
  157. </body>
  158. </html>