1
0

goodshistoryprice.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../goodshistoryprice/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, width: 50,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. 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": "scroll"});
  43. }
  44. });
  45. });
  46. let vm = new Vue({
  47. el: '#rrapp',
  48. data: {
  49. showList: true,
  50. title: null,
  51. goodsHistoryPrice: {},
  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.goodsHistoryPrice = {};
  69. },
  70. update: function (event) {
  71. let id = getSelectedRow();
  72. if (id == null) {
  73. return;
  74. }
  75. vm.showList = false;
  76. vm.title = "修改";
  77. vm.getInfo(id)
  78. },
  79. saveOrUpdate: function (event) {
  80. let url = vm.goodsHistoryPrice.id == null ? "../goodshistoryprice/save" : "../goodshistoryprice/update";
  81. $.ajax({
  82. type: "POST",
  83. url: url,
  84. contentType: "application/json",
  85. data: JSON.stringify(vm.goodsHistoryPrice),
  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 ids = getSelectedRows();
  99. if (ids == null){
  100. return;
  101. }
  102. confirm('确定要删除选中的记录?', function () {
  103. $.ajax({
  104. type: "POST",
  105. url: "../goodshistoryprice/delete",
  106. contentType: "application/json",
  107. data: JSON.stringify(ids),
  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(id){
  121. $.get("../goodshistoryprice/info/"+id, function (r) {
  122. vm.goodsHistoryPrice = r.goodsHistoryPrice;
  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: {
  136. 'sku': vm.q.sku,
  137. 'plu': vm.q.plu,
  138. },
  139. page: page
  140. }).trigger("reloadGrid");
  141. vm.handleReset('formValidate');
  142. },
  143. handleSubmit: function (name) {
  144. handleSubmitValidate(this, name, function () {
  145. vm.saveOrUpdate()
  146. });
  147. },
  148. handleReset: function (name) {
  149. handleResetForm(this, name);
  150. }
  151. }
  152. });