flow.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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: 'qingdong/work/flow/index' + location.search,
  8. add_url: 'qingdong/work/flow/add',
  9. edit_url: 'qingdong/work/flow/edit',
  10. multi_url: 'qingdong/work/flow/multi',
  11. import_url: 'qingdong/work/flow/import',
  12. recyclebin_url: 'qingdong/work/flow/recyclebin',
  13. table: 'qingdong_flow',
  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: 'name', title: __('审批流名称'), operate: false},
  26. {field: 'status', title: __('流程类型'),operate: false,formatter:Table.api.formatter.status, searchList: {0:'授权审批人', 1: '固定审批'}},
  27. {field: 'relation_type', title: __('关联对象'), operate: false,formatter:Table.api.formatter.status,
  28. searchList: {'contract':'合同', 'receivables': '回款', 'consume': '费用', 'achievement': '业绩目标', 'card': '补卡', 'leave': '请假'}},
  29. {field: 'groups_text', title: __('适用范围'), operate: false},
  30. {field: 'remark', title: __('备注'), operate: false},
  31. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  32. {field: 'last_modified', title: __('最后修改时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. {field: 'last_admin_text', title: __('最后修改人'), operate:false},
  34. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  35. ]
  36. ],
  37. //启用普通表单搜索
  38. search:false,
  39. commonSearch: false,
  40. searchFormVisible: true,
  41. onLoadSuccess:function(){
  42. // 这里就是数据渲染结束后的回调函数
  43. $('.btn-editone').html('编辑');
  44. $('.fa-pencil').remove();
  45. $('.btn-delone').html('删除');
  46. $('.fa-trash').remove();
  47. $('.btn-editone').removeClass('btn-success')
  48. $('.btn-editone').removeClass('btn')
  49. $('.btn-delone').removeClass('btn')
  50. $('.btn-delone').removeClass('btn-danger')
  51. }
  52. });
  53. // 为表格绑定事件
  54. Table.api.bindevent(table);
  55. },
  56. recyclebin: function () {
  57. // 初始化表格参数配置
  58. Table.api.init({
  59. extend: {
  60. 'dragsort_url': ''
  61. }
  62. });
  63. var table = $("#table");
  64. // 初始化表格
  65. table.bootstrapTable({
  66. url: 'qingdong/work/recyclebin' + location.search,
  67. pk: 'id',
  68. sortName: 'id',
  69. columns: [
  70. [
  71. {checkbox: true},
  72. {field: 'id', title: __('Id')},
  73. {field: 'name', title: __('Name'), align: 'left'},
  74. {
  75. field: 'deletetime',
  76. title: __('Deletetime'),
  77. operate: 'RANGE',
  78. addclass: 'datetimerange',
  79. formatter: Table.api.formatter.datetime
  80. },
  81. {
  82. field: 'operate',
  83. width: '130px',
  84. title: __('Operate'),
  85. table: table,
  86. events: Table.api.events.operate,
  87. buttons: [
  88. {
  89. name: 'Restore',
  90. text: __('Restore'),
  91. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  92. icon: 'fa fa-rotate-left',
  93. url: 'qingdong/work/restore',
  94. refresh: true
  95. },
  96. {
  97. name: 'Destroy',
  98. text: __('Destroy'),
  99. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  100. icon: 'fa fa-times',
  101. url: 'qingdong/work/destroy',
  102. refresh: true
  103. }
  104. ],
  105. formatter: Table.api.formatter.operate
  106. }
  107. ]
  108. ]
  109. });
  110. // 为表格绑定事件
  111. Table.api.bindevent(table);
  112. },
  113. add: function () {
  114. Controller.api.bindevent();
  115. },
  116. edit: function () {
  117. Controller.api.bindevent();
  118. },
  119. api: {
  120. bindevent: function () {
  121. $(document).on("fa.event.appendfieldlist", '.fieldlist', function(){
  122. //通用的表单组件事件绑定和组件渲染
  123. Form.events.selectpage($("form"));
  124. Form.events.datetimepicker($("form"));
  125. });
  126. $(document).on('change','.stafftype',function (){
  127. var stafftype=$(this).val();
  128. if(stafftype == 1 || stafftype == 2){
  129. $(this).parent('td').next('td').find('div').show();
  130. }else{
  131. $(this).parent('td').next('td').find('div').hide();
  132. }
  133. }).on('change','[name="row[status]"]',function (){
  134. var status=$(this).val();
  135. console.log(status)
  136. if(status == 1){
  137. $('.status_text').show();
  138. }else{
  139. $('.status_text').hide();
  140. }
  141. })
  142. Form.api.bindevent($("form[role=form]"));
  143. }
  144. }
  145. };
  146. return Controller;
  147. });