searchhistory.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../searchhistory/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '关键字', name: 'keyword', index: 'keyword', width: 80 },
  8. // {label: '搜索来源', name: 'from', index: 'from', width: 80 },
  9. {label: '搜索时间', name: 'addTime', index: 'add_time', width: 80 },
  10. {label: '会员', name: 'userName', index: 'user_name', width: 80 } ],
  11. viewrecords: true,
  12. height: 550,
  13. rowNum: 10,
  14. rowList: [10, 30, 50],
  15. rownumbers: true,
  16. rownumWidth: 25,
  17. autowidth:true,
  18. multiselect: true,
  19. pager: "#jqGridPager",
  20. jsonReader: {
  21. root: "page.list",
  22. page: "page.currPage",
  23. total: "page.totalPage",
  24. records: "page.totalCount"
  25. },
  26. prmNames: {
  27. page: "page",
  28. rows: "limit",
  29. order: "order"
  30. },
  31. gridComplete: function () {
  32. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  33. }
  34. });
  35. });
  36. var vm = new Vue({
  37. el:'#rrapp',
  38. data:{
  39. showList: true,
  40. title: null,
  41. searchHistory: {},
  42. q: {
  43. name: ''
  44. }
  45. },
  46. methods: {
  47. query: function () {
  48. vm.reload();
  49. },
  50. add: function(){
  51. vm.showList = false;
  52. vm.title = "新增";
  53. vm.searchHistory = {};
  54. },
  55. update: function (event) {
  56. var id = getSelectedRow();
  57. if(id == null){
  58. return ;
  59. }
  60. vm.showList = false;
  61. vm.title = "修改";
  62. vm.getInfo(id)
  63. },
  64. saveOrUpdate: function (event) {
  65. var url = vm.searchHistory.id == null ? "../searchhistory/save" : "../searchhistory/update";
  66. $.ajax({
  67. type: "POST",
  68. url: url,
  69. contentType: "application/json",
  70. data: JSON.stringify(vm.searchHistory),
  71. success: function(r){
  72. if(r.code === 0){
  73. alert('操作成功', function(index){
  74. vm.reload();
  75. });
  76. }else{
  77. alert(r.msg);
  78. }
  79. }
  80. });
  81. },
  82. del: function (event) {
  83. var ids = getSelectedRows();
  84. if(ids == null){
  85. return ;
  86. }
  87. confirm('确定要删除选中的记录?', function(){
  88. $.ajax({
  89. type: "POST",
  90. url: "../searchhistory/delete",
  91. contentType: "application/json",
  92. data: JSON.stringify(ids),
  93. success: function(r){
  94. if(r.code == 0){
  95. alert('操作成功', function(index){
  96. $("#jqGrid").trigger("reloadGrid");
  97. });
  98. }else{
  99. alert(r.msg);
  100. }
  101. }
  102. });
  103. });
  104. },
  105. getInfo: function(id){
  106. $.get("../searchhistory/info/"+id, function(r){
  107. vm.searchHistory = r.searchHistory;
  108. });
  109. },
  110. reload: function (event) {
  111. vm.showList = true;
  112. var page = $("#jqGrid").jqGrid('getGridParam','page');
  113. $("#jqGrid").jqGrid('setGridParam',{
  114. postData: {'name': vm.q.name},
  115. page:page
  116. }).trigger("reloadGrid");
  117. }
  118. }
  119. });