define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'company/index' + location.search, add_url: 'company/add', edit_url: 'company/edit', // del_url: 'company/del', multi_url: 'company/multi', import_url: 'company/import', table: 'company', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', fixedColumns: true, fixedRightNumber: 1, search:false, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, // {field: 'user_id', title: __('User_id')}, {field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'contacts', title: __('Contacts'), operate: 'LIKE'}, {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, // {field: 'province_name', title: __('Province_name'), operate: 'LIKE'}, // {field: 'city_name', title: __('City_name'), operate: 'LIKE'}, // {field: 'area_name', title: __('Area_name'), operate: 'LIKE'}, // {field: 'province_id', title: __('Province_id')}, // {field: 'city_id', title: __('City_id')}, // {field: 'area_id', title: __('Area_id')}, // {field: 'address', title: __('Address'), operate: 'LIKE'}, {field: 'full_address', title: __('Full_address'), operate: 'LIKE'}, // {field: 'longitude', title: __('Longitude'), operate:'BETWEEN'}, // {field: 'latitude', title: __('Latitude'), operate:'BETWEEN'}, // {field: 'aptitude_images', title: __('Aptitude_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status}, {field: 'is_open', title: __('Is_open'), searchList: {"0":__('Is_open 0'),"1":__('Is_open 1')}, formatter: Table.api.formatter.normal}, {field: 'open_hours', title: __('Open_hours'), operate: 'LIKE'}, // {field: 'agent_id', title: __('Agent_id')}, // {field: 'mini_code', title: __('Mini_code'), operate: 'LIKE'}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'wallet.money', title: __('Wallet.money'), operate:'BETWEEN'}, {field: 'operate', title: __('Operate'), table: table, buttons:[ { name:'guanlian', text:'关联分公司', title:'关联分公司', icon:'fa fa-exclamation-circle', classname:'btn btn-xs btn-info btn-dialog', extend: 'data-area=["80%","80%"]', url:'company/guanlian/ids/{ids}?dialog=1', target:'_self', hidden:function($row){ if($row.status == -1){ return false; } return true; } }, { name:'audit', text:'平台审核', title:'平台审核', icon:'fa fa-exclamation-circle', classname:'btn btn-xs btn-info btn-dialog', extend: 'data-area=["80%","80%"]', url:'company/audit/ids/{ids}?dialog=1', target:'_self', hidden:function($row){ if($row.status == 0 || $row.status == 1 || $row.status == 2){ return false; } return true; } }, ], events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, guanlian: function () { Controller.api.bindevent(); }, audit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { $("#c-city_id").data("params",function(){ return {custom:{pid:$("#c-province_id").val()}}; }); $("#c-area_id").data("params",function(){ return {custom:{pid:$("#c-city_id").val()}}; }); $("[data-toggle='addresspicker']").data("callback", function(res){ //其中res则是包含了address/lat/lng等信息的JSON对象 }); Form.api.bindevent($("form[role=form]")); } } }; return Controller; });