goodshistoryprice.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../goodshistoryprice/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '商品编码(sku)', name: 'sku', index: 'sku', width: 180},
  8. {label: 'PLU', name: 'plu', index: 'plu', width: 180,align: 'center',formatter: function (value) {
  9. if(!value){
  10. return '-';
  11. }
  12. return value;
  13. }},
  14. {label: '销售价格', name: 'retailPrice', index: 'retail_price',align: 'right', width: 180},
  15. {label: '创建时间', name: 'createTime', index: 'create_time', width: 180 ,align: 'center',formatter: function (value) {
  16. return transDate(value,'yyyy-MM-dd hh:mm:ss');
  17. }}
  18. ],
  19. viewrecords: true,
  20. height: 550,
  21. rowNum: 10,
  22. rowList: [10, 30, 50],
  23. rownumbers: true,
  24. rownumWidth: 25,
  25. autowidth: true,
  26. shrinkToFit: false,
  27. autoScroll: true, //开启水平滚动条
  28. width: 1500,
  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": "scroll"});
  44. }
  45. });
  46. });
  47. let vm = new Vue({
  48. el: '#rrapp',
  49. data: {
  50. showList: true,
  51. title: null,
  52. goodsHistoryPrice: {},
  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.goodsHistoryPrice = {};
  70. },
  71. update: function (event) {
  72. let id = getSelectedRow();
  73. if (id == null) {
  74. return;
  75. }
  76. vm.showList = false;
  77. vm.title = "修改";
  78. vm.getInfo(id)
  79. },
  80. saveOrUpdate: function (event) {
  81. let url = vm.goodsHistoryPrice.id == null ? "../goodshistoryprice/save" : "../goodshistoryprice/update";
  82. $.ajax({
  83. type: "POST",
  84. url: url,
  85. contentType: "application/json",
  86. data: JSON.stringify(vm.goodsHistoryPrice),
  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 ids = getSelectedRows();
  100. if (ids == null){
  101. return;
  102. }
  103. confirm('确定要删除选中的记录?', function () {
  104. $.ajax({
  105. type: "POST",
  106. url: "../goodshistoryprice/delete",
  107. contentType: "application/json",
  108. data: JSON.stringify(ids),
  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(id){
  122. $.get("../goodshistoryprice/info/"+id, function (r) {
  123. vm.goodsHistoryPrice = r.goodsHistoryPrice;
  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: {
  137. 'sku': vm.q.sku,
  138. 'plu': vm.q.plu,
  139. },
  140. page: page
  141. }).trigger("reloadGrid");
  142. vm.handleReset('formValidate');
  143. },
  144. handleSubmit: function (name) {
  145. handleSubmitValidate(this, name, function () {
  146. vm.saveOrUpdate()
  147. });
  148. },
  149. handleReset: function (name) {
  150. handleResetForm(this, name);
  151. }
  152. }
  153. });