qa.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/qa/index' + location.search,
  8. add_url: 'wwh/qa/add',
  9. edit_url: 'wwh/qa/edit',
  10. del_url: 'wwh/qa/del',
  11. multi_url: 'wwh/qa/multi',
  12. import_url: 'wwh/qa/import',
  13. table: 'wwh_qa',
  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: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  29. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  30. {field: 'name', title: __('Name'), operate: 'LIKE'},
  31. {field: 'model', title: __('Model'), operate: 'LIKE'},
  32. {field: 'sn', title: __('Sn'), operate: 'LIKE'},
  33. {field: 'custom', title: __('Custom'), operate: 'LIKE'},
  34. {field: 'phone', title: __('Phone'), operate: 'LIKE'},
  35. {field: 'fhdate', title: __('Fhdate'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  36. {field: 'dqdate', title: __('Dqdate'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  37. {field: 'lang', title: __('Lang'), searchList: {"1":__('Lang 1'),"2":__('Lang 2')}, custom: {1: 'success', 2: 'warning'}, formatter: Table.api.formatter.normal},
  38. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. // 弹窗窗口大小
  45. table.on('post-body.bs.table',function(e, settings, json, xhr){
  46. $(".btn-add").data("area", ['80%','80%']);
  47. $(".btn-editone").data("area", ['80%','80%']);
  48. });
  49. // TAB选项卡默认选中简体中文
  50. $('ul.nav-tabs li a[data-toggle="tab"]').eq(0).trigger("click");
  51. // 获取TAB选项卡值,通过options.extend.add_url传递
  52. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  53. var options = table.bootstrapTable('getOptions');
  54. options.extend.add_url = 'wwh/qa/add?lang=' + $(this).data('value');
  55. });
  56. },
  57. add: function () {
  58. // 将TAB选项卡赋值给lang
  59. $('#c-lang option').each(function(){
  60. if($(this).attr('value') == Fast.api.query('lang'))
  61. {
  62. $(this).attr('selected', 'selected');
  63. }
  64. });
  65. Controller.api.bindevent();
  66. },
  67. edit: function () {
  68. Controller.api.bindevent();
  69. },
  70. api: {
  71. bindevent: function () {
  72. Form.api.bindevent($("form[role=form]"));
  73. }
  74. }
  75. };
  76. return Controller;
  77. });