index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. </head>
  45. <body layadmin-themealias="default">
  46. <div class="layui-fluid">
  47. <div class="layui-card">
  48. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text">角色管理</span></div>
  49. <div class="layui-card-body" style="padding:15px;">
  50. <form action="" method="get" class="form-horizontal form-search layui-form" role="form">
  51. <input type="hidden" name="c" value="perm" />
  52. <input type="hidden" name="a" value="index" />
  53. <div class="layui-form-item">
  54. <div class="layui-inline">
  55. <div class="layui-input-inline" >
  56. <select name="status" class='form-control'>
  57. <option value="" <?php if($gpc['status'] == ''){ ?>selected<?php } ?>>状态</option>
  58. <option value="1" <?php if($gpc['status']== '1'){ ?> selected<?php } ?>>启用</option>
  59. <option value="0" <?php if($gpc['status'] == '0'){ ?> selected<?php } ?>>禁用</option>
  60. </select>
  61. </div>
  62. <div class="layui-input-inline">
  63. <input type="text" class="layui-input" name='keyword' value="{$gpc['keyword']}" placeholder="请输入关键词">
  64. </div>
  65. <div class="layui-input-inline">
  66. <button class="layui-btn layui-btn-sm" type="submit"> 搜索</button>
  67. </div>
  68. </div>
  69. </div>
  70. </form>
  71. <form action="" class="layui-form" lay-filter="example" method="post" >
  72. <div class="row">
  73. <div class="col-md-12">
  74. <div class="page-table-header">
  75. <span class="pull-right">
  76. <a href="{:U('perm/addrole')}" class="layui-btn layui-btn-sm"><i class="fa fa-plus"></i> 添加新角色</a>
  77. </span>
  78. <div class="btn-group">
  79. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:U('perm/rolestatus',array('status'=>1))}">启用</button>
  80. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:U('perm/rolestatus',array('status'=>0))}">禁用</button>
  81. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{:U('perm/roledelete')}">删除</button>
  82. </div>
  83. </div>
  84. <table class="layui-table" lay-skin="line" lay-size="lg">
  85. <thead>
  86. <tr>
  87. <th style="width:25px;">
  88. <input type='checkbox' name="checkall" lay-skin="primary" lay-filter="checkboxall" />
  89. </th>
  90. <th>角色名称</th>
  91. <th>操作员数量</th>
  92. <th>状态</th>
  93. <th style="width: 265px;">操作</th>
  94. </tr>
  95. </thead>
  96. <tbody>
  97. <?php foreach($list as $row){ ?>
  98. <tr>
  99. <td>
  100. <input type='checkbox' name="item_checkbox" lay-skin="primary" value="{$row['id']}"/>
  101. </td>
  102. <td>{$row['rolename']}</td>
  103. <td>{$row['usercount']}</td>
  104. <td>
  105. <input type="checkbox" name="" lay-filter="statewsitch" data-href="{:U('perm/rolestatus',array('id'=>$row['id']))}" <?php if( $row['status']==1){ ?>checked<?php }else{ ?><?php } ?> lay-skin="switch" lay-text="启用|禁用">
  106. </td>
  107. <td>
  108. <a class='layui-btn layui-btn-xs' href="{:U('perm/addrole', array('id' => $row['id']))}" >
  109. <i class="layui-icon layui-icon-edit"></i>编辑
  110. </a>
  111. <a class='layui-btn layui-btn-xs deldom' href="javascript:;" data-href="{:U('perm/roledelete', array('id' => $row['id']))}" data-confirm='确认要删除吗?'>
  112. <i class="layui-icon">&#xe640;</i>删除
  113. </a>
  114. </td>
  115. </tr>
  116. <?php } ?>
  117. </tbody>
  118. <tfoot>
  119. <tr>
  120. <td colspan="3">
  121. <div class="page-table-header">
  122. <input type="checkbox" name="checkall" lay-skin="primary" lay-filter="checkboxall">
  123. <div class="btn-group">
  124. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:U('perm/rolestatus',array('status'=>1))}">启用</button>
  125. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{:U('perm/rolestatus',array('status'=>0))}">禁用</button>
  126. <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{:U('perm/roledelete')}">删除</button>
  127. </div>
  128. </div>
  129. </td>
  130. <td colspan="2" style="text-align: right">
  131. {$pager}
  132. </td>
  133. </tr>
  134. </tfoot>
  135. </table>
  136. </div>
  137. </div>
  138. </form>
  139. </div>
  140. </div>
  141. </div>
  142. <script src="/layuiadmin/layui/layui.js"></script>
  143. <script>
  144. layui.config({
  145. base: '/layuiadmin/' //静态资源所在路径
  146. }).extend({
  147. index: 'lib/index' //主入口模块
  148. }).use('index');
  149. </script>
  150. <script>
  151. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  152. var layer = layui.layer;
  153. var $;
  154. layui.use(['jquery', 'layer','form'], function(){
  155. $ = layui.$;
  156. var form = layui.form;
  157. $('.deldom').click(function(){
  158. var s_url = $(this).attr('data-href');
  159. layer.confirm($(this).attr('data-confirm'), function(index){
  160. $.ajax({
  161. url:s_url,
  162. type:'post',
  163. dataType:'json',
  164. success:function(info){
  165. if(info.status == 0)
  166. {
  167. layer.msg(info.result.message,{icon: 1,time: 2000});
  168. }else if(info.status == 1){
  169. var go_url = location.href;
  170. if( info.result.hasOwnProperty("url") )
  171. {
  172. go_url = info.result.url;
  173. }
  174. layer.msg('操作成功',{time: 1000,
  175. end:function(){
  176. location.href = info.result.url;
  177. }
  178. });
  179. }
  180. }
  181. })
  182. });
  183. })
  184. $('.btn-operation').click(function(){
  185. var ids_arr = [];
  186. var obj = $(this);
  187. var s_toggle = $(this).attr('data-toggle');
  188. var s_url = $(this).attr('data-href');
  189. $("input[name=item_checkbox]").each(function() {
  190. if( $(this).prop('checked') )
  191. {
  192. ids_arr.push( $(this).val() );
  193. }
  194. })
  195. if(ids_arr.length < 1)
  196. {
  197. layer.msg('请选择要操作的内容');
  198. }else{
  199. var can_sub = true;
  200. if( s_toggle == 'batch-remove' )
  201. {
  202. can_sub = false;
  203. layer.confirm($(obj).attr('data-confirm'), function(index){
  204. $.ajax({
  205. url:s_url,
  206. type:'post',
  207. dataType:'json',
  208. data:{ids:ids_arr},
  209. success:function(info){
  210. if(info.status == 0)
  211. {
  212. layer.msg(info.result.message,{icon: 1,time: 2000});
  213. }else if(info.status == 1){
  214. var go_url = location.href;
  215. if( info.result.hasOwnProperty("url") )
  216. {
  217. go_url = info.result.url;
  218. }
  219. layer.msg('操作成功',{time: 1000,
  220. end:function(){
  221. location.href = info.result.url;
  222. }
  223. });
  224. }
  225. }
  226. })
  227. });
  228. }else{
  229. $.ajax({
  230. url:s_url,
  231. type:'post',
  232. dataType:'json',
  233. data:{ids:ids_arr},
  234. success:function(info){
  235. if(info.status == 0)
  236. {
  237. layer.msg(info.result.message,{icon: 1,time: 2000});
  238. }else if(info.status == 1){
  239. var go_url = location.href;
  240. if( info.result.hasOwnProperty("url") )
  241. {
  242. go_url = info.result.url;
  243. }
  244. layer.msg('操作成功',{time: 1000,
  245. end:function(){
  246. location.href = info.result.url;
  247. }
  248. });
  249. }
  250. }
  251. })
  252. }
  253. }
  254. })
  255. form.on('switch(statewsitch)', function(data){
  256. var s_url = $(this).attr('data-href')
  257. var s_value = 1;
  258. if(data.elem.checked)
  259. {
  260. s_value = 1;
  261. }else{
  262. s_value = 0;
  263. }
  264. $.ajax({
  265. url:s_url,
  266. type:'post',
  267. dataType:'json',
  268. data:{status:s_value},
  269. success:function(info){
  270. if(info.status == 0)
  271. {
  272. layer.msg(info.result.message,{icon: 1,time: 2000});
  273. }else if(info.status == 1){
  274. var go_url = location.href;
  275. if( info.result.hasOwnProperty("url") )
  276. {
  277. go_url = info.result.url;
  278. }
  279. layer.msg('操作成功',{time: 1000,
  280. end:function(){
  281. location.href = info.result.url;
  282. }
  283. });
  284. }
  285. }
  286. })
  287. });
  288. form.on('checkbox(checkboxall)', function(data){
  289. if(data.elem.checked)
  290. {
  291. $("input[name=item_checkbox]").each(function() {
  292. $(this).prop("checked", true);
  293. });
  294. $("input[name=checkall]").each(function() {
  295. $(this).prop("checked", true);
  296. });
  297. }else{
  298. $("input[name=item_checkbox]").each(function() {
  299. $(this).prop("checked", false);
  300. });
  301. $("input[name=checkall]").each(function() {
  302. $(this).prop("checked", false);
  303. });
  304. }
  305. form.render('checkbox');
  306. });
  307. //监听提交
  308. form.on('submit(formDemo)', function(data){
  309. $.ajax({
  310. url: data.form.action,
  311. type: data.form.method,
  312. data: data.field,
  313. dataType:'json',
  314. success: function (info) {
  315. if(info.status == 0)
  316. {
  317. layer.msg(info.result.message,{icon: 1,time: 2000});
  318. }else if(info.status == 1){
  319. var go_url = location.href;
  320. if( info.result.hasOwnProperty("url") )
  321. {
  322. go_url = info.result.url;
  323. }
  324. layer.msg('操作成功',{time: 1000,
  325. end:function(){
  326. location.href = info.result.url;
  327. }
  328. });
  329. }
  330. }
  331. });
  332. return false;
  333. });
  334. })
  335. </script>
  336. </body>
  337. </html>