donate.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. function queryParams (data, isPrefix) {
  3. isPrefix = isPrefix ? isPrefix : false
  4. let prefix = isPrefix ? '?' : ''
  5. let _result = []
  6. for (let key in data) {
  7. let value = data[key]
  8. // 去掉为空的参数
  9. if (['', undefined, null].includes(value)) {
  10. continue
  11. }
  12. if (value.constructor === Array) {
  13. value.forEach(_value => {
  14. _result.push(encodeURIComponent(key) + '[]=' + encodeURIComponent(_value))
  15. })
  16. } else {
  17. _result.push(encodeURIComponent(key) + '=' + encodeURIComponent(value))
  18. }
  19. }
  20. return _result.length ? prefix + _result.join('&') : ''
  21. }
  22. var inof = {}
  23. var Controller = {
  24. index: function () {
  25. // 初始化表格参数配置
  26. Table.api.init({
  27. extend: {
  28. index_url: 'donate/index' + location.search,
  29. add_url: 'donate/add',
  30. edit_url: 'donate/edit',
  31. del_url: 'donate/del',
  32. multi_url: 'donate/multi',
  33. import_url: 'donate/import',
  34. table: 'donate',
  35. }
  36. });
  37. var table = $("#table");
  38. // 初始化表格
  39. table.bootstrapTable({
  40. url: $.fn.bootstrapTable.defaults.extend.index_url,
  41. pk: 'id',
  42. sortName: 'id',
  43. onClickRow:function(row, $element, field)
  44. {
  45. console.log($element)
  46. info = row
  47. console.log(row,'row')
  48. },
  49. columns: [
  50. [
  51. {checkbox: true},
  52. {field: 'id', title: __('Id')},
  53. {field: 'cid', title: __('Cid')},
  54. {field: 'user_id', title: __('User_id')},
  55. {field: 'full_name', title: __('Full_name'), operate: 'LIKE'},
  56. {field: 'sex', title: __('Sex'), searchList: {"0":__('Sex 0'),"1":__('Sex 1')}, formatter: Table.api.formatter.normal},
  57. {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  58. {field: 'id_card', title: __('Id_card'), operate: 'LIKE'},
  59. {field: 'vocation', title: __('Vocation'), operate: 'LIKE'},
  60. {field: 'education', title: __('Education'), searchList: {"0":__('Education 0'),"1":__('Education 1'),"2":__('Education 2'),"3":__('Education 3'),"4":__('Education 4'),"5":__('Education 5'),"6":__('Education 6'),"7":__('Education 7'),"8":__('Education 8'),"9":__('Education 9')}, formatter: Table.api.formatter.normal},
  61. {field: 'category_id', title: __('Category_id'), operate: 'LIKE'},
  62. {field: 'tel', title: __('Tel'), operate: 'LIKE'},
  63. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  64. {field: 'executor', title: __('Executor'), operate: 'LIKE'},
  65. {field: 'executor_id_card', title: __('Executor_id_card'), operate: 'LIKE'},
  66. {field: 'executor_tel', title: __('Executor_tel'), operate: 'LIKE'},
  67. {field: 'executor_mobile', title: __('Executor_mobile'), operate: 'LIKE'},
  68. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  69. {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
  70. {field: 'SN', title: __('Sn'), operate: 'LIKE'},
  71. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons:[{
  72. name: 'daying',
  73. title: '打印',
  74. text: '打印',
  75. icon: 'fa',
  76. classname: 'btn btn-xs btn-info daying'
  77. // url: 'info'
  78. }]}
  79. ]
  80. ]
  81. });
  82. // 为表格绑定事件
  83. Table.api.bindevent(table);
  84. $("#table").on("click",".daying",function () {
  85. // alert('点击了打印')
  86. window.open("http://red.liuniu946.com/dru/donation.html?" + queryParams(info))
  87. })
  88. },
  89. add: function () {
  90. $("#c-user_id").data("params", function (obj) {
  91. return {custom: {cid: $("#c-cid").val()}};
  92. });
  93. Controller.api.bindevent();
  94. },
  95. edit: function () {
  96. $("#c-user_id").data("params", function (obj) {
  97. return {custom: {cid: $("#c-cid").val()}};
  98. });
  99. Controller.api.bindevent();
  100. },
  101. api: {
  102. bindevent: function () {
  103. Form.api.bindevent($("form[role=form]"));
  104. }
  105. }
  106. };
  107. return Controller;
  108. });