123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'policy/lists/index' + location.search,
- add_url: 'policy/lists/add',
- edit_url: 'policy/lists/edit',
- del_url: 'policy/lists/del',
- multi_url: 'policy/lists/multi',
- import_url: 'policy/lists/import',
- table: 'policy_lists',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- showExport:false,
- // commonSearch:false,
- columns: [
- [
- {checkbox: true},
- {field:'id', title: __('序号'),formatter: function(value, row, index){
- return ++index;
- }, operate: false},
- {field: 't_id', title: __('Policytype.name'),sortable:true, searchList: $.getJSON("policy/type/indexxx"),formatter:function (value,row,index) {
- console.log(row)
- return row.policytype.name;
- }},
- {field: 'title', title: __('Title')},
- // {field: 'content', title: __('Content')},
- {field: 'switch', title: __('Switch'), table: table, formatter: Table.api.formatter.toggle,operate:false},
- {field: 'sort', title: __('Sort'),operate:false},
- {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
- {
- field: 'buttons',
- width: "120px",
- title: __('入驻情况'),
- table: table,
- events: Table.api.events.operate,
- buttons: [
- {
- name: 'detail',
- text: __('查看入驻人员'),
- title: __('查看入驻人员'),
- classname: 'btn btn-xs btn-primary btn-dialog',
- icon: 'fa fa-list',
- url: 'policy/ruzhu/index',
- callback: function (data) {
- Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return true;
- }
- },
- ],
- formatter: Table.api.formatter.buttons
- },
- // {field: 'policytype.name', title: __('Policytype.name'), operate: 'LIKE'},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 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;
- });
|