storetopic.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: 80},
  8. {label: '活动内容', name: 'content', index: 'content',align: 'center', width: 80},
  9. // {label: '活动图片', name: 'itemPicUrl', index: 'item_pic_url', width: 80},
  10. {label: '子标题', name: 'subtitle', index: 'subtitle', align: 'center',width: 80},
  11. {label: '活动类别名称', name: 'promTypeName', index: 'prom_type_id',align: 'center', width: 80},
  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: 80},
  15. {label: '第三方商户名称', name: 'thirdPartyMerchName', index: 'third_merch_sn',align: 'center', width: 80},
  16. {label: '是否有效', name: 'isValid', index: 'is_valid', width: 50, 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: 80},
  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. multiselect: true,
  36. pager: "#jqGridPager",
  37. jsonReader: {
  38. root: "page.list",
  39. page: "page.currPage",
  40. total: "page.totalPage",
  41. records: "page.totalCount"
  42. },
  43. prmNames: {
  44. page: "page",
  45. rows: "limit",
  46. order: "order"
  47. },
  48. gridComplete: function () {
  49. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  50. }
  51. });
  52. });
  53. let vm = new Vue({
  54. el: '#rrapp',
  55. data: {
  56. showList: true,
  57. title: null,
  58. storeTopic: {},
  59. ruleValidate: {
  60. name: [
  61. {required: true, message: '名称不能为空', trigger: 'blur'}
  62. ]
  63. },
  64. q: {
  65. name: ''
  66. }
  67. },
  68. methods: {
  69. query: function () {
  70. vm.reload();
  71. },
  72. add: function () {
  73. vm.showList = false;
  74. vm.title = "新增";
  75. vm.storeTopic = {};
  76. },
  77. update: function (event) {
  78. let id = getSelectedRow();
  79. if (id == null) {
  80. return;
  81. }
  82. vm.showList = false;
  83. vm.title = "修改";
  84. vm.getInfo(id)
  85. },
  86. saveOrUpdate: function (event) {
  87. let url = vm.storeTopic.id == null ? "../storetopic/save" : "../storetopic/update";
  88. $.ajax({
  89. type: "POST",
  90. url: url,
  91. contentType: "application/json",
  92. data: JSON.stringify(vm.storeTopic),
  93. success: function (r) {
  94. if (r.code === 0) {
  95. alert('操作成功', function (index) {
  96. vm.reload();
  97. });
  98. } else {
  99. alert(r.msg);
  100. }
  101. }
  102. });
  103. },
  104. del: function (event) {
  105. let ids = getSelectedRows();
  106. if (ids == null){
  107. return;
  108. }
  109. confirm('确定要删除选中的记录?', function () {
  110. $.ajax({
  111. type: "POST",
  112. url: "../storetopic/delete",
  113. contentType: "application/json",
  114. data: JSON.stringify(ids),
  115. success: function (r) {
  116. if (r.code == 0) {
  117. alert('操作成功', function (index) {
  118. $("#jqGrid").trigger("reloadGrid");
  119. });
  120. } else {
  121. alert(r.msg);
  122. }
  123. }
  124. });
  125. });
  126. },
  127. getInfo: function(id){
  128. $.get("../storetopic/info/"+id, function (r) {
  129. vm.storeTopic = r.storeTopic;
  130. });
  131. },
  132. reloadSearch: function() {
  133. vm.q = {
  134. name: ''
  135. }
  136. vm.reload();
  137. },
  138. reload: function (event) {
  139. vm.showList = true;
  140. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  141. $("#jqGrid").jqGrid('setGridParam', {
  142. postData: {'name': vm.q.name},
  143. page: page
  144. }).trigger("reloadGrid");
  145. vm.handleReset('formValidate');
  146. },
  147. handleSubmit: function (name) {
  148. handleSubmitValidate(this, name, function () {
  149. vm.saveOrUpdate()
  150. });
  151. },
  152. handleReset: function (name) {
  153. handleResetForm(this, name);
  154. }
  155. }
  156. });