1
0

mk2goodstopicprice.js 5.2 KB

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