mall2pointsrules.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../mall2pointsrules/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'ID', name: 'mprId', index: 'mpr_id', key: true, hidden: true},
  7. {
  8. label: '积分类型', name: 'pointsType', index: 'points_type', width: 80, formatter: function (value) {
  9. if (value === '0' || value === 0) {
  10. return '门店';
  11. }
  12. if (value == '1' || value === 1) {
  13. return '商品类别';
  14. }
  15. if (value == '2' || value === 2) {
  16. return '门店商品';
  17. }
  18. }
  19. },
  20. // {label: '积分金额', name: 'pointsRulesMoney', index: 'points_rules_money', width: 80},
  21. // {label: '对应积分数', name: 'pointsRulesNum', index: 'points_rules_num', width: 80},
  22. {label: '对应积分生成比例', name: 'ratio', index: 'ratio', width: 80},
  23. {
  24. label: '规则适用开始时间', name: 'pointsBeginTime', index: 'points_begin_time',align:"center", width: 200
  25. },
  26. {
  27. label: '规则适用结束时间', name: 'pointsEndTime', index: 'points_end_time',align:"center", width: 200
  28. },
  29. {
  30. label: '是否有效', name: 'isValid', index: 'is_valid', width: 80, formatter: function (value) {
  31. if (value === '0' || value === 0) {
  32. return '是';
  33. }
  34. if (value == '1') {
  35. return '否';
  36. }
  37. }
  38. },
  39. {label: '操作', width: 80, align: 'center',
  40. formatter: function (value, col, row) {
  41. htmlStr = "<button class='btn btn-outline btn-primary' " +
  42. "onclick='vm.showMkactivitiesGoods(\""+row.mprId+"\")'>管理详情</button>";
  43. return htmlStr;
  44. }
  45. }
  46. ],
  47. viewrecords: true,
  48. height: 550,
  49. rowNum: 10,
  50. rowList: [10, 30, 50],
  51. rownumbers: true,
  52. rownumWidth: 25,
  53. autowidth: true,
  54. multiselect: true,
  55. pager: "#jqGridPager",
  56. jsonReader: {
  57. root: "page.list",
  58. page: "page.currPage",
  59. total: "page.totalPage",
  60. records: "page.totalCount"
  61. },
  62. prmNames: {
  63. page: "page",
  64. rows: "limit",
  65. order: "order"
  66. },
  67. gridComplete: function () {
  68. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  69. }
  70. });
  71. });
  72. let vm = new Vue({
  73. el: '#rrapp',
  74. data: {
  75. showList: true,
  76. title: null,
  77. categories: [],//积分类型
  78. isValidMsgCategories: [],//是否一致
  79. brands: [],
  80. brandsIsValid:[],
  81. categoriesTwo: [],
  82. isValidMsgCategoriesTwo:[],
  83. macros: [],//积分类型
  84. mall2PointsRules: {},
  85. ruleValidate: {
  86. name: [
  87. {required: true, message: '名称不能为空', trigger: 'blur'}
  88. ]
  89. },
  90. q: {
  91. name: ''
  92. },
  93. categoryObj: [
  94. {
  95. id : 0,
  96. name : '门店'
  97. },
  98. {
  99. id : 1,
  100. name : '商品类别'
  101. },
  102. {
  103. id : 2,
  104. name : '门店商品'
  105. }
  106. ]
  107. },
  108. methods: {
  109. query: function () {
  110. vm.reload(1);
  111. },
  112. add: function () {
  113. vm.showList = false;
  114. vm.title = "新增";
  115. vm.mall2PointsRules = {};
  116. vm.isValidMsgCategories=[],
  117. vm.brands=[],
  118. vm.getCategories();
  119. vm.getIsValiDCategories();
  120. },
  121. update: function (event) {
  122. let mprId = getSelectedRow();
  123. if (mprId == null) {
  124. return;
  125. }
  126. vm.showList = false;
  127. vm.title = "修改";
  128. vm.getCategories();
  129. vm.getIsValiDCategories();
  130. vm.getInfo(mprId)
  131. },
  132. saveOrUpdate: function (event) {
  133. let url = vm.mall2PointsRules.mprId == null ? "../mall2pointsrules/save" : "../mall2pointsrules/update";
  134. var pointsBeginTime=vm.mall2PointsRules.pointsBeginTime;
  135. var pointsEndTime=vm.mall2PointsRules.pointsEndTime;
  136. vm.mall2PointsRules.pointsBeginTime=vm.mall2PointsRules.pointsBeginTime.replaceAll("T"," ")+":00";
  137. vm.mall2PointsRules.pointsEndTime=vm.mall2PointsRules.pointsEndTime.replaceAll("T"," ")+":00";
  138. $.ajax({
  139. type: "POST",
  140. url: url,
  141. contentType: "application/json",
  142. data: JSON.stringify(vm.mall2PointsRules),
  143. success: function (r) {
  144. if (r.code === 0) {
  145. alert('操作成功', function (index) {
  146. vm.reload();
  147. });
  148. } else {
  149. alert(r.msg);
  150. }
  151. }
  152. });
  153. //修改会出现问题
  154. if (vm.mall2PointsRules.mprId != null){
  155. vm.mall2PointsRules.pointsBeginTime=pointsBeginTime.replaceAll(" ","T");
  156. vm.mall2PointsRules.pointsEndTime=pointsEndTime.replaceAll(" ","T");
  157. }
  158. },
  159. // 管理商品
  160. showMkactivitiesGoods: function(mkaId){
  161. var url = "/mk/mall2RulesDetil.html"
  162. window.location.href = url+"?flag=false&mkaId="+mkaId;
  163. },
  164. del: function (event) {
  165. let mprIds = getSelectedRows();
  166. if (mprIds == null){
  167. return;
  168. }
  169. confirm('确定要删除选中的记录?', function () {
  170. $.ajax({
  171. type: "POST",
  172. url: "../mall2pointsrules/delete",
  173. contentType: "application/json",
  174. data: JSON.stringify(mprIds),
  175. success: function (r) {
  176. if (r.code == 0) {
  177. alert('操作成功', function (index) {
  178. $("#jqGrid").trigger("reloadGrid");
  179. });
  180. } else {
  181. alert(r.msg);
  182. }
  183. }
  184. });
  185. });
  186. },
  187. getInfo: function(mprId){
  188. $.get("../mall2pointsrules/info/"+mprId, function (r) {
  189. vm.mall2PointsRules = r.mall2PointsRules;
  190. vm.mall2PointsRules.pointsBeginTime=r.mall2PointsRules.pointsBeginTime.replaceAll(" ","T");
  191. vm.mall2PointsRules.pointsEndTime=r.mall2PointsRules.pointsEndTime.replaceAll(" ","T");
  192. });
  193. },
  194. reloadSearch: function() {
  195. vm.q = {
  196. name: ''
  197. }
  198. vm.reload();
  199. },
  200. getCategories: function () {
  201. $.get("../sys/macro/queryMacrosByValueRuRules?id=70", function (r) {
  202. vm.categories = r.list;
  203. });
  204. },
  205. getBrand: function () {
  206. $.get("../sys/macro/queryMacrosByValueRuRules?id=70" , function (r) {
  207. vm.brands = r.list;
  208. });
  209. },
  210. getIsValiDCategories: function () {
  211. $.get("../sys/macro/queryMacrosByValueRuRules?id=79", function (r) {
  212. vm.isValidMsgCategories = r.list;
  213. });
  214. },
  215. reload: function (event) {
  216. vm.showList = true;
  217. let page = event;
  218. if (event != 1) {
  219. page = $("#jqGrid").jqGrid('getGridParam', 'page');
  220. }
  221. $("#jqGrid").jqGrid('setGridParam', {
  222. postData: {'name': vm.q.name},
  223. page: page
  224. }).trigger("reloadGrid");
  225. vm.handleReset('formValidate');
  226. },
  227. handleSubmit: function (name) {
  228. handleSubmitValidate(this, name, function () {
  229. vm.saveOrUpdate()
  230. });
  231. },
  232. handleReset: function (name) {
  233. handleResetForm(this, name);
  234. }
  235. },
  236. mounted() {
  237. $.get("../sys/macro/queryMacrosByValueRuRules?id=70", function (r) {
  238. vm.macros = r.list;
  239. });
  240. }
  241. });