mk2goodstopichistoryprice.js 4.0 KB

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