12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'topicdongtai/index' + location.search,
- add_url: 'topicdongtai/add',
- edit_url: 'topicdongtai/edit',
- del_url: 'topicdongtai/del',
- multi_url: 'topicdongtai/multi',
- import_url: 'topicdongtai/import',
- table: 'topic_dongtai',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'topic_id', title: __('Topic_id')},
- {field: 'topichub.name', title: __('Topichub.name'), operate: 'LIKE'},
- {field: 'user_id', title: __('User_id')},
- {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
- {field: 'content', title: __('Content'), operate: 'LIKE'},
- {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
- {field: 'goodnum', title: __('Goodnum')},
- {field: 'answernum', title: __('Answernum')},
- {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: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
- buttons:[
- {
- name:'comment_list',
- text:'评论列表',
- title:'评论列表',
- icon:'fa fa-exclamation-circle',
- classname:'btn btn-xs btn-info btn-dialog',
- url:'topicdongtaianswer/index/dt_id/{ids}?dialog=1',
- target:'_self',
- extend: 'data-area=["90%","90%"]',
- hidden:function($row){
- if($row['answernum'] == 0){
- return true;
- }
- return false;
- }
- },
- {
- name:'good_list',
- text:'点赞列表',
- title:'点赞列表',
- icon:'fa fa-exclamation-circle',
- classname:'btn btn-xs btn-info btn-dialog',
- url:'topicdongtaigood/index/dt_id/{ids}?dialog=1',
- target:'_self',
- extend: 'data-area=["90%","90%"]',
- hidden:function($row){
- if($row['goodnum'] == 0){
- return true;
- }
- return false;
- }
- },
- ],}
- ]
- ]
- });
- // 为表格绑定事件
- 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;
- });
|