index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <div class="row-content am-cf">
  2. <div class="row">
  3. <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
  4. <div class="widget am-cf">
  5. <div class="widget-head am-cf">
  6. <div class="widget-title am-cf">出售中的商品</div>
  7. </div>
  8. <div class="widget-body am-fr">
  9. <!-- 工具栏 -->
  10. <div class="page_toolbar am-margin-bottom-xs am-cf">
  11. <form class="toolbar-form" action="">
  12. <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
  13. <div class="am-u-sm-12 am-u-md-3">
  14. <div class="am-form-group">
  15. <?php if (checkPrivilege('goods/add')): ?>
  16. <div class="am-btn-group am-btn-group-xs">
  17. <a class="am-btn am-btn-default am-btn-success"
  18. href="<?= url('goods/add') ?>">
  19. <span class="am-icon-plus"></span> 新增
  20. </a>
  21. </div>
  22. <?php endif; ?>
  23. </div>
  24. </div>
  25. <div class="am-u-sm-12 am-u-md-9">
  26. <div class="am fr">
  27. <div class="am-form-group am-fl">
  28. <?php $category_id = $request->get('category_id') ?: null; ?>
  29. <select name="category_id"
  30. data-am-selected="{searchBox: 1, btnSize: 'sm', placeholder: '商品分类', maxHeight: 400}">
  31. <option value=""></option>
  32. <?php if (isset($catgory)): foreach ($catgory as $first): ?>
  33. <option value="<?= $first['category_id'] ?>"
  34. <?= $category_id == $first['category_id'] ? 'selected' : '' ?>>
  35. <?= $first['name'] ?></option>
  36. <?php if (isset($first['child'])): foreach ($first['child'] as $two): ?>
  37. <option value="<?= $two['category_id'] ?>"
  38. <?= $category_id == $two['category_id'] ? 'selected' : '' ?>>
  39.   <?= $two['name'] ?></option>
  40. <?php endforeach; endif; ?>
  41. <?php endforeach; endif; ?>
  42. </select>
  43. </div>
  44. <div class="am-form-group am-fl">
  45. <?php $status = $request->get('status') ?: null; ?>
  46. <select name="status"
  47. data-am-selected="{btnSize: 'sm', placeholder: '商品状态'}">
  48. <option value=""></option>
  49. <option value="10"
  50. <?= $status == 10 ? 'selected' : '' ?>>上架
  51. </option>
  52. <option value="20"
  53. <?= $status == 20 ? 'selected' : '' ?>>下架
  54. </option>
  55. </select>
  56. </div>
  57. <div class="am-form-group am-fl">
  58. <div class="am-input-group am-input-group-sm tpl-form-border-form">
  59. <input type="text" class="am-form-field" name="search"
  60. placeholder="请输入商品名称"
  61. value="<?= $request->get('search') ?>">
  62. <div class="am-input-group-btn">
  63. <button class="am-btn am-btn-default am-icon-search"
  64. type="submit"></button>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </form>
  71. </div>
  72. <div class="am-scrollable-horizontal am-u-sm-12">
  73. <table width="100%" class="am-table am-table-compact am-table-striped
  74. tpl-table-black am-text-nowrap">
  75. <thead>
  76. <tr>
  77. <th>商品ID</th>
  78. <th>商品图片</th>
  79. <th>商品名称</th>
  80. <th>商品分类</th>
  81. <th>实际销量</th>
  82. <th>商品排序</th>
  83. <th>商品状态</th>
  84. <th>添加时间</th>
  85. <th>操作</th>
  86. </tr>
  87. </thead>
  88. <tbody>
  89. <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
  90. <tr>
  91. <td class="am-text-middle"><?= $item['goods_id'] ?></td>
  92. <td class="am-text-middle">
  93. <a href="<?= $item['image'][0]['file_path'] ?>"
  94. title="点击查看大图" target="_blank">
  95. <img src="<?= $item['image'][0]['file_path'] ?>"
  96. width="50" height="50" alt="商品图片">
  97. </a>
  98. </td>
  99. <td class="am-text-middle">
  100. <p class="item-title"><?= $item['goods_name'] ?></p>
  101. </td>
  102. <td class="am-text-middle"><?= $item['category']['name'] ?></td>
  103. <td class="am-text-middle"><?= $item['sales_actual'] ?></td>
  104. <td class="am-text-middle"><?= $item['goods_sort'] ?></td>
  105. <td class="am-text-middle">
  106. <span class="j-state am-badge x-cur-p
  107. am-badge-<?= $item['goods_status']['value'] == 10 ? 'success' : 'warning' ?>"
  108. data-id="<?= $item['goods_id'] ?>"
  109. data-state="<?= $item['goods_status']['value'] ?>">
  110. <?= $item['goods_status']['text'] ?>
  111. </span>
  112. </td>
  113. <td class="am-text-middle"><?= $item['create_time'] ?></td>
  114. <td class="am-text-middle">
  115. <div class="tpl-table-black-operation">
  116. <?php if (checkPrivilege('goods/edit')): ?>
  117. <a href="<?= url('goods/edit',
  118. ['goods_id' => $item['goods_id']]) ?>">
  119. <i class="am-icon-pencil"></i> 编辑
  120. </a>
  121. <?php endif; ?>
  122. <?php if (checkPrivilege('goods/delete')): ?>
  123. <a href="javascript:;" class="item-delete tpl-table-black-operation-del"
  124. data-id="<?= $item['goods_id'] ?>">
  125. <i class="am-icon-trash"></i> 删除
  126. </a>
  127. <?php endif; ?>
  128. <?php if (checkPrivilege('goods/copy')): ?>
  129. <a class="tpl-table-black-operation-green" href="<?= url('goods/copy',
  130. ['goods_id' => $item['goods_id']]) ?>">
  131. 一键复制
  132. </a>
  133. <?php endif; ?>
  134. </div>
  135. </td>
  136. </tr>
  137. <?php endforeach; else: ?>
  138. <tr>
  139. <td colspan="9" class="am-text-center">暂无记录</td>
  140. </tr>
  141. <?php endif; ?>
  142. </tbody>
  143. </table>
  144. </div>
  145. <div class="am-u-lg-12 am-cf">
  146. <div class="am-fr"><?= $list->render() ?> </div>
  147. <div class="am-fr pagination-total am-margin-right">
  148. <div class="am-vertical-align-middle">总记录:<?= $list->total() ?></div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <script>
  157. $(function () {
  158. // 商品状态
  159. $('.j-state').click(function () {
  160. // 验证权限
  161. if (!"<?= checkPrivilege('goods/state')?>") {
  162. return false;
  163. }
  164. var data = $(this).data();
  165. layer.confirm('确定要' + (parseInt(data.state) === 10 ? '下架' : '上架') + '该商品吗?'
  166. , {title: '友情提示'}
  167. , function (index) {
  168. $.post("<?= url('goods/state') ?>"
  169. , {
  170. goods_id: data.id,
  171. state: Number(!(parseInt(data.state) === 10))
  172. }
  173. , function (result) {
  174. result.code === 1 ? $.show_success(result.msg, result.url)
  175. : $.show_error(result.msg);
  176. });
  177. layer.close(index);
  178. });
  179. });
  180. // 删除元素
  181. var url = "<?= url('goods/delete') ?>";
  182. $('.item-delete').delete('goods_id', url);
  183. });
  184. </script>