index.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. {extend name='table'}
  2. {block name="button"}
  3. {if isset($type) and $type eq 'index'}
  4. <!--{if auth("add")}-->
  5. <button data-modal='{:url("add")}' data-title="添加用户" class='layui-btn layui-btn-sm layui-btn-primary'>添加用户</button>
  6. <!--{/if}-->
  7. <!--{if auth("state")}-->
  8. <a data-confirm="确定要启用该用户吗?" data-table-id="UserTable" data-action="{:url('state')}" data-rule="id#{id};status#0" class='layui-btn layui-btn-sm layui-btn-primary'>批量禁用</a>
  9. <!--{/if}-->
  10. {else}
  11. <!--{if auth("state")}-->
  12. <a data-confirm="确定要恢复这些账号吗?" data-table-id="UserTable" data-action="{:url('state')}" data-rule="id#{id};status#1" class='layui-btn layui-btn-sm layui-btn-primary'>批量恢复</a>
  13. <!--{/if}-->
  14. <!--{if auth("remove")}-->
  15. <a data-confirm="确定永久删除这些账号吗?" data-table-id="UserTable" data-action='{:url("remove")}' data-rule="id#{id}" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</a>
  16. <!--{/if}-->
  17. {/if}
  18. {/block}
  19. {block name="content"}
  20. <div class="layui-tab layui-tab-card">
  21. <ul class="layui-tab-title">
  22. {foreach ['index'=>'系统用户','recycle'=>'回 收 站'] as $k=>$v}{if isset($type) and $type eq $k}
  23. <li data-open="{:url('index')}?type={$k}" class="layui-this">{$v}</li>
  24. {else}
  25. <li data-open="{:url('index')}?type={$k}">{$v}</li>
  26. {/if}{/foreach}
  27. </ul>
  28. <div class="layui-tab-content">
  29. {include file='user/index_search'}
  30. <table id="UserTable" data-url="{:sysuri('index')}" data-target-search="form.form-search"></table>
  31. </div>
  32. </div>
  33. <script>
  34. $(function () {
  35. $('#UserTable').layTable({
  36. even: true, height: 'full',
  37. sort: {field: 'sort desc,id', type: 'desc'},
  38. where: {type: '{$type|default="index"}'},
  39. cols: [[
  40. {checkbox: true, fixed: true},
  41. {field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTpl'},
  42. {
  43. field: 'headimg', title: '头像', width: 60, align: 'center', templet: function (d) {
  44. if (!d.headimg) return '-';
  45. return layui.laytpl('<div class="headimg headimg-ss shadow-inset margin-0" data-tips-image data-tips-hover data-lazy-src="{{d.headimg}}"></div>').render(d);
  46. }
  47. },
  48. {field: 'username', title: '登录账号', minWidth: 100, align: 'center', templet: '<div>{{d.username||"-"}}</div>'},
  49. {field: 'nickname', title: '用户名称', minWidth: 100, align: 'center', templet: '<div>{{d.nickname||"-"}}</div>'},
  50. /* {notempty name='bases'} */
  51. {
  52. field: 'usertype', title: '角色身份', minWidth: 100, align: 'center', templet: function (d) {
  53. d.userinfo = d.userinfo || {};
  54. return d.userinfo.code ? (d.userinfo.name + ' ( ' + d.userinfo.code + ' ) ') : '-';
  55. }
  56. },
  57. /* {/notempty} */
  58. // {field: 'contact_mail', title: '联系邮箱', minWidth: 80, templet: '<div>{{d.contact_mail||"-"}}</div>'},
  59. // {field: 'contact_phone', title: '联系电话', minWidth: 80, templet: '<div>{{d.contact_phone||"-"}}</div>'},
  60. {field: 'status', title: '账号状态', align: 'center', minWidth: 110, templet: '#StatusSwitchTpl'},
  61. {field: 'login_num', title: '登录次数', align: 'center', minWidth: 100, sort: true},
  62. {field: 'usertype', title: '类型', align: 'center', minWidth: 110,templet: function (d) {
  63. if (d.usertype=='admin'){
  64. return '后台用户';
  65. }else if (d.usertype=='shop'){
  66. return '商家';
  67. }else if (d.usertype=='shipyard'){
  68. return '船厂'
  69. }
  70. }},
  71. {field: 'login_at', title: '最后登录', align: 'center', minWidth: 170, sort: true},
  72. {field: 'create_at', title: '创建时间', align: 'center', minWidth: 170, sort: true},
  73. {toolbar: '#toolbar', title: '操作面板', align: 'center', minWidth: 150, fixed: 'right'}
  74. ]]
  75. });
  76. // 数据状态切换操作
  77. layui.form.on('switch(StatusSwitch)', function (obj) {
  78. var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
  79. $.form.load("{:url('state')}", data, 'post', function (ret) {
  80. if (ret.code < 1) $.msg.error(ret.info, 3, function () {
  81. $('#UserTable').trigger('reload');
  82. }); else {
  83. $('#UserTable').trigger('reload')
  84. }
  85. return false;
  86. }, false);
  87. });
  88. });
  89. </script>
  90. <!-- 数据状态切换模板 -->
  91. <script type="text/html" id="StatusSwitchTpl">
  92. <!--{if auth("state")}-->
  93. <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{-d.status>0?'checked':''}}>
  94. <!--{else}-->
  95. {{-d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
  96. <!--{/if}-->
  97. </script>
  98. <!-- 列表排序权重模板 -->
  99. <script type="text/html" id="SortInputTpl">
  100. <input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
  101. </script>
  102. <script type="text/html" id="toolbar">
  103. {if isset($type) and $type eq 'index'}
  104. <!--{if auth("edit")}-->
  105. <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="编辑用户" data-modal='{:url("edit")}?id={{d.id}}'>编 辑</a>
  106. <!--{/if}-->
  107. <!--{if auth("pass")}-->
  108. <a class="layui-btn layui-btn-sm layui-btn-normal" data-title="设置密码" data-modal='{:url("pass")}?id={{d.id}}'>密 码</a>
  109. <!--{/if}-->
  110. {else}
  111. <!--{if auth("edit")}-->
  112. <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="编辑用户" data-modal='{:url("edit")}?id={{d.id}}'>编 辑</a>
  113. <!--{/if}-->
  114. <!--{if auth("remove")}-->
  115. <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要永久删除此账号吗?" data-action="{:url('remove')}" data-value="id#{{d.id}}">删 除</a>
  116. <!--{/if}-->
  117. {/if}
  118. </script>
  119. {/block}