123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'ad/index' + location.search,
- add_url: 'ad/add',
- edit_url: 'ad/edit',
- del_url: 'ad/del',
- multi_url: 'ad/multi',
- import_url: 'ad/import',
- table: 'ad',
- }
- });
- var table = $("#table");
- let pos=$('#table').data('pos')
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- //{checkbox: true},
- {field: 'id', title: __('Id'), operate: false},
- {field: 'pos', title: __('Pos'), operate: false,searchList:$.getJSON('ad/pos'),formatter: function (a, b, c) {
- return pos[a]
- }},
- {field: 'img', title: __('Img'), operate: false,formatter: Table.api.formatter.image,events: Table.api.events.image},
- /*{field: 'link_type', title: __('Link_type'), operate: false},
- {field: 'link_id', title: __('Link_id'), operate: false},*/
- {field: 'sort', title: __('Sort'), operate: false},
- {field: 'admin.nickname', title: __('通道'), operate: 'like'},
- {field: 'upload_admin.nickname', title: __('上传用户'), operate: 'like'},
- //{field: 'link', title: __('链接'), operate: false,formatter:Table.api.formatter.url},
- {field: 'created_at', title: __('Created_at'), operate: false,formatter: Table.api.formatter.datetime},
- {field: 'updated_at', title: __('Updated_at'), operate: false,formatter: Table.api.formatter.datetime},
- {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;
- });
|