org-dropdown-list.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. (function() {
  2. $.jgrid.defaults.styleUI="Bootstrap";
  3. Vue.component('org-dropdown-list', {
  4. template: '<div class="mt10">\
  5. <form id="searchbar" onsubmit="return false;" >\
  6. <div class="clearfix" >\
  7. <div class="dataCell form-group">\
  8. <label for="orgCode" class="cellTitle">机构编号:</label>\
  9. <input v-model="orgCode" id="orgCode" name="orgCode" class="form-control inline w150 ml5" type="text" placeholder="">\
  10. </div>\
  11. <div class="dataCell form-group">\
  12. <label for="orgName" class="cellTitle">机构名称:</label>\
  13. <input v-model="orgName" id="orgName" name="orgName" class="form-control inline w150 ml5" type="text" placeholder="">\
  14. </div>\
  15. <div class="form-group ">\
  16. <button @click="search" class="btn btn-primary w50 ml10" type="submit">搜索</button>\
  17. <button @click="confirm" class="btn btn-success w50 ml10" type="submit">确定</button>\
  18. <!--<button @click="reset" class="btn btn-white w50 ml10" type="submit">重置</button> -->\
  19. </div>\
  20. </div>\
  21. </form>\
  22. <div ref="container" style="overflow-x: hidden">\
  23. <div class="jqGrid_wrapper">\
  24. <table id="table_list"></table>\
  25. </div>\
  26. </div>\
  27. <div id="pager_list">\
  28. </div>\
  29. </div>',
  30. props: [],
  31. data: function() {
  32. return {
  33. orgName: "",
  34. orgCode: ""
  35. }
  36. },
  37. mounted: function() {
  38. initTable()
  39. initContainer(this)
  40. initEventOnBus()
  41. this.search()
  42. },
  43. methods: {
  44. goBack: function() {
  45. var layerid = parent.layer.getFrameIndex(window.name)
  46. parent.layer.close(layerid)
  47. },
  48. search: function() {
  49. var vm = this
  50. $("#table_list").jqGrid('setGridParam',{datatype:'json', page: 1, postData: {
  51. agency_code: vm.orgCode,
  52. shanhu_name: vm.orgName
  53. }}).trigger('reloadGrid');
  54. },
  55. confirm: function() {
  56. var rowId = $("#table_list").jqGrid('getGridParam','selrow')
  57. var rowData = $("#table_list").jqGrid('getRowData',rowId);
  58. top.GlobalEventBus.$emit("org-dropdown-list:selected", rowData)
  59. this.goBack()
  60. },
  61. reset: function() {
  62. vm.orgName = ""
  63. vm.orgCode = ""
  64. this.search()
  65. }
  66. }
  67. })
  68. function resetWidth(vm) {
  69. var $searchbar = $("#searchbar")
  70. $("#table_list").setGridWidth($(window).width());
  71. $("#table_list").jqGrid("setGridHeight", $(window).height() - $searchbar.height() - 153)
  72. }
  73. function initContainer(vm) {
  74. resetWidth(vm)
  75. window.onresize = function() {
  76. resetWidth(vm)
  77. }
  78. }
  79. function initEventOnBus() {
  80. EventBus.$on('org-dropdown-list-search', function (arg) {
  81. $("#table_list").jqGrid('setGridParam',{datatype:'json', page: 1, postData: arg}).trigger('reloadGrid');
  82. })
  83. }
  84. function initTable() {
  85. $("#table_list").jqGrid({
  86. url: httpRequest.server+"/w0/Hlpay/Web/getShanhuList.html",
  87. datatype:"json",
  88. mtype: 'POST',
  89. ajaxGridOptions: {
  90. beforeSend: function(request, grid) {
  91. var userAgent = window.localStorage.getItem(httpRequest.agentName);
  92. request.setRequestHeader(httpRequest.agentName, userAgent);
  93. }
  94. },
  95. postData: {
  96. },
  97. prmNames: {
  98. page: "pageno",
  99. rows: "rowcount"
  100. },
  101. rowNum: 10,
  102. jsonReader: {
  103. root: "data",
  104. page: "pageno",
  105. records: "total",
  106. total: "totalpages"
  107. },
  108. height:400,
  109. autowidth:true,
  110. shrinkToFit:true,
  111. rowNum:10,
  112. rowList:[10,20,30],
  113. colNames:["机构编号","机构名称"],
  114. colModel:[
  115. {name:"code",index:"code",width:150},
  116. {name:"name",index:"name",width:150}
  117. ],
  118. pager:"#pager_list",
  119. pagerpos: "left",
  120. viewrecords:true,
  121. hidegrid:false})
  122. }
  123. })()