apply.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 info = {}
  23. var Controller = {
  24. index: function () {
  25. // 初始化表格参数配置
  26. Table.api.init({
  27. extend: {
  28. index_url: 'user/apply/index' + location.search,
  29. add_url: 'user/apply/add',
  30. edit_url: 'user/apply/edit',
  31. del_url: 'user/apply/del',
  32. multi_url: 'user/apply/multi',
  33. import_url: 'user/apply/import',
  34. table: 'user_apply',
  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: 'vocation', title: __('Vocation'), operate: 'LIKE'},
  57. {field: 'position', title: __('Position'), operate: 'LIKE'},
  58. {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},
  59. {field: 'tel', title: __('Tel'), operate: 'LIKE'},
  60. {field: 'address', title: __('Address'), operate: 'LIKE'},
  61. {field: 'company_name', title: __('Company_name'), operate: 'LIKE'},
  62. {field: 'nature', title: __('Nature'), operate: 'LIKE'},
  63. {field: 'legal_person', title: __('Legal_person'), operate: 'LIKE'},
  64. {field: 'zip_code', title: __('Zip_code'), operate: 'LIKE'},
  65. {field: 'compnay_address', title: __('Compnay_address'), operate: 'LIKE'},
  66. {field: 'company_email', title: __('Company_email'), operate: 'LIKE'},
  67. {field: 'certificateimage', title: __('Certificateimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  68. {field: 'id_card', title: __('Id_card'), operate: 'LIKE'},
  69. {field: 'nation', title: __('Nation'), operate: 'LIKE'},
  70. {field: 'birthday', title: __('Birthday'), operate: 'LIKE'},
  71. {field: 'user_type', title: __('User_type'), searchList: {"0":__('User_type 0'),"1":__('User_type 1'),"2":__('User_type 2')}, formatter: Table.api.formatter.normal},
  72. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  73. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons:[{
  74. name: 'daying',
  75. title: '打印',
  76. text: '打印',
  77. icon: 'fa',
  78. classname: 'btn btn-xs btn-info daying'
  79. // url: 'info'
  80. }]}
  81. ]
  82. ]
  83. });
  84. // 为表格绑定事件
  85. Table.api.bindevent(table);
  86. $("#table").on("click",".daying",function () {
  87. // alert('点击了打印')
  88. if(info.user_type == 2) {
  89. window.open("http://red.liuniu946.com/dru/group.html?" + queryParams(info))
  90. }else {
  91. window.open("http://red.liuniu946.com/dru/personal.html?" + queryParams(info))
  92. }
  93. })
  94. },
  95. daying: function () {
  96. // alert(JSON.stringify(row));
  97. console.log('点击打印')
  98. Controller.api.bindevent();
  99. console.log('点击打印+++')
  100. },
  101. add: function () {
  102. $("#c-user_id").data("params", function (obj) {
  103. return {custom: {cid: $("#c-cid").val()}};
  104. });
  105. Controller.api.bindevent();
  106. },
  107. edit: function () {
  108. $("#c-user_id").data("params", function (obj) {
  109. return {custom: {cid: $("#c-cid").val()}};
  110. });
  111. Controller.api.bindevent();
  112. },
  113. api: {
  114. bindevent: function () {
  115. Form.api.bindevent($("form[role=form]"));
  116. }
  117. }
  118. };
  119. return Controller;
  120. });