1
0

mkactivitiesassociation.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../mkactivitiesassociation/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'mkaaId', name: 'mkaaId', index: 'mkaa_id', key: true, hidden: true},
  7. {label: '活动形式代码', name: 'mkCode', index: 'mk_code', width: 80},
  8. {label: '营销活动编号', name: 'mkaId', index: 'mka_id', width: 80},
  9. {label: '活动门店id', name: 'mkaStoreId', index: 'mka_store_id', width: 80},
  10. {label: '是否启用', name: 'mkaStatus', index: 'mka_status', width: 80},
  11. {label: '开始时间', name: 'mkaStartTime', index: 'mka_start_time', width: 80},
  12. {label: '结束时间', name: 'mkdEndTime', index: 'mkd_end_time', width: 80},
  13. {label: '是否提前结束', name: 'mkaEndEarly', index: 'mka_end_early', width: 80},
  14. {label: '提前结束时间', name: 'mkdEndEarlyTime', index: 'mkd_end_early_time', width: 80}],
  15. viewrecords: true,
  16. height: 550,
  17. rowNum: 10,
  18. rowList: [10, 30, 50],
  19. rownumbers: true,
  20. rownumWidth: 25,
  21. autowidth: true,
  22. multiselect: true,
  23. pager: "#jqGridPager",
  24. jsonReader: {
  25. root: "page.list",
  26. page: "page.currPage",
  27. total: "page.totalPage",
  28. records: "page.totalCount"
  29. },
  30. prmNames: {
  31. page: "page",
  32. rows: "limit",
  33. order: "order"
  34. },
  35. gridComplete: function () {
  36. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  37. }
  38. });
  39. });
  40. let vm = new Vue({
  41. el: '#rrapp',
  42. data: {
  43. showList: true,
  44. title: null,
  45. mkActivitiesAssociation: {},
  46. ruleValidate: {
  47. name: [
  48. {required: true, message: '名称不能为空', trigger: 'blur'}
  49. ]
  50. },
  51. q: {
  52. name: ''
  53. }
  54. },
  55. methods: {
  56. query: function () {
  57. vm.reload();
  58. },
  59. add: function () {
  60. vm.showList = false;
  61. vm.title = "新增";
  62. vm.mkActivitiesAssociation = {};
  63. },
  64. update: function (event) {
  65. let mkaaId = getSelectedRow();
  66. if (mkaaId == null) {
  67. return;
  68. }
  69. vm.showList = false;
  70. vm.title = "修改";
  71. vm.getInfo(mkaaId)
  72. },
  73. saveOrUpdate: function (event) {
  74. let url = vm.mkActivitiesAssociation.mkaaId == null ? "../mkactivitiesassociation/save" : "../mkactivitiesassociation/update";
  75. $.ajax({
  76. type: "POST",
  77. url: url,
  78. contentType: "application/json",
  79. data: JSON.stringify(vm.mkActivitiesAssociation),
  80. success: function (r) {
  81. if (r.code === 0) {
  82. alert('操作成功', function (index) {
  83. vm.reload();
  84. });
  85. } else {
  86. alert(r.msg);
  87. }
  88. }
  89. });
  90. },
  91. del: function (event) {
  92. let mkaaIds = getSelectedRows();
  93. if (mkaaIds == null){
  94. return;
  95. }
  96. confirm('确定要删除选中的记录?', function () {
  97. $.ajax({
  98. type: "POST",
  99. url: "../mkactivitiesassociation/delete",
  100. contentType: "application/json",
  101. data: JSON.stringify(mkaaIds),
  102. success: function (r) {
  103. if (r.code == 0) {
  104. alert('操作成功', function (index) {
  105. $("#jqGrid").trigger("reloadGrid");
  106. });
  107. } else {
  108. alert(r.msg);
  109. }
  110. }
  111. });
  112. });
  113. },
  114. getInfo: function(mkaaId){
  115. $.get("../mkactivitiesassociation/info/"+mkaaId, function (r) {
  116. vm.mkActivitiesAssociation = r.mkActivitiesAssociation;
  117. });
  118. },
  119. reloadSearch: function() {
  120. vm.q = {
  121. name: ''
  122. }
  123. vm.reload();
  124. },
  125. reload: function (event) {
  126. vm.showList = true;
  127. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  128. $("#jqGrid").jqGrid('setGridParam', {
  129. postData: {'name': vm.q.name},
  130. page: page
  131. }).trigger("reloadGrid");
  132. vm.handleReset('formValidate');
  133. },
  134. handleSubmit: function (name) {
  135. handleSubmitValidate(this, name, function () {
  136. vm.saveOrUpdate()
  137. });
  138. },
  139. handleReset: function (name) {
  140. handleResetForm(this, name);
  141. }
  142. }
  143. });