123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- 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',
- sortOrder: 'desc',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- // {field: 'topic_ids', title: __('Topic_ids'), operate: 'LIKE'},
- // {field: 'topichub.name', title: __('Topichub.name'), operate: 'LIKE'},
- {field: 'user_id', title: __('User_id')},
- {field: 'user.username', title: __('User.username'),sortable:true, operate: 'LIKE'},
- {field: 'content', title: __('Content'), operate: 'LIKE',
- cellStyle: {css: {
- "white-space": "break-spaces",
- "max-width": "200px",
- "min-width": "200px",
- "word-break": "break-all",
- "text-overflow": "inherit",
- "overflow": "visible",
- }
- }
- },
- {field: 'images', title: __('Images'), operate: false,
- cellStyle: {css: {
- "white-space": "break-spaces",
- "max-width": "150px",
- "min-width": "150px",
- "word-break": "break-all",
- "text-overflow": "inherit",
- "overflow": "visible",
- }
- },
- events: Table.api.events.image, formatter: Table.api.formatter.images},
- {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
- {field: 'audio_file', title: __('Audio_file'), operate: false,events: Table.api.events.image, formatter: Table.api.formatter.audio},
- // {field: 'audio_second', title: __('Audio_second')},
- // {field: 'goodnum', title: __('Goodnum')},
- // {field: 'answernum', title: __('Answernum')},
- {field: 'createtime', title: __('Createtime'),sortable:true, 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: 'cityname', title: __('Cityname'), operate: 'LIKE'},
- // {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
- // {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
- // {field: 'aite', title: __('Aite'), operate: 'LIKE'},
- {field: 'is_public', title: __('Is_public'), searchList: {"1":__('Is_public 1'),"2":__('Is_public 2')}, formatter: Table.api.formatter.normal},
- {field: 'toptime', title: __('toptime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'auditstatus', title: __('Auditstatus'), searchList: {"0":__('Auditstatus 0'),"1":__('Auditstatus 1'),"2":__('Auditstatus 2')}, formatter: Table.api.formatter.status},
- {field: 'audittime', title: __('Audittime'),sortable:true, operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'auditremark', title: __('Auditremark'), operate: 'LIKE',
- cellStyle: {css: {
- "white-space": "break-spaces",
- "max-width": "100px",
- "min-width": "100px",
- "word-break": "break-all",
- "text-overflow": "inherit",
- "overflow": "visible",
- }
- }
- },
- {field: 'operate', title: __('Operate'), table: table,
- buttons:[
- {
- name:'toptime',
- text:'置顶',
- title:'置顶',
- icon:'fa fa-exclamation-circle',
- classname:'btn btn-xs btn-info btn-ajax',
- url:'topicdongtai/toptime/id/{ids}?dialog=1',
- target:'_self',
- refresh:true,
- },
- {
- name:'untoptime',
- text:'取消置顶',
- title:'取消置顶',
- icon:'fa fa-exclamation-circle',
- classname:'btn btn-xs btn-info btn-ajax',
- url:'topicdongtai/untoptime/id/{ids}?dialog=1',
- target:'_self',
- hidden:function(row){
- if(row.toptime > 0){
- return false;
- }
- return true;
- },
- refresh:true,
- }
- ],
- events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- toptime: function () {
- Controller.api.bindevent();
- },
- untoptime: function () {
- Controller.api.bindevent();
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|