field.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
  2. var Controller = {
  3. index : function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend : {
  7. index_url : 'qingdong/general/field/index',
  8. edit_url : 'qingdong/general/field/edit',
  9. table : 'field'
  10. }
  11. });
  12. var table = $("#table");
  13. // 初始化表格
  14. table.bootstrapTable({
  15. url : $.fn.bootstrapTable.defaults.extend.index_url,
  16. templateView: true,
  17. columns : [
  18. [
  19. {field : 'name', title : __('标题'), width : 200},
  20. {field : 'data', title : '可选字段'},
  21. {
  22. field : 'operate',
  23. title : __('Operate'),
  24. table : table,
  25. events : Table.api.events.operate,
  26. formatter : Table.api.formatter.operate
  27. }
  28. ]
  29. ],
  30. pageList:['ALL'],
  31. pagination:false,
  32. //启用普通表单搜索
  33. commonSearch : false,
  34. searchFormVisible : false,
  35. });
  36. // 为表格绑定事件
  37. Table.api.bindevent(table);
  38. $('.search').hide();
  39. $('.btn-import').hide();
  40. },
  41. edit : function () {
  42. Controller.api.bindevent();
  43. },
  44. api : {
  45. bindevent : function () {
  46. Form.api.bindevent($("form[role=form]"));
  47. },
  48. formatter : {
  49. thumb : function (value, row, index) {
  50. var style = row.storage == 'upyun' ? '!/fwfh/120x90' : '';
  51. return '<img src="' + row.image + '" data-tips-image alt="" title="封面图" style="max-height:90px;max-width:120px">';
  52. },
  53. }
  54. }
  55. };
  56. return Controller;
  57. });