index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  6. <title><?php echo $shoname; ?></title>
  7. <link rel="shortcut icon" href="" />
  8. <meta name="renderer" content="webkit">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  11. <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  18. <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  19. <script type="text/javascript">
  20. window.sysinfo = {
  21. <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '{$_W['acid']}',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '{$_W['uid']}',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '{$_W['siteroot']}',
  27. 'siteurl': '{$_W['siteurl']}',
  28. 'attachurl': '{$_W['attachurl']}',
  29. 'attachurl_local': '{$_W['attachurl_local']}',
  30. 'attachurl_remote': '{$_W['attachurl_remote']}',
  31. 'module': {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
  32. 'cookie': {'pre': ''},
  33. 'account': {:json_encode($_W['account'])},
  34. };
  35. </script>
  36. <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  37. <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  38. <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  39. <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  40. <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  41. <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  42. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  43. <link href="/static/css/snailfish.css" rel="stylesheet">
  44. <style>
  45. .full>span {
  46. display: -webkit-box;
  47. display: -webkit-flex;
  48. display: -ms-flexbox;
  49. display: flex;
  50. vertical-align: middle;
  51. align-items: center;
  52. }
  53. </style>
  54. </head>
  55. <body layadmin-themealias="default">
  56. <div class="layui-fluid">
  57. <div class="layui-card">
  58. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text">菜谱管理</span></div>
  59. <div class="layui-card-body" style="padding:15px;">
  60. <form action="" method="get" class="form-horizontal form-search layui-form" role="form">
  61. <input type="hidden" name="c" value="recipe" />
  62. <input type="hidden" name="a" value="index" />
  63. <div class="layui-form-item">
  64. <div class="layui-inline">
  65. <div class="layui-input-inline">
  66. <input type="text" class="layui-input" name='keyword' value="{$_GPC['keyword']}" placeholder="输入关键词然后回车">
  67. </div>
  68. <div class="layui-input-inline" >
  69. <select name="state" class='layui-input layui-unselect' >
  70. <option value="-1" <?php if( !isset($_GPC['state']) || $_GPC['state'] == -1 ){ ?>selected<?php } ?> >状态</option>
  71. <option value="1" <?php if( $_GPC['state']==1 ){ ?>selected<?php } ?> >启用</option>
  72. <option value="0" <?php if( isset($_GPC['state']) && $_GPC['state']==0 ){ ?>selected<?php } ?> >禁用</option>
  73. </select>
  74. </div>
  75. <div class="layui-input-inline" >
  76. <select name="cate" class='layui-input layui-unselect' style="width:200px;" >
  77. <option value="" <?php if( empty($_GPC['cate']) ){ ?>selected<?php } ?> >分类</option>
  78. <?php foreach($category as $c){ ?>
  79. <option value="{$c['id']}" <?php if( $_GPC['cate']==$c['id'] ){ ?>selected<?php } ?> >{$c['name']}</option>
  80. <?php } ?>
  81. </select>
  82. </div>
  83. <div class="layui-input-inline">
  84. <button class="layui-btn layui-btn-sm" type="submit"> 搜索</button>
  85. </div>
  86. </div>
  87. </div>
  88. </form>
  89. <form action="" class="layui-form" lay-filter="example" method="post" >
  90. <div class="row">
  91. <div class="col-md-12">
  92. <div class="page-table-header">
  93. <span class="pull-right">
  94. <a href="{:U('recipe/add', array('ok' => 1))}" class="layui-btn layui-btn-sm"><i class="fa fa-plus"></i> 添加菜谱</a>
  95. </span>
  96. <div class="btn-group">
  97. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除吗?" data-href="{:U('recipe/delete')}">删除</button>
  98. </div>
  99. </div>
  100. <table class="layui-table" lay-skin="line" lay-size="lg" style="word-break:break-all;">
  101. <thead>
  102. <tr>
  103. <th style="width:25px;"><input type='checkbox' name="checkall" lay-skin="primary" lay-filter="checkboxall" /></th>
  104. <th style="width:80px;">ID</th>
  105. <th style="">菜谱名称</th>
  106. <th style="">菜谱分类</th>
  107. <th style="">菜谱关联会员</th>
  108. <th style="">菜谱商品数量</th>
  109. <th style="">发布时间</th>
  110. <th style="">状态</th>
  111. <th style="width: 200px;">操作</th>
  112. </tr>
  113. </thead>
  114. <tbody>
  115. <?php foreach($list as $item){ ?>
  116. <tr>
  117. <td style="width:25px;">
  118. <input type='checkbox' name="item_checkbox" lay-skin="primary" value="{$item['id']}"/>
  119. </td>
  120. <td>
  121. {$item['id']}
  122. </td>
  123. <td class="full">
  124. <span>{$item['recipe_name']}</span>
  125. </td>
  126. <td>
  127. {$item['cate_name']}
  128. </td>
  129. <td>
  130. {$item['username']}
  131. </td>
  132. <td>
  133. {$item['goods_count']}
  134. </td>
  135. <td>
  136. <?php echo date('Y-m-d H:i:s',$item['addtime']); ?>
  137. </td>
  138. <td>
  139. <input type="checkbox" name="" lay-filter="is_index_showsitch" data-href="{:U('recipe/change',array('type'=>'state','id'=>$item['id']))}" <?php if( $item['state']==1 ){ ?>checked<?php } ?> lay-skin="switch" lay-text="启用|禁用">
  140. </td>
  141. <td style="overflow:visible;position:relative">
  142. <a class='layui-btn layui-btn-xs' href="{:U('recipe/add', array('id'=>$item['id'],'ok' => 1))}" >
  143. <i class="layui-icon layui-icon-edit"></i>编辑
  144. </a>
  145. <a class='layui-btn layui-btn-xs deldom' href="javascript:;" data-href="{:U('recipe/delete',array('id'=>$item['id']))}" data-confirm='确认要删除吗?'>
  146. <i class="layui-icon">&#xe640;</i>删除
  147. </a>
  148. </td>
  149. </tr>
  150. <?php } ?>
  151. </tbody>
  152. <tfoot>
  153. <tr>
  154. <td colspan="4">
  155. <div class="page-table-header">
  156. <input type="checkbox" name="checkall" lay-skin="primary" lay-filter="checkboxall">
  157. <div class="btn-group">
  158. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除吗?" data-href="{:U('recipe/delete')}">删除</button>
  159. </div>
  160. </div>
  161. </td>
  162. <td colspan="5" style="text-align: right">
  163. {$pager}
  164. </td>
  165. </tr>
  166. </tfoot>
  167. </table>
  168. </div>
  169. </div>
  170. </form>
  171. </div>
  172. </div>
  173. </div>
  174. <script src="/layuiadmin/layui/layui.js"></script>
  175. <script>
  176. layui.config({
  177. base: '/layuiadmin/' //静态资源所在路径
  178. }).extend({
  179. index: 'lib/index' //主入口模块
  180. }).use('index');
  181. </script>
  182. <script>
  183. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  184. var layer = layui.layer;
  185. var $;
  186. layui.use(['jquery', 'layer','form'], function(){
  187. $ = layui.$;
  188. var form = layui.form;
  189. form.on('switch(is_index_showsitch)', function(data){
  190. var s_url = $(this).attr('data-href')
  191. var is_index_show = 1;
  192. if(data.elem.checked)
  193. {
  194. is_index_show = 1;
  195. }else{
  196. is_index_show = 0;
  197. }
  198. $.ajax({
  199. url:s_url,
  200. type:'post',
  201. dataType:'json',
  202. data:{value:is_index_show},
  203. success:function(info){
  204. if(info.status == 0)
  205. {
  206. layer.msg(info.result.message,{icon: 1,time: 2000});
  207. }else if(info.status == 1){
  208. var go_url = location.href;
  209. if( info.result.hasOwnProperty("url") )
  210. {
  211. go_url = info.result.url;
  212. }
  213. layer.msg('操作成功',{time: 1000,
  214. end:function(){
  215. location.href = info.result.url;
  216. }
  217. });
  218. }
  219. }
  220. })
  221. });
  222. $('.deldom').click(function(){
  223. var s_url = $(this).attr('data-href');
  224. layer.confirm($(this).attr('data-confirm'), function(index){
  225. $.ajax({
  226. url:s_url,
  227. type:'post',
  228. dataType:'json',
  229. success:function(info){
  230. if(info.status == 0)
  231. {
  232. layer.msg(info.result.message,{icon: 1,time: 2000});
  233. }else if(info.status == 1){
  234. var go_url = location.href;
  235. if( info.result.hasOwnProperty("url") )
  236. {
  237. go_url = info.result.url;
  238. }
  239. layer.msg('操作成功',{time: 1000,
  240. end:function(){
  241. location.href = info.result.url;
  242. }
  243. });
  244. }
  245. }
  246. })
  247. });
  248. })
  249. $('.btn-operation').click(function(){
  250. var ids_arr = [];
  251. var obj = $(this);
  252. var s_toggle = $(this).attr('data-toggle');
  253. var s_url = $(this).attr('data-href');
  254. $("input[name=item_checkbox]").each(function() {
  255. if( $(this).prop('checked') )
  256. {
  257. ids_arr.push( $(this).val() );
  258. }
  259. })
  260. if(ids_arr.length < 1)
  261. {
  262. layer.msg('请选择要操作的内容');
  263. }else{
  264. var can_sub = true;
  265. if( s_toggle == 'batch-remove' )
  266. {
  267. can_sub = false;
  268. layer.confirm($(obj).attr('data-confirm'), function(index){
  269. $.ajax({
  270. url:s_url,
  271. type:'post',
  272. dataType:'json',
  273. data:{ids:ids_arr},
  274. success:function(info){
  275. if(info.status == 0)
  276. {
  277. layer.msg(info.result.message,{icon: 1,time: 2000});
  278. }else if(info.status == 1){
  279. var go_url = location.href;
  280. if( info.result.hasOwnProperty("url") )
  281. {
  282. go_url = info.result.url;
  283. }
  284. layer.msg('操作成功',{time: 1000,
  285. end:function(){
  286. location.href = info.result.url;
  287. }
  288. });
  289. }
  290. }
  291. })
  292. });
  293. }else{
  294. $.ajax({
  295. url:s_url,
  296. type:'post',
  297. dataType:'json',
  298. data:{ids:ids_arr},
  299. success:function(info){
  300. if(info.status == 0)
  301. {
  302. layer.msg(info.result.message,{icon: 1,time: 2000});
  303. }else if(info.status == 1){
  304. var go_url = location.href;
  305. if( info.result.hasOwnProperty("url") )
  306. {
  307. go_url = info.result.url;
  308. }
  309. layer.msg('操作成功',{time: 1000,
  310. end:function(){
  311. location.href = info.result.url;
  312. }
  313. });
  314. }
  315. }
  316. })
  317. }
  318. }
  319. })
  320. form.on('switch(statewsitch)', function(data){
  321. var s_url = $(this).attr('data-href')
  322. var s_value = 1;
  323. if(data.elem.checked)
  324. {
  325. s_value = 1;
  326. }else{
  327. s_value = 0;
  328. }
  329. $.ajax({
  330. url:s_url,
  331. type:'post',
  332. dataType:'json',
  333. data:{value:s_value},
  334. success:function(info){
  335. if(info.status == 0)
  336. {
  337. layer.msg(info.result.message,{icon: 1,time: 2000});
  338. }else if(info.status == 1){
  339. var go_url = location.href;
  340. if( info.result.hasOwnProperty("url") )
  341. {
  342. go_url = info.result.url;
  343. }
  344. layer.msg('操作成功',{time: 1000,
  345. end:function(){
  346. location.href = info.result.url;
  347. }
  348. });
  349. }
  350. }
  351. })
  352. });
  353. form.on('checkbox(checkboxall)', function(data){
  354. if(data.elem.checked)
  355. {
  356. $("input[name=item_checkbox]").each(function() {
  357. $(this).prop("checked", true);
  358. });
  359. $("input[name=checkall]").each(function() {
  360. $(this).prop("checked", true);
  361. });
  362. }else{
  363. $("input[name=item_checkbox]").each(function() {
  364. $(this).prop("checked", false);
  365. });
  366. $("input[name=checkall]").each(function() {
  367. $(this).prop("checked", false);
  368. });
  369. }
  370. form.render('checkbox');
  371. });
  372. //监听提交
  373. form.on('submit(formDemo)', function(data){
  374. $.ajax({
  375. url: data.form.action,
  376. type: data.form.method,
  377. data: data.field,
  378. dataType:'json',
  379. success: function (info) {
  380. if(info.status == 0)
  381. {
  382. layer.msg(info.result.message,{icon: 1,time: 2000});
  383. }else if(info.status == 1){
  384. var go_url = location.href;
  385. if( info.result.hasOwnProperty("url") )
  386. {
  387. go_url = info.result.url;
  388. }
  389. layer.msg('操作成功',{time: 1000,
  390. end:function(){
  391. location.href = info.result.url;
  392. }
  393. });
  394. }
  395. }
  396. });
  397. return false;
  398. });
  399. })
  400. </script>
  401. </body>
  402. </html>