mk2goodstopicprice.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../mk2goodstopicprice/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'mgthpId', name: 'mgthpId', index: 'mgthp_id', key: true, hidden: true},
  7. {label: '活动id', name: 'topicId', index: 'topic_id', align: 'center',width: 120},
  8. {label: '活动类别', name: 'topicType', index: 'topic_type', align: 'center',width: 120},
  9. {label: '活动价格', name: 'topicPrice', index: 'topic_price',align: 'right', width: 80},
  10. {label: '活动名称', name: 'topicName', index: 'topic_name' ,align: 'center',width: 280},
  11. {label: '活动内容', name: 'topicContent', index: 'topic_content', align: 'center',width: 280},
  12. {label: '活动产品', name: 'goodsName', index: 'goodsName', width: 380},
  13. {label: '活动开始时间', name: 'topicBeginTime', index: 'topic_begin_time', width: 160,align: 'center',
  14. formatter: function (value) {
  15. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  16. }},
  17. {label: '活动结束时间', name: 'topicEndTime', index: 'topic_end_time', width: 160,align: 'center',
  18. formatter: function (value) {
  19. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  20. }}
  21. ],
  22. viewrecords: true,
  23. height: 550,
  24. rowNum: 10,
  25. rowList: [10, 30, 50],
  26. rownumbers: true,
  27. rownumWidth: 25,
  28. autowidth: true,
  29. shrinkToFit: false,
  30. autoScroll: true, //开启水平滚动条
  31. width: 1500,
  32. pager: "#jqGridPager",
  33. jsonReader: {
  34. root: "page.list",
  35. page: "page.currPage",
  36. total: "page.totalPage",
  37. records: "page.totalCount"
  38. },
  39. prmNames: {
  40. page: "page",
  41. rows: "limit",
  42. order: "order"
  43. },
  44. gridComplete: function () {
  45. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
  46. }
  47. });
  48. });
  49. let vm = new Vue({
  50. el: '#rrapp',
  51. data: {
  52. showList: true,
  53. title: null,
  54. mk2GoodsTopicPrice: {},
  55. ruleValidate: {
  56. name: [
  57. {required: true, message: '名称不能为空', trigger: 'blur'}
  58. ]
  59. },
  60. q: {
  61. topicName: ''
  62. }
  63. },
  64. methods: {
  65. query: function () {
  66. vm.reload(1);
  67. },
  68. add: function () {
  69. vm.showList = false;
  70. vm.title = "新增";
  71. vm.mk2GoodsTopicPrice = {};
  72. },
  73. update: function (event) {
  74. let mgthpId = getSelectedRow();
  75. if (mgthpId == null) {
  76. return;
  77. }
  78. vm.showList = false;
  79. vm.title = "修改";
  80. vm.getInfo(mgthpId)
  81. },
  82. saveOrUpdate: function (event) {
  83. let url = vm.mk2GoodsTopicPrice.mgthpId == null ? "../mk2goodstopicprice/save" : "../mk2goodstopicprice/update";
  84. $.ajax({
  85. type: "POST",
  86. url: url,
  87. contentType: "application/json",
  88. data: JSON.stringify(vm.mk2GoodsTopicPrice),
  89. success: function (r) {
  90. if (r.code === 0) {
  91. alert('操作成功', function (index) {
  92. vm.reload();
  93. });
  94. } else {
  95. alert(r.msg);
  96. }
  97. }
  98. });
  99. },
  100. del: function (event) {
  101. let mgthpIds = getSelectedRows();
  102. if (mgthpIds == null){
  103. return;
  104. }
  105. confirm('确定要删除选中的记录?', function () {
  106. $.ajax({
  107. type: "POST",
  108. url: "../mk2goodstopicprice/delete",
  109. contentType: "application/json",
  110. data: JSON.stringify(mgthpIds),
  111. success: function (r) {
  112. if (r.code == 0) {
  113. alert('操作成功', function (index) {
  114. $("#jqGrid").trigger("reloadGrid");
  115. });
  116. } else {
  117. alert(r.msg);
  118. }
  119. }
  120. });
  121. });
  122. },
  123. getInfo: function(mgthpId){
  124. $.get("../mk2goodstopicprice/info/"+mgthpId, function (r) {
  125. vm.mk2GoodsTopicPrice = r.mk2GoodsTopicPrice;
  126. });
  127. },
  128. reloadSearch: function() {
  129. vm.q = {
  130. topicName: ''
  131. }
  132. vm.reload();
  133. },
  134. reload: function (event) {
  135. vm.showList = true;
  136. let page = event;
  137. if (event != 1) {
  138. page = $("#jqGrid").jqGrid('getGridParam', 'page');
  139. }
  140. $("#jqGrid").jqGrid('setGridParam', {
  141. postData: {'topicName': vm.q.topicName},
  142. page: page
  143. }).trigger("reloadGrid");
  144. vm.handleReset('formValidate');
  145. },
  146. uploadExcelSuccess: function () {
  147. alert('上传成功', function (index) {
  148. $("#jqGrid").trigger("reloadGrid");
  149. });
  150. },
  151. uploadExcelError: function () {
  152. alert('上传出现异常');
  153. },
  154. uploadExcelSuccess: function (data) {
  155. if(data.code==0){
  156. alert('导入成功', function (index) {
  157. vm.reload();
  158. });
  159. }else{
  160. if(data.msg == '导入成功!'){
  161. alert(data.msg);
  162. vm.reload();
  163. }else {
  164. alert(data.msg);
  165. }
  166. }
  167. },
  168. uploadExcelError: function (data) {
  169. console.log(data);
  170. alert('上传出现异常,请重试!');
  171. },
  172. handleSubmit: function (name) {
  173. handleSubmitValidate(this, name, function () {
  174. vm.saveOrUpdate()
  175. });
  176. },
  177. handleReset: function (name) {
  178. handleResetForm(this, name);
  179. },
  180. uploadExcelFormatError: function (file) {
  181. this.$Notice.warning({
  182. title: '文件格式不正确',
  183. desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
  184. });
  185. }
  186. }
  187. });