jianceproject.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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: 'jianceproject/index' + location.search,
  8. add_url: 'jianceproject/add',
  9. edit_url: 'jianceproject/edit',
  10. del_url: 'jianceproject/del',
  11. multi_url: 'jianceproject/multi',
  12. import_url: 'jianceproject/import',
  13. table: 'jiance_project',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. search: false,
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id'),operate:false},
  26. // {field: 'company_id', title: __('Company_id')},
  27. {field: 'company.companyname', title: __('Company.companyname'), operate: 'LIKE'},
  28. // {field: 'pid', title: __('Pid')},
  29. {field: 'pj.title', title: '上级',operate:'LIKE'},
  30. {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  31. {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  32. {field: 'info', title: __('Info'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  33. {field: 'weigh', title: __('Weigh'), operate: false},
  34. {field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'operate', title: __('Operate'), table: table,
  36. buttons:[
  37. {
  38. name:'addchild',
  39. text:'添加',
  40. title:'添加',
  41. icon:'fa fa-exclamation-circle',
  42. classname:'btn btn-xs btn-info btn-dialog btn-addchild',
  43. url:function(row){
  44. return 'jianceproject/addchild/company_id/'+ row.company_id +'/pid/'+ row.id +'?dialog=1'
  45. },
  46. target:'_self',
  47. hidden:function(row){
  48. if(row.pid == 0){
  49. return false;
  50. }
  51. return true;
  52. },
  53. refresh:true,
  54. },
  55. ],
  56. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  57. ]
  58. ]
  59. });
  60. // 为表格绑定事件
  61. Table.api.bindevent(table);
  62. },
  63. recyclebin: function () {
  64. // 初始化表格参数配置
  65. Table.api.init({
  66. extend: {
  67. 'dragsort_url': ''
  68. }
  69. });
  70. var table = $("#table");
  71. // 初始化表格
  72. table.bootstrapTable({
  73. url: 'jianceproject/recyclebin' + location.search,
  74. pk: 'id',
  75. sortName: 'id',
  76. columns: [
  77. [
  78. {checkbox: true},
  79. {field: 'id', title: __('Id')},
  80. {field: 'title', title: __('Title'), align: 'left'},
  81. {
  82. field: 'deletetime',
  83. title: __('Deletetime'),
  84. operate: 'RANGE',
  85. addclass: 'datetimerange',
  86. formatter: Table.api.formatter.datetime
  87. },
  88. {
  89. field: 'operate',
  90. width: '140px',
  91. title: __('Operate'),
  92. table: table,
  93. events: Table.api.events.operate,
  94. buttons: [
  95. {
  96. name: 'Restore',
  97. text: __('Restore'),
  98. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  99. icon: 'fa fa-rotate-left',
  100. url: 'jianceproject/restore',
  101. refresh: true
  102. },
  103. {
  104. name: 'Destroy',
  105. text: __('Destroy'),
  106. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  107. icon: 'fa fa-times',
  108. url: 'jianceproject/destroy',
  109. refresh: true
  110. }
  111. ],
  112. formatter: Table.api.formatter.operate
  113. }
  114. ]
  115. ]
  116. });
  117. // 为表格绑定事件
  118. Table.api.bindevent(table);
  119. },
  120. addchild: function () {
  121. Controller.api.bindevent();
  122. },
  123. add: function () {
  124. Controller.api.bindevent();
  125. },
  126. edit: function () {
  127. Controller.api.bindevent();
  128. },
  129. api: {
  130. bindevent: function () {
  131. Form.api.bindevent($("form[role=form]"));
  132. }
  133. }
  134. };
  135. return Controller;
  136. });