审查视图

public/assets/js/backend/mobile/company.js 7.8 KB
何书鹏 authored
1 2 3 4 5 6 7 8 9 10 11 12 13
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'mobile/company/index' + location.search,
                    add_url: 'mobile/company/add',
                    edit_url: 'mobile/company/edit',
                    del_url: 'mobile/company/del',
                    multi_url: 'mobile/company/multi',
					examine_url: 'mobile/company/examine',
何书鹏 authored
14
                    user_url: 'mobile/company/user',
何书鹏 authored
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
                    table: 'mobile_company',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
何书鹏 authored
30
                        {field: 'user.nickname', title: __('用户名')},
何书鹏 authored
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
                        {field: 'name', title: __('Name')},
                        {field: 'address', title: __('Address')},
                        {field: 'license', title: __('License'), events: Table.api.events.image, formatter: Table.api.formatter.images, searchable: false},
                        {field: 'legal_person', title: __('Legal_person')},
                        {field: 'invite_code', title: __('Invite_code')},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'examine',
                                    text: '通过',
                                    title: '通过',
                                    classname: 'btn btn-xs btn-primary btn-ajax',
                                    icon: '',
                                    url: $.fn.bootstrapTable.defaults.extend.examine_url+'/status/1',
                                    confirm: '是否确认通过审核?',
                                    visible:function (row) {
                                        if(row.status == 0){
                                            return true;
                                        }else{
                                            return false;
                                        }
                                    },
                                    success: function (data) {
                                        table.bootstrapTable('refresh');
                                    }
                                },
                                {
                                    name: 'examine',
                                    text: '拒绝',
                                    title: '拒绝',
                                    classname: 'btn btn-xs btn-danger btn-ajax',
                                    icon: '',
                                    url: $.fn.bootstrapTable.defaults.extend.examine_url+'/status/2',
                                    confirm: '是否确认拒绝审核?',
                                    visible:function (row) {
                                        if(row.status == 0){
                                            return true;
                                        }else{
                                            return false;
                                        }
                                    },
                                    success: function (data) {
                                        table.bootstrapTable('refresh');
                                    }
何书鹏 authored
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
                                },
                                {
                                    name: 'user',
                                    text: '员工名单',
                                    title: '员工名单',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: '',
                                    url: 'mobile/company_user/?company_id={id}',
                                    visible:function (row) {
                                        if(row.status == '1'){
                                            return true;
                                        }
                                    },
                                },
                                {
                                    name: 'userlog',
                                    text: '员工记录',
                                    title: '员工记录',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: '',
                                    url: 'mobile/company_user_log/?company_id={id}',
                                    visible:function (row) {
                                        if(row.status == '1'){
                                            return true;
                                        }
                                    },
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
                                },
                                {
                                    name: 'setuser',
                                    text: '设为普通用户',
                                    title: '设为普通用户',
                                    classname: 'btn btn-xs btn-primary btn-ajax',
                                    icon: '',
                                    url: 'mobile/company/setgroup?group_id=0',
                                    confirm: '是否确认拒绝审核?',
                                    visible:function (row) {
                                        if(row.user.group_id == 1){
                                            return true;
                                        }
                                    },
                                    success: function (data) {
                                        table.bootstrapTable('refresh');
                                    }
                                },
                                {
                                    name: 'setuser',
                                    text: '设为企业管理员',
                                    title: '设为企业管理员',
                                    classname: 'btn btn-xs btn-primary btn-ajax',
                                    icon: '',
                                    url: 'mobile/company/setgroup?group_id=1',
                                    confirm: '是否确认拒绝审核?',
                                    visible:function (row) {
                                        if(row.user.group_id == 0){
                                            return true;
                                        }
                                    },
                                    success: function (data) {
                                        table.bootstrapTable('refresh');
                                    }
何书鹏 authored
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
                                }
                            ], formatter: Table.api.formatter.operate,
						}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});