mkactivitiesscore.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. $(function () {
  2. let flag = getQueryString("flag");
  3. if(flag != null && flag == "false"){
  4. vm.isMkactivitiesShow = false;
  5. }
  6. let mkCode = getQueryString("mkCode");
  7. if(mkCode){
  8. vm.mkCode = mkCode;
  9. }
  10. let storeId = getQueryString("storeId");
  11. console.log(storeId);
  12. if(storeId){
  13. vm.storeId = storeId;
  14. }
  15. let mkaId = getQueryString("mkaId");
  16. if(mkaId){
  17. vm.mkaId = mkaId;
  18. }
  19. $("#jqGrid").jqGrid({
  20. url: '../mkactivitiesscore/list',
  21. datatype: "json",
  22. colModel: [
  23. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  24. {label: '商品条码', name: 'prodBarcode', index: 'prod_barcode', width: 80},
  25. {label: 'sku', name: 'sku', index: 'sku', width: 80},
  26. {label: '门店id', name: 'storeId', index: 'store_id', width: 80},
  27. {label: '抵扣比例', name: 'scoreLimit', index: 'score_limit', width: 80},
  28. {label: '营销活动编号', name: 'mkaId', index: 'mka_id', width: 80},
  29. {label: '截止日期', name: 'deadline', index: 'deadline', width: 80},
  30. {label: '创建时间', name: 'createTime', index: 'create_time', width: 80},
  31. {label: '创建人编号', name: 'createrSn', index: 'creater_sn', width: 80},
  32. {label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 80},
  33. {label: '修改时间', name: 'updateTime', index: 'update_time', width: 80}],
  34. viewrecords: true,
  35. postData: {'mkaId': vm.mkaId},
  36. height: 550,
  37. rowNum: 10,
  38. rowList: [10, 30, 50],
  39. rownumbers: true,
  40. rownumWidth: 25,
  41. autowidth: true,
  42. multiselect: true,
  43. pager: "#jqGridPager",
  44. jsonReader: {
  45. root: "page.list",
  46. page: "page.currPage",
  47. total: "page.totalPage",
  48. records: "page.totalCount"
  49. },
  50. prmNames: {
  51. page: "page",
  52. rows: "limit",
  53. order: "order"
  54. },
  55. gridComplete: function () {
  56. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  57. }
  58. });
  59. });
  60. let vm = new Vue({
  61. el: '#rrapp',
  62. data: {
  63. showList: true,
  64. title: null,
  65. mkActivitiesScore: {},
  66. ruleValidate: {
  67. name: [
  68. {required: true, message: '名称不能为空', trigger: 'blur'}
  69. ]
  70. },
  71. q: {
  72. name: ''
  73. },
  74. isMkactivitiesShow: true,
  75. mkCode: '',
  76. uploadData:[],
  77. storeId : '',
  78. mkaId : ''
  79. },
  80. methods: {
  81. query: function () {
  82. vm.reload();
  83. },
  84. add: function () {
  85. vm.showList = false;
  86. vm.title = "新增";
  87. vm.mkActivitiesScore = {};
  88. },
  89. update: function (event) {
  90. let id = getSelectedRow();
  91. if (id == null) {
  92. return;
  93. }
  94. vm.showList = false;
  95. vm.title = "修改";
  96. vm.getInfo(id)
  97. },
  98. saveOrUpdate: function (event) {
  99. let url = vm.mkActivitiesScore.id == null ? "../mkactivitiesscore/save" : "../mkactivitiesscore/update";
  100. //添加上层的门店编号与营销方式编号
  101. vm.mkActivitiesHalfPrice.shopSn = vm.storeId;
  102. vm.mkActivitiesHalfPrice.mkaId = vm.mkaId;
  103. $.ajax({
  104. type: "POST",
  105. url: url,
  106. contentType: "application/json",
  107. data: JSON.stringify(vm.mkActivitiesScore),
  108. success: function (r) {
  109. if (r.code === 0) {
  110. alert('操作成功', function (index) {
  111. vm.reload();
  112. });
  113. } else {
  114. alert(r.msg);
  115. }
  116. }
  117. });
  118. },
  119. del: function (event) {
  120. let ids = getSelectedRows();
  121. if (ids == null){
  122. return;
  123. }
  124. confirm('确定要删除选中的记录?', function () {
  125. $.ajax({
  126. type: "POST",
  127. url: "../mkactivitiesscore/delete",
  128. contentType: "application/json",
  129. data: JSON.stringify(ids),
  130. success: function (r) {
  131. if (r.code == 0) {
  132. alert('操作成功', function (index) {
  133. $("#jqGrid").trigger("reloadGrid");
  134. });
  135. } else {
  136. alert(r.msg);
  137. }
  138. }
  139. });
  140. });
  141. },
  142. getInfo: function(id){
  143. $.get("../mkactivitiesscore/info/"+id, function (r) {
  144. vm.mkActivitiesScore = r.mkActivitiesScore;
  145. });
  146. },
  147. reloadSearch: function() {
  148. vm.q = {
  149. name: ''
  150. }
  151. vm.reload();
  152. },
  153. reload: function (event) {
  154. vm.showList = true;
  155. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  156. $("#jqGrid").jqGrid('setGridParam', {
  157. postData: {'name': vm.q.name},
  158. page: page
  159. }).trigger("reloadGrid");
  160. vm.handleReset('formValidate');
  161. },
  162. handleSubmit: function (name) {
  163. handleSubmitValidate(this, name, function () {
  164. vm.saveOrUpdate()
  165. });
  166. },
  167. handleReset: function (name) {
  168. handleResetForm(this, name);
  169. },
  170. //返回营销方式页
  171. reloadMkactivities: function () {
  172. window.location.href = "/mk/mkactivityform.html?mkCode="+vm.mkCode;
  173. },
  174. uploadExcelSuccess: function (data) {
  175. // console.log(data);
  176. if(data.code==0){
  177. alert('导入成功', function (index) {
  178. $("#jqGrid").trigger("reloadGrid");
  179. });
  180. }else{
  181. alert(data.msg);
  182. }
  183. },
  184. uploadExcelError: function () {
  185. alert('上传出现异常,请重试!');
  186. },
  187. uploadExcelFormatError: function (file) {
  188. this.$Notice.warning({
  189. title: '文件格式不正确',
  190. desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
  191. });
  192. },beforeUpload(){
  193. vm.uploadData = {
  194. storeId: vm.storeId,
  195. mkaId : vm.mkaId
  196. }
  197. let promise = new Promise((resolve) => {
  198. this.$nextTick(function () {
  199. resolve(true);
  200. });
  201. });
  202. return promise; //通过返回一个promis对象解决
  203. }
  204. }
  205. });