<#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="data-form">
    <div class="select-list">
        <ul>
            <li>
                字典名称：
                <@f.select name="dictType" value="${dictHtml.dictType}" items=dictList itemLabel="dictName" itemValue="dictType"/>
            </li>
            <li>
                字典标签：<input type="text" class="form-control" name="dictLabel"/>
            </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;<@ctx.i18n text = "查询"/></a>
                <a class="btn btn-warning btn-rounded btn-sm" @click="resetPre"><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" @click="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>
        <a class="btn btn-warning" onclick="opt.modal.closeTab()">
            <i class="fa fa-reply-all"></i> <@ctx.i18n text = "关闭"/>
        </a>
    </@table>
    </div>
</div>
<@footer>
<script>

    var editFlag = "${permission.hasPermi('sys:dict:edit')}";
    var delFlag = "${permission.hasPermi('sys:dict:del')}";
    var datas = ${dict.getDictListJson('sys_normal_disable')};
    var isSysDatas = ${dict.getDictListJson('sys_yes_no')};
    var prefix = baseURL + 'sys/dict/data';

    var _vm = new Vue({
        el:'#_app',
        data:{
        },
        methods:{
            queryParams:function(params) {
                var search = $.table.queryParams(params);
                search.dictType = $("#dictType").val();
                return search;
            },
            /*页面重置按钮*/
            resetPre:function() {
                // $("#dictType").val($("#dictType").val()).trigger("change");
                opt.form.reset("data-form","","dictType");
            },
            /*字典数据-新增字典*/
            add :function() {
                var dictType = $("#dictType option:selected").val();
                opt.operate.add(dictType);
            }
        },
        updated : function(){
        },
        mounted:function () {
            /*初始表格对象*/
            var options = {
                url: prefix + "/list",
                addUrl: prefix + "/add/{id}",
                editUrl: prefix + "/edit/{id}",
                delUrl: prefix + "/del",
                sortName: "dictSort",
                queryParams: this.queryParams, /*初始化请求参数*/
                modalName: "字典数据",
                columns: [
                     /*{checkbox: true},*/
                    {field: 'id', title: "<@ctx.i18n text = "字典编码"/>", sortable: true},
                    {field: 'dictValue', title: "<@ctx.i18n text = "字典键值"/>",formatter:function (value) {
                            return $.table.tooltip(value,20);
                    }},
                    {field: 'dictLabel', title: "<@ctx.i18n text = "字典标签"/>", formatter: function(value, row, index) {

                            var actions = [];
                            var listClass = "";
                            var style = "";

                            if(!opt.common.isEmpty(row.cssStyle)){
                                style = row.cssStyle;
                            }
                            if(!opt.common.isEmpty(row.cssClass)){
                                listClass = row.cssClass;
                            }

                            if(opt.common.isEmpty(listClass)){
                                if(!opt.common.isEmpty(row.listClass)){
                                    listClass = row.listClass;
                                }
                            }

                            if(!opt.common.isEmpty(style) || !opt.common.isEmpty(listClass)){
                                actions.push(opt.common.sprintf("<span %s %s>%s</span>",
                                    !opt.common.isEmpty(style)?"style='"+style + "'":"",
                                    opt.common.isEmpty(listClass)  || !opt.common.isEmpty(style)  ? "":opt.common.equals("default", row.listClass) || opt.common.isEmpty(row.listClass) ?
                                        "class='"+listClass+"'" : "class='badge badge-" + row.listClass+"'",
                                    value));
                                return actions.join('');
                            }else{
                                return $.table.tooltip(value,20);
                            }

                        }},
                    {field: 'dictSort', title: "<@ctx.i18n text = "字典排序"/>",sortable: true},
                    {field: 'status', title: "<@ctx.i18n text = "状态"/>", align: 'center', formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }},
                    {field: 'remark', title: "<@ctx.i18n text = "备注"/>"},
                    {field: 'createTime', title: "<@ctx.i18n text = "创建时间"/>", sortable: true},
                    {field: 'isDefault', title: "<@ctx.i18n text = "系统默认"/>", formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isSysDatas, value);
                        }
                    },
                    {field: 'isSys', title: "<@ctx.i18n text = "系统内置"/>", formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isSysDatas, value);
                        }
                    },
                    {title:"<@ctx.i18n text = "操作"/>", align: 'center', 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-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);
        }
    })

</script>
</@footer>
</@pageTheme>