account.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 : 'qingdongams/finance/account/index',
  8. add_url: 'qingdongams/finance/account/add',
  9. edit_url: 'qingdongams/finance/account/edit',
  10. del_url: 'qingdongams/finance/account/del',
  11. table : 'account',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url : $.fn.bootstrapTable.defaults.extend.index_url,
  18. pk : 'id',
  19. sortName : 'id',
  20. fixedColumns : true,
  21. fixedNumber : 2,
  22. search:false,
  23. searchFormVisible:true,
  24. columns : [
  25. [
  26. {checkbox : true},
  27. {field : 'deposit', title : '开户行', fixedColumns : true,operate:'like'},
  28. {field : 'name', title : '收款账号名称',operate:'like'},
  29. {field : 'account', title : '收款账号',operate:false},
  30. {field : 'status', title : '状态', formatter : Table.api.formatter.status,
  31. searchList : {0 : '禁用', 1 : '正常'}},
  32. {field : 'type', title : '账户类型', formatter : Table.api.formatter.status,
  33. searchList : {'public' : '公账', 'private' : '私账'}},
  34. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: false, addclass: 'datetimerange', sortable: true},
  35. {
  36. field : 'operate',
  37. title : __('Operate'),
  38. table : table,
  39. events : Table.api.events.operate,
  40. formatter : Table.api.formatter.operate,
  41. buttons : [
  42. {
  43. name: 'edit',
  44. text: __('编辑'),
  45. title: __('编辑'),
  46. classname: 'records btn-dialog',
  47. url: 'qingdongams/finance/account/edit',
  48. visible: function (row) {
  49. //返回true时按钮显示,返回false隐藏
  50. return true;
  51. }
  52. },
  53. {
  54. name: 'del',
  55. text: __('删除'),
  56. title: __('删除'),
  57. classname: 'records btn-ajax',
  58. url: 'qingdongams/finance/account/del',
  59. confirm: '确定要删除吗?',
  60. refresh:true,
  61. error: function (data, ret) {
  62. console.log(data, ret);
  63. Layer.alert(ret.msg);
  64. return false;
  65. },
  66. visible: function (row) {
  67. //返回true时按钮显示,返回false隐藏
  68. return true;
  69. }
  70. },
  71. ]
  72. }
  73. ]
  74. ]
  75. });
  76. $('.y_submit').on('click',function(){
  77. $("form[role=form]").submit();
  78. })
  79. // 为表格绑定事件
  80. Table.api.bindevent(table);
  81. },
  82. add : function () {
  83. Controller.api.bindevent();
  84. },
  85. edit : function () {
  86. Controller.api.bindevent();
  87. },
  88. api : {
  89. bindevent : function () {
  90. Form.api.bindevent($("form[role=form]"), function(data, ret){
  91. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  92. Fast.api.close(data);//这里是重点
  93. });
  94. }
  95. }
  96. };
  97. return Controller;
  98. });