storetopic.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../storetopic/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '活动主题', name: 'title', index: 'title', align: 'center',width: 200},
  8. {label: '活动内容', name: 'content', index: 'content',align: 'center', width: 200},
  9. // {label: '活动图片', name: 'itemPicUrl', index: 'item_pic_url', width: 80},
  10. {label: '子标题', name: 'subtitle', index: 'subtitle', align: 'center',width: 200},
  11. {label: '活动类别名称', name: 'promTypeName', index: 'prom_type_id',align: 'center', width: 200},
  12. // {label: '活动价格', name: 'priceInfo', index: 'price_info', width: 80},
  13. // {label: '场景图片链接', name: 'scenePicUrl', index: 'scene_pic_url', width: 80},
  14. {label: '门店名称', name: 'storeName', index: 'store_id', align: 'center',width: 200},
  15. {label: '第三方商户名称', name: 'thirdPartyMerchName', index: 'third_merch_sn',align: 'center', width: 200},
  16. {label: '是否有效', name: 'isValid', index: 'is_valid', width: 80, align: 'center',
  17. formatter: function (value) {
  18. if (value == '0') {
  19. return '有效';
  20. } else if (value == '1') {
  21. return '无效';
  22. }
  23. return '-';
  24. }
  25. },
  26. {label: '备注', name: 'note', index: 'note', width: 200},
  27. ],
  28. viewrecords: true,
  29. height: 550,
  30. rowNum: 10,
  31. rowList: [10, 30, 50],
  32. rownumbers: true,
  33. rownumWidth: 25,
  34. autowidth: true,
  35. shrinkToFit: false,
  36. autoScroll: true, //开启水平滚动条
  37. width: 1500,
  38. pager: "#jqGridPager",
  39. jsonReader: {
  40. root: "page.list",
  41. page: "page.currPage",
  42. total: "page.totalPage",
  43. records: "page.totalCount"
  44. },
  45. prmNames: {
  46. page: "page",
  47. rows: "limit",
  48. order: "order"
  49. },
  50. gridComplete: function () {
  51. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  52. }
  53. });
  54. });
  55. let vm = new Vue({
  56. el: '#rrapp',
  57. data: {
  58. showList: true,
  59. title: null,
  60. storeTopic: {},
  61. ruleValidate: {
  62. name: [
  63. {required: true, message: '名称不能为空', trigger: 'blur'}
  64. ]
  65. },
  66. q: {
  67. name: ''
  68. }
  69. },
  70. methods: {
  71. query: function () {
  72. vm.reload();
  73. },
  74. add: function () {
  75. vm.showList = false;
  76. vm.title = "新增";
  77. vm.storeTopic = {};
  78. },
  79. update: function (event) {
  80. let id = getSelectedRow();
  81. if (id == null) {
  82. return;
  83. }
  84. vm.showList = false;
  85. vm.title = "修改";
  86. vm.getInfo(id)
  87. },
  88. saveOrUpdate: function (event) {
  89. let url = vm.storeTopic.id == null ? "../storetopic/save" : "../storetopic/update";
  90. $.ajax({
  91. type: "POST",
  92. url: url,
  93. contentType: "application/json",
  94. data: JSON.stringify(vm.storeTopic),
  95. success: function (r) {
  96. if (r.code === 0) {
  97. alert('操作成功', function (index) {
  98. vm.reload();
  99. });
  100. } else {
  101. alert(r.msg);
  102. }
  103. }
  104. });
  105. },
  106. del: function (event) {
  107. let ids = getSelectedRows();
  108. if (ids == null){
  109. return;
  110. }
  111. confirm('确定要删除选中的记录?', function () {
  112. $.ajax({
  113. type: "POST",
  114. url: "../storetopic/delete",
  115. contentType: "application/json",
  116. data: JSON.stringify(ids),
  117. success: function (r) {
  118. if (r.code == 0) {
  119. alert('操作成功', function (index) {
  120. $("#jqGrid").trigger("reloadGrid");
  121. });
  122. } else {
  123. alert(r.msg);
  124. }
  125. }
  126. });
  127. });
  128. },
  129. getInfo: function(id){
  130. $.get("../storetopic/info/"+id, function (r) {
  131. vm.storeTopic = r.storeTopic;
  132. });
  133. },
  134. reloadSearch: function() {
  135. vm.q = {
  136. name: ''
  137. }
  138. vm.reload();
  139. },
  140. reload: function (event) {
  141. vm.showList = true;
  142. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  143. $("#jqGrid").jqGrid('setGridParam', {
  144. postData: {'name': vm.q.name},
  145. page: page
  146. }).trigger("reloadGrid");
  147. vm.handleReset('formValidate');
  148. },
  149. handleSubmit: function (name) {
  150. handleSubmitValidate(this, name, function () {
  151. vm.saveOrUpdate()
  152. });
  153. },
  154. handleReset: function (name) {
  155. handleResetForm(this, name);
  156. }
  157. }
  158. });