<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="字典列表" libs=["table"]/>
<div class="container-div" id="_app">
    <div class="row">
    <div class="col-sm-12 search-collapse">
    <@f.form id="type-form">
        <div class="select-list">
            <ul>
                <li>
                    字典名称：<input type="text"  class="form-control" name="dictName"/>
                </li>
                <li>
                    字典类型：<input type="text" class="form-control" name="dictType"/>
                </li>
                <li>
                    字典状态：
                    <@f.select name="status" blankValue="" blankLabel="所有" dictType="sys_normal_disable" />
                </li>
                <li>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;&nbsp;<@ctx.i18n text = "查询"/></a>
                    <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;<@ctx.i18n text = "重置"/></a>
                </li>
            </ul>
        </div>
    </@f.form>
    </div>
    <@table id="bootstrap-table">
        <@shiro.hasPermission name="sys:dict:add">
            <a class="btn btn-success" onclick="opt.operate.add()"><i class="fa fa-plus"></i>&nbsp;<@ctx.i18n text = "新增"/></a>
        </@shiro.hasPermission>
        <@shiro.hasPermission name="sys:dict:edit">
            <a class="btn btn-primary single disabled" onclick="opt.operate.edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;<@ctx.i18n text = "修改"/></a>
        </@shiro.hasPermission>
        <@shiro.hasPermission name="sys:dict:del">
            <a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()"><i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/></a>
        </@shiro.hasPermission>
        <@shiro.hasPermission name="sys:dict:clear">
            <a class="btn btn-danger" onclick="clearRedis()"><i class="fa fa-refresh"></i>&nbsp;<@ctx.i18n text = "清除缓存"/></a>
        </@shiro.hasPermission>
    </@table>
    </div>
</div>
<@footer>
<script>
    var editFlag = "${permission.hasPermi('sys:dict:edit')}";
    var listFlag = "${permission.hasPermi('sys:dict:add')}";
    var delFlag = "${permission.hasPermi('sys:dict:del')}";
    var statusDatas = ${dict.getDictListJson('sys_normal_disable')};
    var isSysDatas = ${dict.getDictListJson('sys_yes_no')};
    var visible = ${permission.isPermitteds("sys:dict:edit,sys:dict:del,sys:dict:add")?string('true', 'false')};
    var prefix = baseURL + 'sys/dict';

    var _vm = new Vue({
        el:'#_app',
        data:{
        },
        methods:{
            detail:function (dictId) {
                var url = prefix + '/detail/' + dictId;
                opt.modal.openTab("字典数据", url);
                return;
            }
        },
        updated : function(){
        },
        mounted:function () {
            /*初始表格对象*/
            var options = {
                url: prefix + "/list",
                addUrl: prefix + "/add",
                editUrl: prefix + "/edit/{id}",
                delUrl: prefix + "/del",
                sortName: "id",
                uniqueId: "id",
                pageSize: 12,
                pageList: [12, 24, 36],
                modalName: "字典管理",
                columns: [
                    {title: "序号",width:15,align:"center", formatter: function (value, row, index) {
                            return $.table.serialNumber(index);
                    }},
                    /*{checkbox: true},*/
                    {field: 'id',title: '字典主键', sortable: true},
                    {field: 'dictName', title: '字典名称'},
                    {field: 'dictType', title: '字典类型', formatter: function(value, row, index) {
                            return '<a href="javascript:void(0)" onclick="_vm.detail(\'' + row.id + '\')">' + value + '</a>';
                    }},
                    {field: 'status', title: $.i18n.prop("状态"), align: 'center', formatter: function(value, row, index) {
                            return $.table.selectDictLabel(statusDatas, value);
                    }},
                    {field: 'remark', title: $.i18n.prop("备注"),formatter: function(value, row, index) {
                            return $.table.tooltip(value,8);
                    }},
                    {field: 'createTime', title: $.i18n.prop("创建时间"), sortable: true},
                    {field: 'isSys', title: '系统内置', formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isSysDatas, value);
                    }},
                    {title:"<@ctx.i18n text = "操作"/>", align: 'center',visible:visible, formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="opt.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="_vm.detail(\'' + row.id + '\')"><i class="fa fa-list-ul"></i>列表</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + delFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                    }}]
            };
            $.table.init(options);
        }
    })

    function clearRedis() {
        opt.operate.get(prefix + "/clearDict")
    }
</script>
</@footer>
</@pageTheme>