approval.js 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/work/approval/index',
  8. add_url: 'qingdong/work/approval/add',
  9. table: 'approval'
  10. }
  11. });
  12. var table = $("#table");
  13. // 初始化表格
  14. table.bootstrapTable({
  15. url: $.fn.bootstrapTable.defaults.extend.index_url,
  16. sortName: 'id',
  17. columns: [
  18. [
  19. {field: 'state', checkbox: true},
  20. {field: 'formapproval.name', title: __('类型'), operate:false},
  21. {field: 'create_staff.name', title: __('创建人'), operate:false},
  22. {field: 'check_status', title: __('状态'),formatter:Table.api.formatter.status,
  23. searchList: {'0':'待审核', 1:'审核中',2:'审核通过',3:'审核未通过',4:'撤销',}},
  24. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  25. {
  26. field : 'operate',
  27. title : __('Operate'),
  28. table : table,
  29. events : Table.api.events.operate,
  30. formatter : Table.api.formatter.operate,
  31. buttons : [
  32. {
  33. name: 'detail',
  34. text: __('详情'),
  35. classname: 'records btn-dialog',
  36. url: 'qingdong/work/approval/detail',
  37. extend: "data-area='[\"80%\", \"80%\"]'",
  38. callback: function (data) {
  39. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  40. }
  41. }
  42. ]
  43. }
  44. ]
  45. ],
  46. //启用普通表单搜索
  47. commonSearch: true,
  48. searchFormVisible: true,
  49. onLoadSuccess:function(){
  50. // 这里就是数据渲染结束后的回调函数
  51. $(".btn-add").data("area",["80%","80%"]);
  52. $(".btn-edit").data("area",["80%","80%"]);
  53. }
  54. });
  55. // 为表格绑定事件
  56. Table.api.bindevent(table);
  57. $('.search').hide();
  58. $('.btn-import').hide();
  59. $('#myPopover').popover();
  60. },
  61. add: function () {
  62. Controller.api.bindevent();
  63. },
  64. edit: function () {
  65. Controller.api.bindevent();
  66. },
  67. detail: function () {
  68. $('.stafflist').popover({
  69. placement : 'bottom',
  70. trigger : 'hover'
  71. });
  72. Controller.api.bindevent();
  73. },
  74. api: {
  75. bindevent: function () {
  76. Form.api.bindevent($("form[role=form]"),function (data){
  77. Fast.api.close(data);
  78. });
  79. },
  80. formatter: {
  81. thumb: function (value, row, index) {
  82. var style = row.storage == 'upyun' ? '!/fwfh/120x90' : '';
  83. return '<img src="' + row.image + '" data-tips-image alt="" title="封面图" style="max-height:90px;max-width:120px">';
  84. },
  85. }
  86. }
  87. };
  88. return Controller;
  89. });