1
0

mk2goodstopicprice.js 5.2 KB

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