thought.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["790px","360px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'thought/index' + location.search,
  9. add_url: 'thought/add',
  10. edit_url: 'thought/edit',
  11. del_url: 'thought/del',
  12. multi_url: 'thought/multi',
  13. import_url: 'thought/import',
  14. table: 'thought',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'order_number', title: __('Id')},
  27. {field: 'name', title: __('Name'), operate: 'LIKE'},
  28. {field: 'file_name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'type', title: __('Type'), operate: 'LIKE'},
  30. {field: 'deadline', title: __('Deadline'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  31. {field: 'admin_id_text', title: __('上传人')},
  32. {field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. //{field: 'updatetime', title: __('Updatetime'), operate: 'LIKE'},
  34. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  35. {
  36. name: '查看',
  37. text: '查看',
  38. title: '查看',
  39. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  40. icon: 'fa fa-search',
  41. url: 'thought/details',
  42. refresh: true
  43. },
  44. {
  45. name: '上传',
  46. text: '上传',
  47. title: '上传',
  48. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  49. icon: 'fa fa-search',
  50. url: 'thought_file/add',
  51. refresh: true
  52. },
  53. {
  54. name: '下载',
  55. text: '下载',
  56. title: '下载',
  57. classname: 'btn btn-xs btn-info btn-view ',
  58. icon: 'fa fa-search',
  59. url: 'thought/download',
  60. refresh: true
  61. }
  62. ], formatter: Table.api.formatter.operate}
  63. ]
  64. ]
  65. });
  66. // 为表格绑定事件
  67. Table.api.bindevent(table);
  68. table.on('post-body.bs.table',function(){
  69. $(".btn-editone").data("area",["790px","450px"]);
  70. })
  71. table.on('post-body.bs.table',function(){
  72. $(".btn-dialog").data("area",["790px","450px"]);
  73. })
  74. },
  75. add: function () {
  76. Controller.api.bindevent();
  77. $("#faupload-file").data("upload-success", function(data, ret){
  78. //这里进行后续操作
  79. $('#c-file_name').val(data.name);
  80. $('#c-type').val(data.type);
  81. });
  82. },
  83. edit: function () {
  84. Controller.api.bindevent();
  85. $("#faupload-file").data("upload-success", function(data, ret){
  86. //这里进行后续操作
  87. $('#c-file_name').val(data.name);
  88. $('#c-type').val(data.type);
  89. });
  90. },
  91. api: {
  92. bindevent: function () {
  93. Form.api.bindevent($("form[role=form]"));
  94. }
  95. }
  96. };
  97. return Controller;
  98. });