截流自动化的商城平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

lists.html 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. <label for="is_notice" class="layui-form-label">商城公告:</label>
  38. <div class="layui-input-inline">
  39. <select name="is_notice" id="is_notice">
  40. <option value="">全部</option>
  41. <option value="1">是</option>
  42. <option value="0">否</option>
  43. </select>
  44. </div>
  45. </div>
  46. <div class="layui-inline">
  47. <a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
  48. <a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
  49. </div>
  50. </div>
  51. </div>
  52. <!-- 主体区域 -->
  53. <div class="layui-card-body">
  54. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layEvent" lay-event="add">新增文章</button>
  55. <table id="like-table-lists" lay-filter="like-table-lists"></table>
  56. <script type="text/html" id="table-image">
  57. {{# if(d.image){ }}
  58. <img src="{{d.image}}" alt="图" style="width:28px;height:28px;">
  59. {{# } }}
  60. </script>
  61. <script type="text/html" id="table-operation">
  62. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
  63. {{# if(d.is_show == '显示'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm layui-btn-warm" lay-event="hide">隐藏</a>{{# } }}
  64. {{# if(d.is_show == '隐藏'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="hide">显示</a>{{# } }}
  65. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
  66. </script>
  67. </div>
  68. </div>
  69. </div>
  70. <script>
  71. layui.use(["table", "form"], function(){
  72. var table = layui.table;
  73. var form = layui.form;
  74. like.tableLists("#like-table-lists", "{:url()}", [
  75. {field:"id", width:60, title:"ID"}
  76. ,{field:"title", width:200, align:"center", title:"文章标题"}
  77. ,{field:"image", width:100, align:"center", title:"封面图", templet:"#table-image"}
  78. ,{field:"category", width:150, align:"center", title:"文章分类"}
  79. ,{field:"is_notice", width:100, align:"center", title:"商城公告"}
  80. ,{field:"is_show", width:100, align:"center", title:"文章状态"}
  81. ,{field:"visit", width:100, align:"center", title:"浏览量"}
  82. ,{field:"likes", width:100, align:"center", title:"点赞量"}
  83. ,{field:"sort", width:100, align:"center", title:"排序"}
  84. ,{field:"create_time", width:180, align:"center", title:"创建时间"}
  85. ,{title:"操作", width:200, align:"center", fixed:"right", toolbar:"#table-operation"}
  86. ]);
  87. var active = {
  88. add: function() {
  89. layer.open({
  90. type: 2
  91. ,title: "新增文章"
  92. ,content: "{:url('content.Article/add')}"
  93. ,area: ["90%", "90%"]
  94. ,btn: ["确定", "取消"]
  95. ,yes: function(index, layero){
  96. var iframeWindow = window["layui-layer-iframe" + index];
  97. var submit = layero.find("iframe").contents().find("#addSubmit");
  98. iframeWindow.layui.form.on("submit(addSubmit)", function(data){
  99. like.ajax({
  100. url: "{:url('content.Article/add')}",
  101. data: data.field,
  102. type: "POST",
  103. success:function(res) {
  104. if(res.code === 1) {
  105. layui.layer.msg(res.msg);
  106. layer.close(index);
  107. table.reload("like-table-lists", {
  108. where: {},
  109. page: { cur: 1 }
  110. });
  111. }
  112. }
  113. });
  114. });
  115. submit.trigger("click");
  116. }
  117. });
  118. },
  119. edit: function(obj) {
  120. layer.open({
  121. type: 2
  122. ,title: "编辑文章"
  123. ,content: "{:url('content.Article/edit')}?id=" + obj.data.id
  124. ,area: ["90%", "90%"]
  125. ,btn: ["确定", "取消"]
  126. ,yes: function(index, layero){
  127. var iframeWindow = window["layui-layer-iframe" + index];
  128. var submit = layero.find("iframe").contents().find("#addSubmit");
  129. iframeWindow.layui.form.on("submit(addSubmit)", function(data){
  130. data.field['id'] = obj.data.id;
  131. like.ajax({
  132. url: "{:url('content.Article/edit')}",
  133. data: data.field,
  134. type: "POST",
  135. success:function(res) {
  136. if(res.code === 1) {
  137. layui.layer.msg(res.msg);
  138. layer.close(index);
  139. table.reload("like-table-lists", {
  140. where: {},
  141. page: { cur: 1 }
  142. });
  143. }
  144. }
  145. });
  146. });
  147. submit.trigger("click");
  148. }
  149. });
  150. },
  151. del: function(obj) {
  152. layer.confirm("确定删除文章:"+obj.data.title, function(index) {
  153. like.ajax({
  154. url: "{:url('content.Article/del')}",
  155. data: {id: obj.data.id},
  156. type: "POST",
  157. success: function (res) {
  158. if (res.code === 1) {
  159. layui.layer.msg(res.msg);
  160. layer.close(index);
  161. obj.del();
  162. }
  163. }
  164. });
  165. layer.close(index);
  166. })
  167. },
  168. hide: function(obj) {
  169. var text = obj.data.is_show === '显示' ? '确定隐藏:' : '确定显示:';
  170. layer.confirm(text+obj.data.title, function(index) {
  171. like.ajax({
  172. url: "{:url('content.Article/hide')}",
  173. data: {id: obj.data.id},
  174. type: "POST",
  175. success: function (res) {
  176. if (res.code === 1) {
  177. layui.layer.msg(res.msg);
  178. layer.close(index);
  179. table.reload("like-table-lists", {
  180. where: {},
  181. page: { cur: 1 }
  182. });
  183. }
  184. }
  185. });
  186. layer.close(index);
  187. })
  188. }
  189. };
  190. like.eventClick(active);
  191. form.on("submit(search)", function(data){
  192. table.reload("like-table-lists", {
  193. where: data.field,
  194. page: {
  195. curr: 1
  196. }
  197. });
  198. });
  199. form.on("submit(clear-search)", function(){
  200. $("#title").val("");
  201. form.render("select");
  202. table.reload("like-table-lists", {
  203. where: {},
  204. page: {
  205. curr: 1
  206. }
  207. });
  208. });
  209. })
  210. </script>