define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'train/question/index' + location.search, add_url: 'train/question/add', // edit_url: 'train/question/edit', del_url: 'train/question/del', multi_url: 'train/question/multi', table: 'train_question', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, // {field: 'id', title: __('Id')}, {field: 'title', title: __('Title'), width: '50%', operate: 'LIKE %...%',}, { field: 'class_id', title: __('Class_id'), formatter: Table.api.formatter.label, searchList: $.getJSON('train/class_dict/classSelectList') }, { field: 'type', title: __('Type'), formatter: Table.api.formatter.label, searchList: {1: '单选', 2: '多选', 3: '判断'}, }, {field: 'result', title: __('Result'), searchable: false}, {field: 'created_at', title: __('createdAt'), operate:'RANGE', addclass:'datetimerange'}, { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons: [ { name : 'detail', title : '详情', text : '详情', extend : 'data-toggle="tooltip"', icon : 'fa fa-th-list', classname: 'btn btn-xs btn-warning btn-dialog', url : 'train/question/detail', } ] } ] ] }); table.on('post-body.bs.table', function (e, settings, json, xhr) { $('.form-commonsearch input[name="createdAt"]').attr('autocomplete','off') }) // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); updateType(1) } } }; $('input[name="row[type]"]').change(function (){ updateType($('input[name="row[type]"]:checked').val()) }) var result1 = ' \n' + '