123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'applys/eyemargin/index' + location.search,
- edit_url: 'applys/eyemargin/edit',
- del_url: 'applys/eyemargin/del',
- multi_url: 'applys/eyemargin/multi',
- table: 'eyemargin',
- }
- });
- 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.nickname', title: __('User.nickname'), operate: 'LIKE'},
- {field: 'eye_type', title: __('Eye_type'), searchList: {"1":__('Eye_type 1'),"2":__('Eye_type 2')}, formatter: Table.api.formatter.normal},
- {field: 'content', title: __('Content'), operate: 'LIKE'},
- {field: 'video', title: __('Video'), operate: 'LIKE',formatter: function(val, row) {
- if(val) {
- return '<video width="120" height="90" preload="none" controls>'+
- '<source src="'+val+'" type="video/ogg">'+
- '</video>';
- } else {
- return '暂无';
- }
- }},
- {field: 'cover', title: __('Cover'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
- {field: 'city', title: __('城市'), operate: 'LIKE'},
- {field: 'is_main', title: __('Is_main'), searchList: {"1":__('Is_main 1'),"0":__('Is_main 0')}, formatter: Table.api.formatter.normal},
- {field: 'encode_status', title: __('转码状态'), searchList: {"0":__('待处理'),"1":__('成功'),"2":__('失败')}, formatter: Table.api.formatter.status},
- {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
- {field: 'weight', title: __('Weight')},
- {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;
- });
|