export.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .layui-card-header{background-color:#f8f8f8}
  5. .apply-time{
  6. float:left;
  7. }
  8. .export-select{float:left;}
  9. .download-button{
  10. float:right;
  11. }
  12. .export-list-view{
  13. font-size:12px;
  14. }
  15. .export-foot-operation{overflow:hidden;margin-top:15px;}
  16. .export-page{
  17. float:right;
  18. }
  19. .export-content-bar{
  20. float:left;
  21. padding-top: 6px;
  22. margin-left: 15px;
  23. }
  24. .export-foot-operation .layui-btn {
  25. padding: 0px 5px;
  26. font-size: 12px;
  27. line-height: 2 !important;
  28. height: auto;
  29. display: inline-block;
  30. }
  31. .layui-unselect.layui-form-checkbox{
  32. margin-top:-5px;
  33. }
  34. </style>
  35. {/block}
  36. {block name="main"}
  37. <div class="layui-layout layui-layout-admin">
  38. <div class="body-content">
  39. <div id="export_list"></div>
  40. <div class="export-foot-operation">
  41. <div class="export-content-bar layui-form bg-color-light-gray">
  42. <input type="checkbox" name="export_select" lay-filter="allChoose" lay-skin="primary" title="全选">
  43. </div>
  44. <button class="layui-btn layui-btn-primary" onclick="deleteExport()">批量删除</button>
  45. <div class='export-page' id="export_page"></div>
  46. </div>
  47. </div>
  48. </div>
  49. {/block}
  50. {block name="script"}
  51. <script type="text/html" id="exportHtml">
  52. {{# layui.each(d.data.list, function(index, item){ }}
  53. <div class="layui-card export-list-view">
  54. <div class="layui-card-header">
  55. <div class="layui-form export-select">
  56. <input type="checkbox" name="check[]" value="{{item.export_id}}" lay-skin="primary" title="">
  57. </div>
  58. <div class="apply-time">序号:{{ item.export_id }}&nbsp;&nbsp;&nbsp;导出时间:{{ ns.time_to_date(item.create_time) }}</div>
  59. <div class="download-button">
  60. {{# if(item.status == 0){ }}
  61. <span>正在导出中,请耐心等待…</span>
  62. {{# }else{ }}
  63. {{# if(item.path != ''){ }}
  64. <a class="text-color" href="{{ ns.img(item.path) }}">下载</a>
  65. {{#}}}
  66. {{#}}}
  67. &nbsp;&nbsp;<a class="text-color" href="javascript:void(0)"data-export_id ="{{item.export_id}}" onclick="deleteExport(this)">删除</a>
  68. </div>
  69. </div>
  70. <div class="layui-card-body">
  71. <div class="layui-row layui-col-space10">
  72. {{# layui.each(JSON.parse(item.condition), function(condition_index, condition_item){ }}
  73. <div class="layui-col-md3">
  74. {{condition_item.name}}:{{condition_item.value || '-'}}
  75. </div>
  76. {{# }); }}
  77. </div>
  78. </div>
  79. </div>
  80. {{# }); }}
  81. {{# if(d.data.list.length === 0){ }}
  82. <div class="layui-card export-list-view">
  83. <div class="layui-card-header">
  84. <div class="apply-time">商品导出记录</div>
  85. </div>
  86. <div class="layui-card-body">
  87. <div class="layui-row layui-col-space10">
  88. <div class="layui-col-md3">暂无导出记录</div>
  89. </div>
  90. </div>
  91. </div>
  92. {{# } }}
  93. </script>
  94. <script>
  95. var laypage,form;
  96. layui.use(['form', 'laytpl', 'laypage'], function() {
  97. form = layui.form;
  98. laytpl = layui.laytpl;
  99. form.render();
  100. exportList(1,10);
  101. laypage = layui.laypage;
  102. /**
  103. * 全选
  104. */
  105. form.on("checkbox(allChoose)", function(data) {
  106. $("input[name='check[]']").each(function() {
  107. this.checked = data.elem.checked;
  108. });
  109. form.render('checkbox');
  110. })
  111. });
  112. function exportList(page, limit){
  113. $.ajax({
  114. url: '{:addon_url("shop/goods/export")}',
  115. data: {
  116. limit,
  117. page
  118. },
  119. dataType: 'JSON',
  120. type: 'POST',
  121. success: function(res) {
  122. var export_template = $("#exportHtml").html();
  123. if(res.code >= 0){
  124. laytpl(export_template).render(res, function (html) {
  125. $("#export_list").html(html);
  126. })
  127. }
  128. laypage.render({
  129. elem: 'export_page',
  130. count: res.data.count,
  131. curr: page, //当前页
  132. limit: limit,
  133. jump: function(obj, first){
  134. //obj包含了当前分页的所有参数,比如:
  135. //首次不执行
  136. if(!first){
  137. exportList(obj.curr, obj.limit);
  138. form.render();
  139. }
  140. }
  141. });
  142. form.render();
  143. }
  144. });
  145. }
  146. /**
  147. * 删除导出记录
  148. */
  149. var flag_delete = false;
  150. function deleteExport(data) {
  151. var export_ids = [];
  152. if (!data) {
  153. $("input[name='check[]']:checked").each(function(index, item) {
  154. export_ids.push($(item).val());
  155. });
  156. }else{
  157. export_ids.push($(data).attr("data-export_id"));
  158. }
  159. export_ids = export_ids.toString();
  160. layer.confirm('确定要删除选择的商品导出记录吗?', {
  161. btn: ['确定', '取消']
  162. }, function() {
  163. if (flag_delete) return;
  164. flag_delete = true;
  165. $.ajax({
  166. type: "POST",
  167. async: true,
  168. url: ns.url("shop/goods/deleteExport"),
  169. data: {
  170. export_ids: export_ids,
  171. },
  172. dataType: "JSON",
  173. success: function(data) {
  174. layer.msg(data.message);
  175. if (data.code == 0) {
  176. location.reload();
  177. }else{
  178. flag_delete = false;
  179. }
  180. }
  181. });
  182. }, function() {
  183. layer.close();
  184. });
  185. }
  186. </script>
  187. {/block}