mkactivitiescoupon.js 4.7 KB

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