goodstransportinfodetail.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../goodstransportinfodetail/searchListByStatusAndSku',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'transItemId', name: 'transItemId', index: 'trans_item_id', key: true, hidden: true},
  7. {label: '是否在途', name: 'wayStatus', index: 'way_status', width: 100,align: 'center',formatter: function (value) {
  8. if (value == '0') {
  9. return '是(0)';
  10. } else if(value == '1'){
  11. return '否(1)';
  12. }
  13. }},
  14. {label: '商品sku', name: 'sku', index: 'sku', width: 180},
  15. {label: '供应商id', name: 'supplierId', index: 'supplier_id', width: 120},
  16. {label: '原产地', name: 'originCountry', index: 'origin_country', align: 'center',width: 120},
  17. {label: '数量', name: 'num', index: 'num', align: 'right',width: 120},
  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. goodsTransportInfoDetail: {},
  53. ruleValidate: {
  54. sku:{required: true, message: 'sku不能为空', trigger: 'blur'},
  55. // supplierId:{required: true, message: '供应商id不能为空', trigger: 'blur'},
  56. // originCountry:{required: true, message: '原产地不能为空', trigger: 'blur'},
  57. // num:{required: true, message: '数量不能为空', trigger: 'blur'}
  58. },
  59. q: {
  60. wayStatus: null,
  61. sku: null
  62. }
  63. },
  64. methods: {
  65. query: function () {
  66. vm.reload();
  67. },
  68. add: function () {
  69. vm.showList = false;
  70. vm.title = "新增";
  71. vm.goodsTransportInfoDetail = {};
  72. },
  73. update: function (event) {
  74. let transItemId = getSelectedRow();
  75. if (transItemId == null) {
  76. return;
  77. }
  78. vm.showList = false;
  79. vm.title = "修改";
  80. vm.getInfo(transItemId)
  81. },
  82. saveOrUpdate: function (event) {
  83. var re = /^[1-9]+[0-9]*]*$/;
  84. if (!re.test(vm.goodsTransportInfoDetail.num)) {
  85. alert("数量请输入数字");
  86. return false;
  87. }
  88. if (!re.test(vm.goodsTransportInfoDetail.supplierId)) {
  89. alert("供应商id请输入数字");
  90. return false;
  91. }
  92. let url = vm.goodsTransportInfoDetail.transItemId == null ? "../goodstransportinfodetail/save" : "../goodstransportinfodetail/update";
  93. $.ajax({
  94. type: "POST",
  95. url: url,
  96. contentType: "application/json",
  97. data: JSON.stringify(vm.goodsTransportInfoDetail),
  98. success: function (r) {
  99. if (r.code === 0) {
  100. alert('操作成功', function (index) {
  101. vm.reload();
  102. });
  103. } else {
  104. alert(r.msg);
  105. }
  106. }
  107. });
  108. },
  109. del: function (event) {
  110. let transItemIds = getSelectedRows();
  111. if (transItemIds == null){
  112. return;
  113. }
  114. confirm('确定要删除选中的记录?', function () {
  115. $.ajax({
  116. type: "POST",
  117. url: "../goodstransportinfodetail/delete",
  118. contentType: "application/json",
  119. data: JSON.stringify(transItemIds),
  120. success: function (r) {
  121. if (r.code == 0) {
  122. alert('操作成功', function (index) {
  123. $("#jqGrid").trigger("reloadGrid");
  124. });
  125. } else {
  126. alert(r.msg);
  127. }
  128. }
  129. });
  130. });
  131. },
  132. getInfo: function(transItemId){
  133. $.get("../goodstransportinfodetail/info/"+transItemId, function (r) {
  134. vm.goodsTransportInfoDetail = r.goodsTransportInfoDetail;
  135. });
  136. },
  137. reloadSearch: function() {
  138. vm.q = {
  139. wayStatus: null,
  140. sku: null
  141. }
  142. vm.reload();
  143. },
  144. reload: function (event) {
  145. vm.showList = true;
  146. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  147. $("#jqGrid").jqGrid('setGridParam', {
  148. postData: {'sku': vm.q.sku,'wayStatus' : vm.q.wayStatus},
  149. page: page
  150. }).trigger("reloadGrid");
  151. vm.handleReset('formValidate');
  152. },
  153. handleSubmit: function (name) {
  154. handleSubmitValidate(this, name, function () {
  155. vm.saveOrUpdate()
  156. });
  157. },
  158. handleReset: function (name) {
  159. handleResetForm(this, name);
  160. },
  161. uploadExcelSuccess: function () {
  162. alert('上传成功', function (index) {
  163. $("#jqGrid").trigger("reloadGrid");
  164. });
  165. },
  166. uploadExcelError: function () {
  167. alert('上传出现异常');
  168. },
  169. uploadExcelSuccess: function (data) {
  170. if(data.code==0){
  171. alert('导入成功', function (index) {
  172. vm.reload();
  173. });
  174. }else{
  175. if(data.msg == '导入成功!'){
  176. alert(data.msg);
  177. vm.reload();
  178. }else {
  179. alert(data.msg);
  180. }
  181. }
  182. },
  183. uploadExcelError: function (data) {
  184. console.log(data);
  185. alert('上传出现异常,请重试!');
  186. },
  187. uploadExcelFormatError: function (file) {
  188. this.$Notice.warning({
  189. title: '文件格式不正确',
  190. desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
  191. });
  192. }
  193. }
  194. });