123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- {extend name="common/base" /}
- <!-- 主体 -->
- {block name="body"}
- <div class="p-3">
- <form class="layui-form gg-form-bar border-t border-x">
- <div class="layui-input-inline" style="width:300px;">
- <input type="text" name="keywords" placeholder="名称/备注" class="layui-input" autocomplete="off" />
- </div>
- <div class="layui-input-inline">
- <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
- </div>
- </form>
- <table class="layui-hide" id="role" lay-filter="role"></table>
- </div>
- <script type="text/html" id="status">
- <i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
- </script>
- <script type="text/html" id="toolbarDemo">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-sm" lay-event="add">+ 添加权限组</button>
- </div>
- </script>
- {/block}
- <!-- /主体 -->
- <!-- 脚本 -->
- {block name="script"}
- <script>
- const moduleInit = ['tool'];
- function gouguInit() {
- var table = layui.table, tool = layui.tool, form = layui.form;
- var allcount;
- layui.pageTable = table.render({
- elem: '#role',
- toolbar: '#toolbarDemo',
- url: "/admin/role/index", //数据接口
- page: true, //开启分页
- limit: 20,
- parseData: function(res) { // 数据解析回调函数
- // 在这里可以获取数据总数
- allcount = res.count;
- return {
- code: res.code, // 数据状态码
- msg: res.msg, // 状态信息
- count: res.count, // 数据总数
- data: res.data // 当前页数据
- };
- },
- cols: [[ //表头
- {
- fixed: 'left', field: 'id', title: '编号', align: 'center', width: 80,
- templet: function(d){
- return allcount - (d.LAY_NUM-1);
- }
- },
- { field: 'title', title: '权限组名称', width: 200 },
- { field: 'd_title', title: '所属单位', width: 200 },
- { field: 'desc', title: '备注' },
- {
- field: 'user', title: '使用用户' ,templet:function (admin) {
- // console.log(1);
- // console.log(admin);
- // console.log(1);
- var user = '';
- for(i = 0; i < admin.admin.length; i++){
-
- if(i < admin.admin.length - 1){
- user = user + admin.admin[i]['nickname'] + ',';
- console.log(user);
- continue;
- }
- user = user + admin.admin[i]['nickname'];
- }
- return '用户量:' + admin.admin.length + ';' + user;
- }
-
- },
- { field: 'status', title: '状态', toolbar: '#status', align: 'center', width: 80 },
- { field: 'operator', title: '操作员', align: 'center', width: 100 },
- { width: 100,title: '操作',align: 'center',templet: function (d) {
- var html = '<div class="layui-btn-group"><button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button></div>';
- return html;
- }
- }
- ]]
- });
-
- //表头工具栏事件
- table.on('toolbar(role)', function(obj){
- if (obj.event === 'add') {
- tool.side("/admin/role/add");
- return;
- }
- });
- //监听行工具事件
- table.on('tool(role)', function (obj) {
- var data = obj.data;
- if (obj.event === 'edit') {
- tool.side('/admin/role/add?id='+obj.data.id);
- return;
- }
- if (obj.event === 'del') {
- layer.confirm('确定要删除该权限角色吗?', { icon: 3, title: '提示' }, function (index) {
- let callback = function (res) {
- layer.msg(res.msg);
- if (res.code == 0) {
- obj.del();
- }
- }
- tool.delete("/admin/role/delete", { id: obj.data.id }, callback);
- layer.close(index);
- });
- }
- });
- //监听搜索提交
- form.on('submit(webform)', function (data) {
- layui.pageTable.reload({
- where: { keywords: data.field.keywords },
- page: { curr: 1 }
- });
- return false;
- });
- }
- </script>
- {/block}
- <!-- /脚本 -->
|