1
0

mk2goodstopichistoryprice.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../mk2goodstopichistoryprice/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'mgthpId', name: 'mgthpId', index: 'mgthp_id', key: true, hidden: true},
  7. {label: '活动id', name: 'topicId', index: 'topic_id', align: 'center',width: 80},
  8. {label: '活动类别', name: 'topicType', index: 'topic_type', align: 'center',width: 180},
  9. {label: '活动价格', name: 'topicPrice', index: 'topic_price', align: 'right',width: 120},
  10. {label: '活动名称', name: 'topicName', index: 'topic_name',align: 'center', width: 180},
  11. {label: '活动内容', name: 'topicContent', index: 'topic_content', width: 280}],
  12. viewrecords: true,
  13. height: 550,
  14. rowNum: 10,
  15. rowList: [10, 30, 50],
  16. rownumbers: true,
  17. rownumWidth: 25,
  18. autowidth: true,
  19. shrinkToFit: false,
  20. autoScroll: true, //开启水平滚动条
  21. width: 1500,
  22. pager: "#jqGridPager",
  23. jsonReader: {
  24. root: "page.list",
  25. page: "page.currPage",
  26. total: "page.totalPage",
  27. records: "page.totalCount"
  28. },
  29. prmNames: {
  30. page: "page",
  31. rows: "limit",
  32. order: "order"
  33. },
  34. gridComplete: function () {
  35. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
  36. }
  37. });
  38. });
  39. let vm = new Vue({
  40. el: '#rrapp',
  41. data: {
  42. showList: true,
  43. title: null,
  44. mk2GoodsTopicHistoryPrice: {},
  45. ruleValidate: {
  46. name: [
  47. {required: true, message: '名称不能为空', trigger: 'blur'}
  48. ]
  49. },
  50. q: {
  51. topicName: ''
  52. }
  53. },
  54. methods: {
  55. query: function () {
  56. vm.reload();
  57. },
  58. add: function () {
  59. vm.showList = false;
  60. vm.title = "新增";
  61. vm.mk2GoodsTopicHistoryPrice = {};
  62. },
  63. update: function (event) {
  64. let mgthpId = getSelectedRow();
  65. if (mgthpId == null) {
  66. return;
  67. }
  68. vm.showList = false;
  69. vm.title = "修改";
  70. vm.getInfo(mgthpId)
  71. },
  72. saveOrUpdate: function (event) {
  73. let url = vm.mk2GoodsTopicHistoryPrice.mgthpId == null ? "../mk2goodstopichistoryprice/save" : "../mk2goodstopichistoryprice/update";
  74. $.ajax({
  75. type: "POST",
  76. url: url,
  77. contentType: "application/json",
  78. data: JSON.stringify(vm.mk2GoodsTopicHistoryPrice),
  79. success: function (r) {
  80. if (r.code === 0) {
  81. alert('操作成功', function (index) {
  82. vm.reload();
  83. });
  84. } else {
  85. alert(r.msg);
  86. }
  87. }
  88. });
  89. },
  90. del: function (event) {
  91. let mgthpIds = getSelectedRows();
  92. if (mgthpIds == null){
  93. return;
  94. }
  95. confirm('确定要删除选中的记录?', function () {
  96. $.ajax({
  97. type: "POST",
  98. url: "../mk2goodstopichistoryprice/delete",
  99. contentType: "application/json",
  100. data: JSON.stringify(mgthpIds),
  101. success: function (r) {
  102. if (r.code == 0) {
  103. alert('操作成功', function (index) {
  104. $("#jqGrid").trigger("reloadGrid");
  105. });
  106. } else {
  107. alert(r.msg);
  108. }
  109. }
  110. });
  111. });
  112. },
  113. getInfo: function(mgthpId){
  114. $.get("../mk2goodstopichistoryprice/info/"+mgthpId, function (r) {
  115. vm.mk2GoodsTopicHistoryPrice = r.mk2GoodsTopicHistoryPrice;
  116. });
  117. },
  118. reloadSearch: function() {
  119. vm.q = {
  120. topicName: ''
  121. }
  122. vm.reload();
  123. },
  124. reload: function (event) {
  125. vm.showList = true;
  126. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  127. $("#jqGrid").jqGrid('setGridParam', {
  128. postData: {'topicName': vm.q.topicName},
  129. page: page
  130. }).trigger("reloadGrid");
  131. vm.handleReset('formValidate');
  132. },
  133. handleSubmit: function (name) {
  134. handleSubmitValidate(this, name, function () {
  135. vm.saveOrUpdate()
  136. });
  137. },
  138. handleReset: function (name) {
  139. handleResetForm(this, name);
  140. }
  141. }
  142. });