formapproval.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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/formapproval/index',
  8. add_url : 'qingdong/work/formapproval/add',
  9. edit_url : 'qingdong/work/formapproval/edit',
  10. del_url : 'qingdong/work/formapproval/del',
  11. table : 'formapproval'
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url : $.fn.bootstrapTable.defaults.extend.index_url,
  18. sortName : 'id',
  19. pageSize : 1000,
  20. columns : [
  21. [
  22. {field : 'name', title : __('模块'), width : 200},
  23. {field : 'img', title : __('图标'), formatter: Table.api.formatter.image, operate: false},
  24. {field : 'desc', title : __('备注'), width : 600},
  25. {field : 'updatetime', title : '更新时间'},
  26. {
  27. field : 'operate',
  28. title : __('Operate'),
  29. table : table,
  30. events : Table.api.events.operate,
  31. formatter : Table.api.formatter.operate,
  32. buttons : [
  33. {
  34. text : "设计表单",
  35. title : __('设计表单'),
  36. extend : 'data-area=\'["100%","100%"]\'',
  37. classname : 'btn-xs btn-dialog',
  38. url: function (row) {
  39. return 'qingdong/general/form/edit/#/?id=' + row.form_id;
  40. }
  41. }
  42. ],
  43. }
  44. ]
  45. ],
  46. pageList : ['ALL'],
  47. //启用普通表单搜索
  48. commonSearch : false,
  49. searchFormVisible : false,
  50. onLoadSuccess:function(){
  51. // 这里就是数据渲染结束后的回调函数
  52. $('.btn-editone').html('编辑');
  53. $('.fa-pencil').remove();
  54. $('.btn-delone').html('删除');
  55. $('.fa-trash').remove();
  56. $('.btn-editone').removeClass('btn-success')
  57. $('.btn-editone').removeClass('btn')
  58. $('.btn-delone').removeClass('btn')
  59. $('.btn-delone').removeClass('btn-danger')
  60. }
  61. });
  62. // 为表格绑定事件
  63. Table.api.bindevent(table);
  64. $('.search').hide();
  65. $('.btn-import').hide();
  66. },
  67. add : function () {
  68. Controller.api.bindevent();
  69. },
  70. edit : function () {
  71. Controller.api.bindevent();
  72. },
  73. edit_form : function () {
  74. Controller.api.bindevent();
  75. },
  76. api : {
  77. bindevent : function () {
  78. $(document).on("fa.event.appendfieldlist", '.fieldlist', function(){
  79. //通用的表单组件事件绑定和组件渲染
  80. Form.events.selectpage($("form"));
  81. Form.events.datetimepicker($("form"));
  82. });
  83. $(document).on('change','.stafftype',function (){
  84. var stafftype=$(this).val();
  85. if(stafftype == 1 || stafftype == 2){
  86. $(this).parent('td').next('td').find('div').show();
  87. }else{
  88. $(this).parent('td').next('td').find('div').hide();
  89. }
  90. }).on('change','[name="row[status]"]',function (){
  91. var status=$(this).val();
  92. console.log(status)
  93. if(status == 1){
  94. $('.status_text').show();
  95. }else{
  96. $('.status_text').hide();
  97. }
  98. })
  99. Form.api.bindevent($("form[role=form]"));
  100. },
  101. formatter : {
  102. thumb : function (value, row, index) {
  103. return '<img src="' + row.img + '" data-tips-image alt="" title="封面图" style="max-height:90px;max-width:120px">';
  104. },
  105. }
  106. }
  107. };
  108. return Controller;
  109. });