12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'qingdongams/notice/notice/index',
- add_url: 'qingdongams/notice/notice/add',
- edit_url: 'qingdongams/notice/notice/edit',
- del_url: 'qingdongams/notice/notice/del',
- table: 'notice'
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- sortName: 'id',
- columns: [
- [
- {field: 'state', checkbox: true},
- {field: 'title', title: __('标题'), operate:'like'},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ],
- //启用普通表单搜索
- search:false,
- commonSearch: true,
- searchFormVisible: true,
- onLoadSuccess:function(){
- // 这里就是数据渲染结束后的回调函数
- $('.btn-editone').html('编辑');
- $('.fa-pencil').remove();
- $('.btn-delone').html('删除');
- $('.fa-trash').remove();
- $('.btn-editone').removeClass('btn-success')
- $('.btn-editone').removeClass('btn')
- $('.btn-delone').removeClass('btn')
- $('.btn-delone').removeClass('btn-danger')
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $('.search').hide();
- $('.btn-import').hide();
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- detail: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- thumb: function (value, row, index) {
- var style = row.storage == 'upyun' ? '!/fwfh/120x90' : '';
- return '<img src="' + row.image + '" data-tips-image alt="" title="封面图" style="max-height:90px;max-width:120px">';
- },
- }
- }
- };
- return Controller;
- });
|