goodsbatch.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../goodsbatch/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '批次编号', name: 'batchSn', index: 'batch_sn', width: 280},
  8. {label: 'sku', name: 'sku', index: 'sku', width: 280},
  9. {label: '批次到期日期', name: 'batchExpireDate', index: 'batch_expire_date', align: 'center',width: 280,formatter: function (value) {
  10. return transDate(value,'yyyy-MM-dd hh:mm:ss');
  11. }}
  12. // {label: '', name: 'createrSn', index: 'creater_sn', width: 80},
  13. // {label: '', name: 'createTime', index: 'create_time', width: 80},
  14. // {label: '', name: 'moderSn', index: 'moder_sn', width: 80},
  15. // {label: '', name: 'modTime', index: 'mod_time', width: 80},
  16. // {label: '', name: 'tstm', index: 'tstm', width: 80}
  17. ],
  18. viewrecords: true,
  19. height: 550,
  20. rowNum: 10,
  21. rowList: [10, 30, 50],
  22. rownumbers: true,
  23. rownumWidth: 25,
  24. autowidth: true,
  25. shrinkToFit: false,
  26. autoScroll: true, //开启水平滚动条
  27. width: 1500,
  28. multiselect: 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": "scroll"});
  43. }
  44. });
  45. });
  46. let vm = new Vue({
  47. el: '#rrapp',
  48. data: {
  49. showList: true,
  50. title: null,
  51. goodsBatch: {},
  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.goodsBatch = {};
  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.goodsBatch.id == null ? "../goodsbatch/save" : "../goodsbatch/update";
  81. $.ajax({
  82. type: "POST",
  83. url: url,
  84. contentType: "application/json",
  85. data: JSON.stringify(vm.goodsBatch),
  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: "../goodsbatch/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("../goodsbatch/info/"+id, function (r) {
  122. vm.goodsBatch = r.goodsBatch;
  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. 'batchSn': vm.q.batchSn,
  137. 'sku': vm.q.sku
  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. });