1
0

coupongrads.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. $(function () {
  2. let sendType = getQueryString("sendType");
  3. let menuName = getQueryString("menuName");
  4. let url = '../coupon/list';
  5. if (sendType) {
  6. url += '?sendType=' + sendType;
  7. vm.sendType = sendType;
  8. vm.menuName = menuName;
  9. }
  10. $("#jqGrid").Grid({
  11. url: url,
  12. colModel: [
  13. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  14. {label: '优惠券名称', name: 'name', index: 'name', width: 120},
  15. /*{
  16. label: '优惠券类型', name: 'couponType', index: 'couponType', width: 80,
  17. formatter: function (value) {
  18. if (value == 0) {
  19. return '通用优惠券';
  20. } else if (value == 1) {
  21. return '门店优惠券';
  22. } else if (value == 2) {
  23. return '产品优惠券';
  24. }
  25. return '-';
  26. }
  27. },*/
  28. /*{
  29. label: '状态', name: 'status', index: 'status', width: 50,
  30. formatter: function (value) {
  31. if (value == 0) {
  32. return '失效';
  33. } else if (value == 1) {
  34. return '正常';
  35. }
  36. return '-';
  37. }
  38. },*/
  39. {label: '订单最小金额', name: 'minAmount', index: 'minAmount', width: 80},
  40. {label: '订单最大金额', name: 'maxAmount', index: 'maxAmount', width: 80},
  41. {label: '金额', name: 'typeMoney', index: 'type_money', width: 80},
  42. // {label: '最小商品金额', name: 'minGoodsAmount', index: 'min_goods_amount', width: 80},
  43. {label: '有效天数', name: 'invalidDays', index: 'invalidDays', width: 80}
  44. /*{
  45. label: '操作', width: 70, align: 'center', sortable: false,
  46. formatter: function (value, col, row) {
  47. if (row.couponType == 1) {
  48. return '<button class="btn btn-outline btn-info ivu-btn-small" onclick="vm.lookCouponStoreList(' + row.id + ',\'' + row.name + '\')"><i class="fa fa-info-circle"></i>&nbsp;门店列表</button>&nbsp;';
  49. } else if (row.couponType == 2) {
  50. return '<button class="btn btn-outline btn-info ivu-btn-small" onclick="vm.lookCouponProductList(' + row.id + ',\'' + row.name + '\')"><i class="fa fa-info-circle"></i>&nbsp;产品列表</button>&nbsp;';
  51. }
  52. return '';
  53. }
  54. }*/
  55. ],
  56. multiselect: true
  57. });
  58. });
  59. var vm = new Vue({
  60. el: '#rrapp',
  61. data: {
  62. showDiv: 1,// 1List 2edit 3publish 4store 5product
  63. title: null,
  64. menuName: null,
  65. sendType: 0,
  66. coupon: {sendType: 0, status: 1, couponType: 0, name: '', minAmount: 0, maxAmount: 0, minGoodsAmount: 0},
  67. ruleValidate: {
  68. name: [
  69. {required: true, message: '优惠券名称不能为空', trigger: 'blur'}
  70. ]
  71. },
  72. q: {
  73. name: ''
  74. },
  75. storeList: [],
  76. merchList: []
  77. },
  78. methods: {
  79. query: function () {
  80. vm.reload();
  81. },
  82. add: function () {
  83. vm.showDiv = 2;
  84. vm.title = "新增";
  85. vm.coupon = {
  86. sendType: vm.sendType,
  87. status: 1,
  88. couponType: 0,
  89. name: '',
  90. minAmount: 0,
  91. maxAmount: 0,
  92. minGoodsAmount: 0
  93. };
  94. vm.storeList = [];
  95. vm.merchList = [];
  96. vm.getMerchList();
  97. },
  98. update: function (event) {
  99. var id = getSelectedRow();
  100. if (id == null) {
  101. return;
  102. }
  103. vm.showDiv = 2;
  104. vm.title = "修改";
  105. vm.getInfo(id);
  106. vm.getMerchList();
  107. vm.getStoresByMerch();
  108. },
  109. saveOrUpdate: function (event) {
  110. var url = vm.coupon.id == null ? "../coupon/save" : "../coupon/update";
  111. Ajax.request({
  112. url: url,
  113. params: JSON.stringify(vm.coupon),
  114. contentType: "application/json",
  115. type: 'POST',
  116. successCallback: function () {
  117. alert('操作成功', function (index) {
  118. vm.reload();
  119. });
  120. }
  121. });
  122. },
  123. del: function (event) {
  124. var ids = getSelectedRows();
  125. if (ids == null) {
  126. return;
  127. }
  128. confirm('确定要删除选中的记录?', function () {
  129. Ajax.request({
  130. url: "../coupon/delete",
  131. params: JSON.stringify(ids),
  132. contentType: "application/json",
  133. type: 'POST',
  134. successCallback: function () {
  135. alert('操作成功', function (index) {
  136. vm.reload();
  137. });
  138. }
  139. });
  140. });
  141. },
  142. getInfo: function (id) {
  143. Ajax.request({
  144. url: "../coupon/info/" + id,
  145. async: true,
  146. successCallback: function (r) {
  147. vm.coupon = r.coupon;
  148. }
  149. });
  150. },
  151. getStoresByMerch: function (opt) {
  152. var value = opt.value;
  153. $.get("../store/getStoresByMerch?merchSn=" + value, function (r) {
  154. vm.storeList = r.list;
  155. });
  156. },
  157. getMerchList: function() {
  158. $.get("../merch/queryAll", function (r) {
  159. vm.merchList = r.list;
  160. });
  161. },
  162. reload: function (event) {
  163. vm.showDiv = 1;
  164. var page = $("#jqGrid").jqGrid('getGridParam', 'page');
  165. $("#jqGrid").jqGrid('setGridParam', {
  166. postData: {'name': vm.q.name},
  167. page: page
  168. }).trigger("reloadGrid");
  169. vm.handleReset('formValidate');
  170. },
  171. handleSubmit: function (name) {
  172. handleSubmitValidate(this, name, function () {
  173. vm.saveOrUpdate()
  174. });
  175. },
  176. handleReset: function (name) {
  177. handleResetForm(this, name);
  178. },
  179. }
  180. });