devices.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'soft/devices/index' + location.search,
  8. add_url: 'soft/devices/add',
  9. edit_url: 'soft/devices/edit',
  10. del_url: 'soft/devices/del',
  11. multi_url: 'soft/devices/multi',
  12. import_url: 'soft/devices/import',
  13. table: 'soft_devices',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'type', title: __('Type'), operate: 'LIKE'},
  29. {field: 'name', title: __('Name'), operate: 'LIKE'},
  30. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  31. {field: 'client_id', title: __('Client_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  32. {field: 'device_id', title: __('Device_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  33. {field: 'device_brand', title: __('Device_brand'), operate: 'LIKE'},
  34. {field: 'device_model', title: __('Device_model'), operate: 'LIKE'},
  35. {field: 'device_release', title: __('Device_release'), operate: 'LIKE'},
  36. {field: 'activate_code', title: __('Activate_code'), operate: 'LIKE'},
  37. {field: 'activated_time', title: __('Activated_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'expiration_time', title: __('Expiration_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"3":__('Status 3')}, formatter: Table.api.formatter.status},
  42. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  43. ]
  44. ]
  45. });
  46. // 为表格绑定事件
  47. Table.api.bindevent(table);
  48. },
  49. add: function () {
  50. Controller.api.bindevent();
  51. },
  52. edit: function () {
  53. Controller.api.bindevent();
  54. },
  55. api: {
  56. bindevent: function () {
  57. Form.api.bindevent($("form[role=form]"));
  58. }
  59. }
  60. };
  61. return Controller;
  62. });