12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, Selectpage) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'dict/subclass/index' + location.search,
- add_url: 'dict/subclass/add',
- edit_url: 'dict/subclass/edit',
- del_url: 'dict/subclass/del',
- multi_url: 'dict/subclass/multi',
- table: 'exam_subclass',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'createdat',
- showToggle: false,
- showColumns: false,
- columns: [
- [
- {field: 'name', title: __('Name'), formatter: Table.api.formatter.bold},
- {
- field: 'exam_class_id',
- title: __('Exam_class'),
- visible: false,
- searchList: $.getJSON('dict/device/classSelectList')
- },
- {field: 'exam_class', title: __('Exam_class'), searchable: false},
- {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange'},
- {field: 'updatedAt', title: __('Updatedat'), operate:'RANGE', addclass:'datetimerange'},
- {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 () {
- $.ajax({
- url: 'dict/device/classSelectList/save/1',
- type: 'post',
- dataType: 'json',
- success: function success(res) {
- var data = res.rows;
- $('#c-exam_class_id').selectPage({
- data : data,
- });
- }
- });
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|