mkactivitiescombinationprice.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../mkactivitiescombinationprice/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'macpId', name: 'macpId', index: 'macp_id', key: true, hidden: true},
  7. {label: '商品编码', name: 'goodsSn', index: 'goods_sn', width: 80},
  8. {label: '条形码', name: 'barcode', index: 'barcode', width: 80},
  9. {label: '组合的产品数量', name: 'combinationNum', index: 'combination_num', width: 80},
  10. {label: '组合价', name: 'combinedPrice', index: 'combined_price', width: 80},
  11. {label: '营销活动编号', name: 'mkaId', index: 'mka_id', width: 80},
  12. {label: '截止日期', name: 'deadline', index: 'deadline', width: 80}],
  13. viewrecords: true,
  14. height: 550,
  15. rowNum: 10,
  16. rowList: [10, 30, 50],
  17. rownumbers: true,
  18. rownumWidth: 25,
  19. autowidth: true,
  20. multiselect: true,
  21. pager: "#jqGridPager",
  22. jsonReader: {
  23. root: "page.list",
  24. page: "page.currPage",
  25. total: "page.totalPage",
  26. records: "page.totalCount"
  27. },
  28. prmNames: {
  29. page: "page",
  30. rows: "limit",
  31. order: "order"
  32. },
  33. gridComplete: function () {
  34. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  35. }
  36. });
  37. let flag = getQueryString("flag");
  38. if(flag != null && flag == "false"){
  39. vm.isMkactivitiesShow = false;
  40. }
  41. let mkCode = getQueryString("mkCode");
  42. if(mkCode){
  43. vm.mkCode = mkCode;
  44. }
  45. });
  46. let vm = new Vue({
  47. el: '#rrapp',
  48. data: {
  49. showList: true,
  50. title: null,
  51. mkActivitiesCombinationPrice: {},
  52. ruleValidate: {
  53. name: [
  54. {required: true, message: '名称不能为空', trigger: 'blur'}
  55. ]
  56. },
  57. q: {
  58. name: ''
  59. },
  60. isMkactivitiesShow: true,
  61. mkCode: ''
  62. },
  63. methods: {
  64. query: function () {
  65. vm.reload();
  66. },
  67. add: function () {
  68. vm.showList = false;
  69. vm.title = "新增";
  70. vm.mkActivitiesCombinationPrice = {};
  71. },
  72. update: function (event) {
  73. let macpId = getSelectedRow();
  74. if (macpId == null) {
  75. return;
  76. }
  77. vm.showList = false;
  78. vm.title = "修改";
  79. vm.getInfo(macpId)
  80. },
  81. saveOrUpdate: function (event) {
  82. let url = vm.mkActivitiesCombinationPrice.macpId == null ? "../mkactivitiescombinationprice/save" : "../mkactivitiescombinationprice/update";
  83. $.ajax({
  84. type: "POST",
  85. url: url,
  86. contentType: "application/json",
  87. data: JSON.stringify(vm.mkActivitiesCombinationPrice),
  88. success: function (r) {
  89. if (r.code === 0) {
  90. alert('操作成功', function (index) {
  91. vm.reload();
  92. });
  93. } else {
  94. alert(r.msg);
  95. }
  96. }
  97. });
  98. },
  99. del: function (event) {
  100. let macpIds = getSelectedRows();
  101. if (macpIds == null){
  102. return;
  103. }
  104. confirm('确定要删除选中的记录?', function () {
  105. $.ajax({
  106. type: "POST",
  107. url: "../mkactivitiescombinationprice/delete",
  108. contentType: "application/json",
  109. data: JSON.stringify(macpIds),
  110. success: function (r) {
  111. if (r.code == 0) {
  112. alert('操作成功', function (index) {
  113. $("#jqGrid").trigger("reloadGrid");
  114. });
  115. } else {
  116. alert(r.msg);
  117. }
  118. }
  119. });
  120. });
  121. },
  122. getInfo: function(macpId){
  123. $.get("../mkactivitiescombinationprice/info/"+macpId, function (r) {
  124. vm.mkActivitiesCombinationPrice = r.mkActivitiesCombinationPrice;
  125. });
  126. },
  127. reloadSearch: function() {
  128. vm.q = {
  129. name: ''
  130. }
  131. vm.reload();
  132. },
  133. reload: function (event) {
  134. vm.showList = true;
  135. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  136. $("#jqGrid").jqGrid('setGridParam', {
  137. postData: {'name': vm.q.name},
  138. page: page
  139. }).trigger("reloadGrid");
  140. vm.handleReset('formValidate');
  141. },
  142. handleSubmit: function (name) {
  143. handleSubmitValidate(this, name, function () {
  144. vm.saveOrUpdate()
  145. });
  146. },
  147. handleReset: function (name) {
  148. handleResetForm(this, name);
  149. },
  150. //返回营销方式页
  151. reloadMkactivities: function () {
  152. window.location.href = "/mk/mkactivityform.html?mkCode="+vm.mkCode;
  153. }
  154. }
  155. });