@using MineTec.ProManager.Admin.ViewResources
@using MineTec.ProManager.Authorization
@{
    ViewBag.CurrentPageName = PageNames.Permissions;
}

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">权限名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="permissionName" placeholder="" class="layui-input">
                </div>
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="permission-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>

<div class="layui-card">
    <div class="layui-card-body">
        <table id="permission-table" lay-filter="permission-table"></table>
    </div>
</div>

@section scripts{
    <script type="text/javascript">
        layui.use(['abp', 'form', 'table'], function () {
            var $ = layui.jquery;
            var abp = layui.abp;
            var table = layui.table;
            var form = layui.form;

            form.on('submit(permission-query)', function (data) {
				table.reload('permission-table', {
                    where: data.field,
                    page: {
                        curr: 1
                    }
				})
				return false;
			});

            table.render({
				elem: "#permission-table",
				url: "@Url.Action("GetPermissionList", "Permissions")",
				height: 'full-150',
				page: true,
				cols: [
				    [
					    {
						    title: '权限名称',
						    field: 'name'
					    }
				    ]
                ],
                parseData: function (res) {
                    return {
                        "code": res.result.code, //解析接口状态
                        "msg": res.result.msg, //解析提示文本
                        "count": res.result.count, //解析数据长度
                        "data": res.result.data //解析数据列表
                    };
                },
                response: {
                    statusCode: 200 //规定成功的状态码，默认：0
                },
				skin: 'line',
				toolbar: '#organizationToolBar',
				defaultToolbar: [{
					layEvent: 'refresh',
					icon: 'layui-icon-refresh',
				}, 'filter', 'print', 'exports']
			});
        });
    </script>
}

