thought_file.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: 'thought_file/index' + location.search,
  8. add_url: 'thought_file/add',
  9. edit_url: 'thought_file/edit',
  10. del_url: 'thought_file/del',
  11. multi_url: 'thought_file/multi',
  12. import_url: 'thought_file/import',
  13. table: 'thought_file',
  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. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'unit_id', title: __('Unit_id')},
  27. {field: 'people_id', title: __('People_id')},
  28. {field: 'file_name', title: __('File_name'), operate: 'LIKE'},
  29. {field: 'thought_id', title: __('Thought_id')},
  30. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  31. ]
  32. ]
  33. });
  34. // 为表格绑定事件
  35. Table.api.bindevent(table);
  36. },
  37. add: function () {
  38. Controller.api.bindevent();
  39. $("#c-people_id").data("params", function (obj) {
  40. var unit_id = $('#J_unitselect').val();
  41. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  42. });
  43. $("#faupload-file").data("upload-success", function(data, ret){
  44. //这里进行后续操作
  45. $('#c-file_name').val(data.name);
  46. });
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. api: {
  52. bindevent: function () {
  53. Form.api.bindevent($("form[role=form]"));
  54. }
  55. }
  56. };
  57. return Controller;
  58. });