123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'dynamic/commit/index' + location.search,
- // add_url: 'dynamic/commit/add',
- edit_url: 'dynamic/commit/edit',
- del_url: 'dynamic/commit/del',
- // multi_url: 'dynamic/commit/multi',
- // import_url: 'dynamic/commit/import',
- table: 'dynamic_commit',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'dynamic_id', title: __('Dynamic_id')},
- {field: 'user.u_id', title: __('User.u_id')},
- {field: 'user.nickname', title: __('User.nickname')},
- {
- field: 'content',
- title: __('Content'),
- operate: 'LIKE',
- formatter: function (value, row, index, field) {
- return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.content + "'>" + value + "</span>";
- },
- cellStyle: function (value, row, index, field) {
- return {
- css: {
- "white-space": "nowrap",
- "text-overflow": "ellipsis",
- "overflow": "hidden",
- "max-width": "250px"
- }
- };
- }
- },
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete: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;
- });
|