|
@@ -0,0 +1,77 @@
|
|
|
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
+
|
|
|
+ var Controller = {
|
|
|
+ index: function () {
|
|
|
+ // 初始化表格参数配置
|
|
|
+ Table.api.init({
|
|
|
+ extend: {
|
|
|
+ index_url: 'usergreetcontent/index' + location.search,
|
|
|
+ add_url: 'usergreetcontent/add',
|
|
|
+// edit_url: 'usergreetcontent/edit',
|
|
|
+ del_url: 'usergreetcontent/del',
|
|
|
+ multi_url: 'usergreetcontent/multi',
|
|
|
+ import_url: 'usergreetcontent/import',
|
|
|
+ table: 'user_greet_content',
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var table = $("#table");
|
|
|
+
|
|
|
+ // 初始化表格
|
|
|
+ table.bootstrapTable({
|
|
|
+ url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
|
+ pk: 'id',
|
|
|
+ sortName: 'id',
|
|
|
+ columns: [
|
|
|
+ [
|
|
|
+ {checkbox: true},
|
|
|
+ {field: 'id', title: __('Id')},
|
|
|
+ {field: 'user_id', title: __('User_id')},
|
|
|
+ {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
|
|
|
+ {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
|
|
|
+ {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
|
|
|
+ {field: 'title', title: __('Title'), operate: 'LIKE'},
|
|
|
+ {field: 'content', title: __('Content'), operate: 'LIKE',events: Table.api.events.image,formatter: function (value,row,index){
|
|
|
+ if (row.type == 0){
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ if (row.type == 1){
|
|
|
+ return Table.api.formatter.audio(value,row,index);
|
|
|
+ }
|
|
|
+ if (row.type == 2){
|
|
|
+ return Table.api.formatter.image(value,row,index);
|
|
|
+ }
|
|
|
+ if (row.type == 'images'){
|
|
|
+ return Table.api.formatter.images(value,row,index);
|
|
|
+ }
|
|
|
+ if (row.type == 'video'){
|
|
|
+ return Table.api.formatter.video(value,row,index);
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+ }},
|
|
|
+ {field: 'duration', title: __('Duration')},
|
|
|
+ {field: 'is_default', title: __('Is_default'), searchList: {"0":__('Is_default 0'),"1":__('Is_default 1')}, formatter: Table.api.formatter.normal},
|
|
|
+ {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;
|
|
|
+});
|