define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_pk:'app_id',
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'app.games/index',
        add_url: 'app.games/add',
        edit_url: 'app.games/edit',
        delete_url: 'app.games/delete',
        export_url: 'app.games/export',
        modify_url: 'app.games/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'app_id',width: 100, title: '游戏ID'},
                    {field: 'product_name',width: 200, title: '主游戏'},
                    {field: 'app_name', width: 200, title: '子游戏名称'},
                    {field: 'appkey', width: 300, title: 'appkey',search:false},
                    {field: 'paykey', width: 300, title: 'paykey',search:false},
                    {
                        field: 'status',
                        width: 100,
                        title: '状态',
                        search:false,
                        templet: function (d) {
                            if (d.status === 1) {
                                return '<span class="layui-badge layui-bg-green">已上线</span>';
                            }else {
                                return '<span class="layui-badge layui-bg-red">未上线</span>';
                            }
                        }
                    },
                    {
                        field: 'is_test',
                        width: 100,
                        title: '是否测试',
                        search:false,
                        templet: function (d) {
                            if (d.is_test === 1) {
                                return '<span class="layui-badge layui-bg-green">否</span>';
                            }else {
                                return '<span class="layui-badge layui-bg-red">是</span>';
                            }
                        }
                    },
                    {field: 'add_user', width: 200, title: '创建人',search:false},
                    {field: 'add_time', width: 200, title: '创建时间',search:false},
                    {width: 200, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        modify: function () {
            ea.listen();
        },
    };
    return Controller;
});
