截流自动化的商城平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

lists.html 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <!-- 操作提示 -->
  5. <div class="layui-card-body">
  6. <div class="layui-collapse" style="border:1px dashed #c4c4c4">
  7. <div class="layui-colla-item">
  8. <h2 class="layui-colla-title like-layui-colla-title">操作提示</h2>
  9. <div class="layui-colla-content layui-show">
  10. <p>*平台发布的操作说明,帮助文档,常见问题。用户可在商城的帮助功能查看。</p>
  11. <p>*帮助文档排序值越小越前,排序值相同时新增文章在前。</p>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. <!-- 搜索区域 -->
  17. <div class="layui-card-body layui-form">
  18. <div class="layui-form-item">
  19. <div class="layui-inline">
  20. <label for="title" class="layui-form-label">帮助标题:</label>
  21. <div class="layui-input-inline">
  22. <input type="text" id="title" name="title" autocomplete="off" class="layui-input">
  23. </div>
  24. </div>
  25. <div class="layui-inline">
  26. <label for="cid" class="layui-form-label">帮助分类:</label>
  27. <div class="layui-input-inline">
  28. <select name="cid" id="cid">
  29. <option value="">全部</option>
  30. {volist name="category" id="vo"}
  31. <option value="{$vo.id}">{$vo.name}</option>
  32. {/volist}
  33. </select>
  34. </div>
  35. </div>
  36. <div class="layui-inline">
  37. <a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
  38. <a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
  39. </div>
  40. </div>
  41. </div>
  42. <!-- 主体区域 -->
  43. <div class="layui-card-body">
  44. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layEvent" lay-event="add">新增帮助</button>
  45. <table id="like-table-lists" lay-filter="like-table-lists"></table>
  46. <script type="text/html" id="table-image">
  47. {{# if(d.image){ }}
  48. <img src="{{d.image}}" alt="图" style="width:28px;height:28px;">
  49. {{# } }}
  50. </script>
  51. <script type="text/html" id="table-operation">
  52. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
  53. {{# if(d.is_show == '显示'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm layui-btn-warm" lay-event="hide">隐藏</a>{{# } }}
  54. {{# if(d.is_show == '隐藏'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="hide">显示</a>{{# } }}
  55. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
  56. </script>
  57. </div>
  58. </div>
  59. </div>
  60. <script>
  61. layui.use(["table", "form"], function(){
  62. var table = layui.table;
  63. var form = layui.form;
  64. like.tableLists("#like-table-lists", "{:url()}", [
  65. {field:"id", width:60, title:"ID"}
  66. ,{field:"title", width:200, align:"center", title:"帮助标题"}
  67. ,{field:"image", width:100, align:"center", title:"封面图", templet:"#table-image"}
  68. ,{field:"category", width:150, align:"center", title:"帮助分类"}
  69. ,{field:"is_show", width:100, align:"center", title:"帮助状态"}
  70. ,{field:"visit", width:100, align:"center", title:"浏览量"}
  71. ,{field:"likes", width:100, align:"center", title:"点赞量"}
  72. ,{field:"sort", width:100, align:"center", title:"排序"}
  73. ,{field:"create_time", width:180, align:"center", title:"创建时间"}
  74. ,{title:"操作", width:200, align:"center", fixed:"right", toolbar:"#table-operation"}
  75. ]);
  76. var active = {
  77. add: function() {
  78. layer.open({
  79. type: 2
  80. ,title: "新增帮助"
  81. ,content: "{:url('content.Help/add')}"
  82. ,area: ["90%", "90%"]
  83. ,btn: ["确定", "取消"]
  84. ,yes: function(index, layero){
  85. var iframeWindow = window["layui-layer-iframe" + index];
  86. var submit = layero.find("iframe").contents().find("#addSubmit");
  87. iframeWindow.layui.form.on("submit(addSubmit)", function(data){
  88. like.ajax({
  89. url: "{:url('content.Help/add')}",
  90. data: data.field,
  91. type: "POST",
  92. success:function(res) {
  93. if(res.code === 1) {
  94. layui.layer.msg(res.msg);
  95. layer.close(index);
  96. table.reload("like-table-lists", {
  97. where: {},
  98. page: { cur: 1 }
  99. });
  100. }
  101. }
  102. });
  103. });
  104. submit.trigger("click");
  105. }
  106. });
  107. },
  108. edit: function(obj) {
  109. layer.open({
  110. type: 2
  111. ,title: "编辑帮助"
  112. ,content: "{:url('content.Help/edit')}?id=" + obj.data.id
  113. ,area: ["90%", "90%"]
  114. ,btn: ["确定", "取消"]
  115. ,yes: function(index, layero){
  116. var iframeWindow = window["layui-layer-iframe" + index];
  117. var submit = layero.find("iframe").contents().find("#addSubmit");
  118. iframeWindow.layui.form.on("submit(addSubmit)", function(data){
  119. data.field['id'] = obj.data.id;
  120. like.ajax({
  121. url: "{:url('content.Help/edit')}",
  122. data: data.field,
  123. type: "POST",
  124. success:function(res) {
  125. if(res.code === 1) {
  126. layui.layer.msg(res.msg);
  127. layer.close(index);
  128. table.reload("like-table-lists", {
  129. where: {},
  130. page: { cur: 1 }
  131. });
  132. }
  133. }
  134. });
  135. });
  136. submit.trigger("click");
  137. }
  138. });
  139. },
  140. del: function(obj) {
  141. layer.confirm("确定删除帮助:"+obj.data.title, function(index) {
  142. like.ajax({
  143. url: "{:url('content.Help/del')}",
  144. data: {id: obj.data.id},
  145. type: "POST",
  146. success: function (res) {
  147. if (res.code === 1) {
  148. layui.layer.msg(res.msg);
  149. layer.close(index);
  150. obj.del();
  151. }
  152. }
  153. });
  154. layer.close(index);
  155. })
  156. },
  157. hide: function(obj) {
  158. var text = obj.data.is_show === '显示' ? '确定隐藏:' : '确定显示:';
  159. layer.confirm(text+obj.data.title, function(index) {
  160. like.ajax({
  161. url: "{:url('content.Help/hide')}",
  162. data: {id: obj.data.id},
  163. type: "POST",
  164. success: function (res) {
  165. if (res.code === 1) {
  166. layui.layer.msg(res.msg);
  167. layer.close(index);
  168. table.reload("like-table-lists", {
  169. where: {},
  170. page: { cur: 1 }
  171. });
  172. }
  173. }
  174. });
  175. layer.close(index);
  176. })
  177. }
  178. };
  179. like.eventClick(active);
  180. form.on("submit(search)", function(data){
  181. table.reload("like-table-lists", {
  182. where: data.field,
  183. page: {
  184. curr: 1
  185. }
  186. });
  187. });
  188. form.on("submit(clear-search)", function(){
  189. $("#title").val("");
  190. form.render("select");
  191. table.reload("like-table-lists", {
  192. where: {},
  193. page: {
  194. curr: 1
  195. }
  196. });
  197. });
  198. })
  199. </script>