adduser.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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">
  49. <?php if(!empty($item['s_id'])){ ?>编辑<?php }else{ ?>添加<?php } ?>操作员 <small><?php if(!empty($item['s_id'])){ ?>修改【{$item['s_true_name']}】<?php } ?></small>
  50. </span></div>
  51. <div class="layui-card-body" style="padding:15px;">
  52. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
  53. <input type="hidden" name="s_id" value="{$item['s_id']}" />
  54. <div class="layui-form-item">
  55. <label class="layui-form-label must">登录用户名</label>
  56. <div class="col-sm-9 col-xs-12">
  57. <input type="text" name="s_uname" class="form-control" value="{$item['s_uname']}" data-rule-required=true autocomplete="off" />
  58. <span class='help-block'></span>
  59. </div>
  60. </div>
  61. <div class="layui-form-item">
  62. <label class="layui-form-label must">登录密码</label>
  63. <div class="col-sm-9 col-xs-12">
  64. <input type="password" name="s_passwd" class="form-control" value="" autocomplete="off" <?php if(empty($item['s_passwd'])){ ?>data-rule-required='true' <?php } ?> />
  65. <span class='help-block'>如果您编辑密码,不填写,则不修改</span>
  66. </div>
  67. </div>
  68. <div class="layui-form-item">
  69. <label class="layui-form-label">所属角色</label>
  70. <div class="col-sm-9 col-xs-12">
  71. <input type='hidden' id='userid' name='roleid' value="{$role['id']}" />
  72. <div class='input-group'>
  73. <input type="text" name="user" maxlength="30" value="{$role['rolename']}" id="user" class="form-control" readonly />
  74. <div class='input-group-btn'>
  75. <button class="btn btn-default" type="button" onclick="popwin = $('#modal-module-menus1').modal();">选择角色</button>
  76. <button class="btn btn-danger" type="button" onclick="$('#userid').val('');$('#user').val('');">清除选择</button>
  77. </div>
  78. </div>
  79. <span class='help-block'>如果您选择了角色,则此用户本身就继承了此角色的所有权限</span>
  80. <div id="modal-module-menus1" class="modal fade" tabindex="-1">
  81. <div class="modal-dialog" style='width: 920px;'>
  82. <div class="modal-content">
  83. <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>选择角色</h3></div>
  84. <div class="modal-body" >
  85. <div class="row">
  86. <div class="input-group">
  87. <input type="text" class="form-control" name="keyword" value="" id="search-kwd1" placeholder="请输入角色名称" />
  88. <span class='input-group-btn'><button type="button" class="btn btn-default" onclick="search_users();">搜索</button></span>
  89. </div>
  90. </div>
  91. <div id="usertable" style='max-height:500px;overflow:auto;min-width:850px;'>
  92. <table class="table table-hover" style="min-width:850px;">
  93. <tbody>
  94. <?php foreach($ds as $row){ ?>
  95. <tr>
  96. <td><?php echo $row['rolename']; ?></td>
  97. <td style="width:80px;"><a href="javascript:;" onclick='select_role(<?php echo json_encode($row); ?>)'>选择</a></td>
  98. </tr>
  99. <?php } ?>
  100. <?php if( count($ds)<=0 ){ ?>
  101. <tr>
  102. <td colspan='2' align='center'>未找到角色</td>
  103. </tr>
  104. <?php } ?>
  105. </tbody>
  106. </table>
  107. </div>
  108. <div id="module-menus1" style="padding-top:5px;"></div>
  109. </div>
  110. <div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a></div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="layui-form-item">
  117. <label class="layui-form-label">管理员姓名</label>
  118. <div class="layui-input-block">
  119. <input type="text" name="s_true_name" class="form-control" value="{$item['s_true_name']}" />
  120. </div>
  121. </div>
  122. <div class="layui-form-item">
  123. <label class="layui-form-label">管理员电话</label>
  124. <div class="layui-input-block">
  125. <input type="text" name="s_mobile" class="form-control" value="{$item['s_mobile']}" />
  126. </div>
  127. </div>
  128. <div class="layui-form-item">
  129. <label class="layui-form-label">管理员状态</label>
  130. <div class="layui-input-block">
  131. <label class='radio-inline'>
  132. <input type='radio' name='s_status' <?php if($item['s_id'] == 1){ ?> disabled="disabled" <?php } ?> value=1' <?php if(empty($item) || $item['s_status']==1){ ?>checked<?php } ?> title="启用" />
  133. </label>
  134. <label class='radio-inline'>
  135. <input type='radio' name='s_status' <?php if($item['s_id'] == 1){ ?> disabled="disabled" <?php } ?> value=0' <?php if(!empty($item) && $item['s_status']==0){ ?>checked<?php } ?> title="禁用" />
  136. </label>
  137. </div>
  138. </div>
  139. <div class="layui-form-item">
  140. <label class="layui-form-label"> </label>
  141. <div class="layui-input-block">
  142. <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary" />
  143. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  144. </div>
  145. </div>
  146. </form>
  147. </div>
  148. </div>
  149. </div>
  150. <script src="/layuiadmin/layui/layui.js"></script>
  151. <script>
  152. layui.config({
  153. base: '/layuiadmin/' //静态资源所在路径
  154. }).extend({
  155. index: 'lib/index' //主入口模块
  156. }).use('index');
  157. </script>
  158. <script>
  159. var layer = layui.layer;
  160. var $;
  161. var cur_open_div;
  162. layui.use(['jquery', 'layer','form'], function(){
  163. $ = layui.$;
  164. var form = layui.form;
  165. form.on('radio(linktype)', function(data){
  166. if (data.value == 2) {
  167. $('#typeGroup').show();
  168. } else {
  169. $('#typeGroup').hide();
  170. }
  171. });
  172. $('#chose_link').click(function(){
  173. cur_open_div = $(this).attr('data-input');
  174. $.post("{:U('util.selecturl', array('ok' => 1))}", {}, function(shtml){
  175. layer.open({
  176. type: 1,
  177. area: '930px',
  178. content: shtml //注意,如果str是object,那么需要字符拼接。
  179. });
  180. });
  181. })
  182. form.verify({
  183. title: [
  184. /^[\S]{1,}$/,'标题不能为空'
  185. ]
  186. });
  187. //监听提交
  188. form.on('submit(formDemo)', function(data){
  189. $.ajax({
  190. url: data.form.action,
  191. type: data.form.method,
  192. data: data.field,
  193. dataType:'json',
  194. success: function (info) {
  195. if(info.status == 0)
  196. {
  197. layer.msg('此用户为系统存在用户,无法添加',{icon: 1,time: 2000});
  198. }else if(info.status == 1){
  199. var go_url = location.href;
  200. if( info.result.hasOwnProperty("url") )
  201. {
  202. go_url = info.result.url;
  203. }
  204. layer.msg('操作成功',{time: 1000,
  205. end:function(){
  206. location.href = "{:U('perm/user')}";
  207. }
  208. });
  209. }
  210. }
  211. });
  212. return false;
  213. });
  214. })
  215. </script>
  216. <script language='javascript'>
  217. function search_users() {
  218. $("#module-menus1").html("正在搜索....")
  219. $("#usertable").hide();
  220. $.get('{:U("perm/rolequery")}', {
  221. keyword: $.trim($('#search-kwd1').val())
  222. }, function(dat){
  223. $('#module-menus1').html(dat);
  224. });
  225. }
  226. function select_role(o) {
  227. $("#userid").val(o.id);
  228. $("#user").val( o.rolename );
  229. var perms = o.perms2.split(',');
  230. $(':checkbox').removeAttr('disabled').removeAttr('checked').each(function(){
  231. var _this = $(this);
  232. var perm = '';
  233. if( _this.data('group') ){
  234. perm+=_this.data('group');
  235. }
  236. if( _this.data('parent') ){
  237. if (_this.data('parent') != 'text') {
  238. perm += "." + _this.data('parent');
  239. }
  240. }
  241. if( _this.data('son') ){
  242. if (_this.data('son') != 'text') {
  243. perm += "." + _this.data('son');
  244. }
  245. }
  246. if( _this.data('grandson') ){
  247. if (_this.data('grandson') != 'text') {
  248. perm += "." + _this.data('grandson');
  249. }
  250. }
  251. if( $.arrayIndexOf(perms,perm)!=-1){
  252. $(this).attr('disabled',true).get(0).checked =true;
  253. }
  254. });
  255. $(".close").click();
  256. }
  257. </script>
  258. </body>
  259. </html>