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', title: '游戏ID'},
                    {field: 'product_name', title: '主游戏'},
                    {field: 'app_name', title: '子游戏名称'},
                    {field: 'appkey', title: 'appkey',search:false},
                    {field: 'paykey', title: 'paykey',search:false},
                    {
                        field: 'status',
                        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',
                        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', title: '创建人',search:false},
                    {field: 'add_time', title: '创建时间',search:false},
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

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