volunteer.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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: 'training/volunteer/index' + location.search,
  29. add_url: 'training/volunteer/add',
  30. edit_url: 'training/volunteer/edit',
  31. del_url: 'training/volunteer/del',
  32. multi_url: 'training/volunteer/multi',
  33. import_url: 'training/volunteer/import',
  34. table: 'volunteer',
  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: 'name', title: __('Name'), operate: 'LIKE'},
  56. {field: 'phone', title: __('Phone'), operate: 'LIKE'},
  57. {field: 'sex', title: __('Sex'), searchList: {"0":__('Sex 0'),"1":__('Sex 1')}, formatter: Table.api.formatter.normal},
  58. {field: 'birth', title: __('Birth'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  59. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  60. {field: 'certificateimage', title: __('Certificateimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  61. {field: 'email', title: __('Email'), operate: 'LIKE'},
  62. {field: 'address', title: __('Address'), operate: 'LIKE'},
  63. {field: 'work', title: __('Work'), operate: 'LIKE'},
  64. {field: 'specialty', title: __('Specialty'), operate: 'LIKE'},
  65. {field: 'education', title: __('Education'), operate: 'LIKE'},
  66. {field: 'is_vol', title: __('Is_vol'), searchList: {"0":__('Is_vol 0'),"1":__('Is_vol 1')}, formatter: Table.api.formatter.normal},
  67. {field: 'is_experience', title: __('Is_experience'), searchList: {"0":__('Is_experience 0'),"1":__('Is_experience 1')}, formatter: Table.api.formatter.normal},
  68. {field: 'start_hour', title: __('Start_hour')},
  69. {field: 'end_hour', title: __('End_hour')},
  70. {field: 'work_week', title: __('Work_week'), searchList: {"1":__('Work_week 1'),"2":__('Work_week 2'),"3":__('Work_week 3'),"4":__('Work_week 4'),"5":__('Work_week 5'),"6":__('Work_week 6'),"7":__('Work_week 7')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label},
  71. {field: 'taste', title: __('Taste'), operate: 'LIKE'},
  72. {field: 'taste_title', title: __('Taste_title'), operate: 'LIKE'},
  73. {field: 'speciali', title: __('Speciali'), operate: 'LIKE'},
  74. {field: 'speciali_title', title: __('Speciali_title'), operate: 'LIKE'},
  75. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  76. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  77. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  78. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons:[{
  79. name: 'daying',
  80. title: '打印',
  81. text: '打印',
  82. icon: 'fa',
  83. classname: 'btn btn-xs btn-info daying'
  84. // url: 'info'
  85. }]}
  86. ]
  87. ]
  88. });
  89. // 为表格绑定事件
  90. Table.api.bindevent(table);
  91. $("#table").on("click",".daying",function () {
  92. // alert('点击了打印')
  93. window.open("http://red.liuniu946.com/dru/zyz.html?" + queryParams(info))
  94. })
  95. },
  96. daying: function () {
  97. // alert(JSON.stringify(row));
  98. console.log('点击打印')
  99. Controller.api.bindevent();
  100. console.log('点击打印+++')
  101. },
  102. add: function () {
  103. $("#c-user_id").data("params", function (obj) {
  104. return {custom: {cid: $("#c-cid").val()}};
  105. });
  106. Controller.api.bindevent();
  107. },
  108. edit: function () {
  109. $("#c-user_id").data("params", function (obj) {
  110. return {custom: {cid: $("#c-cid").val()}};
  111. });
  112. Controller.api.bindevent();
  113. },
  114. api: {
  115. bindevent: function () {
  116. Form.api.bindevent($("form[role=form]"));
  117. }
  118. }
  119. };
  120. return Controller;
  121. });