user_province.js 2.7 KB
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user_province/index' + location.search,
                    add_url: 'user_province/add/user_id/' + Config.user_id,
                    edit_url: 'user_province/edit',
                    del_url: 'user_province/del',
                    multi_url: 'user_province/multi',
                    table: 'user_province',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id'),visible:false},
                        // {field: 'province_id', title: __('Province_id')},
                        {field: 'province.name', title: __('Province.name')},
                        {field: 'expiration_time', title: __('Expiration_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('创建时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'store_id', title: __('Store_id')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,

                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
            parent.window.$(".layui-layer-iframe").find(".layui-layer-close").on('click',function () {
                Fast.api.close('');
            });
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
                parent.window.$(".layui-layer-iframe").find(".layui-layer-close").on('click',function () {
                    Fast.api.close('');
                });
            }
        }
    };
    return Controller;
});