position.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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: 'wwh/position/index' + location.search,
  8. add_url: 'wwh/position/add',
  9. edit_url: 'wwh/position/edit',
  10. del_url: 'wwh/position/del',
  11. multi_url: 'wwh/position/multi',
  12. table: 'wwh_position',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. fixedColumns: true,
  22. fixedRightNumber: 1,
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id')},
  27. {field: 'name', title: __('Name')},
  28. {field: 'dept', title: __('Dept')},
  29. {field: 'addr', title: __('Addr')},
  30. {field: 'xueli', title: __('Xueli')},
  31. {field: 'num', title: __('Num')},
  32. {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange'},
  33. {field: 'lang', title: __('Lang'), searchList: {"1":__('Lang 1'),"2":__('Lang 2')}, custom: {1: 'success', 2: 'warning'}, formatter: Table.api.formatter.normal},
  34. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  35. ]
  36. ]
  37. });
  38. // 为表格绑定事件
  39. Table.api.bindevent(table);
  40. // 弹窗窗口大小
  41. table.on('post-body.bs.table',function(e, settings, json, xhr){
  42. $(".btn-add").data("area", ['80%','80%']);
  43. $(".btn-editone").data("area", ['80%','80%']);
  44. });
  45. // TAB选项卡默认选中简体中文
  46. $('ul.nav-tabs li a[data-toggle="tab"]').eq(0).trigger("click");
  47. // 获取TAB选项卡值,通过options.extend.add_url传递
  48. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  49. var options = table.bootstrapTable('getOptions');
  50. options.extend.add_url = 'wwh/position/add?lang=' + $(this).data('value');
  51. });
  52. },
  53. add: function () {
  54. // 将TAB选项卡赋值给lang
  55. $('#c-lang option').each(function(){
  56. if($(this).attr('value') == Fast.api.query('lang'))
  57. {
  58. $(this).attr('selected', 'selected');
  59. }
  60. });
  61. Controller.api.bindevent();
  62. },
  63. edit: function () {
  64. Controller.api.bindevent();
  65. },
  66. api: {
  67. bindevent: function () {
  68. Form.api.bindevent($("form[role=form]"));
  69. }
  70. }
  71. };
  72. return Controller;
  73. });